@nithin554/code-crawler 0.1.81 → 0.1.83
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
package/dist/graph/budget.js
CHANGED
|
@@ -54,6 +54,17 @@ export function applyBudget(items, opts = {}) {
|
|
|
54
54
|
estimatedTokens: used,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The next step for a truncated page, phrased so it names the actual cursor
|
|
59
|
+
* value rather than describing the mechanism.
|
|
60
|
+
*/
|
|
61
|
+
export function truncationHint(page) {
|
|
62
|
+
const first = page.cursor;
|
|
63
|
+
const last = page.cursor + page.returnedCount - 1;
|
|
64
|
+
return (`Truncated: items ${first}-${last} of ${page.totalCount}. ` +
|
|
65
|
+
`Pass cursor=${page.nextCursor} for the next page, raise max_tokens, ` +
|
|
66
|
+
`or narrow the query with this tool's filter arguments.`);
|
|
67
|
+
}
|
|
57
68
|
/** Strip the items from a page so it can be attached as response metadata. */
|
|
58
69
|
export function pageMeta(page) {
|
|
59
70
|
return {
|
|
@@ -63,6 +74,7 @@ export function pageMeta(page) {
|
|
|
63
74
|
...(page.nextCursor !== undefined ? { nextCursor: page.nextCursor } : {}),
|
|
64
75
|
truncated: page.truncated,
|
|
65
76
|
estimatedTokens: page.estimatedTokens,
|
|
77
|
+
...(page.truncated ? { hint: truncationHint(page) } : {}),
|
|
66
78
|
};
|
|
67
79
|
}
|
|
68
80
|
/** True when the caller opted into budgeted output in any way. */
|
package/dist/graph/budget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/graph/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../src/graph/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoCH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,KAAmB,EAAE,IAAI,GAAkB,EAAE;IAC1E,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAEjC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAC9C,OAAO;YACL,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,UAAU,QAAQ,CAAI,IAAmB;IAC7C,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACJ,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change impact: turn a git diff, a file list or an explicit symbol list into
|
|
3
|
+
* one ranked report of what the change reaches.
|
|
4
|
+
*
|
|
5
|
+
* A single-symbol `impact_analysis` call answers "what breaks if I change
|
|
6
|
+
* this". A reviewer holding a diff needs the same answer for every symbol the
|
|
7
|
+
* diff touches, plus the two wire-ups a call graph cannot show on its own:
|
|
8
|
+
* who injects the changed type, and which advice intercepts the changed
|
|
9
|
+
* method. This module maps changed lines onto declarations and reuses
|
|
10
|
+
* `impactAnalysis` per symbol, so both tools can never drift apart.
|
|
11
|
+
*/
|
|
12
|
+
import { type ImpactCaller, type ImpactImplementation, type ImpactSummary } from "./insights.js";
|
|
13
|
+
import { type SymbolRef, type WiringEdge } from "./queries.js";
|
|
14
|
+
import type { GraphStore } from "./store.js";
|
|
15
|
+
/** One 1-based, inclusive line range in the new version of a file. */
|
|
16
|
+
export interface DiffRange {
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
}
|
|
20
|
+
export interface DiffFileChange {
|
|
21
|
+
file: string;
|
|
22
|
+
ranges: DiffRange[];
|
|
23
|
+
}
|
|
24
|
+
/** A declaration that a diff, a file list or a symbol list pointed at. */
|
|
25
|
+
export interface ChangedDeclaration {
|
|
26
|
+
symbol: SymbolRef;
|
|
27
|
+
matchedBy: "symbol" | "file" | "diff";
|
|
28
|
+
/** Present for `diff` matches: the hunks that overlapped this declaration. */
|
|
29
|
+
diffRanges?: DiffRange[];
|
|
30
|
+
}
|
|
31
|
+
export interface InjectionPoint {
|
|
32
|
+
/** `injects`: the changed symbol is injected into `symbol`. */
|
|
33
|
+
role: "injects" | "injectedBy";
|
|
34
|
+
symbol: SymbolRef;
|
|
35
|
+
injectedName?: string;
|
|
36
|
+
framework?: string;
|
|
37
|
+
line?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface AdvicePoint {
|
|
40
|
+
advice: SymbolRef;
|
|
41
|
+
advised: SymbolRef;
|
|
42
|
+
framework?: string;
|
|
43
|
+
line?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ChangedSymbolImpact {
|
|
46
|
+
symbol: SymbolRef;
|
|
47
|
+
matchedBy: ChangedDeclaration["matchedBy"];
|
|
48
|
+
diffRanges?: DiffRange[];
|
|
49
|
+
summary: ImpactSummary & {
|
|
50
|
+
injectionPoints: number;
|
|
51
|
+
advice: number;
|
|
52
|
+
};
|
|
53
|
+
/** Ranking score; higher is more exposed. Ordering only, not a probability. */
|
|
54
|
+
score: number;
|
|
55
|
+
callers: ImpactCaller[];
|
|
56
|
+
entryPoints: {
|
|
57
|
+
symbol: SymbolRef;
|
|
58
|
+
entryPointKind: string;
|
|
59
|
+
detail?: string;
|
|
60
|
+
viaDepth?: number;
|
|
61
|
+
}[];
|
|
62
|
+
routes: WiringEdge[];
|
|
63
|
+
eventFlows: WiringEdge[];
|
|
64
|
+
implementations: ImpactImplementation[];
|
|
65
|
+
injectionPoints: InjectionPoint[];
|
|
66
|
+
advice: AdvicePoint[];
|
|
67
|
+
affectedFiles: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface ChangeImpactReport {
|
|
70
|
+
/** How the change was described, after normalization. */
|
|
71
|
+
input: {
|
|
72
|
+
symbols: number;
|
|
73
|
+
files: string[];
|
|
74
|
+
hunks: number;
|
|
75
|
+
};
|
|
76
|
+
symbols: ChangedSymbolImpact[];
|
|
77
|
+
totals: {
|
|
78
|
+
symbols: number;
|
|
79
|
+
callers: number;
|
|
80
|
+
entryPoints: number;
|
|
81
|
+
routes: number;
|
|
82
|
+
injectionPoints: number;
|
|
83
|
+
advice: number;
|
|
84
|
+
eventFlows: number;
|
|
85
|
+
implementations: number;
|
|
86
|
+
affectedFiles: number;
|
|
87
|
+
};
|
|
88
|
+
/** Symbols or files that matched nothing in the index. */
|
|
89
|
+
unmatched: {
|
|
90
|
+
symbols: string[];
|
|
91
|
+
files: string[];
|
|
92
|
+
};
|
|
93
|
+
/** True when more symbols matched than `maxSymbols` allowed. */
|
|
94
|
+
truncated: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface ChangeImpactOptions {
|
|
97
|
+
maxDepth?: number;
|
|
98
|
+
includeDynamic?: boolean;
|
|
99
|
+
/** Callers kept per symbol (default 20). */
|
|
100
|
+
limit?: number;
|
|
101
|
+
/** Symbols ranked in the report (default 25). */
|
|
102
|
+
maxSymbols?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Extract new-side line ranges per file from unified diff text.
|
|
106
|
+
*
|
|
107
|
+
* Only the new side matters: the index describes the current tree, so a
|
|
108
|
+
* deleted-only hunk is anchored on the line where the deletion happened.
|
|
109
|
+
* Renames are followed to their new path; deletions map to nothing.
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseUnifiedDiff(diff: string): DiffFileChange[];
|
|
112
|
+
/**
|
|
113
|
+
* "What does this diff break?" — every symbol the change touches, ranked.
|
|
114
|
+
*
|
|
115
|
+
* Supply any combination of `symbols`, `files` and `diff`. Files and diff hunks
|
|
116
|
+
* are mapped onto declarations by line span; a changed member replaces its
|
|
117
|
+
* enclosing type so the report does not count the same call sites twice.
|
|
118
|
+
*/
|
|
119
|
+
export declare function changeImpact(store: GraphStore, query: {
|
|
120
|
+
symbols?: string[];
|
|
121
|
+
files?: string[];
|
|
122
|
+
diff?: string;
|
|
123
|
+
}, opts?: ChangeImpactOptions): ChangeImpactReport;
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change impact: turn a git diff, a file list or an explicit symbol list into
|
|
3
|
+
* one ranked report of what the change reaches.
|
|
4
|
+
*
|
|
5
|
+
* A single-symbol `impact_analysis` call answers "what breaks if I change
|
|
6
|
+
* this". A reviewer holding a diff needs the same answer for every symbol the
|
|
7
|
+
* diff touches, plus the two wire-ups a call graph cannot show on its own:
|
|
8
|
+
* who injects the changed type, and which advice intercepts the changed
|
|
9
|
+
* method. This module maps changed lines onto declarations and reuses
|
|
10
|
+
* `impactAnalysis` per symbol, so both tools can never drift apart.
|
|
11
|
+
*/
|
|
12
|
+
import { impactAnalysis, } from "./insights.js";
|
|
13
|
+
import { findEventFlows, findRoutes, nodeToRef, resolveNode, } from "./queries.js";
|
|
14
|
+
/** Declarations a file-level change expands to, before member collapsing. */
|
|
15
|
+
const TYPE_KINDS = new Set(["class", "interface", "enum", "annotation_type", "aspect"]);
|
|
16
|
+
const MEMBER_KINDS = new Set(["method", "constructor"]);
|
|
17
|
+
const HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
|
|
18
|
+
/** Normalize a diff path to the repo-relative, forward-slash form. */
|
|
19
|
+
function normalizePath(raw) {
|
|
20
|
+
let p = raw.trim().replace(/^"(.*)"$/, "$1");
|
|
21
|
+
p = p.replace(/\\/g, "/");
|
|
22
|
+
p = p.replace(/^[ab]\//, "");
|
|
23
|
+
p = p.replace(/^\.\//, "");
|
|
24
|
+
return p;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract new-side line ranges per file from unified diff text.
|
|
28
|
+
*
|
|
29
|
+
* Only the new side matters: the index describes the current tree, so a
|
|
30
|
+
* deleted-only hunk is anchored on the line where the deletion happened.
|
|
31
|
+
* Renames are followed to their new path; deletions map to nothing.
|
|
32
|
+
*/
|
|
33
|
+
export function parseUnifiedDiff(diff) {
|
|
34
|
+
const files = new Map();
|
|
35
|
+
let current;
|
|
36
|
+
for (const line of diff.split(/\r?\n/)) {
|
|
37
|
+
if (line.startsWith("+++ ")) {
|
|
38
|
+
const target = line.slice(4).trim();
|
|
39
|
+
if (target === "/dev/null") {
|
|
40
|
+
current = undefined;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const file = normalizePath(target);
|
|
44
|
+
if (!file) {
|
|
45
|
+
current = undefined;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const existing = files.get(file);
|
|
49
|
+
current = existing ?? { file, ranges: [] };
|
|
50
|
+
if (!existing)
|
|
51
|
+
files.set(file, current);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const hunk = HUNK_HEADER.exec(line);
|
|
55
|
+
if (!hunk || !current)
|
|
56
|
+
continue;
|
|
57
|
+
const start = Number(hunk[1]);
|
|
58
|
+
const count = hunk[2] === undefined ? 1 : Number(hunk[2]);
|
|
59
|
+
// `+start,0` is a pure deletion: nothing on the new side is new, but the
|
|
60
|
+
// deletion happened at this point, so anchor a single line on it.
|
|
61
|
+
current.ranges.push(count === 0 ? { start, end: start } : { start, end: start + count - 1 });
|
|
62
|
+
}
|
|
63
|
+
return [...files.values()].filter((f) => f.ranges.length > 0);
|
|
64
|
+
}
|
|
65
|
+
function spanOf(row) {
|
|
66
|
+
const props = JSON.parse(row.properties || "{}");
|
|
67
|
+
if (typeof props.startLine !== "number")
|
|
68
|
+
return null;
|
|
69
|
+
// Node lines are zero-based; diff lines are one-based.
|
|
70
|
+
const start = props.startLine + 1;
|
|
71
|
+
const end = typeof props.endLine === "number" ? props.endLine + 1 : start;
|
|
72
|
+
return { start, end: Math.max(start, end) };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Map a diff path onto indexed file paths.
|
|
76
|
+
*
|
|
77
|
+
* The diff is repository-relative while `file_path` is crawl-root-relative, and
|
|
78
|
+
* the two differ whenever the crawl root is a module of a larger repo. Accept
|
|
79
|
+
* an exact match, else a suffix match on a path boundary in either direction.
|
|
80
|
+
*/
|
|
81
|
+
function resolveFiles(target, known) {
|
|
82
|
+
const norm = (p) => p.replace(/\\/g, "/");
|
|
83
|
+
const wanted = norm(target);
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const candidate of known) {
|
|
86
|
+
const c = norm(candidate);
|
|
87
|
+
if (c === wanted || c.endsWith(`/${wanted}`) || wanted.endsWith(`/${c}`)) {
|
|
88
|
+
out.push(candidate);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Declarations in one file, with their line spans. */
|
|
94
|
+
function declarationsIn(store, file) {
|
|
95
|
+
const rows = store.raw(`SELECT id, kind, qualified_name, name, file_path, properties
|
|
96
|
+
FROM nodes
|
|
97
|
+
WHERE file_path = ?
|
|
98
|
+
AND kind IN ('class', 'interface', 'enum', 'annotation_type', 'aspect',
|
|
99
|
+
'method', 'constructor')
|
|
100
|
+
LIMIT 20000`, file);
|
|
101
|
+
const out = [];
|
|
102
|
+
for (const row of rows) {
|
|
103
|
+
const span = spanOf(row);
|
|
104
|
+
if (!span)
|
|
105
|
+
continue;
|
|
106
|
+
out.push({
|
|
107
|
+
symbol: {
|
|
108
|
+
id: row.id,
|
|
109
|
+
qualifiedName: row.qualified_name,
|
|
110
|
+
name: row.name ?? undefined,
|
|
111
|
+
kind: row.kind,
|
|
112
|
+
filePath: row.file_path,
|
|
113
|
+
},
|
|
114
|
+
span,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
function enclosingTypeId(id) {
|
|
120
|
+
const hash = id.lastIndexOf("#");
|
|
121
|
+
return hash > 0 ? id.slice(0, hash) : undefined;
|
|
122
|
+
}
|
|
123
|
+
/** True when `outer` contains `inner` and is strictly bigger. */
|
|
124
|
+
function contains(outer, inner) {
|
|
125
|
+
return (outer.start <= inner.start &&
|
|
126
|
+
outer.end >= inner.end &&
|
|
127
|
+
outer.end - outer.start > inner.end - inner.start);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Diff-matched declarations, collapsed so a changed method does not also
|
|
131
|
+
* report its enclosing class. A class only survives when nothing smaller in it
|
|
132
|
+
* was touched, which is the case for a field or an annotation change.
|
|
133
|
+
*/
|
|
134
|
+
function diffDeclarations(store, changes, known, unmatched) {
|
|
135
|
+
const out = new Map();
|
|
136
|
+
for (const change of changes) {
|
|
137
|
+
const files = resolveFiles(change.file, known);
|
|
138
|
+
if (files.length === 0) {
|
|
139
|
+
unmatched.push(change.file);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
for (const file of files) {
|
|
143
|
+
const declared = declarationsIn(store, file);
|
|
144
|
+
const hits = declared.filter((d) => change.ranges.some((r) => d.span.start <= r.end && d.span.end >= r.start));
|
|
145
|
+
for (const hit of hits) {
|
|
146
|
+
// Member wins over its type when both spans were touched.
|
|
147
|
+
if (TYPE_KINDS.has(hit.symbol.kind)) {
|
|
148
|
+
const hasTouchedMember = hits.some((other) => other !== hit &&
|
|
149
|
+
MEMBER_KINDS.has(other.symbol.kind) &&
|
|
150
|
+
contains(hit.span, other.span) &&
|
|
151
|
+
enclosingTypeId(other.symbol.id) === hit.symbol.id);
|
|
152
|
+
if (hasTouchedMember)
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const existing = out.get(hit.symbol.id);
|
|
156
|
+
const ranges = change.ranges.filter((r) => hit.span.start <= r.end && hit.span.end >= r.start);
|
|
157
|
+
if (existing) {
|
|
158
|
+
existing.diffRanges = [...(existing.diffRanges ?? []), ...ranges];
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
out.set(hit.symbol.id, {
|
|
162
|
+
symbol: hit.symbol,
|
|
163
|
+
matchedBy: "diff",
|
|
164
|
+
diffRanges: ranges,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [...out.values()];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* File-level changes expand to the file's top-level declarations.
|
|
173
|
+
*
|
|
174
|
+
* A module-level Python/TypeScript function is a `method` node owned by the
|
|
175
|
+
* module node, so "top level" is decided by the owner's kind rather than by the
|
|
176
|
+
* declaration's own kind.
|
|
177
|
+
*/
|
|
178
|
+
function fileDeclarations(store, files, knownPaths, unmatched) {
|
|
179
|
+
const out = new Map();
|
|
180
|
+
for (const wanted of files) {
|
|
181
|
+
const matched = resolveFiles(normalizePath(wanted), knownPaths);
|
|
182
|
+
if (matched.length === 0) {
|
|
183
|
+
unmatched.push(wanted);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
for (const file of matched) {
|
|
187
|
+
for (const decl of declarationsIn(store, file)) {
|
|
188
|
+
if (TYPE_KINDS.has(decl.symbol.kind)) {
|
|
189
|
+
out.set(decl.symbol.id, { symbol: decl.symbol, matchedBy: "file" });
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (decl.symbol.kind !== "method")
|
|
193
|
+
continue;
|
|
194
|
+
const owner = enclosingTypeId(decl.symbol.id);
|
|
195
|
+
if (!owner)
|
|
196
|
+
continue;
|
|
197
|
+
if (store.getNode(owner)?.kind === "module") {
|
|
198
|
+
out.set(decl.symbol.id, { symbol: decl.symbol, matchedBy: "file" });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [...out.values()];
|
|
204
|
+
}
|
|
205
|
+
function injectionsFor(store, id) {
|
|
206
|
+
const rows = store.raw(`SELECT source, target, properties FROM edges
|
|
207
|
+
WHERE kind = 'INJECTS' AND (source = ? OR target = ?)
|
|
208
|
+
LIMIT 500`, id, id);
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const row of rows) {
|
|
211
|
+
const otherId = row.source === id ? row.target : row.source;
|
|
212
|
+
if (otherId === id)
|
|
213
|
+
continue;
|
|
214
|
+
const other = store.getNode(otherId);
|
|
215
|
+
if (!other)
|
|
216
|
+
continue;
|
|
217
|
+
const props = JSON.parse(row.properties || "{}");
|
|
218
|
+
out.push({
|
|
219
|
+
role: row.source === id ? "injects" : "injectedBy",
|
|
220
|
+
symbol: nodeToRef(other),
|
|
221
|
+
...(props.injectedName ? { injectedName: props.injectedName } : {}),
|
|
222
|
+
...(props.framework ? { framework: props.framework } : {}),
|
|
223
|
+
...(props.line !== undefined ? { line: props.line } : {}),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return out.sort((a, b) => a.role.localeCompare(b.role) || a.symbol.id.localeCompare(b.symbol.id));
|
|
227
|
+
}
|
|
228
|
+
function adviceFor(store, id, isType) {
|
|
229
|
+
// ADVISES runs advice -> advised, so a changed method is advised when it is
|
|
230
|
+
// the target. For a type, every member is checked through CONTAINS.
|
|
231
|
+
const rows = isType
|
|
232
|
+
? store.raw(`SELECT a.source, a.target, a.properties
|
|
233
|
+
FROM edges a
|
|
234
|
+
JOIN edges c ON c.target = a.target AND c.kind = 'CONTAINS' AND c.source = ?
|
|
235
|
+
WHERE a.kind = 'ADVISES'
|
|
236
|
+
LIMIT 500`, id)
|
|
237
|
+
: store.raw(`SELECT source, target, properties FROM edges
|
|
238
|
+
WHERE kind = 'ADVISES' AND target = ?
|
|
239
|
+
LIMIT 500`, id);
|
|
240
|
+
const out = [];
|
|
241
|
+
for (const row of rows) {
|
|
242
|
+
const advice = store.getNode(row.source);
|
|
243
|
+
const advised = store.getNode(row.target);
|
|
244
|
+
if (!advice || !advised)
|
|
245
|
+
continue;
|
|
246
|
+
const props = JSON.parse(row.properties || "{}");
|
|
247
|
+
out.push({
|
|
248
|
+
advice: nodeToRef(advice),
|
|
249
|
+
advised: nodeToRef(advised),
|
|
250
|
+
...(props.framework ? { framework: props.framework } : {}),
|
|
251
|
+
...(props.line !== undefined ? { line: props.line } : {}),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return out.sort((a, b) => a.advice.id.localeCompare(b.advice.id));
|
|
255
|
+
}
|
|
256
|
+
function riskScore(risk) {
|
|
257
|
+
return risk === "high" ? 1000 : risk === "medium" ? 100 : 0;
|
|
258
|
+
}
|
|
259
|
+
const wiringKey = (e) => `${e.source.id}->${e.target.id}:${e.path ?? ""}`;
|
|
260
|
+
/**
|
|
261
|
+
* Extend `impactAnalysis`'s wiring to everything the change reaches.
|
|
262
|
+
*
|
|
263
|
+
* `impactAnalysis` keeps only the routes and event flows wired straight to the
|
|
264
|
+
* analysed symbol or its members, which is the right answer for "what is wired
|
|
265
|
+
* to this method". A change is broader than that: editing a service must still
|
|
266
|
+
* name the endpoint that reaches it through a handler. So anything whose
|
|
267
|
+
* wired endpoint is the symbol or one of its transitive callers is added.
|
|
268
|
+
*/
|
|
269
|
+
function reachableWiring(direct, all, reachable, side) {
|
|
270
|
+
const seen = new Set(direct.map(wiringKey));
|
|
271
|
+
const out = [...direct];
|
|
272
|
+
for (const edge of all) {
|
|
273
|
+
if (!reachable.has(edge[side].id))
|
|
274
|
+
continue;
|
|
275
|
+
const key = wiringKey(edge);
|
|
276
|
+
if (seen.has(key))
|
|
277
|
+
continue;
|
|
278
|
+
seen.add(key);
|
|
279
|
+
out.push(edge);
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Score orders the report; it is never a probability. Framework reach dominates
|
|
285
|
+
* because an entry point makes a change externally visible, then wire-ups that
|
|
286
|
+
* a static call graph cannot show.
|
|
287
|
+
*/
|
|
288
|
+
function scoreOf(entry) {
|
|
289
|
+
return (riskScore(entry.summary.risk) +
|
|
290
|
+
20 * entry.summary.routes +
|
|
291
|
+
20 * entry.summary.entryPoints +
|
|
292
|
+
10 * entry.injectionPoints.length +
|
|
293
|
+
10 * entry.advice.length +
|
|
294
|
+
5 * entry.eventFlows.length +
|
|
295
|
+
entry.summary.totalCallers);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* "What does this diff break?" — every symbol the change touches, ranked.
|
|
299
|
+
*
|
|
300
|
+
* Supply any combination of `symbols`, `files` and `diff`. Files and diff hunks
|
|
301
|
+
* are mapped onto declarations by line span; a changed member replaces its
|
|
302
|
+
* enclosing type so the report does not count the same call sites twice.
|
|
303
|
+
*/
|
|
304
|
+
export function changeImpact(store, query, opts = {}) {
|
|
305
|
+
const limit = Math.max(1, opts.limit ?? 20);
|
|
306
|
+
const maxSymbols = Math.max(1, opts.maxSymbols ?? 25);
|
|
307
|
+
const knownPaths = store
|
|
308
|
+
.raw("SELECT DISTINCT file_path FROM nodes WHERE file_path IS NOT NULL LIMIT 50000")
|
|
309
|
+
.map((r) => r.file_path)
|
|
310
|
+
.filter((p) => typeof p === "string");
|
|
311
|
+
const unmatched = { symbols: [], files: [] };
|
|
312
|
+
const found = new Map();
|
|
313
|
+
for (const requested of query.symbols ?? []) {
|
|
314
|
+
const node = resolveNode(store, requested);
|
|
315
|
+
if (!node) {
|
|
316
|
+
unmatched.symbols.push(requested);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const decl = { symbol: nodeToRef(node), matchedBy: "symbol" };
|
|
320
|
+
found.set(node.id, decl);
|
|
321
|
+
}
|
|
322
|
+
if (query.files && query.files.length > 0) {
|
|
323
|
+
for (const decl of fileDeclarations(store, query.files, knownPaths, unmatched.files)) {
|
|
324
|
+
found.set(decl.symbol.id, decl);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const changes = query.diff ? parseUnifiedDiff(query.diff) : [];
|
|
328
|
+
if (changes.length > 0) {
|
|
329
|
+
for (const decl of diffDeclarations(store, changes, knownPaths, unmatched.files)) {
|
|
330
|
+
found.set(decl.symbol.id, decl);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const allRoutes = findRoutes(store, { limit: 10000 });
|
|
334
|
+
const allFlows = findEventFlows(store, { limit: 10000 });
|
|
335
|
+
const analysed = [];
|
|
336
|
+
for (const decl of found.values()) {
|
|
337
|
+
const impact = impactAnalysis(store, decl.symbol.id, {
|
|
338
|
+
maxDepth: opts.maxDepth,
|
|
339
|
+
includeDynamic: opts.includeDynamic,
|
|
340
|
+
limit,
|
|
341
|
+
});
|
|
342
|
+
if (!impact)
|
|
343
|
+
continue;
|
|
344
|
+
const isType = TYPE_KINDS.has(decl.symbol.kind) || decl.symbol.kind === "module";
|
|
345
|
+
const injectionPoints = injectionsFor(store, decl.symbol.id);
|
|
346
|
+
const advice = adviceFor(store, decl.symbol.id, isType);
|
|
347
|
+
const reachable = new Set([decl.symbol.id]);
|
|
348
|
+
for (const c of impact.callers)
|
|
349
|
+
reachable.add(c.caller.id);
|
|
350
|
+
const routes = reachableWiring(impact.routes, allRoutes, reachable, "target");
|
|
351
|
+
const eventFlows = reachableWiring(impact.eventFlows, allFlows, reachable, "source");
|
|
352
|
+
const summary = {
|
|
353
|
+
...impact.summary,
|
|
354
|
+
routes: routes.length,
|
|
355
|
+
eventFlows: eventFlows.length,
|
|
356
|
+
injectionPoints: injectionPoints.length,
|
|
357
|
+
advice: advice.length,
|
|
358
|
+
};
|
|
359
|
+
analysed.push({
|
|
360
|
+
symbol: decl.symbol,
|
|
361
|
+
matchedBy: decl.matchedBy,
|
|
362
|
+
...(decl.diffRanges ? { diffRanges: decl.diffRanges } : {}),
|
|
363
|
+
summary,
|
|
364
|
+
score: scoreOf({
|
|
365
|
+
summary,
|
|
366
|
+
routes,
|
|
367
|
+
eventFlows,
|
|
368
|
+
injectionPoints,
|
|
369
|
+
advice,
|
|
370
|
+
}),
|
|
371
|
+
callers: impact.callers,
|
|
372
|
+
entryPoints: impact.entryPoints,
|
|
373
|
+
routes,
|
|
374
|
+
eventFlows,
|
|
375
|
+
implementations: impact.implementations,
|
|
376
|
+
injectionPoints,
|
|
377
|
+
advice,
|
|
378
|
+
affectedFiles: impact.affectedFiles,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
analysed.sort((a, b) => b.score - a.score || a.symbol.id.localeCompare(b.symbol.id));
|
|
382
|
+
const kept = analysed.slice(0, maxSymbols);
|
|
383
|
+
const files = new Set();
|
|
384
|
+
const callerIds = new Set();
|
|
385
|
+
const routeKeys = new Set();
|
|
386
|
+
const entryKeys = new Set();
|
|
387
|
+
const injectionKeys = new Set();
|
|
388
|
+
const adviceKeys = new Set();
|
|
389
|
+
const flowKeys = new Set();
|
|
390
|
+
const implKeys = new Set();
|
|
391
|
+
for (const entry of kept) {
|
|
392
|
+
for (const f of entry.affectedFiles)
|
|
393
|
+
files.add(f);
|
|
394
|
+
for (const c of entry.callers)
|
|
395
|
+
callerIds.add(c.caller.id);
|
|
396
|
+
for (const r of entry.routes)
|
|
397
|
+
routeKeys.add(`${r.source.id}->${r.target.id}:${r.path ?? ""}`);
|
|
398
|
+
for (const e of entry.entryPoints)
|
|
399
|
+
entryKeys.add(e.symbol.id);
|
|
400
|
+
for (const i of entry.injectionPoints)
|
|
401
|
+
injectionKeys.add(`${i.role}:${i.symbol.id}`);
|
|
402
|
+
for (const a of entry.advice)
|
|
403
|
+
adviceKeys.add(`${a.advice.id}->${a.advised.id}`);
|
|
404
|
+
for (const f of entry.eventFlows)
|
|
405
|
+
flowKeys.add(`${f.source.id}->${f.target.id}`);
|
|
406
|
+
for (const i of entry.implementations)
|
|
407
|
+
implKeys.add(i.type.id);
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
input: {
|
|
411
|
+
symbols: (query.symbols ?? []).length,
|
|
412
|
+
files: (query.files ?? []).map(normalizePath),
|
|
413
|
+
hunks: changes.reduce((sum, c) => sum + c.ranges.length, 0),
|
|
414
|
+
},
|
|
415
|
+
symbols: kept,
|
|
416
|
+
totals: {
|
|
417
|
+
symbols: kept.length,
|
|
418
|
+
callers: callerIds.size,
|
|
419
|
+
entryPoints: entryKeys.size,
|
|
420
|
+
routes: routeKeys.size,
|
|
421
|
+
injectionPoints: injectionKeys.size,
|
|
422
|
+
advice: adviceKeys.size,
|
|
423
|
+
eventFlows: flowKeys.size,
|
|
424
|
+
implementations: implKeys.size,
|
|
425
|
+
affectedFiles: files.size,
|
|
426
|
+
},
|
|
427
|
+
unmatched,
|
|
428
|
+
truncated: analysed.length > kept.length,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=changeImpact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeImpact.js","sourceRoot":"","sources":["../../src/graph/changeImpact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAIL,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,UAAU,EACV,SAAS,EACT,WAAW,GAGZ,MAAM,cAAc,CAAC;AAqFtB,6EAA6E;AAC7E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AAExD,MAAM,WAAW,GAAG,yCAAyC,CAAC;AAE9D,sEAAsE;AACtE,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC,GAAG,CAAC,CAAC,OAAO,CA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CAAC,eAAe;YAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,OAAO;QACL,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM;YACrC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;YAC7C,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SAC5D;QACD,OAAO,EAAE,IAAI;QACb,MAAM,EAAE;YACN,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,OAAO,EAAE,SAAS,CAAC,IAAI;YACvB,WAAW,EAAE,SAAS,CAAC,IAAI;YAC3B,MAAM,EAAE,SAAS,CAAC,IAAI;YACtB,eAAe,EAAE,aAAa,CAAC,IAAI;YACnC,MAAM,EAAE,UAAU,CAAC,IAAI;YACvB,UAAU,EAAE,QAAQ,CAAC,IAAI;YACzB,eAAe,EAAE,QAAQ,CAAC,IAAI;YAC9B,aAAa,EAAE,KAAK,CAAC,IAAI;SAC1B;QACD,SAAS;QACT,SAAS,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;KACzC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact projection for tool responses.
|
|
3
|
+
*
|
|
4
|
+
* A projected symbol reference costs about 150 characters:
|
|
5
|
+
* `{"id":"method:pkg.Type#m:12","qualifiedName":"pkg.Type#m","name":"m","kind":"method","filePath":"src/Type.java"}`.
|
|
6
|
+
* A deep trace repeats that object for every step, so the payload is dominated
|
|
7
|
+
* by framing rather than by the answer. Compact mode keeps the answer and drops
|
|
8
|
+
* the framing: every symbol reference becomes its fully-qualified name, which
|
|
9
|
+
* already encodes both the owner and the member.
|
|
10
|
+
*
|
|
11
|
+
* The projection is structural, not per-tool, so it applies uniformly to every
|
|
12
|
+
* response without each tool having to describe a second output shape. Callers
|
|
13
|
+
* that need `kind` or `filePath` back either resolve the qualified name with
|
|
14
|
+
* `get_node` or call the same tool without `compact`.
|
|
15
|
+
*
|
|
16
|
+
* Measured on the dynamic-dispatch fixture, compact cuts response size by 61%
|
|
17
|
+
* (`get_callers`) to 83% (`search_symbols`); the heavier the payload leans on
|
|
18
|
+
* repeated references and absolute paths, the more it saves.
|
|
19
|
+
*/
|
|
20
|
+
/** A symbol reference as the tool layer builds it: either the five keys from `ref` or the four `search_symbols` keys. */
|
|
21
|
+
export interface CompactableRef {
|
|
22
|
+
id: string;
|
|
23
|
+
qualifiedName: string;
|
|
24
|
+
kind: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
filePath?: string | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* True only for an object shaped like a projected symbol reference.
|
|
30
|
+
*
|
|
31
|
+
* The test is the identity triple — `id`, `qualifiedName`, `kind` — not the
|
|
32
|
+
* full five-key shape, because `search_symbols` omits `name` for packages. An
|
|
33
|
+
* unrelated payload that happens to carry a `kind` (an edge row, a schema
|
|
34
|
+
* description) lacks a symbol id, so it is left untouched.
|
|
35
|
+
*/
|
|
36
|
+
export declare function looksLikeSymbolRef(value: unknown): value is CompactableRef;
|
|
37
|
+
/**
|
|
38
|
+
* Recursively replace symbol references with their qualified names.
|
|
39
|
+
*
|
|
40
|
+
* Arrays and plain objects are walked; every other value is returned as-is. The
|
|
41
|
+
* function never drops a key, so the shape of the response is otherwise
|
|
42
|
+
* unchanged and a caller can still read `count`, `page`, `path`, `line` and the
|
|
43
|
+
* fields that are not symbol references.
|
|
44
|
+
*/
|
|
45
|
+
export declare function compactify(value: unknown): unknown;
|