raggrep 0.6.0 → 0.7.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.
@@ -5,3 +5,4 @@
5
5
  */
6
6
  export { FileIndexStorage } from "./fileIndexStorage";
7
7
  export { SymbolicIndex, getSymbolicPath } from "./symbolicIndex";
8
+ export { LiteralIndex, getLiteralIndexPath } from "./literalIndex";
@@ -0,0 +1,103 @@
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
+ * Find matches for query literals.
51
+ *
52
+ * @param queryLiterals - Literals detected in the query
53
+ * @returns Array of matches with chunk IDs and filepaths
54
+ */
55
+ findMatches(queryLiterals: DetectedLiteral[]): LiteralMatch[];
56
+ /**
57
+ * Get all chunk IDs that contain a specific literal.
58
+ *
59
+ * @param literal - The literal value to search for
60
+ * @returns Array of chunk IDs
61
+ */
62
+ getChunksForLiteral(literal: string): string[];
63
+ /**
64
+ * Save the index to disk.
65
+ */
66
+ save(): Promise<void>;
67
+ /**
68
+ * Load the index from disk.
69
+ */
70
+ load(): Promise<void>;
71
+ /**
72
+ * Check if the index exists on disk.
73
+ */
74
+ exists(): Promise<boolean>;
75
+ /**
76
+ * Clear the index.
77
+ */
78
+ clear(): void;
79
+ /**
80
+ * Get the number of unique literals in the index.
81
+ */
82
+ get size(): number;
83
+ /**
84
+ * Get the total number of literal-to-chunk mappings.
85
+ */
86
+ get totalMappings(): number;
87
+ /**
88
+ * Get all unique literals in the index.
89
+ */
90
+ getAllLiterals(): string[];
91
+ /**
92
+ * Build a map from chunk ID to literal matches for a set of query literals.
93
+ * Convenience method for search integration.
94
+ *
95
+ * @param queryLiterals - Literals detected in the query
96
+ * @returns Map from chunk ID to array of matches
97
+ */
98
+ buildMatchMap(queryLiterals: DetectedLiteral[]): Map<string, LiteralMatch[]>;
99
+ }
100
+ /**
101
+ * Get the literal index path for a module.
102
+ */
103
+ 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 index
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 tiered approach for efficient search:
55
- * 1. Tier 1: Use BM25 on file summaries to find candidate files
56
- * 2. Tier 2: Load only candidate files and compute semantic similarity
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raggrep",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",