@colbymchenry/codegraph 0.9.7 → 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.
- package/README.md +111 -24
- package/dist/bin/codegraph.d.ts +25 -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 +110 -0
- package/dist/db/index.d.ts +101 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/queries.d.ts +344 -0
- package/dist/db/sqlite-adapter.d.ts +46 -0
- package/dist/directory.d.ts +57 -0
- package/dist/errors.d.ts +136 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/grammars.d.ts +100 -0
- package/dist/extraction/index.d.ts +138 -0
- package/dist/extraction/languages/c-cpp.d.ts +4 -0
- package/dist/extraction/languages/csharp.d.ts +3 -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/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 +3 -0
- package/dist/extraction/liquid-extractor.d.ts +52 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/parse-worker.d.ts +8 -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 +193 -0
- package/dist/extraction/tree-sitter.d.ts +291 -0
- package/dist/extraction/vue-extractor.d.ts +36 -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 +492 -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 +18 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/claude.d.ts +56 -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 +30 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/shared.d.ts +77 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/types.d.ts +101 -0
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/index.d.ts +112 -0
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/server-instructions.d.ts +19 -0
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/tools.d.ts +423 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -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/index.d.ts +48 -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/import-resolver.d.ts +68 -0
- package/dist/resolution/index.d.ts +116 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/name-matcher.d.ts +32 -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 +209 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-utils.d.ts +53 -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 +191 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/types.d.ts +369 -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/utils.d.ts +205 -0
- package/npm-sdk.js +75 -0
- package/package.json +18 -7
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grammar Loading and Caching
|
|
3
|
+
*
|
|
4
|
+
* Uses web-tree-sitter (WASM) for universal cross-platform support.
|
|
5
|
+
* Grammars are loaded lazily — only languages actually present in the project
|
|
6
|
+
* are compiled, keeping V8 WASM memory pressure low on large codebases.
|
|
7
|
+
*/
|
|
8
|
+
import { Parser } from 'web-tree-sitter';
|
|
9
|
+
import { Language } from '../types';
|
|
10
|
+
export type GrammarLanguage = Exclude<Language, 'svelte' | 'vue' | 'liquid' | 'yaml' | 'twig' | 'xml' | 'properties' | 'unknown'>;
|
|
11
|
+
/**
|
|
12
|
+
* File extension to Language mapping
|
|
13
|
+
*/
|
|
14
|
+
export declare const EXTENSION_MAP: Record<string, Language>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a file is one CodeGraph can parse, based purely on its extension.
|
|
17
|
+
* This is the single source of truth for "should we index this file" — derived
|
|
18
|
+
* from EXTENSION_MAP so parser support and indexing selection never drift.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSourceFile(filePath: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Play Framework routes file: the extensionless `conf/routes` (and included
|
|
23
|
+
* `conf/*.routes`). No grammar — route extraction is done by the Play framework
|
|
24
|
+
* resolver, so it's processed through the no-grammar (`yaml`-style) path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPlayRoutesFile(filePath: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize the tree-sitter WASM runtime. Must be called before loading grammars.
|
|
29
|
+
* Does NOT load any grammar WASM files — use loadGrammarsForLanguages() for that.
|
|
30
|
+
* Idempotent — safe to call multiple times.
|
|
31
|
+
*/
|
|
32
|
+
export declare function initGrammars(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Load grammar WASM files for specific languages only.
|
|
35
|
+
* Skips languages that are already loaded or have no WASM grammar.
|
|
36
|
+
* Must be called after initGrammars().
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadGrammarsForLanguages(languages: Language[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Load ALL grammar WASM files. Convenience function for tests and
|
|
41
|
+
* backward compatibility. Prefer loadGrammarsForLanguages() in production.
|
|
42
|
+
*/
|
|
43
|
+
export declare function loadAllGrammars(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if grammars have been initialized
|
|
46
|
+
*/
|
|
47
|
+
export declare function isGrammarsInitialized(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get a parser for the specified language.
|
|
50
|
+
* Returns synchronously from pre-loaded cache.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getParser(language: Language): Parser | null;
|
|
53
|
+
/**
|
|
54
|
+
* Detect language from file extension
|
|
55
|
+
*/
|
|
56
|
+
export declare function detectLanguage(filePath: string, source?: string): Language;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a language is supported (has a grammar defined).
|
|
59
|
+
* Returns true if the grammar exists, even if not yet loaded.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isLanguageSupported(language: Language): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a grammar has been loaded and is ready for parsing.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isGrammarLoaded(language: Language): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Languages tracked at the file-record level only: parsing emits zero symbol
|
|
68
|
+
* nodes, but the file is still stored (and framework resolvers may add per-file
|
|
69
|
+
* references later, e.g. Drupal routing yml, Spring `@Value` against
|
|
70
|
+
* application.properties). This is the canonical set behind the no-symbol
|
|
71
|
+
* branch in `tree-sitter.ts`; `xml` is intentionally excluded because its
|
|
72
|
+
* MyBatis extractor emits a file node. Callers use this to count such files as
|
|
73
|
+
* indexed rather than skipped, so it must stay in sync with that branch.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isFileLevelOnlyLanguage(language: Language): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get all supported languages (those with grammar definitions).
|
|
78
|
+
*/
|
|
79
|
+
export declare function getSupportedLanguages(): Language[];
|
|
80
|
+
/**
|
|
81
|
+
* Reset the cached parser for a language to reclaim WASM heap memory.
|
|
82
|
+
* The tree-sitter WASM runtime accumulates fragmented memory over thousands
|
|
83
|
+
* of parses. Deleting and recreating the Parser instance forces the WASM
|
|
84
|
+
* heap to reset, preventing "memory access out of bounds" crashes in
|
|
85
|
+
* large repos.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resetParser(language: Language): void;
|
|
88
|
+
/**
|
|
89
|
+
* Clear parser/grammar caches (useful for testing)
|
|
90
|
+
*/
|
|
91
|
+
export declare function clearParserCache(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Report grammars that failed to load.
|
|
94
|
+
*/
|
|
95
|
+
export declare function getUnavailableGrammarErrors(): Partial<Record<Language, string>>;
|
|
96
|
+
/**
|
|
97
|
+
* Get language display name
|
|
98
|
+
*/
|
|
99
|
+
export declare function getLanguageDisplayName(language: Language): string;
|
|
100
|
+
//# sourceMappingURL=grammars.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
* Recursively scan a directory for source files.
|
|
58
|
+
*
|
|
59
|
+
* In git repos, uses `git ls-files` (inherently respects .gitignore at all
|
|
60
|
+
* levels), then keeps files with a supported source extension. For non-git
|
|
61
|
+
* projects, falls back to a filesystem walk that parses .gitignore itself.
|
|
62
|
+
*/
|
|
63
|
+
export declare function scanDirectory(rootDir: string, onProgress?: (current: number, file: string) => void): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Async variant of scanDirectory that yields to the event loop periodically,
|
|
66
|
+
* allowing worker threads to receive and render progress messages.
|
|
67
|
+
*/
|
|
68
|
+
export declare function scanDirectoryAsync(rootDir: string, onProgress?: (current: number, file: string) => void): Promise<string[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Extraction orchestrator
|
|
71
|
+
*/
|
|
72
|
+
export declare class ExtractionOrchestrator {
|
|
73
|
+
private rootDir;
|
|
74
|
+
private queries;
|
|
75
|
+
/**
|
|
76
|
+
* Names of frameworks detected for this project, populated by indexAll().
|
|
77
|
+
* Passed to extractFromSource so framework-specific extractors (route nodes,
|
|
78
|
+
* middleware, etc.) run after the tree-sitter pass. Cleared if detection
|
|
79
|
+
* hasn't run yet so single-file re-index paths can detect on the spot.
|
|
80
|
+
*/
|
|
81
|
+
private detectedFrameworkNames;
|
|
82
|
+
constructor(rootDir: string, queries: QueryBuilder);
|
|
83
|
+
/**
|
|
84
|
+
* Build a filesystem-backed ResolutionContext sufficient for framework
|
|
85
|
+
* detection. Graph-query methods (getNodesByName etc.) return empty because
|
|
86
|
+
* the DB hasn't been populated yet, but detect() only uses readFile,
|
|
87
|
+
* fileExists, and getAllFiles, so that's fine.
|
|
88
|
+
*/
|
|
89
|
+
private buildDetectionContext;
|
|
90
|
+
/**
|
|
91
|
+
* Detect frameworks on demand using the current scanned files (or a fresh
|
|
92
|
+
* scan if none are provided). Cached on the orchestrator so repeat calls
|
|
93
|
+
* inside a single run don't re-scan.
|
|
94
|
+
*/
|
|
95
|
+
private ensureDetectedFrameworks;
|
|
96
|
+
/**
|
|
97
|
+
* Index all files in the project
|
|
98
|
+
*/
|
|
99
|
+
indexAll(onProgress?: (progress: IndexProgress) => void, signal?: AbortSignal, verbose?: boolean): Promise<IndexResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Index specific files
|
|
102
|
+
*/
|
|
103
|
+
indexFiles(filePaths: string[]): Promise<IndexResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Index a single file
|
|
106
|
+
*/
|
|
107
|
+
indexFile(relativePath: string): Promise<ExtractionResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Index a single file with pre-read content and stats.
|
|
110
|
+
* Used by the parallel batch reader to avoid redundant file I/O.
|
|
111
|
+
*/
|
|
112
|
+
indexFileWithContent(relativePath: string, content: string, stats: fs.Stats): Promise<ExtractionResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Store extraction result in database
|
|
115
|
+
*/
|
|
116
|
+
private storeExtractionResult;
|
|
117
|
+
/**
|
|
118
|
+
* Sync the index with the current file state.
|
|
119
|
+
*
|
|
120
|
+
* Change detection is filesystem-based, never git: a (size, mtime) stat
|
|
121
|
+
* pre-filter skips unchanged files, then a content-hash compare confirms real
|
|
122
|
+
* changes. This works in non-git projects and catches committed changes from
|
|
123
|
+
* `git pull`/`checkout`/`merge`/`rebase` that `git status` cannot see.
|
|
124
|
+
*/
|
|
125
|
+
sync(onProgress?: (progress: IndexProgress) => void): Promise<SyncResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Get files that have changed since last index.
|
|
128
|
+
* Uses git status as a fast path when available, falling back to full scan.
|
|
129
|
+
*/
|
|
130
|
+
getChangedFiles(): {
|
|
131
|
+
added: string[];
|
|
132
|
+
modified: string[];
|
|
133
|
+
removed: string[];
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export { extractFromSource } from './tree-sitter';
|
|
137
|
+
export { detectLanguage, isSourceFile, isLanguageSupported, isGrammarLoaded, getSupportedLanguages, initGrammars, loadGrammarsForLanguages, loadAllGrammars } from './grammars';
|
|
138
|
+
//# sourceMappingURL=index.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,52 @@
|
|
|
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
|
+
* Extract {% render 'snippet' %} and {% include 'snippet' %} references
|
|
29
|
+
*/
|
|
30
|
+
private extractSnippetReferences;
|
|
31
|
+
/**
|
|
32
|
+
* Extract {% section 'name' %} references
|
|
33
|
+
*/
|
|
34
|
+
private extractSectionReferences;
|
|
35
|
+
/**
|
|
36
|
+
* Extract {% schema %}...{% endschema %} blocks
|
|
37
|
+
*/
|
|
38
|
+
private extractSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Extract {% assign var = value %} statements
|
|
41
|
+
*/
|
|
42
|
+
private extractAssignments;
|
|
43
|
+
/**
|
|
44
|
+
* Get the line number for a character index
|
|
45
|
+
*/
|
|
46
|
+
private getLineNumber;
|
|
47
|
+
/**
|
|
48
|
+
* Get the character index of the start of a line
|
|
49
|
+
*/
|
|
50
|
+
private getLineStart;
|
|
51
|
+
}
|
|
52
|
+
//# 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,56 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* SvelteExtractor - Extracts code relationships from Svelte component files
|
|
4
|
+
*
|
|
5
|
+
* Svelte files are multi-language (script + template + style). Rather than
|
|
6
|
+
* parsing the full Svelte grammar, we extract the <script> block content
|
|
7
|
+
* and delegate it to the TypeScript/JavaScript TreeSitterExtractor.
|
|
8
|
+
*
|
|
9
|
+
* Also extracts function calls from template expressions (`{fn(...)}`) so
|
|
10
|
+
* cross-file call edges are captured even when calls live in markup.
|
|
11
|
+
*
|
|
12
|
+
* Every .svelte file produces a component node (Svelte components are always importable).
|
|
13
|
+
*/
|
|
14
|
+
export declare class SvelteExtractor {
|
|
15
|
+
private filePath;
|
|
16
|
+
private source;
|
|
17
|
+
private nodes;
|
|
18
|
+
private edges;
|
|
19
|
+
private unresolvedReferences;
|
|
20
|
+
private errors;
|
|
21
|
+
constructor(filePath: string, source: string);
|
|
22
|
+
/**
|
|
23
|
+
* Extract from Svelte source
|
|
24
|
+
*/
|
|
25
|
+
extract(): ExtractionResult;
|
|
26
|
+
/**
|
|
27
|
+
* Create a component node for the .svelte file
|
|
28
|
+
*/
|
|
29
|
+
private createComponentNode;
|
|
30
|
+
/**
|
|
31
|
+
* Extract <script> blocks from the Svelte source
|
|
32
|
+
*/
|
|
33
|
+
private extractScriptBlocks;
|
|
34
|
+
/**
|
|
35
|
+
* Process a script block by delegating to TreeSitterExtractor
|
|
36
|
+
*/
|
|
37
|
+
private processScriptBlock;
|
|
38
|
+
/**
|
|
39
|
+
* Extract function calls from Svelte template expressions.
|
|
40
|
+
*
|
|
41
|
+
* In Svelte, many function calls happen in markup (e.g., `class={cn(...)}`),
|
|
42
|
+
* not inside `<script>` blocks. We scan the template portion for `{expression}`
|
|
43
|
+
* blocks and extract call patterns from them.
|
|
44
|
+
*/
|
|
45
|
+
private extractTemplateCalls;
|
|
46
|
+
/**
|
|
47
|
+
* Extract component usages from the Svelte template.
|
|
48
|
+
*
|
|
49
|
+
* PascalCase tags like <Modal>, <Button />, <DevServerPreview> represent
|
|
50
|
+
* component instantiations — analogous to function calls in imperative code.
|
|
51
|
+
* Capturing these creates graph edges from parent to child components and
|
|
52
|
+
* gives codegraph_explore anchor points in the template markup.
|
|
53
|
+
*/
|
|
54
|
+
private extractTemplateComponents;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=svelte-extractor.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter Shared Helpers
|
|
3
|
+
*
|
|
4
|
+
* Utility functions used by the core TreeSitterExtractor and per-language extractors.
|
|
5
|
+
* Extracted to a leaf module to avoid circular imports between tree-sitter.ts and languages/.
|
|
6
|
+
*/
|
|
7
|
+
import { Node as SyntaxNode } from 'web-tree-sitter';
|
|
8
|
+
import { NodeKind } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Generate a unique node ID
|
|
11
|
+
*
|
|
12
|
+
* Uses a 32-character (128-bit) hash to avoid collisions when indexing
|
|
13
|
+
* large codebases with many files containing similar symbols.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateNodeId(filePath: string, kind: NodeKind, name: string, line: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Extract text from a syntax node
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNodeText(node: SyntaxNode, source: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Find a child node by field name
|
|
22
|
+
*/
|
|
23
|
+
export declare function getChildByField(node: SyntaxNode, fieldName: string): SyntaxNode | null;
|
|
24
|
+
/**
|
|
25
|
+
* Get the docstring/comment preceding a node
|
|
26
|
+
*/
|
|
27
|
+
export declare function getPrecedingDocstring(node: SyntaxNode, source: string): string | undefined;
|
|
28
|
+
//# sourceMappingURL=tree-sitter-helpers.d.ts.map
|