raggrep 0.10.8 → 0.11.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.
- package/dist/app/indexer/index.d.ts +3 -14
- package/dist/cli/main.js +96 -149
- package/dist/cli/main.js.map +4 -4
- package/dist/domain/entities/fileIndex.d.ts +7 -6
- package/dist/index.js +93 -135
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -30,31 +30,20 @@ export interface IndexOptions {
|
|
|
30
30
|
export interface TimingInfo {
|
|
31
31
|
/** Total time in milliseconds */
|
|
32
32
|
totalMs: number;
|
|
33
|
-
/** Time spent on file discovery (
|
|
33
|
+
/** Time spent on file discovery (with mtime filtering) */
|
|
34
34
|
fileDiscoveryMs: number;
|
|
35
|
-
/** Time spent on stat checks */
|
|
36
|
-
statCheckMs: number;
|
|
37
35
|
/** Time spent on indexing changed files */
|
|
38
36
|
indexingMs: number;
|
|
39
37
|
/** Time spent on cleanup operations */
|
|
40
38
|
cleanupMs: number;
|
|
41
39
|
/** Number of files discovered on disk */
|
|
42
40
|
filesDiscovered: number;
|
|
43
|
-
/** Number of files
|
|
44
|
-
|
|
45
|
-
/** Number of files with detected changes (mtime or size changed) that went to Phase 2 */
|
|
46
|
-
filesWithChanges: number;
|
|
41
|
+
/** Number of files modified since last index */
|
|
42
|
+
filesChanged: number;
|
|
47
43
|
/** Number of files that were actually re-indexed (content changed) */
|
|
48
44
|
filesReindexed: number;
|
|
49
45
|
/** Whether result was from cache */
|
|
50
46
|
fromCache: boolean;
|
|
51
|
-
/** Diagnostic: breakdown of why files went to Phase 2 */
|
|
52
|
-
phase2Reasons?: {
|
|
53
|
-
newFiles: number;
|
|
54
|
-
noFileSize: number;
|
|
55
|
-
sizeMismatch: number;
|
|
56
|
-
noContentHash: number;
|
|
57
|
-
};
|
|
58
47
|
}
|
|
59
48
|
export interface EnsureFreshResult {
|
|
60
49
|
/** Number of files indexed (new or modified) */
|
package/dist/cli/main.js
CHANGED
|
@@ -11933,6 +11933,7 @@ function getOptimalConcurrency() {
|
|
|
11933
11933
|
return optimal;
|
|
11934
11934
|
}
|
|
11935
11935
|
async function indexDirectory(rootDir, options = {}) {
|
|
11936
|
+
const indexStartTime = new Date().toISOString();
|
|
11936
11937
|
const verbose = options.verbose ?? false;
|
|
11937
11938
|
const quiet = options.quiet ?? false;
|
|
11938
11939
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
@@ -12013,7 +12014,7 @@ Indexing complete in ${formatDuration(overallDuration)}`);
|
|
|
12013
12014
|
const totalSkipped = results.reduce((sum, r) => sum + r.skipped, 0);
|
|
12014
12015
|
const totalErrors = results.reduce((sum, r) => sum + r.errors, 0);
|
|
12015
12016
|
logger.info(`Total: ${totalIndexed} indexed, ${totalSkipped} skipped, ${totalErrors} errors`);
|
|
12016
|
-
await updateGlobalManifest(rootDir, enabledModules, config);
|
|
12017
|
+
await updateGlobalManifest(rootDir, enabledModules, config, indexStartTime);
|
|
12017
12018
|
return results;
|
|
12018
12019
|
}
|
|
12019
12020
|
async function isIndexVersionCompatible(rootDir) {
|
|
@@ -12050,19 +12051,14 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12050
12051
|
const verbose = options.verbose ?? false;
|
|
12051
12052
|
const quiet = options.quiet ?? false;
|
|
12052
12053
|
const showTiming = options.timing ?? false;
|
|
12054
|
+
const indexStartTime = new Date().toISOString();
|
|
12053
12055
|
const startTime = Date.now();
|
|
12054
12056
|
let fileDiscoveryMs = 0;
|
|
12055
|
-
let statCheckMs = 0;
|
|
12056
12057
|
let indexingMs = 0;
|
|
12057
12058
|
let cleanupMs = 0;
|
|
12058
12059
|
let filesDiscovered = 0;
|
|
12059
|
-
let
|
|
12060
|
-
let filesWithChanges = 0;
|
|
12060
|
+
let filesChanged = 0;
|
|
12061
12061
|
let filesReindexed = 0;
|
|
12062
|
-
let totalDiagNewFiles = 0;
|
|
12063
|
-
let totalDiagNoFileSize = 0;
|
|
12064
|
-
let totalDiagSizeMismatch = 0;
|
|
12065
|
-
let totalDiagNoContentHash = 0;
|
|
12066
12062
|
const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
|
|
12067
12063
|
rootDir = path22.resolve(rootDir);
|
|
12068
12064
|
const status = await getIndexStatus(rootDir);
|
|
@@ -12099,12 +12095,10 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12099
12095
|
cachedResult.timing = {
|
|
12100
12096
|
totalMs: Date.now() - startTime,
|
|
12101
12097
|
fileDiscoveryMs: 0,
|
|
12102
|
-
statCheckMs: 0,
|
|
12103
12098
|
indexingMs: 0,
|
|
12104
12099
|
cleanupMs: 0,
|
|
12105
12100
|
filesDiscovered: 0,
|
|
12106
|
-
|
|
12107
|
-
filesWithChanges: 0,
|
|
12101
|
+
filesChanged: 0,
|
|
12108
12102
|
filesReindexed: 0,
|
|
12109
12103
|
fromCache: true
|
|
12110
12104
|
};
|
|
@@ -12116,15 +12110,20 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12116
12110
|
if (enabledModules.length === 0) {
|
|
12117
12111
|
return { indexed: 0, removed: 0, unchanged: 0 };
|
|
12118
12112
|
}
|
|
12113
|
+
const globalManifest = await loadGlobalManifest(rootDir, config);
|
|
12114
|
+
const lastIndexStarted = globalManifest?.lastIndexStarted ? new Date(globalManifest.lastIndexStarted) : null;
|
|
12119
12115
|
const fileDiscoveryStart = Date.now();
|
|
12120
12116
|
const introspection = new IntrospectionIndex(rootDir);
|
|
12121
|
-
const [,
|
|
12117
|
+
const [, discoveryResult] = await Promise.all([
|
|
12122
12118
|
introspection.initialize(),
|
|
12123
|
-
|
|
12119
|
+
findFilesWithStats(rootDir, config, lastIndexStarted)
|
|
12124
12120
|
]);
|
|
12125
12121
|
fileDiscoveryMs = Date.now() - fileDiscoveryStart;
|
|
12122
|
+
const { allFiles: currentFiles, changedFiles, changedFileMtimes } = discoveryResult;
|
|
12126
12123
|
filesDiscovered = currentFiles.length;
|
|
12124
|
+
filesChanged = changedFiles.length;
|
|
12127
12125
|
const currentFileSet = new Set(currentFiles.map((f) => path22.relative(rootDir, f)));
|
|
12126
|
+
const changedFileSet = new Set(changedFiles);
|
|
12128
12127
|
let totalIndexed = 0;
|
|
12129
12128
|
let totalRemoved = 0;
|
|
12130
12129
|
let totalUnchanged = 0;
|
|
@@ -12195,107 +12194,38 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12195
12194
|
},
|
|
12196
12195
|
getIntrospection: (filepath) => introspection.getFile(filepath)
|
|
12197
12196
|
};
|
|
12198
|
-
const
|
|
12197
|
+
const moduleChangedFiles = module2.supportsFile ? changedFiles.filter((f) => module2.supportsFile(f)) : changedFiles;
|
|
12198
|
+
const filesToProcess = moduleChangedFiles.map((filepath) => {
|
|
12199
12199
|
const relativePath = path22.relative(rootDir, filepath);
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
return { filepath, relativePath, lastModified, fileSize, needsCheck: false, isNew: false, existingContentHash: existingEntry.contentHash };
|
|
12213
|
-
}
|
|
12214
|
-
return { filepath, relativePath, lastModified, fileSize, needsCheck: true, isNew: false, existingContentHash: existingEntry.contentHash };
|
|
12215
|
-
} catch {
|
|
12216
|
-
return null;
|
|
12217
|
-
}
|
|
12218
|
-
};
|
|
12219
|
-
const moduleFiles = module2.supportsFile ? currentFiles.filter((f) => module2.supportsFile(f)) : currentFiles;
|
|
12220
|
-
const statCheckStart = Date.now();
|
|
12221
|
-
const statResults = await parallelMap(moduleFiles, statCheck, STAT_CONCURRENCY);
|
|
12222
|
-
statCheckMs += Date.now() - statCheckStart;
|
|
12223
|
-
filesStatChecked += moduleFiles.length;
|
|
12224
|
-
const filesToProcess = [];
|
|
12225
|
-
const filesWithMtimeOnlyChange = [];
|
|
12226
|
-
let unchangedCount = 0;
|
|
12227
|
-
let diagNewFiles = 0;
|
|
12228
|
-
let diagNoFileSize = 0;
|
|
12229
|
-
let diagSizeMismatch = 0;
|
|
12230
|
-
let diagNoContentHash = 0;
|
|
12231
|
-
for (const result2 of statResults) {
|
|
12232
|
-
if (!result2.success || !result2.value)
|
|
12233
|
-
continue;
|
|
12234
|
-
if (result2.value.needsCheck) {
|
|
12235
|
-
filesToProcess.push(result2.value);
|
|
12236
|
-
if (result2.value.isNew) {
|
|
12237
|
-
diagNewFiles++;
|
|
12238
|
-
} else {
|
|
12239
|
-
const existingEntry = manifest.files[result2.value.relativePath];
|
|
12240
|
-
if (existingEntry) {
|
|
12241
|
-
if (existingEntry.fileSize === undefined)
|
|
12242
|
-
diagNoFileSize++;
|
|
12243
|
-
else if (existingEntry.fileSize !== result2.value.fileSize)
|
|
12244
|
-
diagSizeMismatch++;
|
|
12245
|
-
else if (!existingEntry.contentHash)
|
|
12246
|
-
diagNoContentHash++;
|
|
12247
|
-
}
|
|
12248
|
-
}
|
|
12249
|
-
} else {
|
|
12250
|
-
unchangedCount++;
|
|
12251
|
-
const existingEntry = manifest.files[result2.value.relativePath];
|
|
12252
|
-
if (existingEntry && existingEntry.lastModified !== result2.value.lastModified) {
|
|
12253
|
-
filesWithMtimeOnlyChange.push(result2.value);
|
|
12254
|
-
}
|
|
12255
|
-
}
|
|
12256
|
-
}
|
|
12257
|
-
totalDiagNewFiles += diagNewFiles;
|
|
12258
|
-
totalDiagNoFileSize += diagNoFileSize;
|
|
12259
|
-
totalDiagSizeMismatch += diagSizeMismatch;
|
|
12260
|
-
totalDiagNoContentHash += diagNoContentHash;
|
|
12261
|
-
if (filesToProcess.length > 100 && verbose) {
|
|
12262
|
-
logger.info(` [Diagnostic] Phase 2 reasons: new=${diagNewFiles}, noSize=${diagNoFileSize}, sizeMismatch=${diagSizeMismatch}, noHash=${diagNoContentHash}`);
|
|
12263
|
-
}
|
|
12264
|
-
let mtimeOnlyUpdates = 0;
|
|
12265
|
-
for (const file of filesWithMtimeOnlyChange) {
|
|
12266
|
-
const existingEntry = manifest.files[file.relativePath];
|
|
12267
|
-
if (existingEntry) {
|
|
12268
|
-
manifest.files[file.relativePath] = {
|
|
12269
|
-
...existingEntry,
|
|
12270
|
-
lastModified: file.lastModified,
|
|
12271
|
-
fileSize: file.fileSize
|
|
12272
|
-
};
|
|
12273
|
-
mtimeOnlyUpdates++;
|
|
12274
|
-
}
|
|
12275
|
-
}
|
|
12200
|
+
const existingEntry = manifest.files[relativePath];
|
|
12201
|
+
const lastModified = changedFileMtimes.get(filepath) || new Date().toISOString();
|
|
12202
|
+
return {
|
|
12203
|
+
filepath,
|
|
12204
|
+
relativePath,
|
|
12205
|
+
lastModified,
|
|
12206
|
+
isNew: !existingEntry,
|
|
12207
|
+
existingContentHash: existingEntry?.contentHash
|
|
12208
|
+
};
|
|
12209
|
+
});
|
|
12210
|
+
const moduleAllFiles = module2.supportsFile ? currentFiles.filter((f) => module2.supportsFile(f)) : currentFiles;
|
|
12211
|
+
const unchangedCount = moduleAllFiles.length - filesToProcess.length;
|
|
12276
12212
|
if (filesToProcess.length === 0) {
|
|
12277
12213
|
totalUnchanged += unchangedCount;
|
|
12278
|
-
if (mtimeOnlyUpdates > 0) {
|
|
12279
|
-
manifest.lastUpdated = new Date().toISOString();
|
|
12280
|
-
await writeModuleManifest(rootDir, module2.id, manifest, config);
|
|
12281
|
-
}
|
|
12282
12214
|
continue;
|
|
12283
12215
|
}
|
|
12284
12216
|
let completedCount = 0;
|
|
12285
12217
|
const totalToProcess = filesToProcess.length;
|
|
12286
|
-
const processChangedFile = async (
|
|
12287
|
-
const { filepath, relativePath, lastModified,
|
|
12218
|
+
const processChangedFile = async (fileToProcess) => {
|
|
12219
|
+
const { filepath, relativePath, lastModified, isNew, existingContentHash } = fileToProcess;
|
|
12288
12220
|
try {
|
|
12289
12221
|
const content = await fs8.readFile(filepath, "utf-8");
|
|
12290
12222
|
const contentHash = computeContentHash(content);
|
|
12291
|
-
|
|
12292
|
-
if (!isNew && existingEntry?.contentHash && existingEntry.contentHash === contentHash) {
|
|
12223
|
+
if (!isNew && existingContentHash && existingContentHash === contentHash) {
|
|
12293
12224
|
completedCount++;
|
|
12294
12225
|
return {
|
|
12295
12226
|
relativePath,
|
|
12296
12227
|
status: "mtime_updated",
|
|
12297
12228
|
lastModified,
|
|
12298
|
-
fileSize,
|
|
12299
12229
|
contentHash
|
|
12300
12230
|
};
|
|
12301
12231
|
}
|
|
@@ -12304,14 +12234,13 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12304
12234
|
introspection.addFile(relativePath, content);
|
|
12305
12235
|
const fileIndex = await module2.indexFile(relativePath, content, ctx);
|
|
12306
12236
|
if (!fileIndex) {
|
|
12307
|
-
return { relativePath, status: "unchanged"
|
|
12237
|
+
return { relativePath, status: "unchanged" };
|
|
12308
12238
|
}
|
|
12309
12239
|
await writeFileIndex(rootDir, module2.id, relativePath, fileIndex, config);
|
|
12310
12240
|
return {
|
|
12311
12241
|
relativePath,
|
|
12312
12242
|
status: "indexed",
|
|
12313
12243
|
lastModified,
|
|
12314
|
-
fileSize,
|
|
12315
12244
|
chunkCount: fileIndex.chunks.length,
|
|
12316
12245
|
contentHash
|
|
12317
12246
|
};
|
|
@@ -12324,7 +12253,6 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12324
12253
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
12325
12254
|
const results = await parallelMap(filesToProcess, processChangedFile, concurrency);
|
|
12326
12255
|
indexingMs += Date.now() - indexingStart;
|
|
12327
|
-
filesWithChanges += filesToProcess.length;
|
|
12328
12256
|
totalUnchanged += unchangedCount;
|
|
12329
12257
|
logger.clearProgress();
|
|
12330
12258
|
let mtimeUpdates = 0;
|
|
@@ -12338,18 +12266,17 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12338
12266
|
manifest.files[fileResult.relativePath] = {
|
|
12339
12267
|
lastModified: fileResult.lastModified,
|
|
12340
12268
|
chunkCount: fileResult.chunkCount,
|
|
12341
|
-
contentHash: fileResult.contentHash
|
|
12342
|
-
fileSize: fileResult.fileSize
|
|
12269
|
+
contentHash: fileResult.contentHash
|
|
12343
12270
|
};
|
|
12344
12271
|
totalIndexed++;
|
|
12272
|
+
filesReindexed++;
|
|
12345
12273
|
break;
|
|
12346
12274
|
case "mtime_updated":
|
|
12347
12275
|
if (manifest.files[fileResult.relativePath]) {
|
|
12348
12276
|
manifest.files[fileResult.relativePath] = {
|
|
12349
12277
|
...manifest.files[fileResult.relativePath],
|
|
12350
12278
|
lastModified: fileResult.lastModified,
|
|
12351
|
-
contentHash: fileResult.contentHash
|
|
12352
|
-
fileSize: fileResult.fileSize
|
|
12279
|
+
contentHash: fileResult.contentHash
|
|
12353
12280
|
};
|
|
12354
12281
|
mtimeUpdates++;
|
|
12355
12282
|
}
|
|
@@ -12363,7 +12290,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12363
12290
|
break;
|
|
12364
12291
|
}
|
|
12365
12292
|
}
|
|
12366
|
-
const hasManifestChanges = totalIndexed > 0 || totalRemoved > 0 || mtimeUpdates > 0
|
|
12293
|
+
const hasManifestChanges = totalIndexed > 0 || totalRemoved > 0 || mtimeUpdates > 0;
|
|
12367
12294
|
if (hasManifestChanges) {
|
|
12368
12295
|
manifest.lastUpdated = new Date().toISOString();
|
|
12369
12296
|
await writeModuleManifest(rootDir, module2.id, manifest, config);
|
|
@@ -12379,8 +12306,8 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12379
12306
|
if (totalIndexed > 0) {
|
|
12380
12307
|
await introspection.save(config);
|
|
12381
12308
|
}
|
|
12309
|
+
await updateGlobalManifest(rootDir, enabledModules, config, indexStartTime);
|
|
12382
12310
|
if (totalIndexed > 0 || totalRemoved > 0) {
|
|
12383
|
-
await updateGlobalManifest(rootDir, enabledModules, config);
|
|
12384
12311
|
clearFreshnessCache();
|
|
12385
12312
|
}
|
|
12386
12313
|
const result = {
|
|
@@ -12392,20 +12319,12 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
12392
12319
|
result.timing = {
|
|
12393
12320
|
totalMs: Date.now() - startTime,
|
|
12394
12321
|
fileDiscoveryMs,
|
|
12395
|
-
statCheckMs,
|
|
12396
12322
|
indexingMs,
|
|
12397
12323
|
cleanupMs,
|
|
12398
12324
|
filesDiscovered,
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
fromCache: false,
|
|
12403
|
-
phase2Reasons: {
|
|
12404
|
-
newFiles: totalDiagNewFiles,
|
|
12405
|
-
noFileSize: totalDiagNoFileSize,
|
|
12406
|
-
sizeMismatch: totalDiagSizeMismatch,
|
|
12407
|
-
noContentHash: totalDiagNoContentHash
|
|
12408
|
-
}
|
|
12325
|
+
filesChanged,
|
|
12326
|
+
filesReindexed,
|
|
12327
|
+
fromCache: false
|
|
12409
12328
|
};
|
|
12410
12329
|
}
|
|
12411
12330
|
let finalManifestMtime = currentManifestMtime;
|
|
@@ -12474,7 +12393,6 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12474
12393
|
try {
|
|
12475
12394
|
const stats = await fs8.stat(filepath);
|
|
12476
12395
|
const lastModified = stats.mtime.toISOString();
|
|
12477
|
-
const fileSize = stats.size;
|
|
12478
12396
|
const existingEntry = manifest.files[relativePath];
|
|
12479
12397
|
if (existingEntry && existingEntry.lastModified === lastModified) {
|
|
12480
12398
|
completedCount++;
|
|
@@ -12490,7 +12408,6 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12490
12408
|
relativePath,
|
|
12491
12409
|
status: "skipped",
|
|
12492
12410
|
lastModified,
|
|
12493
|
-
fileSize,
|
|
12494
12411
|
contentHash
|
|
12495
12412
|
};
|
|
12496
12413
|
}
|
|
@@ -12500,14 +12417,13 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12500
12417
|
const fileIndex = await module2.indexFile(relativePath, content, ctx);
|
|
12501
12418
|
if (!fileIndex) {
|
|
12502
12419
|
logger.debug(` [${completedCount}/${totalFiles}] Skipped ${relativePath} (no chunks)`);
|
|
12503
|
-
return { relativePath, status: "skipped"
|
|
12420
|
+
return { relativePath, status: "skipped" };
|
|
12504
12421
|
}
|
|
12505
12422
|
await writeFileIndex(rootDir, module2.id, relativePath, fileIndex, config);
|
|
12506
12423
|
return {
|
|
12507
12424
|
relativePath,
|
|
12508
12425
|
status: "indexed",
|
|
12509
12426
|
lastModified,
|
|
12510
|
-
fileSize,
|
|
12511
12427
|
chunkCount: fileIndex.chunks.length,
|
|
12512
12428
|
contentHash
|
|
12513
12429
|
};
|
|
@@ -12530,8 +12446,7 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12530
12446
|
manifest.files[fileResult.relativePath] = {
|
|
12531
12447
|
lastModified: fileResult.lastModified,
|
|
12532
12448
|
chunkCount: fileResult.chunkCount,
|
|
12533
|
-
contentHash: fileResult.contentHash
|
|
12534
|
-
fileSize: fileResult.fileSize
|
|
12449
|
+
contentHash: fileResult.contentHash
|
|
12535
12450
|
};
|
|
12536
12451
|
result.indexed++;
|
|
12537
12452
|
break;
|
|
@@ -12542,8 +12457,7 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12542
12457
|
manifest.files[fileResult.relativePath] = {
|
|
12543
12458
|
...existingEntry,
|
|
12544
12459
|
lastModified: fileResult.lastModified,
|
|
12545
|
-
contentHash: fileResult.contentHash
|
|
12546
|
-
fileSize: fileResult.fileSize
|
|
12460
|
+
contentHash: fileResult.contentHash
|
|
12547
12461
|
};
|
|
12548
12462
|
}
|
|
12549
12463
|
}
|
|
@@ -12559,15 +12473,49 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
12559
12473
|
await writeModuleManifest(rootDir, module2.id, manifest, config);
|
|
12560
12474
|
return result;
|
|
12561
12475
|
}
|
|
12562
|
-
async function
|
|
12476
|
+
async function findFilesWithStats(rootDir, config, lastIndexStarted) {
|
|
12563
12477
|
const validExtensions = new Set(config.extensions);
|
|
12564
12478
|
const ignoreDirs = new Set(config.ignorePaths);
|
|
12479
|
+
const lastIndexMs = lastIndexStarted?.getTime() ?? 0;
|
|
12565
12480
|
const crawler = new Builder().withFullPaths().exclude((dirName) => ignoreDirs.has(dirName)).filter((filePath) => {
|
|
12566
12481
|
const ext = path22.extname(filePath);
|
|
12567
12482
|
return validExtensions.has(ext);
|
|
12568
12483
|
}).crawl(rootDir);
|
|
12569
|
-
const
|
|
12570
|
-
|
|
12484
|
+
const allFiles = await crawler.withPromise();
|
|
12485
|
+
if (!lastIndexStarted) {
|
|
12486
|
+
const changedFileMtimes2 = new Map;
|
|
12487
|
+
await parallelMap(allFiles, async (filePath) => {
|
|
12488
|
+
try {
|
|
12489
|
+
const stats = await fs8.stat(filePath);
|
|
12490
|
+
changedFileMtimes2.set(filePath, stats.mtime.toISOString());
|
|
12491
|
+
} catch {}
|
|
12492
|
+
}, STAT_CONCURRENCY);
|
|
12493
|
+
return {
|
|
12494
|
+
allFiles,
|
|
12495
|
+
changedFiles: allFiles,
|
|
12496
|
+
changedFileMtimes: changedFileMtimes2
|
|
12497
|
+
};
|
|
12498
|
+
}
|
|
12499
|
+
const changedFiles = [];
|
|
12500
|
+
const changedFileMtimes = new Map;
|
|
12501
|
+
await parallelMap(allFiles, async (filePath) => {
|
|
12502
|
+
try {
|
|
12503
|
+
const stats = await fs8.stat(filePath);
|
|
12504
|
+
if (stats.mtimeMs > lastIndexMs) {
|
|
12505
|
+
changedFiles.push(filePath);
|
|
12506
|
+
changedFileMtimes.set(filePath, stats.mtime.toISOString());
|
|
12507
|
+
}
|
|
12508
|
+
} catch {}
|
|
12509
|
+
}, STAT_CONCURRENCY);
|
|
12510
|
+
return {
|
|
12511
|
+
allFiles,
|
|
12512
|
+
changedFiles,
|
|
12513
|
+
changedFileMtimes
|
|
12514
|
+
};
|
|
12515
|
+
}
|
|
12516
|
+
async function findFiles(rootDir, config) {
|
|
12517
|
+
const result = await findFilesWithStats(rootDir, config, null);
|
|
12518
|
+
return result.allFiles;
|
|
12571
12519
|
}
|
|
12572
12520
|
async function loadModuleManifest(rootDir, moduleId, config) {
|
|
12573
12521
|
const manifestPath = getModuleManifestPath(rootDir, moduleId, config);
|
|
@@ -12594,11 +12542,21 @@ async function writeFileIndex(rootDir, moduleId, filepath, fileIndex, config) {
|
|
|
12594
12542
|
await fs8.mkdir(path22.dirname(indexFilePath), { recursive: true });
|
|
12595
12543
|
await fs8.writeFile(indexFilePath, JSON.stringify(fileIndex, null, 2));
|
|
12596
12544
|
}
|
|
12597
|
-
async function
|
|
12545
|
+
async function loadGlobalManifest(rootDir, config) {
|
|
12546
|
+
const manifestPath = getGlobalManifestPath(rootDir, config);
|
|
12547
|
+
try {
|
|
12548
|
+
const content = await fs8.readFile(manifestPath, "utf-8");
|
|
12549
|
+
return JSON.parse(content);
|
|
12550
|
+
} catch {
|
|
12551
|
+
return null;
|
|
12552
|
+
}
|
|
12553
|
+
}
|
|
12554
|
+
async function updateGlobalManifest(rootDir, modules, config, indexStartTime) {
|
|
12598
12555
|
const manifestPath = getGlobalManifestPath(rootDir, config);
|
|
12599
12556
|
const manifest = {
|
|
12600
12557
|
version: INDEX_SCHEMA_VERSION,
|
|
12601
12558
|
lastUpdated: new Date().toISOString(),
|
|
12559
|
+
lastIndexStarted: indexStartTime,
|
|
12602
12560
|
modules: modules.map((m) => m.id)
|
|
12603
12561
|
};
|
|
12604
12562
|
await fs8.mkdir(path22.dirname(manifestPath), { recursive: true });
|
|
@@ -12736,7 +12694,7 @@ async function getIndexStatus(rootDir) {
|
|
|
12736
12694
|
}
|
|
12737
12695
|
return status;
|
|
12738
12696
|
}
|
|
12739
|
-
var FRESHNESS_CACHE_TTL_MS = 5000, freshnessCache = null, INDEX_SCHEMA_VERSION = "2.0.0", DEFAULT_CONCURRENCY, STAT_CONCURRENCY;
|
|
12697
|
+
var FRESHNESS_CACHE_TTL_MS = 5000, freshnessCache = null, INDEX_SCHEMA_VERSION = "2.0.0", DEFAULT_CONCURRENCY, STAT_CONCURRENCY = 64;
|
|
12740
12698
|
var init_indexer = __esm(() => {
|
|
12741
12699
|
init_dist();
|
|
12742
12700
|
init_config2();
|
|
@@ -12745,7 +12703,6 @@ var init_indexer = __esm(() => {
|
|
|
12745
12703
|
init_logger();
|
|
12746
12704
|
init_watcher();
|
|
12747
12705
|
DEFAULT_CONCURRENCY = getOptimalConcurrency();
|
|
12748
|
-
STAT_CONCURRENCY = Math.max(32, getOptimalConcurrency() * 4);
|
|
12749
12706
|
});
|
|
12750
12707
|
|
|
12751
12708
|
// node_modules/balanced-match/index.js
|
|
@@ -14165,7 +14122,7 @@ async function search(rootDir, query, options = {}) {
|
|
|
14165
14122
|
console.log(`Searching for: "${query}"`);
|
|
14166
14123
|
const config = await loadConfig(rootDir);
|
|
14167
14124
|
await registerBuiltInModules();
|
|
14168
|
-
const globalManifest = await
|
|
14125
|
+
const globalManifest = await loadGlobalManifest2(rootDir, config);
|
|
14169
14126
|
if (!globalManifest || globalManifest.modules.length === 0) {
|
|
14170
14127
|
console.log('No index found. Run "raggrep index" first.');
|
|
14171
14128
|
return [];
|
|
@@ -14249,7 +14206,7 @@ async function traverseDirectory(dir, files, basePath) {
|
|
|
14249
14206
|
}
|
|
14250
14207
|
} catch {}
|
|
14251
14208
|
}
|
|
14252
|
-
async function
|
|
14209
|
+
async function loadGlobalManifest2(rootDir, config) {
|
|
14253
14210
|
const manifestPath = getGlobalManifestPath(rootDir, config);
|
|
14254
14211
|
try {
|
|
14255
14212
|
const content = await fs9.readFile(manifestPath, "utf-8");
|
|
@@ -14319,7 +14276,7 @@ init_logger();
|
|
|
14319
14276
|
// package.json
|
|
14320
14277
|
var package_default = {
|
|
14321
14278
|
name: "raggrep",
|
|
14322
|
-
version: "0.
|
|
14279
|
+
version: "0.11.0",
|
|
14323
14280
|
description: "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
|
|
14324
14281
|
type: "module",
|
|
14325
14282
|
main: "./dist/index.js",
|
|
@@ -14669,21 +14626,11 @@ Examples:
|
|
|
14669
14626
|
console.log(`│ Cache hit (TTL-based) │`);
|
|
14670
14627
|
console.log(`│ Total: ${t.totalMs.toFixed(0).padStart(6)}ms │`);
|
|
14671
14628
|
} else {
|
|
14672
|
-
console.log(`│ File discovery: ${t.fileDiscoveryMs.toFixed(0).padStart(6)}ms │ ${String(t.filesDiscovered).padStart(6)} files
|
|
14673
|
-
console.log(`│
|
|
14674
|
-
console.log(`│ Indexing: ${t.indexingMs.toFixed(0).padStart(6)}ms │ ${String(t.filesWithChanges).padStart(6)} with changes → ${t.filesReindexed} reindexed`.padEnd(57) + "│");
|
|
14629
|
+
console.log(`│ File discovery: ${t.fileDiscoveryMs.toFixed(0).padStart(6)}ms │ ${String(t.filesDiscovered).padStart(6)} files, ${t.filesChanged} changed`.padEnd(57) + "│");
|
|
14630
|
+
console.log(`│ Indexing: ${t.indexingMs.toFixed(0).padStart(6)}ms │ ${String(t.filesReindexed).padStart(6)} reindexed`.padEnd(57) + "│");
|
|
14675
14631
|
console.log(`│ Cleanup: ${t.cleanupMs.toFixed(0).padStart(6)}ms │`.padEnd(57) + "│");
|
|
14676
14632
|
console.log(`│ ───────────────────────────────────────────────────── │`);
|
|
14677
14633
|
console.log(`│ Total: ${t.totalMs.toFixed(0).padStart(6)}ms`.padEnd(57) + "│");
|
|
14678
|
-
if (t.phase2Reasons && t.filesWithChanges > 0) {
|
|
14679
|
-
const r = t.phase2Reasons;
|
|
14680
|
-
console.log(`│ ───────────────────────────────────────────────────── │`);
|
|
14681
|
-
console.log(`│ Phase 2 breakdown (why files needed verification): │`);
|
|
14682
|
-
console.log(`│ New files: ${String(r.newFiles).padStart(6)}`.padEnd(57) + "│");
|
|
14683
|
-
console.log(`│ No cached size: ${String(r.noFileSize).padStart(6)}`.padEnd(57) + "│");
|
|
14684
|
-
console.log(`│ Size mismatch: ${String(r.sizeMismatch).padStart(6)}`.padEnd(57) + "│");
|
|
14685
|
-
console.log(`│ No cached hash: ${String(r.noContentHash).padStart(6)}`.padEnd(57) + "│");
|
|
14686
|
-
}
|
|
14687
14634
|
}
|
|
14688
14635
|
console.log(`└────────────────────────────────────────────────────────┘
|
|
14689
14636
|
`);
|
|
@@ -14945,4 +14892,4 @@ Run 'raggrep <command> --help' for more information.
|
|
|
14945
14892
|
}
|
|
14946
14893
|
main();
|
|
14947
14894
|
|
|
14948
|
-
//# debugId=
|
|
14895
|
+
//# debugId=4E166248FB39358064756E2164756E21
|