raggrep 0.2.1 → 0.2.3

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
@@ -147,7 +147,7 @@ function getEmbeddingConfigFromModule(moduleConfig) {
147
147
  }
148
148
  return {
149
149
  model: modelName,
150
- showProgress: options.showProgress !== false
150
+ showProgress: options.showProgress === true
151
151
  };
152
152
  }
153
153
  var DEFAULT_CONFIG, RAGGREP_TEMP_BASE, EMBEDDING_MODELS;
@@ -1847,7 +1847,6 @@ class CoreModule {
1847
1847
  bm25Data: this.bm25Index.serialize()
1848
1848
  };
1849
1849
  await fs2.writeFile(path5.join(coreDir, "symbols.json"), JSON.stringify(symbolIndexData, null, 2));
1850
- console.log(` [Core] Symbol index built with ${this.symbolIndex.size} files`);
1851
1850
  }
1852
1851
  async search(query, ctx, options) {
1853
1852
  const config = ctx.config;
@@ -1982,7 +1981,7 @@ class TransformersEmbeddingProvider {
1982
1981
  constructor(config) {
1983
1982
  this.config = {
1984
1983
  model: config?.model ?? "all-MiniLM-L6-v2",
1985
- showProgress: config?.showProgress ?? true
1984
+ showProgress: config?.showProgress ?? false
1986
1985
  };
1987
1986
  }
1988
1987
  async initialize(config) {
@@ -2115,7 +2114,7 @@ var init_transformersEmbedding = __esm(() => {
2115
2114
  };
2116
2115
  globalConfig = {
2117
2116
  model: "all-MiniLM-L6-v2",
2118
- showProgress: true
2117
+ showProgress: false
2119
2118
  };
2120
2119
  });
2121
2120
 
@@ -2732,7 +2731,9 @@ class TypeScriptModule {
2732
2731
  embeddings,
2733
2732
  embeddingModel: currentConfig.model
2734
2733
  };
2735
- const chunkTypes = [...new Set(parsedChunks.map((pc) => pc.type))];
2734
+ const chunkTypes = [
2735
+ ...new Set(parsedChunks.map((pc) => pc.type))
2736
+ ];
2736
2737
  const exports = parsedChunks.filter((pc) => pc.isExported && pc.name).map((pc) => pc.name);
2737
2738
  const allKeywords = new Set;
2738
2739
  for (const pc of parsedChunks) {
@@ -2772,26 +2773,26 @@ class TypeScriptModule {
2772
2773
  }
2773
2774
  this.symbolicIndex.buildBM25Index();
2774
2775
  await this.symbolicIndex.save();
2775
- console.log(` Symbolic index built with ${this.pendingSummaries.size} file summaries`);
2776
2776
  this.pendingSummaries.clear();
2777
2777
  }
2778
2778
  async search(query, ctx, options = {}) {
2779
- const { topK = DEFAULT_TOP_K2, minScore = DEFAULT_MIN_SCORE2, filePatterns } = options;
2779
+ const {
2780
+ topK = DEFAULT_TOP_K2,
2781
+ minScore = DEFAULT_MIN_SCORE2,
2782
+ filePatterns
2783
+ } = options;
2780
2784
  const indexDir = getRaggrepDir(ctx.rootDir, ctx.config);
2781
2785
  const symbolicIndex = new SymbolicIndex(indexDir, this.id);
2782
- let candidateFiles;
2786
+ let allFiles;
2783
2787
  try {
2784
2788
  await symbolicIndex.initialize();
2785
- const maxCandidates = topK * TIER1_CANDIDATE_MULTIPLIER;
2786
- candidateFiles = symbolicIndex.findCandidates(query, maxCandidates);
2787
- if (candidateFiles.length === 0) {
2788
- candidateFiles = symbolicIndex.getAllFiles();
2789
- }
2789
+ allFiles = symbolicIndex.getAllFiles();
2790
2790
  } catch {
2791
- candidateFiles = await ctx.listIndexedFiles();
2791
+ allFiles = await ctx.listIndexedFiles();
2792
2792
  }
2793
+ let filesToSearch = allFiles;
2793
2794
  if (filePatterns && filePatterns.length > 0) {
2794
- candidateFiles = candidateFiles.filter((filepath) => {
2795
+ filesToSearch = allFiles.filter((filepath) => {
2795
2796
  return filePatterns.some((pattern) => {
2796
2797
  if (pattern.startsWith("*.")) {
2797
2798
  const ext = pattern.slice(1);
@@ -2804,7 +2805,7 @@ class TypeScriptModule {
2804
2805
  const queryEmbedding = await getEmbedding(query);
2805
2806
  const bm25Index = new BM25Index;
2806
2807
  const allChunksData = [];
2807
- for (const filepath of candidateFiles) {
2808
+ for (const filepath of filesToSearch) {
2808
2809
  const fileIndex = await ctx.loadFileIndex(filepath);
2809
2810
  if (!fileIndex)
2810
2811
  continue;
@@ -2831,7 +2832,7 @@ class TypeScriptModule {
2831
2832
  }
2832
2833
  const queryTerms = query.toLowerCase().split(/\s+/).filter((t) => t.length > 2);
2833
2834
  const pathBoosts = new Map;
2834
- for (const filepath of candidateFiles) {
2835
+ for (const filepath of filesToSearch) {
2835
2836
  const summary = symbolicIndex.getFileSummary(filepath);
2836
2837
  if (summary?.pathContext) {
2837
2838
  let boost = 0;
@@ -2896,7 +2897,7 @@ class TypeScriptModule {
2896
2897
  return references;
2897
2898
  }
2898
2899
  }
2899
- var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3, TIER1_CANDIDATE_MULTIPLIER = 3;
2900
+ var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3;
2900
2901
  var init_typescript = __esm(() => {
2901
2902
  init_embeddings();
2902
2903
  init_config2();
@@ -2916,10 +2917,9 @@ import * as path11 from "path";
2916
2917
  class ModuleRegistryImpl {
2917
2918
  modules = new Map;
2918
2919
  register(module) {
2919
- if (this.modules.has(module.id)) {
2920
- console.warn(`Module '${module.id}' is already registered, overwriting...`);
2920
+ if (!this.modules.has(module.id)) {
2921
+ this.modules.set(module.id, module);
2921
2922
  }
2922
- this.modules.set(module.id, module);
2923
2923
  }
2924
2924
  get(id) {
2925
2925
  return this.modules.get(id);
@@ -3158,7 +3158,6 @@ class IntrospectionIndex {
3158
3158
  await fs5.mkdir(path10.dirname(introFilePath), { recursive: true });
3159
3159
  await fs5.writeFile(introFilePath, JSON.stringify(intro, null, 2));
3160
3160
  }
3161
- console.log(` [Introspection] Saved metadata for ${this.files.size} files`);
3162
3161
  }
3163
3162
  async load(config) {
3164
3163
  const introDir = path10.join(getRaggrepDir(this.rootDir, config), "introspection");
@@ -3627,4 +3626,4 @@ export {
3627
3626
  cleanup
3628
3627
  };
3629
3628
 
3630
- //# debugId=DEB2F8AAF72AF0A164756E2164756E21
3629
+ //# debugId=22D9AEEC336F77A764756E2164756E21