@vohongtho.infotech/code-intel 0.8.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -66,6 +66,19 @@ declare function createKnowledgeGraph(): KnowledgeGraph;
66
66
  declare function generateNodeId(kind: NodeKind, filePath: string, qualifiedName: string): string;
67
67
  declare function generateEdgeId(source: string, target: string, kind: string): string;
68
68
 
69
+ declare class DbManager {
70
+ private db;
71
+ private conn;
72
+ private dbPath;
73
+ private readOnly;
74
+ constructor(dbPath: string, readOnly?: boolean);
75
+ init(): Promise<void>;
76
+ query(cypher: string): Promise<Record<string, unknown>[]>;
77
+ execute(cypher: string): Promise<void>;
78
+ close(): void;
79
+ get isOpen(): boolean;
80
+ }
81
+
69
82
  /** Initialize web-tree-sitter (idempotent). */
70
83
  declare function initParser(): Promise<void>;
71
84
  /**
@@ -206,6 +219,10 @@ interface PhaseResult {
206
219
  status: PipelinePhaseStatus;
207
220
  duration: number;
208
221
  message?: string;
222
+ /** v1.0.0 profiling — heap MB before phase (set by orchestrator) */
223
+ memoryBeforeMB?: number;
224
+ /** v1.0.0 profiling — heap MB after phase (set by orchestrator) */
225
+ memoryAfterMB?: number;
209
226
  }
210
227
  interface PipelineContext {
211
228
  workspaceRoot: string;
@@ -232,6 +249,8 @@ interface PipelineContext {
232
249
  summarize?: boolean;
233
250
  /** LLM provider config used by the summarize phase. */
234
251
  llmConfig?: LLMConfig;
252
+ /** v1.0.0: when true, orchestrator captures per-phase memory and writes profile.json */
253
+ profile?: boolean;
235
254
  }
236
255
  interface Phase {
237
256
  name: string;
@@ -312,6 +331,57 @@ interface SearchResult {
312
331
  declare function textSearch(graph: KnowledgeGraph, query: string, limit?: number): SearchResult[];
313
332
  declare function reciprocalRankFusion(...rankings: SearchResult[][]): SearchResult[];
314
333
 
334
+ /**
335
+ * bm25-index.ts — Epic 2: Pre-Built BM25 Inverted Index (v1.0.0)
336
+ *
337
+ * Strategy:
338
+ * - Built at analysis time (post-pipeline), stored in `.code-intel/bm25.db` (better-sqlite3).
339
+ * - Loaded into memory on `serve` startup: replaces linear O(n) scan.
340
+ * - Incremental updates: only changed nodes' terms are rewritten.
341
+ * - LIMIT pushdown: applies limit before sorting the full score list.
342
+ *
343
+ * Tables:
344
+ * bm25_index(term TEXT PK, postings TEXT) — term→[{nodeId,tf}] JSON
345
+ * bm25_doclen(node_id TEXT PK, doclen INT) — document length per node
346
+ * bm25_nodemeta(node_id TEXT PK, …) — name/kind/filePath/snippet
347
+ * bm25_meta(key TEXT PK, value TEXT) — avgdl, docCount
348
+ */
349
+
350
+ declare class Bm25Index {
351
+ private readonly dbPath;
352
+ /** In-memory inverted index (populated after `load()`). */
353
+ private readonly invertedIndex;
354
+ private readonly docLengths;
355
+ private readonly nodeMeta;
356
+ private avgdl;
357
+ private docCount;
358
+ private _loaded;
359
+ constructor(dbPath: string);
360
+ get isLoaded(): boolean;
361
+ /**
362
+ * Build the inverted index from a KnowledgeGraph and persist to SQLite.
363
+ * Called once at analysis time after the main pipeline completes.
364
+ */
365
+ build(graph: KnowledgeGraph): void;
366
+ /**
367
+ * Load the full inverted index into memory.
368
+ * Called once on `serve` startup.
369
+ */
370
+ load(): void;
371
+ /**
372
+ * BM25 search. LIMIT pushdown: scores only the posting lists for query terms,
373
+ * then partial-sorts to return only the top `limit` results.
374
+ */
375
+ search(query: string, limit: number): SearchResult[];
376
+ /**
377
+ * Incrementally update index for a set of changed/added nodes.
378
+ * Only terms that overlap with the changed nodes are rewritten.
379
+ * Works even if `load()` was not called (reads affected terms directly from DB).
380
+ */
381
+ updateNodes(nodes: CodeNode[]): void;
382
+ }
383
+ declare function getBm25DbPath(workspaceRoot: string): string;
384
+
315
385
  declare function createMcpServer(graph: KnowledgeGraph, repoName: string, workspaceRoot?: string): Server;
316
386
  declare function startMcpStdio(graph: KnowledgeGraph, repoName: string, workspaceRoot?: string): Promise<void>;
317
387
 
@@ -360,18 +430,6 @@ declare function startHttpServer(graph: KnowledgeGraph, repoName: string, port?:
360
430
  lastEventAt: number | null;
361
431
  }): Promise<HttpServerInstance>;
362
432
 
363
- declare class DbManager {
364
- private db;
365
- private conn;
366
- private dbPath;
367
- constructor(dbPath: string);
368
- init(): Promise<void>;
369
- query(cypher: string): Promise<Record<string, unknown>[]>;
370
- execute(cypher: string): Promise<void>;
371
- close(): void;
372
- get isOpen(): boolean;
373
- }
374
-
375
433
  /**
376
434
  * Load graph into DB using bulk CSV COPY — dramatically faster than
377
435
  * individual CREATE statements (10-100× speedup for large repos).
@@ -508,4 +566,4 @@ declare function queryGroup(group: RepoGroup, query: string, limit?: number): Pr
508
566
 
509
567
  declare function mergeSearchResults(...perRepoResults: SearchResult[][]): SearchResult[];
510
568
 
511
- 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 };
569
+ export { AstCache, BindingTracker, Bm25Index, 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, getBm25DbPath, 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 };