@grec0/memory-bank-mcp 0.1.4 → 0.1.5
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/tools/analyzeCoverage.js +26 -20
- package/package.json +1 -1
|
@@ -234,34 +234,40 @@ export async function analyzeCoverage(indexManager, vectorStore, workspaceRoot,
|
|
|
234
234
|
console.error(`Error escaneando archivos: ${error}`);
|
|
235
235
|
throw error;
|
|
236
236
|
}
|
|
237
|
-
// 2. Get
|
|
238
|
-
console.error("Obteniendo
|
|
237
|
+
// 2. Get ALL chunks from vector store in ONE query (optimized)
|
|
238
|
+
console.error("Obteniendo todos los chunks indexados (query única)...");
|
|
239
239
|
await vectorStore.initialize();
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
//
|
|
240
|
+
const queryStart = Date.now();
|
|
241
|
+
const allChunks = await vectorStore.getAllChunks(projectId);
|
|
242
|
+
console.error(`Query completada en ${Date.now() - queryStart}ms - ${allChunks.length} chunks`);
|
|
243
|
+
// 3. Build indexed files map from chunks (in memory - fast)
|
|
244
|
+
console.error("Procesando chunks en memoria...");
|
|
244
245
|
const indexedFiles = new Map();
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
for (const chunk of allChunks) {
|
|
247
|
+
const existing = indexedFiles.get(chunk.file_path);
|
|
248
|
+
if (!existing) {
|
|
249
|
+
indexedFiles.set(chunk.file_path, {
|
|
250
|
+
lastIndexed: chunk.timestamp,
|
|
251
|
+
chunks: 1,
|
|
252
|
+
hash: chunk.file_hash,
|
|
252
253
|
});
|
|
253
254
|
}
|
|
255
|
+
else {
|
|
256
|
+
existing.chunks++;
|
|
257
|
+
// Keep most recent timestamp
|
|
258
|
+
if (chunk.timestamp > existing.lastIndexed) {
|
|
259
|
+
existing.lastIndexed = chunk.timestamp;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
254
262
|
}
|
|
255
|
-
//
|
|
263
|
+
// 4. Get index stats
|
|
264
|
+
const indexStats = await indexManager.getStats();
|
|
265
|
+
// 5. Identify pending files (files that changed) - in memory comparison
|
|
256
266
|
const pendingFiles = new Set();
|
|
257
267
|
for (const file of allFiles) {
|
|
258
268
|
const indexed = indexedFiles.get(file.path);
|
|
259
|
-
if (indexed) {
|
|
260
|
-
|
|
261
|
-
const chunks = await vectorStore.getChunksByFile(file.path);
|
|
262
|
-
if (chunks.length > 0 && chunks[0].file_hash !== file.hash) {
|
|
263
|
-
pendingFiles.add(file.path);
|
|
264
|
-
}
|
|
269
|
+
if (indexed && indexed.hash !== file.hash) {
|
|
270
|
+
pendingFiles.add(file.path);
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
273
|
console.error(`Archivos indexados: ${indexedFiles.size}`);
|