raggrep 0.3.0 → 0.4.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/index.js CHANGED
@@ -1,4 +1,20 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
1
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
2
18
  var __export = (target, all) => {
3
19
  for (var name in all)
4
20
  __defProp(target, name, {
@@ -9,6 +25,7 @@ var __export = (target, all) => {
9
25
  });
10
26
  };
11
27
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
12
29
  // src/domain/entities/searchResult.ts
13
30
  var DEFAULT_SEARCH_OPTIONS;
14
31
  var init_searchResult = __esm(() => {
@@ -1999,7 +2016,8 @@ class TransformersEmbeddingProvider {
1999
2016
  constructor(config) {
2000
2017
  this.config = {
2001
2018
  model: config?.model ?? "all-MiniLM-L6-v2",
2002
- showProgress: config?.showProgress ?? false
2019
+ showProgress: config?.showProgress ?? false,
2020
+ logger: config?.logger
2003
2021
  };
2004
2022
  }
2005
2023
  async initialize(config) {
@@ -2021,29 +2039,55 @@ class TransformersEmbeddingProvider {
2021
2039
  this.isInitializing = true;
2022
2040
  this.initPromise = (async () => {
2023
2041
  const modelId = EMBEDDING_MODELS2[this.config.model];
2024
- if (this.config.showProgress) {
2025
- console.log(`
2026
- Loading embedding model: ${this.config.model}`);
2027
- console.log(` Cache: ${CACHE_DIR}`);
2028
- }
2042
+ const logger = this.config.logger;
2043
+ const showProgress = this.config.showProgress || !!logger;
2044
+ const isCached = await isModelCached(this.config.model);
2045
+ let hasDownloads = false;
2029
2046
  try {
2030
2047
  this.pipeline = await pipeline("feature-extraction", modelId, {
2031
- progress_callback: this.config.showProgress ? (progress) => {
2048
+ progress_callback: showProgress && !isCached ? (progress) => {
2032
2049
  if (progress.status === "progress" && progress.file) {
2050
+ if (!hasDownloads) {
2051
+ hasDownloads = true;
2052
+ if (logger) {
2053
+ logger.info(`Downloading embedding model: ${this.config.model}`);
2054
+ } else {
2055
+ console.log(`
2056
+ Loading embedding model: ${this.config.model}`);
2057
+ console.log(` Cache: ${CACHE_DIR}`);
2058
+ }
2059
+ }
2033
2060
  const pct = progress.progress ? Math.round(progress.progress) : 0;
2034
- process.stdout.write(`\r Downloading ${progress.file}: ${pct}% `);
2061
+ if (logger) {
2062
+ logger.progress(` Downloading ${progress.file}: ${pct}%`);
2063
+ } else {
2064
+ process.stdout.write(`\r Downloading ${progress.file}: ${pct}% `);
2065
+ }
2035
2066
  } else if (progress.status === "done" && progress.file) {
2036
- process.stdout.write(`\r Downloaded ${progress.file}
2067
+ if (logger) {
2068
+ logger.clearProgress();
2069
+ logger.info(` Downloaded ${progress.file}`);
2070
+ } else if (hasDownloads) {
2071
+ process.stdout.write(`\r Downloaded ${progress.file}
2037
2072
  `);
2073
+ }
2038
2074
  }
2039
2075
  } : undefined
2040
2076
  });
2041
- if (this.config.showProgress) {
2042
- console.log(` Model ready.
2077
+ if (hasDownloads) {
2078
+ if (logger) {
2079
+ logger.clearProgress();
2080
+ logger.info(`Model ready: ${this.config.model}`);
2081
+ } else {
2082
+ console.log(` Model ready.
2043
2083
  `);
2084
+ }
2044
2085
  }
2045
2086
  } catch (error) {
2046
2087
  this.pipeline = null;
2088
+ if (logger) {
2089
+ logger.clearProgress();
2090
+ }
2047
2091
  throw new Error(`Failed to load embedding model: ${error}`);
2048
2092
  } finally {
2049
2093
  this.isInitializing = false;
@@ -2094,9 +2138,21 @@ class TransformersEmbeddingProvider {
2094
2138
  this.pipeline = null;
2095
2139
  }
2096
2140
  }
2141
+ async function isModelCached(model) {
2142
+ const modelId = EMBEDDING_MODELS2[model];
2143
+ const modelPath = path6.join(CACHE_DIR, modelId);
2144
+ try {
2145
+ const fs3 = await import("fs/promises");
2146
+ const onnxPath = path6.join(modelPath, "onnx", "model_quantized.onnx");
2147
+ await fs3.access(onnxPath);
2148
+ return true;
2149
+ } catch {
2150
+ return false;
2151
+ }
2152
+ }
2097
2153
  function configureEmbeddings(config) {
2098
2154
  const newConfig = { ...globalConfig, ...config };
2099
- if (newConfig.model !== globalConfig.model) {
2155
+ if (newConfig.model !== globalConfig.model || newConfig.logger !== globalConfig.logger) {
2100
2156
  globalProvider = null;
2101
2157
  }
2102
2158
  globalConfig = newConfig;
@@ -2132,7 +2188,8 @@ var init_transformersEmbedding = __esm(() => {
2132
2188
  };
2133
2189
  globalConfig = {
2134
2190
  model: "all-MiniLM-L6-v2",
2135
- showProgress: false
2191
+ showProgress: false,
2192
+ logger: undefined
2136
2193
  };
2137
2194
  });
2138
2195
 
@@ -2765,8 +2822,16 @@ class TypeScriptModule {
2765
2822
  symbolicIndex = null;
2766
2823
  pendingSummaries = new Map;
2767
2824
  rootDir = "";
2825
+ logger = undefined;
2768
2826
  async initialize(config) {
2769
2827
  this.embeddingConfig = getEmbeddingConfigFromModule(config);
2828
+ this.logger = config.options?.logger;
2829
+ if (this.logger) {
2830
+ this.embeddingConfig = {
2831
+ ...this.embeddingConfig,
2832
+ logger: this.logger
2833
+ };
2834
+ }
2770
2835
  configureEmbeddings(this.embeddingConfig);
2771
2836
  this.pendingSummaries.clear();
2772
2837
  }
@@ -3315,6 +3380,92 @@ class IntrospectionIndex {
3315
3380
  this.structure = null;
3316
3381
  }
3317
3382
  }
3383
+ // src/infrastructure/logger/loggers.ts
3384
+ class ConsoleLogger {
3385
+ verbose;
3386
+ constructor(options) {
3387
+ this.verbose = options?.verbose ?? false;
3388
+ }
3389
+ info(message) {
3390
+ console.log(message);
3391
+ }
3392
+ warn(message) {
3393
+ console.warn(message);
3394
+ }
3395
+ error(message) {
3396
+ console.error(message);
3397
+ }
3398
+ debug(message) {
3399
+ if (this.verbose) {
3400
+ console.log(message);
3401
+ }
3402
+ }
3403
+ progress(message) {
3404
+ console.log(message);
3405
+ }
3406
+ clearProgress() {}
3407
+ }
3408
+
3409
+ class InlineProgressLogger {
3410
+ verbose;
3411
+ lastProgressLength = 0;
3412
+ hasProgress = false;
3413
+ constructor(options) {
3414
+ this.verbose = options?.verbose ?? false;
3415
+ }
3416
+ info(message) {
3417
+ this.clearProgress();
3418
+ console.log(message);
3419
+ }
3420
+ warn(message) {
3421
+ this.clearProgress();
3422
+ console.warn(message);
3423
+ }
3424
+ error(message) {
3425
+ this.clearProgress();
3426
+ console.error(message);
3427
+ }
3428
+ debug(message) {
3429
+ if (this.verbose) {
3430
+ this.clearProgress();
3431
+ console.log(message);
3432
+ }
3433
+ }
3434
+ progress(message) {
3435
+ process.stdout.write(`\r${message}`);
3436
+ const padding = Math.max(0, this.lastProgressLength - message.length);
3437
+ if (padding > 0) {
3438
+ process.stdout.write(" ".repeat(padding));
3439
+ }
3440
+ this.lastProgressLength = message.length;
3441
+ this.hasProgress = true;
3442
+ }
3443
+ clearProgress() {
3444
+ if (this.hasProgress && this.lastProgressLength > 0) {
3445
+ process.stdout.write("\r" + " ".repeat(this.lastProgressLength) + "\r");
3446
+ this.lastProgressLength = 0;
3447
+ this.hasProgress = false;
3448
+ }
3449
+ }
3450
+ }
3451
+
3452
+ class SilentLogger {
3453
+ info() {}
3454
+ warn() {}
3455
+ error() {}
3456
+ debug() {}
3457
+ progress() {}
3458
+ clearProgress() {}
3459
+ }
3460
+ function createLogger(options) {
3461
+ return new ConsoleLogger(options);
3462
+ }
3463
+ function createInlineLogger(options) {
3464
+ return new InlineProgressLogger(options);
3465
+ }
3466
+ function createSilentLogger() {
3467
+ return new SilentLogger;
3468
+ }
3318
3469
  // src/app/indexer/watcher.ts
3319
3470
  import { watch } from "chokidar";
3320
3471
  init_config2();
@@ -3324,42 +3475,31 @@ var INDEX_SCHEMA_VERSION = "1.0.0";
3324
3475
  async function indexDirectory(rootDir, options = {}) {
3325
3476
  const verbose = options.verbose ?? false;
3326
3477
  const quiet = options.quiet ?? false;
3478
+ const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
3327
3479
  rootDir = path11.resolve(rootDir);
3328
3480
  const location = getIndexLocation(rootDir);
3329
- if (!quiet) {
3330
- console.log(`Indexing directory: ${rootDir}`);
3331
- console.log(`Index location: ${location.indexDir}`);
3332
- }
3481
+ logger.info(`Indexing directory: ${rootDir}`);
3482
+ logger.info(`Index location: ${location.indexDir}`);
3333
3483
  const config = await loadConfig(rootDir);
3334
3484
  const introspection = new IntrospectionIndex(rootDir);
3335
3485
  await introspection.initialize();
3336
- if (verbose) {
3337
- const structure = introspection.getStructure();
3338
- if (structure?.isMonorepo) {
3339
- console.log(`Detected monorepo with ${structure.projects.length} projects`);
3340
- }
3486
+ const structure = introspection.getStructure();
3487
+ if (structure?.isMonorepo) {
3488
+ logger.debug(`Detected monorepo with ${structure.projects.length} projects`);
3341
3489
  }
3342
3490
  await registerBuiltInModules();
3343
3491
  const enabledModules = registry.getEnabled(config);
3344
3492
  if (enabledModules.length === 0) {
3345
- if (!quiet) {
3346
- console.log("No modules enabled. Check your configuration.");
3347
- }
3493
+ logger.info("No modules enabled. Check your configuration.");
3348
3494
  return [];
3349
3495
  }
3350
- if (!quiet) {
3351
- console.log(`Enabled modules: ${enabledModules.map((m) => m.id).join(", ")}`);
3352
- }
3496
+ logger.info(`Enabled modules: ${enabledModules.map((m) => m.id).join(", ")}`);
3353
3497
  const files = await findFiles(rootDir, config);
3354
- if (!quiet) {
3355
- console.log(`Found ${files.length} files to index`);
3356
- }
3498
+ logger.info(`Found ${files.length} files to index`);
3357
3499
  const results = [];
3358
3500
  for (const module of enabledModules) {
3359
- if (!quiet) {
3360
- console.log(`
3501
+ logger.info(`
3361
3502
  [${module.name}] Starting indexing...`);
3362
- }
3363
3503
  const moduleConfig = getModuleConfig(config, module.id);
3364
3504
  if (module.initialize && moduleConfig) {
3365
3505
  const configWithOverrides = { ...moduleConfig };
@@ -3369,14 +3509,16 @@ async function indexDirectory(rootDir, options = {}) {
3369
3509
  embeddingModel: options.model
3370
3510
  };
3371
3511
  }
3512
+ configWithOverrides.options = {
3513
+ ...configWithOverrides.options,
3514
+ logger
3515
+ };
3372
3516
  await module.initialize(configWithOverrides);
3373
3517
  }
3374
- const result = await indexWithModule(rootDir, files, module, config, verbose, introspection);
3518
+ const result = await indexWithModule(rootDir, files, module, config, verbose, introspection, logger);
3375
3519
  results.push(result);
3376
3520
  if (module.finalize) {
3377
- if (!quiet) {
3378
- console.log(`[${module.name}] Building secondary indexes...`);
3379
- }
3521
+ logger.info(`[${module.name}] Building secondary indexes...`);
3380
3522
  const ctx = {
3381
3523
  rootDir,
3382
3524
  config,
@@ -3392,9 +3534,7 @@ async function indexDirectory(rootDir, options = {}) {
3392
3534
  };
3393
3535
  await module.finalize(ctx);
3394
3536
  }
3395
- if (!quiet) {
3396
- console.log(`[${module.name}] Complete: ${result.indexed} indexed, ${result.skipped} skipped, ${result.errors} errors`);
3397
- }
3537
+ logger.info(`[${module.name}] Complete: ${result.indexed} indexed, ${result.skipped} skipped, ${result.errors} errors`);
3398
3538
  }
3399
3539
  await introspection.save(config);
3400
3540
  await updateGlobalManifest(rootDir, enabledModules, config);
@@ -3417,28 +3557,37 @@ async function deleteIndex(rootDir) {
3417
3557
  await fs6.rm(indexDir, { recursive: true, force: true });
3418
3558
  } catch {}
3419
3559
  }
3560
+ async function resetIndex(rootDir) {
3561
+ rootDir = path11.resolve(rootDir);
3562
+ const status = await getIndexStatus(rootDir);
3563
+ if (!status.exists) {
3564
+ throw new Error(`No index found for ${rootDir}`);
3565
+ }
3566
+ await deleteIndex(rootDir);
3567
+ return {
3568
+ success: true,
3569
+ indexDir: status.indexDir
3570
+ };
3571
+ }
3420
3572
  async function ensureIndexFresh(rootDir, options = {}) {
3421
3573
  const verbose = options.verbose ?? false;
3422
3574
  const quiet = options.quiet ?? false;
3575
+ const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
3423
3576
  rootDir = path11.resolve(rootDir);
3424
3577
  const status = await getIndexStatus(rootDir);
3425
3578
  if (!status.exists) {
3426
- if (!quiet) {
3427
- console.log(`No index found. Creating index...
3579
+ logger.info(`No index found. Creating index...
3428
3580
  `);
3429
- }
3430
- const results = await indexDirectory(rootDir, { ...options, quiet });
3581
+ const results = await indexDirectory(rootDir, { ...options, logger });
3431
3582
  const totalIndexed2 = results.reduce((sum, r) => sum + r.indexed, 0);
3432
3583
  return { indexed: totalIndexed2, removed: 0, unchanged: 0 };
3433
3584
  }
3434
3585
  const versionCompatible = await isIndexVersionCompatible(rootDir);
3435
3586
  if (!versionCompatible) {
3436
- if (!quiet) {
3437
- console.log(`Index version incompatible. Rebuilding...
3587
+ logger.info(`Index version incompatible. Rebuilding...
3438
3588
  `);
3439
- }
3440
3589
  await deleteIndex(rootDir);
3441
- const results = await indexDirectory(rootDir, { ...options, quiet });
3590
+ const results = await indexDirectory(rootDir, { ...options, logger });
3442
3591
  const totalIndexed2 = results.reduce((sum, r) => sum + r.indexed, 0);
3443
3592
  return { indexed: totalIndexed2, removed: 0, unchanged: 0 };
3444
3593
  }
@@ -3465,6 +3614,10 @@ async function ensureIndexFresh(rootDir, options = {}) {
3465
3614
  embeddingModel: options.model
3466
3615
  };
3467
3616
  }
3617
+ configWithOverrides.options = {
3618
+ ...configWithOverrides.options,
3619
+ logger
3620
+ };
3468
3621
  await module.initialize(configWithOverrides);
3469
3622
  }
3470
3623
  const manifest = await loadModuleManifest(rootDir, module.id, config);
@@ -3476,9 +3629,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
3476
3629
  }
3477
3630
  }
3478
3631
  for (const filepath of filesToRemove) {
3479
- if (verbose) {
3480
- console.log(` Removing stale: ${filepath}`);
3481
- }
3632
+ logger.debug(` Removing stale: ${filepath}`);
3482
3633
  const indexFilePath = path11.join(indexPath, filepath.replace(/\.[^.]+$/, ".json"));
3483
3634
  try {
3484
3635
  await fs6.unlink(indexFilePath);
@@ -3504,8 +3655,11 @@ async function ensureIndexFresh(rootDir, options = {}) {
3504
3655
  },
3505
3656
  getIntrospection: (filepath) => introspection.getFile(filepath)
3506
3657
  };
3507
- for (const filepath of currentFiles) {
3658
+ const totalFiles = currentFiles.length;
3659
+ for (let i = 0;i < currentFiles.length; i++) {
3660
+ const filepath = currentFiles[i];
3508
3661
  const relativePath = path11.relative(rootDir, filepath);
3662
+ const progress = `[${i + 1}/${totalFiles}]`;
3509
3663
  try {
3510
3664
  const stats = await fs6.stat(filepath);
3511
3665
  const lastModified = stats.mtime.toISOString();
@@ -3514,9 +3668,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
3514
3668
  totalUnchanged++;
3515
3669
  continue;
3516
3670
  }
3517
- if (verbose) {
3518
- console.log(` Indexing: ${relativePath}`);
3519
- }
3671
+ logger.progress(` ${progress} Indexing: ${relativePath}`);
3520
3672
  const content = await fs6.readFile(filepath, "utf-8");
3521
3673
  introspection.addFile(relativePath, content);
3522
3674
  const fileIndex = await module.indexFile(relativePath, content, ctx);
@@ -3529,11 +3681,11 @@ async function ensureIndexFresh(rootDir, options = {}) {
3529
3681
  totalIndexed++;
3530
3682
  }
3531
3683
  } catch (error) {
3532
- if (verbose) {
3533
- console.error(` Error indexing ${relativePath}:`, error);
3534
- }
3684
+ logger.clearProgress();
3685
+ logger.error(` ${progress} Error indexing ${relativePath}: ${error}`);
3535
3686
  }
3536
3687
  }
3688
+ logger.clearProgress();
3537
3689
  if (totalIndexed > 0 || totalRemoved > 0) {
3538
3690
  manifest.lastUpdated = new Date().toISOString();
3539
3691
  await writeModuleManifest(rootDir, module.id, manifest, config);
@@ -3557,7 +3709,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
3557
3709
  unchanged: totalUnchanged
3558
3710
  };
3559
3711
  }
3560
- async function indexWithModule(rootDir, files, module, config, verbose, introspection) {
3712
+ async function indexWithModule(rootDir, files, module, config, verbose, introspection, logger) {
3561
3713
  const result = {
3562
3714
  moduleId: module.id,
3563
3715
  indexed: 0,
@@ -3565,6 +3717,30 @@ async function indexWithModule(rootDir, files, module, config, verbose, introspe
3565
3717
  errors: 0
3566
3718
  };
3567
3719
  const manifest = await loadModuleManifest(rootDir, module.id, config);
3720
+ const indexPath = getModuleIndexPath(rootDir, module.id, config);
3721
+ const currentFileSet = new Set(files.map((f) => path11.relative(rootDir, f)));
3722
+ const filesToRemove = [];
3723
+ for (const filepath of Object.keys(manifest.files)) {
3724
+ if (!currentFileSet.has(filepath)) {
3725
+ filesToRemove.push(filepath);
3726
+ }
3727
+ }
3728
+ if (filesToRemove.length > 0) {
3729
+ logger.info(` Removing ${filesToRemove.length} stale entries...`);
3730
+ for (const filepath of filesToRemove) {
3731
+ logger.debug(` Removing: ${filepath}`);
3732
+ const indexFilePath = path11.join(indexPath, filepath.replace(/\.[^.]+$/, ".json"));
3733
+ try {
3734
+ await fs6.unlink(indexFilePath);
3735
+ } catch {}
3736
+ const symbolicFilePath = path11.join(indexPath, "symbolic", filepath.replace(/\.[^.]+$/, ".json"));
3737
+ try {
3738
+ await fs6.unlink(symbolicFilePath);
3739
+ } catch {}
3740
+ delete manifest.files[filepath];
3741
+ }
3742
+ await cleanupEmptyDirectories(indexPath);
3743
+ }
3568
3744
  const ctx = {
3569
3745
  rootDir,
3570
3746
  config,
@@ -3579,29 +3755,26 @@ async function indexWithModule(rootDir, files, module, config, verbose, introspe
3579
3755
  },
3580
3756
  getIntrospection: (filepath) => introspection.getFile(filepath)
3581
3757
  };
3582
- for (const filepath of files) {
3758
+ const totalFiles = files.length;
3759
+ for (let i = 0;i < files.length; i++) {
3760
+ const filepath = files[i];
3583
3761
  const relativePath = path11.relative(rootDir, filepath);
3762
+ const progress = `[${i + 1}/${totalFiles}]`;
3584
3763
  try {
3585
3764
  const stats = await fs6.stat(filepath);
3586
3765
  const lastModified = stats.mtime.toISOString();
3587
3766
  const existingEntry = manifest.files[relativePath];
3588
3767
  if (existingEntry && existingEntry.lastModified === lastModified) {
3589
- if (verbose) {
3590
- console.log(` Skipped ${relativePath} (unchanged)`);
3591
- }
3768
+ logger.debug(` ${progress} Skipped ${relativePath} (unchanged)`);
3592
3769
  result.skipped++;
3593
3770
  continue;
3594
3771
  }
3595
3772
  const content = await fs6.readFile(filepath, "utf-8");
3596
3773
  introspection.addFile(relativePath, content);
3597
- if (verbose) {
3598
- console.log(` Processing ${relativePath}...`);
3599
- }
3774
+ logger.progress(` ${progress} Processing: ${relativePath}`);
3600
3775
  const fileIndex = await module.indexFile(relativePath, content, ctx);
3601
3776
  if (!fileIndex) {
3602
- if (verbose) {
3603
- console.log(` Skipped ${relativePath} (no chunks)`);
3604
- }
3777
+ logger.debug(` ${progress} Skipped ${relativePath} (no chunks)`);
3605
3778
  result.skipped++;
3606
3779
  continue;
3607
3780
  }
@@ -3612,10 +3785,12 @@ async function indexWithModule(rootDir, files, module, config, verbose, introspe
3612
3785
  };
3613
3786
  result.indexed++;
3614
3787
  } catch (error) {
3615
- console.error(` Error indexing ${relativePath}:`, error);
3788
+ logger.clearProgress();
3789
+ logger.error(` ${progress} Error indexing ${relativePath}: ${error}`);
3616
3790
  result.errors++;
3617
3791
  }
3618
3792
  }
3793
+ logger.clearProgress();
3619
3794
  manifest.lastUpdated = new Date().toISOString();
3620
3795
  await writeModuleManifest(rootDir, module.id, manifest, config);
3621
3796
  return result;
@@ -3671,26 +3846,27 @@ async function updateGlobalManifest(rootDir, modules, config) {
3671
3846
  }
3672
3847
  async function cleanupIndex(rootDir, options = {}) {
3673
3848
  const verbose = options.verbose ?? false;
3849
+ const logger = options.logger ?? createLogger({ verbose });
3674
3850
  rootDir = path11.resolve(rootDir);
3675
- console.log(`Cleaning up index in: ${rootDir}`);
3851
+ logger.info(`Cleaning up index in: ${rootDir}`);
3676
3852
  const config = await loadConfig(rootDir);
3677
3853
  await registerBuiltInModules();
3678
3854
  const enabledModules = registry.getEnabled(config);
3679
3855
  if (enabledModules.length === 0) {
3680
- console.log("No modules enabled.");
3856
+ logger.info("No modules enabled.");
3681
3857
  return [];
3682
3858
  }
3683
3859
  const results = [];
3684
3860
  for (const module of enabledModules) {
3685
- console.log(`
3861
+ logger.info(`
3686
3862
  [${module.name}] Checking for stale entries...`);
3687
- const result = await cleanupModuleIndex(rootDir, module.id, config, verbose);
3863
+ const result = await cleanupModuleIndex(rootDir, module.id, config, logger);
3688
3864
  results.push(result);
3689
- console.log(`[${module.name}] Removed ${result.removed} stale entries, kept ${result.kept} valid entries`);
3865
+ logger.info(`[${module.name}] Removed ${result.removed} stale entries, kept ${result.kept} valid entries`);
3690
3866
  }
3691
3867
  return results;
3692
3868
  }
3693
- async function cleanupModuleIndex(rootDir, moduleId, config, verbose) {
3869
+ async function cleanupModuleIndex(rootDir, moduleId, config, logger) {
3694
3870
  const result = {
3695
3871
  moduleId,
3696
3872
  removed: 0,
@@ -3709,9 +3885,7 @@ async function cleanupModuleIndex(rootDir, moduleId, config, verbose) {
3709
3885
  } catch {
3710
3886
  filesToRemove.push(filepath);
3711
3887
  result.removed++;
3712
- if (verbose) {
3713
- console.log(` Removing stale entry: ${filepath}`);
3714
- }
3888
+ logger.debug(` Removing stale entry: ${filepath}`);
3715
3889
  }
3716
3890
  }
3717
3891
  for (const filepath of filesToRemove) {
@@ -3956,19 +4130,30 @@ async function search2(directory, query, options = {}) {
3956
4130
  async function cleanup(directory, options = {}) {
3957
4131
  return cleanupIndex(directory, options);
3958
4132
  }
4133
+ async function reset(directory) {
4134
+ return resetIndex(directory);
4135
+ }
3959
4136
  var raggrep = {
3960
4137
  index,
3961
4138
  search: search2,
3962
4139
  cleanup,
4140
+ reset,
3963
4141
  formatSearchResults
3964
4142
  };
3965
4143
  var src_default = raggrep;
3966
4144
  export {
3967
4145
  search2 as search,
4146
+ reset,
3968
4147
  index,
3969
4148
  formatSearchResults,
3970
4149
  src_default as default,
3971
- cleanup
4150
+ createSilentLogger,
4151
+ createLogger,
4152
+ createInlineLogger,
4153
+ cleanup,
4154
+ SilentLogger,
4155
+ InlineProgressLogger,
4156
+ ConsoleLogger
3972
4157
  };
3973
4158
 
3974
- //# debugId=25853E0D892AD2D964756E2164756E21
4159
+ //# debugId=3E17C296D218EF4F64756E2164756E21