1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
use std::path::PathBuf;
use clap::{Parser, Subcommand};
use crate::model::DetailLevel;
#[derive(Parser, Debug)]
#[command(name = "indxr", version, about = "Fast codebase indexer for AI agents")]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Command>,
/// Root directory to index
#[arg(default_value = ".")]
pub path: PathBuf,
/// Output file path (default: stdout)
#[arg(short, long)]
pub output: Option<PathBuf>,
/// Output format: markdown, json, or yaml
#[arg(short, long, default_value = "markdown")]
pub format: OutputFormat,
/// Detail level: summary, signatures, or full
#[arg(short, long, default_value = "signatures")]
pub detail: DetailLevel,
/// Maximum directory depth to traverse
#[arg(long)]
pub max_depth: Option<usize>,
/// Skip files larger than N kilobytes
#[arg(long, default_value = "512")]
pub max_file_size: u64,
/// Comma-separated list of languages to include
#[arg(short, long, value_delimiter = ',')]
pub languages: Option<Vec<String>>,
/// Additional glob patterns to exclude
#[arg(short, long)]
pub exclude: Option<Vec<String>>,
/// Do not respect .gitignore
#[arg(long)]
pub no_gitignore: bool,
/// Disable incremental caching
#[arg(long)]
pub no_cache: bool,
/// Cache directory
#[arg(long, default_value = ".indxr-cache")]
pub cache_dir: PathBuf,
/// Suppress progress output
#[arg(short, long)]
pub quiet: bool,
/// Print indexing statistics to stderr
#[arg(long)]
pub stats: bool,
// === New filtering options ===
/// Filter to a specific subdirectory path
#[arg(long, value_name = "SUBPATH")]
pub filter_path: Option<String>,
/// Search for a specific symbol by name
#[arg(long)]
pub symbol: Option<String>,
/// Filter by declaration kind (e.g., function, struct, class)
#[arg(long)]
pub kind: Option<String>,
/// Only show public declarations
#[arg(long)]
pub public_only: bool,
// === Git-aware diffing ===
/// Show structural changes since a git ref (branch, tag, or commit)
#[arg(long, value_name = "REF")]
pub since: Option<String>,
// === Token budget ===
/// Maximum tokens in output (approximate, ~4 chars/token)
#[arg(long, value_name = "N")]
pub max_tokens: Option<usize>,
// === Output control ===
/// Omit import listings from output
#[arg(long)]
pub omit_imports: bool,
/// Omit directory tree from output
#[arg(long)]
pub omit_tree: bool,
}
#[derive(Subcommand, Debug)]
pub enum Command {
/// Start MCP (Model Context Protocol) server for AI agent integration
Serve {
/// Root directory to index
#[arg(default_value = ".")]
path: PathBuf,
/// Cache directory
#[arg(long, default_value = ".indxr-cache")]
cache_dir: PathBuf,
/// Skip files larger than N kilobytes
#[arg(long, default_value = "512")]
max_file_size: u64,
/// Maximum directory depth to traverse
#[arg(long)]
max_depth: Option<usize>,
/// Additional glob patterns to exclude
#[arg(short, long)]
exclude: Option<Vec<String>>,
/// Do not respect .gitignore
#[arg(long)]
no_gitignore: bool,
},
}
#[derive(Debug, Clone, clap::ValueEnum)]
pub enum OutputFormat {
Markdown,
Json,
Yaml,
}