@wrongstack/tools 0.236.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.
Files changed (47) hide show
  1. package/dist/audit.js +591 -48
  2. package/dist/audit.js.map +1 -1
  3. package/dist/background-indexer-CJ5JiV5i.d.ts +365 -0
  4. package/dist/bash.js +135 -20
  5. package/dist/bash.js.map +1 -1
  6. package/dist/builtin.js +1840 -1109
  7. package/dist/builtin.js.map +1 -1
  8. package/dist/codebase-index/index.d.ts +53 -2
  9. package/dist/codebase-index/index.js +870 -364
  10. package/dist/codebase-index/index.js.map +1 -1
  11. package/dist/codebase-index/worker.d.ts +2 -0
  12. package/dist/codebase-index/worker.js +2326 -0
  13. package/dist/codebase-index/worker.js.map +1 -0
  14. package/dist/diff.js +2 -1
  15. package/dist/diff.js.map +1 -1
  16. package/dist/exec.js +116 -5
  17. package/dist/exec.js.map +1 -1
  18. package/dist/format.js +591 -48
  19. package/dist/format.js.map +1 -1
  20. package/dist/git.js +2 -1
  21. package/dist/git.js.map +1 -1
  22. package/dist/grep.js +2 -2
  23. package/dist/grep.js.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +1189 -496
  26. package/dist/index.js.map +1 -1
  27. package/dist/install.js +591 -48
  28. package/dist/install.js.map +1 -1
  29. package/dist/lint.js +590 -47
  30. package/dist/lint.js.map +1 -1
  31. package/dist/logs.js +1 -1
  32. package/dist/logs.js.map +1 -1
  33. package/dist/outdated.js +1 -1
  34. package/dist/outdated.js.map +1 -1
  35. package/dist/pack.js +1840 -1109
  36. package/dist/pack.js.map +1 -1
  37. package/dist/patch.js +1 -1
  38. package/dist/patch.js.map +1 -1
  39. package/dist/replace.js +3 -2
  40. package/dist/replace.js.map +1 -1
  41. package/dist/test.d.ts +1 -0
  42. package/dist/test.js +605 -55
  43. package/dist/test.js.map +1 -1
  44. package/dist/typecheck.js +591 -48
  45. package/dist/typecheck.js.map +1 -1
  46. package/package.json +3 -3
  47. package/dist/background-indexer-CtbgPExj.d.ts +0 -228
@@ -1,5 +1,5 @@
1
- import { I as IndexResult, S as Symbol, F as FileMeta, a as SymbolKind, b as SymbolLang, c as SearchResult, d as IndexStats, R as Ref } from '../background-indexer-CtbgPExj.js';
2
- export { e as FileSymbols, f as SCHEMA_VERSION, g as cancelPendingReindexes, h as codebaseIndexTool, i as codebaseSearchTool, j as codebaseStatsTool, k as enqueueReindex, l as getIndexState, m as isIndexReady, n as isIndexableFile, o as isIndexing, p as onIndexStateChange, r as runStartupIndex } from '../background-indexer-CtbgPExj.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 {
@@ -17,6 +17,12 @@ interface IndexerOptions {
17
17
  * and `runIndexer` throws, releasing the mutex and resetting flags.
18
18
  */
19
19
  signal?: AbortSignal | undefined;
20
+ /**
21
+ * Per-file progress callback. Injected by the caller instead of imported
22
+ * from the host's module state so the indexer can run inside a worker
23
+ * thread (worker posts progress messages; inline host updates its state).
24
+ */
25
+ onProgress?: ((current: number, total: number) => void) | undefined;
20
26
  }
21
27
  /** Run a full or incremental index and return statistics. */
22
28
  declare function runIndexer(_ctx: Context, opts: IndexerOptions): Promise<IndexResult>;
@@ -41,12 +47,36 @@ declare class IndexStore {
41
47
  private db;
42
48
  /** Absolute path to this project's index directory. */
43
49
  private readonly indexDir;
50
+ /**
51
+ * True when the SQLite build provides FTS5 (Node's bundled SQLite does).
52
+ * When false, ranked search falls back to the LIKE + in-process BM25 path.
53
+ */
54
+ private ftsAvailable;
55
+ /**
56
+ * Execute a SQLite write operation with automatic retry on lock conflicts.
57
+ *
58
+ * When another wstack process is holding the write lock the statement first
59
+ * waits up to `busy_timeout` ms, then throws SQLITE_BUSY. This wrapper catches
60
+ * that error and retries (up to MAX_LOCK_RETRIES) with exponential backoff,
61
+ * giving the competing writer time to finish and release the lock.
62
+ *
63
+ * @param fn The write operation to execute. Can return a value which is
64
+ * returned to the caller on success.
65
+ * @throws {@link LockError} when all retries are exhausted on a lock conflict
66
+ * (non-lock errors always propagate on the first attempt).
67
+ */
68
+ runWithRetry<T>(fn: () => T): T;
44
69
  constructor(projectRoot: string, opts?: {
45
70
  indexDir?: string | undefined;
46
71
  });
47
72
  private initSchema;
48
73
  insertSymbols(symbols: Symbol[], nextId: number): number;
49
74
  deleteSymbolsForFile(file: string): void;
75
+ /**
76
+ * Remove every trace of a file (refs, symbols, FTS rows, file meta). Used
77
+ * when a source file disappears between index runs — previously this only
78
+ * dropped the `files` row, leaving its symbols orphaned but still searchable.
79
+ */
50
80
  deleteFile(file: string): void;
51
81
  upsertFile(meta: FileMeta): void;
52
82
  getFileMeta(file: string): FileMeta | null;
@@ -57,6 +87,27 @@ declare class IndexStore {
57
87
  file?: string | undefined;
58
88
  lspKind?: number | undefined;
59
89
  }): SearchResult[];
90
+ /**
91
+ * Ranked search — the one-stop query the codebase-search tool and plug-lsp
92
+ * use. With FTS5 this is a single indexed `MATCH` ranked by SQLite's native
93
+ * `bm25()` with a built-in `snippet()`; without FTS5 it falls back to the
94
+ * legacy LIKE scan + in-process BM25 (identical semantics, slower).
95
+ *
96
+ * Tokens are matched as prefixes (`"tok"*`), mirroring the old
97
+ * `LIKE '%tok%'` recall for the common symbol-search shapes ("user" finds
98
+ * "users", camelCase-split text makes "complex" find "complexOperation").
99
+ */
100
+ searchRanked(query: string, filter: {
101
+ kind?: SymbolKind | undefined;
102
+ lang?: SymbolLang | undefined;
103
+ file?: string | undefined;
104
+ lspKind?: number | undefined;
105
+ } | undefined, limit: number): {
106
+ results: SearchResult[];
107
+ total: number;
108
+ };
109
+ /** Legacy ranked path: LIKE candidates + in-process BM25 + JS snippets. */
110
+ private searchRankedFallback;
60
111
  getAllIndexable(): Array<{
61
112
  id: number;
62
113
  text: string;