raggrep 0.10.5 → 0.10.8
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/app/indexer/index.d.ts +13 -4
- package/dist/cli/main.js +111 -30
- package/dist/cli/main.js.map +4 -4
- package/dist/domain/entities/fileIndex.d.ts +5 -0
- package/dist/index.js +91 -19
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -36,6 +36,11 @@ export interface FileManifestEntry {
|
|
|
36
36
|
* This prevents false positives when git updates mtime on branch switches.
|
|
37
37
|
*/
|
|
38
38
|
contentHash?: string;
|
|
39
|
+
/**
|
|
40
|
+
* File size in bytes. Used as a quick filter:
|
|
41
|
+
* If mtime changed but size is same, content is likely unchanged.
|
|
42
|
+
*/
|
|
43
|
+
fileSize?: number;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
46
|
* Manifest tracking all indexed files for a specific module.
|
package/dist/index.js
CHANGED
|
@@ -12099,7 +12099,12 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12099
12099
|
let cleanupMs = 0;
|
|
12100
12100
|
let filesDiscovered = 0;
|
|
12101
12101
|
let filesStatChecked = 0;
|
|
12102
|
-
let
|
|
12102
|
+
let filesWithChanges = 0;
|
|
12103
|
+
let filesReindexed = 0;
|
|
12104
|
+
let totalDiagNewFiles = 0;
|
|
12105
|
+
let totalDiagNoFileSize = 0;
|
|
12106
|
+
let totalDiagSizeMismatch = 0;
|
|
12107
|
+
let totalDiagNoContentHash = 0;
|
|
12103
12108
|
const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
|
|
12104
12109
|
rootDir = path21.resolve(rootDir);
|
|
12105
12110
|
const status = await getIndexStatus(rootDir);
|
|
@@ -12141,7 +12146,8 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12141
12146
|
cleanupMs: 0,
|
|
12142
12147
|
filesDiscovered: 0,
|
|
12143
12148
|
filesStatChecked: 0,
|
|
12144
|
-
|
|
12149
|
+
filesWithChanges: 0,
|
|
12150
|
+
filesReindexed: 0,
|
|
12145
12151
|
fromCache: true
|
|
12146
12152
|
};
|
|
12147
12153
|
}
|
|
@@ -12236,41 +12242,91 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12236
12242
|
try {
|
|
12237
12243
|
const stats = await fs8.stat(filepath);
|
|
12238
12244
|
const lastModified = stats.mtime.toISOString();
|
|
12245
|
+
const fileSize = stats.size;
|
|
12239
12246
|
const existingEntry = manifest.files[relativePath];
|
|
12240
12247
|
if (!existingEntry) {
|
|
12241
|
-
return { filepath, relativePath, lastModified, needsCheck: true, isNew: true };
|
|
12248
|
+
return { filepath, relativePath, lastModified, fileSize, needsCheck: true, isNew: true };
|
|
12242
12249
|
}
|
|
12243
12250
|
if (existingEntry.lastModified === lastModified) {
|
|
12244
|
-
return { filepath, relativePath, lastModified, needsCheck: false, isNew: false };
|
|
12251
|
+
return { filepath, relativePath, lastModified, fileSize, needsCheck: false, isNew: false };
|
|
12245
12252
|
}
|
|
12246
|
-
|
|
12253
|
+
if (existingEntry.fileSize !== undefined && existingEntry.fileSize === fileSize && existingEntry.contentHash) {
|
|
12254
|
+
return { filepath, relativePath, lastModified, fileSize, needsCheck: false, isNew: false, existingContentHash: existingEntry.contentHash };
|
|
12255
|
+
}
|
|
12256
|
+
return { filepath, relativePath, lastModified, fileSize, needsCheck: true, isNew: false, existingContentHash: existingEntry.contentHash };
|
|
12247
12257
|
} catch {
|
|
12248
12258
|
return null;
|
|
12249
12259
|
}
|
|
12250
12260
|
};
|
|
12261
|
+
const moduleFiles = module2.supportsFile ? currentFiles.filter((f) => module2.supportsFile(f)) : currentFiles;
|
|
12251
12262
|
const statCheckStart = Date.now();
|
|
12252
|
-
const statResults = await parallelMap(
|
|
12263
|
+
const statResults = await parallelMap(moduleFiles, statCheck, STAT_CONCURRENCY);
|
|
12253
12264
|
statCheckMs += Date.now() - statCheckStart;
|
|
12254
|
-
filesStatChecked +=
|
|
12265
|
+
filesStatChecked += moduleFiles.length;
|
|
12255
12266
|
const filesToProcess = [];
|
|
12267
|
+
const filesWithMtimeOnlyChange = [];
|
|
12256
12268
|
let unchangedCount = 0;
|
|
12269
|
+
let diagNewFiles = 0;
|
|
12270
|
+
let diagNoFileSize = 0;
|
|
12271
|
+
let diagSizeMismatch = 0;
|
|
12272
|
+
let diagNoContentHash = 0;
|
|
12257
12273
|
for (const result2 of statResults) {
|
|
12258
12274
|
if (!result2.success || !result2.value)
|
|
12259
12275
|
continue;
|
|
12260
12276
|
if (result2.value.needsCheck) {
|
|
12261
12277
|
filesToProcess.push(result2.value);
|
|
12278
|
+
if (result2.value.isNew) {
|
|
12279
|
+
diagNewFiles++;
|
|
12280
|
+
} else {
|
|
12281
|
+
const existingEntry = manifest.files[result2.value.relativePath];
|
|
12282
|
+
if (existingEntry) {
|
|
12283
|
+
if (existingEntry.fileSize === undefined)
|
|
12284
|
+
diagNoFileSize++;
|
|
12285
|
+
else if (existingEntry.fileSize !== result2.value.fileSize)
|
|
12286
|
+
diagSizeMismatch++;
|
|
12287
|
+
else if (!existingEntry.contentHash)
|
|
12288
|
+
diagNoContentHash++;
|
|
12289
|
+
}
|
|
12290
|
+
}
|
|
12262
12291
|
} else {
|
|
12263
12292
|
unchangedCount++;
|
|
12293
|
+
const existingEntry = manifest.files[result2.value.relativePath];
|
|
12294
|
+
if (existingEntry && existingEntry.lastModified !== result2.value.lastModified) {
|
|
12295
|
+
filesWithMtimeOnlyChange.push(result2.value);
|
|
12296
|
+
}
|
|
12297
|
+
}
|
|
12298
|
+
}
|
|
12299
|
+
totalDiagNewFiles += diagNewFiles;
|
|
12300
|
+
totalDiagNoFileSize += diagNoFileSize;
|
|
12301
|
+
totalDiagSizeMismatch += diagSizeMismatch;
|
|
12302
|
+
totalDiagNoContentHash += diagNoContentHash;
|
|
12303
|
+
if (filesToProcess.length > 100 && verbose) {
|
|
12304
|
+
logger.info(` [Diagnostic] Phase 2 reasons: new=${diagNewFiles}, noSize=${diagNoFileSize}, sizeMismatch=${diagSizeMismatch}, noHash=${diagNoContentHash}`);
|
|
12305
|
+
}
|
|
12306
|
+
let mtimeOnlyUpdates = 0;
|
|
12307
|
+
for (const file of filesWithMtimeOnlyChange) {
|
|
12308
|
+
const existingEntry = manifest.files[file.relativePath];
|
|
12309
|
+
if (existingEntry) {
|
|
12310
|
+
manifest.files[file.relativePath] = {
|
|
12311
|
+
...existingEntry,
|
|
12312
|
+
lastModified: file.lastModified,
|
|
12313
|
+
fileSize: file.fileSize
|
|
12314
|
+
};
|
|
12315
|
+
mtimeOnlyUpdates++;
|
|
12264
12316
|
}
|
|
12265
12317
|
}
|
|
12266
12318
|
if (filesToProcess.length === 0) {
|
|
12267
12319
|
totalUnchanged += unchangedCount;
|
|
12320
|
+
if (mtimeOnlyUpdates > 0) {
|
|
12321
|
+
manifest.lastUpdated = new Date().toISOString();
|
|
12322
|
+
await writeModuleManifest(rootDir, module2.id, manifest, config);
|
|
12323
|
+
}
|
|
12268
12324
|
continue;
|
|
12269
12325
|
}
|
|
12270
12326
|
let completedCount = 0;
|
|
12271
12327
|
const totalToProcess = filesToProcess.length;
|
|
12272
12328
|
const processChangedFile = async (statResult) => {
|
|
12273
|
-
const { filepath, relativePath, lastModified, isNew } = statResult;
|
|
12329
|
+
const { filepath, relativePath, lastModified, fileSize, isNew } = statResult;
|
|
12274
12330
|
try {
|
|
12275
12331
|
const content = await fs8.readFile(filepath, "utf-8");
|
|
12276
12332
|
const contentHash = computeContentHash(content);
|
|
@@ -12281,6 +12337,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12281
12337
|
relativePath,
|
|
12282
12338
|
status: "mtime_updated",
|
|
12283
12339
|
lastModified,
|
|
12340
|
+
fileSize,
|
|
12284
12341
|
contentHash
|
|
12285
12342
|
};
|
|
12286
12343
|
}
|
|
@@ -12289,13 +12346,14 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12289
12346
|
introspection.addFile(relativePath, content);
|
|
12290
12347
|
const fileIndex = await module2.indexFile(relativePath, content, ctx);
|
|
12291
12348
|
if (!fileIndex) {
|
|
12292
|
-
return { relativePath, status: "unchanged" };
|
|
12349
|
+
return { relativePath, status: "unchanged", fileSize };
|
|
12293
12350
|
}
|
|
12294
12351
|
await writeFileIndex(rootDir, module2.id, relativePath, fileIndex, config);
|
|
12295
12352
|
return {
|
|
12296
12353
|
relativePath,
|
|
12297
12354
|
status: "indexed",
|
|
12298
12355
|
lastModified,
|
|
12356
|
+
fileSize,
|
|
12299
12357
|
chunkCount: fileIndex.chunks.length,
|
|
12300
12358
|
contentHash
|
|
12301
12359
|
};
|
|
@@ -12308,7 +12366,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12308
12366
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
12309
12367
|
const results = await parallelMap(filesToProcess, processChangedFile, concurrency);
|
|
12310
12368
|
indexingMs += Date.now() - indexingStart;
|
|
12311
|
-
|
|
12369
|
+
filesWithChanges += filesToProcess.length;
|
|
12312
12370
|
totalUnchanged += unchangedCount;
|
|
12313
12371
|
logger.clearProgress();
|
|
12314
12372
|
let mtimeUpdates = 0;
|
|
@@ -12322,7 +12380,8 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12322
12380
|
manifest.files[fileResult.relativePath] = {
|
|
12323
12381
|
lastModified: fileResult.lastModified,
|
|
12324
12382
|
chunkCount: fileResult.chunkCount,
|
|
12325
|
-
contentHash: fileResult.contentHash
|
|
12383
|
+
contentHash: fileResult.contentHash,
|
|
12384
|
+
fileSize: fileResult.fileSize
|
|
12326
12385
|
};
|
|
12327
12386
|
totalIndexed++;
|
|
12328
12387
|
break;
|
|
@@ -12331,7 +12390,8 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12331
12390
|
manifest.files[fileResult.relativePath] = {
|
|
12332
12391
|
...manifest.files[fileResult.relativePath],
|
|
12333
12392
|
lastModified: fileResult.lastModified,
|
|
12334
|
-
contentHash: fileResult.contentHash
|
|
12393
|
+
contentHash: fileResult.contentHash,
|
|
12394
|
+
fileSize: fileResult.fileSize
|
|
12335
12395
|
};
|
|
12336
12396
|
mtimeUpdates++;
|
|
12337
12397
|
}
|
|
@@ -12345,7 +12405,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12345
12405
|
break;
|
|
12346
12406
|
}
|
|
12347
12407
|
}
|
|
12348
|
-
const hasManifestChanges = totalIndexed > 0 || totalRemoved > 0 || mtimeUpdates > 0;
|
|
12408
|
+
const hasManifestChanges = totalIndexed > 0 || totalRemoved > 0 || mtimeUpdates > 0 || mtimeOnlyUpdates > 0;
|
|
12349
12409
|
if (hasManifestChanges) {
|
|
12350
12410
|
manifest.lastUpdated = new Date().toISOString();
|
|
12351
12411
|
await writeModuleManifest(rootDir, module2.id, manifest, config);
|
|
@@ -12379,8 +12439,15 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12379
12439
|
cleanupMs,
|
|
12380
12440
|
filesDiscovered,
|
|
12381
12441
|
filesStatChecked,
|
|
12382
|
-
|
|
12383
|
-
|
|
12442
|
+
filesWithChanges,
|
|
12443
|
+
filesReindexed: totalIndexed,
|
|
12444
|
+
fromCache: false,
|
|
12445
|
+
phase2Reasons: {
|
|
12446
|
+
newFiles: totalDiagNewFiles,
|
|
12447
|
+
noFileSize: totalDiagNoFileSize,
|
|
12448
|
+
sizeMismatch: totalDiagSizeMismatch,
|
|
12449
|
+
noContentHash: totalDiagNoContentHash
|
|
12450
|
+
}
|
|
12384
12451
|
};
|
|
12385
12452
|
}
|
|
12386
12453
|
let finalManifestMtime = currentManifestMtime;
|
|
@@ -12449,6 +12516,7 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12449
12516
|
try {
|
|
12450
12517
|
const stats = await fs8.stat(filepath);
|
|
12451
12518
|
const lastModified = stats.mtime.toISOString();
|
|
12519
|
+
const fileSize = stats.size;
|
|
12452
12520
|
const existingEntry = manifest.files[relativePath];
|
|
12453
12521
|
if (existingEntry && existingEntry.lastModified === lastModified) {
|
|
12454
12522
|
completedCount++;
|
|
@@ -12464,6 +12532,7 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12464
12532
|
relativePath,
|
|
12465
12533
|
status: "skipped",
|
|
12466
12534
|
lastModified,
|
|
12535
|
+
fileSize,
|
|
12467
12536
|
contentHash
|
|
12468
12537
|
};
|
|
12469
12538
|
}
|
|
@@ -12473,13 +12542,14 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12473
12542
|
const fileIndex = await module2.indexFile(relativePath, content, ctx);
|
|
12474
12543
|
if (!fileIndex) {
|
|
12475
12544
|
logger.debug(` [${completedCount}/${totalFiles}] Skipped ${relativePath} (no chunks)`);
|
|
12476
|
-
return { relativePath, status: "skipped" };
|
|
12545
|
+
return { relativePath, status: "skipped", fileSize };
|
|
12477
12546
|
}
|
|
12478
12547
|
await writeFileIndex(rootDir, module2.id, relativePath, fileIndex, config);
|
|
12479
12548
|
return {
|
|
12480
12549
|
relativePath,
|
|
12481
12550
|
status: "indexed",
|
|
12482
12551
|
lastModified,
|
|
12552
|
+
fileSize,
|
|
12483
12553
|
chunkCount: fileIndex.chunks.length,
|
|
12484
12554
|
contentHash
|
|
12485
12555
|
};
|
|
@@ -12502,7 +12572,8 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12502
12572
|
manifest.files[fileResult.relativePath] = {
|
|
12503
12573
|
lastModified: fileResult.lastModified,
|
|
12504
12574
|
chunkCount: fileResult.chunkCount,
|
|
12505
|
-
contentHash: fileResult.contentHash
|
|
12575
|
+
contentHash: fileResult.contentHash,
|
|
12576
|
+
fileSize: fileResult.fileSize
|
|
12506
12577
|
};
|
|
12507
12578
|
result.indexed++;
|
|
12508
12579
|
break;
|
|
@@ -12513,7 +12584,8 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12513
12584
|
manifest.files[fileResult.relativePath] = {
|
|
12514
12585
|
...existingEntry,
|
|
12515
12586
|
lastModified: fileResult.lastModified,
|
|
12516
|
-
contentHash: fileResult.contentHash
|
|
12587
|
+
contentHash: fileResult.contentHash,
|
|
12588
|
+
fileSize: fileResult.fileSize
|
|
12517
12589
|
};
|
|
12518
12590
|
}
|
|
12519
12591
|
}
|
|
@@ -14115,4 +14187,4 @@ export {
|
|
|
14115
14187
|
ConsoleLogger
|
|
14116
14188
|
};
|
|
14117
14189
|
|
|
14118
|
-
//# debugId=
|
|
14190
|
+
//# debugId=3F7DE957CF0C467164756E2164756E21
|