@nithin554/code-crawler 0.1.55 → 0.1.58
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 +24 -2
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/crawler.d.ts +1 -1
- package/dist/crawler.js +42 -15
- package/dist/crawler.js.map +1 -1
- package/dist/graph/budget.d.ts +46 -0
- package/dist/graph/budget.js +72 -0
- package/dist/graph/budget.js.map +1 -0
- package/dist/graph/insights.d.ts +217 -0
- package/dist/graph/insights.js +616 -0
- package/dist/graph/insights.js.map +1 -0
- package/dist/graph/queries.d.ts +15 -1
- package/dist/graph/queries.js +25 -28
- package/dist/graph/queries.js.map +1 -1
- package/dist/graph/store.d.ts +1 -1
- package/dist/graph/store.js +4 -10
- package/dist/graph/store.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/parser/cache.js.map +1 -1
- package/dist/parser/controlFlow.js +1 -3
- package/dist/parser/controlFlow.js.map +1 -1
- package/dist/parser/languages/java.js +22 -7
- package/dist/parser/languages/java.js.map +1 -1
- package/dist/parser/languages/python.js +50 -18
- package/dist/parser/languages/python.js.map +1 -1
- package/dist/parser/languages/typescript.js +58 -19
- package/dist/parser/languages/typescript.js.map +1 -1
- package/dist/parser/moduleId.js +2 -1
- package/dist/parser/moduleId.js.map +1 -1
- package/dist/parser/treeSitter.d.ts +1 -1
- package/dist/parser/treeSitter.js +2 -2
- package/dist/parser/treeSitter.js.map +1 -1
- package/dist/resolver/common.js +89 -23
- package/dist/resolver/common.js.map +1 -1
- package/dist/resolver/dynamic.d.ts +1 -1
- package/dist/resolver/dynamic.js +4 -2
- package/dist/resolver/dynamic.js.map +1 -1
- package/dist/resolver/genericResolver.js +61 -12
- package/dist/resolver/genericResolver.js.map +1 -1
- package/dist/resolver/javaResolver.js +7 -4
- package/dist/resolver/javaResolver.js.map +1 -1
- package/dist/resolver/types.js +1 -1
- package/dist/resolver/types.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +491 -173
- package/dist/server.js.map +1 -1
- package/package.json +9 -3
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher-level analyses built on top of the primitive queries.
|
|
3
|
+
*
|
|
4
|
+
* These power the "agent-facing" tools: what the index could not resolve, what
|
|
5
|
+
* breaks if a symbol changes, a one-shot explanation of a symbol, call cycles,
|
|
6
|
+
* and graph export in diagram formats.
|
|
7
|
+
*/
|
|
8
|
+
import { type DecoratorInfo, type SymbolRef, type WiringEdge } from "./queries.js";
|
|
9
|
+
import type { EdgeKind, NodeKind } from "./schema.js";
|
|
10
|
+
import type { GraphStore } from "./store.js";
|
|
11
|
+
export interface UnresolvedCall {
|
|
12
|
+
caller: SymbolRef;
|
|
13
|
+
/** Placeholder node id the call edge points at (`__unknown__:<label>`). */
|
|
14
|
+
targetId: string;
|
|
15
|
+
/** Callee as written in source, e.g. `System.out.println`. */
|
|
16
|
+
targetLabel: string;
|
|
17
|
+
/** Why the resolver gave up. */
|
|
18
|
+
reason: string;
|
|
19
|
+
line?: number;
|
|
20
|
+
edgeKind: EdgeKind;
|
|
21
|
+
}
|
|
22
|
+
export interface ReasonCount {
|
|
23
|
+
reason: string;
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
export interface UnresolvedReport {
|
|
27
|
+
/** Total unresolved call edges matching the filters, ignoring `limit`. */
|
|
28
|
+
total: number;
|
|
29
|
+
/** Unresolved edges grouped by resolver reason, most frequent first. */
|
|
30
|
+
byReason: ReasonCount[];
|
|
31
|
+
calls: UnresolvedCall[];
|
|
32
|
+
/** True when `calls` hit the scan limit before `total` did. */
|
|
33
|
+
scanTruncated: boolean;
|
|
34
|
+
/** `kind` filter that was applied to the caller node kind. */
|
|
35
|
+
callerKind?: NodeKind;
|
|
36
|
+
/** `reason` filter that was applied (substring, case-insensitive). */
|
|
37
|
+
reasonFilter?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface UnresolvedQueryOptions {
|
|
40
|
+
/** Substring match against the resolver reason, case-insensitive. */
|
|
41
|
+
reason?: string;
|
|
42
|
+
/** Restrict to unresolved calls made by callers of this node kind. */
|
|
43
|
+
kind?: NodeKind;
|
|
44
|
+
/** Cap on rows scanned (default 2000). */
|
|
45
|
+
limit?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Every call the resolver could not bind to a node, with the reason it failed.
|
|
49
|
+
*
|
|
50
|
+
* Unresolved calls are the honest boundary of a static index: they show where
|
|
51
|
+
* analysis stops (dynamic dispatch, untyped receivers, missing dependencies)
|
|
52
|
+
* and they are the highest-signal input for improving the parsers.
|
|
53
|
+
*/
|
|
54
|
+
export declare function findUnresolved(store: GraphStore, opts?: UnresolvedQueryOptions): UnresolvedReport;
|
|
55
|
+
export interface NodeUnresolvedInfo {
|
|
56
|
+
/** Calls this node makes that could not be resolved. */
|
|
57
|
+
outgoing: UnresolvedCall[];
|
|
58
|
+
/** Unresolved calls elsewhere in the graph that point at this node. */
|
|
59
|
+
incoming: {
|
|
60
|
+
caller: SymbolRef;
|
|
61
|
+
line?: number;
|
|
62
|
+
}[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Unresolved call detail for a single node, used to annotate `get_node`.
|
|
66
|
+
* Returns `undefined` when the node has no unresolved edges in either
|
|
67
|
+
* direction so callers can omit the block entirely.
|
|
68
|
+
*/
|
|
69
|
+
export declare function unresolvedForNode(store: GraphStore, nodeId: string): NodeUnresolvedInfo | undefined;
|
|
70
|
+
export interface ImpactCaller {
|
|
71
|
+
caller: SymbolRef;
|
|
72
|
+
depth: number;
|
|
73
|
+
callSiteLine?: number;
|
|
74
|
+
edgeKind: EdgeKind;
|
|
75
|
+
}
|
|
76
|
+
export interface ImpactImplementation {
|
|
77
|
+
type: SymbolRef;
|
|
78
|
+
/** Override of the analyzed method, when the symbol is a member. */
|
|
79
|
+
method?: SymbolRef;
|
|
80
|
+
depth: number;
|
|
81
|
+
via: "EXTENDS" | "IMPLEMENTS";
|
|
82
|
+
}
|
|
83
|
+
export interface ImpactSummary {
|
|
84
|
+
totalCallers: number;
|
|
85
|
+
directCallers: number;
|
|
86
|
+
entryPoints: number;
|
|
87
|
+
routes: number;
|
|
88
|
+
implementations: number;
|
|
89
|
+
affectedFiles: number;
|
|
90
|
+
/**
|
|
91
|
+
* Heuristic blast radius: `high` when a framework entry point reaches the
|
|
92
|
+
* symbol, `medium` when at least one caller exists, else `low`.
|
|
93
|
+
*/
|
|
94
|
+
risk: "low" | "medium" | "high";
|
|
95
|
+
}
|
|
96
|
+
export interface ImpactAnalysis {
|
|
97
|
+
symbol: SymbolRef;
|
|
98
|
+
summary: ImpactSummary;
|
|
99
|
+
callers: ImpactCaller[];
|
|
100
|
+
entryPoints: {
|
|
101
|
+
symbol: SymbolRef;
|
|
102
|
+
entryPointKind: string;
|
|
103
|
+
detail?: string;
|
|
104
|
+
viaDepth?: number;
|
|
105
|
+
}[];
|
|
106
|
+
routes: WiringEdge[];
|
|
107
|
+
implementations: ImpactImplementation[];
|
|
108
|
+
affectedFiles: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface ImpactOptions {
|
|
111
|
+
maxDepth?: number;
|
|
112
|
+
includeDynamic?: boolean;
|
|
113
|
+
limit?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* "What breaks if I change this?" — reverse callers, framework entry points,
|
|
117
|
+
* routes and implementations in a single response.
|
|
118
|
+
*
|
|
119
|
+
* A type aggregates the callers of its contained methods, since call edges bind
|
|
120
|
+
* to methods and a class is usually changed through its members.
|
|
121
|
+
*/
|
|
122
|
+
export declare function impactAnalysis(store: GraphStore, symbol: string, opts?: ImpactOptions): ImpactAnalysis | null;
|
|
123
|
+
export interface ExplainedMember {
|
|
124
|
+
symbol: SymbolRef;
|
|
125
|
+
line?: number;
|
|
126
|
+
decorators: DecoratorInfo[];
|
|
127
|
+
}
|
|
128
|
+
export interface SymbolExplanation {
|
|
129
|
+
symbol: SymbolRef;
|
|
130
|
+
line?: number;
|
|
131
|
+
isEntryPoint?: boolean;
|
|
132
|
+
decorators: DecoratorInfo[];
|
|
133
|
+
members: ExplainedMember[];
|
|
134
|
+
callers: ImpactCaller[];
|
|
135
|
+
callees: ImpactCaller[];
|
|
136
|
+
implementations: ImpactImplementation[];
|
|
137
|
+
routes: WiringEdge[];
|
|
138
|
+
injections: WiringEdge[];
|
|
139
|
+
reflections: WiringEdge[];
|
|
140
|
+
summary: {
|
|
141
|
+
members: number;
|
|
142
|
+
callers: number;
|
|
143
|
+
callees: number;
|
|
144
|
+
implementations: number;
|
|
145
|
+
wiringEdges: number;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export interface ExplainOptions {
|
|
149
|
+
maxDepth?: number;
|
|
150
|
+
includeDynamic?: boolean;
|
|
151
|
+
limit?: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* One-shot digest of a symbol: what it is, what it is annotated with, what it
|
|
155
|
+
* contains, who calls it, what it calls, and how frameworks reach it.
|
|
156
|
+
*
|
|
157
|
+
* Intended to replace a chain of five tool calls with one round trip.
|
|
158
|
+
*/
|
|
159
|
+
export declare function explainSymbol(store: GraphStore, symbol: string, opts?: ExplainOptions): SymbolExplanation | null;
|
|
160
|
+
export interface CallCycle {
|
|
161
|
+
size: number;
|
|
162
|
+
members: SymbolRef[];
|
|
163
|
+
/** Shortest closed walk through the cycle, starting at the first member. */
|
|
164
|
+
sample: string[];
|
|
165
|
+
}
|
|
166
|
+
export interface CycleReport {
|
|
167
|
+
/** Number of multi-node cycles reported (after `minSize`). */
|
|
168
|
+
cycleCount: number;
|
|
169
|
+
cycles: CallCycle[];
|
|
170
|
+
/** Symbols that call themselves directly (size-1 cycles). */
|
|
171
|
+
selfRecursive: SymbolRef[];
|
|
172
|
+
edgeKinds: EdgeKind[];
|
|
173
|
+
scannedNodes: number;
|
|
174
|
+
scannedEdges: number;
|
|
175
|
+
/** True when the edge scan hit `maxNodes` and results may be incomplete. */
|
|
176
|
+
scanTruncated: boolean;
|
|
177
|
+
}
|
|
178
|
+
export interface CycleOptions {
|
|
179
|
+
edgeKinds?: EdgeKind[];
|
|
180
|
+
includeDynamic?: boolean;
|
|
181
|
+
/** Minimum cycle size to report. Default 2 (direct recursion is separate). */
|
|
182
|
+
minSize?: number;
|
|
183
|
+
/** Cap on edges scanned, guarding against very large graphs. */
|
|
184
|
+
maxEdges?: number;
|
|
185
|
+
limit?: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Find strongly connected components in the call graph with an iterative
|
|
189
|
+
* Tarjan. A component larger than one node means the members are mutually
|
|
190
|
+
* reachable, i.e. a call cycle; a self-edge is direct recursion.
|
|
191
|
+
*
|
|
192
|
+
* Iterative rather than recursive so deep call chains cannot blow the stack.
|
|
193
|
+
*/
|
|
194
|
+
export declare function findCycles(store: GraphStore, opts?: CycleOptions): CycleReport;
|
|
195
|
+
export type ExportFormat = "mermaid" | "dot";
|
|
196
|
+
export interface GraphExport {
|
|
197
|
+
format: ExportFormat;
|
|
198
|
+
diagram: string;
|
|
199
|
+
nodeCount: number;
|
|
200
|
+
edgeCount: number;
|
|
201
|
+
truncated: boolean;
|
|
202
|
+
/** Symbol the export was centered on, when one was given. */
|
|
203
|
+
center?: SymbolRef;
|
|
204
|
+
}
|
|
205
|
+
export interface ExportOptions {
|
|
206
|
+
symbol?: string;
|
|
207
|
+
radius?: number;
|
|
208
|
+
edgeKinds?: EdgeKind[];
|
|
209
|
+
format?: ExportFormat;
|
|
210
|
+
direction?: "LR" | "TB" | "RL" | "BT";
|
|
211
|
+
limit?: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Render a neighborhood (or the whole graph) as Mermaid or Graphviz DOT so an
|
|
215
|
+
* agent can show the user a diagram instead of a list of edges.
|
|
216
|
+
*/
|
|
217
|
+
export declare function exportGraph(store: GraphStore, opts?: ExportOptions): GraphExport | null;
|