kodegraf-cli 0.1.0

Structural code intelligence for AI coding assistants — CLI
use anyhow::Result;
use kodegraf_core::config::{self, Config};
use kodegraf_core::graph::GraphStore;

pub fn run() -> Result<()> {
    let repo_root = config::find_repo_root()?;
    let config_dir = Config::config_dir(&repo_root);
    let config_path = Config::config_path(&repo_root);
    let db_path = Config::graph_db_path(&repo_root);

    // Create .kodegraf/ directory
    std::fs::create_dir_all(&config_dir)?;

    // Auto-detect and save config
    let config = Config::detect(&repo_root)?;
    config.save(&config_path)?;

    // Create empty graph database
    let _store = GraphStore::open(&db_path)?;

    println!("Initialized Kodegraf in {}", repo_root.display());
    println!();
    println!("  Config:   {}", config_path.strip_prefix(&repo_root).unwrap_or(&config_path).display());
    println!("  Database: {}", db_path.strip_prefix(&repo_root).unwrap_or(&db_path).display());
    println!("  Languages: {}", config.scan.languages.join(", "));
    println!();
    println!("Next steps:");
    println!("  kodegraf build     Build the knowledge graph");
    println!("  kodegraf install   Configure your AI coding tool");

    Ok(())
}