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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
use schemars::JsonSchema;
use serde::Deserialize;
// ── Parameter types ───────────────────────────────────────────────────────────
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GcxDispatchParams {
/// Which graph operation to run. One of: lookup_symbol, find_callers, pre_edit_impact,
/// find_callees, find_unused_symbols, get_subgraph, search_code, start_tour, wiki_symbol,
/// trace_path, list_definitions, symbol_context, list_symbols_in_range, graph_stats,
/// ast_search, type_hierarchy, find_importers, find_type_usages, module_dependencies,
/// get_call_sites, find_god_nodes, find_clusters, find_cycles, health_report.
pub action: String,
/// Parameters for the chosen action as a JSON object (same fields as the
/// individual tool: name, function_name, seed_name, query, file, branch,
/// depth, limit, direction, src, dst, start_line, end_line).
pub params: serde_json::Map<String, serde_json::Value>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct LookupSymbolParams {
/// Symbol name to search for (unqualified).
pub name: String,
/// When true, matches any symbol whose name *contains* `name` (substring).
/// When false (default), exact match only.
pub fuzzy: Option<bool>,
/// Branch name (defaults to "main" if omitted).
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindCallersParams {
/// Name of the function/method to find callers of.
pub function_name: String,
/// How many hops to walk up the call graph (1–5, default 1).
/// depth=1 returns direct callers only. depth=3 walks three levels.
pub depth: Option<u8>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct SymbolContextParams {
/// Symbol name to look up (unqualified).
pub name: String,
/// Branch name (defaults to current branch if omitted).
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ListDefinitionsParams {
/// Repo-relative path to a source file.
pub file: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct BranchDiffParams {
pub from_branch: String,
pub to_branch: String,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DetectChangesParams {
/// Branch to query (defaults to "main" if omitted).
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindCalleesParams {
/// Name of the function/method to trace callees of.
pub function_name: String,
/// How many hops to walk forward in the call graph (1–5, default 1).
pub depth: Option<u8>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindImplementorsParams {
/// Trait, interface, or abstract class name to find implementors of.
pub trait_name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct TypeHierarchyParams {
/// Type name (struct/class/trait/interface) to map relationships for.
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindImportersParams {
/// Symbol name to find importers of (the imported thing, unqualified).
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetCallSitesParams {
/// Function/method name to find call sites of.
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindTypeUsagesParams {
/// Type name (struct/class/trait/interface/enum) to find usages of.
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ModuleDependenciesParams {
/// Module name (file stem, e.g. "tools" for tools.rs) to list dependencies of.
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct TracePathParams {
/// Starting function/method name.
pub from: String,
/// Target function/method name.
pub to: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct ListSymbolsInRangeParams {
/// Repo-relative path to a source file.
pub file: String,
/// Start line of the range (1-indexed, inclusive).
pub start_line: u32,
/// End line of the range (1-indexed, inclusive).
pub end_line: u32,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindUnusedSymbolsParams {
/// Optional NodeKind filter: "function", "method", "struct", etc.
pub kind: Option<String>,
/// Max symbols returned (default 30, capped at 200). `count` always reports
/// the true total; `truncated` flags when the list was longer.
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GetSubgraphParams {
/// Seed symbol name (unqualified).
pub seed_name: String,
/// How many hops to expand from the seed (1–5, default 1). Depth 2+ on a
/// high-degree hub returns a large subgraph — raise deliberately.
pub depth: Option<u8>,
/// Direction: "in" (callers/ancestors), "out" (callees/descendants), "both" (default).
pub direction: Option<String>,
/// Max ranked direct-relation evidence rows (default 20, capped at 100).
/// Coverage still reports the full neighborhood and direct-relation totals.
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct WikiSymbolParams {
/// Symbol to summarise (unqualified name).
pub name: String,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct SearchCodeParams {
/// Free-text query — substring matched against `name` and `qualified_name`.
pub query: String,
/// Max results (default 10, capped at 200).
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct StartTourParams {
/// Optional seed symbol — when given, the tour walks outward from it
/// along the call graph. When omitted, picks the highest-centrality
/// entry points across the repo.
pub seed: Option<String>,
/// How many steps/components in the tour (default 6, capped at 20).
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GraphStatsParams {
/// Branch to summarise (defaults to current branch if omitted).
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindGodNodesParams {
/// Minimum inbound `Calls` edges to count as a hub (default 10).
pub min_in_degree: Option<u32>,
/// Max results (default 20, capped at 100).
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindClustersParams {
/// Minimum members for a group to be reported as a cluster (default 3).
pub min_cluster_size: Option<usize>,
/// Max clusters returned (default 20, capped at 100).
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct FindCyclesParams {
/// Max import cycles to return (default 20, capped at 100).
pub limit: Option<usize>,
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct HealthReportParams {
/// Branch to report on (defaults to current branch if omitted).
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct AstSearchParams {
/// NodeKind filter: "function", "method", "struct", "trait", "interface",
/// "enum", "constant", "type_alias", "module", etc. Omit for any kind.
pub kind: Option<String>,
/// When set, match only async (true) or only non-async (false) symbols.
pub is_async: Option<bool>,
/// Visibility filter: "pub", "pub_crate", or "private".
pub visibility: Option<String>,
/// Inclusive lower bound on cyclomatic complexity. Symbols without a
/// recorded complexity are excluded when this is set.
pub min_complexity: Option<u32>,
/// Inclusive upper bound on cyclomatic complexity.
pub max_complexity: Option<u32>,
/// Case-insensitive substring the symbol name must contain.
pub name_contains: Option<String>,
/// Annotation/decorator name the symbol must carry (case-insensitive
/// substring): "Test" finds `@Test`, "route" finds `@app.route`,
/// "derive" finds `#[derive(...)]`.
pub annotation: Option<String>,
/// Max results (default 30, capped at 200).
pub limit: Option<usize>,
pub branch: Option<String>,
}
// ── Prompt parameter types ────────────────────────────────────────────────────
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DetectImpactParams {
/// Comma-separated list of changed file paths (repo-relative).
pub changed_files: String,
/// Branch to query (defaults to "main").
pub branch: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
pub struct GenerateMapParams {
/// Branch to document (defaults to "main").
pub branch: Option<String>,
}