kodegraf-cli 0.1.0

Structural code intelligence for AI coding assistants — CLI
use anyhow::Result;
use kodegraf_core::config::Config;
use kodegraf_core::graph::GraphStore;
use kodegraf_core::models::EdgeKind;

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

    if !db_path.exists() {
        anyhow::bail!("Graph not built. Run `kodegraf init && kodegraf build` first.");
    }

    let store = GraphStore::open(&db_path)?;
    let edges = store.get_edges_for(file)?;

    let imports: Vec<_> = edges
        .iter()
        .filter(|e| e.kind == EdgeKind::ImportsFrom && e.source_qualified == file)
        .collect();

    if imports.is_empty() {
        println!("{} has no tracked dependencies.", file);
        return Ok(());
    }

    println!("Dependencies of {}:", file);
    for edge in &imports {
        println!("{}", edge.target_qualified);
    }

    Ok(())
}