async fn handle_oracle_fix(
path: &Path,
max_iterations: usize,
auto_apply_threshold: f32,
review_threshold: f32,
dry_run: bool,
format: OracleOutputFormat,
output: Option<&Path>,
) -> Result<()> {
println!("🔮 PMAT Oracle - PDCA Quality Improvement Loop");
println!(" Path: {}", path.display());
println!(" Max iterations: {}", max_iterations);
println!(
" Thresholds: auto={:.2}, review={:.2}",
auto_apply_threshold, review_threshold
);
if dry_run {
println!(" Mode: DRY RUN (no changes will be applied)");
}
println!();
if !path.exists() {
anyhow::bail!("Project path does not exist: {}", path.display());
}
let config = OracleConfig {
max_iterations,
auto_apply_threshold,
review_threshold,
..Default::default()
};
let targets = ConvergenceTargets::default();
let pdca = PdcaLoop::with_config(config, targets.clone());
if dry_run {
println!("🔍 Dry run: Collecting signals only...\n");
let results = pdca.run_iterations(path, 1).await?;
if let Some(result) = results.first() {
format_iteration_result(result, &format, output)?;
}
} else {
println!("🚀 Starting PDCA loop...\n");
let results = pdca.run(path).await?;
let formatted = format_pdca_results(&results, &targets, format)?;
if let Some(output_path) = output {
std::fs::write(output_path, &formatted)?;
println!("✅ Results written to: {}", output_path.display());
} else {
println!("{}", formatted);
}
}
Ok(())
}
async fn handle_oracle_status(path: &Path, format: OracleOutputFormat) -> Result<()> {
println!("📊 PMAT Oracle - Project Quality Status");
println!(" Path: {}", path.display());
println!();
if !path.exists() {
anyhow::bail!("Project path does not exist: {}", path.display());
}
let targets = ConvergenceTargets::default();
let metrics = collect_project_metrics(path).await?;
let status = targets.check(&metrics);
let formatted = format_status(&metrics, &targets, &status, format)?;
println!("{}", formatted);
Ok(())
}
async fn handle_oracle_single(
path: &Path,
format: OracleOutputFormat,
output: Option<&Path>,
) -> Result<()> {
println!("⚡ PMAT Oracle - Single PDCA Iteration");
println!(" Path: {}", path.display());
println!();
if !path.exists() {
anyhow::bail!("Project path does not exist: {}", path.display());
}
let pdca = PdcaLoop::new();
let result = pdca.run_single(path).await?;
let formatted = format_single_result(&result, format)?;
if let Some(output_path) = output {
std::fs::write(output_path, &formatted)?;
println!("✅ Results written to: {}", output_path.display());
} else {
println!("{}", formatted);
}
Ok(())
}
async fn collect_project_metrics(_path: &Path) -> Result<ProjectMetrics> {
Ok(ProjectMetrics::default())
}