@nithin554/code-crawler 0.1.81 → 0.1.82
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/README.md +105 -10
- package/dist/crawler.d.ts +2 -0
- package/dist/crawler.js +91 -16
- package/dist/crawler.js.map +1 -1
- package/dist/graph/budget.d.ts +10 -0
- package/dist/graph/budget.js +12 -0
- package/dist/graph/budget.js.map +1 -1
- package/dist/graph/changeImpact.d.ts +123 -0
- package/dist/graph/changeImpact.js +431 -0
- package/dist/graph/changeImpact.js.map +1 -0
- package/dist/graph/compact.d.ts +45 -0
- package/dist/graph/compact.js +57 -0
- package/dist/graph/compact.js.map +1 -0
- package/dist/graph/insights.d.ts +2 -0
- package/dist/graph/insights.js +5 -1
- package/dist/graph/insights.js.map +1 -1
- package/dist/graph/queries.d.ts +76 -2
- package/dist/graph/queries.js +123 -13
- package/dist/graph/queries.js.map +1 -1
- package/dist/graph/schema.d.ts +18 -3
- package/dist/graph/schema.js +1 -0
- package/dist/graph/schema.js.map +1 -1
- package/dist/graph/store.js +26 -4
- package/dist/graph/store.js.map +1 -1
- package/dist/parser/cache.d.ts +3 -2
- package/dist/parser/cache.js +2 -0
- package/dist/parser/cache.js.map +1 -1
- package/dist/parser/frameworks/fastapi.js +3 -0
- package/dist/parser/frameworks/fastapi.js.map +1 -1
- package/dist/parser/frameworks/index.d.ts +8 -0
- package/dist/parser/frameworks/index.js +39 -1
- package/dist/parser/frameworks/index.js.map +1 -1
- package/dist/parser/frameworks/lombok.d.ts +10 -0
- package/dist/parser/frameworks/lombok.js +14 -0
- package/dist/parser/frameworks/lombok.js.map +1 -0
- package/dist/parser/frameworks/spring.js +18 -0
- package/dist/parser/frameworks/spring.js.map +1 -1
- package/dist/parser/frameworks/types.d.ts +15 -0
- package/dist/parser/language.d.ts +47 -0
- package/dist/parser/languages/java.js +245 -17
- package/dist/parser/languages/java.js.map +1 -1
- package/dist/parser/languages/python.js +179 -8
- package/dist/parser/languages/python.js.map +1 -1
- package/dist/resolver/channels.d.ts +14 -0
- package/dist/resolver/channels.js +334 -0
- package/dist/resolver/channels.js.map +1 -0
- package/dist/resolver/common.d.ts +23 -2
- package/dist/resolver/common.js +46 -27
- package/dist/resolver/common.js.map +1 -1
- package/dist/resolver/genericResolver.d.ts +70 -2
- package/dist/resolver/genericResolver.js +165 -25
- package/dist/resolver/genericResolver.js.map +1 -1
- package/dist/resolver/javaResolver.js +31 -13
- package/dist/resolver/javaResolver.js.map +1 -1
- package/dist/resolver/types.d.ts +22 -0
- package/dist/resolver/types.js +13 -0
- package/dist/resolver/types.js.map +1 -1
- package/dist/server.js +238 -21
- package/dist/server.js.map +1 -1
- package/dist/toolGroups.d.ts +24 -0
- package/dist/toolGroups.js +67 -0
- package/dist/toolGroups.js.map +1 -0
- package/package.json +7 -2
- package/skills/code-crawler/SKILL.md +40 -5
- package/skills/code-crawler/reference/edge-semantics.md +115 -6
- package/skills/code-crawler/reference/tools.md +41 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/resolver/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/resolver/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAiEzD;;;GAGG;AACH,MAAM,OAAO,SAAS;IACpB,4DAA4D;IAC5D,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAChD,0CAA0C;IAC1C,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxC,wDAAwD;IACxD,YAAY,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC/C,wEAAwE;IACxE,YAAY,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC3C,2DAA2D;IAC3D,aAAa,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC5C,iDA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AAC,KAAmB;IAChD,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,KAAK,CAAC,aAAa,EAAE,CAAC;IACtB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB;QAClC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE;QACpB,CAAC,CAAC,IAAI,CAAC,QAAQ;YACb,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE;YACjC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAChB,OAAO,eAAe,KAAK,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -5,8 +5,10 @@ import { z } from "zod";
|
|
|
5
5
|
import { loadConfig } from "./config.js";
|
|
6
6
|
import { crawlProject } from "./crawler.js";
|
|
7
7
|
import { applyBudget, pageMeta } from "./graph/budget.js";
|
|
8
|
+
import { changeImpact } from "./graph/changeImpact.js";
|
|
9
|
+
import { compactify } from "./graph/compact.js";
|
|
8
10
|
import { explainSymbol, exportGraph, findCycles, findUnresolved, impactAnalysis, unresolvedForNode, } from "./graph/insights.js";
|
|
9
|
-
import { deadCode, externalDependencies, findAnnotated, findEntryPoints, findImplementations, findInjections, findReflections, findRoutes, getAspects, getCallees, getCallers, getDecorators, getSubgraph, hotspots, searchSymbols, suggestSymbols, traceExecution, tracePath, } from "./graph/queries.js";
|
|
11
|
+
import { deadCode, externalDependencies, findAnnotated, findEntryPoints, findEventFlows, findImplementations, findInjections, findReflections, findRoutes, getAspects, getCallees, getCallers, getDecorators, getSubgraph, hotspots, searchSymbols, suggestSymbols, traceExecution, tracePath, } from "./graph/queries.js";
|
|
10
12
|
import { EDGE_KINDS, NODE_KINDS } from "./graph/schema.js";
|
|
11
13
|
import { scopedStore } from "./projects.js";
|
|
12
14
|
import { SERVER_VERSION } from "./version.js";
|
|
@@ -103,6 +105,41 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
103
105
|
.optional()
|
|
104
106
|
.describe("Offset into the list; pass page.nextCursor from a previous response to continue."),
|
|
105
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Added to every tool's schema by `tool` below. Kept here so the description
|
|
110
|
+
* matches the projection in `compactify` rather than being reworded per tool.
|
|
111
|
+
*/
|
|
112
|
+
const compactParam = z
|
|
113
|
+
.boolean()
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('Return every symbol reference as its fully-qualified name ("pkg.Type#method") instead of an {id, name, kind, filePath} object. Typically removes 60-80% of a response, and more on deep traces. A class is "pkg.Type" and a member is "pkg.Type#member", so the name still says what it is; call get_node with the name when you need the metadata back.');
|
|
116
|
+
/**
|
|
117
|
+
* Apply the compact projection to a tool result. Only JSON text parts are
|
|
118
|
+
* touched; a non-JSON payload (export_graph) passes through unchanged.
|
|
119
|
+
*/
|
|
120
|
+
const compactResult = (result) => {
|
|
121
|
+
if (typeof result !== "object" || result === null)
|
|
122
|
+
return result;
|
|
123
|
+
const content = result.content;
|
|
124
|
+
if (!Array.isArray(content))
|
|
125
|
+
return result;
|
|
126
|
+
let projected = false;
|
|
127
|
+
const next = content.map((part) => {
|
|
128
|
+
const entry = part;
|
|
129
|
+
if (entry?.type !== "text" || typeof entry.text !== "string")
|
|
130
|
+
return part;
|
|
131
|
+
let parsed;
|
|
132
|
+
try {
|
|
133
|
+
parsed = JSON.parse(entry.text);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return part;
|
|
137
|
+
}
|
|
138
|
+
projected = true;
|
|
139
|
+
return { ...entry, text: JSON.stringify(compactify(parsed), null, 2) };
|
|
140
|
+
});
|
|
141
|
+
return projected ? { ...result, content: next } : result;
|
|
142
|
+
};
|
|
106
143
|
/**
|
|
107
144
|
* Attach a `page` block and cut the list when the caller asked for a budget.
|
|
108
145
|
* Counting keys keep reporting the full window size so clients can decide
|
|
@@ -127,15 +164,25 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
127
164
|
/**
|
|
128
165
|
* Every handler shares one error boundary so MCP clients always receive the
|
|
129
166
|
* same `{ ok, error, hint }` shape instead of a mix of throws and payloads.
|
|
167
|
+
*
|
|
168
|
+
* `compact` is added to every tool here rather than to each schema, because
|
|
169
|
+
* the projection is structural (see `compactify`) and a per-tool copy would
|
|
170
|
+
* drift the moment a new tool is added.
|
|
130
171
|
*/
|
|
131
172
|
const tool = (name, description, paramsSchema, handler) => {
|
|
132
173
|
const register = server.tool.bind(server);
|
|
133
|
-
|
|
174
|
+
const schema = {
|
|
175
|
+
...paramsSchema,
|
|
176
|
+
compact: compactParam,
|
|
177
|
+
};
|
|
178
|
+
register(name, description, schema, async (...args) => {
|
|
134
179
|
try {
|
|
135
180
|
// `crawl_project` names the project it wants; every other tool inherits
|
|
136
181
|
// the client's roots or the project the previous call selected.
|
|
137
182
|
const requested = name === "crawl_project" ? args[0]?.path : undefined;
|
|
138
|
-
|
|
183
|
+
const result = await scoped(typeof requested === "string" ? requested : undefined, () => handler(...args));
|
|
184
|
+
const compact = args[0]?.compact === true;
|
|
185
|
+
return compact ? compactResult(result) : result;
|
|
139
186
|
}
|
|
140
187
|
catch (err) {
|
|
141
188
|
return errorResult(err);
|
|
@@ -251,25 +298,30 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
251
298
|
: {}),
|
|
252
299
|
});
|
|
253
300
|
});
|
|
254
|
-
tool("get_callers", "Find every symbol that calls the given symbol, directly or transitively (the call graph above it).
|
|
301
|
+
tool("get_callers", "Find every symbol that calls the given symbol, directly or transitively (the call graph above it). Follows virtual-dispatch and framework event edges by default, because a method reached only through either one is still called; pass include_dynamic: false and include_events: false for a static-only view. Each caller reports the edge kind and, when the edge has one, its confidence. When the callee sits behind a run-time proxy, direct callers also report the proxy kind, whether the container can honour the annotation at all, and whether the call is a self-invocation that never reaches the proxy.", {
|
|
255
302
|
symbol: z.string().describe("Method/constructor id or qualified name."),
|
|
256
303
|
transitive: z.boolean().optional().describe("Include transitive callers (default true)."),
|
|
257
304
|
include_dynamic: z
|
|
258
305
|
.boolean()
|
|
259
306
|
.optional()
|
|
260
|
-
.describe("
|
|
307
|
+
.describe("Follow DYNAMIC_DISPATCH edges (virtual/interface targets). Default true — pass false to see only static CALLS edges."),
|
|
261
308
|
include_advice: z
|
|
262
309
|
.boolean()
|
|
263
310
|
.optional()
|
|
264
311
|
.describe("Also follow ADVISES edges (aspect advice methods)."),
|
|
312
|
+
include_events: z
|
|
313
|
+
.boolean()
|
|
314
|
+
.optional()
|
|
315
|
+
.describe("Follow EMITS edges (event/message publication -> listener). Default true — pass false to ignore framework event wiring."),
|
|
265
316
|
max_depth: z.number().int().min(1).max(50).optional().describe("Traversal depth cap."),
|
|
266
317
|
limit: z.number().int().min(1).max(500).optional().describe("Max callers returned."),
|
|
267
318
|
...budgetParams,
|
|
268
|
-
}, async ({ symbol, transitive, include_dynamic, include_advice, max_depth, limit, max_tokens, cursor, }) => {
|
|
319
|
+
}, async ({ symbol, transitive, include_dynamic, include_advice, include_events, max_depth, limit, max_tokens, cursor, }) => {
|
|
269
320
|
const result = getCallers(store, symbol, {
|
|
270
321
|
transitive,
|
|
271
322
|
includeDynamic: include_dynamic,
|
|
272
323
|
includeAdvice: include_advice,
|
|
324
|
+
includeEvents: include_events,
|
|
273
325
|
maxDepth: max_depth,
|
|
274
326
|
limit,
|
|
275
327
|
});
|
|
@@ -280,31 +332,45 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
280
332
|
depth: c.depth,
|
|
281
333
|
callSiteLine: line(c.callSiteLine),
|
|
282
334
|
edgeKind: c.edgeKind,
|
|
335
|
+
...(c.confidence !== undefined ? { confidence: c.confidence } : {}),
|
|
336
|
+
...(c.resolved !== undefined ? { resolved: c.resolved } : {}),
|
|
337
|
+
...(c.conditional !== undefined ? { conditional: c.conditional } : {}),
|
|
338
|
+
...(c.controlFlow ? { controlFlow: c.controlFlow } : {}),
|
|
339
|
+
...(c.guards ? { guards: c.guards } : {}),
|
|
283
340
|
}));
|
|
284
|
-
return text(paged({
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
341
|
+
return text(paged({
|
|
342
|
+
target: ref(result.target),
|
|
343
|
+
count: callers.length,
|
|
344
|
+
callers,
|
|
345
|
+
edgesFollowed: result.edgesFollowed,
|
|
346
|
+
includeDynamic: result.includeDynamic,
|
|
347
|
+
includeAdvice: result.includeAdvice,
|
|
348
|
+
}, "callers", callers, { max_tokens, cursor }));
|
|
288
349
|
});
|
|
289
|
-
tool("get_callees", "Find every symbol the given symbol calls, directly or transitively (the call graph below it).
|
|
350
|
+
tool("get_callees", "Find every symbol the given symbol calls, directly or transitively (the call graph below it). Follows virtual/interface dispatch and framework event edges by default; pass include_dynamic: false and include_events: false for a static-only view. Each callee reports the edge kind and, when the edge has one, its confidence.", {
|
|
290
351
|
symbol: z.string().describe("Method/constructor id or qualified name."),
|
|
291
352
|
transitive: z.boolean().optional().describe("Include transitive callees (default true)."),
|
|
292
353
|
include_dynamic: z
|
|
293
354
|
.boolean()
|
|
294
355
|
.optional()
|
|
295
|
-
.describe("
|
|
356
|
+
.describe("Follow DYNAMIC_DISPATCH edges (virtual/interface targets). Default true — pass false to see only static CALLS edges."),
|
|
296
357
|
include_advice: z
|
|
297
358
|
.boolean()
|
|
298
359
|
.optional()
|
|
299
360
|
.describe("Also follow ADVISES edges (aspect advice methods)."),
|
|
361
|
+
include_events: z
|
|
362
|
+
.boolean()
|
|
363
|
+
.optional()
|
|
364
|
+
.describe("Follow EMITS edges (event/message publication -> listener). Default true — pass false to ignore framework event wiring."),
|
|
300
365
|
max_depth: z.number().int().min(1).max(50).optional().describe("Traversal depth cap."),
|
|
301
366
|
limit: z.number().int().min(1).max(500).optional().describe("Max callees returned."),
|
|
302
367
|
...budgetParams,
|
|
303
|
-
}, async ({ symbol, transitive, include_dynamic, include_advice, max_depth, limit, max_tokens, cursor, }) => {
|
|
368
|
+
}, async ({ symbol, transitive, include_dynamic, include_advice, include_events, max_depth, limit, max_tokens, cursor, }) => {
|
|
304
369
|
const result = getCallees(store, symbol, {
|
|
305
370
|
transitive,
|
|
306
371
|
includeDynamic: include_dynamic,
|
|
307
372
|
includeAdvice: include_advice,
|
|
373
|
+
includeEvents: include_events,
|
|
308
374
|
maxDepth: max_depth,
|
|
309
375
|
limit,
|
|
310
376
|
});
|
|
@@ -315,23 +381,36 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
315
381
|
depth: c.depth,
|
|
316
382
|
callSiteLine: line(c.callSiteLine),
|
|
317
383
|
edgeKind: c.edgeKind,
|
|
384
|
+
...(c.confidence !== undefined ? { confidence: c.confidence } : {}),
|
|
385
|
+
...(c.resolved !== undefined ? { resolved: c.resolved } : {}),
|
|
386
|
+
...(c.conditional !== undefined ? { conditional: c.conditional } : {}),
|
|
387
|
+
...(c.controlFlow ? { controlFlow: c.controlFlow } : {}),
|
|
388
|
+
...(c.guards ? { guards: c.guards } : {}),
|
|
318
389
|
}));
|
|
319
|
-
return text(paged({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
390
|
+
return text(paged({
|
|
391
|
+
source: ref(result.source),
|
|
392
|
+
count: callees.length,
|
|
393
|
+
callees,
|
|
394
|
+
edgesFollowed: result.edgesFollowed,
|
|
395
|
+
includeDynamic: result.includeDynamic,
|
|
396
|
+
includeAdvice: result.includeAdvice,
|
|
397
|
+
}, "callees", callees, { max_tokens, cursor }));
|
|
323
398
|
});
|
|
324
|
-
tool("trace_path", "Find call paths between two symbols. Follows static CALLS edges by default;
|
|
399
|
+
tool("trace_path", "Find call paths between two symbols. Follows static CALLS, virtual/interface dispatch and framework event edges by default, so the path reflects what can actually run; pass include_dynamic: false and include_events: false for static edges only. Each hop reports its edge kind and confidence.", {
|
|
325
400
|
source: z.string().describe("Starting symbol id or qualified name."),
|
|
326
401
|
target: z.string().describe("Destination symbol id or qualified name."),
|
|
327
402
|
include_dynamic: z
|
|
328
403
|
.boolean()
|
|
329
404
|
.optional()
|
|
330
|
-
.describe("
|
|
405
|
+
.describe("Follow DYNAMIC_DISPATCH edges (virtual/interface targets). Default true — pass false to see only static CALLS edges."),
|
|
331
406
|
include_advice: z
|
|
332
407
|
.boolean()
|
|
333
408
|
.optional()
|
|
334
409
|
.describe("Also follow ADVISES edges (aspect advice methods)."),
|
|
410
|
+
include_events: z
|
|
411
|
+
.boolean()
|
|
412
|
+
.optional()
|
|
413
|
+
.describe("Follow EMITS edges (event/message publication -> listener). Default true — pass false to ignore framework event wiring."),
|
|
335
414
|
max_depth: z.number().int().min(1).max(50).optional().describe("Maximum path length."),
|
|
336
415
|
limit: z
|
|
337
416
|
.number()
|
|
@@ -341,10 +420,11 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
341
420
|
.optional()
|
|
342
421
|
.describe("Max paths returned (default 10)."),
|
|
343
422
|
...budgetParams,
|
|
344
|
-
}, async ({ source, target, include_dynamic, include_advice, max_depth, limit, max_tokens, cursor, }) => {
|
|
423
|
+
}, async ({ source, target, include_dynamic, include_advice, include_events, max_depth, limit, max_tokens, cursor, }) => {
|
|
345
424
|
const paths = tracePath(store, source, target, {
|
|
346
425
|
includeDynamic: include_dynamic,
|
|
347
426
|
includeAdvice: include_advice,
|
|
427
|
+
includeEvents: include_events,
|
|
348
428
|
maxDepth: max_depth,
|
|
349
429
|
limit,
|
|
350
430
|
});
|
|
@@ -358,6 +438,8 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
358
438
|
target: e.target,
|
|
359
439
|
kind: e.kind,
|
|
360
440
|
callSiteLine: line(e.callSiteLine),
|
|
441
|
+
...(e.confidence !== undefined ? { confidence: e.confidence } : {}),
|
|
442
|
+
...(e.resolved !== undefined ? { resolved: e.resolved } : {}),
|
|
361
443
|
})),
|
|
362
444
|
}));
|
|
363
445
|
return text(paged({ source, target, pathCount: mapped.length, paths: mapped }, "paths", mapped, {
|
|
@@ -630,6 +712,27 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
630
712
|
}));
|
|
631
713
|
return text(paged({ count: routes.length, routes }, "routes", routes, { max_tokens, cursor }));
|
|
632
714
|
});
|
|
715
|
+
tool("find_event_flows", "Join event and message publications to the listeners that receive them (`publishEvent` -> `@EventListener`, `KafkaTemplate.send` -> `@KafkaListener`, `emit` -> `@OnEvent`). This is the edge static call graphs miss: the publisher never names the listener. `confidence` is 1 for a fully-qualified event match and 0.85 for a literal topic, where the same name can belong to another broker. A `phase` means the listener only runs at that transaction phase.", {
|
|
716
|
+
symbol: z
|
|
717
|
+
.string()
|
|
718
|
+
.optional()
|
|
719
|
+
.describe("Restrict to a single publishing or listening symbol id/qualified name."),
|
|
720
|
+
limit: z.number().int().min(1).max(500).optional().describe("Max results (default 50)."),
|
|
721
|
+
...budgetParams,
|
|
722
|
+
}, async ({ symbol, limit, max_tokens, cursor }) => {
|
|
723
|
+
const results = findEventFlows(store, { symbol, limit });
|
|
724
|
+
const flows = results.map((e) => ({
|
|
725
|
+
source: ref(e.source),
|
|
726
|
+
listener: ref(e.target),
|
|
727
|
+
...(e.channel ? { channel: e.channel } : {}),
|
|
728
|
+
...(e.channelKind ? { channelKind: e.channelKind } : {}),
|
|
729
|
+
...(e.framework ? { framework: e.framework } : {}),
|
|
730
|
+
...(e.phase ? { phase: e.phase } : {}),
|
|
731
|
+
...(e.confidence !== undefined ? { confidence: e.confidence } : {}),
|
|
732
|
+
...(e.line !== undefined ? { line: line(e.line) } : {}),
|
|
733
|
+
}));
|
|
734
|
+
return text(paged({ count: flows.length, flows }, "flows", flows, { max_tokens, cursor }));
|
|
735
|
+
});
|
|
633
736
|
tool("find_external_dependencies", "Summarize third-party packages the crawled source imports, with reference and file counts. External libraries are modelled as package-level nodes: the crawler records the dependency, not the library's internals.", {
|
|
634
737
|
limit: z.number().int().min(1).max(500).optional().describe("Max packages (default 50)."),
|
|
635
738
|
...budgetParams,
|
|
@@ -712,7 +815,7 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
712
815
|
unresolved: calls,
|
|
713
816
|
}, "unresolved", calls, { max_tokens, cursor }));
|
|
714
817
|
});
|
|
715
|
-
tool("impact_analysis", "One call that answers 'what breaks if I change this?': reverse callers to a depth, framework entry points that reach the symbol, HTTP routes that serve it, and overriding implementations. Analysing a type aggregates the callers of all its methods. Returns a heuristic risk band: high when a framework entry point reaches the symbol, medium when it has direct callers, low otherwise.", {
|
|
818
|
+
tool("impact_analysis", "One call that answers 'what breaks if I change this?': reverse callers to a depth, framework entry points that reach the symbol, HTTP routes that serve it, events it publishes or listens to, and overriding implementations. Analysing a type aggregates the callers of all its methods. Returns a heuristic risk band: high when a framework entry point reaches the symbol, medium when it has direct callers, low otherwise.", {
|
|
716
819
|
symbol: z.string().describe("Symbol id or qualified name."),
|
|
717
820
|
max_depth: z
|
|
718
821
|
.number()
|
|
@@ -756,6 +859,7 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
756
859
|
viaDepth: e.viaDepth,
|
|
757
860
|
})),
|
|
758
861
|
routes: result.routes.map(wiring),
|
|
862
|
+
eventFlows: result.eventFlows.map(wiring),
|
|
759
863
|
implementations: result.implementations.map((i) => ({
|
|
760
864
|
type: ref(i.type),
|
|
761
865
|
...(i.method ? { method: ref(i.method) } : {}),
|
|
@@ -765,6 +869,118 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
765
869
|
affectedFiles: result.affectedFiles,
|
|
766
870
|
});
|
|
767
871
|
});
|
|
872
|
+
tool("change_impact", "Answers 'what does this change break?' for a whole diff instead of one symbol: pass a unified diff (from `git diff`), a list of files, or a list of symbols, in any combination. Hunk line ranges are mapped onto the declarations they overlap, and a changed method replaces its enclosing class so call sites are not counted twice. Every touched declaration gets the impact_analysis treatment plus injection points and AOP advice, ranked by exposure. The score orders the report and is not a probability. Unmatched paths and symbols are returned rather than silently dropped.", {
|
|
873
|
+
diff: z
|
|
874
|
+
.string()
|
|
875
|
+
.optional()
|
|
876
|
+
.describe("Unified diff text (output of `git diff` or `git diff HEAD~1`)."),
|
|
877
|
+
files: z
|
|
878
|
+
.array(z.string())
|
|
879
|
+
.optional()
|
|
880
|
+
.describe("Changed file paths, repo- or crawl-root-relative. Expands to each file's top-level declarations."),
|
|
881
|
+
symbols: z
|
|
882
|
+
.array(z.string())
|
|
883
|
+
.optional()
|
|
884
|
+
.describe("Changed symbols, as ids or qualified names."),
|
|
885
|
+
max_depth: z
|
|
886
|
+
.number()
|
|
887
|
+
.int()
|
|
888
|
+
.min(1)
|
|
889
|
+
.max(50)
|
|
890
|
+
.optional()
|
|
891
|
+
.describe("Caller traversal depth per symbol (default 10)."),
|
|
892
|
+
include_dynamic: z
|
|
893
|
+
.boolean()
|
|
894
|
+
.optional()
|
|
895
|
+
.describe("Also follow DYNAMIC_DISPATCH edges (default true)."),
|
|
896
|
+
limit: z
|
|
897
|
+
.number()
|
|
898
|
+
.int()
|
|
899
|
+
.min(1)
|
|
900
|
+
.max(1000)
|
|
901
|
+
.optional()
|
|
902
|
+
.describe("Max callers kept per symbol (default 20)."),
|
|
903
|
+
max_symbols: z
|
|
904
|
+
.number()
|
|
905
|
+
.int()
|
|
906
|
+
.min(1)
|
|
907
|
+
.max(200)
|
|
908
|
+
.optional()
|
|
909
|
+
.describe("Max ranked symbols in the report (default 25). Lower-risk symbols are dropped and counted in `truncated`."),
|
|
910
|
+
}, async ({ diff, files, symbols, max_depth, include_dynamic, limit, max_symbols }) => {
|
|
911
|
+
if (!diff?.trim() && !files?.length && !symbols?.length) {
|
|
912
|
+
return text({
|
|
913
|
+
ok: false,
|
|
914
|
+
error: "no change description supplied",
|
|
915
|
+
hint: "Pass at least one of `diff` (unified diff text), `files` (changed paths) or `symbols` (changed symbol ids).",
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
try {
|
|
919
|
+
const report = changeImpact(store, { diff, files, symbols }, {
|
|
920
|
+
maxDepth: max_depth,
|
|
921
|
+
includeDynamic: include_dynamic,
|
|
922
|
+
limit,
|
|
923
|
+
maxSymbols: max_symbols,
|
|
924
|
+
});
|
|
925
|
+
return text({
|
|
926
|
+
input: report.input,
|
|
927
|
+
totals: report.totals,
|
|
928
|
+
...(report.truncated
|
|
929
|
+
? {
|
|
930
|
+
truncated: true,
|
|
931
|
+
truncatedHint: `Report limited to ${max_symbols ?? 25} symbols by risk score; raise max_symbols or narrow the diff to see the rest.`,
|
|
932
|
+
}
|
|
933
|
+
: {}),
|
|
934
|
+
...(report.unmatched.symbols.length || report.unmatched.files.length
|
|
935
|
+
? { unmatched: report.unmatched }
|
|
936
|
+
: {}),
|
|
937
|
+
symbols: report.symbols.map((s) => ({
|
|
938
|
+
symbol: ref(s.symbol),
|
|
939
|
+
matchedBy: s.matchedBy,
|
|
940
|
+
...(s.diffRanges ? { diffRanges: s.diffRanges } : {}),
|
|
941
|
+
score: s.score,
|
|
942
|
+
summary: s.summary,
|
|
943
|
+
callers: s.callers.map((c) => ({
|
|
944
|
+
caller: ref(c.caller),
|
|
945
|
+
depth: c.depth,
|
|
946
|
+
callSiteLine: line(c.callSiteLine),
|
|
947
|
+
edgeKind: c.edgeKind,
|
|
948
|
+
})),
|
|
949
|
+
entryPoints: s.entryPoints.map((e) => ({
|
|
950
|
+
symbol: ref(e.symbol),
|
|
951
|
+
entryPointKind: e.entryPointKind,
|
|
952
|
+
...(e.detail ? { detail: e.detail } : {}),
|
|
953
|
+
viaDepth: e.viaDepth,
|
|
954
|
+
})),
|
|
955
|
+
routes: s.routes.map(wiring),
|
|
956
|
+
injectionPoints: s.injectionPoints.map((i) => ({
|
|
957
|
+
role: i.role,
|
|
958
|
+
symbol: ref(i.symbol),
|
|
959
|
+
...(i.injectedName ? { injectedName: i.injectedName } : {}),
|
|
960
|
+
...(i.framework ? { framework: i.framework } : {}),
|
|
961
|
+
...(i.line !== undefined ? { line: line(i.line) } : {}),
|
|
962
|
+
})),
|
|
963
|
+
advice: s.advice.map((a) => ({
|
|
964
|
+
advice: ref(a.advice),
|
|
965
|
+
advised: ref(a.advised),
|
|
966
|
+
...(a.framework ? { framework: a.framework } : {}),
|
|
967
|
+
...(a.line !== undefined ? { line: line(a.line) } : {}),
|
|
968
|
+
})),
|
|
969
|
+
eventFlows: s.eventFlows.map(wiring),
|
|
970
|
+
implementations: s.implementations.map((i) => ({
|
|
971
|
+
type: ref(i.type),
|
|
972
|
+
...(i.method ? { method: ref(i.method) } : {}),
|
|
973
|
+
depth: i.depth,
|
|
974
|
+
via: i.via,
|
|
975
|
+
})),
|
|
976
|
+
affectedFiles: s.affectedFiles,
|
|
977
|
+
})),
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
catch (err) {
|
|
981
|
+
return errorResult(err);
|
|
982
|
+
}
|
|
983
|
+
});
|
|
768
984
|
tool("explain_symbol", "One-shot digest of a symbol: kind, file and line, annotations/decorators, contained members with their decorators, direct callers and callees, overriding implementations, and the framework wiring that reaches it (routes, injections, reflections). Replaces a chain of five lookups with one round trip.", {
|
|
769
985
|
symbol: z.string().describe("Symbol id or qualified name."),
|
|
770
986
|
max_depth: z
|
|
@@ -935,6 +1151,7 @@ export function createServer(initialStore, config, options = {}) {
|
|
|
935
1151
|
INJECTS: "injecting symbol -> injected type, from DI/framework wiring.",
|
|
936
1152
|
REFLECTS: "looking-up symbol -> resolved target, from reflection/dynamic import.",
|
|
937
1153
|
ROUTES: "registering symbol -> handler symbol, with HTTP verb and path.",
|
|
1154
|
+
EMITS: "publisher symbol -> listener symbol, joined on event class or message topic.",
|
|
938
1155
|
ANNOTATED_WITH: "symbol -> annotation node, carrying arguments and source line.",
|
|
939
1156
|
},
|
|
940
1157
|
}, null, 2),
|