raggrep 0.10.0 → 0.10.2

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/index.js CHANGED
@@ -8240,9 +8240,9 @@ class TreeSitterParser {
8240
8240
  }
8241
8241
  async initializeTreeSitter() {
8242
8242
  try {
8243
- const Parser2 = await Promise.resolve().then(() => (init_web_tree_sitter(), exports_web_tree_sitter));
8244
- await Parser2.default.init();
8245
- this.parserInstance = new Parser2.default;
8243
+ const { Parser: Parser2 } = await Promise.resolve().then(() => (init_web_tree_sitter(), exports_web_tree_sitter));
8244
+ await Parser2.init();
8245
+ this.parserInstance = new Parser2;
8246
8246
  } catch (error) {
8247
8247
  console.error("Failed to initialize web-tree-sitter:", error);
8248
8248
  throw error;
@@ -11395,6 +11395,11 @@ import { watch } from "chokidar";
11395
11395
  init_config2();
11396
11396
 
11397
11397
  // src/app/indexer/index.ts
11398
+ var FRESHNESS_CACHE_TTL_MS = 5000;
11399
+ var freshnessCache = null;
11400
+ function clearFreshnessCache() {
11401
+ freshnessCache = null;
11402
+ }
11398
11403
  function computeContentHash(content) {
11399
11404
  return crypto2.createHash("sha256").update(content, "utf-8").digest("hex");
11400
11405
  }
@@ -11417,7 +11422,7 @@ async function parallelMap(items, processor, concurrency) {
11417
11422
  await Promise.all(workers);
11418
11423
  return results;
11419
11424
  }
11420
- var INDEX_SCHEMA_VERSION = "1.1.0";
11425
+ var INDEX_SCHEMA_VERSION = "2.0.0";
11421
11426
  function formatDuration(ms) {
11422
11427
  if (ms < 1000) {
11423
11428
  return `${ms}ms`;
@@ -11440,6 +11445,7 @@ async function indexDirectory(rootDir, options = {}) {
11440
11445
  const verbose = options.verbose ?? false;
11441
11446
  const quiet = options.quiet ?? false;
11442
11447
  const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
11448
+ clearFreshnessCache();
11443
11449
  const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
11444
11450
  rootDir = path21.resolve(rootDir);
11445
11451
  const location = getIndexLocation(rootDir);
@@ -11538,6 +11544,7 @@ async function deleteIndex(rootDir) {
11538
11544
  }
11539
11545
  async function resetIndex(rootDir) {
11540
11546
  rootDir = path21.resolve(rootDir);
11547
+ clearFreshnessCache();
11541
11548
  const status = await getIndexStatus(rootDir);
11542
11549
  if (!status.exists) {
11543
11550
  throw new Error(`No index found for ${rootDir}`);
@@ -11555,6 +11562,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
11555
11562
  rootDir = path21.resolve(rootDir);
11556
11563
  const status = await getIndexStatus(rootDir);
11557
11564
  if (!status.exists) {
11565
+ clearFreshnessCache();
11558
11566
  logger.info(`No index found. Creating index...
11559
11567
  `);
11560
11568
  const results = await indexDirectory(rootDir, { ...options, logger });
@@ -11563,6 +11571,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
11563
11571
  }
11564
11572
  const versionCompatible = await isIndexVersionCompatible(rootDir);
11565
11573
  if (!versionCompatible) {
11574
+ clearFreshnessCache();
11566
11575
  logger.info(`Index version incompatible. Rebuilding...
11567
11576
  `);
11568
11577
  await deleteIndex(rootDir);
@@ -11571,6 +11580,17 @@ async function ensureIndexFresh(rootDir, options = {}) {
11571
11580
  return { indexed: totalIndexed2, removed: 0, unchanged: 0 };
11572
11581
  }
11573
11582
  const config = await loadConfig(rootDir);
11583
+ const globalManifestPath = getGlobalManifestPath(rootDir, config);
11584
+ let currentManifestMtime = 0;
11585
+ try {
11586
+ const manifestStats = await fs8.stat(globalManifestPath);
11587
+ currentManifestMtime = manifestStats.mtimeMs;
11588
+ } catch {}
11589
+ const now = Date.now();
11590
+ if (freshnessCache && freshnessCache.rootDir === rootDir && now - freshnessCache.timestamp < FRESHNESS_CACHE_TTL_MS && freshnessCache.manifestMtime === currentManifestMtime) {
11591
+ logger.debug("Using cached freshness check result");
11592
+ return freshnessCache.result;
11593
+ }
11574
11594
  await registerBuiltInModules();
11575
11595
  const enabledModules = registry.getEnabled(config);
11576
11596
  if (enabledModules.length === 0) {
@@ -11746,12 +11766,25 @@ async function ensureIndexFresh(rootDir, options = {}) {
11746
11766
  }
11747
11767
  if (totalIndexed > 0 || totalRemoved > 0) {
11748
11768
  await updateGlobalManifest(rootDir, enabledModules, config);
11769
+ clearFreshnessCache();
11749
11770
  }
11750
- return {
11771
+ const result = {
11751
11772
  indexed: totalIndexed,
11752
11773
  removed: totalRemoved,
11753
11774
  unchanged: totalUnchanged
11754
11775
  };
11776
+ let finalManifestMtime = currentManifestMtime;
11777
+ try {
11778
+ const manifestStats = await fs8.stat(globalManifestPath);
11779
+ finalManifestMtime = manifestStats.mtimeMs;
11780
+ } catch {}
11781
+ freshnessCache = {
11782
+ rootDir,
11783
+ result,
11784
+ timestamp: Date.now(),
11785
+ manifestMtime: finalManifestMtime
11786
+ };
11787
+ return result;
11755
11788
  }
11756
11789
  async function indexWithModule(rootDir, files, module2, config, verbose, introspection, logger, concurrency = DEFAULT_CONCURRENCY) {
11757
11790
  const result = {
@@ -13476,4 +13509,4 @@ export {
13476
13509
  ConsoleLogger
13477
13510
  };
13478
13511
 
13479
- //# debugId=FC0C2D85F4A7323164756E2164756E21
13512
+ //# debugId=F14D312160862FA864756E2164756E21