@colbymchenry/codegraph 0.9.9 → 1.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/README.md +120 -24
- package/dist/bin/codegraph.d.ts +1 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/queries.d.ts +43 -0
- package/dist/db/sqlite-adapter.d.ts +7 -0
- package/dist/directory.d.ts +49 -2
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/grammars.d.ts +7 -1
- package/dist/extraction/index.d.ts +34 -0
- package/dist/extraction/languages/c-cpp.d.ts +8 -0
- package/dist/extraction/languages/csharp.d.ts +22 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts +13 -0
- package/dist/extraction/liquid-extractor.d.ts +7 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/tree-sitter-types.d.ts +33 -0
- package/dist/extraction/tree-sitter.d.ts +211 -0
- package/dist/extraction/vue-extractor.d.ts +15 -0
- package/dist/index.d.ts +34 -2
- package/dist/installer/instructions-template.d.ts +34 -11
- package/dist/installer/targets/opencode.d.ts +9 -1
- package/dist/installer/targets/shared.d.ts +14 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon.d.ts +60 -1
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/dist/mcp/proxy.d.ts +6 -0
- package/dist/mcp/server-instructions.d.ts +12 -1
- package/dist/mcp/session.d.ts +2 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/tools.d.ts +71 -0
- package/dist/resolution/callback-synthesizer.d.ts +3 -3
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/index.d.ts +1 -0
- package/dist/resolution/import-resolver.d.ts +10 -0
- package/dist/resolution/index.d.ts +80 -0
- package/dist/resolution/name-matcher.d.ts +61 -0
- package/dist/resolution/types.d.ts +27 -3
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/search/query-utils.d.ts +17 -1
- package/dist/sync/watcher.d.ts +124 -32
- package/dist/telemetry/index.d.ts +146 -0
- package/dist/types.d.ts +17 -2
- package/dist/upgrade/index.d.ts +132 -0
- package/dist/utils.d.ts +30 -24
- package/package.json +7 -7
package/dist/mcp/tools.d.ts
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type CodeGraph from '../index';
|
|
7
7
|
import type { PendingFile } from '../sync';
|
|
8
|
+
/**
|
|
9
|
+
* An expected, recoverable "codegraph can't serve this" condition — most
|
|
10
|
+
* importantly a project with no index. The dispatch catch converts these to
|
|
11
|
+
* SUCCESS-shaped responses (guidance text, NO isError): an `isError: true`
|
|
12
|
+
* early in a session teaches the agent the toolset is broken and it stops
|
|
13
|
+
* calling codegraph entirely (observed repeatedly), which is exactly wrong
|
|
14
|
+
* for conditions the agent can simply work around (use built-in tools for
|
|
15
|
+
* that codebase / pass projectPath). isError is reserved for "stop trying"
|
|
16
|
+
* cases: security refusals ({@link PathRefusalError}) and genuine
|
|
17
|
+
* malfunctions.
|
|
18
|
+
*/
|
|
19
|
+
export declare class NotIndexedError extends Error {
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A security refusal (sensitive system path). Stays `isError: true` WITHOUT
|
|
23
|
+
* retry guidance — abandoning this path is the desired agent reaction.
|
|
24
|
+
*/
|
|
25
|
+
export declare class PathRefusalError extends Error {
|
|
26
|
+
}
|
|
8
27
|
/**
|
|
9
28
|
* Calculate the recommended number of codegraph_explore calls based on project size.
|
|
10
29
|
* Larger codebases need more exploration calls to cover their surface area,
|
|
@@ -241,6 +260,16 @@ export declare class ToolHandler {
|
|
|
241
260
|
* Handle codegraph_search
|
|
242
261
|
*/
|
|
243
262
|
private handleSearch;
|
|
263
|
+
/**
|
|
264
|
+
* Group symbol matches into DISTINCT DEFINITIONS — one group per
|
|
265
|
+
* (filePath, qualifiedName), so same-file overloads stay together while
|
|
266
|
+
* unrelated same-named classes across a monorepo's apps (#764: one
|
|
267
|
+
* `UserService` per NestJS app) are kept apart. Optionally narrowed by a
|
|
268
|
+
* `file` path/suffix first.
|
|
269
|
+
*/
|
|
270
|
+
private groupDefinitions;
|
|
271
|
+
/** Section heading for one distinct definition in grouped output. */
|
|
272
|
+
private definitionHeading;
|
|
244
273
|
/**
|
|
245
274
|
* Handle codegraph_callers
|
|
246
275
|
*/
|
|
@@ -275,6 +304,27 @@ export declare class ToolHandler {
|
|
|
275
304
|
* dropping unrelated `OmsOrderService::list`.
|
|
276
305
|
*/
|
|
277
306
|
private buildFlowFromNamedSymbols;
|
|
307
|
+
/**
|
|
308
|
+
* Dynamic-boundary surfacing (#687): when the flow among the agent's named
|
|
309
|
+
* symbols does not fully connect, scan the disconnected symbols' bodies for
|
|
310
|
+
* dynamic-dispatch sites (computed member calls, getattr, reflection, typed
|
|
311
|
+
* message buses, runtime-keyed emits) and ANNOUNCE the boundary — the exact
|
|
312
|
+
* site, the form, and (when a key is statically visible) candidate targets —
|
|
313
|
+
* instead of guessing edges. The answer to "how does A reach B" when no
|
|
314
|
+
* static path exists IS the dispatch site: that's where the flow continues
|
|
315
|
+
* at runtime. Query-time, deterministic, zero graph mutation; a fully
|
|
316
|
+
* connected flow never reaches this method.
|
|
317
|
+
*/
|
|
318
|
+
private buildDynamicBoundaries;
|
|
319
|
+
/**
|
|
320
|
+
* Shortlist candidate runtime targets for a dispatch key surfaced by
|
|
321
|
+
* {@link buildDynamicBoundaries}. Exact conventional names first (`save` →
|
|
322
|
+
* `onSave`/`handleSave`; `CreateCmd` → `CreateCmdHandler`), then FTS, with a
|
|
323
|
+
* normalized-containment post-filter (FTS camel-splitting is fuzzier than a
|
|
324
|
+
* candidate list should be). Symbols the agent already named sort first and
|
|
325
|
+
* are marked — that's the "you were right, here's the wiring" case.
|
|
326
|
+
*/
|
|
327
|
+
private boundaryCandidates;
|
|
278
328
|
/**
|
|
279
329
|
* Compact "blast radius" for the entry symbols of an explore result: who
|
|
280
330
|
* depends on each (callers) and which test files cover it — LOCATIONS ONLY,
|
|
@@ -317,6 +367,20 @@ export declare class ToolHandler {
|
|
|
317
367
|
* Handle codegraph_node
|
|
318
368
|
*/
|
|
319
369
|
private handleNode;
|
|
370
|
+
/**
|
|
371
|
+
* FILE READ MODE: resolve `fileArg` (path or basename) to an indexed file and
|
|
372
|
+
* read it like the Read tool — its current on-disk source with line numbers,
|
|
373
|
+
* narrowable with `offset`/`limit` exactly as Read's are — preceded by a
|
|
374
|
+
* one-line blast-radius header (which files depend on it). `symbolsOnly`
|
|
375
|
+
* returns just the structural map (symbols + dependents) instead of source.
|
|
376
|
+
*
|
|
377
|
+
* Parity goal: the numbered source block is byte-for-byte the shape Read
|
|
378
|
+
* returns (`<n>\t<line>`, no padding), so the agent treats it as a Read — only
|
|
379
|
+
* faster (served from the index) and with the blast radius attached. Security:
|
|
380
|
+
* yaml/properties files are summarized by key, never dumped (#383); reads go
|
|
381
|
+
* through validatePathWithinRoot (#527).
|
|
382
|
+
*/
|
|
383
|
+
private handleFileView;
|
|
320
384
|
/** Render one symbol: details + (optional) body/outline + its caller/callee trail. */
|
|
321
385
|
private renderNodeSection;
|
|
322
386
|
/**
|
|
@@ -396,6 +460,13 @@ export declare class ToolHandler {
|
|
|
396
460
|
private truncateOutput;
|
|
397
461
|
private formatSearchResults;
|
|
398
462
|
private formatNodeList;
|
|
463
|
+
/**
|
|
464
|
+
* Relationship label for a non-`calls` edge in callers/callees lists. A
|
|
465
|
+
* function-as-value edge (#756) is the high-signal one: `callers(cb)`
|
|
466
|
+
* showing "via callback registration" tells the agent this is where the
|
|
467
|
+
* callback is WIRED, not where it's invoked.
|
|
468
|
+
*/
|
|
469
|
+
private edgeLabel;
|
|
399
470
|
private formatImpact;
|
|
400
471
|
/**
|
|
401
472
|
* Build a compact structural outline of a container symbol from its
|
|
@@ -2,9 +2,9 @@ import type { QueryBuilder } from '../db/queries';
|
|
|
2
2
|
import type { ResolutionContext } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Synthesize dispatcher→callback edges (field observers + EventEmitters +
|
|
5
|
-
* React re-render + JSX children + Vue templates + RN event
|
|
6
|
-
* Fabric native-impl + MyBatis Java↔XML + Gin middleware chain).
|
|
7
|
-
* count added. Never throws into indexing — callers wrap in try/catch.
|
|
5
|
+
* React re-render + JSX children + Vue templates + SvelteKit load + RN event
|
|
6
|
+
* channel + Fabric native-impl + MyBatis Java↔XML + Gin middleware chain).
|
|
7
|
+
* Returns the count added. Never throws into indexing — callers wrap in try/catch.
|
|
8
8
|
*/
|
|
9
9
|
export declare function synthesizeCallbackEdges(queries: QueryBuilder, ctx: ResolutionContext): number;
|
|
10
10
|
//# sourceMappingURL=callback-synthesizer.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro Framework Resolver
|
|
3
|
+
*
|
|
4
|
+
* Handles Astro component references, the `Astro` global, `astro:*` virtual
|
|
5
|
+
* module imports, and Astro's `src/pages/` file-based routing.
|
|
6
|
+
*/
|
|
7
|
+
import { FrameworkResolver } from '../types';
|
|
8
|
+
export declare const astroResolver: FrameworkResolver;
|
|
9
|
+
//# sourceMappingURL=astro.d.ts.map
|
|
@@ -33,6 +33,7 @@ export { nestjsResolver } from './nestjs';
|
|
|
33
33
|
export { reactResolver } from './react';
|
|
34
34
|
export { svelteResolver } from './svelte';
|
|
35
35
|
export { vueResolver } from './vue';
|
|
36
|
+
export { astroResolver } from './astro';
|
|
36
37
|
export { djangoResolver, flaskResolver, fastapiResolver } from './python';
|
|
37
38
|
export { railsResolver } from './ruby';
|
|
38
39
|
export { springResolver } from './java';
|
|
@@ -27,6 +27,16 @@ export declare function clearCppIncludeDirCache(): void;
|
|
|
27
27
|
* Returns paths relative to projectRoot.
|
|
28
28
|
*/
|
|
29
29
|
export declare function loadCppIncludeDirs(projectRoot: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Is this reference a PHP include/require PATH (vs a namespace `use` symbol)?
|
|
32
|
+
*
|
|
33
|
+
* include/require emit a file path ("lib.php", "inc/db.php", "../x.php"),
|
|
34
|
+
* whereas namespace use is an FQN (App\Foo\Bar) or a bare class symbol
|
|
35
|
+
* (Closure). PHP identifiers contain neither '/' nor '.', so a slash or dot
|
|
36
|
+
* marks a path-shaped include. Such references resolve to files only — never
|
|
37
|
+
* to a same-named symbol — so callers must not fall back to the name-matcher.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isPhpIncludePathRef(ref: UnresolvedRef): boolean;
|
|
30
40
|
/**
|
|
31
41
|
* Extract import mappings from a file
|
|
32
42
|
*/
|
|
@@ -17,6 +17,9 @@ export declare class ReferenceResolver {
|
|
|
17
17
|
private queries;
|
|
18
18
|
private context;
|
|
19
19
|
private frameworks;
|
|
20
|
+
private deferredChainRefs;
|
|
21
|
+
private deferredThisMemberRefs;
|
|
22
|
+
private razorUsingsCache;
|
|
20
23
|
private nodeCache;
|
|
21
24
|
private fileCache;
|
|
22
25
|
private importMappingCache;
|
|
@@ -29,6 +32,7 @@ export declare class ReferenceResolver {
|
|
|
29
32
|
private cachesWarmed;
|
|
30
33
|
private projectAliases;
|
|
31
34
|
private goModule;
|
|
35
|
+
private workspacePackages;
|
|
32
36
|
constructor(projectRoot: string, queries: QueryBuilder);
|
|
33
37
|
/**
|
|
34
38
|
* Initialize the resolver (detect frameworks, etc.)
|
|
@@ -86,6 +90,20 @@ export declare class ReferenceResolver {
|
|
|
86
90
|
* Resolve and persist edges to database
|
|
87
91
|
*/
|
|
88
92
|
resolveAndPersist(unresolvedRefs: UnresolvedReference[], onProgress?: (current: number, total: number) => void): ResolutionResult;
|
|
93
|
+
/**
|
|
94
|
+
* Second resolution pass for chained static-factory / fluent calls whose
|
|
95
|
+
* chained method is defined on a SUPERTYPE the receiver's type conforms to —
|
|
96
|
+
* a protocol-extension / inherited / default-interface method (#750). The
|
|
97
|
+
* first pass can't resolve these because `implements`/`extends` edges aren't
|
|
98
|
+
* built yet; this runs AFTER edges are persisted, so `context.getSupertypes`
|
|
99
|
+
* (and the conformance fallback in resolveMethodOnType) can walk them.
|
|
100
|
+
*
|
|
101
|
+
* Operates only on the leftover unresolved refs that have the `inner().method`
|
|
102
|
+
* chain shape, for the dotted-chain languages — a small set — and is idempotent
|
|
103
|
+
* (re-resolving an already-resolved ref is a no-op since it's been deleted).
|
|
104
|
+
* Returns the number of newly-created edges.
|
|
105
|
+
*/
|
|
106
|
+
resolveChainedCallsViaConformance(): number;
|
|
89
107
|
/**
|
|
90
108
|
* Resolve and persist in batches to keep memory bounded.
|
|
91
109
|
* Processes unresolved references in chunks, persisting edges and cleaning
|
|
@@ -108,6 +126,68 @@ export declare class ReferenceResolver {
|
|
|
108
126
|
* Get language from node ID
|
|
109
127
|
*/
|
|
110
128
|
private getLanguageFromNodeId;
|
|
129
|
+
/**
|
|
130
|
+
* Drop an import/name-strategy resolution that crosses a language family.
|
|
131
|
+
* Two regimes (mirrors `applyLanguageGate`'s candidate filter):
|
|
132
|
+
* - `references` (type usage): STRICT — a `Type.member` static read names a
|
|
133
|
+
* same-family type, never a coincidentally same-named symbol in another
|
|
134
|
+
* language. Drops any non-same-family target.
|
|
135
|
+
* - `imports` (import binding / `#include`): both-known — a C++ `#include
|
|
136
|
+
* "X.h"` must not resolve to a same-named ObjC header on another platform
|
|
137
|
+
* (basename collision), but a singleton-family / SFC language (`vue` →
|
|
138
|
+
* `.ts`) importing across is left alone.
|
|
139
|
+
* Applies to the import (strategy 2) + name-match (strategy 3) results.
|
|
140
|
+
*/
|
|
141
|
+
/**
|
|
142
|
+
* Collect the `@using` namespaces in scope for a `.razor`/`.cshtml` file: its
|
|
143
|
+
* own `@using` directives plus every `_Imports.razor` from the file's folder up
|
|
144
|
+
* to the project root (Razor `_Imports` cascade). Cached per file.
|
|
145
|
+
*/
|
|
146
|
+
private getRazorUsings;
|
|
147
|
+
/**
|
|
148
|
+
* Resolve a Razor/Blazor simple type ref through the file's `@using`
|
|
149
|
+
* namespaces: `CatalogBrand` + `@using BlazorShared.Models` → the node whose
|
|
150
|
+
* qualified name is `BlazorShared.Models::CatalogBrand`. Only resolves when the
|
|
151
|
+
* `@using` set yields exactly ONE type (otherwise it stays ambiguous and falls
|
|
152
|
+
* through to name-matching).
|
|
153
|
+
*/
|
|
154
|
+
private resolveRazorUsing;
|
|
155
|
+
/**
|
|
156
|
+
* Resolve a `this.<member>` function-as-value reference (#756/#808) to the
|
|
157
|
+
* ENCLOSING CLASS's own member — never a same-named symbol elsewhere. The
|
|
158
|
+
* registration idiom (`btn.on('click', this.handleClick)`) names a member
|
|
159
|
+
* of the class being defined, so the only valid target shares the
|
|
160
|
+
* from-symbol's qualified-name scope. Function/method targets only — a
|
|
161
|
+
* property (a data field, post-#808 classification) yields no edge — same
|
|
162
|
+
* file required, no fallback of any kind.
|
|
163
|
+
*/
|
|
164
|
+
private resolveThisMemberFnRef;
|
|
165
|
+
/**
|
|
166
|
+
* Second pass for `this.<member>` refs whose member wasn't on the enclosing
|
|
167
|
+
* class itself (#808): once implements/extends edges exist, walk the
|
|
168
|
+
* class's supertypes (transitively, depth-capped) and resolve the member on
|
|
169
|
+
* the nearest one that declares it — `this.handleSubmit` registered in a
|
|
170
|
+
* subclass resolves to `FormBase::handleSubmit`. Validated targets only
|
|
171
|
+
* (function/method kind, same language family); no match → no edge.
|
|
172
|
+
* Mirrors resolveChainedCallsViaConformance's lifecycle. Returns the number
|
|
173
|
+
* of newly-created edges.
|
|
174
|
+
*/
|
|
175
|
+
resolveDeferredThisMemberRefs(): number;
|
|
176
|
+
private gateLanguage;
|
|
177
|
+
/**
|
|
178
|
+
* Drop a FRAMEWORK-strategy resolution that crosses two *known* language
|
|
179
|
+
* families for a type-usage (`references`) or import-binding (`imports`)
|
|
180
|
+
* edge. The framework strategy is intentionally ungated for cross-language
|
|
181
|
+
* bridges, but those legitimate bridges are either `calls` edges (RN/Expo
|
|
182
|
+
* JS → native) or config↔code edges whose config side (`yaml`/`blade`/…) is
|
|
183
|
+
* not a known programming-language family. A `references`/`imports` edge
|
|
184
|
+
* between two *known* families is always a coincidental name collision — the
|
|
185
|
+
* React/Svelte/Vue PascalCase component resolvers name-match `getNodesByName`
|
|
186
|
+
* without a language check, so a TS `<TestRunner>` ref happily matched a
|
|
187
|
+
* Kotlin `class TestRunner`. Gating only the both-known-cross-family case
|
|
188
|
+
* lets config bridges and `calls` bridges through untouched.
|
|
189
|
+
*/
|
|
190
|
+
private gateFrameworkLanguage;
|
|
111
191
|
}
|
|
112
192
|
/**
|
|
113
193
|
* Create a reference resolver instance
|
|
@@ -9,6 +9,36 @@ import { UnresolvedRef, ResolvedRef, ResolutionContext } from './types';
|
|
|
9
9
|
* by matching the filename against file nodes.
|
|
10
10
|
*/
|
|
11
11
|
export declare function matchByFilePath(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
12
|
+
export declare function sameLanguageFamily(a: string, b: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* True when `lang` belongs to a known multi-language family (jvm/apple/web/c).
|
|
15
|
+
* Languages not listed (php, python, go, ruby, rust, dart, …) and config
|
|
16
|
+
* formats (yaml/xml/blade) form their own singleton families and return
|
|
17
|
+
* `false` — used to leave config↔code framework bridges (whose config side is
|
|
18
|
+
* never a known programming-language family) out of the cross-family gate.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isKnownLanguageFamily(lang: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* True when `a` and `b` are two DIFFERENT *known* language families — the
|
|
23
|
+
* signature of a coincidental cross-language name collision (a TS `import
|
|
24
|
+
* React` matching a Swift `import React`, a C++ `#include "X.h"` matching a
|
|
25
|
+
* same-named ObjC header on another platform). The both-*known* test is
|
|
26
|
+
* deliberately weaker than {@link sameLanguageFamily}'s negation: a
|
|
27
|
+
* single-file-component language that carries its own tag (`vue`/`svelte`)
|
|
28
|
+
* importing a `.ts` module, or any singleton-family language (php/go/ruby/…),
|
|
29
|
+
* returns `false` here and is left alone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function crossesKnownFamily(a: string, b: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a function-as-value reference (#756) — a function name used as a
|
|
34
|
+
* callback/function-pointer value (`register(handler)`, `o->cb = handler`,
|
|
35
|
+
* `{ .cb = handler }`, `signal(SIGINT, handler)`). The ONLY strategy allowed
|
|
36
|
+
* for `function_ref` refs: exact name, function/method targets only, same
|
|
37
|
+
* language family, same-file first, and cross-file only when the match is
|
|
38
|
+
* UNIQUE. No fuzzy fallback, no qualified-name walking — a wrong callback
|
|
39
|
+
* edge is worse than none.
|
|
40
|
+
*/
|
|
41
|
+
export declare function matchFunctionRef(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
12
42
|
/**
|
|
13
43
|
* Try to resolve a reference by exact name match
|
|
14
44
|
*/
|
|
@@ -17,6 +47,37 @@ export declare function matchByExactName(ref: UnresolvedRef, context: Resolution
|
|
|
17
47
|
* Try to resolve by qualified name
|
|
18
48
|
*/
|
|
19
49
|
export declare function matchByQualifiedName(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve a C++ chained call whose receiver is itself a call — encoded by the
|
|
52
|
+
* extractor as `<innerCallee>().<method>` (#645). The receiver's type is what
|
|
53
|
+
* the inner call returns; the outer method is then resolved and VALIDATED on it
|
|
54
|
+
* (resolveMethodOnType requires `cls::method` to exist), so a wrong inference
|
|
55
|
+
* produces no edge rather than a wrong one.
|
|
56
|
+
*/
|
|
57
|
+
export declare function matchCppCallChain(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a `::`-scoped factory chain whose receiver is a scoped/static call —
|
|
60
|
+
* PHP `Cls::for($x)->method()` (#608, the per-credential Laravel client idiom) or
|
|
61
|
+
* Rust `Foo::new().bar()` (an associated-function call) — both encoded by the
|
|
62
|
+
* extractor as `Cls::factory().method`. The receiver's type is what `Cls::factory`
|
|
63
|
+
* returns: a `self` marker (PHP `: self`/`: static`, Rust `-> Self`) resolves to
|
|
64
|
+
* the factory's own type, a concrete return type to that type. The outer method is
|
|
65
|
+
* then resolved and VALIDATED on it (resolveMethodOnType requires the method to
|
|
66
|
+
* exist on the type or a supertype it conforms to), so a wrong inference yields no
|
|
67
|
+
* edge rather than a wrong one. Shared by the `::`-receiver languages (PHP, Rust).
|
|
68
|
+
*/
|
|
69
|
+
export declare function matchScopedCallChain(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve a dotted chained call whose receiver is a static factory / fluent call —
|
|
72
|
+
* `Foo.getInstance().bar()`, encoded by the extractor as `Foo.getInstance().bar`
|
|
73
|
+
* (#645/#608 mechanism). The receiver's type is what `Foo.getInstance` returns
|
|
74
|
+
* (its declared return type); the outer method is then resolved and VALIDATED on
|
|
75
|
+
* it (resolveMethodOnType requires `Type::method` to exist), so a wrong inference
|
|
76
|
+
* yields no edge rather than a wrong one (e.g. a same-named `bar()` on an
|
|
77
|
+
* unrelated class is never matched). Shared by the dot-notation languages
|
|
78
|
+
* (Java, Kotlin, C#, Swift) — same receiver shape, same `Class::method` qualified names.
|
|
79
|
+
*/
|
|
80
|
+
export declare function matchDottedCallChain(ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null;
|
|
20
81
|
/**
|
|
21
82
|
* Try to resolve by method name on a class/object
|
|
22
83
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Types for the reference resolution system.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { Language, Node, ReferenceKind } from '../types';
|
|
7
7
|
/**
|
|
8
8
|
* An unresolved reference from extraction
|
|
9
9
|
*/
|
|
@@ -13,7 +13,7 @@ export interface UnresolvedRef {
|
|
|
13
13
|
/** The name being referenced */
|
|
14
14
|
referenceName: string;
|
|
15
15
|
/** Type of reference */
|
|
16
|
-
referenceKind:
|
|
16
|
+
referenceKind: ReferenceKind;
|
|
17
17
|
/** Line where reference occurs */
|
|
18
18
|
line: number;
|
|
19
19
|
/** Column where reference occurs */
|
|
@@ -36,7 +36,7 @@ export interface ResolvedRef {
|
|
|
36
36
|
/** Confidence score (0-1) */
|
|
37
37
|
confidence: number;
|
|
38
38
|
/** How it was resolved */
|
|
39
|
-
resolvedBy: 'exact-match' | 'import' | 'qualified-name' | 'framework' | 'fuzzy' | 'instance-method' | 'file-path';
|
|
39
|
+
resolvedBy: 'exact-match' | 'import' | 'qualified-name' | 'framework' | 'fuzzy' | 'instance-method' | 'file-path' | 'function-ref';
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Result of resolution attempt
|
|
@@ -76,6 +76,23 @@ export interface ResolutionContext {
|
|
|
76
76
|
getAllFiles(): string[];
|
|
77
77
|
/** Get nodes by lowercase name (O(1) lookup for fuzzy matching) */
|
|
78
78
|
getNodesByLowerName(lowerName: string): Node[];
|
|
79
|
+
/**
|
|
80
|
+
* Direct supertypes of the type named `typeName` (same language): the classes
|
|
81
|
+
* it extends and the interfaces / protocols / traits it implements/conforms to,
|
|
82
|
+
* by simple name. Backed by the resolved `implements`/`extends` edges, so it is
|
|
83
|
+
* EMPTY during the first resolution pass (edges aren't built yet) and populated
|
|
84
|
+
* afterward — the conformance pass uses it to resolve a chained method defined
|
|
85
|
+
* on a supertype the receiver type conforms to (e.g. a protocol-extension
|
|
86
|
+
* method). Optional so external/test contexts compile without it.
|
|
87
|
+
*/
|
|
88
|
+
getSupertypes?(typeName: string, language: Language): string[];
|
|
89
|
+
/**
|
|
90
|
+
* Look up a node by its id. Lets matchers derive the FROM-symbol's
|
|
91
|
+
* enclosing-class scope (Swift implicit-self method scoping, `this.X`
|
|
92
|
+
* member resolution). Optional so external/test contexts compile
|
|
93
|
+
* without it.
|
|
94
|
+
*/
|
|
95
|
+
getNodeById?(id: string): Node | null;
|
|
79
96
|
/** Get cached import mappings for a file */
|
|
80
97
|
getImportMappings(filePath: string, language: Language): ImportMapping[];
|
|
81
98
|
/**
|
|
@@ -94,6 +111,13 @@ export interface ResolutionContext {
|
|
|
94
111
|
* cross-package imports from third-party packages.
|
|
95
112
|
*/
|
|
96
113
|
getGoModule?(): import('./go-module').GoModule | null;
|
|
114
|
+
/**
|
|
115
|
+
* Monorepo workspace member packages, keyed by declared package name.
|
|
116
|
+
* Returns `null` for single-package repos (no `workspaces` field).
|
|
117
|
+
* Lets the resolver treat `@scope/ui/sub` as a local import into the
|
|
118
|
+
* member's directory instead of an external npm package (#629).
|
|
119
|
+
*/
|
|
120
|
+
getWorkspacePackages?(): import('./workspace-packages').WorkspacePackages | null;
|
|
97
121
|
/**
|
|
98
122
|
* Re-exports declared by a file (`export { x } from './other'`,
|
|
99
123
|
* `export * from './other'`). Empty array when the file has none.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS/TS workspace (monorepo) package resolution.
|
|
3
|
+
*
|
|
4
|
+
* npm / yarn / bun read member packages from the root `package.json`
|
|
5
|
+
* `workspaces` field; pnpm from `pnpm-workspace.yaml`. A cross-package
|
|
6
|
+
* import like `@scope/ui/widgets` is LOCAL to the monorepo, but to a
|
|
7
|
+
* single-package resolver it looks exactly like a third-party npm
|
|
8
|
+
* specifier — so `isExternalImport` flags it external and the
|
|
9
|
+
* consumer↔definition edge is never created. For component barrels
|
|
10
|
+
* (`export { default as X } from './x.svelte'`) that surfaces as a false
|
|
11
|
+
* `0 callers` on a live component (issue #629).
|
|
12
|
+
*
|
|
13
|
+
* This module maps each member package's declared `name` to its
|
|
14
|
+
* directory so the resolver can rewrite `@scope/ui/widgets` →
|
|
15
|
+
* `packages/ui/widgets` and then run normal extension/index resolution.
|
|
16
|
+
*
|
|
17
|
+
* Scope deliberately small for v1 (mirrors path-aliases.ts):
|
|
18
|
+
* - reads `workspaces` (array OR `{ packages: [...] }`) from package.json,
|
|
19
|
+
* plus a minimal `pnpm-workspace.yaml` `packages:` list
|
|
20
|
+
* - expands one level of `*` / `**` globs (`packages/*`, `apps/*`)
|
|
21
|
+
* - subpath resolution is directory-based (`@scope/ui/sub` → `<ui>/sub`);
|
|
22
|
+
* it does NOT yet honour a member's `exports` map or `main` field
|
|
23
|
+
* - returns null when the project declares no workspaces, so single-
|
|
24
|
+
* package repos pay nothing and see no behaviour change.
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkspacePackages {
|
|
27
|
+
/** Member package `name` → directory relative to projectRoot (posix). */
|
|
28
|
+
byName: Map<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load workspace member packages for `projectRoot`. Returns `null` when
|
|
32
|
+
* the project declares no workspaces (the common single-package case) —
|
|
33
|
+
* callers then skip all workspace logic.
|
|
34
|
+
*
|
|
35
|
+
* Cheap to call repeatedly only via the resolver's per-instance cache;
|
|
36
|
+
* this function itself touches the filesystem, so the resolver memoises it
|
|
37
|
+
* the same way it does {@link loadProjectAliases} / {@link loadGoModule}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadWorkspacePackages(projectRoot: string): WorkspacePackages | null;
|
|
40
|
+
/**
|
|
41
|
+
* Rewrite a bare workspace import to a path relative to projectRoot,
|
|
42
|
+
* WITHOUT an extension — the caller applies the language's extension/index
|
|
43
|
+
* resolution. `@scope/ui/widgets` → `packages/ui/widgets`; the bare package
|
|
44
|
+
* name `@scope/ui` → its directory. Returns `null` when no member package
|
|
45
|
+
* name matches.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveWorkspaceImport(importPath: string, ws: WorkspacePackages): string | null;
|
|
48
|
+
//# sourceMappingURL=workspace-packages.d.ts.map
|
|
@@ -4,6 +4,22 @@
|
|
|
4
4
|
* Shared module for search term extraction and scoring.
|
|
5
5
|
*/
|
|
6
6
|
import { Node } from '../types';
|
|
7
|
+
/** Normalize a name to a comparable token: lowercase, alphanumerics only. */
|
|
8
|
+
export declare function normalizeNameToken(raw: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Tokens that name the PROJECT as a whole — its `go.mod` module, `package.json`
|
|
11
|
+
* name, or repo root directory — rather than any specific symbol. A user
|
|
12
|
+
* naturally puts the project name in a query as context ("MyApp backend
|
|
13
|
+
* routes"), but it carries no discriminative signal: when it's also a substring
|
|
14
|
+
* of a symbol or path on one stack (a `MyAppFrontend/` dir, a `MyAppApp` class)
|
|
15
|
+
* it lexically inflates that stack and buries the rest (#720).
|
|
16
|
+
*
|
|
17
|
+
* Returned normalized (lowercase, alphanumerics only) so a query word can be
|
|
18
|
+
* compared by its normalized form. Only names ≥5 chars are kept — short ones
|
|
19
|
+
* (`api`, `app`, `core`, `web`) collide with real query terms too often to
|
|
20
|
+
* safely down-weight.
|
|
21
|
+
*/
|
|
22
|
+
export declare function deriveProjectNameTokens(projectRoot: string): Set<string>;
|
|
7
23
|
/**
|
|
8
24
|
* Common stop words to filter from search queries.
|
|
9
25
|
* Includes generic English + code-specific noise words.
|
|
@@ -34,7 +50,7 @@ export declare function extractSearchTerms(query: string, options?: {
|
|
|
34
50
|
* Score path relevance to a query
|
|
35
51
|
* Higher score = more relevant path
|
|
36
52
|
*/
|
|
37
|
-
export declare function scorePathRelevance(filePath: string, query: string): number;
|
|
53
|
+
export declare function scorePathRelevance(filePath: string, query: string, projectNameTokens?: Set<string>): number;
|
|
38
54
|
/**
|
|
39
55
|
* Check if a file path looks like a test file
|
|
40
56
|
*/
|