@colbymchenry/codegraph 0.9.9 → 1.0.0
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 +100 -17
- package/dist/bin/codegraph.d.ts +1 -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 +34 -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.d.ts +60 -1
- package/dist/mcp/dynamic-boundaries.d.ts +41 -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
|
@@ -53,6 +53,40 @@ export declare function hashContent(content: string): string;
|
|
|
53
53
|
* it project code; the explicit `.gitignore` negation is the only opt-in).
|
|
54
54
|
*/
|
|
55
55
|
export declare function buildDefaultIgnore(rootDir: string): Ignore;
|
|
56
|
+
/**
|
|
57
|
+
* Workspace-scope ignore matcher. Ordinary paths get the root's matcher
|
|
58
|
+
* (built-in defaults + root `.gitignore`); paths inside an EMBEDDED repo get
|
|
59
|
+
* that repo's own matcher (defaults + its root `.gitignore`) — the parent's
|
|
60
|
+
* `.gitignore` hides a child repo from git, not from the index (#514). A
|
|
61
|
+
* directory path (trailing slash) that is an ANCESTOR of an embedded root is
|
|
62
|
+
* never ignored, so directory-pruning callers (the Linux per-directory
|
|
63
|
+
* watcher) still descend to reach the embedded repos.
|
|
64
|
+
*
|
|
65
|
+
* Single source of truth for indexer and watcher scope — they must not diverge.
|
|
66
|
+
*/
|
|
67
|
+
export declare class ScopeIgnore {
|
|
68
|
+
private rootMatcher;
|
|
69
|
+
private embedded;
|
|
70
|
+
private defaults;
|
|
71
|
+
constructor(rootMatcher: Ignore, embedded: Array<{
|
|
72
|
+
root: string;
|
|
73
|
+
matcher: Ignore;
|
|
74
|
+
}>);
|
|
75
|
+
ignores(rel: string): boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build the workspace-scope matcher. When the caller already knows the
|
|
79
|
+
* embedded roots (the scanner discovers them during collection), pass them to
|
|
80
|
+
* skip rediscovery; otherwise they're discovered here (the watcher path).
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildScopeIgnore(rootDir: string, embeddedRoots?: Iterable<string>): ScopeIgnore;
|
|
83
|
+
/**
|
|
84
|
+
* Standalone discovery of every embedded repo root under `rootDir` (relative,
|
|
85
|
+
* trailing-slashed) — both the untracked kind (#193) and the gitignored kind
|
|
86
|
+
* (#514), recursively (an embedded repo can embed further repos). Returns []
|
|
87
|
+
* for non-git roots: the filesystem walk handles nested repos there already.
|
|
88
|
+
*/
|
|
89
|
+
export declare function discoverEmbeddedRepoRoots(rootDir: string): string[];
|
|
56
90
|
/**
|
|
57
91
|
* Recursively scan a directory for source files.
|
|
58
92
|
*
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a C++ return type to the bare class name a method could be called
|
|
4
|
+
* on. Unwraps smart-pointer / optional wrappers to their element type
|
|
5
|
+
* (`std::unique_ptr<Widget>` → `Widget`) so a factory's `->method()` resolves on
|
|
6
|
+
* the pointee. Strips cv-qualifiers, `&`/`*`, namespace qualifiers, and other
|
|
7
|
+
* template args. Returns undefined for primitives / void / `auto` / empty.
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeCppReturnType(raw: string): string | undefined;
|
|
2
10
|
export declare const cExtractor: LanguageExtractor;
|
|
3
11
|
export declare const cppExtractor: LanguageExtractor;
|
|
4
12
|
//# sourceMappingURL=c-cpp.d.ts.map
|
|
@@ -1,3 +1,25 @@
|
|
|
1
1
|
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
2
|
+
/**
|
|
3
|
+
* Blank C# conditional-compilation directive lines (`#if` / `#elif` / `#else` /
|
|
4
|
+
* `#endif`) before parsing. The vendored tree-sitter-c-sharp grammar mis-parses
|
|
5
|
+
* a `#if` that appears *inside an enum member list* — the canonical
|
|
6
|
+
* multi-targeting shape:
|
|
7
|
+
*
|
|
8
|
+
* enum ReadType {
|
|
9
|
+
* #if HAVE_DATE_TIME_OFFSET
|
|
10
|
+
* ReadAsDateTimeOffset,
|
|
11
|
+
* #endif
|
|
12
|
+
* ReadAsDouble,
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* It emits an ERROR that, for a nested enum, detaches the *enclosing class's*
|
|
16
|
+
* member list, so most of the class's methods drop out of the index. Removing
|
|
17
|
+
* the directive lines (keeping the guarded code) sidesteps it. Both branches of
|
|
18
|
+
* an `#if/#else` are kept — the same behaviour the previous grammar produced,
|
|
19
|
+
* and the right default for a code graph (index every symbol regardless of
|
|
20
|
+
* build flags). Replacement preserves byte offsets (directive text → spaces,
|
|
21
|
+
* newlines kept) so every symbol's line/column stays exact. (#237)
|
|
22
|
+
*/
|
|
23
|
+
export declare function blankCsharpPreprocessorDirectives(source: string): string;
|
|
2
24
|
export declare const csharpExtractor: LanguageExtractor;
|
|
3
25
|
//# sourceMappingURL=csharp.d.ts.map
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
2
|
+
import type { Node as SyntaxNode } from 'web-tree-sitter';
|
|
3
|
+
/**
|
|
4
|
+
* A TS/JS class field (`public_field_definition` / `field_definition`) is a
|
|
5
|
+
* METHOD only when its value is callable — an arrow function, a function
|
|
6
|
+
* expression, or a HOF call wrapping one (`onScroll = throttle(() => {…})`),
|
|
7
|
+
* exactly mirroring what `resolveBody` below knows how to walk. Everything
|
|
8
|
+
* else (`public fonts: Fonts;`, `count = 0`, `static defaults = {…}`) is a
|
|
9
|
+
* PROPERTY. Previously every field extracted as method-kind (#808), which
|
|
10
|
+
* misrepresented class shape and defeated kind-based filtering — the reason
|
|
11
|
+
* #756's function-ref resolution had to restrict TS/JS bare identifiers to
|
|
12
|
+
* function targets.
|
|
13
|
+
*/
|
|
14
|
+
export declare function classifyTsClassMember(node: SyntaxNode): 'method' | 'property';
|
|
2
15
|
export declare const typescriptExtractor: LanguageExtractor;
|
|
3
16
|
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -24,6 +24,13 @@ export declare class LiquidExtractor {
|
|
|
24
24
|
* Create a file node for the Liquid template
|
|
25
25
|
*/
|
|
26
26
|
private createFileNode;
|
|
27
|
+
/**
|
|
28
|
+
* Shopify OS 2.0 JSON template / section group. Both have a `sections` object
|
|
29
|
+
* mapping an id → `{ "type": "<section-name>", ... }`; the `type` names a
|
|
30
|
+
* `sections/<type>.liquid` file. Emit a `references` edge to each, so a section
|
|
31
|
+
* used only from a JSON template (the OS 2.0 norm) is no longer orphaned.
|
|
32
|
+
*/
|
|
33
|
+
private extractShopifyJsonSections;
|
|
27
34
|
/**
|
|
28
35
|
* Extract {% render 'snippet' %} and {% include 'snippet' %} references
|
|
29
36
|
*/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
export declare class RazorExtractor {
|
|
3
|
+
private filePath;
|
|
4
|
+
private source;
|
|
5
|
+
private nodes;
|
|
6
|
+
private edges;
|
|
7
|
+
private unresolvedReferences;
|
|
8
|
+
private errors;
|
|
9
|
+
constructor(filePath: string, source: string);
|
|
10
|
+
extract(): ExtractionResult;
|
|
11
|
+
private createComponentNode;
|
|
12
|
+
/** Last `.`-segment (`App.ViewModels.RegisterModel` → `RegisterModel`). */
|
|
13
|
+
private lastSegment;
|
|
14
|
+
/**
|
|
15
|
+
* Split a type expression into the capitalized type names it contains — base
|
|
16
|
+
* type plus any generic arguments (`Bar<Foo, Baz>` → `Bar`, `Foo`, `Baz`),
|
|
17
|
+
* each reduced to its last namespace segment. Lowercase/keyword tokens drop out.
|
|
18
|
+
*/
|
|
19
|
+
private typeNames;
|
|
20
|
+
private pushRef;
|
|
21
|
+
private extractDirectives;
|
|
22
|
+
private extractComponentTags;
|
|
23
|
+
/**
|
|
24
|
+
* Find the matching `}` for the `{` at `openIdx`, skipping string literals and
|
|
25
|
+
* comments so a brace inside `"{"` / `// }` doesn't throw off the count.
|
|
26
|
+
* Returns the index of the closing brace, or -1 if unbalanced.
|
|
27
|
+
*/
|
|
28
|
+
private matchBrace;
|
|
29
|
+
/** `@code { … }` / `@functions { … }` (Blazor) and `@{ … }` (Razor) C# blocks. */
|
|
30
|
+
private extractCodeBlocks;
|
|
31
|
+
/**
|
|
32
|
+
* Delegate each `@code`/`@functions`/`@{` block's C# to the tree-sitter C#
|
|
33
|
+
* extractor and attribute the block's external references (service/DTO calls,
|
|
34
|
+
* `new X()`, type uses) to the component. The block is wrapped in a synthetic
|
|
35
|
+
* class so tree-sitter parses the component's fields/methods in a class context
|
|
36
|
+
* (a Blazor `@code` body compiles into the component's partial class). We keep
|
|
37
|
+
* only the dependency references — coverage just needs the edges to external
|
|
38
|
+
* types, not per-member nodes. Degrades gracefully if the C# grammar isn't loaded.
|
|
39
|
+
*/
|
|
40
|
+
private processCodeBlocks;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=razor-extractor.d.ts.map
|
|
@@ -69,6 +69,15 @@ export interface ExtractorContext {
|
|
|
69
69
|
* language-specific details like signatures, visibility, and imports.
|
|
70
70
|
*/
|
|
71
71
|
export interface LanguageExtractor {
|
|
72
|
+
/**
|
|
73
|
+
* Optional source transform applied immediately before the grammar parses the
|
|
74
|
+
* file. Used to work around grammar gaps that would otherwise corrupt the
|
|
75
|
+
* parse tree (e.g. C# blanks conditional-compilation directive lines the
|
|
76
|
+
* grammar mis-parses inside enum bodies). MUST preserve byte offsets (replace
|
|
77
|
+
* removed text with spaces, keep newlines) so node positions and getNodeText
|
|
78
|
+
* stay correct; the returned string is used for both parsing and extraction.
|
|
79
|
+
*/
|
|
80
|
+
preParse?: (source: string) => string;
|
|
72
81
|
/** Node types that represent functions */
|
|
73
82
|
functionTypes: string[];
|
|
74
83
|
/** Node types that represent classes */
|
|
@@ -119,6 +128,14 @@ export interface LanguageExtractor {
|
|
|
119
128
|
isStatic?: (node: SyntaxNode) => boolean;
|
|
120
129
|
/** Check if variable declaration is a constant (const vs let/var) */
|
|
121
130
|
isConst?: (node: SyntaxNode) => boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Extract extra symbol-level modifier keywords to persist on the node's
|
|
133
|
+
* `decorators` list (e.g. Kotlin `expect`/`actual` multiplatform markers).
|
|
134
|
+
* Called generically for every created node; return undefined/[] when none.
|
|
135
|
+
* Used by the resolver to link `expect` declarations to their `actual`
|
|
136
|
+
* implementations across source sets.
|
|
137
|
+
*/
|
|
138
|
+
extractModifiers?: (node: SyntaxNode) => string[] | undefined;
|
|
122
139
|
/** Additional node types to treat as class declarations (e.g. Dart: 'mixin_declaration') */
|
|
123
140
|
extraClassNodeTypes?: string[];
|
|
124
141
|
/** Whether methods can be top-level without enclosing class (Go: true) */
|
|
@@ -135,6 +152,14 @@ export interface LanguageExtractor {
|
|
|
135
152
|
* for multiple concepts (e.g. Swift uses class_declaration for classes, structs, and enums).
|
|
136
153
|
*/
|
|
137
154
|
classifyClassNode?: (node: SyntaxNode) => 'class' | 'struct' | 'enum' | 'interface' | 'trait';
|
|
155
|
+
/**
|
|
156
|
+
* Classify a methodTypes node when the grammar reuses one node type for
|
|
157
|
+
* both callable and data members (#808): TS/JS class FIELDS
|
|
158
|
+
* (`public_field_definition` / `field_definition`) are methods only when
|
|
159
|
+
* their value is callable (`onClick = () => {}`); a plain field
|
|
160
|
+
* (`public fonts: Fonts;`, `count = 0`) is a property. Default: 'method'.
|
|
161
|
+
*/
|
|
162
|
+
classifyMethodNode?: (node: SyntaxNode) => 'method' | 'property';
|
|
138
163
|
/**
|
|
139
164
|
* Resolve the body node for a function/method/class when it's not a child field.
|
|
140
165
|
* (e.g. Dart puts function_body as a sibling, not a child.)
|
|
@@ -156,6 +181,14 @@ export interface LanguageExtractor {
|
|
|
156
181
|
* When present, the receiver type is included in the qualified name for better searchability.
|
|
157
182
|
*/
|
|
158
183
|
getReceiverType?: (node: SyntaxNode, source: string) => string | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Extract a function/method's normalized return type name (bare class name,
|
|
186
|
+
* smart-pointer pointee unwrapped), stored on the node as `returnType`. Used
|
|
187
|
+
* by C/C++ so resolution can infer a chained receiver's type from what the
|
|
188
|
+
* inner call returns (`Foo::instance().bar()` → resolve `bar` on `Foo`,
|
|
189
|
+
* issue #645). Return undefined for primitives / void / constructors.
|
|
190
|
+
*/
|
|
191
|
+
getReturnType?: (node: SyntaxNode, source: string) => string | undefined;
|
|
159
192
|
/**
|
|
160
193
|
* Resolve the actual node kind for a type alias declaration.
|
|
161
194
|
* Used by Go where `type_spec` is the named declaration wrapper for structs/interfaces:
|
|
@@ -20,11 +20,45 @@ export declare class TreeSitterExtractor {
|
|
|
20
20
|
private extractor;
|
|
21
21
|
private nodeStack;
|
|
22
22
|
private methodIndex;
|
|
23
|
+
private fnRefSpec;
|
|
24
|
+
private fnRefCandidates;
|
|
23
25
|
constructor(filePath: string, source: string, language?: Language);
|
|
24
26
|
/**
|
|
25
27
|
* Parse and extract from the source code
|
|
26
28
|
*/
|
|
27
29
|
extract(): ExtractionResult;
|
|
30
|
+
/**
|
|
31
|
+
* Function-as-value capture (#756): if this node is one of the language's
|
|
32
|
+
* value-position containers (call arguments, assignment RHS, struct/object
|
|
33
|
+
* initializer, array/table literal), collect candidate function names from
|
|
34
|
+
* it. Candidates are gated & flushed at end-of-file (flushFnRefCandidates).
|
|
35
|
+
*/
|
|
36
|
+
private maybeCaptureFnRefs;
|
|
37
|
+
/**
|
|
38
|
+
* Candidates-only scan of a subtree the main walkers won't traverse
|
|
39
|
+
* (top-level variable initializers). No extraction side effects. Halts at
|
|
40
|
+
* nested function definitions: their bodies are walked — and their
|
|
41
|
+
* candidates attributed — by extractFunction's own body walk.
|
|
42
|
+
*/
|
|
43
|
+
private scanFnRefSubtree;
|
|
44
|
+
/**
|
|
45
|
+
* Gate captured function-as-value candidates and push survivors as
|
|
46
|
+
* `function_ref` unresolved references.
|
|
47
|
+
*
|
|
48
|
+
* The gate bounds volume and protects precision: a candidate survives only
|
|
49
|
+
* if its name matches a function/method DEFINED IN THIS FILE or a name this
|
|
50
|
+
* file imports/references. Everything else (locals, params, fields passed
|
|
51
|
+
* as arguments) is dropped before it ever reaches the database. Resolution
|
|
52
|
+
* then matches survivors against function/method nodes only
|
|
53
|
+
* (matchFunctionRef) and emits `references` edges — which callers/impact
|
|
54
|
+
* already traverse.
|
|
55
|
+
*
|
|
56
|
+
* Known v1 limit, deliberate: a C/C++ callback registered in a DIFFERENT
|
|
57
|
+
* translation unit than its definition (extern, no symbol imports to match)
|
|
58
|
+
* is not captured. Same-file registration — the dominant C pattern (static
|
|
59
|
+
* callback + same-file ops struct) — is.
|
|
60
|
+
*/
|
|
61
|
+
private flushFnRefCandidates;
|
|
28
62
|
/**
|
|
29
63
|
* Visit a node and extract information
|
|
30
64
|
*/
|
|
@@ -137,6 +171,14 @@ export declare class TreeSitterExtractor {
|
|
|
137
171
|
* Returns true if children should be skipped (struct/interface handled body visiting).
|
|
138
172
|
*/
|
|
139
173
|
private extractTypeAlias;
|
|
174
|
+
/**
|
|
175
|
+
* Extract the method specs of a Go `interface_type` body as `method` nodes
|
|
176
|
+
* contained by the interface (e.g. `Marshal`, `Unmarshal` of a `Core`
|
|
177
|
+
* interface). tree-sitter-go names these `method_elem` (newer) or
|
|
178
|
+
* `method_spec` (older). Embedded interfaces (`Reader` inside `ReadWriter`)
|
|
179
|
+
* are `type_identifier`s, not methods, and are left to inheritance extraction.
|
|
180
|
+
*/
|
|
181
|
+
private extractGoInterfaceMethods;
|
|
140
182
|
/**
|
|
141
183
|
* Surface the members of a TypeScript `type X = { ... }` (or intersection
|
|
142
184
|
* thereof) as `property` / `method` nodes under the type-alias node. Only
|
|
@@ -145,6 +187,34 @@ export declare class TreeSitterExtractor {
|
|
|
145
187
|
* don't produce phantom members.
|
|
146
188
|
*/
|
|
147
189
|
private extractTsTypeAliasMembers;
|
|
190
|
+
/**
|
|
191
|
+
* Surface the string-literal "names" of a TypeScript service/contract
|
|
192
|
+
* registry written as a tuple of generic instantiations:
|
|
193
|
+
*
|
|
194
|
+
* type MyServiceList = [
|
|
195
|
+
* Service<'query_apply_record', Req, Resp>,
|
|
196
|
+
* Service<'apply_confirm', Req, Resp>,
|
|
197
|
+
* ];
|
|
198
|
+
*
|
|
199
|
+
* Each `Service<'name', …>` tags an entry with a string-literal name that a
|
|
200
|
+
* dynamic factory (`createService<MyServiceList>()`) turns into a callable
|
|
201
|
+
* property (`api.query_apply_record(…)`). Static extraction otherwise never
|
|
202
|
+
* sees that name — it's a type argument, not a declaration — so
|
|
203
|
+
* `codegraph query query_apply_record` returned nothing (issue #634). We emit
|
|
204
|
+
* each name as a `method` node under the type alias (qualifiedName
|
|
205
|
+
* `MyServiceList::query_apply_record`) so it's searchable and resolvable as a
|
|
206
|
+
* symbol. (A call through the proxy, `api.query_apply_record(…)`, still
|
|
207
|
+
* resolves to the imported `api` binding — the receiver's type isn't known —
|
|
208
|
+
* so this fixes discoverability, not the per-method call edge.)
|
|
209
|
+
*
|
|
210
|
+
* Scope is deliberately narrow to avoid noise: only a string literal that is
|
|
211
|
+
* a DIRECT type argument of a `generic_type` that is itself a DIRECT element
|
|
212
|
+
* of a `tuple_type`. This excludes utility types (`Pick`/`Omit`/`Record` are
|
|
213
|
+
* never written as tuples) and string args nested deeper
|
|
214
|
+
* (`Service<'a', Pick<U, 'id'>>` yields only `a`, never `id`). Names must be
|
|
215
|
+
* valid identifiers, which also rules out route paths / arbitrary strings.
|
|
216
|
+
*/
|
|
217
|
+
private extractTsTupleContractNames;
|
|
148
218
|
/**
|
|
149
219
|
* `foo: () => T` → property_signature whose type_annotation contains a
|
|
150
220
|
* `function_type`. Treat that as a method-shaped contract member, since
|
|
@@ -158,6 +228,83 @@ export declare class TreeSitterExtractor {
|
|
|
158
228
|
* Also creates unresolved references for resolution purposes.
|
|
159
229
|
*/
|
|
160
230
|
private extractImport;
|
|
231
|
+
/**
|
|
232
|
+
* Emit one `imports` reference per named/default import binding (TS/JS family),
|
|
233
|
+
* attributed to the file node — so the resolver links each imported symbol to
|
|
234
|
+
* the file that DEFINES it.
|
|
235
|
+
*
|
|
236
|
+
* Importing a symbol IS a dependency, but extraction only emits references for
|
|
237
|
+
* calls, instantiations, type annotations, and inheritance. A symbol that's
|
|
238
|
+
* imported and then only re-exported (`export { X } from './x'`), placed in a
|
|
239
|
+
* registry array (`[expressResolver, …]`), passed as an argument, or used in
|
|
240
|
+
* JSX produced NO cross-file edge at all — so the providing file showed a
|
|
241
|
+
* false "0 dependents" and was invisible to blast-radius / `affected`. The
|
|
242
|
+
* resolver maps the local name (alias-aware) to the provider's definition and
|
|
243
|
+
* creates a cross-file `imports` edge; `getFileDependents` picks it up, while
|
|
244
|
+
* `getImpactRadius` keeps it as a bounded leaf (the importing file node).
|
|
245
|
+
*
|
|
246
|
+
* Namespace imports (`import * as NS`) bind a whole module: `NS.member` calls
|
|
247
|
+
* resolve on their own, but a namespace used ONLY via a value-member read
|
|
248
|
+
* (`NS.SOME_CONST`) would leave no edge — so we also emit the namespace local
|
|
249
|
+
* name, which the resolver links to the module FILE as a dependency backstop.
|
|
250
|
+
*/
|
|
251
|
+
private emitImportBindingRefs;
|
|
252
|
+
/**
|
|
253
|
+
* Emit one `imports` reference per re-exported binding of a
|
|
254
|
+
* `export { A, B as C } from './y'` statement, attributed to the file node —
|
|
255
|
+
* so a barrel that re-exports from another module records a dependency on it.
|
|
256
|
+
*
|
|
257
|
+
* Links the SOURCE-side name (`A`, the `name` field — not the local alias
|
|
258
|
+
* `C`), since that is what the source module defines. `export * from './y'`
|
|
259
|
+
* has no named bindings to attribute and `export { default as X }` can't be
|
|
260
|
+
* name-matched, so both are skipped.
|
|
261
|
+
*/
|
|
262
|
+
private emitReExportRefs;
|
|
263
|
+
/**
|
|
264
|
+
* Emit one `imports` reference per binding of a Rust `use` declaration —
|
|
265
|
+
* `use crate::m::Item`, `use crate::m::{A, B as C}`, `pub use self::sub::Item`.
|
|
266
|
+
* Emits the FULL path (e.g. `self::sub::Item`, not just `Item`) so the resolver
|
|
267
|
+
* can resolve the module prefix to a file and find the leaf symbol there —
|
|
268
|
+
* disambiguating common-name re-exports (`pub use self::read::read`, where the
|
|
269
|
+
* leaf `read` collides with many same-named symbols). Falls back to name-match
|
|
270
|
+
* on the leaf when the path can't be resolved. `use ...::*` has no leaf binding.
|
|
271
|
+
*/
|
|
272
|
+
private emitRustUseBindingRefs;
|
|
273
|
+
/**
|
|
274
|
+
* Emit an `imports` reference for a single PHP `use Foo\Bar\Baz;` (grouped
|
|
275
|
+
* imports `use Foo\{A, B}` are handled where their per-item nodes are created).
|
|
276
|
+
* The reference targets the namespace-qualified `Foo\Bar::Baz` form classes are
|
|
277
|
+
* stored under (see the PHP `namespace` capture), so it resolves to the RIGHT
|
|
278
|
+
* definition — Laravel has many same-named contracts (`Factory`, `Dispatcher`,
|
|
279
|
+
* `Guard`) across namespaces that a bare-name match can't disambiguate.
|
|
280
|
+
*/
|
|
281
|
+
private emitPhpUseRefs;
|
|
282
|
+
/**
|
|
283
|
+
* Ruby `require`/`require_relative` → an `imports` ref to the required FILE.
|
|
284
|
+
* `require "sidekiq/fetch"` is load-path-relative (matched by file-path suffix
|
|
285
|
+
* via {@link matchByFilePath}); `require_relative "../foo"` is resolved against
|
|
286
|
+
* this file's directory. Bare gem/stdlib requires (`require "json"`, no slash)
|
|
287
|
+
* are skipped — they're external. The path form (a `/` + `.rb`) makes the ref
|
|
288
|
+
* resolve to the file node, so a file pulled in only by `require` — not by a
|
|
289
|
+
* resolved constant/call — still records a cross-file dependency.
|
|
290
|
+
*/
|
|
291
|
+
private emitRubyRequireRefs;
|
|
292
|
+
/** Convert a PHP FQN `Foo\Bar\Baz` to the stored `Foo\Bar::Baz` and emit an `imports` ref. */
|
|
293
|
+
private pushPhpUseRef;
|
|
294
|
+
/**
|
|
295
|
+
* Emit one `imports` reference per name imported in a Python
|
|
296
|
+
* `from module import A, B as C` statement, attributed to the file node — so
|
|
297
|
+
* the resolver links each imported name to the module that DEFINES it.
|
|
298
|
+
*
|
|
299
|
+
* Same recall gap as TS: extraction only emitted references for calls,
|
|
300
|
+
* instantiations, and inheritance, so a name imported and then used in a
|
|
301
|
+
* non-call position (a list/dict literal, a default argument, a decorator
|
|
302
|
+
* target, or simply re-exported through an `__init__.py` barrel) produced no
|
|
303
|
+
* cross-file edge — the providing module showed a false "0 dependents". Links
|
|
304
|
+
* the LOCAL name (alias when present, since that's what the resolver's import
|
|
305
|
+
* mapping keys on); `from module import *` has no names to attribute.
|
|
306
|
+
*/
|
|
307
|
+
private emitPyFromImportRefs;
|
|
161
308
|
/**
|
|
162
309
|
* Extract a function call
|
|
163
310
|
*/
|
|
@@ -172,6 +319,18 @@ export declare class TreeSitterExtractor {
|
|
|
172
319
|
* arguments (`new Foo(bar())`) get their own `calls` references.
|
|
173
320
|
*/
|
|
174
321
|
private extractInstantiation;
|
|
322
|
+
/**
|
|
323
|
+
* Static-member / value-read pass. A type/enum/class used only via a member
|
|
324
|
+
* VALUE — `Enum.value`, `Type.CONST`, `Colors.red`, `Foo::BAR` — recorded no
|
|
325
|
+
* edge, because the body walker only handled CALLS (`Type.method()`). So a
|
|
326
|
+
* type referenced only by an enum value or a static field looked like nothing
|
|
327
|
+
* depended on it (the residual frontier across Dart/Java/C#/Swift/Kotlin/PHP).
|
|
328
|
+
* Emit a `references` edge to the capitalized receiver. Gated to languages
|
|
329
|
+
* where types are Capitalized by convention, and skipped when the access is a
|
|
330
|
+
* call's callee (the call extractor already links the method).
|
|
331
|
+
*/
|
|
332
|
+
private extractStaticMemberRef;
|
|
333
|
+
private pushStaticMemberRef;
|
|
175
334
|
/**
|
|
176
335
|
* Find a `class_body` child of an `object_creation_expression` — the
|
|
177
336
|
* marker for an anonymous class (`new T() { ... }`). Returns the body
|
|
@@ -216,6 +375,19 @@ export declare class TreeSitterExtractor {
|
|
|
216
375
|
* tree-sitter to interpret the namespace block as a function_definition,
|
|
217
376
|
* hiding real class/struct/enum nodes inside the "function body".
|
|
218
377
|
*/
|
|
378
|
+
/**
|
|
379
|
+
* Rocket route-registration macros — `routes![a::b::handler, c::d::other]`
|
|
380
|
+
* and `catchers![not_found]`. Tree-sitter leaves a macro body as a flat
|
|
381
|
+
* `token_tree` of raw tokens (`identifier`, `::`, `,`), so the handler paths
|
|
382
|
+
* are never seen as references and each handler fn looks like it has no caller
|
|
383
|
+
* — it's mounted by Rocket at runtime, not called by in-repo code, so its file
|
|
384
|
+
* shows 0 dependents. Walk the token tree, reconstruct each comma-separated
|
|
385
|
+
* path, and emit a `references` edge; the Rust path resolver
|
|
386
|
+
* (`resolveRustPathReference`) then links it to the handler fn. The handler
|
|
387
|
+
* names are explicit in source, so this is precise static extraction, not a
|
|
388
|
+
* heuristic — no false edges (resolution still validates each path).
|
|
389
|
+
*/
|
|
390
|
+
private extractRustRouteMacro;
|
|
219
391
|
private visitFunctionBody;
|
|
220
392
|
/**
|
|
221
393
|
* Extract inheritance relationships
|
|
@@ -234,6 +406,11 @@ export declare class TreeSitterExtractor {
|
|
|
234
406
|
* Languages that support type annotations (TypeScript, etc.)
|
|
235
407
|
*/
|
|
236
408
|
private readonly TYPE_ANNOTATION_LANGUAGES;
|
|
409
|
+
/**
|
|
410
|
+
* PHP pseudo-types and `self`/`static`/`parent` that aren't project symbols.
|
|
411
|
+
* (Scalar primitives parse as `primitive_type` and are skipped structurally.)
|
|
412
|
+
*/
|
|
413
|
+
private readonly PHP_PSEUDO_TYPES;
|
|
237
414
|
/**
|
|
238
415
|
* Built-in/primitive type names that shouldn't create references
|
|
239
416
|
*/
|
|
@@ -256,12 +433,35 @@ export declare class TreeSitterExtractor {
|
|
|
256
433
|
* `tuple_type`, …) — none of which are `type_identifier`. Closes #381.
|
|
257
434
|
*/
|
|
258
435
|
private extractCsharpTypeRefs;
|
|
436
|
+
/**
|
|
437
|
+
* Record the dependencies declared by a C# PRIMARY CONSTRUCTOR
|
|
438
|
+
* (`class Svc(IRepo repo, [FromKeyedServices("k")] ICache cache) { … }`,
|
|
439
|
+
* C# 12+). The parameter list hangs off the class/struct/record declaration
|
|
440
|
+
* as an unnamed-field `parameter_list` child (not the `parameters` field a
|
|
441
|
+
* method uses), so it's found by node type. Each parameter's declared type
|
|
442
|
+
* becomes a `references` edge from the owning type — these are exactly the
|
|
443
|
+
* services a DI-registered type depends on, so impact/blast-radius and
|
|
444
|
+
* "who depends on this contract" now see them. No-op when there's no primary
|
|
445
|
+
* constructor. (#237)
|
|
446
|
+
*/
|
|
447
|
+
private extractCsharpPrimaryCtorParamRefs;
|
|
259
448
|
/**
|
|
260
449
|
* Walk a C# subtree that is KNOWN to be in a type position
|
|
261
450
|
* (return type, parameter type, property type, field type, generic
|
|
262
451
|
* argument). Identifiers here are type names, not parameter names.
|
|
263
452
|
*/
|
|
264
453
|
private walkCsharpTypePosition;
|
|
454
|
+
/**
|
|
455
|
+
* Extract PHP type references from a method/function/property declaration.
|
|
456
|
+
* Walks ONLY type positions: each parameter's type child (inside
|
|
457
|
+
* `formal_parameters`), the return type, and a property's type — all
|
|
458
|
+
* `named_type` / `optional_type` / `union_type` / … direct children. Parameter
|
|
459
|
+
* and property NAMES are `variable_name` (`$x`), never type nodes, so they
|
|
460
|
+
* can't be mis-emitted.
|
|
461
|
+
*/
|
|
462
|
+
private extractPhpTypeRefs;
|
|
463
|
+
/** Walk a PHP subtree KNOWN to be in a type position; emit class/interface refs. */
|
|
464
|
+
private walkPhpTypePosition;
|
|
265
465
|
/**
|
|
266
466
|
* Extract type references from a variable's type annotation.
|
|
267
467
|
*/
|
|
@@ -301,6 +501,17 @@ export declare class TreeSitterExtractor {
|
|
|
301
501
|
* Extract function calls from a Pascal expression
|
|
302
502
|
*/
|
|
303
503
|
private extractPascalCall;
|
|
504
|
+
/**
|
|
505
|
+
* Extract a PAREN-LESS Pascal method/procedure call (`Obj.Method;`,
|
|
506
|
+
* `TFoo.GetInstance.DoIt;`). Pascal lets a no-arg method drop its parens, so it
|
|
507
|
+
* parses as a bare `exprDot` (not an `exprCall`). A bare `exprDot` is
|
|
508
|
+
* syntactically identical to a field/property access, so this is only ever
|
|
509
|
+
* called for a STATEMENT-level exprDot (caller-gated): a bare `Obj.Field;`
|
|
510
|
+
* statement is a no-op, so a statement-level dot expression is a call. (An
|
|
511
|
+
* exprDot in assignment LHS/RHS or a condition is left alone — there it really
|
|
512
|
+
* can be a field/property read.)
|
|
513
|
+
*/
|
|
514
|
+
private extractPascalParenlessCall;
|
|
304
515
|
/**
|
|
305
516
|
* Recursively visit a Pascal block/statement tree for call expressions
|
|
306
517
|
*/
|
|
@@ -32,5 +32,20 @@ export declare class VueExtractor {
|
|
|
32
32
|
* Process a script block by delegating to TreeSitterExtractor
|
|
33
33
|
*/
|
|
34
34
|
private processScriptBlock;
|
|
35
|
+
/**
|
|
36
|
+
* Extract component usages from the Vue `<template>`.
|
|
37
|
+
*
|
|
38
|
+
* PascalCase tags (`<Modal>`, `<Button />`) and kebab-case tags
|
|
39
|
+
* (`<my-button>`) both represent component instantiations — analogous to
|
|
40
|
+
* function calls in imperative code. Capturing them creates parent→child
|
|
41
|
+
* component edges and lets `callers` / `impact` see a component that is
|
|
42
|
+
* only ever used in markup. Vue's extractor previously parsed only the
|
|
43
|
+
* `<script>` block, so these usages produced no edge at all (#629).
|
|
44
|
+
*
|
|
45
|
+
* HTML elements (lowercase, no hyphen) and Vue built-ins are skipped.
|
|
46
|
+
* Unmatched names create no edge during resolution, so converting
|
|
47
|
+
* kebab-case is safe even for native custom elements.
|
|
48
|
+
*/
|
|
49
|
+
private extractTemplateComponents;
|
|
35
50
|
}
|
|
36
51
|
//# sourceMappingURL=vue-extractor.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -158,8 +158,8 @@ export declare class CodeGraph {
|
|
|
158
158
|
*/
|
|
159
159
|
getPendingFiles(): PendingFile[];
|
|
160
160
|
/**
|
|
161
|
-
* Resolves once the file watcher has
|
|
162
|
-
*
|
|
161
|
+
* Resolves once the file watcher has installed its watch set. Useful for
|
|
162
|
+
* tests that need a deterministic boundary before asserting on
|
|
163
163
|
* `getPendingFiles()`. Resolves immediately when no watcher is active.
|
|
164
164
|
*/
|
|
165
165
|
waitUntilWatcherReady(timeoutMs?: number): Promise<void>;
|
|
@@ -171,6 +171,30 @@ export declare class CodeGraph {
|
|
|
171
171
|
modified: string[];
|
|
172
172
|
removed: string[];
|
|
173
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Most recent index timestamp (ms since epoch) across all tracked files, or
|
|
176
|
+
* null when nothing is indexed yet. Lets library consumers check index
|
|
177
|
+
* freshness without shelling out to `codegraph status --json`. (#329)
|
|
178
|
+
*/
|
|
179
|
+
getLastIndexedAt(): number | null;
|
|
180
|
+
/**
|
|
181
|
+
* Which engine built the current index: the package version + extraction
|
|
182
|
+
* version stamped at the last full `indexAll`. Either field is null for an
|
|
183
|
+
* index built before stamping existed (treated as stale). See
|
|
184
|
+
* `extraction-version.ts` and `isIndexStale()`.
|
|
185
|
+
*/
|
|
186
|
+
getIndexBuildInfo(): {
|
|
187
|
+
version: string | null;
|
|
188
|
+
extractionVersion: number | null;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* True when the on-disk index was built by an engine whose extraction is
|
|
192
|
+
* older than the one now running — i.e. a re-index would add data a migration
|
|
193
|
+
* can't backfill. False when there's no index yet (nothing to refresh) or the
|
|
194
|
+
* stamp is current. This is the signal behind `codegraph status`'s re-index
|
|
195
|
+
* hint and `codegraph upgrade`'s reminder.
|
|
196
|
+
*/
|
|
197
|
+
isIndexStale(): boolean;
|
|
174
198
|
/**
|
|
175
199
|
* Extract nodes and edges from source code (without storing)
|
|
176
200
|
*/
|
|
@@ -237,6 +261,14 @@ export declare class CodeGraph {
|
|
|
237
261
|
* Search nodes by text
|
|
238
262
|
*/
|
|
239
263
|
searchNodes(query: string, options?: SearchOptions): SearchResult[];
|
|
264
|
+
/**
|
|
265
|
+
* Normalized project-name tokens (go.mod / package.json / repo dir) used to
|
|
266
|
+
* down-weight the non-discriminative project name in search ranking (#720).
|
|
267
|
+
* Exposed so explore can exclude it from the PascalCase type-disambiguation
|
|
268
|
+
* bias, which would otherwise pull overloaded tokens toward whichever stack
|
|
269
|
+
* embeds the project name.
|
|
270
|
+
*/
|
|
271
|
+
getProjectNameTokens(): Set<string>;
|
|
240
272
|
/**
|
|
241
273
|
* Find the project's "primary route file" — the file with the densest
|
|
242
274
|
* concentration of framework-emitted `route` nodes (≥3 routes, ≥30%
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The marker-fenced agent-instructions block the installer writes into each
|
|
3
|
+
* agent's instructions file (CLAUDE.md / AGENTS.md / GEMINI.md).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `mcp/server-instructions.ts` are the single source of truth.
|
|
5
|
+
* History: pre-#529 the installer wrote a full usage playbook here, which
|
|
6
|
+
* duplicated the MCP `initialize` instructions for the main agent — so it
|
|
7
|
+
* was removed and `mcp/server-instructions.ts` became the single source of
|
|
8
|
+
* truth. A much smaller block returned for #704, because the MCP
|
|
9
|
+
* instructions cannot reach two audiences that the instructions FILE does
|
|
10
|
+
* reach:
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* - **Task-tool subagents** — they receive the project instructions file
|
|
13
|
+
* in their context but NOT the MCP initialize instructions. They hold
|
|
14
|
+
* the codegraph MCP tools only as deferred names and rarely think to
|
|
15
|
+
* load them: measured on a forced-delegation flow question (excalidraw,
|
|
16
|
+
* sonnet, high effort), subagents loaded + used codegraph in ~1 of 9
|
|
17
|
+
* runs without this block, and consistently with it — including runs
|
|
18
|
+
* with zero Read/grep fallback.
|
|
19
|
+
* - **Non-MCP harnesses** — agents with no MCP client at all can still
|
|
20
|
+
* run the `codegraph explore` / `codegraph node` CLI, which prints the
|
|
21
|
+
* same output as the MCP tools.
|
|
22
|
+
*
|
|
23
|
+
* Keep this block SHORT. The main agent reads it every turn on top of the
|
|
24
|
+
* server instructions — the #529 duplication-cost argument still bounds
|
|
25
|
+
* its size. Command names and the two surfaces, nothing more.
|
|
14
26
|
*/
|
|
15
|
-
/** Markers used by the marker-based section removal. */
|
|
27
|
+
/** Markers used by the marker-based section write/removal. */
|
|
16
28
|
export declare const CODEGRAPH_SECTION_START = "<!-- CODEGRAPH_START -->";
|
|
17
29
|
export declare const CODEGRAPH_SECTION_END = "<!-- CODEGRAPH_END -->";
|
|
30
|
+
/**
|
|
31
|
+
* The full block, markers included, exactly as written to disk.
|
|
32
|
+
*
|
|
33
|
+
* The wording is deliberately CONDITIONAL ("in repositories indexed by…"):
|
|
34
|
+
* a global install writes this into a user-scope file (~/.claude/CLAUDE.md,
|
|
35
|
+
* ~/.codex/AGENTS.md) that applies to every project the user opens —
|
|
36
|
+
* including unindexed ones, where an unconditional "this repository is
|
|
37
|
+
* indexed" claim would send subagents into failing codegraph calls (the
|
|
38
|
+
* noise the unindexed-session policy exists to prevent).
|
|
39
|
+
*/
|
|
40
|
+
export declare const CODEGRAPH_INSTRUCTIONS_BLOCK = "<!-- CODEGRAPH_START -->\n## CodeGraph\n\nIn repositories indexed by CodeGraph (a `.codegraph/` directory exists at the repo root), reach for it BEFORE grep/find or reading files when you need to understand or locate code:\n\n- **MCP tools** (when available): `codegraph_explore` answers most code questions in one call \u2014 the relevant symbols' verbatim source plus the call paths between them. `codegraph_node` returns one symbol's source + callers, or reads a whole file with line numbers. If the tools are listed but deferred, load them by name via tool search.\n- **Shell** (always works): `codegraph explore \"<symbol names or question>\"` and `codegraph node <symbol-or-file>` print the same output.\n\nIf there is no `.codegraph/` directory, skip CodeGraph entirely \u2014 indexing is the user's decision.\n<!-- CODEGRAPH_END -->";
|
|
18
41
|
//# sourceMappingURL=instructions-template.d.ts.map
|