@wrongstack/tools 0.284.0 → 0.285.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.
- package/dist/_concurrency.d.ts +16 -0
- package/dist/_concurrency.d.ts.map +1 -0
- package/dist/_danger-detect.d.ts +54 -0
- package/dist/_danger-detect.d.ts.map +1 -0
- package/dist/_edit-match.d.ts +86 -0
- package/dist/_edit-match.d.ts.map +1 -0
- package/dist/_env.d.ts +6 -0
- package/dist/_env.d.ts.map +1 -0
- package/dist/_fetch-guard.d.ts +31 -0
- package/dist/_fetch-guard.d.ts.map +1 -0
- package/dist/_output-spool.d.ts +38 -0
- package/dist/_output-spool.d.ts.map +1 -0
- package/dist/_redact-command.d.ts +6 -0
- package/dist/_redact-command.d.ts.map +1 -0
- package/dist/_regex.d.ts +39 -0
- package/dist/_regex.d.ts.map +1 -0
- package/dist/_session-shell.d.ts +73 -0
- package/dist/_session-shell.d.ts.map +1 -0
- package/dist/_shell-pick.d.ts +158 -0
- package/dist/_shell-pick.d.ts.map +1 -0
- package/dist/_spawn-stream.d.ts +32 -0
- package/dist/_spawn-stream.d.ts.map +1 -0
- package/dist/_syntax-check.d.ts +16 -0
- package/dist/_syntax-check.d.ts.map +1 -0
- package/dist/_util.d.ts +68 -0
- package/dist/_util.d.ts.map +1 -0
- package/dist/_win32-resolve.d.ts +42 -0
- package/dist/_win32-resolve.d.ts.map +1 -0
- package/dist/audit.d.ts +4 -5
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +2743 -28
- package/dist/audit.js.map +7 -1
- package/dist/bash-kill-guard.d.ts +62 -0
- package/dist/bash-kill-guard.d.ts.map +1 -0
- package/dist/bash.d.ts +4 -5
- package/dist/bash.d.ts.map +1 -0
- package/dist/bash.js +59 -30
- package/dist/bash.js.map +7 -1
- package/dist/batch-tool-use.d.ts +4 -5
- package/dist/batch-tool-use.d.ts.map +1 -0
- package/dist/batch-tool-use.js +3 -3
- package/dist/batch-tool-use.js.map +7 -1
- package/dist/builtin.d.ts +7 -9
- package/dist/builtin.d.ts.map +1 -0
- package/dist/builtin.js +5282 -1019
- package/dist/builtin.js.map +7 -1
- package/dist/circuit-breaker.d.ts +4 -5
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +3 -3
- package/dist/circuit-breaker.js.map +7 -1
- package/dist/codebase-index/background-indexer.d.ts +116 -0
- package/dist/codebase-index/background-indexer.d.ts.map +1 -0
- package/dist/codebase-index/bm25.d.ts +40 -0
- package/dist/codebase-index/bm25.d.ts.map +1 -0
- package/dist/codebase-index/circuit-breaker.d.ts +94 -0
- package/dist/codebase-index/circuit-breaker.d.ts.map +1 -0
- package/dist/codebase-index/codebase-index-tool.d.ts +17 -0
- package/dist/codebase-index/codebase-index-tool.d.ts.map +1 -0
- package/dist/codebase-index/codebase-search-tool.d.ts +43 -0
- package/dist/codebase-index/codebase-search-tool.d.ts.map +1 -0
- package/dist/codebase-index/codebase-stats-tool.d.ts +23 -0
- package/dist/codebase-index/codebase-stats-tool.d.ts.map +1 -0
- package/dist/codebase-index/gitignore.d.ts +22 -0
- package/dist/codebase-index/gitignore.d.ts.map +1 -0
- package/dist/codebase-index/go-parser.d.ts +16 -0
- package/dist/codebase-index/go-parser.d.ts.map +1 -0
- package/dist/codebase-index/index-service.d.ts +25 -0
- package/dist/codebase-index/index-service.d.ts.map +1 -0
- package/dist/codebase-index/index.d.ts +23 -271
- package/dist/codebase-index/index.d.ts.map +1 -0
- package/dist/codebase-index/index.js +136 -68
- package/dist/codebase-index/index.js.map +7 -1
- package/dist/codebase-index/indexer.d.ts +28 -0
- package/dist/codebase-index/indexer.d.ts.map +1 -0
- package/dist/codebase-index/json-parser.d.ts +8 -0
- package/dist/codebase-index/json-parser.d.ts.map +1 -0
- package/dist/codebase-index/lsp-kind.d.ts +53 -0
- package/dist/codebase-index/lsp-kind.d.ts.map +1 -0
- package/dist/codebase-index/py-parser.d.ts +16 -0
- package/dist/codebase-index/py-parser.d.ts.map +1 -0
- package/dist/codebase-index/refs-extractor.d.ts +25 -0
- package/dist/codebase-index/refs-extractor.d.ts.map +1 -0
- package/dist/codebase-index/rs-parser.d.ts +8 -0
- package/dist/codebase-index/rs-parser.d.ts.map +1 -0
- package/dist/codebase-index/schema.d.ts +82 -0
- package/dist/codebase-index/schema.d.ts.map +1 -0
- package/dist/codebase-index/ts-parser.d.ts +30 -0
- package/dist/codebase-index/ts-parser.d.ts.map +1 -0
- package/dist/codebase-index/worker-protocol.d.ts +77 -0
- package/dist/codebase-index/worker-protocol.d.ts.map +1 -0
- package/dist/codebase-index/worker.d.ts +16 -2
- package/dist/codebase-index/worker.d.ts.map +1 -0
- package/dist/codebase-index/worker.js +103 -65
- package/dist/codebase-index/worker.js.map +7 -1
- package/dist/codebase-index/writer.d.ts +189 -0
- package/dist/codebase-index/writer.d.ts.map +1 -0
- package/dist/codebase-index/yaml-parser.d.ts +8 -0
- package/dist/codebase-index/yaml-parser.d.ts.map +1 -0
- package/dist/design.d.ts +38 -0
- package/dist/design.d.ts.map +1 -0
- package/dist/design.js +270 -0
- package/dist/design.js.map +7 -0
- package/dist/diff.d.ts +4 -5
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +14 -12
- package/dist/diff.js.map +7 -1
- package/dist/document.d.ts +4 -5
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +8 -7
- package/dist/document.js.map +7 -1
- package/dist/edit.d.ts +5 -36
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +28 -16
- package/dist/edit.js.map +7 -1
- package/dist/exec.d.ts +67 -2
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +50 -25
- package/dist/exec.js.map +7 -1
- package/dist/fetch.d.ts +4 -32
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +89 -77
- package/dist/fetch.js.map +7 -1
- package/dist/format.d.ts +4 -5
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +2415 -28
- package/dist/format.js.map +7 -1
- package/dist/git.d.ts +4 -5
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +10 -9
- package/dist/git.js.map +7 -1
- package/dist/glob.d.ts +4 -5
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +15 -12
- package/dist/glob.js.map +7 -1
- package/dist/grep.d.ts +4 -5
- package/dist/grep.d.ts.map +1 -0
- package/dist/grep.js +13 -10
- package/dist/grep.js.map +7 -1
- package/dist/index.d.ts +19 -724
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6088 -1690
- package/dist/index.js.map +7 -1
- package/dist/install.d.ts +4 -5
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +2680 -31
- package/dist/install.js.map +7 -1
- package/dist/json.d.ts +4 -5
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +13 -11
- package/dist/json.js.map +7 -1
- package/dist/kanban.d.ts +107 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.js +845 -0
- package/dist/kanban.js.map +7 -0
- package/dist/languages/detect.d.ts +3 -0
- package/dist/languages/detect.d.ts.map +1 -0
- package/dist/languages/diagnostics.d.ts +15 -0
- package/dist/languages/diagnostics.d.ts.map +1 -0
- package/dist/languages/execute-tool.d.ts +34 -0
- package/dist/languages/execute-tool.d.ts.map +1 -0
- package/dist/languages/execute.d.ts +18 -0
- package/dist/languages/execute.d.ts.map +1 -0
- package/dist/languages/index.d.ts +12 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +4457 -0
- package/dist/languages/index.js.map +7 -0
- package/dist/languages/legacy-bridge.d.ts +29 -0
- package/dist/languages/legacy-bridge.d.ts.map +1 -0
- package/dist/languages/package-tool.d.ts +29 -0
- package/dist/languages/package-tool.d.ts.map +1 -0
- package/dist/languages/plan.d.ts +4 -0
- package/dist/languages/plan.d.ts.map +1 -0
- package/dist/languages/profile-helpers.d.ts +14 -0
- package/dist/languages/profile-helpers.d.ts.map +1 -0
- package/dist/languages/profiles/additional.d.ts +3 -0
- package/dist/languages/profiles/additional.d.ts.map +1 -0
- package/dist/languages/profiles/primary.d.ts +3 -0
- package/dist/languages/profiles/primary.d.ts.map +1 -0
- package/dist/languages/registry.d.ts +11 -0
- package/dist/languages/registry.d.ts.map +1 -0
- package/dist/languages/tool.d.ts +32 -0
- package/dist/languages/tool.d.ts.map +1 -0
- package/dist/languages/types.d.ts +207 -0
- package/dist/languages/types.d.ts.map +1 -0
- package/dist/lint.d.ts +4 -5
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +2415 -27
- package/dist/lint.js.map +7 -1
- package/dist/logs.d.ts +4 -5
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +16 -10
- package/dist/logs.js.map +7 -1
- package/dist/memory.d.ts +7 -8
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +7 -5
- package/dist/memory.js.map +7 -1
- package/dist/mode.d.ts +4 -5
- package/dist/mode.d.ts.map +1 -0
- package/dist/mode.js +3 -3
- package/dist/mode.js.map +7 -1
- package/dist/next-steps.d.ts +5 -6
- package/dist/next-steps.d.ts.map +1 -0
- package/dist/next-steps.js +5 -4
- package/dist/next-steps.js.map +7 -1
- package/dist/outdated.d.ts +4 -5
- package/dist/outdated.d.ts.map +1 -0
- package/dist/outdated.js +4777 -68
- package/dist/outdated.js.map +7 -1
- package/dist/pack.d.ts +3 -6
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +5275 -1019
- package/dist/pack.js.map +7 -1
- package/dist/patch.d.ts +4 -5
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +18 -16
- package/dist/patch.js.map +7 -1
- package/dist/plan.d.ts +55 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +280 -0
- package/dist/plan.js.map +7 -0
- package/dist/process-guardian.d.ts +100 -0
- package/dist/process-guardian.d.ts.map +1 -0
- package/dist/process-registry-persistent.d.ts +121 -0
- package/dist/process-registry-persistent.d.ts.map +1 -0
- package/dist/process-registry.d.ts +13 -17
- package/dist/process-registry.d.ts.map +1 -0
- package/dist/process-registry.js +15 -9
- package/dist/process-registry.js.map +7 -1
- package/dist/ps-slash.d.ts +106 -0
- package/dist/ps-slash.d.ts.map +1 -0
- package/dist/ps-slash.js +1291 -0
- package/dist/ps-slash.js.map +7 -0
- package/dist/read.d.ts +4 -5
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +13 -11
- package/dist/read.js.map +7 -1
- package/dist/replace.d.ts +4 -5
- package/dist/replace.d.ts.map +1 -0
- package/dist/replace.js +26 -13
- package/dist/replace.js.map +7 -1
- package/dist/scaffold.d.ts +4 -5
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +16 -14
- package/dist/scaffold.js.map +7 -1
- package/dist/search.d.ts +5 -6
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +24 -25
- package/dist/search.js.map +7 -1
- package/dist/set-working-dir.d.ts +18 -0
- package/dist/set-working-dir.d.ts.map +1 -0
- package/dist/shim/node-sqlite.d.ts +3 -0
- package/dist/shim/node-sqlite.d.ts.map +1 -0
- package/dist/skill.d.ts +45 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +175 -0
- package/dist/skill.js.map +7 -0
- package/dist/spawn-background.d.ts +80 -0
- package/dist/spawn-background.d.ts.map +1 -0
- package/dist/task.d.ts +35 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +380 -0
- package/dist/task.js.map +7 -0
- package/dist/test.d.ts +4 -5
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +2419 -27
- package/dist/test.js.map +7 -1
- package/dist/todo.d.ts +4 -5
- package/dist/todo.d.ts.map +1 -0
- package/dist/todo.js +5 -5
- package/dist/todo.js.map +7 -1
- package/dist/tool-diff.d.ts +16 -17
- package/dist/tool-diff.d.ts.map +1 -0
- package/dist/tool-diff.js +11 -3
- package/dist/tool-diff.js.map +7 -1
- package/dist/tool-help.d.ts +4 -5
- package/dist/tool-help.d.ts.map +1 -0
- package/dist/tool-help.js +3 -3
- package/dist/tool-help.js.map +7 -1
- package/dist/tool-icon-map.d.ts +45 -0
- package/dist/tool-icon-map.d.ts.map +1 -0
- package/dist/tool-icons.d.ts +5 -6
- package/dist/tool-icons.d.ts.map +1 -0
- package/dist/tool-icons.js +16 -4
- package/dist/tool-icons.js.map +7 -1
- package/dist/tool-search.d.ts +4 -5
- package/dist/tool-search.d.ts.map +1 -0
- package/dist/tool-search.js +3 -3
- package/dist/tool-search.js.map +7 -1
- package/dist/tool-summary.d.ts +4 -5
- package/dist/tool-summary.d.ts.map +1 -0
- package/dist/tool-summary.js +5 -3
- package/dist/tool-summary.js.map +7 -1
- package/dist/tool-use.d.ts +4 -5
- package/dist/tool-use.d.ts.map +1 -0
- package/dist/tool-use.js +3 -3
- package/dist/tool-use.js.map +7 -1
- package/dist/tree.d.ts +4 -5
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +11 -9
- package/dist/tree.js.map +7 -1
- package/dist/typecheck.d.ts +4 -5
- package/dist/typecheck.d.ts.map +1 -0
- package/dist/typecheck.js +2416 -28
- package/dist/typecheck.js.map +7 -1
- package/dist/write.d.ts +4 -5
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +21 -16
- package/dist/write.js.map +7 -1
- package/package.json +34 -6
- package/dist/background-indexer-BeDBxfSh.d.ts +0 -371
- package/dist/exec-2OKoT6tk.d.ts +0 -121
|
@@ -1,275 +1,27 @@
|
|
|
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-BeDBxfSh.js';
|
|
2
|
-
export { C as CircuitOpenError, e as CircuitSnapshot, f as CircuitState, g as FileSymbols, h as IndexCircuitBreaker, i as IndexTimeoutError, j as SCHEMA_VERSION, k as cancelPendingReindexes, l as codebaseIndexStats, m as codebaseIndexTool, n as codebaseSearchTool, o as codebaseStatsTool, p as enqueueReindex, q as getIndexState, r as indexCircuitBreaker, s as isIndexReady, t as isIndexableFile, u as isIndexing, v as onIndexStateChange, w as resetIndexCircuitBreaker, x as runStartupIndex, y as searchCodebaseIndex, z as shutdownCodebaseIndexHost } from '../background-indexer-BeDBxfSh.js';
|
|
3
|
-
import { Context } from '@wrongstack/core';
|
|
4
|
-
|
|
5
|
-
interface IndexerOptions {
|
|
6
|
-
projectRoot: string;
|
|
7
|
-
files?: string[] | undefined;
|
|
8
|
-
force?: boolean | undefined;
|
|
9
|
-
langs?: string[] | undefined;
|
|
10
|
-
ignore?: string[] | undefined;
|
|
11
|
-
/** Override the index directory (default: the global per-project dir). */
|
|
12
|
-
indexDir?: string | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Signal that cancels indexing cooperatively. Polled at yield points
|
|
15
|
-
* (file walk, per-file loop) so a hung filesystem won't lock up the
|
|
16
|
-
* process. When the tool executor's timeout fires, this signal aborts
|
|
17
|
-
* and `runIndexer` throws, releasing the mutex and resetting flags.
|
|
18
|
-
*/
|
|
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;
|
|
26
|
-
}
|
|
27
|
-
/** Run a full or incremental index and return statistics. */
|
|
28
|
-
declare function runIndexer(_ctx: Context, opts: IndexerOptions): Promise<IndexResult>;
|
|
29
|
-
|
|
30
1
|
/**
|
|
31
|
-
*
|
|
32
|
-
* global project dir (`~/.wrongstack/projects/<hash>/codebase-index`),
|
|
33
|
-
* matching every other piece of per-project state. Callers may pass an
|
|
34
|
-
* explicit `override` (used by tests and any wiring that already resolved the
|
|
35
|
-
* path) to avoid touching the real home directory.
|
|
36
|
-
*/
|
|
37
|
-
declare function resolveIndexDir(projectRoot: string, override?: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Optional index-directory override carried on the run context's `meta` bag.
|
|
40
|
-
* Production leaves it unset (the index resolves to the global per-project
|
|
41
|
-
* dir); tests and bespoke wiring set `meta.codebaseIndexDir` to redirect it.
|
|
42
|
-
*/
|
|
43
|
-
declare function codebaseIndexDirOverride(ctx: {
|
|
44
|
-
meta?: Record<string, unknown>;
|
|
45
|
-
}): string | undefined;
|
|
46
|
-
declare class IndexStore {
|
|
47
|
-
private db;
|
|
48
|
-
/** Absolute path to this project's index directory. */
|
|
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
|
-
* Cache of prepared statements keyed by their SQL text. `DatabaseSync`
|
|
57
|
-
* compiles SQL on every `.prepare()` call; for the fixed-SQL methods
|
|
58
|
-
* (upsertFile, getFileMeta, deleteFile, insertRefs, …) that runs thousands
|
|
59
|
-
* of times during a full reindex. `StatementSync` objects are reusable
|
|
60
|
-
* across calls on the same connection, so we compile each distinct SQL once
|
|
61
|
-
* and reuse it. Cleared in {@link close} when the connection is torn down.
|
|
62
|
-
*/
|
|
63
|
-
private readonly stmtCache;
|
|
64
|
-
/** Prepare-once helper: compile `sql` on first use, reuse thereafter. */
|
|
65
|
-
private stmt;
|
|
66
|
-
/**
|
|
67
|
-
* Execute a SQLite write operation with automatic retry on lock conflicts.
|
|
68
|
-
*
|
|
69
|
-
* When another wstack process is holding the write lock the statement first
|
|
70
|
-
* waits up to `busy_timeout` ms, then throws SQLITE_BUSY. This wrapper catches
|
|
71
|
-
* that error and retries (up to MAX_LOCK_RETRIES) with exponential backoff,
|
|
72
|
-
* giving the competing writer time to finish and release the lock.
|
|
73
|
-
*
|
|
74
|
-
* @param fn The write operation to execute. Can return a value which is
|
|
75
|
-
* returned to the caller on success.
|
|
76
|
-
* @throws {@link LockError} when all retries are exhausted on a lock conflict
|
|
77
|
-
* (non-lock errors always propagate on the first attempt).
|
|
78
|
-
*/
|
|
79
|
-
runWithRetry<T>(fn: () => T): T;
|
|
80
|
-
constructor(projectRoot: string, opts?: {
|
|
81
|
-
indexDir?: string | undefined;
|
|
82
|
-
});
|
|
83
|
-
private initSchema;
|
|
84
|
-
/**
|
|
85
|
-
* Insert symbols, assigning IDs atomically inside `BEGIN IMMEDIATE` /
|
|
86
|
-
* `COMMIT`. The ID allocation (`SELECT MAX(id)`) and all `INSERT`s share
|
|
87
|
-
* the same transaction, preventing UNIQUE constraint violations when two
|
|
88
|
-
* processes index concurrently (each would see a different `MAX(id)` and
|
|
89
|
-
* neither can insert with the other's IDs).
|
|
90
|
-
*
|
|
91
|
-
* @returns The symbols array with `id` fields populated so the caller can
|
|
92
|
-
* use them for refs without re-reading from the DB.
|
|
93
|
-
*/
|
|
94
|
-
insertSymbols(symbols: Symbol[]): Symbol[];
|
|
95
|
-
deleteSymbolsForFile(file: string): void;
|
|
96
|
-
/**
|
|
97
|
-
* Remove every trace of a file (refs, symbols, FTS rows, file meta). Used
|
|
98
|
-
* when a source file disappears between index runs — previously this only
|
|
99
|
-
* dropped the `files` row, leaving its symbols orphaned but still searchable.
|
|
100
|
-
*/
|
|
101
|
-
deleteFile(file: string): void;
|
|
102
|
-
upsertFile(meta: FileMeta): void;
|
|
103
|
-
getFileMeta(file: string): FileMeta | null;
|
|
104
|
-
getAllFileMetas(): FileMeta[];
|
|
105
|
-
search(query: string, filter?: {
|
|
106
|
-
kind?: SymbolKind | undefined;
|
|
107
|
-
lang?: SymbolLang | undefined;
|
|
108
|
-
file?: string | undefined;
|
|
109
|
-
lspKind?: number | undefined;
|
|
110
|
-
}): SearchResult[];
|
|
111
|
-
/**
|
|
112
|
-
* Ranked search — the one-stop query the codebase-search tool and plug-lsp
|
|
113
|
-
* use. With FTS5 this is a single indexed `MATCH` ranked by SQLite's native
|
|
114
|
-
* `bm25()` with a built-in `snippet()`; without FTS5 it falls back to the
|
|
115
|
-
* legacy LIKE scan + in-process BM25 (identical semantics, slower).
|
|
116
|
-
*
|
|
117
|
-
* Tokens are matched as prefixes (`"tok"*`), mirroring the old
|
|
118
|
-
* `LIKE '%tok%'` recall for the common symbol-search shapes ("user" finds
|
|
119
|
-
* "users", camelCase-split text makes "complex" find "complexOperation").
|
|
120
|
-
*/
|
|
121
|
-
searchRanked(query: string, filter: {
|
|
122
|
-
kind?: SymbolKind | undefined;
|
|
123
|
-
lang?: SymbolLang | undefined;
|
|
124
|
-
file?: string | undefined;
|
|
125
|
-
lspKind?: number | undefined;
|
|
126
|
-
} | undefined, limit: number): {
|
|
127
|
-
results: SearchResult[];
|
|
128
|
-
total: number;
|
|
129
|
-
};
|
|
130
|
-
/** Legacy ranked path: LIKE candidates + in-process BM25 + JS snippets. */
|
|
131
|
-
private searchRankedFallback;
|
|
132
|
-
getAllIndexable(): Array<{
|
|
133
|
-
id: number;
|
|
134
|
-
text: string;
|
|
135
|
-
}>;
|
|
136
|
-
/**
|
|
137
|
-
* Largest symbol id currently in the table (0 when empty). New ids must be
|
|
138
|
-
* allocated from this, NOT from `COUNT(*)`: incremental reindexes delete a
|
|
139
|
-
* changed file's rows, so the row count drops below the max id and a
|
|
140
|
-
* count-based id would collide with a surviving row (UNIQUE constraint on
|
|
141
|
-
* `symbols.id`). Ids may have gaps — that is fine.
|
|
142
|
-
*/
|
|
143
|
-
getMaxSymbolId(): number;
|
|
144
|
-
getStats(): IndexStats;
|
|
145
|
-
setLastIndexed(ts: number): void;
|
|
146
|
-
clearAll(): void;
|
|
147
|
-
/**
|
|
148
|
-
* Insert cross-references for a given source symbol id.
|
|
149
|
-
* Replaces any existing refs from the same source (idempotent on re-index).
|
|
150
|
-
*/
|
|
151
|
-
insertRefs(fromId: number, refs: Ref[]): void;
|
|
152
|
-
/**
|
|
153
|
-
* Bulk-insert refs for many source symbols in a single transaction.
|
|
154
|
-
*
|
|
155
|
-
* Unlike {@link insertRefs} this does NOT delete per source id — the caller
|
|
156
|
-
* (the indexer) has already cleared stale refs for the file via
|
|
157
|
-
* {@link deleteRefsForFile}, so the per-source DELETE would be redundant work
|
|
158
|
-
* repeated once per symbol. One transaction for the whole file instead of one
|
|
159
|
-
* per symbol turns an O(symbols) transaction count into O(1).
|
|
160
|
-
*
|
|
161
|
-
* Each ref's own {@link Ref.fromId} is used; pass an empty array to no-op.
|
|
162
|
-
*/
|
|
163
|
-
insertRefsBatch(refs: Ref[]): void;
|
|
164
|
-
/**
|
|
165
|
-
* Commit a batch of file-level symbol/refs/upserts in a single transaction.
|
|
166
|
-
*
|
|
167
|
-
* Used by the indexer to amortize SQLite commit overhead across many files.
|
|
168
|
-
* Before this, the indexer issued one transaction per file (BEGIN IMMEDIATE
|
|
169
|
-
* for symbols, plus per-file deletes and an upsertFile call), so a 20-file
|
|
170
|
-
* parallel batch cost ~5+ transactions × 20 files = 100+ commits. With
|
|
171
|
-
* this entry point we do exactly one BEGIN/COMMIT per parallel batch.
|
|
172
|
-
*
|
|
173
|
-
* Each entry must already be a fully-parsed FileSymbols (symbols + refs).
|
|
174
|
-
* The caller is responsible for the per-file prefix accounting
|
|
175
|
-
* (refsByLine → flat list with `fromId` populated). `deleteForFiles` lets
|
|
176
|
-
* the caller clear stale symbols/refs for any files being re-indexed before
|
|
177
|
-
* the inserts run (required to keep refs → symbols FK invariants).
|
|
178
|
-
*
|
|
179
|
-
* Returns the symbols back with their assigned `id` (same shape as
|
|
180
|
-
* {@link insertSymbols}) so callers can build final per-file results.
|
|
181
|
-
*/
|
|
182
|
-
commitBatch(entries: Array<{
|
|
183
|
-
file: string;
|
|
184
|
-
lang: SymbolLang;
|
|
185
|
-
symbols: Symbol[];
|
|
186
|
-
refs: Ref[];
|
|
187
|
-
mtimeMs: number;
|
|
188
|
-
symbolCount: number;
|
|
189
|
-
}>, options?: {
|
|
190
|
-
deleteForFiles?: string[] | undefined;
|
|
191
|
-
}): Symbol[];
|
|
192
|
-
/**
|
|
193
|
-
* Delete all refs whose source symbols are in a given file.
|
|
194
|
-
* Used when re-indexing a file to clear stale refs.
|
|
195
|
-
*/
|
|
196
|
-
deleteRefsForFile(file: string): void;
|
|
197
|
-
/**
|
|
198
|
-
* Resolve `to_name` → `to_id` for all refs that have a name but no id.
|
|
199
|
-
* Call this after all symbols have been inserted to fill in cross-references.
|
|
200
|
-
*
|
|
201
|
-
* Single statement: the `to_name IN (SELECT name FROM symbols)` guard restricts
|
|
202
|
-
* the UPDATE to refs that will actually resolve, so `.changes` counts only refs
|
|
203
|
-
* that found a target — matching the previous per-row loop's return value.
|
|
204
|
-
*/
|
|
205
|
-
resolveRefs(): number;
|
|
206
|
-
/**
|
|
207
|
-
* Find all references TO a given symbol (who calls / uses this symbol?).
|
|
208
|
-
*/
|
|
209
|
-
findRefsTo(symbolId: number): Ref[];
|
|
210
|
-
/**
|
|
211
|
-
* Find all references FROM a given symbol (what does this symbol call/use?).
|
|
212
|
-
*/
|
|
213
|
-
findRefsFrom(symbolId: number): Ref[];
|
|
214
|
-
private sizeBytes;
|
|
215
|
-
close(): void;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* BM25 ranking implementation — no external dependencies.
|
|
2
|
+
* @wrongstack/tools – Codebase Index
|
|
220
3
|
*
|
|
221
|
-
*
|
|
222
|
-
*/
|
|
223
|
-
interface Bm25Doc {
|
|
224
|
-
id: number;
|
|
225
|
-
tokens: string[];
|
|
226
|
-
raw: string;
|
|
227
|
-
len: number;
|
|
228
|
-
}
|
|
229
|
-
/** Tokenise a string into lowercase word tokens. */
|
|
230
|
-
declare function tokenise(text: string): string[];
|
|
231
|
-
interface IndexableDoc {
|
|
232
|
-
id: number;
|
|
233
|
-
text: string;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Build indexable text for BM25 from a symbol's fields.
|
|
237
|
-
* The name is split into camelCase/SnakeCase words so that queries
|
|
238
|
-
* like "complex" match "complexOperation". The verbatim name is
|
|
239
|
-
* also included for exact-match queries.
|
|
240
|
-
*/
|
|
241
|
-
declare function buildIndexableText(name: string, signature: string, docComment: string): string;
|
|
242
|
-
declare function buildBm25Index(docs: IndexableDoc[]): Bm25Index;
|
|
243
|
-
declare class Bm25Index {
|
|
244
|
-
private documents;
|
|
245
|
-
private df;
|
|
246
|
-
private N;
|
|
247
|
-
private readonly safeAvgLen;
|
|
248
|
-
constructor(documents: Bm25Doc[], df: Record<string, number>, N: number, avgLen: number);
|
|
249
|
-
score(query: string, filter?: (id: number) => boolean): Array<{
|
|
250
|
-
id: number;
|
|
251
|
-
score: number;
|
|
252
|
-
}>;
|
|
253
|
-
getDoc(id: number): Bm25Doc | undefined;
|
|
254
|
-
extractSnippet(docId: number, queryTokens: string[], radius?: number): string;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* LSP SymbolKind mapping utilities.
|
|
4
|
+
* Three tools for building and querying a symbol index:
|
|
259
5
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
|
|
268
|
-
declare function lspKindToInternalKind(k: number): SymbolKind | null;
|
|
269
|
-
/**
|
|
270
|
-
* Maps an internal SymbolKind to the corresponding LSP kind number.
|
|
271
|
-
* Returns null if the internal kind has no equivalent LSP kind.
|
|
6
|
+
* `codebase-index` — run the indexer (full or incremental)
|
|
7
|
+
* `codebase-search` — BM25-ranked symbol search
|
|
8
|
+
* `codebase-stats` — index health and statistics
|
|
9
|
+
*
|
|
10
|
+
* Storage: `~/.wrongstack/projects/<hash>/codebase-index/index.db`
|
|
11
|
+
* (outside the repo — no gitignore needed)
|
|
12
|
+
* Parser: TypeScript Compiler API (ts-morph-free, via `@typescript/typescript6`)
|
|
13
|
+
* Ranking: Okapi BM25 with k1=1.5, b=0.75
|
|
272
14
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
export {
|
|
15
|
+
export { codebaseIndexTool } from './codebase-index-tool.js';
|
|
16
|
+
export { codebaseSearchTool } from './codebase-search-tool.js';
|
|
17
|
+
export { codebaseStatsTool } from './codebase-stats-tool.js';
|
|
18
|
+
export { runIndexer } from './indexer.js';
|
|
19
|
+
export { runStartupIndex, enqueueReindex, isIndexableFile, cancelPendingReindexes, isIndexReady, isIndexing, getIndexState, onIndexStateChange, searchCodebaseIndex, codebaseIndexStats, shutdownCodebaseIndexHost, } from './background-indexer.js';
|
|
20
|
+
export { IndexCircuitBreaker, indexCircuitBreaker, resetIndexCircuitBreaker, CircuitOpenError, IndexTimeoutError, } from './circuit-breaker.js';
|
|
21
|
+
export type { CircuitState, CircuitSnapshot } from './circuit-breaker.js';
|
|
22
|
+
export { IndexStore, resolveIndexDir, codebaseIndexDirOverride } from './writer.js';
|
|
23
|
+
export { tokenise, buildIndexableText, buildBm25Index, } from './bm25.js';
|
|
24
|
+
export { internalKindToLspKind, lspKindToInternalKind, } from './lsp-kind.js';
|
|
25
|
+
export type { Symbol, SymbolKind, SymbolLang, FileSymbols, FileMeta, IndexStats, IndexResult, SearchResult, } from './schema.js';
|
|
26
|
+
export { SCHEMA_VERSION } from './schema.js';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codebase-index/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI1E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,MAAM,EACN,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|