@aroman22/codegraph-vba 1.3.3
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 +855 -0
- package/dist/bin/codegraph.d.ts +26 -0
- package/dist/bin/command-supervision.d.ts +12 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/bin/node-version-check.d.ts +37 -0
- package/dist/bin/uninstall.d.ts +14 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/index.d.ts +119 -0
- package/dist/context/markers.d.ts +19 -0
- package/dist/db/index.d.ts +122 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/queries.d.ts +402 -0
- package/dist/db/sqlite-adapter.d.ts +53 -0
- package/dist/directory.d.ts +179 -0
- package/dist/errors.d.ts +136 -0
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/grammars.d.ts +128 -0
- package/dist/extraction/index.d.ts +187 -0
- package/dist/extraction/languages/c-cpp.d.ts +12 -0
- package/dist/extraction/languages/csharp.d.ts +25 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts +16 -0
- package/dist/extraction/liquid-extractor.d.ts +59 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/parse-pool.d.ts +126 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/sql-query-extractor.d.ts +25 -0
- package/dist/extraction/svelte-extractor.d.ts +56 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-types.d.ts +239 -0
- package/dist/extraction/tree-sitter.d.ts +647 -0
- package/dist/extraction/vba-extractor.d.ts +394 -0
- package/dist/extraction/vba-form-extractor.d.ts +89 -0
- package/dist/extraction/vba-preprocess.d.ts +81 -0
- package/dist/extraction/vue-extractor.d.ts +51 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/index.d.ts +563 -0
- package/dist/installer/config-writer.d.ts +28 -0
- package/dist/installer/index.d.ts +100 -0
- package/dist/installer/instructions-template.d.ts +41 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/claude.d.ts +62 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/opencode.d.ts +38 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/shared.d.ts +101 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/types.d.ts +108 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-paths.d.ts +73 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon.d.ts +258 -0
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/engine.d.ts +122 -0
- package/dist/mcp/index.d.ts +113 -0
- package/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/dist/mcp/ppid-watchdog.d.ts +62 -0
- package/dist/mcp/proxy.d.ts +87 -0
- package/dist/mcp/query-pool.d.ts +94 -0
- package/dist/mcp/query-worker.d.ts +24 -0
- package/dist/mcp/server-instructions.d.ts +34 -0
- package/dist/mcp/session.d.ts +79 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/tools.d.ts +591 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/project-config.d.ts +56 -0
- package/dist/reasoning/config.d.ts +45 -0
- package/dist/reasoning/credentials.d.ts +5 -0
- package/dist/reasoning/login.d.ts +21 -0
- package/dist/reasoning/reasoner.d.ts +43 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +5 -0
- package/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/dist/resolution/frameworks/index.d.ts +50 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/goframe-synthesizer.d.ts +28 -0
- package/dist/resolution/import-resolver.d.ts +78 -0
- package/dist/resolution/index.d.ts +196 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/name-matcher.d.ts +93 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/types.d.ts +233 -0
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-utils.d.ts +87 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watcher.d.ts +358 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/telemetry/index.d.ts +143 -0
- package/dist/types.d.ts +409 -0
- package/dist/ui/glyphs.d.ts +42 -0
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/upgrade/index.d.ts +132 -0
- package/dist/utils.d.ts +224 -0
- package/npm-sdk.js +75 -0
- package/npm-shim.js +246 -0
- package/package.json +32 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extraction Orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Coordinates file scanning, parsing, and database storage.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import { ExtractionResult, ExtractionError } from '../types';
|
|
8
|
+
import { QueryBuilder } from '../db/queries';
|
|
9
|
+
import { Ignore } from 'ignore';
|
|
10
|
+
/**
|
|
11
|
+
* Progress callback for indexing operations
|
|
12
|
+
*/
|
|
13
|
+
export interface IndexProgress {
|
|
14
|
+
phase: 'scanning' | 'parsing' | 'storing' | 'resolving';
|
|
15
|
+
current: number;
|
|
16
|
+
total: number;
|
|
17
|
+
currentFile?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of an indexing operation
|
|
21
|
+
*/
|
|
22
|
+
export interface IndexResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
filesIndexed: number;
|
|
25
|
+
filesSkipped: number;
|
|
26
|
+
filesErrored: number;
|
|
27
|
+
nodesCreated: number;
|
|
28
|
+
edgesCreated: number;
|
|
29
|
+
errors: ExtractionError[];
|
|
30
|
+
durationMs: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result of a sync operation
|
|
34
|
+
*/
|
|
35
|
+
export interface SyncResult {
|
|
36
|
+
filesChecked: number;
|
|
37
|
+
filesAdded: number;
|
|
38
|
+
filesModified: number;
|
|
39
|
+
filesRemoved: number;
|
|
40
|
+
nodesUpdated: number;
|
|
41
|
+
durationMs: number;
|
|
42
|
+
changedFilePaths?: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate SHA256 hash of file contents
|
|
46
|
+
*/
|
|
47
|
+
export declare function hashContent(content: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* An `ignore` matcher seeded with the built-in defaults, merged with the project's
|
|
50
|
+
* root .gitignore so a negation there (e.g. `!vendor/`) overrides a default. Shared
|
|
51
|
+
* by both enumeration paths so behavior is identical with or without git — and so
|
|
52
|
+
* the defaults apply to tracked files too (committing a dependency dir doesn't make
|
|
53
|
+
* it project code; the explicit `.gitignore` negation is the only opt-in).
|
|
54
|
+
*/
|
|
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
|
+
/**
|
|
70
|
+
* Project `codegraph.json` `exclude` patterns (#999), matched against the
|
|
71
|
+
* full root-relative path. Wins over everything else — an explicit user
|
|
72
|
+
* exclude applies even to tracked files and even inside embedded repos.
|
|
73
|
+
*/
|
|
74
|
+
private exclude;
|
|
75
|
+
private embedded;
|
|
76
|
+
private defaults;
|
|
77
|
+
constructor(rootMatcher: Ignore, embedded: Array<{
|
|
78
|
+
root: string;
|
|
79
|
+
matcher: Ignore;
|
|
80
|
+
}>,
|
|
81
|
+
/**
|
|
82
|
+
* Project `codegraph.json` `exclude` patterns (#999), matched against the
|
|
83
|
+
* full root-relative path. Wins over everything else — an explicit user
|
|
84
|
+
* exclude applies even to tracked files and even inside embedded repos.
|
|
85
|
+
*/
|
|
86
|
+
exclude?: Ignore | null);
|
|
87
|
+
ignores(rel: string): boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build the workspace-scope matcher. When the caller already knows the
|
|
91
|
+
* embedded roots (the scanner discovers them during collection), pass them to
|
|
92
|
+
* skip rediscovery; otherwise they're discovered here (the watcher path).
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildScopeIgnore(rootDir: string, embeddedRoots?: Iterable<string>): ScopeIgnore;
|
|
95
|
+
/**
|
|
96
|
+
* Standalone discovery of every embedded repo root under `rootDir` (relative,
|
|
97
|
+
* trailing-slashed) — the untracked kind (#193) always, and the gitignored kind
|
|
98
|
+
* (#514) only for directories the project opted in via `codegraph.json`
|
|
99
|
+
* `includeIgnored` (#622, #699); otherwise `.gitignore` is respected and they
|
|
100
|
+
* are not discovered (#970, #976). Recursive (an embedded repo can embed further
|
|
101
|
+
* repos). Returns [] for non-git roots: the filesystem walk handles nested repos
|
|
102
|
+
* there already.
|
|
103
|
+
*/
|
|
104
|
+
export declare function discoverEmbeddedRepoRoots(rootDir: string): string[];
|
|
105
|
+
/**
|
|
106
|
+
* Recursively scan a directory for source files.
|
|
107
|
+
*
|
|
108
|
+
* In git repos, uses `git ls-files` (inherently respects .gitignore at all
|
|
109
|
+
* levels), then keeps files with a supported source extension. For non-git
|
|
110
|
+
* projects, falls back to a filesystem walk that parses .gitignore itself.
|
|
111
|
+
*/
|
|
112
|
+
export declare function scanDirectory(rootDir: string, onProgress?: (current: number, file: string) => void): string[];
|
|
113
|
+
/**
|
|
114
|
+
* Async variant of scanDirectory that yields to the event loop periodically,
|
|
115
|
+
* allowing worker threads to receive and render progress messages.
|
|
116
|
+
*/
|
|
117
|
+
export declare function scanDirectoryAsync(rootDir: string, onProgress?: (current: number, file: string) => void): Promise<string[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Extraction orchestrator
|
|
120
|
+
*/
|
|
121
|
+
export declare class ExtractionOrchestrator {
|
|
122
|
+
private rootDir;
|
|
123
|
+
private queries;
|
|
124
|
+
/**
|
|
125
|
+
* Names of frameworks detected for this project, populated by indexAll().
|
|
126
|
+
* Passed to extractFromSource so framework-specific extractors (route nodes,
|
|
127
|
+
* middleware, etc.) run after the tree-sitter pass. Cleared if detection
|
|
128
|
+
* hasn't run yet so single-file re-index paths can detect on the spot.
|
|
129
|
+
*/
|
|
130
|
+
private detectedFrameworkNames;
|
|
131
|
+
constructor(rootDir: string, queries: QueryBuilder);
|
|
132
|
+
/**
|
|
133
|
+
* Build a filesystem-backed ResolutionContext sufficient for framework
|
|
134
|
+
* detection. Graph-query methods (getNodesByName etc.) return empty because
|
|
135
|
+
* the DB hasn't been populated yet, but detect() only uses readFile,
|
|
136
|
+
* fileExists, and getAllFiles, so that's fine.
|
|
137
|
+
*/
|
|
138
|
+
private buildDetectionContext;
|
|
139
|
+
/**
|
|
140
|
+
* Detect frameworks on demand using the current scanned files (or a fresh
|
|
141
|
+
* scan if none are provided). Cached on the orchestrator so repeat calls
|
|
142
|
+
* inside a single run don't re-scan.
|
|
143
|
+
*/
|
|
144
|
+
private ensureDetectedFrameworks;
|
|
145
|
+
/**
|
|
146
|
+
* Index all files in the project
|
|
147
|
+
*/
|
|
148
|
+
indexAll(onProgress?: (progress: IndexProgress) => void, signal?: AbortSignal, verbose?: boolean): Promise<IndexResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Index specific files
|
|
151
|
+
*/
|
|
152
|
+
indexFiles(filePaths: string[]): Promise<IndexResult>;
|
|
153
|
+
/**
|
|
154
|
+
* Index a single file
|
|
155
|
+
*/
|
|
156
|
+
indexFile(relativePath: string): Promise<ExtractionResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Index a single file with pre-read content and stats.
|
|
159
|
+
* Used by the parallel batch reader to avoid redundant file I/O.
|
|
160
|
+
*/
|
|
161
|
+
indexFileWithContent(relativePath: string, content: string, stats: fs.Stats): Promise<ExtractionResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Store extraction result in database
|
|
164
|
+
*/
|
|
165
|
+
private storeExtractionResult;
|
|
166
|
+
/**
|
|
167
|
+
* Sync the index with the current file state.
|
|
168
|
+
*
|
|
169
|
+
* Change detection is filesystem-based, never git: a (size, mtime) stat
|
|
170
|
+
* pre-filter skips unchanged files, then a content-hash compare confirms real
|
|
171
|
+
* changes. This works in non-git projects and catches committed changes from
|
|
172
|
+
* `git pull`/`checkout`/`merge`/`rebase` that `git status` cannot see.
|
|
173
|
+
*/
|
|
174
|
+
sync(onProgress?: (progress: IndexProgress) => void): Promise<SyncResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Get files that have changed since last index.
|
|
177
|
+
* Uses git status as a fast path when available, falling back to full scan.
|
|
178
|
+
*/
|
|
179
|
+
getChangedFiles(): {
|
|
180
|
+
added: string[];
|
|
181
|
+
modified: string[];
|
|
182
|
+
removed: string[];
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export { extractFromSource } from './tree-sitter';
|
|
186
|
+
export { detectLanguage, isSourceFile, isLanguageSupported, isGrammarLoaded, getSupportedLanguages, initGrammars, loadGrammarsForLanguages, loadAllGrammars } from './grammars';
|
|
187
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
10
|
+
export declare const cExtractor: LanguageExtractor;
|
|
11
|
+
export declare const cppExtractor: LanguageExtractor;
|
|
12
|
+
//# sourceMappingURL=c-cpp.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
24
|
+
export declare const csharpExtractor: LanguageExtractor;
|
|
25
|
+
//# sourceMappingURL=csharp.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-language extraction configurations.
|
|
3
|
+
*
|
|
4
|
+
* Each file exports a LanguageExtractor config object.
|
|
5
|
+
* This barrel builds the EXTRACTORS map consumed by TreeSitterExtractor.
|
|
6
|
+
*/
|
|
7
|
+
import { Language } from '../../types';
|
|
8
|
+
import type { LanguageExtractor } from '../tree-sitter-types';
|
|
9
|
+
export declare const EXTRACTORS: Partial<Record<Language, LanguageExtractor>>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
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';
|
|
15
|
+
export declare const typescriptExtractor: LanguageExtractor;
|
|
16
|
+
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* LiquidExtractor - Extracts relationships from Liquid template files
|
|
4
|
+
*
|
|
5
|
+
* Liquid is a templating language (used by Shopify, Jekyll, etc.) that doesn't
|
|
6
|
+
* have traditional functions or classes. Instead, we extract:
|
|
7
|
+
* - Section references ({% section 'name' %})
|
|
8
|
+
* - Snippet references ({% render 'name' %} and {% include 'name' %})
|
|
9
|
+
* - Schema blocks ({% schema %}...{% endschema %})
|
|
10
|
+
*/
|
|
11
|
+
export declare class LiquidExtractor {
|
|
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 Liquid source
|
|
21
|
+
*/
|
|
22
|
+
extract(): ExtractionResult;
|
|
23
|
+
/**
|
|
24
|
+
* Create a file node for the Liquid template
|
|
25
|
+
*/
|
|
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;
|
|
34
|
+
/**
|
|
35
|
+
* Extract {% render 'snippet' %} and {% include 'snippet' %} references
|
|
36
|
+
*/
|
|
37
|
+
private extractSnippetReferences;
|
|
38
|
+
/**
|
|
39
|
+
* Extract {% section 'name' %} references
|
|
40
|
+
*/
|
|
41
|
+
private extractSectionReferences;
|
|
42
|
+
/**
|
|
43
|
+
* Extract {% schema %}...{% endschema %} blocks
|
|
44
|
+
*/
|
|
45
|
+
private extractSchema;
|
|
46
|
+
/**
|
|
47
|
+
* Extract {% assign var = value %} statements
|
|
48
|
+
*/
|
|
49
|
+
private extractAssignments;
|
|
50
|
+
/**
|
|
51
|
+
* Get the line number for a character index
|
|
52
|
+
*/
|
|
53
|
+
private getLineNumber;
|
|
54
|
+
/**
|
|
55
|
+
* Get the character index of the start of a line
|
|
56
|
+
*/
|
|
57
|
+
private getLineStart;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=liquid-extractor.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* MyBatisExtractor — parses MyBatis mapper XML files.
|
|
4
|
+
*
|
|
5
|
+
* MyBatis splits a DAO interface across two files: a Java interface (parsed by
|
|
6
|
+
* tree-sitter) declares the method, and an XML mapper file holds the SQL keyed
|
|
7
|
+
* by `<namespace>` (the fully-qualified Java type name) and `id` (the method
|
|
8
|
+
* name). Without the XML side in the graph, `trace(Controller, ...DAO.method)`
|
|
9
|
+
* dead-ends at the interface method — the SQL it actually runs is invisible,
|
|
10
|
+
* and "what does this query touch" / "where is this column written" can't be
|
|
11
|
+
* answered.
|
|
12
|
+
*
|
|
13
|
+
* This extractor emits one method-shaped node per `<select|insert|update|
|
|
14
|
+
* delete>` and per `<sql>` fragment, qualified as `<namespace>::<id>` so the
|
|
15
|
+
* MyBatis framework synthesizer (`src/resolution/frameworks/mybatis.ts`) can
|
|
16
|
+
* link the matching Java method → XML statement by suffix-matching qualified
|
|
17
|
+
* names. `<include refid="...">` inside a statement yields an unresolved
|
|
18
|
+
* reference to the SQL fragment, also keyed by `<namespace>::<refid>`.
|
|
19
|
+
*
|
|
20
|
+
* Non-mapper XML (Maven `pom.xml`, Spring beans XML, `web.xml`, log4j config,
|
|
21
|
+
* etc.) is detected by the absence of a `<mapper namespace="...">` root and
|
|
22
|
+
* returns just a file node — we still need the file row so the watcher can
|
|
23
|
+
* track it, but we emit no symbols.
|
|
24
|
+
*/
|
|
25
|
+
export declare class MyBatisExtractor {
|
|
26
|
+
private filePath;
|
|
27
|
+
private source;
|
|
28
|
+
private nodes;
|
|
29
|
+
private edges;
|
|
30
|
+
private unresolvedReferences;
|
|
31
|
+
private errors;
|
|
32
|
+
private lineStarts;
|
|
33
|
+
constructor(filePath: string, source: string);
|
|
34
|
+
extract(): ExtractionResult;
|
|
35
|
+
private createFileNode;
|
|
36
|
+
/**
|
|
37
|
+
* Find the `<mapper namespace="X">` opening tag. Returns the namespace and
|
|
38
|
+
* the byte offsets of the body (between the opening and closing tag) so
|
|
39
|
+
* statement extraction can be scoped to mapper contents.
|
|
40
|
+
*/
|
|
41
|
+
private findMapperRoot;
|
|
42
|
+
private extractMapper;
|
|
43
|
+
private buildSignature;
|
|
44
|
+
private previewSql;
|
|
45
|
+
private computeLineStarts;
|
|
46
|
+
private getLineNumber;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=mybatis-extractor.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse worker pool — runs tree-sitter parsing across N worker threads so a full
|
|
3
|
+
* `codegraph index` uses every core instead of pinning one.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: `ExtractionOrchestrator.indexAll()` already reads files in
|
|
6
|
+
* parallel, but it parsed them through a SINGLE worker thread, so on an
|
|
7
|
+
* N-core machine indexing a large repo used one core and left the rest idle
|
|
8
|
+
* (issue #1015, the parse-time half of #320). Spreading the parse calls across a
|
|
9
|
+
* pool of workers — each its own tree-sitter WASM heap — restores multi-core
|
|
10
|
+
* throughput. SQLite storage stays on the main thread (it isn't thread-safe), so
|
|
11
|
+
* only the CPU-bound parse step is parallelised; results are stored as they
|
|
12
|
+
* arrive, in whatever order they finish.
|
|
13
|
+
*
|
|
14
|
+
* Design mirrors {@link ../mcp/query-pool} (idle-list dispatch, lazy growth,
|
|
15
|
+
* throttled cold-starts, crash recovery), with parse-specific behaviour:
|
|
16
|
+
* - per-worker recycle: WASM linear memory grows but never shrinks, so each
|
|
17
|
+
* worker is torn down and replaced after `recycleInterval` parses to reclaim
|
|
18
|
+
* its heap — the same reason the old single worker recycled.
|
|
19
|
+
* - reject, don't retry: a parse that crashes or times out its worker REJECTS
|
|
20
|
+
* (with a message the orchestrator's retry pass recognises) rather than being
|
|
21
|
+
* silently requeued — the orchestrator owns the smarter two-stage retry
|
|
22
|
+
* (fresh worker, then comment-stripped) on a clean WASM heap.
|
|
23
|
+
* - a size-1 pool reproduces the old single-worker path exactly, which is the
|
|
24
|
+
* conservative rollback: set `CODEGRAPH_PARSE_WORKERS=1`.
|
|
25
|
+
*
|
|
26
|
+
* Memory: peak scales with pool size (≈ size × a worker's pre-recycle heap), so
|
|
27
|
+
* the default is capped and the env var lets constrained machines dial it down.
|
|
28
|
+
*/
|
|
29
|
+
import type { Language, ExtractionResult } from '../types';
|
|
30
|
+
/**
|
|
31
|
+
* Minimal worker surface the pool drives — satisfied by a real `worker_threads`
|
|
32
|
+
* Worker. Abstracted so tests can inject a fake worker and exercise the pool's
|
|
33
|
+
* queue / growth / recycle / crash-recovery logic without spawning threads or a
|
|
34
|
+
* built `dist/`.
|
|
35
|
+
*/
|
|
36
|
+
export interface ParsePoolWorker {
|
|
37
|
+
postMessage(msg: unknown): void;
|
|
38
|
+
terminate(): Promise<number> | void;
|
|
39
|
+
on(event: 'message', cb: (m: unknown) => void): void;
|
|
40
|
+
on(event: 'error', cb: (e: Error) => void): void;
|
|
41
|
+
on(event: 'exit', cb: (code: number) => void): void;
|
|
42
|
+
}
|
|
43
|
+
/** A single file to parse. `language` is resolved on the main thread (it holds
|
|
44
|
+
* the project's codegraph.json extension overrides) and handed to the worker. */
|
|
45
|
+
export interface ParseTask {
|
|
46
|
+
filePath: string;
|
|
47
|
+
content: string;
|
|
48
|
+
language: Language;
|
|
49
|
+
frameworkNames?: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the pool size from the `CODEGRAPH_PARSE_WORKERS` override and the
|
|
53
|
+
* machine's core count.
|
|
54
|
+
* - explicit `0` or `1` → 1 worker (the old single-worker path; the rollback).
|
|
55
|
+
* - explicit `N` → N, clamped to [1, 16].
|
|
56
|
+
* - unset / blank / non-numeric → `clamp(cores - 1, 1, 8)` (leave a core for
|
|
57
|
+
* the main thread + UI; never zero — parsing always needs a worker).
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveParsePoolSize(envVal: string | undefined, cpuCount: number): number;
|
|
60
|
+
export interface ParseWorkerPoolOptions {
|
|
61
|
+
/** Languages to load grammars for in every worker at spawn. */
|
|
62
|
+
languages: Language[];
|
|
63
|
+
/** Number of worker threads (≥1). Clamp the resolved value before passing. */
|
|
64
|
+
size: number;
|
|
65
|
+
/** Compiled `parse-worker.js` path. Required unless `createWorker` is given. */
|
|
66
|
+
workerScriptPath?: string;
|
|
67
|
+
/** Parses per worker before recycle. Default 250. */
|
|
68
|
+
recycleInterval?: number;
|
|
69
|
+
/** Base per-parse timeout (ms); scaled by file size per parse. Default 10s. */
|
|
70
|
+
parseTimeoutMs?: number;
|
|
71
|
+
/** Worker factory (tests inject a fake). Defaults to a real `worker_threads` Worker. */
|
|
72
|
+
createWorker?: () => ParsePoolWorker;
|
|
73
|
+
/** Optional verbose logger (the orchestrator's `[worker] …` logger). */
|
|
74
|
+
log?: (msg: string) => void;
|
|
75
|
+
}
|
|
76
|
+
export declare class ParseWorkerPool {
|
|
77
|
+
private idle;
|
|
78
|
+
private queue;
|
|
79
|
+
private inflight;
|
|
80
|
+
private workers;
|
|
81
|
+
private pending;
|
|
82
|
+
private parseCounts;
|
|
83
|
+
private nextId;
|
|
84
|
+
private totalCrashes;
|
|
85
|
+
private destroyed;
|
|
86
|
+
private readonly languages;
|
|
87
|
+
private readonly maxSize;
|
|
88
|
+
private readonly recycleInterval;
|
|
89
|
+
private readonly parseTimeoutMs;
|
|
90
|
+
private readonly createWorker;
|
|
91
|
+
private readonly log;
|
|
92
|
+
constructor(opts: ParseWorkerPoolOptions);
|
|
93
|
+
/** Pool size cap (for logging). */
|
|
94
|
+
get size(): number;
|
|
95
|
+
/** Live worker count (for tests). */
|
|
96
|
+
get liveWorkers(): number;
|
|
97
|
+
/** False once the crash budget is exhausted (or after destroy). */
|
|
98
|
+
get healthy(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Parse one file on the pool. Resolves with the extraction result, or REJECTS
|
|
101
|
+
* if the parse times out or its worker crashes — the caller records the error
|
|
102
|
+
* and (for worker-exit/OOM rejections) re-attempts in its retry pass.
|
|
103
|
+
*/
|
|
104
|
+
requestParse(task: ParseTask): Promise<ExtractionResult>;
|
|
105
|
+
private spawnOne;
|
|
106
|
+
private onMessage;
|
|
107
|
+
/** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight
|
|
108
|
+
* parse so the caller's retry pass can re-attempt it, then respawn. */
|
|
109
|
+
private onWorkerGone;
|
|
110
|
+
/** Tear down a worker that has hit its recycle threshold and replace it. Not a
|
|
111
|
+
* crash, so it doesn't count against the budget. */
|
|
112
|
+
private recycle;
|
|
113
|
+
private removeWorker;
|
|
114
|
+
private dispatch;
|
|
115
|
+
private onTimeout;
|
|
116
|
+
private drain;
|
|
117
|
+
private settle;
|
|
118
|
+
/**
|
|
119
|
+
* Recycle every idle worker now (fresh WASM heaps). The orchestrator calls
|
|
120
|
+
* this before its retry pass so crash-on-memory files get the cleanest heap.
|
|
121
|
+
*/
|
|
122
|
+
recycleAll(): void;
|
|
123
|
+
/** Terminate all workers and reject any outstanding parses. */
|
|
124
|
+
destroy(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=parse-pool.d.ts.map
|
|
@@ -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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
export declare class SqlQueryExtractor {
|
|
3
|
+
private filePath;
|
|
4
|
+
private source;
|
|
5
|
+
private nodes;
|
|
6
|
+
private edges;
|
|
7
|
+
private errors;
|
|
8
|
+
constructor(filePath: string, source: string);
|
|
9
|
+
/**
|
|
10
|
+
* Table name following `FROM` / `JOIN` / `INTO` / `UPDATE`. Captures either a
|
|
11
|
+
* bracketed name (which may contain spaces, e.g. `[Order Details]`) or a bare
|
|
12
|
+
* identifier. `\p{L}` covers accented identifiers common in localized schemas.
|
|
13
|
+
*/
|
|
14
|
+
private static readonly TABLE_RE;
|
|
15
|
+
extract(): ExtractionResult;
|
|
16
|
+
private basenameWithoutExt;
|
|
17
|
+
private createFileNode;
|
|
18
|
+
/**
|
|
19
|
+
* Scan the SQL for table names and emit one synthetic `class` node + one
|
|
20
|
+
* `references` edge per distinct table. The table node id is line-independent
|
|
21
|
+
* (line 0) so the same table referenced N times collapses to one node.
|
|
22
|
+
*/
|
|
23
|
+
private sweepTables;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=sql-query-extractor.d.ts.map
|