@wrongstack/tools 0.148.0 → 0.155.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/{background-indexer-C2014mH0.d.ts → background-indexer-CtbgPExj.d.ts} +1 -0
- package/dist/builtin.js +30 -8
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.d.ts +9 -2
- package/dist/codebase-index/index.js +32 -9
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -9
- package/dist/index.js.map +1 -1
- package/dist/pack.js +30 -8
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { forgetTool, relatedMemoryTool, rememberTool, searchMemoryTool } from '.
|
|
|
33
33
|
export { createModeTool } from './mode.js';
|
|
34
34
|
export { KillOpts, RegistryStats, TrackedProcess, _resetProcessRegistry, getProcessRegistry } from './process-registry.js';
|
|
35
35
|
export { CircuitBreaker, CircuitBreakerConfig, CircuitBreakerSnapshot } from './circuit-breaker.js';
|
|
36
|
-
export { 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-
|
|
36
|
+
export { 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';
|
|
37
37
|
export { builtinTools } from './builtin.js';
|
|
38
38
|
export { builtinToolsPack } from './pack.js';
|
|
39
39
|
import 'node:child_process';
|
package/dist/index.js
CHANGED
|
@@ -7202,7 +7202,8 @@ async function runStartupIndex(opts) {
|
|
|
7202
7202
|
() => runIndexer(stubCtx(opts.projectRoot), {
|
|
7203
7203
|
projectRoot: opts.projectRoot,
|
|
7204
7204
|
indexDir: opts.indexDir,
|
|
7205
|
-
force: opts.force
|
|
7205
|
+
force: opts.force,
|
|
7206
|
+
signal: opts.signal
|
|
7206
7207
|
})
|
|
7207
7208
|
);
|
|
7208
7209
|
_ready = true;
|
|
@@ -7248,6 +7249,16 @@ var YIELD_EVERY_N = 50;
|
|
|
7248
7249
|
function yieldEventLoop() {
|
|
7249
7250
|
return new Promise((resolve7) => setImmediate(resolve7));
|
|
7250
7251
|
}
|
|
7252
|
+
function throwIfAborted(signal) {
|
|
7253
|
+
if (!signal?.aborted) return;
|
|
7254
|
+
if (signal.reason instanceof Error) throw signal.reason;
|
|
7255
|
+
throw new Error(
|
|
7256
|
+
typeof signal.reason === "string" ? signal.reason : "Indexing cancelled"
|
|
7257
|
+
);
|
|
7258
|
+
}
|
|
7259
|
+
function isAbortError(err) {
|
|
7260
|
+
return err instanceof DOMException && err.name === "AbortError";
|
|
7261
|
+
}
|
|
7251
7262
|
var DEFAULT_IGNORE5 = [
|
|
7252
7263
|
"node_modules",
|
|
7253
7264
|
".git",
|
|
@@ -7259,7 +7270,7 @@ var DEFAULT_IGNORE5 = [
|
|
|
7259
7270
|
"__snapshots__",
|
|
7260
7271
|
".nyc_output"
|
|
7261
7272
|
];
|
|
7262
|
-
async function findSourceFiles(projectRoot, ignore, isGitIgnored) {
|
|
7273
|
+
async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
7263
7274
|
const results = [];
|
|
7264
7275
|
const ignoreSet = /* @__PURE__ */ new Set([...DEFAULT_IGNORE5, ...ignore]);
|
|
7265
7276
|
const globs = [
|
|
@@ -7274,13 +7285,20 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored) {
|
|
|
7274
7285
|
{ ext: ".yaml", pat: compileGlob("**/*.yaml") },
|
|
7275
7286
|
{ ext: ".yml", pat: compileGlob("**/*.yml") }
|
|
7276
7287
|
];
|
|
7288
|
+
let dirCount = 0;
|
|
7277
7289
|
const walk = async (dir) => {
|
|
7290
|
+
throwIfAborted(signal);
|
|
7291
|
+
if (dirCount > 0 && dirCount % YIELD_EVERY_N === 0) {
|
|
7292
|
+
await yieldEventLoop();
|
|
7293
|
+
throwIfAborted(signal);
|
|
7294
|
+
}
|
|
7278
7295
|
let entries;
|
|
7279
7296
|
try {
|
|
7280
7297
|
entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
7281
7298
|
} catch {
|
|
7282
7299
|
return;
|
|
7283
7300
|
}
|
|
7301
|
+
dirCount++;
|
|
7284
7302
|
for (const e of entries) {
|
|
7285
7303
|
if (ignoreSet.has(e.name)) continue;
|
|
7286
7304
|
const full = path.join(dir, e.name);
|
|
@@ -7325,7 +7343,7 @@ async function parseFile(file, content, lang) {
|
|
|
7325
7343
|
}
|
|
7326
7344
|
}
|
|
7327
7345
|
async function runIndexer(_ctx, opts) {
|
|
7328
|
-
const { projectRoot, force = false, langs, ignore = [], indexDir } = opts;
|
|
7346
|
+
const { projectRoot, force = false, langs, ignore = [], indexDir, signal } = opts;
|
|
7329
7347
|
const store = new IndexStore(projectRoot, { indexDir });
|
|
7330
7348
|
const startMs = Date.now();
|
|
7331
7349
|
const errors = [];
|
|
@@ -7337,7 +7355,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
7337
7355
|
if (opts.files && opts.files.length > 0) {
|
|
7338
7356
|
files = opts.files.map((f) => path.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
7339
7357
|
} else {
|
|
7340
|
-
files = await findSourceFiles(projectRoot, ignore, isGitIgnored);
|
|
7358
|
+
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
7341
7359
|
}
|
|
7342
7360
|
if (langs && langs.length > 0) {
|
|
7343
7361
|
const langSet = new Set(langs);
|
|
@@ -7356,11 +7374,14 @@ async function runIndexer(_ctx, opts) {
|
|
|
7356
7374
|
_setIndexProgress(fi + 1, files.length);
|
|
7357
7375
|
if (fi > 0 && fi % YIELD_EVERY_N === 0) {
|
|
7358
7376
|
await yieldEventLoop();
|
|
7377
|
+
throwIfAborted(signal);
|
|
7359
7378
|
}
|
|
7360
7379
|
let stat10;
|
|
7361
7380
|
try {
|
|
7362
|
-
|
|
7363
|
-
|
|
7381
|
+
const statOpts = signal ? { signal } : {};
|
|
7382
|
+
stat10 = await fs4.stat(file, statOpts);
|
|
7383
|
+
} catch (e) {
|
|
7384
|
+
if (isAbortError(e)) throw e;
|
|
7364
7385
|
store.deleteFile(file);
|
|
7365
7386
|
continue;
|
|
7366
7387
|
}
|
|
@@ -7378,8 +7399,9 @@ async function runIndexer(_ctx, opts) {
|
|
|
7378
7399
|
store.deleteSymbolsForFile(file);
|
|
7379
7400
|
let content;
|
|
7380
7401
|
try {
|
|
7381
|
-
content = await fs4.readFile(file, "utf8");
|
|
7402
|
+
content = await fs4.readFile(file, { encoding: "utf8", signal });
|
|
7382
7403
|
} catch (e) {
|
|
7404
|
+
if (isAbortError(e)) throw e;
|
|
7383
7405
|
errors.push(`read error: ${file}: ${e instanceof Error ? e.message : String(e)}`);
|
|
7384
7406
|
continue;
|
|
7385
7407
|
}
|
|
@@ -7469,7 +7491,7 @@ var codebaseIndexTool = {
|
|
|
7469
7491
|
}
|
|
7470
7492
|
}
|
|
7471
7493
|
},
|
|
7472
|
-
async execute(input, ctx) {
|
|
7494
|
+
async execute(input, ctx, execOpts) {
|
|
7473
7495
|
if (isIndexing()) {
|
|
7474
7496
|
return {
|
|
7475
7497
|
filesIndexed: 0,
|
|
@@ -7484,7 +7506,8 @@ var codebaseIndexTool = {
|
|
|
7484
7506
|
projectRoot: ctx.projectRoot,
|
|
7485
7507
|
force: input.force ?? false,
|
|
7486
7508
|
langs: input.langs,
|
|
7487
|
-
indexDir: codebaseIndexDirOverride(ctx)
|
|
7509
|
+
indexDir: codebaseIndexDirOverride(ctx),
|
|
7510
|
+
signal: execOpts?.signal
|
|
7488
7511
|
});
|
|
7489
7512
|
setIndexReady();
|
|
7490
7513
|
return result;
|