vexp-cli 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,791 @@
1
+ /**
2
+ * Agent auto-detection and configuration for the vexp CLI.
3
+ *
4
+ * Ported from packages/vexp-vscode/src/providers/agent-auto-config.ts
5
+ * with VS Code dependencies removed. Uses the Rust binary path
6
+ * (`~/.vexp/bin/vexp-core mcp`) as the MCP command instead of
7
+ * `node <mcp-server.cjs>`.
8
+ */
9
+ import * as fs from "fs";
10
+ import * as path from "path";
11
+ import * as os from "os";
12
+ // ---------------------------------------------------------------------------
13
+ // Constants
14
+ // ---------------------------------------------------------------------------
15
+ const VEXP_MARKER_RE = /<!-- vexp(?:\s+v[\d.]+)? -->/;
16
+ const VEXP_MARKER_END = "<!-- /vexp -->";
17
+ // All vexp MCP tools (all read-only — safe to pre-approve).
18
+ const VEXP_TOOLS = [
19
+ "get_context_capsule",
20
+ "get_impact_graph",
21
+ "search_logic_flow",
22
+ "get_skeleton",
23
+ "index_status",
24
+ "workspace_setup",
25
+ "submit_lsp_edges",
26
+ "get_session_context",
27
+ "search_memory",
28
+ "save_observation",
29
+ ];
30
+ // ---------------------------------------------------------------------------
31
+ // Agent detectors — mirrors VS Code extension's AGENT_DETECTORS
32
+ // ---------------------------------------------------------------------------
33
+ const AGENT_DETECTORS = [
34
+ {
35
+ agent: "Claude Code",
36
+ detectPath: ".claude",
37
+ configFile: ".claude/CLAUDE.md",
38
+ templateName: "claude-code",
39
+ // MCP configured in ~/.claude.json (user-scope) via configureClaudeCodeGlobal()
40
+ },
41
+ {
42
+ agent: "Cursor",
43
+ detectPath: ".cursor",
44
+ configFile: ".cursor/rules",
45
+ templateName: "cursor",
46
+ mcpConfigFile: ".cursor/mcp.json",
47
+ },
48
+ {
49
+ agent: "Windsurf",
50
+ detectPath: ".windsurf",
51
+ configFile: ".windsurf/rules.md",
52
+ templateName: "windsurf",
53
+ mcpConfigFile: ".windsurf/mcp.json",
54
+ },
55
+ {
56
+ agent: "Continue.dev",
57
+ detectPath: ".continue",
58
+ configFile: ".continue/config.json",
59
+ templateName: "continue",
60
+ },
61
+ {
62
+ agent: "Augment",
63
+ detectPath: ".augment",
64
+ configFile: ".augment/guidelines.md",
65
+ templateName: "augment",
66
+ },
67
+ {
68
+ agent: "GitHub Copilot",
69
+ detectPath: ".github",
70
+ configFile: ".github/copilot-instructions.md",
71
+ templateName: "copilot",
72
+ },
73
+ {
74
+ agent: "Zed",
75
+ detectPath: ".zed",
76
+ configFile: ".zed/rules.md",
77
+ templateName: "zed",
78
+ },
79
+ {
80
+ agent: "Codex",
81
+ detectPath: "AGENTS.md",
82
+ configFile: "AGENTS.md",
83
+ templateName: "agents-md",
84
+ },
85
+ {
86
+ agent: "Opencode",
87
+ detectPath: "opencode.json",
88
+ configFile: "AGENTS.md",
89
+ templateName: "agents-md",
90
+ },
91
+ {
92
+ agent: "Kilo Code",
93
+ detectPath: ".kilocode",
94
+ configFile: ".kilocode/rules.md",
95
+ templateName: "generic",
96
+ },
97
+ {
98
+ agent: "Kiro",
99
+ detectPath: ".kiro",
100
+ configFile: ".kiro/steering/vexp.md",
101
+ templateName: "kiro",
102
+ },
103
+ {
104
+ agent: "Antigravity",
105
+ detectPath: ".antigravity",
106
+ configFile: ".antigravity/rules.md",
107
+ templateName: "generic",
108
+ },
109
+ ];
110
+ // ---------------------------------------------------------------------------
111
+ // Public API
112
+ // ---------------------------------------------------------------------------
113
+ /**
114
+ * Detect which AI coding agents are present in the workspace.
115
+ */
116
+ export function detectAgents(workspaceRoot) {
117
+ return AGENT_DETECTORS.filter((d) => {
118
+ const absPath = path.join(workspaceRoot, d.detectPath);
119
+ return fs.existsSync(absPath);
120
+ });
121
+ }
122
+ /**
123
+ * Configure all detected agents: write instruction files + MCP configs.
124
+ * If `agentFilter` is provided, only configure those agents.
125
+ */
126
+ export function configureAgents(workspaceRoot, binaryPath, version, agentFilter) {
127
+ const results = [];
128
+ const mcpConfigs = [];
129
+ const writtenConfigFiles = new Set();
130
+ let agents = detectAgents(workspaceRoot);
131
+ if (agentFilter && agentFilter.length > 0) {
132
+ const filter = agentFilter.map((a) => a.toLowerCase());
133
+ agents = agents.filter((d) => filter.includes(d.agent.toLowerCase()));
134
+ }
135
+ for (const detector of agents) {
136
+ const configFilePath = path.join(workspaceRoot, detector.configFile);
137
+ const alreadyExists = fs.existsSync(configFilePath);
138
+ const content = generateAgentConfig(detector.templateName, {
139
+ workspaceRoot,
140
+ binaryPath,
141
+ configFile: detector.configFile,
142
+ version,
143
+ });
144
+ // Write instruction file (deduplicated by configFile path)
145
+ let action = "skipped";
146
+ if (!writtenConfigFiles.has(detector.configFile)) {
147
+ if (detector.templateName === "continue") {
148
+ const continuePayload = {
149
+ customCommands: [
150
+ {
151
+ name: "vexp-context",
152
+ description: "Get vexp context capsule for current task",
153
+ prompt: "{{{ input }}}\n\nFirst, call get_context_capsule with the above task description.",
154
+ },
155
+ ],
156
+ contextProviders: [
157
+ {
158
+ name: "vexp",
159
+ params: {},
160
+ },
161
+ ],
162
+ mcpServers: [
163
+ {
164
+ name: "vexp",
165
+ command: binaryPath,
166
+ args: ["mcp"],
167
+ type: "stdio",
168
+ },
169
+ ],
170
+ };
171
+ const mergeResult = mergeJsonConfig(configFilePath, continuePayload, version);
172
+ action = mergeResult === "merged" ? "updated" : "skipped";
173
+ }
174
+ else {
175
+ action = appendOrCreate(configFilePath, content, version);
176
+ }
177
+ writtenConfigFiles.add(detector.configFile);
178
+ }
179
+ // Write MCP config JSON (Cursor, Windsurf)
180
+ if (detector.mcpConfigFile) {
181
+ const mcpConfigPath = path.join(workspaceRoot, detector.mcpConfigFile);
182
+ const alwaysAllow = detector.agent === "Windsurf" ? VEXP_TOOLS : undefined;
183
+ if (writeMcpConfig(mcpConfigPath, binaryPath, alwaysAllow)) {
184
+ mcpConfigs.push(detector.mcpConfigFile);
185
+ }
186
+ }
187
+ // Claude Code: configure MCP in ~/.claude.json (user-scope, stdio)
188
+ if (detector.agent === "Claude Code") {
189
+ const wrote = configureClaudeCodeGlobal(binaryPath);
190
+ if (wrote)
191
+ mcpConfigs.push("~/.claude.json");
192
+ }
193
+ // GitHub Copilot: VS Code format (.vscode/mcp.json with "servers" key)
194
+ if (detector.agent === "GitHub Copilot") {
195
+ const mcpPath = path.join(workspaceRoot, ".vscode/mcp.json");
196
+ if (writeVsCodeMcpConfig(mcpPath, binaryPath)) {
197
+ mcpConfigs.push(".vscode/mcp.json");
198
+ }
199
+ }
200
+ // Zed: context_servers in .zed/settings.json
201
+ if (detector.agent === "Zed") {
202
+ const zedPath = path.join(workspaceRoot, ".zed/settings.json");
203
+ if (writeZedMcpConfig(zedPath, binaryPath)) {
204
+ mcpConfigs.push(".zed/settings.json");
205
+ }
206
+ }
207
+ results.push({
208
+ agent: detector.agent,
209
+ configFile: detector.configFile,
210
+ content,
211
+ alreadyExists,
212
+ action,
213
+ });
214
+ }
215
+ return { agents: results, mcpConfigs };
216
+ }
217
+ // ---------------------------------------------------------------------------
218
+ // File helpers — ported from agent-auto-config.ts
219
+ // ---------------------------------------------------------------------------
220
+ function appendOrCreate(filePath, content, version) {
221
+ if (!fs.existsSync(filePath)) {
222
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
223
+ fs.writeFileSync(filePath, content, "utf-8");
224
+ return "created";
225
+ }
226
+ const existing = fs.readFileSync(filePath, "utf-8");
227
+ const markerMatch = existing.match(VEXP_MARKER_RE);
228
+ if (!markerMatch) {
229
+ fs.appendFileSync(filePath, "\n\n" + content);
230
+ return "appended";
231
+ }
232
+ const versionMatch = markerMatch[0].match(/v([\d.]+)/);
233
+ if (versionMatch && versionMatch[1] === version)
234
+ return "skipped";
235
+ const startIdx = existing.indexOf(markerMatch[0]);
236
+ const endIdx = existing.indexOf(VEXP_MARKER_END);
237
+ if (endIdx !== -1) {
238
+ const before = existing.substring(0, startIdx);
239
+ const after = existing.substring(endIdx + VEXP_MARKER_END.length);
240
+ fs.writeFileSync(filePath, before + content + after, "utf-8");
241
+ }
242
+ else {
243
+ const before = existing.substring(0, startIdx);
244
+ fs.writeFileSync(filePath, before + content, "utf-8");
245
+ }
246
+ return "updated";
247
+ }
248
+ function mergeJsonConfig(filePath, mergePayload, version) {
249
+ let existing = {};
250
+ if (fs.existsSync(filePath)) {
251
+ try {
252
+ existing = JSON.parse(fs.readFileSync(filePath, "utf-8"));
253
+ }
254
+ catch {
255
+ // Malformed JSON: overwrite
256
+ }
257
+ }
258
+ const existingVersion = existing.__vexp_version ?? (existing.__vexp ? "0.0.0" : undefined);
259
+ if (existingVersion === version)
260
+ return "skipped";
261
+ for (const [key, value] of Object.entries(mergePayload)) {
262
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
263
+ existing[key] = {
264
+ ...(existing[key] ?? {}),
265
+ ...value,
266
+ };
267
+ }
268
+ else if (Array.isArray(value) && Array.isArray(existing[key])) {
269
+ existing[key] = [...existing[key], ...value];
270
+ }
271
+ else {
272
+ existing[key] = value;
273
+ }
274
+ }
275
+ delete existing.__vexp;
276
+ existing.__vexp_version = version;
277
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
278
+ fs.writeFileSync(filePath, JSON.stringify(existing, null, 2), "utf-8");
279
+ return "merged";
280
+ }
281
+ // ---------------------------------------------------------------------------
282
+ // MCP config writers — adapted for Rust binary path
283
+ // ---------------------------------------------------------------------------
284
+ /**
285
+ * Write MCP config JSON for agents that use mcpServers format (Cursor, Windsurf).
286
+ * Returns true if a new entry was written.
287
+ */
288
+ function writeMcpConfig(mcpConfigPath, binaryPath, alwaysAllow) {
289
+ let existing = {};
290
+ if (fs.existsSync(mcpConfigPath)) {
291
+ try {
292
+ existing = JSON.parse(fs.readFileSync(mcpConfigPath, "utf-8"));
293
+ }
294
+ catch {
295
+ // Malformed JSON: overwrite
296
+ }
297
+ }
298
+ const servers = existing.mcpServers;
299
+ if (servers && "vexp" in servers)
300
+ return false;
301
+ existing.mcpServers = {
302
+ ...(servers ?? {}),
303
+ vexp: {
304
+ command: binaryPath,
305
+ args: ["mcp"],
306
+ ...(alwaysAllow && alwaysAllow.length > 0 ? { alwaysAllow } : {}),
307
+ },
308
+ };
309
+ fs.mkdirSync(path.dirname(mcpConfigPath), { recursive: true });
310
+ fs.writeFileSync(mcpConfigPath, JSON.stringify(existing, null, 2), "utf-8");
311
+ return true;
312
+ }
313
+ /**
314
+ * Write .vscode/mcp.json for GitHub Copilot.
315
+ * VS Code uses "servers" (not "mcpServers") + "type": "stdio".
316
+ */
317
+ function writeVsCodeMcpConfig(p, binaryPath) {
318
+ let existing = {};
319
+ if (fs.existsSync(p)) {
320
+ try {
321
+ existing = JSON.parse(fs.readFileSync(p, "utf-8"));
322
+ }
323
+ catch {
324
+ // Malformed JSON: overwrite
325
+ }
326
+ }
327
+ const servers = existing.servers;
328
+ if (servers && "vexp" in servers)
329
+ return false;
330
+ existing.servers = {
331
+ ...(servers ?? {}),
332
+ vexp: { type: "stdio", command: binaryPath, args: ["mcp"] },
333
+ };
334
+ fs.mkdirSync(path.dirname(p), { recursive: true });
335
+ fs.writeFileSync(p, JSON.stringify(existing, null, 2), "utf-8");
336
+ return true;
337
+ }
338
+ /**
339
+ * Write context_servers in .zed/settings.json for Zed.
340
+ */
341
+ function writeZedMcpConfig(p, binaryPath) {
342
+ let settings = {};
343
+ if (fs.existsSync(p)) {
344
+ try {
345
+ settings = JSON.parse(fs.readFileSync(p, "utf-8"));
346
+ }
347
+ catch {
348
+ // Malformed JSON: overwrite
349
+ }
350
+ }
351
+ const cs = settings.context_servers;
352
+ if (cs && "vexp" in cs)
353
+ return false;
354
+ settings.context_servers = {
355
+ ...(cs ?? {}),
356
+ vexp: { command: { path: binaryPath, args: ["mcp"] } },
357
+ };
358
+ // Pre-approve all vexp tools
359
+ const agent = (settings.agent ?? {});
360
+ const tp = (agent.tool_permissions ?? {});
361
+ const tools = (tp.tools ?? {});
362
+ for (const tool of VEXP_TOOLS) {
363
+ tools[`mcp:vexp:${tool}`] = { default: "allow" };
364
+ }
365
+ settings.agent = { ...agent, tool_permissions: { ...tp, tools } };
366
+ fs.mkdirSync(path.dirname(p), { recursive: true });
367
+ fs.writeFileSync(p, JSON.stringify(settings, null, 2), "utf-8");
368
+ return true;
369
+ }
370
+ /**
371
+ * Configure vexp MCP in ~/.claude.json (user-scope) using the Rust binary.
372
+ * Returns true if config was written/updated.
373
+ */
374
+ function configureClaudeCodeGlobal(binaryPath) {
375
+ const home = os.homedir();
376
+ if (!home)
377
+ return false;
378
+ const configPath = path.join(home, ".claude.json");
379
+ let config = {};
380
+ if (fs.existsSync(configPath)) {
381
+ try {
382
+ config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
383
+ }
384
+ catch {
385
+ // Malformed JSON: overwrite
386
+ }
387
+ }
388
+ const servers = config.mcpServers;
389
+ const existing = servers?.["vexp"];
390
+ // Skip if already configured with this exact binary path
391
+ if (existing?.["command"] === binaryPath &&
392
+ Array.isArray(existing?.["args"]) &&
393
+ existing["args"].includes("mcp")) {
394
+ return false;
395
+ }
396
+ config.mcpServers = {
397
+ ...(servers ?? {}),
398
+ vexp: {
399
+ command: binaryPath,
400
+ args: ["mcp"],
401
+ },
402
+ };
403
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
404
+ return true;
405
+ }
406
+ function generateAgentConfig(template, vars) {
407
+ switch (template) {
408
+ case "claude-code":
409
+ return claudeCodeTemplate(vars);
410
+ case "cursor":
411
+ return cursorTemplate(vars);
412
+ case "windsurf":
413
+ return windsurfTemplate(vars);
414
+ case "continue":
415
+ return continueTemplate(vars);
416
+ case "augment":
417
+ return augmentTemplate(vars);
418
+ case "copilot":
419
+ return copilotTemplate(vars);
420
+ case "zed":
421
+ return zedTemplate(vars);
422
+ case "agents-md":
423
+ return agentsMdTemplate(vars);
424
+ case "kiro":
425
+ return kiroTemplate(vars);
426
+ default:
427
+ return genericTemplate(vars);
428
+ }
429
+ }
430
+ // ---------------------------------------------------------------------------
431
+ // Templates — copied verbatim from agent-auto-config.ts
432
+ // ---------------------------------------------------------------------------
433
+ function claudeCodeTemplate(vars) {
434
+ return `## vexp — Context-Aware AI Coding <!-- vexp v${vars.version} -->
435
+
436
+ ### MANDATORY: use vexp MCP tools before ANYTHING else
437
+ For every task — questions, bug fixes, features, exploration:
438
+ **call the \`get_context_capsule\` MCP tool first**.
439
+
440
+ Do NOT use grep, glob, Bash, or Read to search/explore the codebase.
441
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
442
+
443
+ ### Available MCP tools (invoke via tool interface, NOT via HTTP or bash)
444
+ - \`get_context_capsule\` — most relevant code for your task or question (ALWAYS FIRST)
445
+ - \`get_impact_graph\` — what breaks if you change a symbol
446
+ - \`search_logic_flow\` — execution paths between functions
447
+ - \`get_skeleton\` — token-efficient file structure
448
+ - \`index_status\` — indexing status and health check
449
+ - \`workspace_setup\` — bootstrap vexp config for a new project
450
+ - \`submit_lsp_edges\` — submit type-resolved call edges (used by VS Code extension)
451
+ - \`get_session_context\` — recall observations from current/previous sessions
452
+ - \`search_memory\` — cross-session search for past decisions, insights, and explored code
453
+ - \`save_observation\` — persist important insights with optional code symbol linking
454
+
455
+ ### Smart Features (automatic — no action needed)
456
+ - **Intent Detection**: vexp auto-detects query intent from your prompt keywords.
457
+ "fix bug" → Debug mode (follows error paths), "refactor" → blast-radius mode,
458
+ "add feature" → Modify mode, default → Read mode. Each mode optimizes result ranking.
459
+ - **Hybrid Search**: combines keyword matching (FTS) + semantic similarity (TF-IDF) + graph
460
+ centrality for better results. Finds \`validateCredentials\` when searching "authentication".
461
+ - **Session Memory**: every tool call is auto-captured as an observation. Relevant memories
462
+ from previous sessions are auto-surfaced inside \`get_context_capsule\` results. Observations
463
+ linked to code symbols are auto-flagged stale when that code changes.
464
+ - **Feedback Loop**: repeated queries with similar terms auto-expand the result budget.
465
+ - **LSP Bridge**: VS Code captures type-resolved call edges for high-confidence call graphs.
466
+ - **Change Coupling**: files modified together in git history are included as related context.
467
+ - **Context Lineage**: frequently modified code gets a boost in relevance ranking.
468
+
469
+ ### Workflow
470
+ 1. \`get_context_capsule("your task or question")\` — ALWAYS FIRST (includes relevant memories)
471
+ 2. Read the pivot files returned (full content)
472
+ 3. Review supporting skeletons for broader context
473
+ 4. Make targeted changes based on the context
474
+ 5. \`get_impact_graph\` before refactoring to verify no regressions
475
+ 6. \`save_observation\` to persist important decisions with code symbol links
476
+ 7. \`search_memory\` or \`get_session_context\` to recall past work
477
+
478
+ ### Advanced Parameters
479
+ - \`include_tests: true\` — include test files (useful for debugging)
480
+ - \`max_tokens: 12000\` — increase token budget for complex tasks
481
+ - \`pivot_depth: 3\` — deeper graph traversal for broad exploration
482
+ - \`skeleton_detail: "detailed"\` — more verbose skeletons
483
+
484
+ ### Multi-Repo Workspaces
485
+ When multiple repos are indexed (monorepos, frontend+backend, microservices):
486
+ - \`get_context_capsule\` queries **all repos** automatically — results show repo alias per file
487
+ - Use \`repos: ["alias"]\` to restrict queries to specific repos
488
+ - Use \`cross_repo: true\` on \`get_impact_graph\` and \`search_logic_flow\` to trace across repo boundaries
489
+ - Use \`index_status\` to discover available repo aliases
490
+ - \`get_skeleton\` accepts \`repo: "alias"\` to target a specific repo's files
491
+ <!-- /vexp -->`;
492
+ }
493
+ function cursorTemplate(vars) {
494
+ return `## vexp rules for Cursor <!-- vexp v${vars.version} -->
495
+
496
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
497
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
498
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
499
+
500
+ ### Workflow
501
+ 1. \`get_context_capsule\` with your task description — ALWAYS FIRST
502
+ 2. Review the provided pivot files and skeletons
503
+ 3. Make targeted changes based on the context
504
+ 4. \`get_impact_graph\` before refactoring exported symbols
505
+
506
+ ### Available MCP tools
507
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent: "fix bug" → debug mode, "refactor" → blast-radius mode
508
+ - \`get_impact_graph\` — what breaks if you change a symbol
509
+ - \`search_logic_flow\` — execution paths between functions
510
+ - \`get_skeleton\` — token-efficient file structure
511
+ - \`index_status\` — indexing status
512
+ - \`workspace_setup\` — bootstrap vexp config for a new project
513
+ - \`get_session_context\` — recall observations from current/previous sessions
514
+ - \`search_memory\` — cross-session search for past decisions and insights
515
+ - \`save_observation\` — persist important insights with optional code symbol linking
516
+
517
+ ### Tips
518
+ - vexp uses hybrid search (keywords + semantic similarity + graph centrality) — natural language queries work well
519
+ - Add \`include_tests: true\` when debugging to include test files in results
520
+ - Repeated queries auto-expand result budget via feedback loop
521
+ - Session memory auto-captures observations; use \`save_observation\` for important decisions
522
+
523
+ ### Multi-Repo
524
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on \`get_impact_graph\`/\`search_logic_flow\` to trace across repos. Run \`index_status\` to see available aliases.
525
+
526
+ > **Tip:** To avoid confirmation prompts on every tool call, enable Yolo mode:
527
+ > Cursor Settings → Features → Agent → Enable Yolo Mode.
528
+ <!-- /vexp -->`;
529
+ }
530
+ function windsurfTemplate(vars) {
531
+ return `## vexp for Windsurf <!-- vexp v${vars.version} -->
532
+
533
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
534
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
535
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
536
+
537
+ ### Workflow
538
+ 1. \`get_context_capsule\` — ALWAYS FIRST for any task or question
539
+ 2. Review pivot files and skeletons returned
540
+ 3. Make targeted changes based on the context
541
+ 4. \`get_impact_graph\` before refactoring exported symbols
542
+
543
+ ### Available MCP tools
544
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
545
+ - \`get_impact_graph\` — what breaks if you change a symbol
546
+ - \`search_logic_flow\` — execution paths between functions
547
+ - \`get_skeleton\` — token-efficient file structure
548
+ - \`index_status\` — indexing status
549
+ - \`workspace_setup\` — bootstrap vexp config for a new project
550
+ - \`get_session_context\` — recall observations from current/previous sessions
551
+ - \`search_memory\` — cross-session search for past decisions and insights
552
+ - \`save_observation\` — persist important insights with optional code symbol linking
553
+
554
+ ### Smart Features (automatic)
555
+ - **Intent Detection**: "fix bug" → debug mode, "refactor" → blast-radius, "add" → modify
556
+ - **Hybrid Search**: keyword + semantic + graph centrality ranking
557
+ - **Session Memory**: auto-captures observations; use \`save_observation\` for important decisions
558
+ - **Feedback Loop**: repeated queries auto-expand result budget
559
+
560
+ ### Multi-Repo Workspaces
561
+ When multiple repos are indexed (monorepos, frontend+backend, microservices):
562
+ - \`get_context_capsule\` queries **all repos** automatically — results show repo alias per file
563
+ - Use \`repos: ["alias"]\` to restrict queries to specific repos
564
+ - Use \`cross_repo: true\` on \`get_impact_graph\` and \`search_logic_flow\` to trace across repo boundaries
565
+ - Use \`index_status\` to discover available repo aliases
566
+ - \`get_skeleton\` accepts \`repo: "alias"\` to target a specific repo's files
567
+ <!-- /vexp -->`;
568
+ }
569
+ function continueTemplate(vars) {
570
+ return JSON.stringify({
571
+ customCommands: [
572
+ {
573
+ name: "vexp-context",
574
+ description: "Get vexp context capsule for current task",
575
+ prompt: "{{{ input }}}\n\nFirst, call get_context_capsule with the above task description.",
576
+ },
577
+ ],
578
+ mcpServers: [
579
+ {
580
+ name: "vexp",
581
+ command: vars.binaryPath,
582
+ args: ["mcp"],
583
+ type: "stdio",
584
+ },
585
+ ],
586
+ }, null, 2);
587
+ }
588
+ function augmentTemplate(vars) {
589
+ return `## vexp for Augment <!-- vexp v${vars.version} -->
590
+
591
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
592
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
593
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
594
+
595
+ When working on this codebase:
596
+ 1. Start every task by calling \`get_context_capsule\` — ALWAYS FIRST
597
+ 2. The capsule provides full content of pivot files + skeletons of related files
598
+ 3. Use \`get_impact_graph\` before refactoring exported symbols
599
+
600
+ ### Available MCP tools
601
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
602
+ - \`get_impact_graph\` — what breaks if you change a symbol
603
+ - \`search_logic_flow\` — execution paths between functions
604
+ - \`get_skeleton\` — token-efficient file structure
605
+ - \`index_status\` — indexing status
606
+ - \`workspace_setup\` — bootstrap vexp config for a new project
607
+ - \`get_session_context\` — recall observations from current/previous sessions
608
+ - \`search_memory\` — cross-session search for past decisions and insights
609
+ - \`save_observation\` — persist important insights with optional code symbol linking
610
+
611
+ ### Smart Features
612
+ vexp auto-detects query intent (debug/refactor/modify/read) and uses hybrid ranking
613
+ (keyword + semantic + graph centrality). Session memory auto-captures observations.
614
+ Repeated queries auto-expand result budget.
615
+
616
+ ### Multi-Repo Workspaces
617
+ When multiple repos are indexed (monorepos, frontend+backend, microservices):
618
+ - \`get_context_capsule\` queries **all repos** automatically — results show repo alias per file
619
+ - Use \`repos: ["alias"]\` to restrict queries to specific repos
620
+ - Use \`cross_repo: true\` on \`get_impact_graph\` and \`search_logic_flow\` to trace across repo boundaries
621
+ - Use \`index_status\` to discover available repo aliases
622
+ - \`get_skeleton\` accepts \`repo: "alias"\` to target a specific repo's files
623
+ <!-- /vexp -->`;
624
+ }
625
+ function copilotTemplate(vars) {
626
+ return `## vexp context tools <!-- vexp v${vars.version} -->
627
+
628
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
629
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
630
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
631
+
632
+ ### Workflow
633
+ 1. \`get_context_capsule\` — ALWAYS FIRST for every task or question
634
+ 2. Review the provided pivot files and skeletons
635
+ 3. Make targeted changes based on the context
636
+ 4. \`get_impact_graph\` before refactoring exported symbols
637
+
638
+ ### Available MCP tools
639
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
640
+ - \`get_impact_graph\` — shows which symbols depend on a given function/class
641
+ - \`search_logic_flow\` — traces execution paths between functions
642
+ - \`get_skeleton\` — token-efficient structural overview of a file
643
+ - \`index_status\` — indexing status
644
+ - \`workspace_setup\` — bootstrap vexp config for a new project
645
+ - \`get_session_context\` — recall observations from current/previous sessions
646
+ - \`search_memory\` — cross-session search for past decisions and insights
647
+ - \`save_observation\` — persist important insights with optional code symbol linking
648
+
649
+ ### Smart Features
650
+ vexp auto-detects query intent (debug/refactor/modify/read) and uses hybrid ranking
651
+ (keyword + semantic + graph centrality). Session memory auto-captures observations.
652
+ Repeated queries auto-expand result budget.
653
+
654
+ ### Multi-Repo
655
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on \`get_impact_graph\`/\`search_logic_flow\` to trace across repos. Run \`index_status\` to see available aliases.
656
+ <!-- /vexp -->`;
657
+ }
658
+ function zedTemplate(vars) {
659
+ return `## vexp for Zed <!-- vexp v${vars.version} -->
660
+
661
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
662
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
663
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
664
+
665
+ ### Workflow
666
+ 1. \`get_context_capsule\` — ALWAYS FIRST for any task or question
667
+ 2. Review pivot files and skeletons returned
668
+ 3. Make targeted changes based on the context
669
+ 4. \`get_impact_graph\` before refactoring exported symbols
670
+
671
+ ### Available MCP tools
672
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
673
+ - \`get_impact_graph\` — dependency impact of a symbol change
674
+ - \`search_logic_flow\` — execution paths between functions
675
+ - \`get_skeleton\` — compact structural view of a file
676
+ - \`index_status\` — indexing status
677
+ - \`workspace_setup\` — bootstrap vexp config for a new project
678
+ - \`get_session_context\` — recall observations from current/previous sessions
679
+ - \`search_memory\` — cross-session search for past decisions and insights
680
+ - \`save_observation\` — persist important insights with optional code symbol linking
681
+
682
+ ### Smart Features
683
+ vexp auto-detects query intent (debug/refactor/modify/read) and uses hybrid ranking
684
+ (keyword + semantic + graph centrality). Session memory auto-captures observations.
685
+ Repeated queries auto-expand result budget.
686
+
687
+ ### Multi-Repo
688
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on \`get_impact_graph\`/\`search_logic_flow\` to trace across repos. Run \`index_status\` to see available aliases.
689
+ <!-- /vexp -->`;
690
+ }
691
+ function agentsMdTemplate(vars) {
692
+ return `## vexp <!-- vexp v${vars.version} -->
693
+
694
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
695
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
696
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
697
+
698
+ Before any code change or question, call \`get_context_capsule\` with a description of your task.
699
+ This provides the most relevant source files and their skeletons with minimal token usage.
700
+
701
+ ### Workflow
702
+ 1. \`get_context_capsule\` — ALWAYS FIRST for any task or question
703
+ 2. Review the provided pivot files and skeletons
704
+ 3. Make targeted changes based on the context
705
+ 4. \`get_impact_graph\` before refactoring exported symbols
706
+
707
+ ### Available MCP tools
708
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
709
+ - \`get_impact_graph\` — what breaks if you change a symbol
710
+ - \`search_logic_flow\` — execution paths between functions
711
+ - \`get_skeleton\` — token-efficient file structure
712
+ - \`index_status\` — indexing status
713
+ - \`workspace_setup\` — bootstrap vexp config for a new project
714
+ - \`get_session_context\` — recall observations from current/previous sessions
715
+ - \`search_memory\` — cross-session search for past decisions and insights
716
+ - \`save_observation\` — persist important insights with optional code symbol linking
717
+
718
+ ### Smart Features
719
+ vexp auto-detects query intent (debug/refactor/modify/read) and uses hybrid ranking
720
+ (keyword + semantic + graph centrality). Session memory auto-captures observations.
721
+ Repeated queries auto-expand result budget. Use \`include_tests: true\` when debugging.
722
+
723
+ ### Multi-Repo
724
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on \`get_impact_graph\`/\`search_logic_flow\` to trace across repos. Run \`index_status\` to see available aliases.
725
+ <!-- /vexp -->`;
726
+ }
727
+ function kiroTemplate(vars) {
728
+ return `# vexp steering <!-- vexp v${vars.version} -->
729
+
730
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
731
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
732
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
733
+
734
+ Always start tasks by calling \`get_context_capsule\` with a description of what you need.
735
+
736
+ ## Workflow
737
+ 1. \`get_context_capsule\` — ALWAYS FIRST for any task or question
738
+ 2. Review the provided pivot files and skeletons
739
+ 3. Make targeted changes based on the context
740
+ 4. \`get_impact_graph\` before refactoring exported symbols
741
+
742
+ ## Available vexp tools
743
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
744
+ - \`get_impact_graph\` — impact analysis before refactoring
745
+ - \`search_logic_flow\` — trace execution paths
746
+ - \`get_skeleton\` — compact file structure
747
+ - \`index_status\` — indexing status
748
+ - \`workspace_setup\` — bootstrap config for new projects
749
+ - \`get_session_context\` — recall observations from current/previous sessions
750
+ - \`search_memory\` — cross-session search for past decisions and insights
751
+ - \`save_observation\` — persist important insights with optional code symbol linking
752
+
753
+ ## Smart Features
754
+ Intent detection (debug/refactor/modify/read), hybrid search, session memory, auto-expanding budget on repeated queries.
755
+
756
+ ## Multi-Repo
757
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on impact/flow. Run \`index_status\` to see aliases.
758
+ <!-- /vexp -->`;
759
+ }
760
+ function genericTemplate(vars) {
761
+ return `## vexp <!-- vexp v${vars.version} -->
762
+
763
+ **MANDATORY: use vexp MCP tools for ALL file analysis.**
764
+ Do NOT use grep, glob, search, or file reads to explore the codebase.
765
+ Use vexp MCP tools instead — they return pre-indexed, relevant context.
766
+
767
+ ### Workflow
768
+ 1. \`get_context_capsule\` — ALWAYS FIRST for any task or question
769
+ 2. Review the provided pivot files and skeletons
770
+ 3. Make targeted changes based on the context
771
+ 4. \`get_impact_graph\` before refactoring exported symbols
772
+
773
+ ### Available MCP tools
774
+ - \`get_context_capsule\` — most relevant code (ALWAYS FIRST). Auto-detects intent from your query
775
+ - \`get_impact_graph\` — what breaks if you change a symbol
776
+ - \`search_logic_flow\` — execution paths between functions
777
+ - \`get_skeleton\` — token-efficient file structure
778
+ - \`index_status\` — indexing status
779
+ - \`workspace_setup\` — bootstrap vexp config for a new project
780
+ - \`get_session_context\` — recall observations from current/previous sessions
781
+ - \`search_memory\` — cross-session search for past decisions and insights
782
+ - \`save_observation\` — persist important insights with optional code symbol linking
783
+
784
+ ### Smart Features
785
+ Intent detection (debug/refactor/modify/read), hybrid search, session memory, auto-expanding budget on repeated queries.
786
+
787
+ ### Multi-Repo
788
+ \`get_context_capsule\` auto-queries all indexed repos. Use \`repos: ["alias"]\` to scope, \`cross_repo: true\` on impact/flow. Run \`index_status\` to see aliases.
789
+ <!-- /vexp -->`;
790
+ }
791
+ //# sourceMappingURL=agent-config.js.map