@wrongstack/tools 0.68.0 → 0.77.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/{codebase-stats-tool-C8ApERbn.d.ts → background-indexer-C70RD7LU.d.ts} +81 -1
- package/dist/builtin.js +216 -56
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.d.ts +35 -4
- package/dist/codebase-index/index.js +267 -13
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +274 -15
- package/dist/index.js.map +1 -1
- package/dist/pack.js +216 -56
- package/dist/pack.js.map +1 -1
- package/dist/todo.js +2 -1
- package/dist/todo.js.map +1 -1
- package/dist/tool-search.js +5 -1
- package/dist/tool-search.js.map +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,8 @@ interface CodebaseIndexOutput {
|
|
|
11
11
|
langStats: Record<string, number>;
|
|
12
12
|
durationMs: number;
|
|
13
13
|
errors: string[];
|
|
14
|
+
/** Advisory note when the indexer was skipped (e.g. another index in progress). */
|
|
15
|
+
note?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/** Language a symbol belongs to. */
|
|
@@ -122,6 +124,8 @@ interface CodebaseSearchOutput {
|
|
|
122
124
|
results: SearchResult[];
|
|
123
125
|
total: number;
|
|
124
126
|
query: string;
|
|
127
|
+
/** Non-empty when the index blocked the search (not ready, indexing, failed). */
|
|
128
|
+
indexStatus?: string;
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
/**
|
|
@@ -142,6 +146,82 @@ interface CodebaseStatsOutput {
|
|
|
142
146
|
sizeBytes: number;
|
|
143
147
|
indexPath: string;
|
|
144
148
|
version: number;
|
|
149
|
+
/** Non-empty when the index is not ready or is still building. */
|
|
150
|
+
indexStatus?: string;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Background indexing coordinator.
|
|
155
|
+
*
|
|
156
|
+
* Wraps {@link runIndexer} with two concerns the agent loop and the CLI wiring
|
|
157
|
+
* both need but neither should own:
|
|
158
|
+
*
|
|
159
|
+
* 1. **Serialization** — every reindex (startup full scan, per-edit incremental,
|
|
160
|
+
* external file-watch) goes through one process-wide promise-chain mutex.
|
|
161
|
+
* `writer.ts` opens a synchronous `node:sqlite` `DatabaseSync` connection per
|
|
162
|
+
* `IndexStore`; two concurrent `runIndexer` runs on the same `index.db` would
|
|
163
|
+
* race the writer and risk `SQLITE_BUSY`. The mutex makes them queue instead.
|
|
164
|
+
*
|
|
165
|
+
* 2. **Debounce** — rapid successive edits to the same file (editor autosave,
|
|
166
|
+
* multi-edit) coalesce into a single reindex, keyed per `(indexDir, file)`.
|
|
167
|
+
*
|
|
168
|
+
* 3. **State tracking** — exposes whether the initial index has completed (`ready`)
|
|
169
|
+
* and whether a build is in progress (`indexing`), so downstream tools
|
|
170
|
+
* (codebase-search, codebase-stats) can gate on it and UIs can show progress.
|
|
171
|
+
*
|
|
172
|
+
* `runIndexer` only reads `opts` (and ignores its `_ctx` parameter), so callers
|
|
173
|
+
* outside the agent loop pass a minimal stub cast to the expected shape — no
|
|
174
|
+
* live agent `Context` is required.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/** True once the first full-project index has completed (success or failure). */
|
|
178
|
+
declare function isIndexReady(): boolean;
|
|
179
|
+
/** True while an index build is actively running. */
|
|
180
|
+
declare function isIndexing(): boolean;
|
|
181
|
+
/** Current indexing progress: { currentFile, totalFiles, ready, indexing }. */
|
|
182
|
+
declare function getIndexState(): {
|
|
183
|
+
ready: boolean;
|
|
184
|
+
indexing: boolean;
|
|
185
|
+
currentFile: number;
|
|
186
|
+
totalFiles: number;
|
|
187
|
+
lastError: string | null;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Optional callback fired on every lifecycle transition (started, progress,
|
|
191
|
+
* completed, failed). Plug into the event bus or a TUI dispatcher to surface
|
|
192
|
+
* the indexing state in real time.
|
|
193
|
+
*/
|
|
194
|
+
type IndexStateListener = (state: ReturnType<typeof getIndexState>) => void;
|
|
195
|
+
declare function onIndexStateChange(listener: IndexStateListener): () => void;
|
|
196
|
+
/** True when the file's extension maps to a language the indexer can parse. */
|
|
197
|
+
declare function isIndexableFile(filePath: string): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Run a full-project scan and await it. Used at session start and by the manual
|
|
200
|
+
* `/codebase-reindex` command. Incremental by default (unchanged files skipped
|
|
201
|
+
* via mtime, so repeat runs are cheap); pass `force` to clear and rebuild.
|
|
202
|
+
*
|
|
203
|
+
* Sets the global `_ready` flag on completion so downstream tools know the
|
|
204
|
+
* index is usable.
|
|
205
|
+
*/
|
|
206
|
+
declare function runStartupIndex(opts: {
|
|
207
|
+
projectRoot: string;
|
|
208
|
+
indexDir?: string;
|
|
209
|
+
force?: boolean;
|
|
210
|
+
}): Promise<IndexResult>;
|
|
211
|
+
/**
|
|
212
|
+
* Debounced, fire-and-forget incremental reindex of specific files. Used by the
|
|
213
|
+
* per-edit toolCall middleware and the external file watcher. Non-indexable
|
|
214
|
+
* paths are dropped. Errors are reported via the optional `onError` callback and
|
|
215
|
+
* never thrown to the caller (background work must not crash a turn).
|
|
216
|
+
*/
|
|
217
|
+
declare function enqueueReindex(opts: {
|
|
218
|
+
projectRoot: string;
|
|
219
|
+
files: string[];
|
|
220
|
+
indexDir?: string;
|
|
221
|
+
debounceMs?: number;
|
|
222
|
+
onError?: (err: unknown) => void;
|
|
223
|
+
}): void;
|
|
224
|
+
/** Cancel all pending debounced reindexes. For teardown / tests. */
|
|
225
|
+
declare function cancelPendingReindexes(): void;
|
|
226
|
+
|
|
227
|
+
export { type FileMeta as F, type IndexResult as I, type Ref as R, SCHEMA_VERSION as S, type FileSymbols as a, type IndexStats as b, type SearchResult as c, type Symbol as d, type SymbolKind as e, type SymbolLang as f, cancelPendingReindexes as g, codebaseIndexTool as h, codebaseSearchTool as i, codebaseStatsTool as j, enqueueReindex as k, getIndexState as l, isIndexReady as m, isIndexableFile as n, isIndexing as o, onIndexStateChange as p, runStartupIndex as r };
|