vexp-mcp 2.3.0 → 2.4.0

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.
package/dist/index.js CHANGED
@@ -54,6 +54,25 @@ const ESSENTIAL_TOOL_DEFINITIONS = [
54
54
  INDEX_STATUS_DEFINITION,
55
55
  EXPAND_VEXP_REF_DEFINITION,
56
56
  ];
57
+ /**
58
+ * Default surface (2.3.3): the two tools an agent needs up front. Every
59
+ * schema in tools/list is resident in the agent's context on EVERY turn —
60
+ * measured against true vanilla, the 4-tool surface plus mandate cost more
61
+ * than run_pipeline ever saved on oriented tasks. So:
62
+ * - `index_status` is diagnostics (vexp doctor / CLI territory) — hidden
63
+ * by default, still dispatchable if called.
64
+ * - `expand_vexp_ref` is only meaningful AFTER a response contains
65
+ * [V-REF:...] placeholders — exposed dynamically at that moment via
66
+ * notifications/tools/list_changed. Agents that don't refresh their
67
+ * tool list fall back to the in-band alternative every V-REF response
68
+ * already suggests ("or Read the file"), and direct calls to the tool
69
+ * keep working whether or not it is listed.
70
+ * VEXP_ALL_TOOLS=1 restores the full surface.
71
+ */
72
+ const MINIMAL_TOOL_DEFINITIONS = [
73
+ RUN_PIPELINE_DEFINITION,
74
+ GET_SKELETON_DEFINITION,
75
+ ];
57
76
  function allToolsEnabled() {
58
77
  const v = process.env.VEXP_ALL_TOOLS;
59
78
  if (!v)
@@ -66,10 +85,25 @@ function allToolsEnabled() {
66
85
  // discoverWorkspaceRoot). The Rust daemon registers itself in
67
86
  // ~/.vexp/daemons.json on all platforms, which is the authoritative
68
87
  // lookup when an agent spawns the MCP server from an unrelated cwd.
69
- function createMcpServer(daemon) {
70
- const server = new Server({ name: "vexp-mcp", version: "1.0.0" }, { capabilities: { tools: {} } });
88
+ export function createMcpServer(daemon) {
89
+ const server = new Server({ name: "vexp-mcp", version: "1.0.0" }, { capabilities: { tools: { listChanged: true } } });
90
+ // Once any response carries a [V-REF:...] placeholder, expand_vexp_ref
91
+ // becomes relevant: expose it and tell the client the list changed.
92
+ let vrefSeen = false;
93
+ const noteVref = (text) => {
94
+ if (vrefSeen || !text.includes("[V-REF:"))
95
+ return;
96
+ vrefSeen = true;
97
+ server.sendToolListChanged().catch(() => {
98
+ /* client may not support notifications — fallback is in-band */
99
+ });
100
+ };
71
101
  server.setRequestHandler(ListToolsRequestSchema, () => ({
72
- tools: allToolsEnabled() ? ALL_TOOL_DEFINITIONS : ESSENTIAL_TOOL_DEFINITIONS,
102
+ tools: allToolsEnabled()
103
+ ? ALL_TOOL_DEFINITIONS
104
+ : vrefSeen
105
+ ? [...MINIMAL_TOOL_DEFINITIONS, EXPAND_VEXP_REF_DEFINITION]
106
+ : MINIMAL_TOOL_DEFINITIONS,
73
107
  }));
74
108
  server.setRequestHandler(CallToolRequestSchema, async (req) => {
75
109
  const { name, arguments: args } = req.params;
@@ -115,6 +149,7 @@ function createMcpServer(daemon) {
115
149
  content: [{ type: "text", text: `Unknown tool: ${name}` }],
116
150
  };
117
151
  }
152
+ noteVref(text);
118
153
  return {
119
154
  content: [{ type: "text", text }],
120
155
  };
@@ -313,7 +348,11 @@ async function main() {
313
348
  await startStdio(daemon);
314
349
  }
315
350
  }
316
- main().catch((err) => {
317
- console.error("[vexp-mcp] Fatal:", err);
318
- process.exit(1);
319
- });
351
+ // Auto-start on import EXCEPT under tests (which import createMcpServer
352
+ // and must not have a stdio server grabbing stdin).
353
+ if (process.env.VEXP_MCP_NO_AUTOSTART !== "1") {
354
+ main().catch((err) => {
355
+ console.error("[vexp-mcp] Fatal:", err);
356
+ process.exit(1);
357
+ });
358
+ }
@@ -4,11 +4,7 @@ export const ExpandVexpRefSchema = z.object({
4
4
  });
5
5
  export const EXPAND_VEXP_REF_DEFINITION = {
6
6
  name: "expand_vexp_ref",
7
- description: "Expand a V-REF hash to its full decoded content. " +
8
- "When Vexp v2 compressed context contains [V-REF:xxxx] references " +
9
- "that were not pre-expanded in the bootstrap header, call this tool " +
10
- "to retrieve the original code. Returns both the encoded (camouflaged) " +
11
- "and decoded (original) versions of the referenced code.",
7
+ description: "Expand a [V-REF:xxxx] placeholder from compressed v2 output to its full content.",
12
8
  inputSchema: {
13
9
  type: "object",
14
10
  properties: {
@@ -7,13 +7,9 @@ export const GetSkeletonSchema = z.object({
7
7
  });
8
8
  export const GET_SKELETON_DEFINITION = {
9
9
  name: "get_skeleton",
10
- description: "PREFERRED way to inspect files — returns signatures, class declarations, and type definitions " +
11
- "at three detail levels (70-90% token savings vs Read). " +
12
- "Detail levels: minimal = exports and top-level signatures only. standard = all declarations with doc comments. detailed = full bodies for short functions, signatures for long ones. " +
13
- "WHEN TO USE: (1) ALWAYS prefer this over Read — use get_skeleton first, only fall back to Read if you truly need exact raw content to edit a specific line. " +
14
- "(2) After run_pipeline when you need to drill deeper into a file from the results. " +
15
- "(3) When asked to understand, list, or explore functions/classes in a file. " +
16
- "(4) When you need more context on a supporting file from capsule results.",
10
+ description: "Structural view of files you need to UNDERSTAND but not edit (70-90% smaller than Read): " +
11
+ "signatures, classes, types at detail minimal|standard|detailed. Use after run_pipeline to " +
12
+ "drill into a file; use Read only for files you are about to edit.",
17
13
  inputSchema: {
18
14
  type: "object",
19
15
  properties: {
@@ -97,6 +97,24 @@ function formatStatusAsText(status, targeting) {
97
97
  "Restart the daemon (`vexp daemon-cmd restart`) or re-run `vexp setup-llm` — until then, results are NOT LLM-compressed.");
98
98
  lines.push("");
99
99
  }
100
+ // Savings Ledger (2.3.3) — the one savings surface, on every agent.
101
+ // Replaces the old per-call counter as the headline: zero tool calls is
102
+ // not "not working" — silence on oriented prompts is a logged decision.
103
+ if (status.ledger) {
104
+ const lg = status.ledger;
105
+ lines.push(`## Savings Ledger (last ${lg.period_days ?? 7} days)`);
106
+ lines.push("");
107
+ if ((lg.prompts_analyzed ?? 0) > 0) {
108
+ lines.push(`- Activity: ${lg.prompts_analyzed} prompt(s) analyzed — ${lg.silences} silence(s) (task already oriented), ${lg.hints_served} orientation hint(s) served`);
109
+ }
110
+ if ((lg.measured_calls ?? 0) > 0) {
111
+ lines.push(`- Measured: ${lg.measured_calls} tool call(s), ~${(lg.measured_tokens_saved ?? 0).toLocaleString()} tokens saved (full-read baseline minus served)`);
112
+ }
113
+ if ((lg.prompts_analyzed ?? 0) === 0 && (lg.measured_calls ?? 0) === 0) {
114
+ lines.push("- No classified prompts or tool calls in this window.");
115
+ }
116
+ lines.push("");
117
+ }
100
118
  // Live session usage (2.3 C1) — which agent sessions actually called vexp.
101
119
  if (status.sessions && status.sessions.length > 0) {
102
120
  lines.push("## Active sessions (last 4h)");
@@ -60,19 +60,12 @@ export const RunPipelineSchema = z.object({
60
60
  });
61
61
  export const RUN_PIPELINE_DEFINITION = {
62
62
  name: "run_pipeline",
63
- description: "PRIMARY TOOL — Use this for ANY codebase task. " +
64
- "Runs a full analysis pipeline (context search + impact analysis + memory recall) server-side " +
65
- "and returns a single compressed result with relevant source code, file skeletons, and impact analysis. " +
66
- "WHEN TO USE: (1) Before ANY code change — always call this first. " +
67
- "(2) When asked how a feature works or where something is implemented. " +
68
- "(3) At the start of a debugging session. " +
69
- "(4) Before refactoring — includes blast-radius analysis. " +
70
- "(5) When exploring or understanding code structure. " +
71
- "ALWAYS prefer this over Read, Grep, Glob, or get_context_capsule — " +
72
- "it provides the same results plus impact analysis in a single call with ~60% fewer tokens. " +
73
- "Auto-detects intent (debug/modify/refactor/explore) from your task description. " +
74
- "Read/debug tasks inline pivot file content; modify/refactor tasks return skeletons + V-REF hashes (expand with expand_vexp_ref, or Read the file you are about to edit). " +
75
- "If you need more detail on a specific file, use get_skeleton (detail: minimal/standard/detailed) instead of Read — it saves 70-90% tokens.",
63
+ description: "Code-graph orientation for this repo in one server-side call: ranked pivot files " +
64
+ "with line ranges, blast radius (what breaks if you change X) and prior session " +
65
+ "notes, compressed. Call ONCE at task start when you do NOT already know where to " +
66
+ "work (unfamiliar area, no file/symbol named in the task) or when you need impact " +
67
+ "analysis. If the task already names the files to touch, skip this and use your " +
68
+ "normal tools. Anchor the task on real identifiers or file paths.",
76
69
  inputSchema: {
77
70
  type: "object",
78
71
  properties: {
@@ -80,29 +73,12 @@ export const RUN_PIPELINE_DEFINITION = {
80
73
  preset: {
81
74
  type: "string",
82
75
  enum: ["auto", "explore", "modify", "debug", "refactor"],
83
- description: "Analysis preset. auto=detect from task. explore=capsule+memory. debug=capsule(+tests)+impact+memory. modify=capsule+impact+memory. refactor=capsule+deep_impact+memory.",
76
+ description: "auto (default, detect from task) | explore | debug | modify | refactor (deep impact)",
84
77
  },
85
78
  steps: {
86
79
  type: "array",
87
- description: "Advanced: explicit pipeline steps (overrides preset)",
88
- items: {
89
- type: "object",
90
- properties: {
91
- tool: {
92
- type: "string",
93
- enum: [
94
- "capsule",
95
- "impact",
96
- "flow",
97
- "skeleton",
98
- "memory_search",
99
- "save_observation",
100
- ],
101
- },
102
- params: { type: "object" },
103
- },
104
- required: ["tool"],
105
- },
80
+ description: "Advanced: explicit pipeline steps (overrides preset). Each item: { tool: capsule|impact|flow|skeleton|memory_search|save_observation, params? }",
81
+ items: { type: "object" },
106
82
  },
107
83
  max_tokens: {
108
84
  type: "number",
@@ -112,9 +88,13 @@ export const RUN_PIPELINE_DEFINITION = {
112
88
  type: "boolean",
113
89
  description: "Include test files (default: auto — enabled for debug intent)",
114
90
  },
91
+ eager: {
92
+ type: "boolean",
93
+ description: "One-perfect-call mode: full pivot bodies + covering tests + raised budget in this single response. Use on non-trivial tasks when you will work directly from the result.",
94
+ },
115
95
  include_file_content: {
116
96
  type: "boolean",
117
- description: "Include full file content for pivot files (default: auto — read/debug inline bodies; modify/refactor return skeletons + V-REF)",
97
+ description: "Full pivot bodies (default: auto by intent)",
118
98
  },
119
99
  repos: {
120
100
  type: "array",
@@ -123,7 +103,7 @@ export const RUN_PIPELINE_DEFINITION = {
123
103
  },
124
104
  observation: {
125
105
  type: "string",
126
- description: "Auto-save this observation after pipeline completes (saves an extra tool call)",
106
+ description: "Insight to persist for future sessions (saved in the same call)",
127
107
  },
128
108
  prose_compression: {
129
109
  type: "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexp-mcp",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "vexp MCP server — AI context tools for coding agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",