@mhalder/qdrant-mcp-server 1.3.1 → 1.5.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.
Files changed (118) hide show
  1. package/.codecov.yml +16 -0
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +304 -9
  4. package/build/code/chunker/base.d.ts +19 -0
  5. package/build/code/chunker/base.d.ts.map +1 -0
  6. package/build/code/chunker/base.js +5 -0
  7. package/build/code/chunker/base.js.map +1 -0
  8. package/build/code/chunker/character-chunker.d.ts +22 -0
  9. package/build/code/chunker/character-chunker.d.ts.map +1 -0
  10. package/build/code/chunker/character-chunker.js +111 -0
  11. package/build/code/chunker/character-chunker.js.map +1 -0
  12. package/build/code/chunker/tree-sitter-chunker.d.ts +29 -0
  13. package/build/code/chunker/tree-sitter-chunker.d.ts.map +1 -0
  14. package/build/code/chunker/tree-sitter-chunker.js +213 -0
  15. package/build/code/chunker/tree-sitter-chunker.js.map +1 -0
  16. package/build/code/config.d.ts +11 -0
  17. package/build/code/config.d.ts.map +1 -0
  18. package/build/code/config.js +145 -0
  19. package/build/code/config.js.map +1 -0
  20. package/build/code/indexer.d.ts +42 -0
  21. package/build/code/indexer.d.ts.map +1 -0
  22. package/build/code/indexer.js +508 -0
  23. package/build/code/indexer.js.map +1 -0
  24. package/build/code/metadata.d.ts +32 -0
  25. package/build/code/metadata.d.ts.map +1 -0
  26. package/build/code/metadata.js +128 -0
  27. package/build/code/metadata.js.map +1 -0
  28. package/build/code/scanner.d.ts +35 -0
  29. package/build/code/scanner.d.ts.map +1 -0
  30. package/build/code/scanner.js +108 -0
  31. package/build/code/scanner.js.map +1 -0
  32. package/build/code/sync/merkle.d.ts +45 -0
  33. package/build/code/sync/merkle.d.ts.map +1 -0
  34. package/build/code/sync/merkle.js +116 -0
  35. package/build/code/sync/merkle.js.map +1 -0
  36. package/build/code/sync/snapshot.d.ts +41 -0
  37. package/build/code/sync/snapshot.d.ts.map +1 -0
  38. package/build/code/sync/snapshot.js +91 -0
  39. package/build/code/sync/snapshot.js.map +1 -0
  40. package/build/code/sync/synchronizer.d.ts +53 -0
  41. package/build/code/sync/synchronizer.d.ts.map +1 -0
  42. package/build/code/sync/synchronizer.js +132 -0
  43. package/build/code/sync/synchronizer.js.map +1 -0
  44. package/build/code/types.d.ts +98 -0
  45. package/build/code/types.d.ts.map +1 -0
  46. package/build/code/types.js +5 -0
  47. package/build/code/types.js.map +1 -0
  48. package/build/index.js +321 -6
  49. package/build/index.js.map +1 -1
  50. package/build/prompts/index.d.ts +7 -0
  51. package/build/prompts/index.d.ts.map +1 -0
  52. package/build/prompts/index.js +7 -0
  53. package/build/prompts/index.js.map +1 -0
  54. package/build/prompts/index.test.d.ts +2 -0
  55. package/build/prompts/index.test.d.ts.map +1 -0
  56. package/build/prompts/index.test.js +25 -0
  57. package/build/prompts/index.test.js.map +1 -0
  58. package/build/prompts/loader.d.ts +25 -0
  59. package/build/prompts/loader.d.ts.map +1 -0
  60. package/build/prompts/loader.js +81 -0
  61. package/build/prompts/loader.js.map +1 -0
  62. package/build/prompts/loader.test.d.ts +2 -0
  63. package/build/prompts/loader.test.d.ts.map +1 -0
  64. package/build/prompts/loader.test.js +417 -0
  65. package/build/prompts/loader.test.js.map +1 -0
  66. package/build/prompts/template.d.ts +20 -0
  67. package/build/prompts/template.d.ts.map +1 -0
  68. package/build/prompts/template.js +52 -0
  69. package/build/prompts/template.js.map +1 -0
  70. package/build/prompts/template.test.d.ts +2 -0
  71. package/build/prompts/template.test.d.ts.map +1 -0
  72. package/build/prompts/template.test.js +163 -0
  73. package/build/prompts/template.test.js.map +1 -0
  74. package/build/prompts/types.d.ts +34 -0
  75. package/build/prompts/types.d.ts.map +1 -0
  76. package/build/prompts/types.js +5 -0
  77. package/build/prompts/types.js.map +1 -0
  78. package/examples/code-search/README.md +271 -0
  79. package/package.json +13 -1
  80. package/prompts.example.json +96 -0
  81. package/src/code/chunker/base.ts +22 -0
  82. package/src/code/chunker/character-chunker.ts +131 -0
  83. package/src/code/chunker/tree-sitter-chunker.ts +250 -0
  84. package/src/code/config.ts +156 -0
  85. package/src/code/indexer.ts +613 -0
  86. package/src/code/metadata.ts +153 -0
  87. package/src/code/scanner.ts +124 -0
  88. package/src/code/sync/merkle.ts +136 -0
  89. package/src/code/sync/snapshot.ts +110 -0
  90. package/src/code/sync/synchronizer.ts +154 -0
  91. package/src/code/types.ts +117 -0
  92. package/src/index.ts +382 -5
  93. package/src/prompts/index.test.ts +29 -0
  94. package/src/prompts/index.ts +7 -0
  95. package/src/prompts/loader.test.ts +494 -0
  96. package/src/prompts/loader.ts +90 -0
  97. package/src/prompts/template.test.ts +212 -0
  98. package/src/prompts/template.ts +69 -0
  99. package/src/prompts/types.ts +37 -0
  100. package/tests/code/chunker/character-chunker.test.ts +141 -0
  101. package/tests/code/chunker/tree-sitter-chunker.test.ts +275 -0
  102. package/tests/code/fixtures/sample-py/calculator.py +32 -0
  103. package/tests/code/fixtures/sample-ts/async-operations.ts +120 -0
  104. package/tests/code/fixtures/sample-ts/auth.ts +31 -0
  105. package/tests/code/fixtures/sample-ts/config.ts +52 -0
  106. package/tests/code/fixtures/sample-ts/database.ts +50 -0
  107. package/tests/code/fixtures/sample-ts/index.ts +39 -0
  108. package/tests/code/fixtures/sample-ts/types-advanced.ts +132 -0
  109. package/tests/code/fixtures/sample-ts/utils.ts +105 -0
  110. package/tests/code/fixtures/sample-ts/validator.ts +169 -0
  111. package/tests/code/indexer.test.ts +828 -0
  112. package/tests/code/integration.test.ts +708 -0
  113. package/tests/code/metadata.test.ts +457 -0
  114. package/tests/code/scanner.test.ts +131 -0
  115. package/tests/code/sync/merkle.test.ts +406 -0
  116. package/tests/code/sync/snapshot.test.ts +360 -0
  117. package/tests/code/sync/synchronizer.test.ts +501 -0
  118. package/vitest.config.ts +1 -0
