@easbot/codebase 0.3.2 → 0.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 +30 -0
- package/dist/chunks/chunk-7XCIIOM6.cjs +1 -0
- package/dist/chunks/chunk-ABKFCPSL.cjs +234 -0
- package/dist/chunks/chunk-B35QBUQP.cjs +34 -0
- package/dist/chunks/chunk-BL4XMOO2.cjs +43 -0
- package/dist/chunks/chunk-EVDJNYI2.cjs +1 -0
- package/dist/chunks/chunk-G3IYU6TZ.mjs +1 -0
- package/dist/chunks/chunk-LBEWQNER.mjs +234 -0
- package/dist/chunks/chunk-O3Z5ORQ3.mjs +43 -0
- package/dist/chunks/chunk-PSPE6FME.mjs +34 -0
- package/dist/chunks/chunk-RLZHDTHY.cjs +154 -0
- package/dist/chunks/chunk-SV4WN2DV.mjs +2 -0
- package/dist/chunks/chunk-TS4OAYIJ.cjs +1 -0
- package/dist/chunks/chunk-UEILXBZB.mjs +1 -0
- package/dist/chunks/chunk-UTKA3WG3.mjs +1 -0
- package/dist/chunks/chunk-YOFBT3V6.cjs +2 -0
- package/dist/chunks/chunk-Z4Y3VCYS.mjs +154 -0
- package/dist/chunks/code-base-ONPUU5A3.cjs +1 -0
- package/dist/chunks/code-base-XJXVJ35Z.mjs +1 -0
- package/dist/chunks/database-manager-DRLNOQ6C.cjs +1 -0
- package/dist/chunks/database-manager-WOYUSWKD.mjs +1 -0
- package/dist/chunks/file-watcher-5WEDJY6M.mjs +1 -0
- package/dist/chunks/file-watcher-LZZUEGMY.cjs +1 -0
- package/dist/chunks/stdio-server-3DPRM3WQ.cjs +47 -0
- package/dist/chunks/stdio-server-3HFZJ5G2.mjs +47 -0
- package/dist/chunks/sync-D5GNVNM2.mjs +1 -0
- package/dist/chunks/sync-IYOM3Y62.cjs +1 -0
- package/dist/cli.cjs +3 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +3 -0
- package/dist/index.cjs +1 -108
- package/dist/index.d.cts +494 -21
- package/dist/index.d.ts +494 -21
- package/dist/index.mjs +1 -108
- package/package.json +13 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { KnowledgeSearchOptions, SearchConfig, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig } from '@easbot/types';
|
|
1
|
+
import { KnowledgeSearchOptions, SearchConfig, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig, IGlobal, IInstance } from '@easbot/types';
|
|
2
2
|
export { CodebaseKnowledgeConfig, CodebaseKnowledgeConfigWithModels, SyncConfig } from '@easbot/types';
|
|
3
3
|
import { EmbeddingModelV3 } from '@ai-sdk/provider';
|
|
4
4
|
export { EmbeddingModelV3 as EmbeddingModel } from '@ai-sdk/provider';
|
|
5
5
|
|
|
6
|
+
type IndexState = 'uninitialized' | 'indexing' | 'complete' | 'partial' | 'failed' | 'stale';
|
|
6
7
|
interface FtsSearchResult {
|
|
7
8
|
id: string;
|
|
8
9
|
file_path: string;
|
|
@@ -22,7 +23,6 @@ declare class DatabaseManager {
|
|
|
22
23
|
private closed;
|
|
23
24
|
private ftsAvailable;
|
|
24
25
|
constructor(dbPath: string);
|
|
25
|
-
private openDatabase;
|
|
26
26
|
private ensureSchema;
|
|
27
27
|
private checkFtsAvailability;
|
|
28
28
|
isFtsAvailable(): boolean;
|
|
@@ -43,24 +43,54 @@ declare class DatabaseManager {
|
|
|
43
43
|
setFileHash(filePath: string, hash: string): void;
|
|
44
44
|
deleteFileHash(filePath: string): void;
|
|
45
45
|
getAllFileHashes(): FileHashRecord[];
|
|
46
|
+
checkIntegrity(): {
|
|
47
|
+
issues: Array<{
|
|
48
|
+
severity: 'error' | 'warn' | 'info';
|
|
49
|
+
message: string;
|
|
50
|
+
}>;
|
|
51
|
+
stats: {
|
|
52
|
+
nodes: number;
|
|
53
|
+
edges: number;
|
|
54
|
+
file_hashes: number;
|
|
55
|
+
fts: number;
|
|
56
|
+
node_embeddings: number;
|
|
57
|
+
embedding_cache: number;
|
|
58
|
+
parse_errors: number;
|
|
59
|
+
unresolved_refs: number;
|
|
60
|
+
name_segment_vocab: number;
|
|
61
|
+
project_metadata: number;
|
|
62
|
+
meta: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
46
65
|
getStatus(): {
|
|
47
66
|
nodeCount: number;
|
|
48
67
|
edgeCount: number;
|
|
49
68
|
indexedFiles: number;
|
|
50
69
|
dbPath: string;
|
|
51
70
|
meta: Record<string, string>;
|
|
71
|
+
indexState: IndexState;
|
|
72
|
+
extractionVersion: number;
|
|
73
|
+
isStale: boolean;
|
|
52
74
|
};
|
|
53
75
|
setLastSync(): void;
|
|
76
|
+
getIndexState(): IndexState;
|
|
77
|
+
setIndexState(state: IndexState): void;
|
|
78
|
+
markIndexed(codebasePackageVersion: string): void;
|
|
79
|
+
isIndexStale(): boolean;
|
|
80
|
+
private detectAndMarkStaleOnInit;
|
|
54
81
|
getNodeCount(): number;
|
|
55
82
|
getEdgeCount(): number;
|
|
56
83
|
getFileCount(): number;
|
|
57
84
|
getNodeById(id: string): Node | null;
|
|
58
85
|
getEdgeById(id: string): Edge | null;
|
|
59
|
-
clearAll(
|
|
86
|
+
clearAll(options?: {
|
|
87
|
+
keepEmbeddings?: boolean;
|
|
88
|
+
}): void;
|
|
60
89
|
getCachedEmbedding(contentHash: string): Float32Array | null;
|
|
61
90
|
getVectorDims(): number | undefined;
|
|
62
91
|
ensureVectorDims(dims: number): void;
|
|
63
92
|
cacheEmbedding(contentHash: string, embedding: Float32Array): void;
|
|
93
|
+
private deleteEmbeddingsByFile;
|
|
64
94
|
getAllNodeEmbeddings(): Array<{
|
|
65
95
|
node_id: string;
|
|
66
96
|
embedding: Buffer;
|
|
@@ -70,6 +100,41 @@ declare class DatabaseManager {
|
|
|
70
100
|
embeddingText: string;
|
|
71
101
|
embedding: Float32Array;
|
|
72
102
|
}>): void;
|
|
103
|
+
insertParseError(record: {
|
|
104
|
+
filePath: string;
|
|
105
|
+
language: string;
|
|
106
|
+
stage: string;
|
|
107
|
+
message: string;
|
|
108
|
+
line?: number;
|
|
109
|
+
}): number;
|
|
110
|
+
insertUnresolvedRef(record: {
|
|
111
|
+
fromNodeId?: string;
|
|
112
|
+
referenceName: string;
|
|
113
|
+
referenceKind: string;
|
|
114
|
+
line?: number;
|
|
115
|
+
col?: number;
|
|
116
|
+
filePath: string;
|
|
117
|
+
language: string;
|
|
118
|
+
candidates?: string[];
|
|
119
|
+
}): number;
|
|
120
|
+
insertUnresolvedRefsBatch(records: Array<{
|
|
121
|
+
fromNodeId?: string;
|
|
122
|
+
referenceName: string;
|
|
123
|
+
referenceKind: string;
|
|
124
|
+
line?: number;
|
|
125
|
+
col?: number;
|
|
126
|
+
filePath: string;
|
|
127
|
+
language: string;
|
|
128
|
+
candidates?: string[];
|
|
129
|
+
}>): number;
|
|
130
|
+
insertNameSegment(segment: string, name: string): number;
|
|
131
|
+
insertNameSegmentsBatch(pairs: Array<{
|
|
132
|
+
segment: string;
|
|
133
|
+
name: string;
|
|
134
|
+
}>): number;
|
|
135
|
+
setProjectMetadata(key: string, value: string): number;
|
|
136
|
+
getNodeIdsByFile(filePath: string): string[];
|
|
137
|
+
deleteFtsByFile(filePath: string): number;
|
|
73
138
|
initialize(): void;
|
|
74
139
|
close(): void;
|
|
75
140
|
isClosed(): boolean;
|
|
@@ -77,6 +142,7 @@ declare class DatabaseManager {
|
|
|
77
142
|
transaction<T>(fn: () => T): T;
|
|
78
143
|
getMeta(key: string): string | null;
|
|
79
144
|
setMeta(key: string, value: string): void;
|
|
145
|
+
deleteMeta(key: string): void;
|
|
80
146
|
}
|
|
81
147
|
|
|
82
148
|
type ParserInstance = any;
|
|
@@ -153,7 +219,7 @@ declare function getParserManager(): Promise<ParserManager>;
|
|
|
153
219
|
declare function resetParserManager(): void;
|
|
154
220
|
|
|
155
221
|
type CodeSearchSource = 'fts' | 'structural' | 'vector' | 'basic';
|
|
156
|
-
interface SearchResult extends BaseSearchResult {
|
|
222
|
+
interface SearchResult$1 extends BaseSearchResult {
|
|
157
223
|
id: string;
|
|
158
224
|
name: string;
|
|
159
225
|
astType: string;
|
|
@@ -166,7 +232,7 @@ interface SearchResult extends BaseSearchResult {
|
|
|
166
232
|
endCol: number;
|
|
167
233
|
source: CodeSearchSource;
|
|
168
234
|
}
|
|
169
|
-
interface HybridSearchResult extends SearchResult {
|
|
235
|
+
interface HybridSearchResult extends SearchResult$1 {
|
|
170
236
|
vectorScore?: number;
|
|
171
237
|
ftsScore?: number;
|
|
172
238
|
hybridScore: number;
|
|
@@ -197,8 +263,6 @@ declare class QueryInterface {
|
|
|
197
263
|
private getEdgesForNode;
|
|
198
264
|
private embedText;
|
|
199
265
|
private cosineSimilarity;
|
|
200
|
-
private structuralSearch;
|
|
201
|
-
private calculateNameSimilarity;
|
|
202
266
|
private normalizeScore;
|
|
203
267
|
queryNodes(filter: NodeQueryFilter): Node[];
|
|
204
268
|
queryEdges(filter: EdgeQueryFilter): Edge[];
|
|
@@ -215,6 +279,8 @@ declare class QueryInterface {
|
|
|
215
279
|
ancestors: Node[];
|
|
216
280
|
descendants: Node[];
|
|
217
281
|
};
|
|
282
|
+
queryMembers(nodeId: string, relation?: 'HAS_METHOD' | 'HAS_PROPERTY' | Array<'HAS_METHOD' | 'HAS_PROPERTY'>): Node[];
|
|
283
|
+
queryOverrides(nodeId: string): Node[];
|
|
218
284
|
getNode(nodeId: string): Node | null;
|
|
219
285
|
getEdge(edgeId: string): Edge | null;
|
|
220
286
|
}
|
|
@@ -223,7 +289,7 @@ declare function createQueryInterface(db: DatabaseManager): QueryInterface;
|
|
|
223
289
|
type CodebaseConfig = CodebaseKnowledgeConfigWithModels;
|
|
224
290
|
type Language = 'ts' | 'tsx' | 'js' | 'py' | 'rs' | 'go' | 'c' | 'cpp' | 'csharp' | 'java' | 'scala' | 'ruby' | 'php' | 'zig';
|
|
225
291
|
declare const FILE_EXTENSION_MAP: Record<string, Language>;
|
|
226
|
-
type RelationType = 'CONTAINS' | 'CALLS' | '
|
|
292
|
+
type RelationType = 'CONTAINS' | 'CALLS' | 'IMPORTS' | 'TYPE_REFERENCES' | 'ANNOTATES' | 'EXTENDS' | 'IMPLEMENTS' | 'HAS_METHOD' | 'HAS_PROPERTY' | 'METHOD_OVERRIDES';
|
|
227
293
|
type ASTNodeType = 'class_declaration' | 'function_declaration' | 'method_declaration' | 'method_definition' | 'variable_declaration' | 'import_declaration' | 'import_statement' | 'interface_declaration' | 'type_alias_declaration' | 'enum_declaration' | 'struct_item' | 'impl_item' | 'trait_item' | 'function_definition' | 'function_item' | 'class_definition' | 'module' | 'identifier' | 'type_identifier' | 'property_identifier' | 'field_identifier' | 'call_expression' | 'new_expression' | 'member_expression' | 'assignment_expression' | 'binary_expression' | 'unary_expression' | 'arrow_function' | 'function_expression' | 'lexical_declaration' | 'variable_declarator' | 'formal_parameters' | 'parameter' | 'required_parameter' | 'optional_parameter' | 'rest_parameter' | 'object_type' | 'array_type' | 'union_type' | 'intersection_type' | 'literal_type' | 'generic_type' | 'named_imports' | 'import_clause' | 'export_statement' | 'export_clause' | 'decorator' | 'attribute_item' | 'macro_definition' | 'macro_invocation' | 'namespace_definition' | 'using_directive' | 'class_heredoc' | 'trait_adaptations' | 'namespace_declaration' | 'define_directive' | 'preproc_if' | 'preproc_function_def';
|
|
228
294
|
interface Node {
|
|
229
295
|
id: string;
|
|
@@ -265,6 +331,9 @@ interface ExtractedEdge {
|
|
|
265
331
|
source: string;
|
|
266
332
|
target: string;
|
|
267
333
|
relation: RelationType;
|
|
334
|
+
line?: number;
|
|
335
|
+
col?: number;
|
|
336
|
+
filePath?: string;
|
|
268
337
|
}
|
|
269
338
|
type CodeKnowledgeGraphConfig = CodebaseKnowledgeConfig;
|
|
270
339
|
interface NodeQueryFilter {
|
|
@@ -308,6 +377,7 @@ interface SyncResult {
|
|
|
308
377
|
filesSkipped: number;
|
|
309
378
|
nodesCreated: number;
|
|
310
379
|
edgesCreated: number;
|
|
380
|
+
skipped?: boolean;
|
|
311
381
|
errors: Array<{
|
|
312
382
|
filePath: string;
|
|
313
383
|
error: string;
|
|
@@ -322,6 +392,11 @@ interface GraphStatus {
|
|
|
322
392
|
workspaceDir: string;
|
|
323
393
|
meta: Record<string, string>;
|
|
324
394
|
healthy: boolean;
|
|
395
|
+
indexState?: IndexState;
|
|
396
|
+
extractionVersion?: number;
|
|
397
|
+
isStale?: boolean;
|
|
398
|
+
indexedWithVersion?: string;
|
|
399
|
+
lastSync?: string;
|
|
325
400
|
}
|
|
326
401
|
interface HealthCheckResult {
|
|
327
402
|
healthy: boolean;
|
|
@@ -378,6 +453,8 @@ interface ICodebase {
|
|
|
378
453
|
ancestors: Node[];
|
|
379
454
|
descendants: Node[];
|
|
380
455
|
}>;
|
|
456
|
+
queryMembers(nodeId: string, relation?: 'HAS_METHOD' | 'HAS_PROPERTY' | Array<'HAS_METHOD' | 'HAS_PROPERTY'>): Promise<Node[]>;
|
|
457
|
+
queryOverrides(nodeId: string): Promise<Node[]>;
|
|
381
458
|
getNode(nodeId: string): Promise<Node | null>;
|
|
382
459
|
getEdge(edgeId: string): Promise<Edge | null>;
|
|
383
460
|
getStatus(): Promise<GraphStatus>;
|
|
@@ -456,11 +533,12 @@ declare class NodeExtractor {
|
|
|
456
533
|
extractNodes(tree: ParseTree, source: string, language: Language, filePath: string): ExtractedNode[];
|
|
457
534
|
private walkTree;
|
|
458
535
|
private extractNode;
|
|
536
|
+
private extractParameterTypes;
|
|
537
|
+
private findTypeInNode;
|
|
459
538
|
private getNodeName;
|
|
460
539
|
private findNameInChildren;
|
|
461
540
|
private findNameInGrandchildren;
|
|
462
541
|
private extractImportName;
|
|
463
|
-
private normalizeAstType;
|
|
464
542
|
private getNodeText;
|
|
465
543
|
generateNodeId(node: ExtractedNode): string;
|
|
466
544
|
}
|
|
@@ -471,28 +549,97 @@ declare class EdgeExtractor {
|
|
|
471
549
|
private extractContainsEdges;
|
|
472
550
|
private extractCallEdges;
|
|
473
551
|
private extractInheritanceEdges;
|
|
552
|
+
private collectTypeAnnotations;
|
|
553
|
+
private collectNamedIdentifiers;
|
|
554
|
+
private extractClauseNames;
|
|
474
555
|
private extractImportEdges;
|
|
475
556
|
private walkTree;
|
|
476
557
|
private findEnclosingFunction;
|
|
477
558
|
private extractCalleeName;
|
|
478
|
-
private
|
|
479
|
-
private
|
|
480
|
-
private
|
|
481
|
-
private extractIdentifier;
|
|
482
|
-
private extractIdentifiers;
|
|
483
|
-
private extractImportPath;
|
|
559
|
+
private extractImportPaths;
|
|
560
|
+
private extractPythonImportPaths;
|
|
561
|
+
private extractImportWholePath;
|
|
484
562
|
generateNodeId(node: ExtractedNode): string;
|
|
485
563
|
private extractTypeReferences;
|
|
486
|
-
private
|
|
487
|
-
private
|
|
564
|
+
private extractHasMethodEdges;
|
|
565
|
+
private extractHasPropertyEdges;
|
|
566
|
+
private emitContainerToMemberEdges;
|
|
567
|
+
private extractOverrideEdges;
|
|
568
|
+
private collectMemberIdsByName;
|
|
569
|
+
private buildImportAliasMap;
|
|
570
|
+
private findEnclosingClass;
|
|
488
571
|
private extractAnnotationEdges;
|
|
489
572
|
private extractTypeName;
|
|
490
573
|
private resolveTypeNodeId;
|
|
491
574
|
private generateNodeIdFromName;
|
|
492
|
-
private findChildrenByType;
|
|
493
575
|
}
|
|
494
576
|
declare function createEdgeExtractor(): EdgeExtractor;
|
|
495
577
|
|
|
578
|
+
interface WriteStatement {
|
|
579
|
+
sql: string;
|
|
580
|
+
params: unknown[];
|
|
581
|
+
}
|
|
582
|
+
interface AsyncWriteBackendOptions {
|
|
583
|
+
dbPath: string;
|
|
584
|
+
mock?: boolean;
|
|
585
|
+
batchSize?: number;
|
|
586
|
+
batchIntervalMs?: number;
|
|
587
|
+
queueMax?: number;
|
|
588
|
+
}
|
|
589
|
+
declare class AsyncWriteBackend {
|
|
590
|
+
private worker;
|
|
591
|
+
private readonly mock;
|
|
592
|
+
private readonly dbPath;
|
|
593
|
+
private readonly batchSize;
|
|
594
|
+
private readonly batchIntervalMs;
|
|
595
|
+
private readonly queueMax;
|
|
596
|
+
private bufferedStatements;
|
|
597
|
+
private pendingRequests;
|
|
598
|
+
private nextRequestId;
|
|
599
|
+
private flushTimer;
|
|
600
|
+
readonly ready: Promise<void>;
|
|
601
|
+
private disposed;
|
|
602
|
+
constructor(options: AsyncWriteBackendOptions);
|
|
603
|
+
private installAckHandler;
|
|
604
|
+
private waitForReady;
|
|
605
|
+
waitReady(): Promise<void>;
|
|
606
|
+
enqueue(statements: WriteStatement[]): void;
|
|
607
|
+
private flushBuffer;
|
|
608
|
+
flush(timeoutMs?: number): Promise<void>;
|
|
609
|
+
dispose(): Promise<void>;
|
|
610
|
+
pendingCount(): number;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare class WriteProxy {
|
|
614
|
+
private readonly db;
|
|
615
|
+
private readonly writeBackend;
|
|
616
|
+
private readonly options;
|
|
617
|
+
constructor(db: DatabaseManager, writeBackend: AsyncWriteBackend, options?: {
|
|
618
|
+
ftsAvailable?: boolean;
|
|
619
|
+
});
|
|
620
|
+
insertNodes(nodes: Node[]): void;
|
|
621
|
+
insertEdges(edges: Edge[]): void;
|
|
622
|
+
setFileHash(filePath: string, hash: string): void;
|
|
623
|
+
setLastSync(): void;
|
|
624
|
+
cacheEmbedding(contentHash: string, embedding: Float32Array): void;
|
|
625
|
+
storeNodeEmbeddings(embeddings: Array<{
|
|
626
|
+
nodeId: string;
|
|
627
|
+
embeddingText: string;
|
|
628
|
+
embedding: Float32Array;
|
|
629
|
+
}>): void;
|
|
630
|
+
deleteEdgesByFile(filePath: string): number;
|
|
631
|
+
deleteNodesByFile(filePath: string): number;
|
|
632
|
+
deleteFtsByFile(filePath: string): number;
|
|
633
|
+
deleteFileHash(filePath: string): void;
|
|
634
|
+
flush(): Promise<void>;
|
|
635
|
+
setMeta(key: string, value: string): void;
|
|
636
|
+
deleteMeta(key: string): void;
|
|
637
|
+
markIndexed(codebasePackageVersion: string, extractionVersion: number, timestamp: string): void;
|
|
638
|
+
setIndexState(state: 'uninitialized' | 'indexing' | 'complete' | 'partial' | 'failed' | 'stale'): void;
|
|
639
|
+
dispose(): Promise<void>;
|
|
640
|
+
pendingCount(): number;
|
|
641
|
+
}
|
|
642
|
+
|
|
496
643
|
interface IndexerConfig {
|
|
497
644
|
workspaceDir: string;
|
|
498
645
|
batchSize: number;
|
|
@@ -506,17 +653,25 @@ declare class Indexer {
|
|
|
506
653
|
private nodeExtractor;
|
|
507
654
|
private edgeExtractor;
|
|
508
655
|
private config;
|
|
509
|
-
|
|
656
|
+
private writeProxy;
|
|
657
|
+
constructor(db: DatabaseManager, parserManager: ParserManager, config: IndexerConfig, writeProxy?: WriteProxy);
|
|
658
|
+
flushPendingWrites(): Promise<void>;
|
|
659
|
+
private get dbWriter();
|
|
510
660
|
private generateNodeEmbeddingText;
|
|
511
661
|
private embedText;
|
|
512
662
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
513
663
|
indexDirectory(dir?: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
514
664
|
sync(progress?: ProgressCallback): Promise<SyncResult>;
|
|
515
665
|
private scanFiles;
|
|
666
|
+
private loadGitignore;
|
|
667
|
+
private toRelativePosix;
|
|
516
668
|
private readFile;
|
|
517
669
|
private computeHash;
|
|
518
670
|
private storeNodes;
|
|
671
|
+
private storeNameSegments;
|
|
672
|
+
private splitIdentifier;
|
|
519
673
|
private storeEdges;
|
|
674
|
+
private storeUnresolvedRefs;
|
|
520
675
|
private getValidEdgeCount;
|
|
521
676
|
private embedNodes;
|
|
522
677
|
private chunkArray;
|
|
@@ -526,6 +681,8 @@ declare function createIndexer(db: DatabaseManager, parserManager: ParserManager
|
|
|
526
681
|
declare class CodeBase implements ICodebase {
|
|
527
682
|
private config;
|
|
528
683
|
private db;
|
|
684
|
+
private writeBackend;
|
|
685
|
+
private writeProxy;
|
|
529
686
|
private parserManager;
|
|
530
687
|
private indexer;
|
|
531
688
|
private queryInterface;
|
|
@@ -533,6 +690,9 @@ declare class CodeBase implements ICodebase {
|
|
|
533
690
|
private dirty;
|
|
534
691
|
private syncTimer?;
|
|
535
692
|
private syncingInProgress;
|
|
693
|
+
private codebasePackageVersion;
|
|
694
|
+
private fileWatcher;
|
|
695
|
+
private get dbWriter();
|
|
536
696
|
constructor(config?: Partial<CodebaseConfig>);
|
|
537
697
|
initialize(): Promise<void>;
|
|
538
698
|
private startSyncTimer;
|
|
@@ -544,6 +704,13 @@ declare class CodeBase implements ICodebase {
|
|
|
544
704
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
545
705
|
indexDirectory(dir?: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
546
706
|
sync(progress?: ProgressCallback): Promise<SyncResult>;
|
|
707
|
+
watch(options?: {
|
|
708
|
+
ignorePatterns?: string[];
|
|
709
|
+
debounceMs?: number;
|
|
710
|
+
initialSync?: boolean;
|
|
711
|
+
}): Promise<{
|
|
712
|
+
stop(): Promise<void>;
|
|
713
|
+
}>;
|
|
547
714
|
search(query: string, options?: SearchOptions): Promise<NodeWithEdges[]>;
|
|
548
715
|
queryNodes(filter: NodeQueryFilter): Promise<Node[]>;
|
|
549
716
|
queryEdges(filter: EdgeQueryFilter): Promise<Edge[]>;
|
|
@@ -559,17 +726,323 @@ declare class CodeBase implements ICodebase {
|
|
|
559
726
|
ancestors: Node[];
|
|
560
727
|
descendants: Node[];
|
|
561
728
|
}>;
|
|
729
|
+
queryMembers(nodeId: string, relation?: 'HAS_METHOD' | 'HAS_PROPERTY' | Array<'HAS_METHOD' | 'HAS_PROPERTY'>): Promise<Node[]>;
|
|
730
|
+
queryOverrides(nodeId: string): Promise<Node[]>;
|
|
562
731
|
getNode(nodeId: string): Promise<Node | null>;
|
|
563
732
|
getEdge(edgeId: string): Promise<Edge | null>;
|
|
564
733
|
getStatus(): Promise<GraphStatus>;
|
|
565
734
|
healthCheck(): Promise<HealthCheckResult>;
|
|
566
|
-
clear(
|
|
735
|
+
clear(options?: {
|
|
736
|
+
keepEmbeddings?: boolean;
|
|
737
|
+
}): Promise<void>;
|
|
567
738
|
close(): Promise<void>;
|
|
568
739
|
private ensureInitialized;
|
|
569
740
|
getDatabase(): DatabaseManager;
|
|
570
741
|
getParser(): ParserManager;
|
|
571
742
|
getQuery(): QueryInterface;
|
|
743
|
+
getWorkspaceDir(): string;
|
|
572
744
|
}
|
|
573
745
|
declare function createCodebase(config?: Partial<CodebaseConfig>): Promise<ICodebase>;
|
|
574
746
|
|
|
575
|
-
|
|
747
|
+
interface CodebaseCliDeps {
|
|
748
|
+
version?: string;
|
|
749
|
+
cwd?: string;
|
|
750
|
+
}
|
|
751
|
+
interface CodebaseCliResult {
|
|
752
|
+
code: number;
|
|
753
|
+
handled: boolean;
|
|
754
|
+
command?: string;
|
|
755
|
+
}
|
|
756
|
+
declare function renderBanner(): void;
|
|
757
|
+
declare function renderHelp(): void;
|
|
758
|
+
declare function handleCodebaseCli(args: string[], _deps?: CodebaseCliDeps): Promise<CodebaseCliResult>;
|
|
759
|
+
|
|
760
|
+
interface FormattedNode {
|
|
761
|
+
id: string;
|
|
762
|
+
name: string;
|
|
763
|
+
astType: string;
|
|
764
|
+
language: string;
|
|
765
|
+
filePath: string;
|
|
766
|
+
startLine: number;
|
|
767
|
+
endLine: number;
|
|
768
|
+
isExported: boolean;
|
|
769
|
+
modifiers: string[];
|
|
770
|
+
}
|
|
771
|
+
interface FormattedEdge {
|
|
772
|
+
id: string;
|
|
773
|
+
source: string;
|
|
774
|
+
target: string;
|
|
775
|
+
relation: string;
|
|
776
|
+
direction?: 'in' | 'out';
|
|
777
|
+
}
|
|
778
|
+
interface FormattedSearchHit {
|
|
779
|
+
node: FormattedNode;
|
|
780
|
+
source: string;
|
|
781
|
+
score: number;
|
|
782
|
+
snippet: string;
|
|
783
|
+
edges: FormattedEdge[];
|
|
784
|
+
}
|
|
785
|
+
declare function formatCodebaseNode(node: Node): FormattedNode;
|
|
786
|
+
declare function formatCodebaseEdge(edge: Edge, direction?: 'in' | 'out'): FormattedEdge;
|
|
787
|
+
declare function formatCodebaseSearchHits(nodes: Array<Node & {
|
|
788
|
+
edges?: Edge[];
|
|
789
|
+
}>, sources: string[], scores: number[]): FormattedSearchHit[];
|
|
790
|
+
declare function emptyFormattedNode(): FormattedNode;
|
|
791
|
+
|
|
792
|
+
interface PendingFile {
|
|
793
|
+
path: string;
|
|
794
|
+
lastEventAt: number;
|
|
795
|
+
}
|
|
796
|
+
interface RenderOptions {
|
|
797
|
+
pendingFiles?: PendingFile[];
|
|
798
|
+
toolName: string;
|
|
799
|
+
softLimit?: number;
|
|
800
|
+
hardCeiling?: number;
|
|
801
|
+
sync?: boolean;
|
|
802
|
+
writeToDisk?: boolean;
|
|
803
|
+
}
|
|
804
|
+
interface ImpactBucket {
|
|
805
|
+
depth: number;
|
|
806
|
+
count: number;
|
|
807
|
+
riskLabel: string;
|
|
808
|
+
samples: Array<{
|
|
809
|
+
name: string;
|
|
810
|
+
file: string;
|
|
811
|
+
line: number;
|
|
812
|
+
relation: string;
|
|
813
|
+
}>;
|
|
814
|
+
}
|
|
815
|
+
interface ContextInput {
|
|
816
|
+
root: FormattedNode;
|
|
817
|
+
incoming: FormattedEdge[];
|
|
818
|
+
outgoing: FormattedEdge[];
|
|
819
|
+
neighbors: Array<{
|
|
820
|
+
node: FormattedNode;
|
|
821
|
+
depth: number;
|
|
822
|
+
}>;
|
|
823
|
+
}
|
|
824
|
+
declare function renderSearchResult(hits: FormattedSearchHit[], options: RenderOptions): Promise<string>;
|
|
825
|
+
declare function renderImpact(root: FormattedNode, buckets: ImpactBucket[], options: RenderOptions): Promise<string>;
|
|
826
|
+
declare function defaultRiskLabel(depth: number): string;
|
|
827
|
+
declare function renderContext(input: ContextInput, options: RenderOptions): Promise<string>;
|
|
828
|
+
declare function renderNode(node: FormattedNode, edges: FormattedEdge[], options: RenderOptions): Promise<string>;
|
|
829
|
+
|
|
830
|
+
declare const SECTION_MARKER = "**`";
|
|
831
|
+
declare const SECTION_END = "**";
|
|
832
|
+
interface TruncateOptions {
|
|
833
|
+
softLimit?: number;
|
|
834
|
+
hardCeiling?: number;
|
|
835
|
+
toolName?: string;
|
|
836
|
+
writeToDisk?: boolean;
|
|
837
|
+
}
|
|
838
|
+
type TruncateResult = {
|
|
839
|
+
content: string;
|
|
840
|
+
truncated: false;
|
|
841
|
+
} | {
|
|
842
|
+
content: string;
|
|
843
|
+
truncated: true;
|
|
844
|
+
outputPath: string;
|
|
845
|
+
hint: string;
|
|
846
|
+
info: string;
|
|
847
|
+
};
|
|
848
|
+
declare function truncateAtSectionBoundary(text: string, options?: TruncateOptions): Promise<TruncateResult>;
|
|
849
|
+
declare function truncateAtSectionBoundarySync(text: string, options?: TruncateOptions): TruncateResult;
|
|
850
|
+
|
|
851
|
+
interface ServiceContext {
|
|
852
|
+
workspaceDir: string;
|
|
853
|
+
rootDir: string;
|
|
854
|
+
}
|
|
855
|
+
type NodeKind = 'function' | 'method' | 'class' | 'interface' | 'type' | 'variable' | 'route' | 'component' | 'const';
|
|
856
|
+
interface SearchParams {
|
|
857
|
+
query?: string;
|
|
858
|
+
kind?: NodeKind | string;
|
|
859
|
+
file?: string;
|
|
860
|
+
intent?: string;
|
|
861
|
+
includeContent?: boolean;
|
|
862
|
+
maxResults?: number;
|
|
863
|
+
language?: Language;
|
|
864
|
+
astType?: string;
|
|
865
|
+
enableFts?: boolean;
|
|
866
|
+
enableEmbedding?: boolean;
|
|
867
|
+
}
|
|
868
|
+
interface SearchHit {
|
|
869
|
+
node: Node;
|
|
870
|
+
edges: Edge[];
|
|
871
|
+
source: string;
|
|
872
|
+
score: number;
|
|
873
|
+
snippet: string;
|
|
874
|
+
}
|
|
875
|
+
interface SearchResult {
|
|
876
|
+
total: number;
|
|
877
|
+
hits: SearchHit[];
|
|
878
|
+
durationMs: number;
|
|
879
|
+
truncated: boolean;
|
|
880
|
+
}
|
|
881
|
+
interface NodeParams {
|
|
882
|
+
name?: string;
|
|
883
|
+
nodeId?: string;
|
|
884
|
+
file?: string;
|
|
885
|
+
kind?: string;
|
|
886
|
+
includeEdges?: boolean;
|
|
887
|
+
includeContent?: boolean;
|
|
888
|
+
edgesLimit?: number;
|
|
889
|
+
}
|
|
890
|
+
interface NodeResult {
|
|
891
|
+
node: Node | null;
|
|
892
|
+
edges: Edge[];
|
|
893
|
+
ambiguous?: Array<{
|
|
894
|
+
node: Node;
|
|
895
|
+
score: number;
|
|
896
|
+
}>;
|
|
897
|
+
}
|
|
898
|
+
interface ContextParams {
|
|
899
|
+
name?: string;
|
|
900
|
+
nodeId?: string;
|
|
901
|
+
file?: string;
|
|
902
|
+
kind?: string;
|
|
903
|
+
depth?: number;
|
|
904
|
+
maxNodes?: number;
|
|
905
|
+
direction?: 'incoming' | 'outgoing' | 'both';
|
|
906
|
+
relationTypes?: RelationType[];
|
|
907
|
+
}
|
|
908
|
+
interface ContextNode {
|
|
909
|
+
node: Node;
|
|
910
|
+
depth: number;
|
|
911
|
+
}
|
|
912
|
+
interface ContextResult {
|
|
913
|
+
root: Node | null;
|
|
914
|
+
nodes: ContextNode[];
|
|
915
|
+
edges: Edge[];
|
|
916
|
+
truncated: boolean;
|
|
917
|
+
totalNodes: number;
|
|
918
|
+
totalEdges: number;
|
|
919
|
+
}
|
|
920
|
+
interface ImpactParams {
|
|
921
|
+
name?: string;
|
|
922
|
+
nodeId?: string;
|
|
923
|
+
file?: string;
|
|
924
|
+
kind?: string;
|
|
925
|
+
depth?: number;
|
|
926
|
+
relationTypes?: RelationType[];
|
|
927
|
+
maxResults?: number;
|
|
928
|
+
}
|
|
929
|
+
interface ImpactBucketEntry {
|
|
930
|
+
depth: number;
|
|
931
|
+
count: number;
|
|
932
|
+
sample: Array<{
|
|
933
|
+
id: string;
|
|
934
|
+
name: string;
|
|
935
|
+
filePath: string;
|
|
936
|
+
relation: string;
|
|
937
|
+
}>;
|
|
938
|
+
}
|
|
939
|
+
interface ImpactResult {
|
|
940
|
+
root: Node | null;
|
|
941
|
+
totalImpacted: number;
|
|
942
|
+
buckets: ImpactBucketEntry[];
|
|
943
|
+
}
|
|
944
|
+
interface CallersParams {
|
|
945
|
+
name?: string;
|
|
946
|
+
nodeId?: string;
|
|
947
|
+
file?: string;
|
|
948
|
+
kind?: string;
|
|
949
|
+
relationTypes?: RelationType[];
|
|
950
|
+
maxResults?: number;
|
|
951
|
+
}
|
|
952
|
+
interface CallerEntry {
|
|
953
|
+
id: string;
|
|
954
|
+
name: string;
|
|
955
|
+
astType: string;
|
|
956
|
+
filePath: string;
|
|
957
|
+
startLine: number;
|
|
958
|
+
relation: string;
|
|
959
|
+
}
|
|
960
|
+
interface CallersResult {
|
|
961
|
+
root: Node | null;
|
|
962
|
+
callers: CallerEntry[];
|
|
963
|
+
truncated: boolean;
|
|
964
|
+
}
|
|
965
|
+
interface CalleesParams extends CallersParams {
|
|
966
|
+
}
|
|
967
|
+
interface CalleesResult extends CallersResult {
|
|
968
|
+
}
|
|
969
|
+
interface ExploreParams {
|
|
970
|
+
query: string;
|
|
971
|
+
file?: string;
|
|
972
|
+
kind?: string;
|
|
973
|
+
maxFiles?: number;
|
|
974
|
+
maxSymbols?: number;
|
|
975
|
+
depth?: number;
|
|
976
|
+
includeContent?: boolean;
|
|
977
|
+
intent?: string;
|
|
978
|
+
}
|
|
979
|
+
interface ExploreEntryPoint {
|
|
980
|
+
file: string;
|
|
981
|
+
symbols: Array<{
|
|
982
|
+
node: Node;
|
|
983
|
+
callers: CallerEntry[];
|
|
984
|
+
callees: CallerEntry[];
|
|
985
|
+
}>;
|
|
986
|
+
}
|
|
987
|
+
interface ExploreResult {
|
|
988
|
+
query: string;
|
|
989
|
+
entryPoints: ExploreEntryPoint[];
|
|
990
|
+
totalHits: number;
|
|
991
|
+
}
|
|
992
|
+
interface StatusParams {
|
|
993
|
+
}
|
|
994
|
+
type StatusResult = GraphStatus;
|
|
995
|
+
interface DoctorParams {
|
|
996
|
+
}
|
|
997
|
+
type DoctorResult = HealthCheckResult;
|
|
998
|
+
declare class ServiceError extends Error {
|
|
999
|
+
readonly code: 'NOT_FOUND' | 'AMBIGUOUS' | 'INTERNAL' | 'NOT_INDEXED';
|
|
1000
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
1001
|
+
constructor(message: string, code: 'NOT_FOUND' | 'AMBIGUOUS' | 'INTERNAL' | 'NOT_INDEXED', details?: Record<string, unknown> | undefined);
|
|
1002
|
+
}
|
|
1003
|
+
declare class NotFoundError extends ServiceError {
|
|
1004
|
+
constructor(name: string, candidates?: Array<{
|
|
1005
|
+
node: Node;
|
|
1006
|
+
score: number;
|
|
1007
|
+
}>);
|
|
1008
|
+
}
|
|
1009
|
+
declare class AmbiguousError extends ServiceError {
|
|
1010
|
+
constructor(name: string, candidates: Array<{
|
|
1011
|
+
node: Node;
|
|
1012
|
+
score: number;
|
|
1013
|
+
}>);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
declare function renderSearch(nodes: NodeWithEdges[], options: RenderOptions): Promise<string>;
|
|
1017
|
+
declare function renderImpactFromTuples(root: Node, tuples: Array<{
|
|
1018
|
+
source: Node;
|
|
1019
|
+
relation: string;
|
|
1020
|
+
}>, options: RenderOptions): Promise<string>;
|
|
1021
|
+
declare function renderContextFromQuery(root: Node, incoming: Edge[], outgoing: Edge[], neighbors: Node[], options: RenderOptions): Promise<string>;
|
|
1022
|
+
declare function renderNodeDetail(node: Node | null, edges: Edge[], options: RenderOptions): Promise<string>;
|
|
1023
|
+
declare function renderExploreFromResult(result: ExploreResult, options: RenderOptions): Promise<string>;
|
|
1024
|
+
|
|
1025
|
+
declare function search(ctx: ServiceContext, params: SearchParams): Promise<SearchResult>;
|
|
1026
|
+
declare function node(ctx: ServiceContext, params: NodeParams): Promise<NodeResult>;
|
|
1027
|
+
declare function context(ctx: ServiceContext, params: ContextParams): Promise<ContextResult>;
|
|
1028
|
+
declare function impact(ctx: ServiceContext, params: ImpactParams): Promise<ImpactResult>;
|
|
1029
|
+
declare function callers(ctx: ServiceContext, params: CallersParams): Promise<CallersResult>;
|
|
1030
|
+
declare function callees(ctx: ServiceContext, params: CalleesParams): Promise<CalleesResult>;
|
|
1031
|
+
declare function explore(ctx: ServiceContext, params: ExploreParams): Promise<ExploreResult>;
|
|
1032
|
+
declare function status(ctx: ServiceContext, _params: StatusParams): Promise<StatusResult>;
|
|
1033
|
+
declare function doctor(ctx: ServiceContext, _params: DoctorParams): Promise<DoctorResult>;
|
|
1034
|
+
|
|
1035
|
+
declare function setGlobalAdapter(global: IGlobal | null): void;
|
|
1036
|
+
declare function resetGlobalAdapter(): void;
|
|
1037
|
+
declare function getGlobal(): IGlobal;
|
|
1038
|
+
declare function setInstanceAdapter(instance: IInstance | null): void;
|
|
1039
|
+
declare function resetInstanceAdapter(): void;
|
|
1040
|
+
declare function getInstance(): IInstance;
|
|
1041
|
+
declare function getHomeDir(): string;
|
|
1042
|
+
declare function getXdgData(): string;
|
|
1043
|
+
declare function getXdgConfig(): string;
|
|
1044
|
+
declare function getXdgState(): string;
|
|
1045
|
+
declare function getXdgCache(): string;
|
|
1046
|
+
declare function getProjectDirectory(): string;
|
|
1047
|
+
|
|
1048
|
+
export { type ASTNodeType, AmbiguousError, type CalleesParams, type CalleesResult, type CallerEntry, type CallersParams, type CallersResult, CodeBase, type CodeKnowledgeGraphConfig, type CodebaseCliDeps, type CodebaseCliResult, type CodebaseConfig, ConfigError, type ContextInput, type ContextNode, type ContextParams, type ContextResult, DatabaseError, DatabaseManager, type DoctorParams, type DoctorResult, type Edge, EdgeExtractor, type EdgeQueryFilter, type EdgeWithNodes, type ExploreEntryPoint, type ExploreParams, type ExploreResult, type ExtractedEdge, type ExtractedNode, FILE_EXTENSION_MAP, type FileHashRecord, FileSystemError, type FormattedEdge, type FormattedNode, type FormattedSearchHit, type GraphStatus, type HealthCheckResult, type HybridSearchResult, type ICodebase, type IEdgeExtractor, type INodeExtractor, type IParser, type ImpactBucket, type ImpactBucketEntry, type ImpactParams, type ImpactResult, IndexError, type IndexResult, Indexer, type IndexerConfig, type Language, type Node, NodeExtractor, type NodeKind, type NodeParams, type NodeQueryFilter, type NodeResult, type NodeWithEdges, NotFoundError, ParserError, ParserManager, type PendingFile, type ProgressCallback, QueryError, QueryInterface, type RelationQueryOptions, type RelationType, type RenderOptions, SECTION_END, SECTION_MARKER, SchemaError, type SearchHit, type SearchOptions, type SearchParams, type SearchResult$1 as SearchResult, type ServiceContext, ServiceError, type StatusParams, type StatusResult, type SyncResult, type TruncateOptions, type TruncateResult, UnsupportedLanguageError, callees, callers, context, createCodebase, createEdgeExtractor, createIndexer, createNodeExtractor, createQueryInterface, defaultRiskLabel, doctor, emptyFormattedNode, explore, formatCodebaseEdge, formatCodebaseNode, formatCodebaseSearchHits, getGlobal, getHomeDir, getInstance, getParserManager, getProjectDirectory, getXdgCache, getXdgConfig, getXdgData, getXdgState, handleCodebaseCli, impact, node, renderBanner, renderContext, renderContextFromQuery, renderExploreFromResult, renderHelp, renderImpact, renderImpactFromTuples, renderNode, renderNodeDetail, renderSearch, renderSearchResult, resetGlobalAdapter, resetInstanceAdapter, resetParserManager, search, setGlobalAdapter, setInstanceAdapter, status, truncateAtSectionBoundary, truncateAtSectionBoundarySync };
|