1#![forbid(unsafe_code)]
2
3mod cmds;
4pub mod output;
5pub mod progress;
6
7use clap::{Parser, Subcommand};
8use std::process::ExitCode;
9
10#[derive(Parser)]
11#[command(
12 name = "argyph",
13 version = env!("CARGO_PKG_VERSION"),
14 about = "Semantic code indexer for AI agents",
15 long_about = "Indexes repositories into a hybrid symbol-graph + embedding store and serves queries via MCP or CLI."
16)]
17pub struct Cli {
18 #[command(subcommand)]
19 pub command: Command,
20}
21
22#[derive(Subcommand)]
23pub enum Command {
24 #[command(about = "Start the MCP server on stdio")]
25 Serve,
26 #[command(about = "Index a repository")]
27 Index,
28 #[command(about = "Show indexing status")]
29 Status,
30 #[command(about = "Search indexed code")]
31 Search {
32 #[arg(help = "Natural-language or structured query")]
33 query: String,
34 },
35 #[command(about = "List extracted symbols")]
36 Symbols {
37 #[arg(help = "Optional path filter")]
38 path: Option<String>,
39 },
40 #[command(about = "Export the symbol graph")]
41 Graph {
42 #[arg(help = "Optional path to limit the graph")]
43 path: Option<String>,
44 },
45 #[command(about = "Pack a repository for AI consumption")]
46 Pack {
47 #[arg(help = "Path to the repository root")]
48 path: String,
49 },
50 #[command(about = "Print environment diagnostics")]
51 Doctor,
52 #[command(about = "Install Argyph agent lookup instructions")]
53 Init {
54 #[arg(help = "Directory to initialize in (defaults to cwd)")]
55 path: Option<String>,
56 },
57}
58
59pub fn dispatch(command: Command) -> ExitCode {
60 match command {
61 Command::Serve => cmds::serve::run(),
62 Command::Index => cmds::index::run(),
63 Command::Status => cmds::status::run(),
64 Command::Search { query } => cmds::search::run(&query),
65 Command::Symbols { path } => cmds::symbols::run(path.as_deref()),
66 Command::Graph { path } => cmds::graph::run(path.as_deref()),
67 Command::Pack { path } => cmds::pack::run(&path),
68 Command::Doctor => cmds::doctor::run(),
69 Command::Init { path } => cmds::init::run(path.as_deref()),
70 }
71}