use anyhow::Result; use colored::Colorize; pub fn init_project(root: &str, out: &str) -> Result<()> { println!("{}", "Initializing archdoc project...".cyan().bold()); let out_path = std::path::Path::new(out); std::fs::create_dir_all(out_path)?; std::fs::create_dir_all(out_path.join("modules"))?; std::fs::create_dir_all(out_path.join("files"))?; let layout_md_path = out_path.join("layout.md"); let layout_md_content = r#"# Repository layout ## Manual overrides - `src/app/` — --- ## Detected structure > Generated. Do not edit inside this block. "#; std::fs::write(&layout_md_path, layout_md_content)?; let architecture_md_content = r#"# ARCHITECTURE — ## Project summary **Name:** **Description:** ## Key decisions (manual) - ## Non-goals (manual) - --- ## Document metadata - **Created:** - **Updated:** - **Generated by:** archdoc (cli) v0.1 --- ## Rails / Tooling > Generated. Do not edit inside this block. --- ## Repository layout (top-level) > Generated. Do not edit inside this block. --- ## Modules index > Generated. Do not edit inside this block. --- ## Critical dependency points > Generated. Do not edit inside this block. --- ## Change notes (manual) - "#; let architecture_md_path = std::path::Path::new(root).join("ARCHITECTURE.md"); std::fs::write(&architecture_md_path, architecture_md_content)?; let config_toml_content = r#"[project] root = "." out_dir = "docs/architecture" entry_file = "ARCHITECTURE.md" language = "python" [scan] include = ["src", "app", "tests"] exclude = [ ".venv", "venv", "__pycache__", ".git", "dist", "build", ".mypy_cache", ".ruff_cache", ".pytest_cache", "*.egg-info" ] follow_symlinks = false max_file_size = "10MB" [python] src_roots = ["src", "."] include_tests = true parse_docstrings = true max_parse_errors = 10 [analysis] resolve_calls = true resolve_inheritance = false detect_integrations = true integration_patterns = [ { type = "http", patterns = ["requests", "httpx", "aiohttp"] }, { type = "db", patterns = ["sqlalchemy", "psycopg", "mysql", "sqlite3"] }, { type = "queue", patterns = ["celery", "kafka", "pika", "redis"] } ] [output] single_file = false per_file_docs = true create_directories = true overwrite_manual_sections = false [diff] update_timestamp_on_change_only = true hash_algorithm = "sha256" preserve_manual_content = true [thresholds] critical_fan_in = 20 critical_fan_out = 20 high_complexity = 50 [rendering] template_engine = "handlebars" max_table_rows = 100 truncate_long_descriptions = true description_max_length = 200 [logging] level = "info" file = "archdoc.log" format = "compact" [caching] enabled = true cache_dir = ".archdoc/cache" max_cache_age = "24h" "#; let config_toml_path = std::path::Path::new(root).join("archdoc.toml"); if !config_toml_path.exists() { std::fs::write(&config_toml_path, config_toml_content)?; } println!("{} Project initialized!", "✓".green().bold()); println!(" {} {}", "→".dimmed(), architecture_md_path.display()); println!(" {} {}", "→".dimmed(), config_toml_path.display()); println!(" {} {} (directory)", "→".dimmed(), out_path.display()); Ok(()) }