@easbot/codebase 0.1.13 → 0.1.14
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.en.md +2 -0
- package/README.md +2 -0
- package/dist/chunks/chunk-ERXX2I2S.mjs +4 -0
- package/dist/chunks/chunk-Q66UAC5Z.cjs +4 -0
- package/dist/chunks/log-GDUMUNYJ.cjs +1 -0
- package/dist/chunks/log-RIY4SBWL.mjs +1 -0
- package/dist/index.cjs +16 -19
- package/dist/index.d.cts +122 -80
- package/dist/index.d.ts +122 -80
- package/dist/index.mjs +16 -19
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnowledgeSearchOptions, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig } from '@easbot/types';
|
|
1
|
+
import { KnowledgeSearchOptions, SearchConfig, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig } from '@easbot/types';
|
|
2
2
|
export { CodebaseKnowledgeConfig, CodebaseKnowledgeConfigWithModels } from '@easbot/types';
|
|
3
3
|
import { EmbeddingModelV3 } from '@ai-sdk/provider';
|
|
4
4
|
export { EmbeddingModelV3 as EmbeddingModel } from '@ai-sdk/provider';
|
|
@@ -28,6 +28,7 @@ declare class DatabaseManager {
|
|
|
28
28
|
isFtsAvailable(): boolean;
|
|
29
29
|
insertNode(node: Node): void;
|
|
30
30
|
insertNodes(nodes: Node[]): void;
|
|
31
|
+
private updateFtsNodesInternal;
|
|
31
32
|
private updateFtsNode;
|
|
32
33
|
private updateFtsNodes;
|
|
33
34
|
insertEdge(edge: Edge): void;
|
|
@@ -42,7 +43,13 @@ declare class DatabaseManager {
|
|
|
42
43
|
setFileHash(filePath: string, hash: string): void;
|
|
43
44
|
deleteFileHash(filePath: string): void;
|
|
44
45
|
getAllFileHashes(): FileHashRecord[];
|
|
45
|
-
getStatus():
|
|
46
|
+
getStatus(): {
|
|
47
|
+
nodeCount: number;
|
|
48
|
+
edgeCount: number;
|
|
49
|
+
indexedFiles: number;
|
|
50
|
+
dbPath: string;
|
|
51
|
+
meta: Record<string, string>;
|
|
52
|
+
};
|
|
46
53
|
setLastSync(): void;
|
|
47
54
|
getNodeCount(): number;
|
|
48
55
|
getEdgeCount(): number;
|
|
@@ -51,6 +58,8 @@ declare class DatabaseManager {
|
|
|
51
58
|
getEdgeById(id: string): Edge | null;
|
|
52
59
|
clearAll(): void;
|
|
53
60
|
getCachedEmbedding(contentHash: string): Float32Array | null;
|
|
61
|
+
getVectorDims(): number | undefined;
|
|
62
|
+
ensureVectorDims(dims: number): void;
|
|
54
63
|
cacheEmbedding(contentHash: string, embedding: Float32Array): void;
|
|
55
64
|
getAllNodeEmbeddings(): Array<{
|
|
56
65
|
node_id: string;
|
|
@@ -66,7 +75,82 @@ declare class DatabaseManager {
|
|
|
66
75
|
isClosed(): boolean;
|
|
67
76
|
getDbPath(): string;
|
|
68
77
|
transaction<T>(fn: () => T): T;
|
|
78
|
+
getMeta(key: string): string | null;
|
|
79
|
+
setMeta(key: string, value: string): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type ParserInstance = any;
|
|
83
|
+
type LanguageInstance = any;
|
|
84
|
+
interface ParseTree {
|
|
85
|
+
rootNode: SyntaxNode;
|
|
86
|
+
walk(): TreeCursor;
|
|
87
|
+
delete(): void;
|
|
88
|
+
}
|
|
89
|
+
interface SyntaxNode {
|
|
90
|
+
type: string;
|
|
91
|
+
text: string;
|
|
92
|
+
startPosition: {
|
|
93
|
+
row: number;
|
|
94
|
+
column: number;
|
|
95
|
+
};
|
|
96
|
+
endPosition: {
|
|
97
|
+
row: number;
|
|
98
|
+
column: number;
|
|
99
|
+
};
|
|
100
|
+
childCount: number;
|
|
101
|
+
children: SyntaxNode[];
|
|
102
|
+
namedChildCount: number;
|
|
103
|
+
namedChildren: SyntaxNode[];
|
|
104
|
+
parent: SyntaxNode | null;
|
|
105
|
+
childForFieldName(name: string): SyntaxNode | null;
|
|
106
|
+
childForFieldId(id: number): SyntaxNode | null;
|
|
107
|
+
firstChild: SyntaxNode | null;
|
|
108
|
+
lastChild: SyntaxNode | null;
|
|
109
|
+
nextSibling: SyntaxNode | null;
|
|
110
|
+
prevSibling: SyntaxNode | null;
|
|
111
|
+
nextNamedSibling: SyntaxNode | null;
|
|
112
|
+
prevNamedSibling: SyntaxNode | null;
|
|
113
|
+
descendantForPosition(position: {
|
|
114
|
+
row: number;
|
|
115
|
+
column: number;
|
|
116
|
+
}): SyntaxNode;
|
|
117
|
+
descendantsOfType(type: string | string[]): SyntaxNode[];
|
|
69
118
|
}
|
|
119
|
+
interface TreeCursor {
|
|
120
|
+
nodeType: string;
|
|
121
|
+
nodeText: string;
|
|
122
|
+
startPosition: {
|
|
123
|
+
row: number;
|
|
124
|
+
column: number;
|
|
125
|
+
};
|
|
126
|
+
endPosition: {
|
|
127
|
+
row: number;
|
|
128
|
+
column: number;
|
|
129
|
+
};
|
|
130
|
+
gotoFirstChild(): boolean;
|
|
131
|
+
gotoNextSibling(): boolean;
|
|
132
|
+
gotoParent(): boolean;
|
|
133
|
+
currentNode: SyntaxNode;
|
|
134
|
+
}
|
|
135
|
+
declare class ParserManager {
|
|
136
|
+
private parsers;
|
|
137
|
+
private initialized;
|
|
138
|
+
private initPromise;
|
|
139
|
+
initialize(): Promise<void>;
|
|
140
|
+
private doInitialize;
|
|
141
|
+
getParser(language: Language): ParserInstance | null;
|
|
142
|
+
getLanguage(language: Language): LanguageInstance | null;
|
|
143
|
+
detectLanguage(filePath: string): Language | null;
|
|
144
|
+
parse(sourceCode: string, language: Language): ParseTree;
|
|
145
|
+
parseFile(filePath: string, sourceCode: string): ParseTree;
|
|
146
|
+
isLanguageSupported(language: Language): boolean;
|
|
147
|
+
getSupportedLanguages(): Language[];
|
|
148
|
+
isInitialized(): boolean;
|
|
149
|
+
getStatus(): Record<Language, boolean>;
|
|
150
|
+
dispose(): void;
|
|
151
|
+
}
|
|
152
|
+
declare function getParserManager(): Promise<ParserManager>;
|
|
153
|
+
declare function resetParserManager(): void;
|
|
70
154
|
|
|
71
155
|
type CodeSearchSource = 'fts' | 'structural' | 'vector' | 'basic';
|
|
72
156
|
interface SearchResult extends BaseSearchResult {
|
|
@@ -95,6 +179,7 @@ interface SearchOptions extends KnowledgeSearchOptions {
|
|
|
95
179
|
includeEdges?: boolean;
|
|
96
180
|
edgesLimit?: number;
|
|
97
181
|
embedding?: EmbeddingModelV3;
|
|
182
|
+
enableEmbedding?: boolean;
|
|
98
183
|
}
|
|
99
184
|
interface RelationQueryOptions {
|
|
100
185
|
maxDepth?: number;
|
|
@@ -105,7 +190,8 @@ interface RelationQueryOptions {
|
|
|
105
190
|
declare class QueryInterface {
|
|
106
191
|
private db;
|
|
107
192
|
private embedding?;
|
|
108
|
-
|
|
193
|
+
private config;
|
|
194
|
+
constructor(db: DatabaseManager, embedding?: EmbeddingModelV3, config?: SearchConfig);
|
|
109
195
|
search(query: string, options?: SearchOptions): Promise<NodeWithEdges[]>;
|
|
110
196
|
private vectorSearchNodes;
|
|
111
197
|
private getEdgesForNode;
|
|
@@ -137,7 +223,7 @@ declare function createQueryInterface(db: DatabaseManager): QueryInterface;
|
|
|
137
223
|
type CodebaseConfig = CodebaseKnowledgeConfigWithModels;
|
|
138
224
|
type Language = 'ts' | 'tsx' | 'js' | 'py' | 'rs' | 'go' | 'c' | 'cpp' | 'csharp' | 'java' | 'scala' | 'ruby' | 'php' | 'zig';
|
|
139
225
|
declare const FILE_EXTENSION_MAP: Record<string, Language>;
|
|
140
|
-
type RelationType = 'CONTAINS' | 'CALLS' | 'INHERITS_FROM' | 'IMPLEMENTS' | 'REFERENCES' | 'IMPORTS';
|
|
226
|
+
type RelationType = 'CONTAINS' | 'CALLS' | 'INHERITS_FROM' | 'IMPLEMENTS' | 'REFERENCES' | 'IMPORTS' | 'TYPE_REFERENCES' | 'DEFINES' | 'HAS_PARAMETER' | 'ASSIGNS' | 'ANNOTATES';
|
|
141
227
|
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';
|
|
142
228
|
interface Node {
|
|
143
229
|
id: string;
|
|
@@ -229,12 +315,13 @@ interface SyncResult {
|
|
|
229
315
|
duration: number;
|
|
230
316
|
}
|
|
231
317
|
interface GraphStatus {
|
|
318
|
+
dbPath: string;
|
|
232
319
|
nodeCount: number;
|
|
233
320
|
edgeCount: number;
|
|
234
321
|
indexedFiles: number;
|
|
235
|
-
dbPath: string;
|
|
236
322
|
workspaceDir: string;
|
|
237
|
-
|
|
323
|
+
meta: Record<string, string>;
|
|
324
|
+
healthy: boolean;
|
|
238
325
|
}
|
|
239
326
|
interface HealthCheckResult {
|
|
240
327
|
healthy: boolean;
|
|
@@ -275,6 +362,7 @@ interface ICodebase {
|
|
|
275
362
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
276
363
|
indexDirectory(dir?: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
277
364
|
sync(progress?: ProgressCallback): Promise<SyncResult>;
|
|
365
|
+
markDirty(): void;
|
|
278
366
|
search(query: string, options?: SearchOptions): Promise<NodeWithEdges[]>;
|
|
279
367
|
queryNodes(filter: NodeQueryFilter): Promise<Node[]>;
|
|
280
368
|
queryEdges(filter: EdgeQueryFilter): Promise<Edge[]>;
|
|
@@ -296,81 +384,11 @@ interface ICodebase {
|
|
|
296
384
|
healthCheck(): Promise<HealthCheckResult>;
|
|
297
385
|
clear(): Promise<void>;
|
|
298
386
|
close(): Promise<void>;
|
|
387
|
+
getDatabase(): DatabaseManager;
|
|
388
|
+
getParser(): ParserManager;
|
|
389
|
+
getQuery(): QueryInterface;
|
|
299
390
|
}
|
|
300
391
|
|
|
301
|
-
type ParserInstance = any;
|
|
302
|
-
type LanguageInstance = any;
|
|
303
|
-
interface ParseTree {
|
|
304
|
-
rootNode: SyntaxNode;
|
|
305
|
-
walk(): TreeCursor;
|
|
306
|
-
delete(): void;
|
|
307
|
-
}
|
|
308
|
-
interface SyntaxNode {
|
|
309
|
-
type: string;
|
|
310
|
-
text: string;
|
|
311
|
-
startPosition: {
|
|
312
|
-
row: number;
|
|
313
|
-
column: number;
|
|
314
|
-
};
|
|
315
|
-
endPosition: {
|
|
316
|
-
row: number;
|
|
317
|
-
column: number;
|
|
318
|
-
};
|
|
319
|
-
childCount: number;
|
|
320
|
-
children: SyntaxNode[];
|
|
321
|
-
namedChildCount: number;
|
|
322
|
-
namedChildren: SyntaxNode[];
|
|
323
|
-
parent: SyntaxNode | null;
|
|
324
|
-
childForFieldName(name: string): SyntaxNode | null;
|
|
325
|
-
childForFieldId(id: number): SyntaxNode | null;
|
|
326
|
-
firstChild: SyntaxNode | null;
|
|
327
|
-
lastChild: SyntaxNode | null;
|
|
328
|
-
nextSibling: SyntaxNode | null;
|
|
329
|
-
prevSibling: SyntaxNode | null;
|
|
330
|
-
nextNamedSibling: SyntaxNode | null;
|
|
331
|
-
prevNamedSibling: SyntaxNode | null;
|
|
332
|
-
descendantForPosition(position: {
|
|
333
|
-
row: number;
|
|
334
|
-
column: number;
|
|
335
|
-
}): SyntaxNode;
|
|
336
|
-
descendantsOfType(type: string | string[]): SyntaxNode[];
|
|
337
|
-
}
|
|
338
|
-
interface TreeCursor {
|
|
339
|
-
nodeType: string;
|
|
340
|
-
nodeText: string;
|
|
341
|
-
startPosition: {
|
|
342
|
-
row: number;
|
|
343
|
-
column: number;
|
|
344
|
-
};
|
|
345
|
-
endPosition: {
|
|
346
|
-
row: number;
|
|
347
|
-
column: number;
|
|
348
|
-
};
|
|
349
|
-
gotoFirstChild(): boolean;
|
|
350
|
-
gotoNextSibling(): boolean;
|
|
351
|
-
gotoParent(): boolean;
|
|
352
|
-
currentNode: SyntaxNode;
|
|
353
|
-
}
|
|
354
|
-
declare class ParserManager {
|
|
355
|
-
private parsers;
|
|
356
|
-
private initialized;
|
|
357
|
-
private initPromise;
|
|
358
|
-
initialize(): Promise<void>;
|
|
359
|
-
private doInitialize;
|
|
360
|
-
getParser(language: Language): ParserInstance | null;
|
|
361
|
-
getLanguage(language: Language): LanguageInstance | null;
|
|
362
|
-
detectLanguage(filePath: string): Language | null;
|
|
363
|
-
parse(sourceCode: string, language: Language): ParseTree;
|
|
364
|
-
parseFile(filePath: string, sourceCode: string): ParseTree;
|
|
365
|
-
isLanguageSupported(language: Language): boolean;
|
|
366
|
-
getSupportedLanguages(): Language[];
|
|
367
|
-
isInitialized(): boolean;
|
|
368
|
-
getStatus(): Record<Language, boolean>;
|
|
369
|
-
dispose(): void;
|
|
370
|
-
}
|
|
371
|
-
declare function getParserManager(): Promise<ParserManager>;
|
|
372
|
-
declare function resetParserManager(): void;
|
|
373
|
-
|
|
374
392
|
declare class ParserError extends Error {
|
|
375
393
|
readonly name = "ParserError";
|
|
376
394
|
readonly filePath: string;
|
|
@@ -464,6 +482,14 @@ declare class EdgeExtractor {
|
|
|
464
482
|
private extractIdentifiers;
|
|
465
483
|
private extractImportPath;
|
|
466
484
|
generateNodeId(node: ExtractedNode): string;
|
|
485
|
+
private extractTypeReferences;
|
|
486
|
+
private extractParameterEdges;
|
|
487
|
+
private extractDefinesEdges;
|
|
488
|
+
private extractAnnotationEdges;
|
|
489
|
+
private extractTypeName;
|
|
490
|
+
private resolveTypeNodeId;
|
|
491
|
+
private generateNodeIdFromName;
|
|
492
|
+
private findChildrenByType;
|
|
467
493
|
}
|
|
468
494
|
declare function createEdgeExtractor(): EdgeExtractor;
|
|
469
495
|
|
|
@@ -504,8 +530,16 @@ declare class CodeBase implements ICodebase {
|
|
|
504
530
|
private indexer;
|
|
505
531
|
private queryInterface;
|
|
506
532
|
private initialized;
|
|
533
|
+
private dirty;
|
|
534
|
+
private syncTimer?;
|
|
535
|
+
private syncingInProgress;
|
|
536
|
+
private log;
|
|
507
537
|
constructor(config?: Partial<CodebaseConfig>);
|
|
508
538
|
initialize(): Promise<void>;
|
|
539
|
+
private startSyncTimer;
|
|
540
|
+
private stopSyncTimer;
|
|
541
|
+
private ensureSynced;
|
|
542
|
+
markDirty(): void;
|
|
509
543
|
private validateConfig;
|
|
510
544
|
private resolveDbPath;
|
|
511
545
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
@@ -539,4 +573,12 @@ declare class CodeBase implements ICodebase {
|
|
|
539
573
|
}
|
|
540
574
|
declare function createCodebase(config?: Partial<CodebaseConfig>): Promise<ICodebase>;
|
|
541
575
|
|
|
542
|
-
|
|
576
|
+
declare function initLog(options: {
|
|
577
|
+
print: boolean;
|
|
578
|
+
logDir: string;
|
|
579
|
+
logFile?: string;
|
|
580
|
+
dev?: boolean;
|
|
581
|
+
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
582
|
+
}): Promise<void>;
|
|
583
|
+
|
|
584
|
+
export { type ASTNodeType, CodeBase, type CodeKnowledgeGraphConfig, type CodebaseConfig, ConfigError, DatabaseError, DatabaseManager, type Edge, EdgeExtractor, type EdgeQueryFilter, type EdgeWithNodes, type ExtractedEdge, type ExtractedNode, FILE_EXTENSION_MAP, type FileHashRecord, FileSystemError, type GraphStatus, type HealthCheckResult, type HybridSearchResult, type ICodebase, type IEdgeExtractor, type INodeExtractor, type IParser, IndexError, type IndexResult, Indexer, type IndexerConfig, type Language, type Node, NodeExtractor, type NodeQueryFilter, type NodeWithEdges, ParserError, ParserManager, type ProgressCallback, QueryError, QueryInterface, type RelationQueryOptions, type RelationType, SchemaError, type SearchOptions, type SearchResult, type SyncResult, UnsupportedLanguageError, createCodebase, createEdgeExtractor, createIndexer, createNodeExtractor, createQueryInterface, getParserManager, initLog, resetParserManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnowledgeSearchOptions, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig } from '@easbot/types';
|
|
1
|
+
import { KnowledgeSearchOptions, SearchConfig, BaseSearchResult, CodebaseKnowledgeConfigWithModels, CodebaseKnowledgeConfig } from '@easbot/types';
|
|
2
2
|
export { CodebaseKnowledgeConfig, CodebaseKnowledgeConfigWithModels } from '@easbot/types';
|
|
3
3
|
import { EmbeddingModelV3 } from '@ai-sdk/provider';
|
|
4
4
|
export { EmbeddingModelV3 as EmbeddingModel } from '@ai-sdk/provider';
|
|
@@ -28,6 +28,7 @@ declare class DatabaseManager {
|
|
|
28
28
|
isFtsAvailable(): boolean;
|
|
29
29
|
insertNode(node: Node): void;
|
|
30
30
|
insertNodes(nodes: Node[]): void;
|
|
31
|
+
private updateFtsNodesInternal;
|
|
31
32
|
private updateFtsNode;
|
|
32
33
|
private updateFtsNodes;
|
|
33
34
|
insertEdge(edge: Edge): void;
|
|
@@ -42,7 +43,13 @@ declare class DatabaseManager {
|
|
|
42
43
|
setFileHash(filePath: string, hash: string): void;
|
|
43
44
|
deleteFileHash(filePath: string): void;
|
|
44
45
|
getAllFileHashes(): FileHashRecord[];
|
|
45
|
-
getStatus():
|
|
46
|
+
getStatus(): {
|
|
47
|
+
nodeCount: number;
|
|
48
|
+
edgeCount: number;
|
|
49
|
+
indexedFiles: number;
|
|
50
|
+
dbPath: string;
|
|
51
|
+
meta: Record<string, string>;
|
|
52
|
+
};
|
|
46
53
|
setLastSync(): void;
|
|
47
54
|
getNodeCount(): number;
|
|
48
55
|
getEdgeCount(): number;
|
|
@@ -51,6 +58,8 @@ declare class DatabaseManager {
|
|
|
51
58
|
getEdgeById(id: string): Edge | null;
|
|
52
59
|
clearAll(): void;
|
|
53
60
|
getCachedEmbedding(contentHash: string): Float32Array | null;
|
|
61
|
+
getVectorDims(): number | undefined;
|
|
62
|
+
ensureVectorDims(dims: number): void;
|
|
54
63
|
cacheEmbedding(contentHash: string, embedding: Float32Array): void;
|
|
55
64
|
getAllNodeEmbeddings(): Array<{
|
|
56
65
|
node_id: string;
|
|
@@ -66,7 +75,82 @@ declare class DatabaseManager {
|
|
|
66
75
|
isClosed(): boolean;
|
|
67
76
|
getDbPath(): string;
|
|
68
77
|
transaction<T>(fn: () => T): T;
|
|
78
|
+
getMeta(key: string): string | null;
|
|
79
|
+
setMeta(key: string, value: string): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type ParserInstance = any;
|
|
83
|
+
type LanguageInstance = any;
|
|
84
|
+
interface ParseTree {
|
|
85
|
+
rootNode: SyntaxNode;
|
|
86
|
+
walk(): TreeCursor;
|
|
87
|
+
delete(): void;
|
|
88
|
+
}
|
|
89
|
+
interface SyntaxNode {
|
|
90
|
+
type: string;
|
|
91
|
+
text: string;
|
|
92
|
+
startPosition: {
|
|
93
|
+
row: number;
|
|
94
|
+
column: number;
|
|
95
|
+
};
|
|
96
|
+
endPosition: {
|
|
97
|
+
row: number;
|
|
98
|
+
column: number;
|
|
99
|
+
};
|
|
100
|
+
childCount: number;
|
|
101
|
+
children: SyntaxNode[];
|
|
102
|
+
namedChildCount: number;
|
|
103
|
+
namedChildren: SyntaxNode[];
|
|
104
|
+
parent: SyntaxNode | null;
|
|
105
|
+
childForFieldName(name: string): SyntaxNode | null;
|
|
106
|
+
childForFieldId(id: number): SyntaxNode | null;
|
|
107
|
+
firstChild: SyntaxNode | null;
|
|
108
|
+
lastChild: SyntaxNode | null;
|
|
109
|
+
nextSibling: SyntaxNode | null;
|
|
110
|
+
prevSibling: SyntaxNode | null;
|
|
111
|
+
nextNamedSibling: SyntaxNode | null;
|
|
112
|
+
prevNamedSibling: SyntaxNode | null;
|
|
113
|
+
descendantForPosition(position: {
|
|
114
|
+
row: number;
|
|
115
|
+
column: number;
|
|
116
|
+
}): SyntaxNode;
|
|
117
|
+
descendantsOfType(type: string | string[]): SyntaxNode[];
|
|
69
118
|
}
|
|
119
|
+
interface TreeCursor {
|
|
120
|
+
nodeType: string;
|
|
121
|
+
nodeText: string;
|
|
122
|
+
startPosition: {
|
|
123
|
+
row: number;
|
|
124
|
+
column: number;
|
|
125
|
+
};
|
|
126
|
+
endPosition: {
|
|
127
|
+
row: number;
|
|
128
|
+
column: number;
|
|
129
|
+
};
|
|
130
|
+
gotoFirstChild(): boolean;
|
|
131
|
+
gotoNextSibling(): boolean;
|
|
132
|
+
gotoParent(): boolean;
|
|
133
|
+
currentNode: SyntaxNode;
|
|
134
|
+
}
|
|
135
|
+
declare class ParserManager {
|
|
136
|
+
private parsers;
|
|
137
|
+
private initialized;
|
|
138
|
+
private initPromise;
|
|
139
|
+
initialize(): Promise<void>;
|
|
140
|
+
private doInitialize;
|
|
141
|
+
getParser(language: Language): ParserInstance | null;
|
|
142
|
+
getLanguage(language: Language): LanguageInstance | null;
|
|
143
|
+
detectLanguage(filePath: string): Language | null;
|
|
144
|
+
parse(sourceCode: string, language: Language): ParseTree;
|
|
145
|
+
parseFile(filePath: string, sourceCode: string): ParseTree;
|
|
146
|
+
isLanguageSupported(language: Language): boolean;
|
|
147
|
+
getSupportedLanguages(): Language[];
|
|
148
|
+
isInitialized(): boolean;
|
|
149
|
+
getStatus(): Record<Language, boolean>;
|
|
150
|
+
dispose(): void;
|
|
151
|
+
}
|
|
152
|
+
declare function getParserManager(): Promise<ParserManager>;
|
|
153
|
+
declare function resetParserManager(): void;
|
|
70
154
|
|
|
71
155
|
type CodeSearchSource = 'fts' | 'structural' | 'vector' | 'basic';
|
|
72
156
|
interface SearchResult extends BaseSearchResult {
|
|
@@ -95,6 +179,7 @@ interface SearchOptions extends KnowledgeSearchOptions {
|
|
|
95
179
|
includeEdges?: boolean;
|
|
96
180
|
edgesLimit?: number;
|
|
97
181
|
embedding?: EmbeddingModelV3;
|
|
182
|
+
enableEmbedding?: boolean;
|
|
98
183
|
}
|
|
99
184
|
interface RelationQueryOptions {
|
|
100
185
|
maxDepth?: number;
|
|
@@ -105,7 +190,8 @@ interface RelationQueryOptions {
|
|
|
105
190
|
declare class QueryInterface {
|
|
106
191
|
private db;
|
|
107
192
|
private embedding?;
|
|
108
|
-
|
|
193
|
+
private config;
|
|
194
|
+
constructor(db: DatabaseManager, embedding?: EmbeddingModelV3, config?: SearchConfig);
|
|
109
195
|
search(query: string, options?: SearchOptions): Promise<NodeWithEdges[]>;
|
|
110
196
|
private vectorSearchNodes;
|
|
111
197
|
private getEdgesForNode;
|
|
@@ -137,7 +223,7 @@ declare function createQueryInterface(db: DatabaseManager): QueryInterface;
|
|
|
137
223
|
type CodebaseConfig = CodebaseKnowledgeConfigWithModels;
|
|
138
224
|
type Language = 'ts' | 'tsx' | 'js' | 'py' | 'rs' | 'go' | 'c' | 'cpp' | 'csharp' | 'java' | 'scala' | 'ruby' | 'php' | 'zig';
|
|
139
225
|
declare const FILE_EXTENSION_MAP: Record<string, Language>;
|
|
140
|
-
type RelationType = 'CONTAINS' | 'CALLS' | 'INHERITS_FROM' | 'IMPLEMENTS' | 'REFERENCES' | 'IMPORTS';
|
|
226
|
+
type RelationType = 'CONTAINS' | 'CALLS' | 'INHERITS_FROM' | 'IMPLEMENTS' | 'REFERENCES' | 'IMPORTS' | 'TYPE_REFERENCES' | 'DEFINES' | 'HAS_PARAMETER' | 'ASSIGNS' | 'ANNOTATES';
|
|
141
227
|
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';
|
|
142
228
|
interface Node {
|
|
143
229
|
id: string;
|
|
@@ -229,12 +315,13 @@ interface SyncResult {
|
|
|
229
315
|
duration: number;
|
|
230
316
|
}
|
|
231
317
|
interface GraphStatus {
|
|
318
|
+
dbPath: string;
|
|
232
319
|
nodeCount: number;
|
|
233
320
|
edgeCount: number;
|
|
234
321
|
indexedFiles: number;
|
|
235
|
-
dbPath: string;
|
|
236
322
|
workspaceDir: string;
|
|
237
|
-
|
|
323
|
+
meta: Record<string, string>;
|
|
324
|
+
healthy: boolean;
|
|
238
325
|
}
|
|
239
326
|
interface HealthCheckResult {
|
|
240
327
|
healthy: boolean;
|
|
@@ -275,6 +362,7 @@ interface ICodebase {
|
|
|
275
362
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
276
363
|
indexDirectory(dir?: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
277
364
|
sync(progress?: ProgressCallback): Promise<SyncResult>;
|
|
365
|
+
markDirty(): void;
|
|
278
366
|
search(query: string, options?: SearchOptions): Promise<NodeWithEdges[]>;
|
|
279
367
|
queryNodes(filter: NodeQueryFilter): Promise<Node[]>;
|
|
280
368
|
queryEdges(filter: EdgeQueryFilter): Promise<Edge[]>;
|
|
@@ -296,81 +384,11 @@ interface ICodebase {
|
|
|
296
384
|
healthCheck(): Promise<HealthCheckResult>;
|
|
297
385
|
clear(): Promise<void>;
|
|
298
386
|
close(): Promise<void>;
|
|
387
|
+
getDatabase(): DatabaseManager;
|
|
388
|
+
getParser(): ParserManager;
|
|
389
|
+
getQuery(): QueryInterface;
|
|
299
390
|
}
|
|
300
391
|
|
|
301
|
-
type ParserInstance = any;
|
|
302
|
-
type LanguageInstance = any;
|
|
303
|
-
interface ParseTree {
|
|
304
|
-
rootNode: SyntaxNode;
|
|
305
|
-
walk(): TreeCursor;
|
|
306
|
-
delete(): void;
|
|
307
|
-
}
|
|
308
|
-
interface SyntaxNode {
|
|
309
|
-
type: string;
|
|
310
|
-
text: string;
|
|
311
|
-
startPosition: {
|
|
312
|
-
row: number;
|
|
313
|
-
column: number;
|
|
314
|
-
};
|
|
315
|
-
endPosition: {
|
|
316
|
-
row: number;
|
|
317
|
-
column: number;
|
|
318
|
-
};
|
|
319
|
-
childCount: number;
|
|
320
|
-
children: SyntaxNode[];
|
|
321
|
-
namedChildCount: number;
|
|
322
|
-
namedChildren: SyntaxNode[];
|
|
323
|
-
parent: SyntaxNode | null;
|
|
324
|
-
childForFieldName(name: string): SyntaxNode | null;
|
|
325
|
-
childForFieldId(id: number): SyntaxNode | null;
|
|
326
|
-
firstChild: SyntaxNode | null;
|
|
327
|
-
lastChild: SyntaxNode | null;
|
|
328
|
-
nextSibling: SyntaxNode | null;
|
|
329
|
-
prevSibling: SyntaxNode | null;
|
|
330
|
-
nextNamedSibling: SyntaxNode | null;
|
|
331
|
-
prevNamedSibling: SyntaxNode | null;
|
|
332
|
-
descendantForPosition(position: {
|
|
333
|
-
row: number;
|
|
334
|
-
column: number;
|
|
335
|
-
}): SyntaxNode;
|
|
336
|
-
descendantsOfType(type: string | string[]): SyntaxNode[];
|
|
337
|
-
}
|
|
338
|
-
interface TreeCursor {
|
|
339
|
-
nodeType: string;
|
|
340
|
-
nodeText: string;
|
|
341
|
-
startPosition: {
|
|
342
|
-
row: number;
|
|
343
|
-
column: number;
|
|
344
|
-
};
|
|
345
|
-
endPosition: {
|
|
346
|
-
row: number;
|
|
347
|
-
column: number;
|
|
348
|
-
};
|
|
349
|
-
gotoFirstChild(): boolean;
|
|
350
|
-
gotoNextSibling(): boolean;
|
|
351
|
-
gotoParent(): boolean;
|
|
352
|
-
currentNode: SyntaxNode;
|
|
353
|
-
}
|
|
354
|
-
declare class ParserManager {
|
|
355
|
-
private parsers;
|
|
356
|
-
private initialized;
|
|
357
|
-
private initPromise;
|
|
358
|
-
initialize(): Promise<void>;
|
|
359
|
-
private doInitialize;
|
|
360
|
-
getParser(language: Language): ParserInstance | null;
|
|
361
|
-
getLanguage(language: Language): LanguageInstance | null;
|
|
362
|
-
detectLanguage(filePath: string): Language | null;
|
|
363
|
-
parse(sourceCode: string, language: Language): ParseTree;
|
|
364
|
-
parseFile(filePath: string, sourceCode: string): ParseTree;
|
|
365
|
-
isLanguageSupported(language: Language): boolean;
|
|
366
|
-
getSupportedLanguages(): Language[];
|
|
367
|
-
isInitialized(): boolean;
|
|
368
|
-
getStatus(): Record<Language, boolean>;
|
|
369
|
-
dispose(): void;
|
|
370
|
-
}
|
|
371
|
-
declare function getParserManager(): Promise<ParserManager>;
|
|
372
|
-
declare function resetParserManager(): void;
|
|
373
|
-
|
|
374
392
|
declare class ParserError extends Error {
|
|
375
393
|
readonly name = "ParserError";
|
|
376
394
|
readonly filePath: string;
|
|
@@ -464,6 +482,14 @@ declare class EdgeExtractor {
|
|
|
464
482
|
private extractIdentifiers;
|
|
465
483
|
private extractImportPath;
|
|
466
484
|
generateNodeId(node: ExtractedNode): string;
|
|
485
|
+
private extractTypeReferences;
|
|
486
|
+
private extractParameterEdges;
|
|
487
|
+
private extractDefinesEdges;
|
|
488
|
+
private extractAnnotationEdges;
|
|
489
|
+
private extractTypeName;
|
|
490
|
+
private resolveTypeNodeId;
|
|
491
|
+
private generateNodeIdFromName;
|
|
492
|
+
private findChildrenByType;
|
|
467
493
|
}
|
|
468
494
|
declare function createEdgeExtractor(): EdgeExtractor;
|
|
469
495
|
|
|
@@ -504,8 +530,16 @@ declare class CodeBase implements ICodebase {
|
|
|
504
530
|
private indexer;
|
|
505
531
|
private queryInterface;
|
|
506
532
|
private initialized;
|
|
533
|
+
private dirty;
|
|
534
|
+
private syncTimer?;
|
|
535
|
+
private syncingInProgress;
|
|
536
|
+
private log;
|
|
507
537
|
constructor(config?: Partial<CodebaseConfig>);
|
|
508
538
|
initialize(): Promise<void>;
|
|
539
|
+
private startSyncTimer;
|
|
540
|
+
private stopSyncTimer;
|
|
541
|
+
private ensureSynced;
|
|
542
|
+
markDirty(): void;
|
|
509
543
|
private validateConfig;
|
|
510
544
|
private resolveDbPath;
|
|
511
545
|
indexFile(filePath: string, progress?: ProgressCallback): Promise<IndexResult>;
|
|
@@ -539,4 +573,12 @@ declare class CodeBase implements ICodebase {
|
|
|
539
573
|
}
|
|
540
574
|
declare function createCodebase(config?: Partial<CodebaseConfig>): Promise<ICodebase>;
|
|
541
575
|
|
|
542
|
-
|
|
576
|
+
declare function initLog(options: {
|
|
577
|
+
print: boolean;
|
|
578
|
+
logDir: string;
|
|
579
|
+
logFile?: string;
|
|
580
|
+
dev?: boolean;
|
|
581
|
+
level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
582
|
+
}): Promise<void>;
|
|
583
|
+
|
|
584
|
+
export { type ASTNodeType, CodeBase, type CodeKnowledgeGraphConfig, type CodebaseConfig, ConfigError, DatabaseError, DatabaseManager, type Edge, EdgeExtractor, type EdgeQueryFilter, type EdgeWithNodes, type ExtractedEdge, type ExtractedNode, FILE_EXTENSION_MAP, type FileHashRecord, FileSystemError, type GraphStatus, type HealthCheckResult, type HybridSearchResult, type ICodebase, type IEdgeExtractor, type INodeExtractor, type IParser, IndexError, type IndexResult, Indexer, type IndexerConfig, type Language, type Node, NodeExtractor, type NodeQueryFilter, type NodeWithEdges, ParserError, ParserManager, type ProgressCallback, QueryError, QueryInterface, type RelationQueryOptions, type RelationType, SchemaError, type SearchOptions, type SearchResult, type SyncResult, UnsupportedLanguageError, createCodebase, createEdgeExtractor, createIndexer, createNodeExtractor, createQueryInterface, getParserManager, initLog, resetParserManager };
|