use anyhow::Result;
use std::path::Path;
mod features;
mod generator;
mod profile;
mod scanner;
use features::{DevContainerFeature, FeatureMapper};
use generator::Generator;
use profile::RepoProfile;
use scanner::Scanner;
pub fn execute(
interactive: bool,
defaults: bool,
with: Option<Vec<String>>,
without: Option<Vec<String>>,
json: bool,
) -> Result<()> {
println!("🎯 YOLO Mode: Scanning for autonomous workspace setup...");
let work_dir = std::env::current_dir()?;
let scanner = Scanner::new(&work_dir);
let mut profile = scanner.scan()?;
if let Some(with_tools) = with {
for tool in with_tools {
profile.add_tool_override(&tool);
}
}
if let Some(without_tools) = without {
for tool in without_tools {
profile.exclude_tool(&tool);
}
}
if !json {
display_detection_results(&profile);
}
if interactive && !defaults {
profile = run_interactive_mode(profile)?;
}
let mapper = FeatureMapper::new();
let features = mapper.map_profile(&profile)?;
let generator = Generator::new(&work_dir);
generator.generate(&profile, &features)?;
if json {
output_json_results(&profile, &features)?;
} else {
display_success_message(&work_dir);
}
Ok(())
}
fn display_detection_results(profile: &RepoProfile) {
for (lang, info) in &profile.languages {
if let Some(version) = &info.version {
println!(" ✓ Found {} ({})", lang, version);
} else {
println!(" ✓ Found {}", lang);
}
}
for (tool, info) in &profile.tools {
if let Some(version) = &info.version {
println!(" ✓ Found {} ({})", tool, version);
} else {
println!(" ✓ Found {}", tool);
}
}
for service in &profile.services {
println!(" ✓ Found service: {}", service.name);
}
}
fn run_interactive_mode(profile: RepoProfile) -> Result<RepoProfile> {
println!("\n📝 Interactive mode not yet implemented, using defaults...");
Ok(profile)
}
fn output_json_results(profile: &RepoProfile, features: &[DevContainerFeature]) -> Result<()> {
let result = serde_json::json!({
"profile": profile,
"features": features,
"status": "success"
});
println!("{}", serde_json::to_string_pretty(&result)?);
Ok(())
}
fn display_success_message(work_dir: &Path) {
println!("\n🤖 Generating YOLO workspace for AI autonomy...");
println!(" ✓ Created .devcontainer/devcontainer.json");
println!(" ✓ Created .devcontainer/Dockerfile");
println!(" ✓ Created .devcontainer/docker-compose.yml");
println!("\n💭 AI-Ready Features:");
println!(" • Permissions bypass for autonomous work");
println!(" • All detected toolchains installed");
println!(" • Git worktree isolation configured");
println!("\n🚀 Launch: docker compose -f .devcontainer/docker-compose.yml up -d");
println!(
" Then: docker exec -it {}-yolo bash",
work_dir.file_name().unwrap().to_string_lossy()
);
println!(" \n⚡ For Claude Code: claude --dangerously-skip-permissions");
}