raggrep 0.6.1 → 0.7.1
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 +2 -0
- package/dist/cli/main.js +718 -123
- package/dist/cli/main.js.map +12 -8
- package/dist/domain/entities/index.d.ts +2 -0
- package/dist/domain/entities/literal.d.ts +101 -0
- package/dist/domain/services/index.d.ts +3 -0
- package/dist/domain/services/literalExtractor.d.ts +35 -0
- package/dist/domain/services/literalScorer.d.ts +93 -0
- package/dist/domain/services/queryLiteralParser.d.ts +20 -0
- package/dist/domain/services/queryLiteralParser.test.d.ts +7 -0
- package/dist/index.js +713 -118
- package/dist/index.js.map +12 -8
- package/dist/infrastructure/storage/index.d.ts +1 -0
- package/dist/infrastructure/storage/literalIndex.d.ts +111 -0
- package/dist/modules/language/typescript/index.d.ts +8 -4
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Literal Index Storage
|
|
3
|
+
*
|
|
4
|
+
* Manages the literal index for exact-match boosting.
|
|
5
|
+
* Handles file I/O for persisting literal data.
|
|
6
|
+
*
|
|
7
|
+
* Structure:
|
|
8
|
+
* .raggrep/index/<module>/literals/
|
|
9
|
+
* └── _index.json (literal → chunk mappings)
|
|
10
|
+
*/
|
|
11
|
+
import type { ExtractedLiteral, DetectedLiteral, LiteralMatch } from "../../domain/entities/literal";
|
|
12
|
+
/**
|
|
13
|
+
* Literal Index Manager
|
|
14
|
+
*
|
|
15
|
+
* Manages the literal index for exact-match boosting.
|
|
16
|
+
* Provides O(1) lookup for literal matches.
|
|
17
|
+
*/
|
|
18
|
+
export declare class LiteralIndex {
|
|
19
|
+
private indexPath;
|
|
20
|
+
private moduleId;
|
|
21
|
+
/**
|
|
22
|
+
* In-memory index: lowercase literal value → entries
|
|
23
|
+
*/
|
|
24
|
+
private entries;
|
|
25
|
+
/**
|
|
26
|
+
* Schema version for compatibility checking.
|
|
27
|
+
*/
|
|
28
|
+
private static readonly VERSION;
|
|
29
|
+
constructor(indexDir: string, moduleId: string);
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the literal index.
|
|
32
|
+
* Attempts to load from disk, creates empty index if not found.
|
|
33
|
+
*/
|
|
34
|
+
initialize(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Add literals from a chunk to the index.
|
|
37
|
+
*
|
|
38
|
+
* @param chunkId - Unique identifier for the chunk
|
|
39
|
+
* @param filepath - Path to the file containing the chunk
|
|
40
|
+
* @param literals - Extracted literals from the chunk
|
|
41
|
+
*/
|
|
42
|
+
addLiterals(chunkId: string, filepath: string, literals: ExtractedLiteral[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Remove all literals for a chunk.
|
|
45
|
+
*
|
|
46
|
+
* @param chunkId - Chunk ID to remove
|
|
47
|
+
*/
|
|
48
|
+
removeChunk(chunkId: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Remove all literals for a file.
|
|
51
|
+
* Used when a file is re-indexed or deleted.
|
|
52
|
+
*
|
|
53
|
+
* @param filepath - Filepath to remove all literals for
|
|
54
|
+
* @returns Number of literals removed
|
|
55
|
+
*/
|
|
56
|
+
removeFile(filepath: string): number;
|
|
57
|
+
/**
|
|
58
|
+
* Find matches for query literals.
|
|
59
|
+
*
|
|
60
|
+
* @param queryLiterals - Literals detected in the query
|
|
61
|
+
* @returns Array of matches with chunk IDs and filepaths
|
|
62
|
+
*/
|
|
63
|
+
findMatches(queryLiterals: DetectedLiteral[]): LiteralMatch[];
|
|
64
|
+
/**
|
|
65
|
+
* Get all chunk IDs that contain a specific literal.
|
|
66
|
+
*
|
|
67
|
+
* @param literal - The literal value to search for
|
|
68
|
+
* @returns Array of chunk IDs
|
|
69
|
+
*/
|
|
70
|
+
getChunksForLiteral(literal: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Save the index to disk.
|
|
73
|
+
*/
|
|
74
|
+
save(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Load the index from disk.
|
|
77
|
+
*/
|
|
78
|
+
load(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Check if the index exists on disk.
|
|
81
|
+
*/
|
|
82
|
+
exists(): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* Clear the index.
|
|
85
|
+
*/
|
|
86
|
+
clear(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get the number of unique literals in the index.
|
|
89
|
+
*/
|
|
90
|
+
get size(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Get the total number of literal-to-chunk mappings.
|
|
93
|
+
*/
|
|
94
|
+
get totalMappings(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Get all unique literals in the index.
|
|
97
|
+
*/
|
|
98
|
+
getAllLiterals(): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Build a map from chunk ID to literal matches for a set of query literals.
|
|
101
|
+
* Convenience method for search integration.
|
|
102
|
+
*
|
|
103
|
+
* @param queryLiterals - Literals detected in the query
|
|
104
|
+
* @returns Map from chunk ID to array of matches
|
|
105
|
+
*/
|
|
106
|
+
buildMatchMap(queryLiterals: DetectedLiteral[]): Map<string, LiteralMatch[]>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get the literal index path for a module.
|
|
110
|
+
*/
|
|
111
|
+
export declare function getLiteralIndexPath(rootDir: string, moduleId: string, indexDir?: string): string;
|
|
@@ -39,21 +39,25 @@ export declare class TypeScriptModule implements IndexModule {
|
|
|
39
39
|
supportsFile(filepath: string): boolean;
|
|
40
40
|
private embeddingConfig;
|
|
41
41
|
private symbolicIndex;
|
|
42
|
+
private literalIndex;
|
|
42
43
|
private pendingSummaries;
|
|
44
|
+
/** Map from chunkId → { filepath, literals } for building literal index */
|
|
45
|
+
private pendingLiterals;
|
|
43
46
|
private rootDir;
|
|
44
47
|
private logger;
|
|
45
48
|
initialize(config: ModuleConfig): Promise<void>;
|
|
46
49
|
indexFile(filepath: string, content: string, ctx: IndexContext): Promise<FileIndex | null>;
|
|
47
50
|
/**
|
|
48
|
-
* Finalize indexing by building and saving the symbolic
|
|
51
|
+
* Finalize indexing by building and saving the symbolic and literal indexes
|
|
49
52
|
*/
|
|
50
53
|
finalize(ctx: IndexContext): Promise<void>;
|
|
51
54
|
/**
|
|
52
55
|
* Search the semantic index for chunks matching the query.
|
|
53
56
|
*
|
|
54
|
-
* Uses a
|
|
55
|
-
* 1.
|
|
56
|
-
* 2.
|
|
57
|
+
* Uses a three-source approach:
|
|
58
|
+
* 1. Semantic search with embeddings
|
|
59
|
+
* 2. BM25 keyword search
|
|
60
|
+
* 3. Literal index for exact-match boosting
|
|
57
61
|
*
|
|
58
62
|
* @param query - Natural language search query
|
|
59
63
|
* @param ctx - Search context with index access
|