@vohongtho.infotech/code-intel 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -30
- package/dist/cli/main.js +3920 -1938
- package/dist/cli/main.js.map +1 -1
- package/dist/index.d.ts +48 -4
- package/dist/index.js +4770 -3844
- package/dist/index.js.map +1 -1
- package/dist/wasm/tree-sitter-dart.wasm +0 -0
- package/dist/web/assets/index-CkCM74It.js +338 -0
- package/dist/web/assets/index-eJGDkRsL.css +2 -0
- package/dist/web/index.html +13 -0
- package/package.json +19 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as web_tree_sitter from 'web-tree-sitter';
|
|
2
|
+
import { Language as Language$1, Parser, Node, Tree } from 'web-tree-sitter';
|
|
2
3
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
4
|
import express from 'express';
|
|
4
5
|
|
|
@@ -64,17 +65,41 @@ declare function createKnowledgeGraph(): KnowledgeGraph;
|
|
|
64
65
|
declare function generateNodeId(kind: NodeKind, filePath: string, qualifiedName: string): string;
|
|
65
66
|
declare function generateEdgeId(source: string, target: string, kind: string): string;
|
|
66
67
|
|
|
68
|
+
/** Initialize web-tree-sitter (idempotent). */
|
|
67
69
|
declare function initParser(): Promise<void>;
|
|
68
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Load and cache the TSLanguage WASM for a given language.
|
|
72
|
+
* Returns null when no WASM grammar is available for this language.
|
|
73
|
+
*/
|
|
69
74
|
declare function getLanguage(lang: Language): Promise<Language$1 | null>;
|
|
70
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Get a Parser instance configured for the given language.
|
|
77
|
+
* Returns null when no WASM grammar is available.
|
|
78
|
+
*/
|
|
79
|
+
declare function getParser(lang: Language): Promise<Parser | null>;
|
|
80
|
+
/**
|
|
81
|
+
* Parse source code for the given language.
|
|
82
|
+
* Returns a Tree or null when the language is unsupported / WASM fails.
|
|
83
|
+
*/
|
|
84
|
+
declare function parseSource(lang: Language, source: string): Promise<web_tree_sitter.Tree | null>;
|
|
85
|
+
/** Return true if tree-sitter is available for the given language. */
|
|
86
|
+
declare function isTreeSitterAvailable(lang: Language): Promise<boolean>;
|
|
71
87
|
|
|
72
88
|
interface QueryCapture {
|
|
73
89
|
name: string;
|
|
74
90
|
node: Node;
|
|
75
91
|
text: string;
|
|
76
92
|
}
|
|
93
|
+
interface QueryMatch {
|
|
94
|
+
patternIndex: number;
|
|
95
|
+
captures: QueryCapture[];
|
|
96
|
+
}
|
|
77
97
|
declare function runQuery(tree: Tree, language: Language$1, querySource: string): QueryCapture[];
|
|
98
|
+
/**
|
|
99
|
+
* Return all captures grouped by match, so callers can correlate captures
|
|
100
|
+
* within the same pattern match (e.g. "def.func" + "def.func.name").
|
|
101
|
+
*/
|
|
102
|
+
declare function runQueryMatches(tree: Tree, language: Language$1, querySource: string): QueryMatch[];
|
|
78
103
|
|
|
79
104
|
declare class AstCache {
|
|
80
105
|
private cache;
|
|
@@ -183,6 +208,8 @@ interface PipelineContext {
|
|
|
183
208
|
/** Per-phase progress callback — called with (phase, done, total) for each processed item */
|
|
184
209
|
onPhaseProgress?: (phase: string, done: number, total: number) => void;
|
|
185
210
|
verbose?: boolean;
|
|
211
|
+
/** Set by parse-phase after execution: which parser was used */
|
|
212
|
+
parserUsed?: 'tree-sitter' | 'regex';
|
|
186
213
|
}
|
|
187
214
|
interface Phase {
|
|
188
215
|
name: string;
|
|
@@ -281,6 +308,19 @@ declare function startMcpStdio(graph: KnowledgeGraph, repoName: string, workspac
|
|
|
281
308
|
declare function createApp(graph: KnowledgeGraph, repoName: string, workspaceRoot?: string): express.Application;
|
|
282
309
|
declare function startHttpServer(graph: KnowledgeGraph, repoName: string, port?: number, workspaceRoot?: string): void;
|
|
283
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Load graph into DB using bulk CSV COPY — dramatically faster than
|
|
313
|
+
* individual CREATE statements (10-100× speedup for large repos).
|
|
314
|
+
*
|
|
315
|
+
* Strategy:
|
|
316
|
+
* 1. Create tables
|
|
317
|
+
* 2. Write all nodes to per-table CSV files in a temp dir
|
|
318
|
+
* 3. Write all edges to per-fromTable→toTable CSV files
|
|
319
|
+
* 4. COPY each CSV file into the corresponding table
|
|
320
|
+
* 5. Clean up temp dir
|
|
321
|
+
*
|
|
322
|
+
* Falls back to individual CREATE statements per table if COPY fails.
|
|
323
|
+
*/
|
|
284
324
|
declare function loadGraphToDB(graph: KnowledgeGraph, dbManager: DbManager): Promise<{
|
|
285
325
|
nodeCount: number;
|
|
286
326
|
edgeCount: number;
|
|
@@ -304,6 +344,10 @@ interface IndexMetadata {
|
|
|
304
344
|
indexedAt: string;
|
|
305
345
|
indexVersion?: string;
|
|
306
346
|
commitHash?: string;
|
|
347
|
+
/** Parser used during analysis: 'tree-sitter' | 'regex' */
|
|
348
|
+
parser?: 'tree-sitter' | 'regex';
|
|
349
|
+
/** mtime (ms since epoch) for each indexed file path (relative to workspace root) */
|
|
350
|
+
lastAnalyzedMtimes?: Record<string, number>;
|
|
307
351
|
stats: {
|
|
308
352
|
nodes: number;
|
|
309
353
|
edges: number;
|
|
@@ -394,4 +438,4 @@ declare function queryGroup(group: RepoGroup, query: string, limit?: number): Pr
|
|
|
394
438
|
|
|
395
439
|
declare function mergeSearchResults(...perRepoResults: SearchResult[][]): SearchResult[];
|
|
396
440
|
|
|
397
|
-
export { AstCache, BindingTracker, type CallKind, type CallSite, type ClusterResult, type Contract, type ContractLink, DbManager, type EntryPoint, type FileSet, type FlowTrace, type GroupMember, type GroupQueryResult, type GroupSyncResult, type HeritageInfo, type ImportBinding, type ImportInfo, type ImportResolutionResult, type IndexMetadata, type KnowledgeGraph, type LanguageModule, type MroStrategy, type Phase, type PhaseResult, type PipelineContext, type PipelineRunResult, type QueryCapture, type RepoEntry, type RepoGroup, type Scope, type ScopeBinding, type SearchResult, addBinding, addClustersToGraph, addMember, buildCallEdges, buildHeritageEdges, classifyCall, clusterPhase, computeMRO, createApp, createKnowledgeGraph, createMcpServer, createScope, deleteGroup, detectCommunities, detectOverrides, findEntryPoints, flowPhase, generateEdgeId, generateNodeId, getAllLanguageModules, getDbPath, getLanguage, getLanguageModule, getParser, groupExists, initParser, listGroups, loadGraphToDB, loadGroup, loadMetadata, loadRegistry, loadSyncResult, mergeSearchResults, parsePhase, parseSource, queryGroup, reciprocalRankFusion, removeMember, removeRepo, resolveBinding, resolveImports, resolvePhase, runPipeline, runQuery, saveGroup, saveMetadata, saveSyncResult, scanPhase, startHttpServer, startMcpStdio, structurePhase, syncGroup, textSearch, topologicalSort, traceFlow, upsertRepo, validateDAG };
|
|
441
|
+
export { AstCache, BindingTracker, type CallKind, type CallSite, type ClusterResult, type Contract, type ContractLink, DbManager, type EntryPoint, type FileSet, type FlowTrace, type GroupMember, type GroupQueryResult, type GroupSyncResult, type HeritageInfo, type ImportBinding, type ImportInfo, type ImportResolutionResult, type IndexMetadata, type KnowledgeGraph, type LanguageModule, type MroStrategy, type Phase, type PhaseResult, type PipelineContext, type PipelineRunResult, type QueryCapture, type QueryMatch, type RepoEntry, type RepoGroup, type Scope, type ScopeBinding, type SearchResult, addBinding, addClustersToGraph, addMember, buildCallEdges, buildHeritageEdges, classifyCall, clusterPhase, computeMRO, createApp, createKnowledgeGraph, createMcpServer, createScope, deleteGroup, detectCommunities, detectOverrides, findEntryPoints, flowPhase, generateEdgeId, generateNodeId, getAllLanguageModules, getDbPath, getLanguage, getLanguageModule, getParser, groupExists, initParser, isTreeSitterAvailable, listGroups, loadGraphToDB, loadGroup, loadMetadata, loadRegistry, loadSyncResult, mergeSearchResults, parsePhase, parseSource, queryGroup, reciprocalRankFusion, removeMember, removeRepo, resolveBinding, resolveImports, resolvePhase, runPipeline, runQuery, runQueryMatches, saveGroup, saveMetadata, saveSyncResult, scanPhase, startHttpServer, startMcpStdio, structurePhase, syncGroup, textSearch, topologicalSort, traceFlow, upsertRepo, validateDAG };
|