raggrep 0.8.4 → 0.10.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/cli/main.js +6642 -680
- package/dist/cli/main.js.map +32 -23
- package/dist/domain/entities/fileIndex.d.ts +5 -0
- package/dist/domain/entities/introspection.d.ts +2 -0
- package/dist/domain/entities/literal.d.ts +4 -0
- package/dist/domain/ports/index.d.ts +1 -0
- package/dist/domain/ports/parser.d.ts +121 -0
- package/dist/domain/services/bm25.d.ts +23 -0
- package/dist/domain/services/configValidator.d.ts +44 -0
- package/dist/domain/services/configValidator.test.d.ts +1 -0
- package/dist/domain/services/index.d.ts +4 -2
- package/dist/domain/services/introspection.d.ts +22 -2
- package/dist/domain/services/literalExtractor.d.ts +16 -0
- package/dist/domain/services/literalExtractor.test.d.ts +6 -0
- package/dist/domain/services/literalScorer.d.ts +35 -0
- package/dist/index.js +6569 -608
- package/dist/index.js.map +31 -22
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/infrastructure/introspection/IntrospectionIndex.d.ts +5 -1
- package/dist/infrastructure/parsing/grammarManager.d.ts +83 -0
- package/dist/infrastructure/parsing/index.d.ts +15 -0
- package/dist/infrastructure/parsing/parserFactory.d.ts +56 -0
- package/dist/infrastructure/parsing/parsing.test.d.ts +10 -0
- package/dist/infrastructure/parsing/treeSitterParser.d.ts +103 -0
- package/dist/infrastructure/parsing/typescriptParser.d.ts +43 -0
- package/dist/infrastructure/storage/literalIndex.d.ts +33 -1
- package/dist/infrastructure/storage/symbolicIndex.d.ts +25 -5
- package/dist/modules/data/json/index.d.ts +2 -1
- package/dist/modules/language/go/index.d.ts +58 -0
- package/dist/modules/language/go/index.test.d.ts +1 -0
- package/dist/modules/language/python/index.d.ts +59 -0
- package/dist/modules/language/rust/index.d.ts +58 -0
- package/dist/modules/language/rust/index.test.d.ts +1 -0
- package/dist/modules/language/typescript/index.d.ts +2 -1
- package/dist/tests/vocabulary.test.d.ts +10 -0
- package/package.json +3 -2
|
@@ -9,3 +9,4 @@ export { TransformersEmbeddingProvider, getCacheDir, isModelCached, } from "./em
|
|
|
9
9
|
export { FileIndexStorage, SymbolicIndex, getSymbolicPath } from "./storage";
|
|
10
10
|
export { DEFAULT_CONFIG, EMBEDDING_MODELS, getRaggrepDir, getModuleIndexPath, getModuleManifestPath, getGlobalManifestPath, getConfigPath, loadConfig, saveConfig, getModuleConfig, getEmbeddingConfigFromModule, } from "./config";
|
|
11
11
|
export { ConsoleLogger, InlineProgressLogger, SilentLogger, createLogger, createInlineLogger, createSilentLogger, } from "./logger";
|
|
12
|
+
export { TypeScriptParser, TreeSitterParser, GrammarManager, getGrammarManager, createParserForFile, createParserForLanguage, detectLanguage, detectLanguagesFromFiles, isFileSupported, getSupportedExtensions, getSupportedLanguages, } from "./parsing";
|
|
@@ -24,8 +24,12 @@ export declare class IntrospectionIndex {
|
|
|
24
24
|
getStructure(): ProjectStructure | null;
|
|
25
25
|
/**
|
|
26
26
|
* Introspect a file and add to index.
|
|
27
|
+
*
|
|
28
|
+
* @param filepath - Relative file path
|
|
29
|
+
* @param content - Optional file content for framework detection
|
|
30
|
+
* @param enableReadmeContext - Whether to look for README files (default: true)
|
|
27
31
|
*/
|
|
28
|
-
addFile(filepath: string, content?: string): FileIntrospection;
|
|
32
|
+
addFile(filepath: string, content?: string, enableReadmeContext?: boolean): FileIntrospection;
|
|
29
33
|
/**
|
|
30
34
|
* Get introspection for a file.
|
|
31
35
|
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grammar Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages tree-sitter grammar installation and loading.
|
|
5
|
+
* Uses Bun for dynamic package installation on first use.
|
|
6
|
+
*
|
|
7
|
+
* This is an infrastructure component that handles:
|
|
8
|
+
* - Grammar package installation via Bun
|
|
9
|
+
* - Grammar caching in memory
|
|
10
|
+
* - Thread-safe concurrent installation handling
|
|
11
|
+
*/
|
|
12
|
+
import type { IGrammarManager, GrammarStatus, ParserLanguage } from "../../domain/ports/parser";
|
|
13
|
+
import type { Logger } from "../../domain/ports/logger";
|
|
14
|
+
/**
|
|
15
|
+
* Singleton Grammar Manager for tree-sitter grammars.
|
|
16
|
+
*
|
|
17
|
+
* Handles:
|
|
18
|
+
* - Checking if grammars are installed
|
|
19
|
+
* - Installing grammars via Bun on demand
|
|
20
|
+
* - Caching loaded grammars
|
|
21
|
+
* - Thread-safe concurrent installation
|
|
22
|
+
*/
|
|
23
|
+
export declare class GrammarManager implements IGrammarManager {
|
|
24
|
+
private static instance;
|
|
25
|
+
/** Cache of loaded grammars */
|
|
26
|
+
private grammarCache;
|
|
27
|
+
/** Track installation status */
|
|
28
|
+
private installationStatus;
|
|
29
|
+
/** Track pending installations to prevent duplicate installs */
|
|
30
|
+
private pendingInstalls;
|
|
31
|
+
/** Optional logger for progress reporting */
|
|
32
|
+
private logger?;
|
|
33
|
+
private constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Get the singleton instance.
|
|
36
|
+
*/
|
|
37
|
+
static getInstance(): GrammarManager;
|
|
38
|
+
/**
|
|
39
|
+
* Set a logger for progress reporting.
|
|
40
|
+
*/
|
|
41
|
+
setLogger(logger: Logger): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a grammar package is installed.
|
|
44
|
+
*/
|
|
45
|
+
isInstalled(language: ParserLanguage): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Install a grammar for a language using Bun.
|
|
48
|
+
*
|
|
49
|
+
* Thread-safe: concurrent calls for the same language will wait
|
|
50
|
+
* for the first installation to complete.
|
|
51
|
+
*/
|
|
52
|
+
install(language: ParserLanguage): Promise<GrammarStatus>;
|
|
53
|
+
/**
|
|
54
|
+
* Perform the actual installation using Bun.
|
|
55
|
+
*/
|
|
56
|
+
private doInstall;
|
|
57
|
+
/**
|
|
58
|
+
* Get the status of all supported grammars.
|
|
59
|
+
*/
|
|
60
|
+
getStatus(): Promise<GrammarStatus[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Pre-install grammars for a batch of languages.
|
|
63
|
+
* Shows overall progress and handles failures gracefully.
|
|
64
|
+
*/
|
|
65
|
+
preInstallBatch(languages: ParserLanguage[]): Promise<GrammarStatus[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Load a grammar module.
|
|
68
|
+
* Returns the grammar if installed, null otherwise.
|
|
69
|
+
*/
|
|
70
|
+
loadGrammar(language: ParserLanguage): Promise<unknown | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Get the package name for a language.
|
|
73
|
+
*/
|
|
74
|
+
getPackageName(language: ParserLanguage): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Clear cached grammars (mainly for testing).
|
|
77
|
+
*/
|
|
78
|
+
clearCache(): void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the singleton grammar manager instance.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getGrammarManager(): GrammarManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Provides parser implementations for different programming languages.
|
|
5
|
+
*
|
|
6
|
+
* Exports:
|
|
7
|
+
* - TypeScriptParser: Uses TypeScript Compiler API for TS/JS
|
|
8
|
+
* - TreeSitterParser: Uses tree-sitter for Python, Go, Rust, Java
|
|
9
|
+
* - GrammarManager: Manages tree-sitter grammar installation
|
|
10
|
+
* - Parser factory functions for automatic parser selection
|
|
11
|
+
*/
|
|
12
|
+
export { TypeScriptParser, createTypeScriptParser } from "./typescriptParser";
|
|
13
|
+
export { TreeSitterParser, createTreeSitterParser } from "./treeSitterParser";
|
|
14
|
+
export { GrammarManager, getGrammarManager } from "./grammarManager";
|
|
15
|
+
export { createParserForFile, createParserForLanguage, detectLanguage, detectLanguagesFromFiles, isFileSupported, getSupportedExtensions, getSupportedLanguages, } from "./parserFactory";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates the appropriate parser for a given file or language.
|
|
5
|
+
* Implements the strategy pattern for parser selection.
|
|
6
|
+
*
|
|
7
|
+
* Strategy:
|
|
8
|
+
* - TypeScript/JavaScript: Use TypeScriptParser (TypeScript Compiler API)
|
|
9
|
+
* - Python, Go, Rust, Java: Use TreeSitterParser
|
|
10
|
+
* - Unknown: Fall back to TreeSitterParser or null
|
|
11
|
+
*/
|
|
12
|
+
import type { IParser, ParserLanguage } from "../../domain/ports/parser";
|
|
13
|
+
/**
|
|
14
|
+
* Create a parser for the given file.
|
|
15
|
+
*
|
|
16
|
+
* @param filepath - The file path to get a parser for
|
|
17
|
+
* @returns The appropriate parser, or null if no parser supports the file
|
|
18
|
+
*/
|
|
19
|
+
export declare function createParserForFile(filepath: string): IParser | null;
|
|
20
|
+
/**
|
|
21
|
+
* Create a parser for the given language.
|
|
22
|
+
*
|
|
23
|
+
* @param language - The language to get a parser for
|
|
24
|
+
* @returns The appropriate parser
|
|
25
|
+
*/
|
|
26
|
+
export declare function createParserForLanguage(language: ParserLanguage): IParser;
|
|
27
|
+
/**
|
|
28
|
+
* Detect the language from a file path.
|
|
29
|
+
*
|
|
30
|
+
* @param filepath - The file path to detect language from
|
|
31
|
+
* @returns The detected language, or null if unknown
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectLanguage(filepath: string): ParserLanguage | null;
|
|
34
|
+
/**
|
|
35
|
+
* Detect languages from a list of file paths.
|
|
36
|
+
* Returns unique languages found.
|
|
37
|
+
*
|
|
38
|
+
* @param filepaths - Array of file paths
|
|
39
|
+
* @returns Set of detected languages
|
|
40
|
+
*/
|
|
41
|
+
export declare function detectLanguagesFromFiles(filepaths: string[]): Set<ParserLanguage>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a file is supported by any parser.
|
|
44
|
+
*
|
|
45
|
+
* @param filepath - The file path to check
|
|
46
|
+
* @returns True if a parser can handle this file
|
|
47
|
+
*/
|
|
48
|
+
export declare function isFileSupported(filepath: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get all supported file extensions.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSupportedExtensions(): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Get all supported languages.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSupportedLanguages(): ParserLanguage[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser Infrastructure Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the parser infrastructure including:
|
|
5
|
+
* - TypeScriptParser (TypeScript Compiler API wrapper)
|
|
6
|
+
* - TreeSitterParser (web-tree-sitter based)
|
|
7
|
+
* - Parser factory functions
|
|
8
|
+
* - Language detection
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter Parser
|
|
3
|
+
*
|
|
4
|
+
* Uses web-tree-sitter (WebAssembly) for parsing multiple languages.
|
|
5
|
+
* This parser supports Python, Go, Rust, Java, and can act as a fallback for TS/JS.
|
|
6
|
+
*
|
|
7
|
+
* Web-tree-sitter provides:
|
|
8
|
+
* - Cross-platform compatibility (no native compilation)
|
|
9
|
+
* - Fast, incremental parsing
|
|
10
|
+
* - Support for many languages via WASM grammars
|
|
11
|
+
* - Consistent AST structure
|
|
12
|
+
*/
|
|
13
|
+
import type { IParser, ParseResult, ParserConfig, ParserLanguage } from "../../domain/ports/parser";
|
|
14
|
+
/**
|
|
15
|
+
* Tree-sitter Parser implementation using web-tree-sitter (WebAssembly).
|
|
16
|
+
*
|
|
17
|
+
* Supports multiple languages through WASM grammar files.
|
|
18
|
+
* Falls back to basic chunking if grammar is not available.
|
|
19
|
+
*/
|
|
20
|
+
export declare class TreeSitterParser implements IParser {
|
|
21
|
+
readonly supportedLanguages: ParserLanguage[];
|
|
22
|
+
private grammarManager;
|
|
23
|
+
private parserInstance;
|
|
24
|
+
private loadedLanguages;
|
|
25
|
+
private initPromise;
|
|
26
|
+
/**
|
|
27
|
+
* Parse source code into semantic chunks using tree-sitter.
|
|
28
|
+
*/
|
|
29
|
+
parse(content: string, filepath: string, config?: ParserConfig): Promise<ParseResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if this parser can handle the given file.
|
|
32
|
+
*/
|
|
33
|
+
canParse(filepath: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Detect language from file extension.
|
|
36
|
+
*/
|
|
37
|
+
private detectLanguage;
|
|
38
|
+
/**
|
|
39
|
+
* Ensure tree-sitter is initialized.
|
|
40
|
+
*/
|
|
41
|
+
private ensureInitialized;
|
|
42
|
+
/**
|
|
43
|
+
* Initialize web-tree-sitter.
|
|
44
|
+
*/
|
|
45
|
+
private initializeTreeSitter;
|
|
46
|
+
/**
|
|
47
|
+
* Load a language module for tree-sitter.
|
|
48
|
+
* Returns null if the language is not available.
|
|
49
|
+
*/
|
|
50
|
+
private loadLanguage;
|
|
51
|
+
/**
|
|
52
|
+
* Parse source code with tree-sitter.
|
|
53
|
+
*/
|
|
54
|
+
private parseWithTreeSitter;
|
|
55
|
+
/**
|
|
56
|
+
* Extract chunks from Python AST.
|
|
57
|
+
*/
|
|
58
|
+
private extractPythonChunks;
|
|
59
|
+
/**
|
|
60
|
+
* Extract chunks from Go AST.
|
|
61
|
+
*/
|
|
62
|
+
private extractGoChunks;
|
|
63
|
+
/**
|
|
64
|
+
* Extract chunks from Rust AST.
|
|
65
|
+
*/
|
|
66
|
+
private extractRustChunks;
|
|
67
|
+
/**
|
|
68
|
+
* Extract chunks from Java AST.
|
|
69
|
+
*/
|
|
70
|
+
private extractJavaChunks;
|
|
71
|
+
/**
|
|
72
|
+
* Extract generic chunks.
|
|
73
|
+
*/
|
|
74
|
+
private extractGenericChunks;
|
|
75
|
+
/**
|
|
76
|
+
* Create a chunk from a tree-sitter node.
|
|
77
|
+
*/
|
|
78
|
+
private createChunkFromNode;
|
|
79
|
+
/**
|
|
80
|
+
* Get the text content of a tree-sitter node.
|
|
81
|
+
*/
|
|
82
|
+
private getNodeText;
|
|
83
|
+
/**
|
|
84
|
+
* Find a preceding comment (for Go-style comments).
|
|
85
|
+
*/
|
|
86
|
+
private findPrecedingComment;
|
|
87
|
+
/**
|
|
88
|
+
* Find Rust doc comments (/// or //!).
|
|
89
|
+
*/
|
|
90
|
+
private findRustDocComment;
|
|
91
|
+
/**
|
|
92
|
+
* Find Javadoc comments.
|
|
93
|
+
*/
|
|
94
|
+
private findJavadoc;
|
|
95
|
+
/**
|
|
96
|
+
* Fall back to basic line-based parsing.
|
|
97
|
+
*/
|
|
98
|
+
private fallbackParse;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new tree-sitter parser instance.
|
|
102
|
+
*/
|
|
103
|
+
export declare function createTreeSitterParser(): TreeSitterParser;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Parser
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing TypeScript Compiler API-based parser in the IParser interface.
|
|
5
|
+
* This provides superior type information and JSDoc parsing for TS/JS files.
|
|
6
|
+
*
|
|
7
|
+
* For TypeScript and JavaScript files, this parser is preferred over tree-sitter
|
|
8
|
+
* because it has access to full type information and proven quality.
|
|
9
|
+
*/
|
|
10
|
+
import type { IParser, ParseResult, ParserConfig, ParserLanguage } from "../../domain/ports/parser";
|
|
11
|
+
/**
|
|
12
|
+
* TypeScript Parser implementation using TypeScript Compiler API.
|
|
13
|
+
*
|
|
14
|
+
* This is the primary parser for TypeScript and JavaScript files.
|
|
15
|
+
* It provides:
|
|
16
|
+
* - Accurate AST parsing
|
|
17
|
+
* - Full JSDoc extraction
|
|
18
|
+
* - Export detection
|
|
19
|
+
* - Type information
|
|
20
|
+
*/
|
|
21
|
+
export declare class TypeScriptParser implements IParser {
|
|
22
|
+
readonly supportedLanguages: ParserLanguage[];
|
|
23
|
+
/**
|
|
24
|
+
* Parse TypeScript/JavaScript source code into semantic chunks.
|
|
25
|
+
*/
|
|
26
|
+
parse(content: string, filepath: string, config?: ParserConfig): Promise<ParseResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if this parser can handle the given file.
|
|
29
|
+
*/
|
|
30
|
+
canParse(filepath: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Convert from the existing ParsedChunk format to the domain ParsedChunk format.
|
|
33
|
+
*/
|
|
34
|
+
private convertChunk;
|
|
35
|
+
/**
|
|
36
|
+
* Detect language from file extension.
|
|
37
|
+
*/
|
|
38
|
+
private detectLanguage;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a new TypeScript parser instance.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createTypeScriptParser(): TypeScriptParser;
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
* .raggrep/index/<module>/literals/
|
|
9
9
|
* └── _index.json (literal → chunk mappings)
|
|
10
10
|
*/
|
|
11
|
-
import type { ExtractedLiteral, DetectedLiteral, LiteralMatch } from "../../domain/entities/literal";
|
|
11
|
+
import type { ExtractedLiteral, DetectedLiteral, LiteralMatch, LiteralIndexEntry } from "../../domain/entities/literal";
|
|
12
12
|
/**
|
|
13
13
|
* Literal Index Manager
|
|
14
14
|
*
|
|
15
15
|
* Manages the literal index for exact-match boosting.
|
|
16
16
|
* Provides O(1) lookup for literal matches.
|
|
17
|
+
*
|
|
18
|
+
* Now also supports vocabulary-based search for partial matching:
|
|
19
|
+
* - Store vocabulary words extracted from literals
|
|
20
|
+
* - Search by vocabulary words to find partial matches
|
|
17
21
|
*/
|
|
18
22
|
export declare class LiteralIndex {
|
|
19
23
|
private indexPath;
|
|
@@ -22,6 +26,11 @@ export declare class LiteralIndex {
|
|
|
22
26
|
* In-memory index: lowercase literal value → entries
|
|
23
27
|
*/
|
|
24
28
|
private entries;
|
|
29
|
+
/**
|
|
30
|
+
* Vocabulary index: vocabulary word → literal values that contain it
|
|
31
|
+
* Used for partial matching (e.g., "user" → ["getUserById", "fetchUserData"])
|
|
32
|
+
*/
|
|
33
|
+
private vocabularyIndex;
|
|
25
34
|
/**
|
|
26
35
|
* Schema version for compatibility checking.
|
|
27
36
|
*/
|
|
@@ -32,6 +41,11 @@ export declare class LiteralIndex {
|
|
|
32
41
|
* Attempts to load from disk, creates empty index if not found.
|
|
33
42
|
*/
|
|
34
43
|
initialize(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Rebuild the vocabulary index from entries.
|
|
46
|
+
* Called after loading from disk.
|
|
47
|
+
*/
|
|
48
|
+
private rebuildVocabularyIndex;
|
|
35
49
|
/**
|
|
36
50
|
* Add literals from a chunk to the index.
|
|
37
51
|
*
|
|
@@ -68,6 +82,24 @@ export declare class LiteralIndex {
|
|
|
68
82
|
* @returns Array of chunk IDs
|
|
69
83
|
*/
|
|
70
84
|
getChunksForLiteral(literal: string): string[];
|
|
85
|
+
/**
|
|
86
|
+
* Find literals that contain a specific vocabulary word.
|
|
87
|
+
*
|
|
88
|
+
* @param word - The vocabulary word to search for
|
|
89
|
+
* @returns Array of literal entries that contain this word
|
|
90
|
+
*/
|
|
91
|
+
findByVocabulary(word: string): LiteralIndexEntry[];
|
|
92
|
+
/**
|
|
93
|
+
* Find matches for query by vocabulary words.
|
|
94
|
+
* Returns literals that contain any of the given vocabulary words.
|
|
95
|
+
*
|
|
96
|
+
* @param vocabularyWords - Words to search for
|
|
97
|
+
* @returns Array of matches with overlap information
|
|
98
|
+
*/
|
|
99
|
+
findByVocabularyWords(vocabularyWords: string[]): Array<{
|
|
100
|
+
entry: LiteralIndexEntry;
|
|
101
|
+
matchedWords: string[];
|
|
102
|
+
}>;
|
|
71
103
|
/**
|
|
72
104
|
* Save the index to disk.
|
|
73
105
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Structure:
|
|
8
8
|
* .raggrep/index/<module>/symbolic/
|
|
9
|
-
* ├── _meta.json (BM25 statistics)
|
|
9
|
+
* ├── _meta.json (BM25 statistics + serialized BM25 data)
|
|
10
10
|
* └── <filepath>.json (per-file summaries)
|
|
11
11
|
*/
|
|
12
12
|
import type { FileSummary } from "../../domain/entities";
|
|
@@ -14,6 +14,7 @@ import type { FileSummary } from "../../domain/entities";
|
|
|
14
14
|
* Symbolic Index Manager
|
|
15
15
|
*
|
|
16
16
|
* Manages the keyword-based index for fast file filtering.
|
|
17
|
+
* Supports incremental updates to avoid full rebuilds.
|
|
17
18
|
*/
|
|
18
19
|
export declare class SymbolicIndex {
|
|
19
20
|
private meta;
|
|
@@ -27,15 +28,29 @@ export declare class SymbolicIndex {
|
|
|
27
28
|
*/
|
|
28
29
|
initialize(): Promise<void>;
|
|
29
30
|
/**
|
|
30
|
-
* Add or update a file summary
|
|
31
|
+
* Add or update a file summary (for batch operations, use with buildBM25Index)
|
|
31
32
|
*/
|
|
32
33
|
addFile(summary: FileSummary): void;
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* Add or update a file summary with incremental BM25 update.
|
|
36
|
+
* Use this for incremental indexing instead of addFile + buildBM25Index.
|
|
37
|
+
*/
|
|
38
|
+
addFileIncremental(summary: FileSummary): void;
|
|
39
|
+
/**
|
|
40
|
+
* Remove a file from the index (for batch operations)
|
|
35
41
|
*/
|
|
36
42
|
removeFile(filepath: string): boolean;
|
|
37
43
|
/**
|
|
38
|
-
*
|
|
44
|
+
* Remove a file from the index with incremental BM25 update.
|
|
45
|
+
* Use this for incremental indexing.
|
|
46
|
+
*/
|
|
47
|
+
removeFileIncremental(filepath: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get tokens for a file summary (for BM25 indexing)
|
|
50
|
+
*/
|
|
51
|
+
private getTokensForSummary;
|
|
52
|
+
/**
|
|
53
|
+
* Build BM25 index from file summaries (full rebuild)
|
|
39
54
|
*/
|
|
40
55
|
buildBM25Index(): void;
|
|
41
56
|
/**
|
|
@@ -51,9 +66,14 @@ export declare class SymbolicIndex {
|
|
|
51
66
|
*/
|
|
52
67
|
getFileSummary(filepath: string): FileSummary | undefined;
|
|
53
68
|
/**
|
|
54
|
-
* Save the index to disk (per-file structure)
|
|
69
|
+
* Save the index to disk (per-file structure with BM25 serialization)
|
|
55
70
|
*/
|
|
56
71
|
save(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Save only the updated file summaries (for incremental saves)
|
|
74
|
+
* @param filepaths - List of filepaths that were updated
|
|
75
|
+
*/
|
|
76
|
+
saveIncremental(filepaths: string[]): Promise<void>;
|
|
57
77
|
/**
|
|
58
78
|
* Load the index from disk
|
|
59
79
|
*/
|
|
@@ -48,7 +48,8 @@ export declare class JsonModule implements IndexModule {
|
|
|
48
48
|
initialize(config: ModuleConfig): Promise<void>;
|
|
49
49
|
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
50
50
|
/**
|
|
51
|
-
* Finalize indexing by building and saving the symbolic and literal indexes
|
|
51
|
+
* Finalize indexing by building and saving the symbolic and literal indexes.
|
|
52
|
+
* Uses incremental updates when possible to avoid full rebuilds.
|
|
52
53
|
*/
|
|
53
54
|
finalize(ctx: IndexContext): Promise<void>;
|
|
54
55
|
/**
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Language Index Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Go-aware code search using:
|
|
5
|
+
* - AST parsing via tree-sitter (with regex fallback)
|
|
6
|
+
* - Local text embeddings for semantic similarity
|
|
7
|
+
* - BM25 keyword matching for fast filtering
|
|
8
|
+
*
|
|
9
|
+
* Supported file types: .go
|
|
10
|
+
*
|
|
11
|
+
* Index location: .raggrep/index/language/go/
|
|
12
|
+
*/
|
|
13
|
+
import { IndexModule, IndexContext, SearchContext, SearchOptions, FileIndex, SearchResult, ModuleConfig } from "../../../types";
|
|
14
|
+
/** Default minimum similarity score for search results */
|
|
15
|
+
export declare const DEFAULT_MIN_SCORE = 0.15;
|
|
16
|
+
/** Default number of results to return */
|
|
17
|
+
export declare const DEFAULT_TOP_K = 10;
|
|
18
|
+
/** File extensions supported by this module */
|
|
19
|
+
export declare const GO_EXTENSIONS: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Check if a file is supported by this module.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isGoFile(filepath: string): boolean;
|
|
24
|
+
export declare const supportsFile: typeof isGoFile;
|
|
25
|
+
/**
|
|
26
|
+
* Module-specific data stored alongside file index.
|
|
27
|
+
*/
|
|
28
|
+
export interface GoModuleData {
|
|
29
|
+
embeddings: number[][];
|
|
30
|
+
embeddingModel: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare class GoModule implements IndexModule {
|
|
34
|
+
readonly id = "language/go";
|
|
35
|
+
readonly name = "Go Search";
|
|
36
|
+
readonly description = "Go-aware code search with AST parsing and semantic embeddings";
|
|
37
|
+
readonly version = "1.0.0";
|
|
38
|
+
supportsFile(filepath: string): boolean;
|
|
39
|
+
private embeddingConfig;
|
|
40
|
+
private symbolicIndex;
|
|
41
|
+
private literalIndex;
|
|
42
|
+
private pendingSummaries;
|
|
43
|
+
private pendingLiterals;
|
|
44
|
+
private rootDir;
|
|
45
|
+
private logger;
|
|
46
|
+
initialize(config: ModuleConfig): Promise<void>;
|
|
47
|
+
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Regex-based fallback parser for Go.
|
|
50
|
+
*/
|
|
51
|
+
private parseGoRegex;
|
|
52
|
+
/**
|
|
53
|
+
* Create file index from parsed chunks.
|
|
54
|
+
*/
|
|
55
|
+
private createFileIndex;
|
|
56
|
+
finalize(ctx: IndexContext): Promise<void>;
|
|
57
|
+
search(query: string, ctx: SearchContext, options?: SearchOptions): Promise<SearchResult[]>;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Python Language Index Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Python-aware code search using:
|
|
5
|
+
* - AST parsing via tree-sitter (with regex fallback)
|
|
6
|
+
* - Local text embeddings for semantic similarity
|
|
7
|
+
* - BM25 keyword matching for fast filtering
|
|
8
|
+
*
|
|
9
|
+
* Supported file types: .py, .pyw
|
|
10
|
+
*
|
|
11
|
+
* Index location: .raggrep/index/language/python/
|
|
12
|
+
*/
|
|
13
|
+
import { IndexModule, IndexContext, SearchContext, SearchOptions, FileIndex, SearchResult, ModuleConfig } from "../../../types";
|
|
14
|
+
/** Default minimum similarity score for search results */
|
|
15
|
+
export declare const DEFAULT_MIN_SCORE = 0.15;
|
|
16
|
+
/** Default number of results to return */
|
|
17
|
+
export declare const DEFAULT_TOP_K = 10;
|
|
18
|
+
/** File extensions supported by this module */
|
|
19
|
+
export declare const PYTHON_EXTENSIONS: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Check if a file is supported by this module.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPythonFile(filepath: string): boolean;
|
|
24
|
+
export declare const supportsFile: typeof isPythonFile;
|
|
25
|
+
/**
|
|
26
|
+
* Module-specific data stored alongside file index.
|
|
27
|
+
*/
|
|
28
|
+
export interface PythonModuleData {
|
|
29
|
+
embeddings: number[][];
|
|
30
|
+
embeddingModel: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare class PythonModule implements IndexModule {
|
|
34
|
+
readonly id = "language/python";
|
|
35
|
+
readonly name = "Python Search";
|
|
36
|
+
readonly description = "Python-aware code search with AST parsing and semantic embeddings";
|
|
37
|
+
readonly version = "1.0.0";
|
|
38
|
+
supportsFile(filepath: string): boolean;
|
|
39
|
+
private embeddingConfig;
|
|
40
|
+
private symbolicIndex;
|
|
41
|
+
private literalIndex;
|
|
42
|
+
private pendingSummaries;
|
|
43
|
+
private pendingLiterals;
|
|
44
|
+
private rootDir;
|
|
45
|
+
private logger;
|
|
46
|
+
initialize(config: ModuleConfig): Promise<void>;
|
|
47
|
+
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Regex-based fallback parser for Python.
|
|
50
|
+
* Used when tree-sitter is not available.
|
|
51
|
+
*/
|
|
52
|
+
private parsePythonRegex;
|
|
53
|
+
/**
|
|
54
|
+
* Create file index from parsed chunks.
|
|
55
|
+
*/
|
|
56
|
+
private createFileIndex;
|
|
57
|
+
finalize(ctx: IndexContext): Promise<void>;
|
|
58
|
+
search(query: string, ctx: SearchContext, options?: SearchOptions): Promise<SearchResult[]>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust Language Index Module
|
|
3
|
+
*
|
|
4
|
+
* Provides Rust-aware code search using:
|
|
5
|
+
* - AST parsing via tree-sitter (with regex fallback)
|
|
6
|
+
* - Local text embeddings for semantic similarity
|
|
7
|
+
* - BM25 keyword matching for fast filtering
|
|
8
|
+
*
|
|
9
|
+
* Supported file types: .rs
|
|
10
|
+
*
|
|
11
|
+
* Index location: .raggrep/index/language/rust/
|
|
12
|
+
*/
|
|
13
|
+
import { IndexModule, IndexContext, SearchContext, SearchOptions, FileIndex, SearchResult, ModuleConfig } from "../../../types";
|
|
14
|
+
/** Default minimum similarity score for search results */
|
|
15
|
+
export declare const DEFAULT_MIN_SCORE = 0.15;
|
|
16
|
+
/** Default number of results to return */
|
|
17
|
+
export declare const DEFAULT_TOP_K = 10;
|
|
18
|
+
/** File extensions supported by this module */
|
|
19
|
+
export declare const RUST_EXTENSIONS: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Check if a file is supported by this module.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isRustFile(filepath: string): boolean;
|
|
24
|
+
export declare const supportsFile: typeof isRustFile;
|
|
25
|
+
/**
|
|
26
|
+
* Module-specific data stored alongside file index.
|
|
27
|
+
*/
|
|
28
|
+
export interface RustModuleData {
|
|
29
|
+
embeddings: number[][];
|
|
30
|
+
embeddingModel: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export declare class RustModule implements IndexModule {
|
|
34
|
+
readonly id = "language/rust";
|
|
35
|
+
readonly name = "Rust Search";
|
|
36
|
+
readonly description = "Rust-aware code search with AST parsing and semantic embeddings";
|
|
37
|
+
readonly version = "1.0.0";
|
|
38
|
+
supportsFile(filepath: string): boolean;
|
|
39
|
+
private embeddingConfig;
|
|
40
|
+
private symbolicIndex;
|
|
41
|
+
private literalIndex;
|
|
42
|
+
private pendingSummaries;
|
|
43
|
+
private pendingLiterals;
|
|
44
|
+
private rootDir;
|
|
45
|
+
private logger;
|
|
46
|
+
initialize(config: ModuleConfig): Promise<void>;
|
|
47
|
+
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Regex-based fallback parser for Rust.
|
|
50
|
+
*/
|
|
51
|
+
private parseRustRegex;
|
|
52
|
+
/**
|
|
53
|
+
* Create file index from parsed chunks.
|
|
54
|
+
*/
|
|
55
|
+
private createFileIndex;
|
|
56
|
+
finalize(ctx: IndexContext): Promise<void>;
|
|
57
|
+
search(query: string, ctx: SearchContext, options?: SearchOptions): Promise<SearchResult[]>;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -48,7 +48,8 @@ export declare class TypeScriptModule implements IndexModule {
|
|
|
48
48
|
initialize(config: ModuleConfig): Promise<void>;
|
|
49
49
|
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
50
50
|
/**
|
|
51
|
-
* Finalize indexing by building and saving the symbolic and literal indexes
|
|
51
|
+
* Finalize indexing by building and saving the symbolic and literal indexes.
|
|
52
|
+
* Uses incremental updates when possible to avoid full rebuilds.
|
|
52
53
|
*/
|
|
53
54
|
finalize(ctx: IndexContext): Promise<void>;
|
|
54
55
|
/**
|