@wrongstack/tools 0.268.0 → 0.270.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.
@@ -339,7 +339,7 @@ var IndexStore = class {
339
339
  throw new LockError(`SQLite lock conflict after ${MAX_LOCK_RETRIES} retries: ${msg}`);
340
340
  }
341
341
  const delay = Math.min(
342
- LOCK_RETRY_BASE_DELAY_MS * Math.pow(2, attempt),
342
+ LOCK_RETRY_BASE_DELAY_MS * 2 ** attempt,
343
343
  LOCK_RETRY_MAX_DELAY_MS
344
344
  );
345
345
  sleepSync(delay);
@@ -632,14 +632,15 @@ var IndexStore = class {
632
632
  if (!query.trim()) {
633
633
  return { results: candidates.slice(0, limit), total: candidates.length };
634
634
  }
635
+ const candidateById = new Map(candidates.map((c) => [c.id, c]));
635
636
  const bm25 = buildBm25Index(
636
637
  candidates.map((c) => ({ id: c.id, text: buildIndexableText(c.name, c.signature, c.docComment) }))
637
638
  );
638
- const scored = bm25.score(query, (id) => candidates.some((c) => c.id === id));
639
+ const scored = bm25.score(query, (id) => candidateById.has(id));
639
640
  scored.sort((a, b) => b.score - a.score);
640
641
  const qTokens = tokenise(query);
641
642
  const results = scored.slice(0, limit).map(({ id, score }) => {
642
- const c = expectDefined(candidates.find((cand) => cand.id === id));
643
+ const c = expectDefined(candidateById.get(id));
643
644
  return { ...c, score, snippet: bm25.extractSnippet(id, qTokens) };
644
645
  });
645
646
  return { results, total: candidates.length };
@@ -2211,6 +2212,10 @@ async function runIndexerWithStore(store, opts) {
2211
2212
  if (!stat2.isFile()) return { file, stat: stat2, lang: "", parsed: null };
2212
2213
  const lang = detectLang(file);
2213
2214
  if (!lang) return { file, stat: stat2, lang: "", parsed: null };
2215
+ const meta = existingMeta.get(file);
2216
+ if (!force && meta && meta.mtimeMs === Math.floor(stat2.mtimeMs)) {
2217
+ return { file, stat: stat2, lang, parsed: null, skippedMeta: meta };
2218
+ }
2214
2219
  let content;
2215
2220
  try {
2216
2221
  content = await fs3.readFile(file, { encoding: "utf8", signal });
@@ -2243,6 +2248,12 @@ async function runIndexerWithStore(store, opts) {
2243
2248
  continue;
2244
2249
  }
2245
2250
  const { stat: stat2, lang, parsed } = result;
2251
+ if (result.skippedMeta) {
2252
+ langStats[lang] = (langStats[lang] ?? 0) + result.skippedMeta.symbolCount;
2253
+ symbolsIndexed += result.skippedMeta.symbolCount;
2254
+ filesIndexed++;
2255
+ continue;
2256
+ }
2246
2257
  if (!lang || !parsed) {
2247
2258
  if (lang) {
2248
2259
  store.upsertFile({ file, lang, mtimeMs: Math.floor(stat2.mtimeMs), symbolCount: 0, lastIndexed: Date.now() });
@@ -2250,13 +2261,6 @@ async function runIndexerWithStore(store, opts) {
2250
2261
  }
2251
2262
  continue;
2252
2263
  }
2253
- const meta = existingMeta.get(file);
2254
- if (!force && meta && meta.mtimeMs === Math.floor(stat2.mtimeMs)) {
2255
- langStats[lang] = (langStats[lang] ?? 0) + meta.symbolCount;
2256
- symbolsIndexed += meta.symbolCount;
2257
- filesIndexed++;
2258
- continue;
2259
- }
2260
2264
  store.deleteRefsForFile(file);
2261
2265
  store.deleteSymbolsForFile(file);
2262
2266
  if (parsed.symbols.length === 0) {