@wrongstack/tools 0.250.0 → 0.255.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.
@@ -1,5 +1,5 @@
1
- import { t as IndexResult, S as Symbol, F as FileMeta, u as SymbolKind, v as SymbolLang, w as SearchResult, x as IndexStats, R as Ref } from '../background-indexer-DwJsyAB0.js';
2
- export { C as CircuitOpenError, a as CircuitSnapshot, b as CircuitState, y as FileSymbols, I as IndexCircuitBreaker, c as IndexTimeoutError, z as SCHEMA_VERSION, d as cancelPendingReindexes, e as codebaseIndexStats, f as codebaseIndexTool, g as codebaseSearchTool, h as codebaseStatsTool, i as enqueueReindex, j as getIndexState, k as indexCircuitBreaker, l as isIndexReady, m as isIndexableFile, n as isIndexing, o as onIndexStateChange, r as resetIndexCircuitBreaker, p as runStartupIndex, s as searchCodebaseIndex, q as shutdownCodebaseIndexHost } from '../background-indexer-DwJsyAB0.js';
1
+ import { t as IndexResult, S as Symbol, F as FileMeta, u as SymbolKind, v as SymbolLang, w as SearchResult, x as IndexStats, R as Ref } from '../background-indexer-CJ5JiV5i.js';
2
+ export { C as CircuitOpenError, a as CircuitSnapshot, b as CircuitState, y as FileSymbols, I as IndexCircuitBreaker, c as IndexTimeoutError, z as SCHEMA_VERSION, d as cancelPendingReindexes, e as codebaseIndexStats, f as codebaseIndexTool, g as codebaseSearchTool, h as codebaseStatsTool, i as enqueueReindex, j as getIndexState, k as indexCircuitBreaker, l as isIndexReady, m as isIndexableFile, n as isIndexing, o as onIndexStateChange, r as resetIndexCircuitBreaker, p as runStartupIndex, s as searchCodebaseIndex, q as shutdownCodebaseIndexHost } from '../background-indexer-CJ5JiV5i.js';
3
3
  import { Context } from '@wrongstack/core';
4
4
 
5
5
  interface IndexerOptions {
@@ -2524,6 +2524,13 @@ function debounceKey(indexDir, file) {
2524
2524
  function isIndexableFile(filePath) {
2525
2525
  return detectLang(filePath) !== null;
2526
2526
  }
2527
+ function isUniqueConstraintError(err) {
2528
+ if (err instanceof Error) {
2529
+ const msg = err.message.toLowerCase();
2530
+ return msg.includes("unique constraint") || msg.includes("UNIQUE constraint");
2531
+ }
2532
+ return false;
2533
+ }
2527
2534
  async function runStartupIndex(opts) {
2528
2535
  if (!indexCircuitBreaker.allowRequest()) throw circuitOpenError();
2529
2536
  _indexing = true;
@@ -2553,6 +2560,15 @@ async function runStartupIndex(opts) {
2553
2560
  return result;
2554
2561
  } catch (err) {
2555
2562
  _lastError = err instanceof Error ? err.message : String(err);
2563
+ if (isUniqueConstraintError(err) && !opts.force) {
2564
+ _lastError = null;
2565
+ const rebuildResult = await runStartupIndex({
2566
+ ...opts,
2567
+ force: true
2568
+ });
2569
+ _ready = true;
2570
+ return rebuildResult;
2571
+ }
2556
2572
  _ready = true;
2557
2573
  if (!opts.signal?.aborted) indexCircuitBreaker.recordFailure(err);
2558
2574
  throw err;