@@ -0,0 +1,508 @@
1
+ /**
2
+ * CodeIndexer - Main orchestrator for code vectorization
3
+ */
4
+ import { createHash } from "node:crypto";
5
+ import { promises as fs } from "node:fs";
6
+ import { extname, join, relative, resolve } from "node:path";
7
+ import { BM25SparseVectorGenerator } from "../embeddings/sparse.js";
8
+ import { TreeSitterChunker } from "./chunker/tree-sitter-chunker.js";
9
+ import { MetadataExtractor } from "./metadata.js";
10
+ import { FileScanner } from "./scanner.js";
11
+ import { FileSynchronizer } from "./sync/synchronizer.js";
12
+ export class CodeIndexer {
13
+ qdrant;
14
+ embeddings;
15
+ config;
16
+ constructor(qdrant, embeddings, config) {
17
+ this.qdrant = qdrant;
18
+ this.embeddings = embeddings;
19
+ this.config = config;
20
+ }
21
+ /**
22
+ * Validate that a path doesn't attempt directory traversal
23
+ * @throws Error if path traversal is detected
24
+ */
25
+ async validatePath(path) {
26
+ const absolutePath = resolve(path);
27
+ try {
28
+ // Resolve the real path (follows symlinks)
29
+ const realPath = await fs.realpath(absolutePath);
30
+ // For now, we just ensure the path exists and is resolved
31
+ // In a more restrictive environment, you could check against an allowlist
32
+ return realPath;
33
+ }
34
+ catch (error) {
35
+ // If realpath fails, the path doesn't exist yet or is invalid
36
+ // For operations like indexing, we still need to accept non-existent paths
37
+ // so we just return the resolved absolute path
38
+ return absolutePath;
39
+ }
40
+ }
41
+ /**
42
+ * Index a codebase from scratch or force re-index
43
+ */
44
+ async indexCodebase(path, options, progressCallback) {
45
+ const startTime = Date.now();
46
+ const stats = {
47
+ filesScanned: 0,
48
+ filesIndexed: 0,
49
+ chunksCreated: 0,
50
+ durationMs: 0,
51
+ status: "completed",
52
+ errors: [],
53
+ };
54
+ try {
55
+ const absolutePath = await this.validatePath(path);
56
+ // 1. Scan files
57
+ progressCallback?.({
58
+ phase: "scanning",
59
+ current: 0,
60
+ total: 100,
61
+ percentage: 0,
62
+ message: "Scanning files...",
63
+ });
64
+ const scanner = new FileScanner({
65
+ supportedExtensions: options?.extensions || this.config.supportedExtensions,
66
+ ignorePatterns: this.config.ignorePatterns,
67
+ customIgnorePatterns: options?.ignorePatterns || this.config.customIgnorePatterns,
68
+ });
69
+ await scanner.loadIgnorePatterns(absolutePath);
70
+ const files = await scanner.scanDirectory(absolutePath);
71
+ stats.filesScanned = files.length;
72
+ if (files.length === 0) {
73
+ stats.status = "completed";
74
+ stats.durationMs = Date.now() - startTime;
75
+ return stats;
76
+ }
77
+ // 2. Create or verify collection
78
+ const collectionName = this.getCollectionName(absolutePath);
79
+ const collectionExists = await this.qdrant.collectionExists(collectionName);
80
+ if (options?.forceReindex && collectionExists) {
81
+ await this.qdrant.deleteCollection(collectionName);
82
+ }
83
+ if (!collectionExists || options?.forceReindex) {
84
+ const vectorSize = this.embeddings.getDimensions();
85
+ await this.qdrant.createCollection(collectionName, vectorSize, "Cosine", this.config.enableHybridSearch);
86
+ }
87
+ // 3. Process files and create chunks
88
+ const chunker = new TreeSitterChunker({
89
+ chunkSize: this.config.chunkSize,
90
+ chunkOverlap: this.config.chunkOverlap,
91
+ maxChunkSize: this.config.chunkSize * 2,
92
+ });
93
+ const metadataExtractor = new MetadataExtractor();
94
+ const allChunks = [];
95
+ for (const [index, filePath] of files.entries()) {
96
+ try {
97
+ progressCallback?.({
98
+ phase: "chunking",
99
+ current: index + 1,
100
+ total: files.length,
101
+ percentage: Math.round(((index + 1) / files.length) * 40), // 0-40%
102
+ message: `Chunking file ${index + 1}/${files.length}`,
103
+ });
104
+ const code = await fs.readFile(filePath, "utf-8");
105
+ // Check for secrets (basic detection)
106
+ if (metadataExtractor.containsSecrets(code)) {
107
+ stats.errors?.push(`Skipped ${filePath}: potential secrets detected`);
108
+ continue;
109
+ }
110
+ const language = metadataExtractor.extractLanguage(filePath);
111
+ const chunks = await chunker.chunk(code, filePath, language);
112
+ // Apply chunk limits if configured
113
+ const chunksToAdd = this.config.maxChunksPerFile
114
+ ? chunks.slice(0, this.config.maxChunksPerFile)
115
+ : chunks;
116
+ for (const chunk of chunksToAdd) {
117
+ const id = metadataExtractor.generateChunkId(chunk);
118
+ allChunks.push({ chunk, id });
119
+ // Check total chunk limit
120
+ if (this.config.maxTotalChunks && allChunks.length >= this.config.maxTotalChunks) {
121
+ break;
122
+ }
123
+ }
124
+ stats.filesIndexed++;
125
+ // Check total chunk limit
126
+ if (this.config.maxTotalChunks && allChunks.length >= this.config.maxTotalChunks) {
127
+ break;
128
+ }
129
+ }
130
+ catch (error) {
131
+ const errorMessage = error instanceof Error ? error.message : String(error);
132
+ stats.errors?.push(`Failed to process ${filePath}: ${errorMessage}`);
133
+ }
134
+ }
135
+ stats.chunksCreated = allChunks.length;
136
+ // Save snapshot for incremental updates (even if no chunks were created)
137
+ try {
138
+ const synchronizer = new FileSynchronizer(absolutePath, collectionName);
139
+ await synchronizer.updateSnapshot(files);
140
+ }
141
+ catch (error) {
142
+ // Snapshot failure shouldn't fail the entire indexing
143
+ const errorMessage = error instanceof Error ? error.message : String(error);
144
+ console.error("Failed to save snapshot:", errorMessage);
145
+ stats.errors?.push(`Snapshot save failed: ${errorMessage}`);
146
+ }
147
+ if (allChunks.length === 0) {
148
+ stats.status = "completed";
149
+ stats.durationMs = Date.now() - startTime;
150
+ return stats;
151
+ }
152
+ // 4. Generate embeddings and store in batches
153
+ const batchSize = this.config.batchSize;
154
+ for (let i = 0; i < allChunks.length; i += batchSize) {
155
+ const batch = allChunks.slice(i, i + batchSize);
156
+ progressCallback?.({
157
+ phase: "embedding",
158
+ current: i + batch.length,
159
+ total: allChunks.length,
160
+ percentage: 40 + Math.round(((i + batch.length) / allChunks.length) * 30), // 40-70%
161
+ message: `Generating embeddings ${i + batch.length}/${allChunks.length}`,
162
+ });
163
+ try {
164
+ const texts = batch.map((b) => b.chunk.content);
165
+ const embeddings = await this.embeddings.embedBatch(texts);
166
+ // 5. Store to Qdrant
167
+ const points = batch.map((b, idx) => ({
168
+ id: b.id,
169
+ vector: embeddings[idx].embedding,
170
+ payload: {
171
+ content: b.chunk.content,
172
+ relativePath: relative(absolutePath, b.chunk.metadata.filePath),
173
+ startLine: b.chunk.startLine,
174
+ endLine: b.chunk.endLine,
175
+ fileExtension: extname(b.chunk.metadata.filePath),
176
+ language: b.chunk.metadata.language,
177
+ codebasePath: absolutePath,
178
+ chunkIndex: b.chunk.metadata.chunkIndex,
179
+ ...(b.chunk.metadata.name && { name: b.chunk.metadata.name }),
180
+ ...(b.chunk.metadata.chunkType && { chunkType: b.chunk.metadata.chunkType }),
181
+ },
182
+ }));
183
+ progressCallback?.({
184
+ phase: "storing",
185
+ current: i + batch.length,
186
+ total: allChunks.length,
187
+ percentage: 70 + Math.round(((i + batch.length) / allChunks.length) * 30), // 70-100%
188
+ message: `Storing chunks ${i + batch.length}/${allChunks.length}`,
189
+ });
190
+ if (this.config.enableHybridSearch) {
191
+ // Generate sparse vectors for hybrid search
192
+ const sparseGenerator = new BM25SparseVectorGenerator();
193
+ const hybridPoints = batch.map((b, idx) => ({
194
+ id: b.id,
195
+ vector: embeddings[idx].embedding,
196
+ sparseVector: sparseGenerator.generate(b.chunk.content),
197
+ payload: {
198
+ content: b.chunk.content,
199
+ relativePath: relative(absolutePath, b.chunk.metadata.filePath),
200
+ startLine: b.chunk.startLine,
201
+ endLine: b.chunk.endLine,
202
+ fileExtension: extname(b.chunk.metadata.filePath),
203
+ language: b.chunk.metadata.language,
204
+ codebasePath: absolutePath,
205
+ chunkIndex: b.chunk.metadata.chunkIndex,
206
+ ...(b.chunk.metadata.name && { name: b.chunk.metadata.name }),
207
+ ...(b.chunk.metadata.chunkType && { chunkType: b.chunk.metadata.chunkType }),
208
+ },
209
+ }));
210
+ await this.qdrant.addPointsWithSparse(collectionName, hybridPoints);
211
+ }
212
+ else {
213
+ await this.qdrant.addPoints(collectionName, points);
214
+ }
215
+ }
216
+ catch (error) {
217
+ const errorMessage = error instanceof Error ? error.message : String(error);
218
+ stats.errors?.push(`Failed to process batch at index ${i}: ${errorMessage}`);
219
+ stats.status = "partial";
220
+ }
221
+ }
222
+ stats.durationMs = Date.now() - startTime;
223
+ return stats;
224
+ }
225
+ catch (error) {
226
+ const errorMessage = error instanceof Error ? error.message : String(error);
227
+ stats.status = "failed";
228
+ stats.errors?.push(`Indexing failed: ${errorMessage}`);
229
+ stats.durationMs = Date.now() - startTime;
230
+ return stats;
231
+ }
232
+ }
233
+ /**
234
+ * Search code semantically
235
+ */
236
+ async searchCode(path, query, options) {
237
+ const absolutePath = await this.validatePath(path);
238
+ const collectionName = this.getCollectionName(absolutePath);
239
+ // Check if collection exists
240
+ const exists = await this.qdrant.collectionExists(collectionName);
241
+ if (!exists) {
242
+ throw new Error(`Codebase not indexed: ${path}`);
243
+ }
244
+ // Check if collection has hybrid search enabled
245
+ const collectionInfo = await this.qdrant.getCollectionInfo(collectionName);
246
+ const useHybrid = (options?.useHybrid ?? this.config.enableHybridSearch) && collectionInfo.hybridEnabled;
247
+ // Generate query embedding
248
+ const { embedding } = await this.embeddings.embed(query);
249
+ // Build filter
250
+ let filter;
251
+ if (options?.fileTypes || options?.pathPattern) {
252
+ filter = { must: [] };
253
+ if (options.fileTypes && options.fileTypes.length > 0) {
254
+ filter.must.push({
255
+ key: "fileExtension",
256
+ match: { any: options.fileTypes },
257
+ });
258
+ }
259
+ if (options.pathPattern) {
260
+ // Convert glob pattern to regex (simplified)
261
+ const regex = options.pathPattern
262
+ .replace(/\./g, "\\.")
263
+ .replace(/\*\*/g, ".*")
264
+ .replace(/\*/g, "[^/]*")
265
+ .replace(/\?/g, ".");
266
+ filter.must.push({
267
+ key: "relativePath",
268
+ match: { text: regex },
269
+ });
270
+ }
271
+ }
272
+ // Search with hybrid or standard search
273
+ let results;
274
+ if (useHybrid) {
275
+ const sparseGenerator = new BM25SparseVectorGenerator();
276
+ const sparseVector = sparseGenerator.generate(query);
277
+ results = await this.qdrant.hybridSearch(collectionName, embedding, sparseVector, options?.limit || this.config.defaultSearchLimit, filter);
278
+ }
279
+ else {
280
+ results = await this.qdrant.search(collectionName, embedding, options?.limit || this.config.defaultSearchLimit, filter);
281
+ }
282
+ // Apply score threshold if specified
283
+ const filteredResults = options?.scoreThreshold
284
+ ? results.filter((r) => r.score >= (options.scoreThreshold || 0))
285
+ : results;
286
+ // Format results
287
+ return filteredResults.map((r) => ({
288
+ content: r.payload?.content || "",
289
+ filePath: r.payload?.relativePath || "",
290
+ startLine: r.payload?.startLine || 0,
291
+ endLine: r.payload?.endLine || 0,
292
+ language: r.payload?.language || "unknown",
293
+ score: r.score,
294
+ fileExtension: r.payload?.fileExtension || "",
295
+ }));
296
+ }
297
+ /**
298
+ * Get indexing status for a codebase
299
+ */
300
+ async getIndexStatus(path) {
301
+ const absolutePath = await this.validatePath(path);
302
+ const collectionName = this.getCollectionName(absolutePath);
303
+ const exists = await this.qdrant.collectionExists(collectionName);
304
+ if (!exists) {
305
+ return { isIndexed: false };
306
+ }
307
+ const info = await this.qdrant.getCollectionInfo(collectionName);
308
+ return {
309
+ isIndexed: true,
310
+ collectionName,
311
+ chunksCount: info.pointsCount,
312
+ // TODO: Extract unique languages and file count from collection
313
+ // This would require scrolling through points or maintaining separate metadata
314
+ };
315
+ }
316
+ /**
317
+ * Incrementally re-index only changed files
318
+ */
319
+ async reindexChanges(path, progressCallback) {
320
+ const startTime = Date.now();
321
+ const stats = {
322
+ filesAdded: 0,
323
+ filesModified: 0,
324
+ filesDeleted: 0,
325
+ chunksAdded: 0,
326
+ chunksDeleted: 0,
327
+ durationMs: 0,
328
+ };
329
+ try {
330
+ const absolutePath = await this.validatePath(path);
331
+ const collectionName = this.getCollectionName(absolutePath);
332
+ // Check if collection exists
333
+ const exists = await this.qdrant.collectionExists(collectionName);
334
+ if (!exists) {
335
+ throw new Error(`Codebase not indexed: ${path}`);
336
+ }
337
+ // Initialize synchronizer
338
+ const synchronizer = new FileSynchronizer(absolutePath, collectionName);
339
+ const hasSnapshot = await synchronizer.initialize();
340
+ if (!hasSnapshot) {
341
+ throw new Error("No previous snapshot found. Use index_codebase for initial indexing.");
342
+ }
343
+ // Scan current files
344
+ progressCallback?.({
345
+ phase: "scanning",
346
+ current: 0,
347
+ total: 100,
348
+ percentage: 0,
349
+ message: "Scanning for changes...",
350
+ });
351
+ const scanner = new FileScanner({
352
+ supportedExtensions: this.config.supportedExtensions,
353
+ ignorePatterns: this.config.ignorePatterns,
354
+ customIgnorePatterns: this.config.customIgnorePatterns,
355
+ });
356
+ await scanner.loadIgnorePatterns(absolutePath);
357
+ const currentFiles = await scanner.scanDirectory(absolutePath);
358
+ // Detect changes
359
+ const changes = await synchronizer.detectChanges(currentFiles);
360
+ stats.filesAdded = changes.added.length;
361
+ stats.filesModified = changes.modified.length;
362
+ stats.filesDeleted = changes.deleted.length;
363
+ if (stats.filesAdded === 0 && stats.filesModified === 0 && stats.filesDeleted === 0) {
364
+ stats.durationMs = Date.now() - startTime;
365
+ return stats;
366
+ }
367
+ const chunker = new TreeSitterChunker({
368
+ chunkSize: this.config.chunkSize,
369
+ chunkOverlap: this.config.chunkOverlap,
370
+ maxChunkSize: this.config.chunkSize * 2,
371
+ });
372
+ const metadataExtractor = new MetadataExtractor();
373
+ // Process deleted and modified files - collect chunk IDs to delete
374
+ const _chunkIdsToDelete = [];
375
+ const filesToReprocess = [...changes.modified, ...changes.deleted];
376
+ for (const _filePath of filesToReprocess) {
377
+ try {
378
+ // Read old file content to generate chunk IDs for deletion
379
+ // We need to regenerate the chunks to get their IDs
380
+ // For now, we'll use a simpler approach: delete based on file path
381
+ // This requires keeping track of chunk IDs per file
382
+ // Since we don't have a direct way to query by file path,
383
+ // we'll mark these as needing deletion by filename pattern
384
+ // For simplicity in Phase 2, we'll re-index everything
385
+ // A future enhancement would be to maintain a chunk ID mapping
386
+ }
387
+ catch (_error) {
388
+ // File might be deleted, skip
389
+ }
390
+ }
391
+ // For Phase 2 MVP: Simply re-process all changed files
392
+ // TODO Phase 3: Implement proper chunk deletion by maintaining chunk ID mapping
393
+ const filesToIndex = [...changes.added, ...changes.modified];
394
+ const allChunks = [];
395
+ for (const [index, filePath] of filesToIndex.entries()) {
396
+ try {
397
+ progressCallback?.({
398
+ phase: "chunking",
399
+ current: index + 1,
400
+ total: filesToIndex.length,
401
+ percentage: Math.round(((index + 1) / filesToIndex.length) * 40),
402
+ message: `Processing file ${index + 1}/${filesToIndex.length}`,
403
+ });
404
+ const absoluteFilePath = join(absolutePath, filePath);
405
+ const code = await fs.readFile(absoluteFilePath, "utf-8");
406
+ // Check for secrets
407
+ if (metadataExtractor.containsSecrets(code)) {
408
+ continue;
409
+ }
410
+ const language = metadataExtractor.extractLanguage(absoluteFilePath);
411
+ const chunks = await chunker.chunk(code, absoluteFilePath, language);
412
+ for (const chunk of chunks) {
413
+ const id = metadataExtractor.generateChunkId(chunk);
414
+ allChunks.push({ chunk, id });
415
+ }
416
+ }
417
+ catch (error) {
418
+ console.error(`Failed to process ${filePath}:`, error);
419
+ }
420
+ }
421
+ stats.chunksAdded = allChunks.length;
422
+ // Generate embeddings and store in batches
423
+ const batchSize = this.config.batchSize;
424
+ for (let i = 0; i < allChunks.length; i += batchSize) {
425
+ const batch = allChunks.slice(i, i + batchSize);
426
+ progressCallback?.({
427
+ phase: "embedding",
428
+ current: i + batch.length,
429
+ total: allChunks.length,
430
+ percentage: 40 + Math.round(((i + batch.length) / allChunks.length) * 30),
431
+ message: `Generating embeddings ${i + batch.length}/${allChunks.length}`,
432
+ });
433
+ const texts = batch.map((b) => b.chunk.content);
434
+ const embeddings = await this.embeddings.embedBatch(texts);
435
+ const points = batch.map((b, idx) => ({
436
+ id: b.id,
437
+ vector: embeddings[idx].embedding,
438
+ payload: {
439
+ content: b.chunk.content,
440
+ relativePath: relative(absolutePath, b.chunk.metadata.filePath),
441
+ startLine: b.chunk.startLine,
442
+ endLine: b.chunk.endLine,
443
+ fileExtension: extname(b.chunk.metadata.filePath),
444
+ language: b.chunk.metadata.language,
445
+ codebasePath: absolutePath,
446
+ chunkIndex: b.chunk.metadata.chunkIndex,
447
+ ...(b.chunk.metadata.name && { name: b.chunk.metadata.name }),
448
+ ...(b.chunk.metadata.chunkType && { chunkType: b.chunk.metadata.chunkType }),
449
+ },
450
+ }));
451
+ progressCallback?.({
452
+ phase: "storing",
453
+ current: i + batch.length,
454
+ total: allChunks.length,
455
+ percentage: 70 + Math.round(((i + batch.length) / allChunks.length) * 30),
456
+ message: `Storing chunks ${i + batch.length}/${allChunks.length}`,
457
+ });
458
+ if (this.config.enableHybridSearch) {
459
+ const sparseGenerator = new BM25SparseVectorGenerator();
460
+ const hybridPoints = points.map((point, idx) => ({
461
+ ...point,
462
+ sparseVector: sparseGenerator.generate(allChunks[i + idx].chunk.content),
463
+ }));
464
+ await this.qdrant.addPointsWithSparse(collectionName, hybridPoints);
465
+ }
466
+ else {
467
+ await this.qdrant.addPoints(collectionName, points);
468
+ }
469
+ }
470
+ // Update snapshot
471
+ await synchronizer.updateSnapshot(currentFiles);
472
+ stats.durationMs = Date.now() - startTime;
473
+ return stats;
474
+ }
475
+ catch (error) {
476
+ const errorMessage = error instanceof Error ? error.message : String(error);
477
+ throw new Error(`Incremental re-indexing failed: ${errorMessage}`);
478
+ }
479
+ }
480
+ /**
481
+ * Clear all indexed data for a codebase
482
+ */
483
+ async clearIndex(path) {
484
+ const absolutePath = await this.validatePath(path);
485
+ const collectionName = this.getCollectionName(absolutePath);
486
+ const exists = await this.qdrant.collectionExists(collectionName);
487
+ if (exists) {
488
+ await this.qdrant.deleteCollection(collectionName);
489
+ }
490
+ // Also delete snapshot
491
+ try {
492
+ const synchronizer = new FileSynchronizer(absolutePath, collectionName);
493
+ await synchronizer.deleteSnapshot();
494
+ }
495
+ catch (_error) {
496
+ // Ignore snapshot deletion errors
497
+ }
498
+ }
499
+ /**
500
+ * Generate deterministic collection name from codebase path
501
+ */
502
+ getCollectionName(path) {
503
+ const absolutePath = resolve(path);
504
+ const hash = createHash("md5").update(absolutePath).digest("hex");
505
+ return `code_${hash.substring(0, 8)}`;
506
+ }
507
+ }
508
+ //# sourceMappingURL=indexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/code/indexer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EA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G,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClE,OAAO,QAAQ,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MetadataExtractor - Extracts metadata from code chunks
3
+ */
4
+ import type { CodeChunk } from "./types.js";
5
+ export declare class MetadataExtractor {
6
+ /**
7
+ * Extract programming language from file path
8
+ */
9
+ extractLanguage(filePath: string): string;
10
+ /**
11
+ * Generate deterministic chunk ID based on content and location
12
+ * Format: chunk_{sha256(path:start:end:content)[:16]}
13
+ */
14
+ generateChunkId(chunk: CodeChunk): string;
15
+ /**
16
+ * Calculate simple code complexity score (optional)
17
+ * Based on: cyclomatic complexity indicators
18
+ */
19
+ calculateComplexity(code: string): number;
20
+ /**
21
+ * Detect potential secrets in code (basic pattern matching)
22
+ */
23
+ containsSecrets(code: string): boolean;
24
+ /**
25
+ * Extract imports/exports from code (basic regex-based)
26
+ */
27
+ extractImportsExports(code: string, language: string): {
28
+ imports: string[];
29
+ exports: string[];
30
+ };
31
+ }
32
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/code/metadata.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKzC;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAOzC;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAoCzC;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAsBtC;;OAEG;IACH,qBAAqB,CACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf;QACD,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB;CAiDF"}