@wrongstack/tools 0.268.0 → 0.269.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.
@@ -296,7 +296,7 @@ var IndexStore = class {
296
296
  throw new LockError(`SQLite lock conflict after ${MAX_LOCK_RETRIES} retries: ${msg}`);
297
297
  }
298
298
  const delay = Math.min(
299
- LOCK_RETRY_BASE_DELAY_MS * Math.pow(2, attempt),
299
+ LOCK_RETRY_BASE_DELAY_MS * 2 ** attempt,
300
300
  LOCK_RETRY_MAX_DELAY_MS
301
301
  );
302
302
  sleepSync(delay);
@@ -589,14 +589,15 @@ var IndexStore = class {
589
589
  if (!query.trim()) {
590
590
  return { results: candidates.slice(0, limit), total: candidates.length };
591
591
  }
592
+ const candidateById = new Map(candidates.map((c) => [c.id, c]));
592
593
  const bm25 = buildBm25Index(
593
594
  candidates.map((c) => ({ id: c.id, text: buildIndexableText(c.name, c.signature, c.docComment) }))
594
595
  );
595
- const scored = bm25.score(query, (id) => candidates.some((c) => c.id === id));
596
+ const scored = bm25.score(query, (id) => candidateById.has(id));
596
597
  scored.sort((a, b) => b.score - a.score);
597
598
  const qTokens = tokenise(query);
598
599
  const results = scored.slice(0, limit).map(({ id, score }) => {
599
- const c = expectDefined(candidates.find((cand) => cand.id === id));
600
+ const c = expectDefined(candidateById.get(id));
600
601
  return { ...c, score, snippet: bm25.extractSnippet(id, qTokens) };
601
602
  });
602
603
  return { results, total: candidates.length };
@@ -2168,6 +2169,10 @@ async function runIndexerWithStore(store, opts) {
2168
2169
  if (!stat2.isFile()) return { file, stat: stat2, lang: "", parsed: null };
2169
2170
  const lang = detectLang(file);
2170
2171
  if (!lang) return { file, stat: stat2, lang: "", parsed: null };
2172
+ const meta = existingMeta.get(file);
2173
+ if (!force && meta && meta.mtimeMs === Math.floor(stat2.mtimeMs)) {
2174
+ return { file, stat: stat2, lang, parsed: null, skippedMeta: meta };
2175
+ }
2171
2176
  let content;
2172
2177
  try {
2173
2178
  content = await fs3.readFile(file, { encoding: "utf8", signal });
@@ -2200,6 +2205,12 @@ async function runIndexerWithStore(store, opts) {
2200
2205
  continue;
2201
2206
  }
2202
2207
  const { stat: stat2, lang, parsed } = result;
2208
+ if (result.skippedMeta) {
2209
+ langStats[lang] = (langStats[lang] ?? 0) + result.skippedMeta.symbolCount;
2210
+ symbolsIndexed += result.skippedMeta.symbolCount;
2211
+ filesIndexed++;
2212
+ continue;
2213
+ }
2203
2214
  if (!lang || !parsed) {
2204
2215
  if (lang) {
2205
2216
  store.upsertFile({ file, lang, mtimeMs: Math.floor(stat2.mtimeMs), symbolCount: 0, lastIndexed: Date.now() });
@@ -2207,13 +2218,6 @@ async function runIndexerWithStore(store, opts) {
2207
2218
  }
2208
2219
  continue;
2209
2220
  }
2210
- const meta = existingMeta.get(file);
2211
- if (!force && meta && meta.mtimeMs === Math.floor(stat2.mtimeMs)) {
2212
- langStats[lang] = (langStats[lang] ?? 0) + meta.symbolCount;
2213
- symbolsIndexed += meta.symbolCount;
2214
- filesIndexed++;
2215
- continue;
2216
- }
2217
2221
  store.deleteRefsForFile(file);
2218
2222
  store.deleteSymbolsForFile(file);
2219
2223
  if (parsed.symbols.length === 0) {