@graphpilot-oss/graphpilot 0.0.1
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/.editorconfig +15 -0
- package/.github/CODEOWNERS +22 -0
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +19 -0
- package/.github/dependabot.yml +15 -0
- package/.github/workflows/ci.yml +62 -0
- package/.github/workflows/release.yml +50 -0
- package/.prettierignore +19 -0
- package/.prettierrc.json +20 -0
- package/CHANGELOG.md +138 -0
- package/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +111 -0
- package/LICENSE +201 -0
- package/README.md +132 -0
- package/SECURITY.md +44 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +1 -0
- package/bench/README.md +544 -0
- package/bench/results/agent-tier-2026-05-22.md +28 -0
- package/bench/results/agent-tier-summary.md +44 -0
- package/bench/results/baseline-tier-2026-05-22.md +23 -0
- package/bench/results/baseline.json +810 -0
- package/bench/results/baseline.md +28 -0
- package/bench/run-agent-tier-automated.ts +234 -0
- package/bench/run-agent-tier.md +125 -0
- package/bench/run-baseline-tier.ts +200 -0
- package/bench/run.ts +210 -0
- package/bench/runner-baseline.ts +177 -0
- package/bench/runner-graphpilot.ts +131 -0
- package/bench/score-agent-tier.ts +191 -0
- package/bench/score.ts +59 -0
- package/bench/tasks.ts +236 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +162 -0
- package/dist/cli.js.map +1 -0
- package/dist/edges.d.ts +57 -0
- package/dist/edges.js +170 -0
- package/dist/edges.js.map +1 -0
- package/dist/git.d.ts +95 -0
- package/dist/git.js +247 -0
- package/dist/git.js.map +1 -0
- package/dist/graph-schema.d.ts +36 -0
- package/dist/graph-schema.js +208 -0
- package/dist/graph-schema.js.map +1 -0
- package/dist/impact.d.ts +99 -0
- package/dist/impact.js +123 -0
- package/dist/impact.js.map +1 -0
- package/dist/indexer.d.ts +28 -0
- package/dist/indexer.js +111 -0
- package/dist/indexer.js.map +1 -0
- package/dist/interactions.d.ts +46 -0
- package/dist/interactions.js +0 -0
- package/dist/interactions.js.map +1 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +567 -0
- package/dist/mcp.js.map +1 -0
- package/dist/parser.d.ts +24 -0
- package/dist/parser.js +128 -0
- package/dist/parser.js.map +1 -0
- package/dist/provenance.d.ts +74 -0
- package/dist/provenance.js +95 -0
- package/dist/provenance.js.map +1 -0
- package/dist/query.d.ts +68 -0
- package/dist/query.js +127 -0
- package/dist/query.js.map +1 -0
- package/dist/redact.d.ts +30 -0
- package/dist/redact.js +117 -0
- package/dist/redact.js.map +1 -0
- package/dist/storage.d.ts +42 -0
- package/dist/storage.js +85 -0
- package/dist/storage.js.map +1 -0
- package/dist/symbols.d.ts +20 -0
- package/dist/symbols.js +140 -0
- package/dist/symbols.js.map +1 -0
- package/dist/validation.d.ts +9 -0
- package/dist/validation.js +65 -0
- package/dist/validation.js.map +1 -0
- package/dist/validators.d.ts +55 -0
- package/dist/validators.js +205 -0
- package/dist/validators.js.map +1 -0
- package/dist/watcher.d.ts +86 -0
- package/dist/watcher.js +310 -0
- package/dist/watcher.js.map +1 -0
- package/docs/architecture.md +311 -0
- package/docs/limitations.md +156 -0
- package/docs/mcp-setup.md +231 -0
- package/docs/quickstart.md +202 -0
- package/eslint.config.js +148 -0
- package/lefthook.yml +81 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +6 -0
- package/scripts/smoke-stdio.mjs +97 -0
- package/src/cli.ts +171 -0
- package/src/edges.ts +202 -0
- package/src/git.ts +255 -0
- package/src/graph-schema.ts +229 -0
- package/src/impact.ts +218 -0
- package/src/indexer.ts +152 -0
- package/src/interactions.ts +0 -0
- package/src/mcp.ts +652 -0
- package/src/parser.ts +138 -0
- package/src/provenance.ts +115 -0
- package/src/query.ts +148 -0
- package/src/redact.ts +122 -0
- package/src/storage.ts +115 -0
- package/src/symbols.ts +173 -0
- package/src/validation.ts +69 -0
- package/src/validators.ts +253 -0
- package/src/watcher.ts +383 -0
- package/tests/edges.test.ts +175 -0
- package/tests/fixtures/sample.ts +32 -0
- package/tests/git.test.ts +303 -0
- package/tests/graph-schema.test.ts +321 -0
- package/tests/impact.test.ts +454 -0
- package/tests/interactions.test.ts +180 -0
- package/tests/lint-policy.test.ts +106 -0
- package/tests/mcp-stdio.test.ts +171 -0
- package/tests/mcp.test.ts +335 -0
- package/tests/parser.test.ts +31 -0
- package/tests/provenance.test.ts +132 -0
- package/tests/query.test.ts +160 -0
- package/tests/redact.test.ts +167 -0
- package/tests/security.test.ts +144 -0
- package/tests/symbols.test.ts +78 -0
- package/tests/validators.test.ts +193 -0
- package/tests/watcher.test.ts +250 -0
- package/tsconfig.json +18 -0
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { GraphIndex } from './query.js';
|
|
6
|
+
import { indexDirectory } from './indexer.js';
|
|
7
|
+
import { loadGraph, saveGraph, repoIdFor } from './storage.js';
|
|
8
|
+
import { validateRootPath } from './validation.js';
|
|
9
|
+
import { validateGpIndex, validateGpRecall, validateGpCallers, validateGpImpact, validateGpStats, } from './validators.js';
|
|
10
|
+
import { withInteractionLog } from './interactions.js';
|
|
11
|
+
import { analyzeImpact } from './impact.js';
|
|
12
|
+
import { getChangedFiles, resolveIndexRoot } from './git.js';
|
|
13
|
+
const SERVER_NAME = 'graphpilot';
|
|
14
|
+
const SERVER_VERSION = '0.0.1';
|
|
15
|
+
// ----------------------------------------------------------------------------
|
|
16
|
+
// Per-process cache of loaded GraphIndex by absolute repo path.
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
const indexCache = new Map();
|
|
19
|
+
function getOrLoadIndex(rawPath) {
|
|
20
|
+
// Re-root to the git worktree top so MCP tool calls from a subdir of a
|
|
21
|
+
// worktree still resolve to the branch-level index. Outside git this is
|
|
22
|
+
// a no-op.
|
|
23
|
+
const { root } = resolveIndexRoot(rawPath ?? process.cwd());
|
|
24
|
+
const cached = indexCache.get(root);
|
|
25
|
+
if (cached)
|
|
26
|
+
return { idx: cached, root };
|
|
27
|
+
const graph = loadGraph(root);
|
|
28
|
+
if (!graph) {
|
|
29
|
+
return {
|
|
30
|
+
root,
|
|
31
|
+
error: `No GraphPilot index found for ${root}.\n` +
|
|
32
|
+
`Ask the user to run \`graphpilot index ${rawPath ?? '.'}\` first, or ` +
|
|
33
|
+
`call the gp_index tool to build one.`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const idx = new GraphIndex(graph);
|
|
37
|
+
indexCache.set(root, idx);
|
|
38
|
+
return { idx, root };
|
|
39
|
+
}
|
|
40
|
+
function invalidateCache(absRoot) {
|
|
41
|
+
indexCache.delete(absRoot);
|
|
42
|
+
}
|
|
43
|
+
// ----------------------------------------------------------------------------
|
|
44
|
+
// Tool-output formatting helpers (terse, agent-friendly text).
|
|
45
|
+
// ----------------------------------------------------------------------------
|
|
46
|
+
/**
|
|
47
|
+
* Render the short SHA suffix for an inline evidence anchor. Returns an
|
|
48
|
+
* empty string when the indexed root isn't in a git repo.
|
|
49
|
+
*
|
|
50
|
+
* Format: " @ ab12cd3"
|
|
51
|
+
*/
|
|
52
|
+
function shaTag(idx) {
|
|
53
|
+
const sha = idx.graph.indexedSha;
|
|
54
|
+
if (!sha)
|
|
55
|
+
return '';
|
|
56
|
+
return ' @ ' + sha.slice(0, 7);
|
|
57
|
+
}
|
|
58
|
+
function fmtSymbol(s, idx, index) {
|
|
59
|
+
const prefix = index !== undefined ? `${index + 1}. ` : '';
|
|
60
|
+
const parentTag = s.parent ? `${s.parent}.` : '';
|
|
61
|
+
const exp = s.exported ? ' [exported]' : '';
|
|
62
|
+
// Evidence anchor: file:line @ sha (when in a git repo) — agent can
|
|
63
|
+
// include this verbatim in its reply for the user to verify.
|
|
64
|
+
return (`${prefix}${parentTag}${s.name} (${s.kind}) ${s.file}:${s.line}${shaTag(idx)}${exp}\n` +
|
|
65
|
+
` ${s.signature}`);
|
|
66
|
+
}
|
|
67
|
+
function fmtEdge(e, idx, index) {
|
|
68
|
+
const prefix = index !== undefined ? `${index + 1}. ` : '';
|
|
69
|
+
// We don't know upfront whether this is a callers or callees listing, so the
|
|
70
|
+
// safest thing is to show both ends.
|
|
71
|
+
const fromSym = idx.findById(e.fromId);
|
|
72
|
+
const fromName = fromSym
|
|
73
|
+
? `${fromSym.parent ? fromSym.parent + '.' : ''}${fromSym.name}`
|
|
74
|
+
: e.fromId;
|
|
75
|
+
const toLabel = e.toId
|
|
76
|
+
? (() => {
|
|
77
|
+
const t = idx.findById(e.toId);
|
|
78
|
+
return t ? `${t.parent ? t.parent + '.' : ''}${t.name}` : e.toName;
|
|
79
|
+
})()
|
|
80
|
+
: `${e.toName} <unresolved>`;
|
|
81
|
+
// Evidence anchor on the call site (the file:line where the call occurs).
|
|
82
|
+
return `${prefix}${fromName} → ${toLabel} (${e.file}:${e.line}${shaTag(idx)})`;
|
|
83
|
+
}
|
|
84
|
+
// ----------------------------------------------------------------------------
|
|
85
|
+
// Tool catalog (sent to clients via tools/list)
|
|
86
|
+
// ----------------------------------------------------------------------------
|
|
87
|
+
const TOOLS = [
|
|
88
|
+
{
|
|
89
|
+
name: 'gp_stats',
|
|
90
|
+
description: 'Show GraphPilot index health for a repo (symbol count, edge count, ' +
|
|
91
|
+
'when indexed). Use this to confirm the index is fresh before asking ' +
|
|
92
|
+
'structural questions.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
path: { type: 'string', description: 'Repo path. Default: cwd.' },
|
|
97
|
+
},
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'gp_index',
|
|
103
|
+
description: 'Index or re-index a TypeScript/JavaScript repo into GraphPilot. Call ' +
|
|
104
|
+
'this when the codebase has changed materially or when no index exists.',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
path: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'Repo path to index. Default: cwd.',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
additionalProperties: false,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'gp_recall',
|
|
118
|
+
description: 'Look up symbols (functions, classes, methods, types, interfaces) by ' +
|
|
119
|
+
'name. Returns kind, location, and signature. Default: exact ' +
|
|
120
|
+
'case-insensitive. Pass substring:true for partial matches.',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
query: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'Symbol name to look up.',
|
|
127
|
+
},
|
|
128
|
+
limit: {
|
|
129
|
+
type: 'integer',
|
|
130
|
+
minimum: 1,
|
|
131
|
+
maximum: 50,
|
|
132
|
+
description: 'Max results (default 10).',
|
|
133
|
+
},
|
|
134
|
+
substring: {
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
description: 'Enable substring match (default false).',
|
|
137
|
+
},
|
|
138
|
+
path: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'Repo path. Default: cwd.',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ['query'],
|
|
144
|
+
additionalProperties: false,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'gp_callers',
|
|
149
|
+
description: 'List callers of a symbol (who calls it) or callees (what it calls). ' +
|
|
150
|
+
"Use direction='callers' for impact analysis ('what breaks if I " +
|
|
151
|
+
"change this?'); direction='callees' to see what a function depends on.",
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
symbol: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
description: 'Symbol name or full id.',
|
|
158
|
+
},
|
|
159
|
+
direction: {
|
|
160
|
+
type: 'string',
|
|
161
|
+
enum: ['callers', 'callees'],
|
|
162
|
+
description: "Default 'callers'.",
|
|
163
|
+
},
|
|
164
|
+
limit: {
|
|
165
|
+
type: 'integer',
|
|
166
|
+
minimum: 1,
|
|
167
|
+
maximum: 100,
|
|
168
|
+
description: 'Max edges (default 50).',
|
|
169
|
+
},
|
|
170
|
+
includeUnresolved: {
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
description: 'Include external/stdlib calls (default true).',
|
|
173
|
+
},
|
|
174
|
+
path: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
description: 'Repo path. Default: cwd.',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: ['symbol'],
|
|
180
|
+
additionalProperties: false,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'gp_impact',
|
|
185
|
+
description: 'Analyze the BLAST RADIUS of changing a symbol. Returns direct callers, ' +
|
|
186
|
+
'transitive callers (default depth 3), tests likely affected, and ' +
|
|
187
|
+
'whether the symbol is part of the public API (exported). ' +
|
|
188
|
+
'Use this BEFORE proposing a rename, signature change, or behavior ' +
|
|
189
|
+
'change — it answers "what breaks if I change X?" in one call instead ' +
|
|
190
|
+
'of composing multiple gp_callers queries. ' +
|
|
191
|
+
'Pass `since: <commit|branch>` to restrict callers to files changed ' +
|
|
192
|
+
'since that ref — ideal for PR review ("what does this branch touch?") ' +
|
|
193
|
+
'and refactor scoping.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
symbol: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
description: 'Symbol name or full id to analyze.',
|
|
200
|
+
},
|
|
201
|
+
depth: {
|
|
202
|
+
type: 'integer',
|
|
203
|
+
minimum: 1,
|
|
204
|
+
maximum: 5,
|
|
205
|
+
description: 'BFS depth over the callers graph. Default 3.',
|
|
206
|
+
},
|
|
207
|
+
path: {
|
|
208
|
+
type: 'string',
|
|
209
|
+
description: 'Repo path. Default: cwd.',
|
|
210
|
+
},
|
|
211
|
+
since: {
|
|
212
|
+
type: 'string',
|
|
213
|
+
description: 'Optional commit SHA, tag, or branch. When set, restricts ' +
|
|
214
|
+
'callers to files changed between that ref and HEAD.',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
required: ['symbol'],
|
|
218
|
+
additionalProperties: false,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
function handleGpStats(args) {
|
|
223
|
+
const out = getOrLoadIndex(args.path);
|
|
224
|
+
if ('error' in out) {
|
|
225
|
+
return { text: out.error, results: 0, isError: true };
|
|
226
|
+
}
|
|
227
|
+
const { idx } = out;
|
|
228
|
+
const s = idx.stats;
|
|
229
|
+
const g = idx.graph;
|
|
230
|
+
// Git provenance — surface branch + short SHA so the agent can cite
|
|
231
|
+
// the exact commit the index was built against. Omitted gracefully
|
|
232
|
+
// when the indexed root isn't a git repo.
|
|
233
|
+
const gitLines = [];
|
|
234
|
+
if (g.indexedBranch)
|
|
235
|
+
gitLines.push(`Branch: ${g.indexedBranch}`);
|
|
236
|
+
if (g.indexedSha)
|
|
237
|
+
gitLines.push(`Commit SHA: ${g.indexedSha.slice(0, 7)}`);
|
|
238
|
+
const text = [
|
|
239
|
+
`Repo: ${g.rootPath}`,
|
|
240
|
+
`Repo id: ${g.repoId}`,
|
|
241
|
+
`Indexed at: ${g.indexedAt}`,
|
|
242
|
+
...gitLines,
|
|
243
|
+
`Files: ${g.filesIndexed}`,
|
|
244
|
+
`Symbols: ${s.symbols}`,
|
|
245
|
+
`Calls: ${s.edges} (${s.resolvedEdges} resolved)`,
|
|
246
|
+
].join('\n');
|
|
247
|
+
return { text, results: 1 };
|
|
248
|
+
}
|
|
249
|
+
async function handleGpIndex(args) {
|
|
250
|
+
const requested = resolve(args.path ?? process.cwd());
|
|
251
|
+
const { root, redirected } = resolveIndexRoot(requested);
|
|
252
|
+
const refusal = validateRootPath(root);
|
|
253
|
+
if (refusal)
|
|
254
|
+
return { text: `Error: ${refusal}`, results: 0, isError: true };
|
|
255
|
+
const result = await indexDirectory(root);
|
|
256
|
+
const graph = {
|
|
257
|
+
version: 1,
|
|
258
|
+
repoId: repoIdFor(root),
|
|
259
|
+
rootPath: root,
|
|
260
|
+
indexedAt: new Date().toISOString(),
|
|
261
|
+
filesIndexed: result.filesIndexed,
|
|
262
|
+
symbolCount: result.symbols.length,
|
|
263
|
+
edgeCount: result.edges.length,
|
|
264
|
+
symbols: result.symbols,
|
|
265
|
+
edges: result.edges,
|
|
266
|
+
indexedSha: result.git.sha,
|
|
267
|
+
indexedBranch: result.git.branch,
|
|
268
|
+
};
|
|
269
|
+
saveGraph(graph);
|
|
270
|
+
// After re-index, drop the cached GraphIndex for this root so subsequent
|
|
271
|
+
// calls see fresh data.
|
|
272
|
+
invalidateCache(root);
|
|
273
|
+
const resolved = result.edges.filter((e) => e.toId !== null).length;
|
|
274
|
+
// Mirror cmdIndex: surface git provenance in the agent-visible output so
|
|
275
|
+
// the agent can cite the exact commit it just indexed against.
|
|
276
|
+
let gitLine = '';
|
|
277
|
+
if (result.git.shortSha || result.git.branch) {
|
|
278
|
+
const parts = [];
|
|
279
|
+
if (result.git.branch)
|
|
280
|
+
parts.push(`branch ${result.git.branch}`);
|
|
281
|
+
if (result.git.shortSha)
|
|
282
|
+
parts.push(`sha ${result.git.shortSha}`);
|
|
283
|
+
gitLine = ` Git: ${parts.join(' @ ')}\n`;
|
|
284
|
+
}
|
|
285
|
+
const wtNote = redirected
|
|
286
|
+
? `(re-rooted to git worktree top; requested path was ${requested})\n`
|
|
287
|
+
: '';
|
|
288
|
+
const text = `Indexed ${root}\n` +
|
|
289
|
+
wtNote +
|
|
290
|
+
` Files: ${result.filesIndexed}\n` +
|
|
291
|
+
` Symbols: ${result.symbols.length}\n` +
|
|
292
|
+
` Calls: ${result.edges.length} (${resolved} resolved)\n` +
|
|
293
|
+
gitLine +
|
|
294
|
+
` Took: ${result.durationMs}ms`;
|
|
295
|
+
return { text, results: 1 };
|
|
296
|
+
}
|
|
297
|
+
function handleGpRecall(args) {
|
|
298
|
+
const out = getOrLoadIndex(args.path);
|
|
299
|
+
if ('error' in out) {
|
|
300
|
+
return { text: out.error, results: 0, isError: true };
|
|
301
|
+
}
|
|
302
|
+
const { idx } = out;
|
|
303
|
+
const matches = idx.findByName(args.query, {
|
|
304
|
+
limit: args.limit,
|
|
305
|
+
substring: args.substring,
|
|
306
|
+
});
|
|
307
|
+
if (matches.length === 0) {
|
|
308
|
+
return {
|
|
309
|
+
text: `No symbols match "${args.query}".`,
|
|
310
|
+
results: 0,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const header = `Found ${matches.length} symbol(s) matching "${args.query}":\n`;
|
|
314
|
+
const body = matches.map((s, i) => fmtSymbol(s, idx, i)).join('\n\n');
|
|
315
|
+
return { text: header + body, results: matches.length };
|
|
316
|
+
}
|
|
317
|
+
function handleGpCallers(args) {
|
|
318
|
+
const out = getOrLoadIndex(args.path);
|
|
319
|
+
if ('error' in out) {
|
|
320
|
+
return { text: out.error, results: 0, isError: true };
|
|
321
|
+
}
|
|
322
|
+
const { idx } = out;
|
|
323
|
+
const direction = args.direction ?? 'callers';
|
|
324
|
+
const target = idx.resolveSymbol(args.symbol);
|
|
325
|
+
if (!target) {
|
|
326
|
+
return {
|
|
327
|
+
text: `No symbol found matching "${args.symbol}".`,
|
|
328
|
+
results: 0,
|
|
329
|
+
isError: true,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const edges = direction === 'callers'
|
|
333
|
+
? idx.callers(target.id, { limit: args.limit })
|
|
334
|
+
: idx.callees(target.id, {
|
|
335
|
+
limit: args.limit,
|
|
336
|
+
includeUnresolved: args.includeUnresolved !== false,
|
|
337
|
+
});
|
|
338
|
+
if (edges.length === 0) {
|
|
339
|
+
const label = direction === 'callers' ? 'callers' : 'callees';
|
|
340
|
+
return {
|
|
341
|
+
text: `No ${label} found for ${target.name} (${target.file}:${target.line}).`,
|
|
342
|
+
results: 0,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
const verb = direction === 'callers' ? 'callers of' : 'callees of';
|
|
346
|
+
// Evidence anchor on the target itself: file:line @ sha so the agent can
|
|
347
|
+
// verify the symbol it's about to act on really lives where we say.
|
|
348
|
+
const header = `${edges.length} ${verb} ${target.name} ` + `(${target.file}:${target.line}${shaTag(idx)}):\n`;
|
|
349
|
+
const body = edges.map((e, i) => fmtEdge(e, idx, i)).join('\n');
|
|
350
|
+
return { text: header + body, results: edges.length };
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Format an ImpactCaller for the agent's text output. Includes via-symbol
|
|
354
|
+
* context when depth > 1 so the agent can trace the chain.
|
|
355
|
+
*/
|
|
356
|
+
function fmtImpactCaller(c, idx) {
|
|
357
|
+
// Evidence anchor on every caller — file:line @ sha lets the agent
|
|
358
|
+
// (and ultimately the user) verify each impact entry.
|
|
359
|
+
const head = ` ${c.symbol.name} (${c.symbol.file}:${c.symbol.line}${shaTag(idx)})`;
|
|
360
|
+
if (c.depth === 1)
|
|
361
|
+
return head;
|
|
362
|
+
// For transitive callers, show the immediate hop the edge connects to —
|
|
363
|
+
// the symbol that this caller called (one closer to the target).
|
|
364
|
+
const via = c.edge.toId ? idx.findById(c.edge.toId) : null;
|
|
365
|
+
const viaText = via ? ` ← calls ${via.name}` : ` ← calls ${c.edge.toName}`;
|
|
366
|
+
return `${head} [depth ${c.depth}]${viaText}`;
|
|
367
|
+
}
|
|
368
|
+
function fmtImpactReport(report, idx, diff = { changedFileCount: null }) {
|
|
369
|
+
const t = report.target;
|
|
370
|
+
const lines = [];
|
|
371
|
+
lines.push(`Impact of changing ${t.name} (${t.file}:${t.line}, kind=${t.kind}):`);
|
|
372
|
+
if (diff.since !== undefined) {
|
|
373
|
+
lines.push(`(differential mode: scoped to ${diff.changedFileCount ?? 0} file(s) changed since ${diff.since})`);
|
|
374
|
+
}
|
|
375
|
+
lines.push('');
|
|
376
|
+
lines.push(`Direct callers (${report.stats.directCount}):`);
|
|
377
|
+
if (report.directCallers.length === 0) {
|
|
378
|
+
lines.push(' (none in indexed code)');
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
for (const c of report.directCallers)
|
|
382
|
+
lines.push(fmtImpactCaller(c, idx));
|
|
383
|
+
}
|
|
384
|
+
lines.push('');
|
|
385
|
+
if (report.transitiveCallers.length > 0) {
|
|
386
|
+
lines.push(`Transitive callers (${report.stats.transitiveCount}):`);
|
|
387
|
+
for (const c of report.transitiveCallers)
|
|
388
|
+
lines.push(fmtImpactCaller(c, idx));
|
|
389
|
+
lines.push('');
|
|
390
|
+
}
|
|
391
|
+
lines.push(`Tests likely affected (${report.stats.testCount}):`);
|
|
392
|
+
if (report.testsAffected.length === 0) {
|
|
393
|
+
lines.push(' (no test files reach this symbol)');
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
for (const c of report.testsAffected) {
|
|
397
|
+
lines.push(` ${c.symbol.file}:${c.symbol.line} — ${c.symbol.name}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
lines.push('');
|
|
401
|
+
lines.push(`Public API: ${report.publicApi.exported ? 'YES (exported)' : 'no (internal)'}`);
|
|
402
|
+
lines.push(` ${report.publicApi.reason}`);
|
|
403
|
+
lines.push('');
|
|
404
|
+
const totalCallers = report.stats.directCount + report.stats.transitiveCount;
|
|
405
|
+
const summary = totalCallers === 0
|
|
406
|
+
? `Summary: ${t.name} has no callers in the indexed code. ` +
|
|
407
|
+
`Safe to rename in-repo${report.publicApi.exported
|
|
408
|
+
? '; external consumers (if any) are not visible to this index.'
|
|
409
|
+
: '.'}`
|
|
410
|
+
: `Summary: ${totalCallers} callsite(s) across ` +
|
|
411
|
+
`${report.stats.sourceFileCount} file(s)` +
|
|
412
|
+
(report.stats.testCount > 0 ? ` + ${report.stats.testCount} test(s)` : '') +
|
|
413
|
+
`. ` +
|
|
414
|
+
(report.publicApi.exported
|
|
415
|
+
? `Renaming is a BREAKING change for the module's public API.`
|
|
416
|
+
: `Renaming is contained within the repo.`);
|
|
417
|
+
lines.push(summary);
|
|
418
|
+
if (report.stats.truncated) {
|
|
419
|
+
lines.push('');
|
|
420
|
+
lines.push('(Output truncated — per-level cap hit. Re-run with a smaller depth ' +
|
|
421
|
+
'or query specific callers via gp_callers for full detail.)');
|
|
422
|
+
}
|
|
423
|
+
return lines.join('\n');
|
|
424
|
+
}
|
|
425
|
+
async function handleGpImpact(args) {
|
|
426
|
+
const out = getOrLoadIndex(args.path);
|
|
427
|
+
if ('error' in out) {
|
|
428
|
+
return { text: out.error, results: 0, isError: true };
|
|
429
|
+
}
|
|
430
|
+
const { idx, root } = out;
|
|
431
|
+
let changedFiles = null;
|
|
432
|
+
if (args.since !== undefined) {
|
|
433
|
+
changedFiles = await getChangedFiles(root, args.since);
|
|
434
|
+
if (changedFiles === null) {
|
|
435
|
+
return {
|
|
436
|
+
text: `Could not compute diff against "${args.since}" — either the ref ` +
|
|
437
|
+
`does not resolve to a commit, or ${root} is not a git repo. ` +
|
|
438
|
+
`Drop the \`since\` argument to see the full blast radius.`,
|
|
439
|
+
results: 0,
|
|
440
|
+
isError: true,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const report = analyzeImpact(idx, args.symbol, {
|
|
445
|
+
depth: args.depth,
|
|
446
|
+
changedFiles,
|
|
447
|
+
});
|
|
448
|
+
if (!report) {
|
|
449
|
+
return {
|
|
450
|
+
text: `No symbol found matching "${args.symbol}".`,
|
|
451
|
+
results: 0,
|
|
452
|
+
isError: true,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const text = fmtImpactReport(report, idx, {
|
|
456
|
+
since: args.since,
|
|
457
|
+
changedFileCount: changedFiles?.size ?? null,
|
|
458
|
+
});
|
|
459
|
+
const totalResults = report.stats.directCount + report.stats.transitiveCount;
|
|
460
|
+
return { text, results: totalResults };
|
|
461
|
+
}
|
|
462
|
+
// ----------------------------------------------------------------------------
|
|
463
|
+
// Server builder + dispatcher
|
|
464
|
+
// ----------------------------------------------------------------------------
|
|
465
|
+
export function buildMcpServer() {
|
|
466
|
+
const server = new Server({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {} } });
|
|
467
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
468
|
+
tools: TOOLS,
|
|
469
|
+
}));
|
|
470
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
471
|
+
const { name, arguments: args } = req.params;
|
|
472
|
+
const rawArgs = (args ?? {});
|
|
473
|
+
// We need to know the repo path *before* validation to drive the log,
|
|
474
|
+
// so the log captures even invalid-input attempts. Fall back to cwd.
|
|
475
|
+
// Resolve to the worktree top so per-tool calls from a subdir land in
|
|
476
|
+
// the same interaction log as the rest of the branch's work.
|
|
477
|
+
const requestedLogPath = typeof rawArgs.path === 'string' ? rawArgs.path : process.cwd();
|
|
478
|
+
const repoRootForLog = resolveIndexRoot(requestedLogPath).root;
|
|
479
|
+
return withInteractionLog(repoRootForLog, name, rawArgs, async () => {
|
|
480
|
+
// Validate first
|
|
481
|
+
let result;
|
|
482
|
+
switch (name) {
|
|
483
|
+
case 'gp_stats': {
|
|
484
|
+
const v = validateGpStats(rawArgs);
|
|
485
|
+
if (!v.ok) {
|
|
486
|
+
result = { text: `Invalid input: ${v.error}`, results: 0, isError: true };
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
result = handleGpStats(v.value);
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
case 'gp_index': {
|
|
493
|
+
const v = validateGpIndex(rawArgs);
|
|
494
|
+
if (!v.ok) {
|
|
495
|
+
result = { text: `Invalid input: ${v.error}`, results: 0, isError: true };
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
result = await handleGpIndex(v.value);
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
case 'gp_recall': {
|
|
502
|
+
const v = validateGpRecall(rawArgs);
|
|
503
|
+
if (!v.ok) {
|
|
504
|
+
result = { text: `Invalid input: ${v.error}`, results: 0, isError: true };
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
result = handleGpRecall(v.value);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
case 'gp_callers': {
|
|
511
|
+
const v = validateGpCallers(rawArgs);
|
|
512
|
+
if (!v.ok) {
|
|
513
|
+
result = { text: `Invalid input: ${v.error}`, results: 0, isError: true };
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
result = handleGpCallers(v.value);
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
case 'gp_impact': {
|
|
520
|
+
const v = validateGpImpact(rawArgs);
|
|
521
|
+
if (!v.ok) {
|
|
522
|
+
result = { text: `Invalid input: ${v.error}`, results: 0, isError: true };
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
result = await handleGpImpact(v.value);
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
default:
|
|
529
|
+
result = { text: `Unknown tool: ${name}`, results: 0, isError: true };
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
// Caller (this lambda) returns to the dispatcher which sends to the
|
|
533
|
+
// MCP client. We also return interaction-log metadata.
|
|
534
|
+
value: {
|
|
535
|
+
content: [{ type: 'text', text: result.text }],
|
|
536
|
+
isError: result.isError,
|
|
537
|
+
},
|
|
538
|
+
results: result.results,
|
|
539
|
+
error: result.isError ? result.text.slice(0, 200) : undefined,
|
|
540
|
+
};
|
|
541
|
+
}).then((v) => v);
|
|
542
|
+
});
|
|
543
|
+
return server;
|
|
544
|
+
}
|
|
545
|
+
export async function startMcpServer() {
|
|
546
|
+
const server = buildMcpServer();
|
|
547
|
+
const transport = new StdioServerTransport();
|
|
548
|
+
await server.connect(transport);
|
|
549
|
+
process.stderr.write(`[graphpilot] MCP server ready (stdio).\n`);
|
|
550
|
+
// server.connect() resolves once handlers are wired — it does NOT block.
|
|
551
|
+
// We have to keep this promise pending until the client disconnects, or the
|
|
552
|
+
// CLI's `process.exit(0)` will kill us before the initialize handshake
|
|
553
|
+
// completes. Resolve on either the transport's onclose, or stdin EOF.
|
|
554
|
+
await new Promise((resolve) => {
|
|
555
|
+
let done = false;
|
|
556
|
+
const finish = () => {
|
|
557
|
+
if (done)
|
|
558
|
+
return;
|
|
559
|
+
done = true;
|
|
560
|
+
resolve();
|
|
561
|
+
};
|
|
562
|
+
transport.onclose = finish;
|
|
563
|
+
process.stdin.once('end', finish);
|
|
564
|
+
process.stdin.once('close', finish);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAC3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,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAEjE,yEAAyE;IACzE,4EAA4E;IAC5E,uEAAuE;IACvE,sEAAsE;IACtE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,IAAI,IAAI;gBAAE,OAAO;YACjB,IAAI,GAAG,IAAI,CAAC;YACZ,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Parser from 'tree-sitter';
|
|
2
|
+
export interface ParsedFile {
|
|
3
|
+
path: string;
|
|
4
|
+
lang: 'typescript' | 'tsx' | 'javascript' | 'jsx';
|
|
5
|
+
tree: Parser.Tree;
|
|
6
|
+
source: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function detectLang(path: string): ParsedFile['lang'] | null;
|
|
9
|
+
export declare function parseFile(path: string): ParsedFile | null;
|
|
10
|
+
export declare function parseSource(path: string, source: string, lang: ParsedFile['lang']): ParsedFile;
|
|
11
|
+
/**
|
|
12
|
+
* Walk the tree and yield every node. Depth-first, pre-order.
|
|
13
|
+
*
|
|
14
|
+
* Iterative (not recursive) so a deeply-nested AST can't blow the JS stack.
|
|
15
|
+
* Tree-sitter trees on real codebases hit ~50–80 depth; pathological generated
|
|
16
|
+
* code can go much deeper. Defence against T1.
|
|
17
|
+
*/
|
|
18
|
+
export declare function walk(node: Parser.SyntaxNode): Generator<Parser.SyntaxNode>;
|
|
19
|
+
/**
|
|
20
|
+
* Day-2 deliverable: list every function name in a parsed file.
|
|
21
|
+
* Catches: function declarations, arrow functions assigned to consts,
|
|
22
|
+
* class methods, function expressions assigned to variables.
|
|
23
|
+
*/
|
|
24
|
+
export declare function listFunctions(parsed: ParsedFile): string[];
|