@colbymchenry/codegraph 0.9.6 → 0.9.8

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.
Files changed (119) hide show
  1. package/README.md +122 -57
  2. package/dist/bin/codegraph.d.ts +25 -0
  3. package/dist/bin/node-version-check.d.ts +37 -0
  4. package/dist/bin/uninstall.d.ts +14 -0
  5. package/dist/context/formatter.d.ts +30 -0
  6. package/dist/context/index.d.ts +110 -0
  7. package/dist/db/index.d.ts +101 -0
  8. package/dist/db/migrations.d.ts +44 -0
  9. package/dist/db/queries.d.ts +344 -0
  10. package/dist/db/sqlite-adapter.d.ts +46 -0
  11. package/dist/directory.d.ts +57 -0
  12. package/dist/errors.d.ts +136 -0
  13. package/dist/extraction/dfm-extractor.d.ts +31 -0
  14. package/dist/extraction/generated-detection.d.ts +30 -0
  15. package/dist/extraction/grammars.d.ts +100 -0
  16. package/dist/extraction/index.d.ts +138 -0
  17. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  18. package/dist/extraction/languages/csharp.d.ts +3 -0
  19. package/dist/extraction/languages/dart.d.ts +3 -0
  20. package/dist/extraction/languages/go.d.ts +3 -0
  21. package/dist/extraction/languages/index.d.ts +10 -0
  22. package/dist/extraction/languages/java.d.ts +3 -0
  23. package/dist/extraction/languages/javascript.d.ts +3 -0
  24. package/dist/extraction/languages/kotlin.d.ts +3 -0
  25. package/dist/extraction/languages/lua.d.ts +3 -0
  26. package/dist/extraction/languages/luau.d.ts +3 -0
  27. package/dist/extraction/languages/objc.d.ts +3 -0
  28. package/dist/extraction/languages/pascal.d.ts +3 -0
  29. package/dist/extraction/languages/php.d.ts +3 -0
  30. package/dist/extraction/languages/python.d.ts +3 -0
  31. package/dist/extraction/languages/ruby.d.ts +3 -0
  32. package/dist/extraction/languages/rust.d.ts +3 -0
  33. package/dist/extraction/languages/scala.d.ts +3 -0
  34. package/dist/extraction/languages/swift.d.ts +3 -0
  35. package/dist/extraction/languages/typescript.d.ts +3 -0
  36. package/dist/extraction/liquid-extractor.d.ts +52 -0
  37. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  38. package/dist/extraction/parse-worker.d.ts +8 -0
  39. package/dist/extraction/svelte-extractor.d.ts +56 -0
  40. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  41. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  42. package/dist/extraction/tree-sitter.d.ts +291 -0
  43. package/dist/extraction/vue-extractor.d.ts +36 -0
  44. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  45. package/dist/graph/index.d.ts +8 -0
  46. package/dist/graph/queries.d.ts +106 -0
  47. package/dist/graph/traversal.d.ts +127 -0
  48. package/dist/index.d.ts +492 -0
  49. package/dist/installer/config-writer.d.ts +28 -0
  50. package/dist/installer/index.d.ts +100 -0
  51. package/dist/installer/instructions-template.d.ts +18 -0
  52. package/dist/installer/targets/antigravity.d.ts +57 -0
  53. package/dist/installer/targets/claude.d.ts +56 -0
  54. package/dist/installer/targets/codex.d.ts +18 -0
  55. package/dist/installer/targets/cursor.d.ts +35 -0
  56. package/dist/installer/targets/gemini.d.ts +26 -0
  57. package/dist/installer/targets/hermes.d.ts +18 -0
  58. package/dist/installer/targets/kiro.d.ts +27 -0
  59. package/dist/installer/targets/opencode.d.ts +30 -0
  60. package/dist/installer/targets/registry.d.ts +35 -0
  61. package/dist/installer/targets/shared.d.ts +77 -0
  62. package/dist/installer/targets/toml.d.ts +52 -0
  63. package/dist/installer/targets/types.d.ts +101 -0
  64. package/dist/mcp/daemon-paths.d.ts +46 -0
  65. package/dist/mcp/daemon.d.ts +161 -0
  66. package/dist/mcp/engine.d.ts +105 -0
  67. package/dist/mcp/index.d.ts +112 -0
  68. package/dist/mcp/proxy.d.ts +81 -0
  69. package/dist/mcp/server-instructions.d.ts +19 -0
  70. package/dist/mcp/session.d.ts +77 -0
  71. package/dist/mcp/tools.d.ts +423 -0
  72. package/dist/mcp/transport.d.ts +188 -0
  73. package/dist/mcp/version.d.ts +19 -0
  74. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  75. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  76. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  77. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  78. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  79. package/dist/resolution/frameworks/express.d.ts +8 -0
  80. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  81. package/dist/resolution/frameworks/go.d.ts +8 -0
  82. package/dist/resolution/frameworks/index.d.ts +48 -0
  83. package/dist/resolution/frameworks/java.d.ts +8 -0
  84. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  85. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  86. package/dist/resolution/frameworks/play.d.ts +19 -0
  87. package/dist/resolution/frameworks/python.d.ts +10 -0
  88. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  89. package/dist/resolution/frameworks/react.d.ts +8 -0
  90. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  91. package/dist/resolution/frameworks/rust.d.ts +8 -0
  92. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  93. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  94. package/dist/resolution/frameworks/swift.d.ts +10 -0
  95. package/dist/resolution/frameworks/vue.d.ts +9 -0
  96. package/dist/resolution/go-module.d.ts +26 -0
  97. package/dist/resolution/import-resolver.d.ts +68 -0
  98. package/dist/resolution/index.d.ts +116 -0
  99. package/dist/resolution/lru-cache.d.ts +24 -0
  100. package/dist/resolution/name-matcher.d.ts +32 -0
  101. package/dist/resolution/path-aliases.d.ts +68 -0
  102. package/dist/resolution/strip-comments.d.ts +27 -0
  103. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  104. package/dist/resolution/types.d.ts +209 -0
  105. package/dist/search/query-parser.d.ts +57 -0
  106. package/dist/search/query-utils.d.ts +53 -0
  107. package/dist/sync/git-hooks.d.ts +45 -0
  108. package/dist/sync/index.d.ts +19 -0
  109. package/dist/sync/watch-policy.d.ts +48 -0
  110. package/dist/sync/watcher.d.ts +191 -0
  111. package/dist/sync/worktree.d.ts +54 -0
  112. package/dist/types.d.ts +369 -0
  113. package/dist/ui/glyphs.d.ts +42 -0
  114. package/dist/ui/shimmer-progress.d.ts +11 -0
  115. package/dist/ui/shimmer-worker.d.ts +2 -0
  116. package/dist/ui/types.d.ts +17 -0
  117. package/dist/utils.d.ts +205 -0
  118. package/npm-sdk.js +75 -0
  119. package/package.json +18 -7
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Tree-sitter Extraction Types
3
+ *
4
+ * Defines the LanguageExtractor interface and related types used by
5
+ * the core TreeSitterExtractor and per-language extraction configs.
6
+ * Extracted to a leaf module to avoid circular imports.
7
+ */
8
+ import { Node as SyntaxNode } from 'web-tree-sitter';
9
+ import { Node, NodeKind, UnresolvedReference } from '../types';
10
+ /**
11
+ * Information returned by a language's extractImport hook.
12
+ */
13
+ export interface ImportInfo {
14
+ /** The module/package name being imported */
15
+ moduleName: string;
16
+ /** Full import statement text for display */
17
+ signature: string;
18
+ /** If true, the hook already created unresolved references itself */
19
+ handledRefs?: boolean;
20
+ }
21
+ /**
22
+ * Information about a single variable within a declaration.
23
+ * Returned by a language's extractVariables hook.
24
+ */
25
+ export interface VariableInfo {
26
+ /** Variable name */
27
+ name: string;
28
+ /** Node kind: 'variable' or 'constant' */
29
+ kind: NodeKind;
30
+ /** Optional signature string */
31
+ signature?: string;
32
+ /** If set, this declarator is actually a function and should be extracted as such */
33
+ delegateToFunction?: SyntaxNode;
34
+ /** The AST node to use for positioning (may differ from the declaration node) */
35
+ positionNode?: SyntaxNode;
36
+ }
37
+ /**
38
+ * Context object passed to language hooks that need to call back into the core extractor.
39
+ * Provides a controlled API surface — hooks can create nodes, visit children, and add
40
+ * references without accessing the full TreeSitterExtractor internals.
41
+ */
42
+ export interface ExtractorContext {
43
+ /** Create a node and add it to the extraction result */
44
+ createNode(kind: NodeKind, name: string, node: SyntaxNode, extra?: Partial<Node>): Node | null;
45
+ /** Visit a child node (dispatches through the standard visitNode logic) */
46
+ visitNode(node: SyntaxNode): void;
47
+ /** Visit a function body to extract calls */
48
+ visitFunctionBody(body: SyntaxNode, functionId: string): void;
49
+ /** Add an unresolved reference */
50
+ addUnresolvedReference(ref: UnresolvedReference): void;
51
+ /** Push a node ID onto the scope stack (for containment/qualified name building) */
52
+ pushScope(nodeId: string): void;
53
+ /** Pop the last node ID from the scope stack */
54
+ popScope(): void;
55
+ /** Current file path */
56
+ readonly filePath: string;
57
+ /** Current source text */
58
+ readonly source: string;
59
+ /** Stack of parent node IDs (current scope) */
60
+ readonly nodeStack: readonly string[];
61
+ /** All nodes extracted so far */
62
+ readonly nodes: readonly Node[];
63
+ }
64
+ /**
65
+ * Language-specific extraction configuration.
66
+ *
67
+ * Each supported language provides an implementation of this interface
68
+ * that configures which AST node types to look for and how to extract
69
+ * language-specific details like signatures, visibility, and imports.
70
+ */
71
+ export interface LanguageExtractor {
72
+ /** Node types that represent functions */
73
+ functionTypes: string[];
74
+ /** Node types that represent classes */
75
+ classTypes: string[];
76
+ /** Node types that represent methods */
77
+ methodTypes: string[];
78
+ /** Node types that represent interfaces/protocols/traits */
79
+ interfaceTypes: string[];
80
+ /** Node types that represent structs */
81
+ structTypes: string[];
82
+ /** Node types that represent enums */
83
+ enumTypes: string[];
84
+ /** Node types that represent enum members/cases (e.g. Swift: 'enum_entry', Rust: 'enum_variant') */
85
+ enumMemberTypes?: string[];
86
+ /** Node types that represent type aliases (e.g. `type X = ...`) */
87
+ typeAliasTypes: string[];
88
+ /** Node types that represent imports */
89
+ importTypes: string[];
90
+ /** Node types that represent function calls */
91
+ callTypes: string[];
92
+ /** Node types that represent variable declarations (const, let, var, etc.) */
93
+ variableTypes: string[];
94
+ /** Node types that represent class fields (extracted as 'field' kind inside class bodies) */
95
+ fieldTypes?: string[];
96
+ /** Node types that represent class properties (extracted as 'property' kind inside class bodies) */
97
+ propertyTypes?: string[];
98
+ /** Field name for identifier/name */
99
+ nameField: string;
100
+ /** Field name for body */
101
+ bodyField: string;
102
+ /** Field name for parameters */
103
+ paramsField: string;
104
+ /** Field name for return type */
105
+ returnField?: string;
106
+ /** Override symbol name extraction (e.g. ObjC multi-part selectors). */
107
+ resolveName?: (node: SyntaxNode, source: string) => string | undefined;
108
+ /** Extract property name when the generic name walk fails (e.g. ObjC @property). */
109
+ extractPropertyName?: (node: SyntaxNode, source: string) => string | null;
110
+ /** Extract signature from node */
111
+ getSignature?: (node: SyntaxNode, source: string) => string | undefined;
112
+ /** Extract visibility from node */
113
+ getVisibility?: (node: SyntaxNode) => 'public' | 'private' | 'protected' | 'internal' | undefined;
114
+ /** Check if node is exported */
115
+ isExported?: (node: SyntaxNode, source: string) => boolean;
116
+ /** Check if node is async */
117
+ isAsync?: (node: SyntaxNode) => boolean;
118
+ /** Check if node is static */
119
+ isStatic?: (node: SyntaxNode) => boolean;
120
+ /** Check if variable declaration is a constant (const vs let/var) */
121
+ isConst?: (node: SyntaxNode) => boolean;
122
+ /** Additional node types to treat as class declarations (e.g. Dart: 'mixin_declaration') */
123
+ extraClassNodeTypes?: string[];
124
+ /** Whether methods can be top-level without enclosing class (Go: true) */
125
+ methodsAreTopLevel?: boolean;
126
+ /** NodeKind to use for interface-like declarations (Rust: 'trait'). Default: 'interface' */
127
+ interfaceKind?: NodeKind;
128
+ /**
129
+ * Custom node visitor. Return true if the node was fully handled (skip default dispatch).
130
+ * Used by languages with fundamentally different AST structures (e.g. Pascal).
131
+ */
132
+ visitNode?: (node: SyntaxNode, ctx: ExtractorContext) => boolean;
133
+ /**
134
+ * Classify a class_declaration node when the grammar reuses one node type
135
+ * for multiple concepts (e.g. Swift uses class_declaration for classes, structs, and enums).
136
+ */
137
+ classifyClassNode?: (node: SyntaxNode) => 'class' | 'struct' | 'enum' | 'interface' | 'trait';
138
+ /**
139
+ * Resolve the body node for a function/method/class when it's not a child field.
140
+ * (e.g. Dart puts function_body as a sibling, not a child.)
141
+ */
142
+ resolveBody?: (node: SyntaxNode, bodyField: string) => SyntaxNode | null;
143
+ /**
144
+ * Extract import information from an import node.
145
+ * Return null if the node isn't a recognized import form.
146
+ */
147
+ extractImport?: (node: SyntaxNode, source: string) => ImportInfo | null;
148
+ /**
149
+ * Extract variable declarations from a variable declaration node.
150
+ * Returns info about each declared variable, allowing the core to create nodes.
151
+ */
152
+ extractVariables?: (node: SyntaxNode, source: string) => VariableInfo[];
153
+ /**
154
+ * Extract receiver/owner type name from a method declaration.
155
+ * Used by Go to get the struct receiver (e.g., "scrapeLoop" from "func (sl *scrapeLoop) run()").
156
+ * When present, the receiver type is included in the qualified name for better searchability.
157
+ */
158
+ getReceiverType?: (node: SyntaxNode, source: string) => string | undefined;
159
+ /**
160
+ * Resolve the actual node kind for a type alias declaration.
161
+ * Used by Go where `type_spec` is the named declaration wrapper for structs/interfaces:
162
+ * `type Foo struct { ... }` → type_spec (name: "Foo") → struct_type
163
+ * Returns 'struct', 'interface', etc. to override the default 'type_alias' kind,
164
+ * or undefined to keep it as a type alias.
165
+ */
166
+ resolveTypeAliasKind?: (node: SyntaxNode, source: string) => NodeKind | undefined;
167
+ /**
168
+ * Check if a function/method name is a misparse artifact that should be skipped.
169
+ * Used by C/C++ where macros (e.g. NLOHMANN_JSON_NAMESPACE_BEGIN) cause tree-sitter
170
+ * to misparse namespace blocks as function_definitions. When this returns true,
171
+ * the function node is NOT created, but the body is still visited for calls and
172
+ * structural nodes (classes, structs, enums).
173
+ */
174
+ isMisparsedFunction?: (name: string, node: SyntaxNode) => boolean;
175
+ /**
176
+ * Detect bare method calls that don't use call expression syntax.
177
+ * Used by Ruby where `reset` (no parens, no receiver) is a method call but
178
+ * tree-sitter parses it as a plain `identifier` node instead of `call`/`method_call`.
179
+ * Returns the callee name if this node is a bare call, or undefined if not.
180
+ */
181
+ extractBareCall?: (node: SyntaxNode, source: string) => string | undefined;
182
+ /**
183
+ * Node types representing a file-level package/namespace declaration
184
+ * (e.g. Kotlin `package_header`, Java `package_declaration`). When set,
185
+ * the core wraps every top-level declaration in an implicit `namespace`
186
+ * node carrying the FQN, so cross-file import resolution can match by
187
+ * qualifiedName instead of filename (Kotlin filename ≠ class name).
188
+ */
189
+ packageTypes?: string[];
190
+ /** Extract the dotted package name from a package declaration node. */
191
+ extractPackage?: (node: SyntaxNode, source: string) => string | null;
192
+ }
193
+ //# sourceMappingURL=tree-sitter-types.d.ts.map
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Tree-sitter Parser Wrapper
3
+ *
4
+ * Handles parsing source code and extracting structural information.
5
+ */
6
+ import { Language, ExtractionResult } from '../types';
7
+ export { generateNodeId } from './tree-sitter-helpers';
8
+ /**
9
+ * TreeSitterExtractor - Main extraction class
10
+ */
11
+ export declare class TreeSitterExtractor {
12
+ private filePath;
13
+ private language;
14
+ private source;
15
+ private tree;
16
+ private nodes;
17
+ private edges;
18
+ private unresolvedReferences;
19
+ private errors;
20
+ private extractor;
21
+ private nodeStack;
22
+ private methodIndex;
23
+ constructor(filePath: string, source: string, language?: Language);
24
+ /**
25
+ * Parse and extract from the source code
26
+ */
27
+ extract(): ExtractionResult;
28
+ /**
29
+ * Visit a node and extract information
30
+ */
31
+ private visitNode;
32
+ /**
33
+ * Create a Node object
34
+ */
35
+ private createNode;
36
+ /**
37
+ * Find first named child whose type is in the given list.
38
+ * Used to locate inner type nodes (e.g. enum_specifier inside a typedef).
39
+ */
40
+ private findChildByTypes;
41
+ /**
42
+ * Find a `packageTypes` child under the root, create a `namespace` node
43
+ * for it, and return its id so the caller can scope top-level
44
+ * declarations underneath. Returns null when no package header is
45
+ * present (script files, .kts without a package).
46
+ */
47
+ private extractFilePackage;
48
+ /**
49
+ * Build qualified name from node stack
50
+ */
51
+ private buildQualifiedName;
52
+ /**
53
+ * Build an ExtractorContext for passing to language-specific visitNode hooks.
54
+ */
55
+ private makeExtractorContext;
56
+ /**
57
+ * Check if the current node stack indicates we are inside a class-like node
58
+ * (class, struct, interface, trait). File nodes do not count as class-like.
59
+ */
60
+ private isInsideClassLikeNode;
61
+ /**
62
+ * Extract a function
63
+ */
64
+ private extractFunction;
65
+ /**
66
+ * Extract a class
67
+ */
68
+ private extractClass;
69
+ /**
70
+ * Extract a method
71
+ */
72
+ private extractMethod;
73
+ /**
74
+ * Extract an interface/protocol/trait
75
+ */
76
+ private extractInterface;
77
+ /**
78
+ * Extract a struct
79
+ */
80
+ private extractStruct;
81
+ /**
82
+ * Extract an enum
83
+ */
84
+ private extractEnum;
85
+ /**
86
+ * Extract enum member names from an enum member node.
87
+ * Handles multi-case declarations (Swift: `case put, delete`) and single-case patterns.
88
+ */
89
+ private extractEnumMembers;
90
+ /**
91
+ * Extract a class property declaration (e.g. C# `public string Name { get; set; }`).
92
+ * Extracts as 'property' kind node inside the owning class.
93
+ */
94
+ private extractProperty;
95
+ /**
96
+ * Extract a class field declaration (e.g. Java field_declaration, C# field_declaration).
97
+ * Extracts each declarator as a 'field' kind node inside the owning class.
98
+ */
99
+ private extractField;
100
+ /**
101
+ * Extract a variable declaration (const, let, var, etc.)
102
+ *
103
+ * Extracts top-level and module-level variable declarations.
104
+ * Captures the variable name and first 100 chars of initializer in signature for searchability.
105
+ */
106
+ private extractVariable;
107
+ /**
108
+ * Extract a type alias (e.g. `export type X = ...` in TypeScript).
109
+ * For languages like Go, resolveTypeAliasKind detects when the type_spec
110
+ * wraps a struct or interface definition and creates the correct node kind.
111
+ * Returns true if children should be skipped (struct/interface handled body visiting).
112
+ */
113
+ private extractTypeAlias;
114
+ /**
115
+ * Surface the members of a TypeScript `type X = { ... }` (or intersection
116
+ * thereof) as `property` / `method` nodes under the type-alias node. Only
117
+ * walks the immediate object_type / intersection operands so anonymous
118
+ * nested object types inside generic arguments (`Promise<{ ok: true }>`)
119
+ * don't produce phantom members.
120
+ */
121
+ private extractTsTypeAliasMembers;
122
+ /**
123
+ * `foo: () => T` → property_signature whose type_annotation contains a
124
+ * `function_type`. Treat that as a method-shaped contract member, since
125
+ * the call site `obj.foo()` has identical semantics to `bar(): T`.
126
+ */
127
+ private isTsFunctionTypedProperty;
128
+ /**
129
+ * Extract an import
130
+ *
131
+ * Creates an import node with the full import statement stored in signature for searchability.
132
+ * Also creates unresolved references for resolution purposes.
133
+ */
134
+ private extractImport;
135
+ /**
136
+ * Extract a function call
137
+ */
138
+ private extractCall;
139
+ /**
140
+ * `new Foo(...)` / `Foo::new(...)` / object_creation_expression —
141
+ * emit an `instantiates` reference to the class name. The resolver
142
+ * then links it to the class node, producing the `instantiates`
143
+ * edge that powers "what creates instances of X" queries.
144
+ *
145
+ * Children are still walked so nested calls inside the constructor
146
+ * arguments (`new Foo(bar())`) get their own `calls` references.
147
+ */
148
+ private extractInstantiation;
149
+ /**
150
+ * Find a `class_body` child of an `object_creation_expression` — the
151
+ * marker for an anonymous class (`new T() { ... }`). Returns the body
152
+ * node so the caller can walk it as the anon class's members.
153
+ */
154
+ private findAnonymousClassBody;
155
+ /**
156
+ * Extract a Java/C# anonymous class — `new T() { ...members }`. Emits a
157
+ * `class` node named `<T$anon@line>`, an `extends` reference to T (so
158
+ * Phase 5.5 interface-impl can bridge), and walks the body so its
159
+ * `method_declaration` members become method nodes under the anon class.
160
+ *
161
+ * Why this matters: without anon-class extraction, the overrides inside
162
+ * a lambda-returned `new T() { @Override int foo(){...} }` are not nodes,
163
+ * so a call through T.foo (the abstract parent method) has no static
164
+ * target — the agent has to Read the file to find the implementation.
165
+ */
166
+ private extractAnonymousClass;
167
+ /**
168
+ * Scan `declNode` and its preceding siblings (within the parent's
169
+ * named children) for decorator nodes, emitting a `decorates`
170
+ * reference from `decoratedId` to each decorator's function name.
171
+ *
172
+ * Why preceding siblings: in TypeScript, `@Foo class Bar {}` parses
173
+ * as an `export_statement` (or top-level wrapper) with the
174
+ * `decorator` as a child *before* the `class_declaration` — so the
175
+ * decorator isn't a child of the class itself. For methods/
176
+ * properties, the decorator IS a direct child of the declaration,
177
+ * so we also scan declNode.namedChildren.
178
+ *
179
+ * Idempotent across grammars: if neither location yields decorators
180
+ * (most non-decorator-using languages), the function is a no-op.
181
+ */
182
+ private extractDecoratorsFor;
183
+ /**
184
+ * Visit function body and extract calls (and structural nodes).
185
+ *
186
+ * In addition to call expressions, this also detects class/struct/enum
187
+ * definitions inside function bodies. This handles two cases:
188
+ * 1. Local class/struct/enum definitions (valid in C++, Java, etc.)
189
+ * 2. C++ macro misparsing — macros like NLOHMANN_JSON_NAMESPACE_BEGIN cause
190
+ * tree-sitter to interpret the namespace block as a function_definition,
191
+ * hiding real class/struct/enum nodes inside the "function body".
192
+ */
193
+ private visitFunctionBody;
194
+ /**
195
+ * Extract inheritance relationships
196
+ */
197
+ private extractInheritance;
198
+ /**
199
+ * Rust `impl Trait for Type` — creates an implements edge from Type to Trait.
200
+ * For plain `impl Type { ... }` (no trait), no inheritance edge is needed.
201
+ */
202
+ private extractRustImplItem;
203
+ /**
204
+ * Find a previously-extracted node by name (used for back-references like impl blocks)
205
+ */
206
+ private findNodeByName;
207
+ /**
208
+ * Languages that support type annotations (TypeScript, etc.)
209
+ */
210
+ private readonly TYPE_ANNOTATION_LANGUAGES;
211
+ /**
212
+ * Built-in/primitive type names that shouldn't create references
213
+ */
214
+ private readonly BUILTIN_TYPES;
215
+ /**
216
+ * Extract type references from type annotations on a function/method/field node.
217
+ * Creates 'references' edges for parameter types, return types, and field types.
218
+ */
219
+ private extractTypeAnnotations;
220
+ /**
221
+ * Extract C# type references from a node that owns a type position —
222
+ * a method/constructor declaration, a property declaration, or a
223
+ * field declaration (which wraps `variable_declaration → type`).
224
+ *
225
+ * Walks ONLY into known type fields, so parameter names like
226
+ * `request` in `Build(UserDto request)` are never mis-emitted as
227
+ * type references. Once inside a type subtree, `walkCsharpTypePosition`
228
+ * recognizes C#'s actual type-leaf node kinds (`identifier`,
229
+ * `qualified_name`, `generic_name`, `array_type`, `nullable_type`,
230
+ * `tuple_type`, …) — none of which are `type_identifier`. Closes #381.
231
+ */
232
+ private extractCsharpTypeRefs;
233
+ /**
234
+ * Walk a C# subtree that is KNOWN to be in a type position
235
+ * (return type, parameter type, property type, field type, generic
236
+ * argument). Identifiers here are type names, not parameter names.
237
+ */
238
+ private walkCsharpTypePosition;
239
+ /**
240
+ * Extract type references from a variable's type annotation.
241
+ */
242
+ private extractVariableTypeAnnotation;
243
+ /**
244
+ * Recursively walk a subtree and extract all type_identifier references.
245
+ * Handles unions, intersections, generics, arrays, etc.
246
+ */
247
+ private extractTypeRefsFromSubtree;
248
+ /**
249
+ * Handle Pascal-specific AST structures.
250
+ * Returns true if the node was fully handled and children should be skipped.
251
+ */
252
+ private visitPascalNode;
253
+ /**
254
+ * Extract a Pascal declType node (class, interface, enum, or type alias)
255
+ */
256
+ private extractPascalDeclType;
257
+ /**
258
+ * Extract Pascal uses clause into individual import nodes
259
+ */
260
+ private extractPascalUses;
261
+ /**
262
+ * Extract a Pascal constant declaration
263
+ */
264
+ private extractPascalConst;
265
+ /**
266
+ * Extract Pascal inheritance (extends/implements) from declClass typeref children
267
+ */
268
+ private extractPascalInheritance;
269
+ /**
270
+ * Extract calls and resolve method context from a Pascal defProc (implementation body).
271
+ * Does not create a new node — the declaration was already captured from the interface section.
272
+ */
273
+ private extractPascalDefProc;
274
+ /**
275
+ * Extract function calls from a Pascal expression
276
+ */
277
+ private extractPascalCall;
278
+ /**
279
+ * Recursively visit a Pascal block/statement tree for call expressions
280
+ */
281
+ private visitPascalBlock;
282
+ }
283
+ /**
284
+ * Extract nodes and edges from source code.
285
+ *
286
+ * If `frameworkNames` is provided, framework-specific extractors matching
287
+ * those names and the file's language are run after the tree-sitter pass.
288
+ * Their nodes/references/errors are merged into the returned result.
289
+ */
290
+ export declare function extractFromSource(filePath: string, source: string, language?: Language, frameworkNames?: string[]): ExtractionResult;
291
+ //# sourceMappingURL=tree-sitter.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { ExtractionResult } from '../types';
2
+ /**
3
+ * VueExtractor - Extracts code relationships from Vue Single-File Component files
4
+ *
5
+ * Vue SFCs are multi-language (script + template + style). Rather than
6
+ * parsing the full Vue grammar, we extract the <script> block content
7
+ * and delegate it to the TypeScript/JavaScript TreeSitterExtractor.
8
+ *
9
+ * Every .vue file produces a component node (Vue components are always importable).
10
+ */
11
+ export declare class VueExtractor {
12
+ private filePath;
13
+ private source;
14
+ private nodes;
15
+ private edges;
16
+ private unresolvedReferences;
17
+ private errors;
18
+ constructor(filePath: string, source: string);
19
+ /**
20
+ * Extract from Vue source
21
+ */
22
+ extract(): ExtractionResult;
23
+ /**
24
+ * Create a component node for the .vue file
25
+ */
26
+ private createComponentNode;
27
+ /**
28
+ * Extract <script> and <script setup> blocks from the Vue source
29
+ */
30
+ private extractScriptBlocks;
31
+ /**
32
+ * Process a script block by delegating to TreeSitterExtractor
33
+ */
34
+ private processScriptBlock;
35
+ }
36
+ //# sourceMappingURL=vue-extractor.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The V8 flag(s) that keep tree-sitter grammar compilation off the turboshaft
3
+ * optimizing tier. Single source of truth: the relaunch guard and the test
4
+ * suite both read this (a test asserts each is a real flag on the running
5
+ * runtime, so a rename can't silently regress the fix).
6
+ */
7
+ export declare const WASM_RUNTIME_FLAGS: readonly string[];
8
+ /**
9
+ * Env var carrying the *host* PID (the relauncher's own parent) across the
10
+ * re-exec. Without `--liftoff-only` the CLI re-execs itself once, inserting an
11
+ * intermediate process between the MCP host and the server. That intermediate
12
+ * stays alive (blocked in spawnSync) even after the host is killed, so the
13
+ * server's PPID watchdog can't detect the host's death by watching its own
14
+ * `process.ppid`. Passing the host PID through lets the watchdog poll it
15
+ * directly. Unset on the no-re-exec path (bundled launcher / flag already
16
+ * present), where the server is already a direct child of the host. See
17
+ * src/mcp/index.ts (#277).
18
+ */
19
+ export declare const HOST_PPID_ENV = "CODEGRAPH_HOST_PPID";
20
+ /** True when every required WASM runtime flag is already present in `execArgv`. */
21
+ export declare function processHasWasmRuntimeFlags(execArgv?: readonly string[]): boolean;
22
+ /**
23
+ * Build the argv for re-execing node with the WASM runtime flags: our flags
24
+ * first, then any node flags already in `execArgv` (deduped), then the script
25
+ * and its args. Pure — exported for unit testing.
26
+ */
27
+ export declare function buildRelaunchArgv(scriptPath: string, scriptArgs: readonly string[], execArgv?: readonly string[]): string[];
28
+ /**
29
+ * If the current process is missing the WASM runtime flags, re-exec it once
30
+ * with them and exit with the child's status. No-op when the flags are already
31
+ * present (the normal bundled-launcher path), when already relaunched, or when
32
+ * disabled via CODEGRAPH_NO_RELAUNCH.
33
+ *
34
+ * On spawn failure, returns so the caller runs in-process anyway — risking the
35
+ * OOM is still better than refusing to start.
36
+ */
37
+ export declare function relaunchWithWasmRuntimeFlagsIfNeeded(scriptPath: string): void;
38
+ //# sourceMappingURL=wasm-runtime-flags.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Graph Module
3
+ *
4
+ * Provides graph traversal and query functionality for the code knowledge graph.
5
+ */
6
+ export { GraphTraverser } from './traversal';
7
+ export { GraphQueryManager } from './queries';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Graph Query Functions
3
+ *
4
+ * Higher-level query functions built on top of traversal algorithms.
5
+ */
6
+ import { Node, Context, Subgraph } from '../types';
7
+ import { QueryBuilder } from '../db/queries';
8
+ import { GraphTraverser } from './traversal';
9
+ /**
10
+ * Graph query manager for complex queries
11
+ */
12
+ export declare class GraphQueryManager {
13
+ private queries;
14
+ private traverser;
15
+ constructor(queries: QueryBuilder);
16
+ /**
17
+ * Get full context for a node
18
+ *
19
+ * Returns the focal node along with its ancestors, children,
20
+ * and both incoming and outgoing references.
21
+ *
22
+ * @param nodeId - ID of the focal node
23
+ * @returns Context object with all related information
24
+ */
25
+ getContext(nodeId: string): Context;
26
+ /**
27
+ * Get dependencies of a file
28
+ *
29
+ * Returns all files that this file imports from.
30
+ *
31
+ * @param filePath - Path to the file
32
+ * @returns Array of file paths this file depends on
33
+ */
34
+ getFileDependencies(filePath: string): string[];
35
+ /**
36
+ * Get dependents of a file
37
+ *
38
+ * Returns all files that import from this file.
39
+ *
40
+ * @param filePath - Path to the file
41
+ * @returns Array of file paths that depend on this file
42
+ */
43
+ getFileDependents(filePath: string): string[];
44
+ /**
45
+ * Get all symbols exported by a file
46
+ *
47
+ * @param filePath - Path to the file
48
+ * @returns Array of exported nodes
49
+ */
50
+ getExportedSymbols(filePath: string): Node[];
51
+ /**
52
+ * Find symbols by qualified name pattern
53
+ *
54
+ * @param pattern - Pattern to match (supports * wildcard)
55
+ * @returns Array of matching nodes
56
+ */
57
+ findByQualifiedName(pattern: string): Node[];
58
+ /**
59
+ * Get the module/package structure
60
+ *
61
+ * Returns a tree structure of files organized by directory.
62
+ *
63
+ * @returns Map of directory paths to contained files
64
+ */
65
+ getModuleStructure(): Map<string, string[]>;
66
+ /**
67
+ * Find circular dependencies in the graph
68
+ *
69
+ * @returns Array of cycles, each cycle is an array of node IDs
70
+ */
71
+ findCircularDependencies(): string[][];
72
+ /**
73
+ * Get complexity metrics for a node
74
+ *
75
+ * @param nodeId - ID of the node
76
+ * @returns Object containing various complexity metrics
77
+ */
78
+ getNodeMetrics(nodeId: string): {
79
+ incomingEdgeCount: number;
80
+ outgoingEdgeCount: number;
81
+ callCount: number;
82
+ callerCount: number;
83
+ childCount: number;
84
+ depth: number;
85
+ };
86
+ /**
87
+ * Find dead code (nodes with no incoming references)
88
+ *
89
+ * @param kinds - Node kinds to check (default: functions, methods, classes)
90
+ * @returns Array of unreferenced nodes
91
+ */
92
+ findDeadCode(kinds?: Node['kind'][]): Node[];
93
+ /**
94
+ * Get subgraph containing nodes matching a filter
95
+ *
96
+ * @param filter - Filter function to select nodes
97
+ * @param includeEdges - Whether to include edges between matching nodes
98
+ * @returns Subgraph containing matching nodes
99
+ */
100
+ getFilteredSubgraph(filter: (node: Node) => boolean, includeEdges?: boolean): Subgraph;
101
+ /**
102
+ * Access the underlying traverser for direct traversal operations
103
+ */
104
+ getTraverser(): GraphTraverser;
105
+ }
106
+ //# sourceMappingURL=queries.d.ts.map