agentstatedeveloper_cli/commands/map.rs
1//! `asd map` — initial-read project summary.
2//!
3//! Walks the indexed project, identifies package boundaries, and classifies
4//! test files into `fast-test` vs `diagnostic-test`. Results land as
5//! `Ownership` ledger entries so the next session inherits the project mental
6//! model without re-deriving it. Idempotent: re-running overwrites prior tags.
7//!
8//! The logic lives in `agentstatedeveloper_core::map::run_map` so the `map`
9//! MCP tool shares one implementation with this CLI command.
10
11use anyhow::Result;
12use clap::Args;
13
14use agentstatedeveloper_core::{Engine, map::run_map};
15
16use crate::config::Config;
17
18#[derive(Debug, Args)]
19pub struct MapArgs {
20 /// Dry-run: emit the summary without writing any ledger entries.
21 #[arg(long)]
22 pub dry_run: bool,
23}
24
25pub fn run(cfg: &Config, args: MapArgs) -> Result<()> {
26 let engine = Engine::open_sqlite(&cfg.db_path)?;
27 let db_parent = cfg.db_path.parent();
28 let payload = run_map(&engine, &cfg.agent_id, db_parent, args.dry_run)?;
29 println!("{}", serde_json::to_string_pretty(&payload)?);
30 Ok(())
31}