raggrep 0.5.0 → 0.5.1

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.
@@ -74,6 +74,11 @@ export interface SearchOptions {
74
74
  minScore?: number;
75
75
  /** Filter to specific file patterns (e.g., ['*.ts', '*.tsx']) */
76
76
  filePatterns?: string[];
77
+ /**
78
+ * Filter to files within specified paths (e.g., ['src/auth', 'src/utils']).
79
+ * Results will only include files that start with one of the specified paths.
80
+ */
81
+ pathFilter?: string[];
77
82
  /**
78
83
  * Ensure the index is fresh before searching (default: true).
79
84
  *
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ var init_searchResult = __esm(() => {
33
33
  topK: 10,
34
34
  minScore: 0.15,
35
35
  filePatterns: [],
36
+ pathFilter: [],
36
37
  ensureFresh: true
37
38
  };
38
39
  });
@@ -1795,6 +1796,9 @@ class CoreModule {
1795
1796
  name = "Core Search";
1796
1797
  description = "Language-agnostic text search with symbol extraction";
1797
1798
  version = "1.0.0";
1799
+ supportsFile(_filepath) {
1800
+ return true;
1801
+ }
1798
1802
  symbolIndex = new Map;
1799
1803
  bm25Index = null;
1800
1804
  rootDir = "";
@@ -2885,6 +2889,7 @@ var init_storage = __esm(() => {
2885
2889
  // src/modules/language/typescript/index.ts
2886
2890
  var exports_typescript = {};
2887
2891
  __export(exports_typescript, {
2892
+ supportsFile: () => supportsFile,
2888
2893
  isTypeScriptFile: () => isTypeScriptFile,
2889
2894
  TypeScriptModule: () => TypeScriptModule,
2890
2895
  TYPESCRIPT_EXTENSIONS: () => TYPESCRIPT_EXTENSIONS,
@@ -2923,6 +2928,9 @@ class TypeScriptModule {
2923
2928
  name = "TypeScript Search";
2924
2929
  description = "TypeScript-aware code search with AST parsing and semantic embeddings";
2925
2930
  version = "1.0.0";
2931
+ supportsFile(filepath) {
2932
+ return isTypeScriptFile(filepath);
2933
+ }
2926
2934
  embeddingConfig = null;
2927
2935
  symbolicIndex = null;
2928
2936
  pendingSummaries = new Map;
@@ -3146,7 +3154,7 @@ class TypeScriptModule {
3146
3154
  return references;
3147
3155
  }
3148
3156
  }
3149
- var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3, TYPESCRIPT_EXTENSIONS;
3157
+ var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3, TYPESCRIPT_EXTENSIONS, supportsFile;
3150
3158
  var init_typescript = __esm(() => {
3151
3159
  init_embeddings();
3152
3160
  init_services();
@@ -3163,11 +3171,13 @@ var init_typescript = __esm(() => {
3163
3171
  ".mts",
3164
3172
  ".cts"
3165
3173
  ];
3174
+ supportsFile = isTypeScriptFile;
3166
3175
  });
3167
3176
 
3168
3177
  // src/modules/data/json/index.ts
3169
3178
  var exports_json = {};
3170
3179
  __export(exports_json, {
3180
+ supportsFile: () => supportsFile2,
3171
3181
  isJsonFile: () => isJsonFile,
3172
3182
  JsonModule: () => JsonModule,
3173
3183
  JSON_EXTENSIONS: () => JSON_EXTENSIONS,
@@ -3224,6 +3234,9 @@ class JsonModule {
3224
3234
  name = "JSON Search";
3225
3235
  description = "JSON file search with structure-aware indexing";
3226
3236
  version = "1.0.0";
3237
+ supportsFile(filepath) {
3238
+ return isJsonFile(filepath);
3239
+ }
3227
3240
  embeddingConfig = null;
3228
3241
  symbolicIndex = null;
3229
3242
  pendingSummaries = new Map;
@@ -3385,18 +3398,20 @@ class JsonModule {
3385
3398
  return results.slice(0, topK);
3386
3399
  }
3387
3400
  }
3388
- var DEFAULT_MIN_SCORE3 = 0.15, DEFAULT_TOP_K3 = 10, SEMANTIC_WEIGHT2 = 0.7, BM25_WEIGHT2 = 0.3, JSON_EXTENSIONS;
3401
+ var DEFAULT_MIN_SCORE3 = 0.15, DEFAULT_TOP_K3 = 10, SEMANTIC_WEIGHT2 = 0.7, BM25_WEIGHT2 = 0.3, JSON_EXTENSIONS, supportsFile2;
3389
3402
  var init_json = __esm(() => {
3390
3403
  init_embeddings();
3391
3404
  init_services();
3392
3405
  init_config2();
3393
3406
  init_storage();
3394
3407
  JSON_EXTENSIONS = [".json"];
3408
+ supportsFile2 = isJsonFile;
3395
3409
  });
3396
3410
 
3397
3411
  // src/modules/docs/markdown/index.ts
3398
3412
  var exports_markdown = {};
3399
3413
  __export(exports_markdown, {
3414
+ supportsFile: () => supportsFile3,
3400
3415
  isMarkdownFile: () => isMarkdownFile,
3401
3416
  MarkdownModule: () => MarkdownModule,
3402
3417
  MARKDOWN_EXTENSIONS: () => MARKDOWN_EXTENSIONS,
@@ -3502,6 +3517,9 @@ class MarkdownModule {
3502
3517
  name = "Markdown Search";
3503
3518
  description = "Markdown documentation search with section-aware indexing";
3504
3519
  version = "1.0.0";
3520
+ supportsFile(filepath) {
3521
+ return isMarkdownFile(filepath);
3522
+ }
3505
3523
  embeddingConfig = null;
3506
3524
  symbolicIndex = null;
3507
3525
  pendingSummaries = new Map;
@@ -3671,13 +3689,14 @@ ${section.content}` : section.content,
3671
3689
  return results.slice(0, topK);
3672
3690
  }
3673
3691
  }
3674
- var DEFAULT_MIN_SCORE4 = 0.15, DEFAULT_TOP_K4 = 10, SEMANTIC_WEIGHT3 = 0.7, BM25_WEIGHT3 = 0.3, MARKDOWN_EXTENSIONS;
3692
+ var DEFAULT_MIN_SCORE4 = 0.15, DEFAULT_TOP_K4 = 10, SEMANTIC_WEIGHT3 = 0.7, BM25_WEIGHT3 = 0.3, MARKDOWN_EXTENSIONS, supportsFile3;
3675
3693
  var init_markdown = __esm(() => {
3676
3694
  init_embeddings();
3677
3695
  init_services();
3678
3696
  init_config2();
3679
3697
  init_storage();
3680
3698
  MARKDOWN_EXTENSIONS = [".md", ".txt"];
3699
+ supportsFile3 = isMarkdownFile;
3681
3700
  });
3682
3701
 
3683
3702
  // src/app/indexer/index.ts
@@ -4081,6 +4100,18 @@ async function parallelMap(items, processor, concurrency) {
4081
4100
  return results;
4082
4101
  }
4083
4102
  var INDEX_SCHEMA_VERSION = "1.0.0";
4103
+ function formatDuration(ms) {
4104
+ if (ms < 1000) {
4105
+ return `${ms}ms`;
4106
+ }
4107
+ const seconds = ms / 1000;
4108
+ if (seconds < 60) {
4109
+ return `${seconds.toFixed(1)}s`;
4110
+ }
4111
+ const minutes = Math.floor(seconds / 60);
4112
+ const remainingSeconds = seconds % 60;
4113
+ return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
4114
+ }
4084
4115
  var DEFAULT_CONCURRENCY = 4;
4085
4116
  async function indexDirectory(rootDir, options = {}) {
4086
4117
  const verbose = options.verbose ?? false;
@@ -4108,8 +4139,10 @@ async function indexDirectory(rootDir, options = {}) {
4108
4139
  logger.info(`Enabled modules: ${enabledModules.map((m) => m.id).join(", ")}`);
4109
4140
  const files = await findFiles(rootDir, config);
4110
4141
  logger.info(`Found ${files.length} files to index`);
4142
+ const overallStart = Date.now();
4111
4143
  const results = [];
4112
4144
  for (const module of enabledModules) {
4145
+ const moduleStart = Date.now();
4113
4146
  logger.info(`
4114
4147
  [${module.name}] Starting indexing...`);
4115
4148
  const moduleConfig = getModuleConfig(config, module.id);
@@ -4127,7 +4160,9 @@ async function indexDirectory(rootDir, options = {}) {
4127
4160
  };
4128
4161
  await module.initialize(configWithOverrides);
4129
4162
  }
4130
- const result = await indexWithModule(rootDir, files, module, config, verbose, introspection, logger, concurrency);
4163
+ const moduleFiles = module.supportsFile ? files.filter((f) => module.supportsFile(f)) : files;
4164
+ logger.info(` Processing ${moduleFiles.length} files...`);
4165
+ const result = await indexWithModule(rootDir, moduleFiles, module, config, verbose, introspection, logger, concurrency);
4131
4166
  results.push(result);
4132
4167
  if (module.finalize) {
4133
4168
  logger.info(`[${module.name}] Building secondary indexes...`);
@@ -4146,9 +4181,18 @@ async function indexDirectory(rootDir, options = {}) {
4146
4181
  };
4147
4182
  await module.finalize(ctx);
4148
4183
  }
4149
- logger.info(`[${module.name}] Complete: ${result.indexed} indexed, ${result.skipped} skipped, ${result.errors} errors`);
4184
+ const moduleDuration = Date.now() - moduleStart;
4185
+ result.durationMs = moduleDuration;
4186
+ logger.info(`[${module.name}] Complete: ${result.indexed} indexed, ${result.skipped} skipped, ${result.errors} errors (${formatDuration(moduleDuration)})`);
4150
4187
  }
4151
4188
  await introspection.save(config);
4189
+ const overallDuration = Date.now() - overallStart;
4190
+ logger.info(`
4191
+ Indexing complete in ${formatDuration(overallDuration)}`);
4192
+ const totalIndexed = results.reduce((sum, r) => sum + r.indexed, 0);
4193
+ const totalSkipped = results.reduce((sum, r) => sum + r.skipped, 0);
4194
+ const totalErrors = results.reduce((sum, r) => sum + r.errors, 0);
4195
+ logger.info(`Total: ${totalIndexed} indexed, ${totalSkipped} skipped, ${totalErrors} errors`);
4152
4196
  await updateGlobalManifest(rootDir, enabledModules, config);
4153
4197
  return results;
4154
4198
  }
@@ -4657,9 +4701,17 @@ async function search(rootDir, query, options = {}) {
4657
4701
  const moduleResults = await module.search(query, ctx, options);
4658
4702
  allResults.push(...moduleResults);
4659
4703
  }
4660
- allResults.sort((a, b) => b.score - a.score);
4704
+ let filteredResults = allResults;
4705
+ if (options.pathFilter && options.pathFilter.length > 0) {
4706
+ const normalizedFilters = options.pathFilter.map((p) => p.replace(/\\/g, "/").replace(/^\//, "").replace(/\/$/, ""));
4707
+ filteredResults = allResults.filter((result) => {
4708
+ const normalizedPath = result.filepath.replace(/\\/g, "/");
4709
+ return normalizedFilters.some((filter) => normalizedPath.startsWith(filter + "/") || normalizedPath === filter || normalizedPath.startsWith("./" + filter + "/") || normalizedPath === "./" + filter);
4710
+ });
4711
+ }
4712
+ filteredResults.sort((a, b) => b.score - a.score);
4661
4713
  const topK = options.topK ?? 10;
4662
- return allResults.slice(0, topK);
4714
+ return filteredResults.slice(0, topK);
4663
4715
  }
4664
4716
  function createSearchContext(rootDir, moduleId, config) {
4665
4717
  const indexPath = getModuleIndexPath(rootDir, moduleId, config);
@@ -4792,4 +4844,4 @@ export {
4792
4844
  ConsoleLogger
4793
4845
  };
4794
4846
 
4795
- //# debugId=984F0AA3FD08D5A664756E2164756E21
4847
+ //# debugId=C1C754EB0A3147DB64756E2164756E21