@wrongstack/tools 0.77.0 → 0.82.6
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/audit.d.ts +4 -4
- package/dist/audit.js +10 -2
- package/dist/audit.js.map +1 -1
- package/dist/{background-indexer-C70RD7LU.d.ts → background-indexer-DYm1FUxK.d.ts} +19 -19
- package/dist/bash.d.ts +4 -4
- package/dist/bash.js +18 -4
- package/dist/bash.js.map +1 -1
- package/dist/batch-tool-use.d.ts +4 -4
- package/dist/batch-tool-use.js.map +1 -1
- package/dist/builtin.js +173 -70
- package/dist/builtin.js.map +1 -1
- package/dist/circuit-breaker.d.ts +6 -6
- package/dist/circuit-breaker.js.map +1 -1
- package/dist/codebase-index/index.d.ts +12 -12
- package/dist/codebase-index/index.js +79 -41
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/diff.d.ts +7 -7
- package/dist/diff.js.map +1 -1
- package/dist/document.d.ts +6 -6
- package/dist/document.js.map +1 -1
- package/dist/edit.d.ts +1 -1
- package/dist/edit.js.map +1 -1
- package/dist/exec.d.ts +3 -3
- package/dist/exec.js +15 -3
- package/dist/exec.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.js +3 -1
- package/dist/fetch.js.map +1 -1
- package/dist/format.d.ts +4 -4
- package/dist/format.js +18 -4
- package/dist/format.js.map +1 -1
- package/dist/git.d.ts +10 -10
- package/dist/git.js +8 -2
- package/dist/git.js.map +1 -1
- package/dist/glob.d.ts +2 -2
- package/dist/glob.js.map +1 -1
- package/dist/grep.d.ts +6 -6
- package/dist/grep.js +10 -2
- package/dist/grep.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +173 -70
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +5 -5
- package/dist/install.js +18 -4
- package/dist/install.js.map +1 -1
- package/dist/json.d.ts +8 -8
- package/dist/json.js.map +1 -1
- package/dist/lint.d.ts +4 -4
- package/dist/lint.js +18 -4
- package/dist/lint.js.map +1 -1
- package/dist/logs.d.ts +8 -8
- package/dist/logs.js.map +1 -1
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js.map +1 -1
- package/dist/mode.d.ts +3 -3
- package/dist/mode.js.map +1 -1
- package/dist/outdated.d.ts +4 -4
- package/dist/outdated.js.map +1 -1
- package/dist/pack.js +173 -70
- package/dist/pack.js.map +1 -1
- package/dist/patch.d.ts +3 -3
- package/dist/patch.js.map +1 -1
- package/dist/process-registry.d.ts +3 -3
- package/dist/process-registry.js +7 -1
- package/dist/process-registry.js.map +1 -1
- package/dist/read.d.ts +2 -2
- package/dist/read.js.map +1 -1
- package/dist/replace.d.ts +4 -4
- package/dist/replace.js +8 -2
- package/dist/replace.js.map +1 -1
- package/dist/scaffold.d.ts +2 -2
- package/dist/scaffold.js.map +1 -1
- package/dist/search.d.ts +2 -2
- package/dist/search.js +16 -8
- package/dist/search.js.map +1 -1
- package/dist/test.d.ts +7 -7
- package/dist/test.js +18 -4
- package/dist/test.js.map +1 -1
- package/dist/tool-help.d.ts +4 -4
- package/dist/tool-help.js.map +1 -1
- package/dist/tool-search.d.ts +5 -5
- package/dist/tool-search.js.map +1 -1
- package/dist/tool-use.d.ts +2 -2
- package/dist/tool-use.js.map +1 -1
- package/dist/tree.d.ts +7 -7
- package/dist/tree.js +10 -2
- package/dist/tree.js.map +1 -1
- package/dist/typecheck.d.ts +4 -4
- package/dist/typecheck.js +18 -4
- package/dist/typecheck.js.map +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -19,6 +19,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
19
19
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
20
20
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
21
|
});
|
|
22
|
+
function expectDefined(value) {
|
|
23
|
+
if (value === null || value === void 0) {
|
|
24
|
+
throw new Error("Expected value to be defined");
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
22
28
|
async function detectPackageManager(cwd) {
|
|
23
29
|
const { stat: stat10 } = await import('node:fs/promises');
|
|
24
30
|
try {
|
|
@@ -108,9 +114,9 @@ function collapseConsecutiveDuplicates(text, minRun = REPEAT_RUN_THRESHOLD) {
|
|
|
108
114
|
while (j < lines.length && lines[j] === lines[i]) j++;
|
|
109
115
|
const run = j - i;
|
|
110
116
|
if (run >= minRun) {
|
|
111
|
-
out.push(lines[i], `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
|
|
117
|
+
out.push(expectDefined(lines[i]), `\u2026 \u27E8repeated ${run}\xD7\u27E9`);
|
|
112
118
|
} else {
|
|
113
|
-
for (let k = i; k < j; k++) out.push(lines[k]);
|
|
119
|
+
for (let k = i; k < j; k++) out.push(expectDefined(lines[k]));
|
|
114
120
|
}
|
|
115
121
|
i = j;
|
|
116
122
|
}
|
|
@@ -466,6 +472,12 @@ function capSubject(line) {
|
|
|
466
472
|
}
|
|
467
473
|
|
|
468
474
|
// src/replace.ts
|
|
475
|
+
function expectDefined2(value) {
|
|
476
|
+
if (value === null || value === void 0) {
|
|
477
|
+
throw new Error("Expected value to be defined");
|
|
478
|
+
}
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
469
481
|
var DEFAULT_IGNORE = ["node_modules", ".git", "dist", "build", ".next", "coverage"];
|
|
470
482
|
var replaceTool = {
|
|
471
483
|
name: "replace",
|
|
@@ -545,8 +557,8 @@ var replaceTool = {
|
|
|
545
557
|
const count = matches.length;
|
|
546
558
|
let newContentLf = contentLf;
|
|
547
559
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
548
|
-
const m = matches[i];
|
|
549
|
-
newContentLf = newContentLf.slice(0, m.index) + input.replacement + newContentLf.slice(m.index + m[0].length);
|
|
560
|
+
const m = expectDefined2(matches[i]);
|
|
561
|
+
newContentLf = newContentLf.slice(0, m.index) + input.replacement + newContentLf.slice(expectDefined2(m.index) + m[0].length);
|
|
550
562
|
}
|
|
551
563
|
re.lastIndex = 0;
|
|
552
564
|
totalReplacements += count;
|
|
@@ -747,6 +759,12 @@ async function readGitignore(dir) {
|
|
|
747
759
|
return [];
|
|
748
760
|
}
|
|
749
761
|
}
|
|
762
|
+
function expectDefined3(value) {
|
|
763
|
+
if (value === null || value === void 0) {
|
|
764
|
+
throw new Error("Expected value to be defined");
|
|
765
|
+
}
|
|
766
|
+
return value;
|
|
767
|
+
}
|
|
750
768
|
var DEFAULT_IGNORE3 = ["node_modules", ".git", "dist", "build", ".next", "coverage"];
|
|
751
769
|
var grepTool = {
|
|
752
770
|
name: "grep",
|
|
@@ -795,7 +813,9 @@ var grepTool = {
|
|
|
795
813
|
},
|
|
796
814
|
async execute(input, ctx, opts) {
|
|
797
815
|
let final;
|
|
798
|
-
|
|
816
|
+
const executeStream = grepTool.executeStream;
|
|
817
|
+
if (!executeStream) throw new Error("grepTool: stream execution unavailable");
|
|
818
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
799
819
|
if (ev.type === "final") final = ev.output;
|
|
800
820
|
}
|
|
801
821
|
if (!final) throw new Error("grep: stream ended without final event");
|
|
@@ -886,7 +906,7 @@ async function* runRgStream(input, base, mode, limit, signal) {
|
|
|
886
906
|
waiter = r;
|
|
887
907
|
});
|
|
888
908
|
}
|
|
889
|
-
const c = queue.shift();
|
|
909
|
+
const c = expectDefined3(queue.shift());
|
|
890
910
|
if (c.kind === "error") {
|
|
891
911
|
errored = true;
|
|
892
912
|
continue;
|
|
@@ -1178,6 +1198,12 @@ var CircuitBreaker = class {
|
|
|
1178
1198
|
};
|
|
1179
1199
|
|
|
1180
1200
|
// src/process-registry.ts
|
|
1201
|
+
function expectDefined4(value) {
|
|
1202
|
+
if (value === null || value === void 0) {
|
|
1203
|
+
throw new Error("Expected value to be defined");
|
|
1204
|
+
}
|
|
1205
|
+
return value;
|
|
1206
|
+
}
|
|
1181
1207
|
var SENSITIVE_FLAG_PATTERNS = [
|
|
1182
1208
|
// --flag=value or --flag "value" (value captured up to next space or comma)
|
|
1183
1209
|
/--(?:token|password|passwd|pwd|secret|api[-_]?key|api[-_]?secret|auth|credential|private[-_]?key|access[-_]?key|github[-_]?token|gh[-_]?token|bearer|jwt|oauth|pin|pincode|passphrase|access[-_]?token)(?:[=\s,][^\s]*)?/gi,
|
|
@@ -1198,7 +1224,7 @@ function redactCommand(cmd) {
|
|
|
1198
1224
|
const sp = match.search(/\s/);
|
|
1199
1225
|
const delim = eq !== -1 ? "=" : sp !== -1 ? match[sp] : null;
|
|
1200
1226
|
if (delim !== null) {
|
|
1201
|
-
const flag = match.slice(0, match.indexOf(delim) + 1);
|
|
1227
|
+
const flag = match.slice(0, match.indexOf(expectDefined4(delim)) + 1);
|
|
1202
1228
|
return `${flag}[REDACTED]`;
|
|
1203
1229
|
}
|
|
1204
1230
|
const flagEnd = match.match(/^--?[a-zA-Z][a-zA-Z0-9_-]*/)?.[0] ?? match;
|
|
@@ -1420,7 +1446,9 @@ var bashTool = {
|
|
|
1420
1446
|
},
|
|
1421
1447
|
async execute(input, ctx, opts) {
|
|
1422
1448
|
let final;
|
|
1423
|
-
|
|
1449
|
+
const executeStream = bashTool.executeStream;
|
|
1450
|
+
if (!executeStream) throw new Error("bashTool: stream execution unavailable");
|
|
1451
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
1424
1452
|
if (ev.type === "final") final = ev.output;
|
|
1425
1453
|
}
|
|
1426
1454
|
if (!final) throw new Error("bash: stream ended without final event");
|
|
@@ -2018,7 +2046,9 @@ var fetchTool = {
|
|
|
2018
2046
|
},
|
|
2019
2047
|
async execute(input, ctx, opts) {
|
|
2020
2048
|
let final;
|
|
2021
|
-
|
|
2049
|
+
const executeStream = fetchTool.executeStream;
|
|
2050
|
+
if (!executeStream) throw new Error("fetchTool: stream execution unavailable");
|
|
2051
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
2022
2052
|
if (ev.type === "final") final = ev.output;
|
|
2023
2053
|
}
|
|
2024
2054
|
if (!final) throw new Error("fetch: stream ended without final event");
|
|
@@ -2247,6 +2277,12 @@ function stripTags(s) {
|
|
|
2247
2277
|
}
|
|
2248
2278
|
|
|
2249
2279
|
// src/search.ts
|
|
2280
|
+
function expectDefined5(value) {
|
|
2281
|
+
if (value === null || value === void 0) {
|
|
2282
|
+
throw new Error("Expected value to be defined");
|
|
2283
|
+
}
|
|
2284
|
+
return value;
|
|
2285
|
+
}
|
|
2250
2286
|
var DEFAULT_NUM = 10;
|
|
2251
2287
|
var MAX_RESULTS = 50;
|
|
2252
2288
|
var TIMEOUT_MS3 = 15e3;
|
|
@@ -2279,7 +2315,9 @@ var searchTool = {
|
|
|
2279
2315
|
},
|
|
2280
2316
|
async execute(input, ctx, opts) {
|
|
2281
2317
|
let final;
|
|
2282
|
-
|
|
2318
|
+
const executeStream = searchTool.executeStream;
|
|
2319
|
+
if (!executeStream) throw new Error("searchTool: stream execution unavailable");
|
|
2320
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
2283
2321
|
if (ev.type === "final") final = ev.output;
|
|
2284
2322
|
}
|
|
2285
2323
|
if (!final) throw new Error("search: stream ended without final event");
|
|
@@ -2340,11 +2378,11 @@ function parseDuckDuckGo(html, num) {
|
|
|
2340
2378
|
const snippetRegex = /<a class="result-link"[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/gi;
|
|
2341
2379
|
const snippet2Regex = /<a class="result-snippet"[^>]*>([^<]+)<\/a>/gi;
|
|
2342
2380
|
const linkMatches = takeFrom(
|
|
2343
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: m[1], title: stripTags2(m[2]) })),
|
|
2381
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: expectDefined5(m[1]), title: stripTags2(expectDefined5(m[2])) })),
|
|
2344
2382
|
num
|
|
2345
2383
|
);
|
|
2346
2384
|
const snippetMatches = takeFrom(
|
|
2347
|
-
[...html.matchAll(snippet2Regex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
2385
|
+
[...html.matchAll(snippet2Regex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined5(m[1]))),
|
|
2348
2386
|
num
|
|
2349
2387
|
);
|
|
2350
2388
|
for (let i = 0; i < linkMatches.length && i < num; i++) {
|
|
@@ -2375,15 +2413,15 @@ function parseGoogleResults(html, num) {
|
|
|
2375
2413
|
const urlRegex = /<cite[^>]*>([^<]+)<\/cite>/gi;
|
|
2376
2414
|
const snippetRegex = /<span[^>]*class="[^"]*aXCZ0b[^>]*>([^<]+)<\/span>/gi;
|
|
2377
2415
|
const titles = takeFrom(
|
|
2378
|
-
[...html.matchAll(titleRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
2416
|
+
[...html.matchAll(titleRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined5(m[1]))),
|
|
2379
2417
|
num
|
|
2380
2418
|
);
|
|
2381
2419
|
const urls = takeFrom(
|
|
2382
|
-
[...html.matchAll(urlRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1]).replace(/^\*(https?:\/\/[^\s]+).*$/, "$1")).filter((u) => u.startsWith("http")),
|
|
2420
|
+
[...html.matchAll(urlRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined5(m[1])).replace(/^\*(https?:\/\/[^\s]+).*$/, "$1")).filter((u) => u.startsWith("http")),
|
|
2383
2421
|
num
|
|
2384
2422
|
);
|
|
2385
2423
|
const snippets = takeFrom(
|
|
2386
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
2424
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined5(m[1]))),
|
|
2387
2425
|
num
|
|
2388
2426
|
);
|
|
2389
2427
|
for (let i = 0; i < Math.min(titles.length, num); i++) {
|
|
@@ -2412,11 +2450,11 @@ function parseBingResults(html, num) {
|
|
|
2412
2450
|
const titleRegex = /<h2[^>]*>\s*<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>\s*<\/h2>/gi;
|
|
2413
2451
|
const snippetRegex = /<p[^>]*class="[^"]*b_paractl[^"]*"[^>]*>([^<]+)<\/p>/gi;
|
|
2414
2452
|
const entries = takeFrom(
|
|
2415
|
-
[...html.matchAll(titleRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: m[1], title: stripTags2(m[2]) })),
|
|
2453
|
+
[...html.matchAll(titleRegex)].filter((m) => m[1] && m[2]).map((m) => ({ url: expectDefined5(m[1]), title: stripTags2(expectDefined5(m[2])) })),
|
|
2416
2454
|
num
|
|
2417
2455
|
);
|
|
2418
2456
|
const snippets = takeFrom(
|
|
2419
|
-
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(m[1])),
|
|
2457
|
+
[...html.matchAll(snippetRegex)].filter((m) => m[1]).map((m) => stripTags2(expectDefined5(m[1]))),
|
|
2420
2458
|
num
|
|
2421
2459
|
);
|
|
2422
2460
|
for (let i = 0; i < entries.length; i++) {
|
|
@@ -2678,14 +2716,15 @@ var planTool = {
|
|
|
2678
2716
|
};
|
|
2679
2717
|
function mkResult(plan, ok, message, todos) {
|
|
2680
2718
|
const open = plan.items.filter((i) => i.status !== "done").length;
|
|
2681
|
-
|
|
2719
|
+
const result = {
|
|
2682
2720
|
ok,
|
|
2683
2721
|
message,
|
|
2684
2722
|
plan: formatPlan(plan),
|
|
2685
2723
|
count: plan.items.length,
|
|
2686
|
-
open
|
|
2687
|
-
todos
|
|
2724
|
+
open
|
|
2688
2725
|
};
|
|
2726
|
+
if (todos !== void 0) result.todos = todos;
|
|
2727
|
+
return result;
|
|
2689
2728
|
}
|
|
2690
2729
|
var TIMEOUT_MS4 = 3e4;
|
|
2691
2730
|
var MAX_OUTPUT3 = 1e5;
|
|
@@ -3306,6 +3345,12 @@ function formatWithLineNumbers(file, lines) {
|
|
|
3306
3345
|
return `--- ${file} (line-numbered dump, not a unified diff) ---
|
|
3307
3346
|
${numbered}`;
|
|
3308
3347
|
}
|
|
3348
|
+
function expectDefined6(value) {
|
|
3349
|
+
if (value === null || value === void 0) {
|
|
3350
|
+
throw new Error("Expected value to be defined");
|
|
3351
|
+
}
|
|
3352
|
+
return value;
|
|
3353
|
+
}
|
|
3309
3354
|
var DEFAULT_IGNORE4 = [
|
|
3310
3355
|
"node_modules",
|
|
3311
3356
|
".git",
|
|
@@ -3366,7 +3411,9 @@ var treeTool = {
|
|
|
3366
3411
|
},
|
|
3367
3412
|
async execute(input, ctx, opts) {
|
|
3368
3413
|
let final;
|
|
3369
|
-
|
|
3414
|
+
const executeStream = treeTool.executeStream;
|
|
3415
|
+
if (!executeStream) throw new Error("treeTool: stream execution unavailable");
|
|
3416
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3370
3417
|
if (ev.type === "final") final = ev.output;
|
|
3371
3418
|
}
|
|
3372
3419
|
if (!final) throw new Error("tree: stream ended without final event");
|
|
@@ -3416,7 +3463,7 @@ var treeTool = {
|
|
|
3416
3463
|
});
|
|
3417
3464
|
while (!walkDone || queue.length > 0) {
|
|
3418
3465
|
if (queue.length > 0) {
|
|
3419
|
-
yield queue.shift();
|
|
3466
|
+
yield expectDefined6(queue.shift());
|
|
3420
3467
|
} else {
|
|
3421
3468
|
let pollTimer;
|
|
3422
3469
|
const poll = new Promise((r) => {
|
|
@@ -3481,6 +3528,12 @@ async function walkDir(dir, depth, opts) {
|
|
|
3481
3528
|
}
|
|
3482
3529
|
}
|
|
3483
3530
|
}
|
|
3531
|
+
function expectDefined7(value) {
|
|
3532
|
+
if (value === null || value === void 0) {
|
|
3533
|
+
throw new Error("Expected value to be defined");
|
|
3534
|
+
}
|
|
3535
|
+
return value;
|
|
3536
|
+
}
|
|
3484
3537
|
async function* spawnStream(opts) {
|
|
3485
3538
|
const max = opts.maxBytes ?? 2e5;
|
|
3486
3539
|
const flushAt = opts.flushBytes ?? 4 * 1024;
|
|
@@ -3532,7 +3585,7 @@ async function* spawnStream(opts) {
|
|
|
3532
3585
|
waiter = resolve7;
|
|
3533
3586
|
});
|
|
3534
3587
|
}
|
|
3535
|
-
const chunk = queue.shift();
|
|
3588
|
+
const chunk = expectDefined7(queue.shift());
|
|
3536
3589
|
if (chunk.kind === "close") {
|
|
3537
3590
|
if (!spawnFailed) exitCode = chunk.code ?? 0;
|
|
3538
3591
|
break;
|
|
@@ -3587,7 +3640,9 @@ var lintTool = {
|
|
|
3587
3640
|
},
|
|
3588
3641
|
async execute(input, ctx, opts) {
|
|
3589
3642
|
let final;
|
|
3590
|
-
|
|
3643
|
+
const executeStream = lintTool.executeStream;
|
|
3644
|
+
if (!executeStream) throw new Error("lintTool: stream execution unavailable");
|
|
3645
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3591
3646
|
if (ev.type === "final") final = ev.output;
|
|
3592
3647
|
}
|
|
3593
3648
|
if (!final) throw new Error("lint: stream ended without final event");
|
|
@@ -3683,7 +3738,9 @@ var formatTool = {
|
|
|
3683
3738
|
},
|
|
3684
3739
|
async execute(input, ctx, opts) {
|
|
3685
3740
|
let final;
|
|
3686
|
-
|
|
3741
|
+
const executeStream = formatTool.executeStream;
|
|
3742
|
+
if (!executeStream) throw new Error("formatTool: stream execution unavailable");
|
|
3743
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3687
3744
|
if (ev.type === "final") final = ev.output;
|
|
3688
3745
|
}
|
|
3689
3746
|
if (!final) throw new Error("format: stream ended without final event");
|
|
@@ -3776,7 +3833,9 @@ var typecheckTool = {
|
|
|
3776
3833
|
},
|
|
3777
3834
|
async execute(input, ctx, opts) {
|
|
3778
3835
|
let final;
|
|
3779
|
-
|
|
3836
|
+
const executeStream = typecheckTool.executeStream;
|
|
3837
|
+
if (!executeStream) throw new Error("typecheckTool: stream execution unavailable");
|
|
3838
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3780
3839
|
if (ev.type === "final") final = ev.output;
|
|
3781
3840
|
}
|
|
3782
3841
|
if (!final) throw new Error("typecheck: stream ended without final event");
|
|
@@ -3860,7 +3919,9 @@ var testTool = {
|
|
|
3860
3919
|
},
|
|
3861
3920
|
async execute(input, ctx, opts) {
|
|
3862
3921
|
let final;
|
|
3863
|
-
|
|
3922
|
+
const executeStream = testTool.executeStream;
|
|
3923
|
+
if (!executeStream) throw new Error("testTool: stream execution unavailable");
|
|
3924
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
3864
3925
|
if (ev.type === "final") final = ev.output;
|
|
3865
3926
|
}
|
|
3866
3927
|
if (!final) throw new Error("test: stream ended without final event");
|
|
@@ -4017,7 +4078,9 @@ var installTool = {
|
|
|
4017
4078
|
},
|
|
4018
4079
|
async execute(input, ctx, opts) {
|
|
4019
4080
|
let final;
|
|
4020
|
-
|
|
4081
|
+
const executeStream = installTool.executeStream;
|
|
4082
|
+
if (!executeStream) throw new Error("installTool: stream execution unavailable");
|
|
4083
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
4021
4084
|
if (ev.type === "final") final = ev.output;
|
|
4022
4085
|
}
|
|
4023
4086
|
if (!final) throw new Error("install: stream ended without final event");
|
|
@@ -4108,7 +4171,9 @@ var auditTool = {
|
|
|
4108
4171
|
},
|
|
4109
4172
|
async execute(input, ctx, opts) {
|
|
4110
4173
|
let final;
|
|
4111
|
-
|
|
4174
|
+
const executeStream = auditTool.executeStream;
|
|
4175
|
+
if (!executeStream) throw new Error("auditTool: stream execution unavailable");
|
|
4176
|
+
for await (const ev of executeStream(input, ctx, opts)) {
|
|
4112
4177
|
if (ev.type === "final") final = ev.output;
|
|
4113
4178
|
}
|
|
4114
4179
|
if (!final) throw new Error("audit: stream ended without final event");
|
|
@@ -5361,6 +5426,12 @@ function lspKindToInternalKind(k) {
|
|
|
5361
5426
|
}
|
|
5362
5427
|
|
|
5363
5428
|
// src/codebase-index/writer.ts
|
|
5429
|
+
function expectDefined8(value) {
|
|
5430
|
+
if (value === null || value === void 0) {
|
|
5431
|
+
throw new Error("Expected value to be defined");
|
|
5432
|
+
}
|
|
5433
|
+
return value;
|
|
5434
|
+
}
|
|
5364
5435
|
var DB_FILE = "index.db";
|
|
5365
5436
|
function resolveIndexDir(projectRoot, override) {
|
|
5366
5437
|
return override ?? resolveWstackPaths({ projectRoot }).projectCodebaseIndex;
|
|
@@ -5505,7 +5576,7 @@ var IndexStore = class {
|
|
|
5505
5576
|
"SELECT file, lang, mtime_ms, symbol_count, last_indexed FROM files WHERE file = ?"
|
|
5506
5577
|
).all(file);
|
|
5507
5578
|
if (!rows.length) return null;
|
|
5508
|
-
const r = rows[0];
|
|
5579
|
+
const r = expectDefined8(rows[0]);
|
|
5509
5580
|
return { file: r.file, lang: r.lang, mtimeMs: r.mtime_ms, symbolCount: r.symbol_count, lastIndexed: r.last_indexed };
|
|
5510
5581
|
}
|
|
5511
5582
|
getAllFileMetas() {
|
|
@@ -5587,7 +5658,7 @@ var IndexStore = class {
|
|
|
5587
5658
|
const lastRows = this.db.prepare(
|
|
5588
5659
|
"SELECT value FROM metadata WHERE key = 'last_indexed'"
|
|
5589
5660
|
).all();
|
|
5590
|
-
const lastIndexed = lastRows.length ? Number(lastRows[0]
|
|
5661
|
+
const lastIndexed = lastRows.length ? Number(lastRows[0]?.value) : null;
|
|
5591
5662
|
const totalRows = this.db.prepare("SELECT COUNT(*) FROM symbols").all();
|
|
5592
5663
|
const totalSymbols = totalRows[0] ? Number(totalRows[0]["COUNT(*)"]) : 0;
|
|
5593
5664
|
const fileRows = this.db.prepare("SELECT COUNT(*) FROM files").all();
|
|
@@ -5662,8 +5733,9 @@ var IndexStore = class {
|
|
|
5662
5733
|
let resolved = 0;
|
|
5663
5734
|
for (const row of unresolved) {
|
|
5664
5735
|
const target = this.db.prepare("SELECT id FROM symbols WHERE name = ? LIMIT 1").all(row.to_name);
|
|
5665
|
-
|
|
5666
|
-
|
|
5736
|
+
const first = target[0];
|
|
5737
|
+
if (first) {
|
|
5738
|
+
this.db.prepare("UPDATE refs SET to_id = ? WHERE id = ?").run(first.id, row.id);
|
|
5667
5739
|
resolved++;
|
|
5668
5740
|
}
|
|
5669
5741
|
}
|
|
@@ -6417,6 +6489,12 @@ function syncPyParse(filePath, lang) {
|
|
|
6417
6489
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
6418
6490
|
}
|
|
6419
6491
|
}
|
|
6492
|
+
function expectDefined9(value) {
|
|
6493
|
+
if (value === null || value === void 0) {
|
|
6494
|
+
throw new Error("Expected value to be defined");
|
|
6495
|
+
}
|
|
6496
|
+
return value;
|
|
6497
|
+
}
|
|
6420
6498
|
function parseSymbols4(opts) {
|
|
6421
6499
|
const { file, content, lang } = opts;
|
|
6422
6500
|
const nativeAvailable = checkNativeParser();
|
|
@@ -6498,14 +6576,14 @@ function regexParse(opts) {
|
|
|
6498
6576
|
const lines = content.split("\n");
|
|
6499
6577
|
const lineOffsets = [0];
|
|
6500
6578
|
for (let i = 0; i < lines.length; i++) {
|
|
6501
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
6579
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
6502
6580
|
}
|
|
6503
6581
|
function lineFromOffset(offset) {
|
|
6504
6582
|
let lo = 0;
|
|
6505
6583
|
let hi = lineOffsets.length - 1;
|
|
6506
6584
|
while (lo < hi) {
|
|
6507
6585
|
const mid = lo + hi + 1 >>> 1;
|
|
6508
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
6586
|
+
if (expectDefined9(lineOffsets[mid]) <= offset) lo = mid;
|
|
6509
6587
|
else hi = mid - 1;
|
|
6510
6588
|
}
|
|
6511
6589
|
return lo + 1;
|
|
@@ -6517,8 +6595,8 @@ function regexParse(opts) {
|
|
|
6517
6595
|
for (const pattern of RS_PATTERNS) {
|
|
6518
6596
|
pattern.regex.lastIndex = 0;
|
|
6519
6597
|
for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
|
|
6520
|
-
const name = match[1];
|
|
6521
|
-
const offset = match.index;
|
|
6598
|
+
const name = expectDefined9(match[1]);
|
|
6599
|
+
const offset = match.index ?? 0;
|
|
6522
6600
|
const line = lineFromOffset(offset);
|
|
6523
6601
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6524
6602
|
const lineIdx = line - 1;
|
|
@@ -6547,6 +6625,12 @@ function regexParse(opts) {
|
|
|
6547
6625
|
});
|
|
6548
6626
|
return { file, lang, symbols: deduped, mtimeMs: Date.now() };
|
|
6549
6627
|
}
|
|
6628
|
+
function expectDefined10(value) {
|
|
6629
|
+
if (value === null || value === void 0) {
|
|
6630
|
+
throw new Error("Expected value to be defined");
|
|
6631
|
+
}
|
|
6632
|
+
return value;
|
|
6633
|
+
}
|
|
6550
6634
|
function parseSymbols5(opts) {
|
|
6551
6635
|
const { file, content, lang } = opts;
|
|
6552
6636
|
try {
|
|
@@ -6566,21 +6650,21 @@ function regexParse2(opts) {
|
|
|
6566
6650
|
const lines = content.split("\n");
|
|
6567
6651
|
const lineOffsets = [0];
|
|
6568
6652
|
for (let i = 0; i < lines.length; i++) {
|
|
6569
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
6653
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
6570
6654
|
}
|
|
6571
6655
|
function lineFromOffset(offset) {
|
|
6572
6656
|
let lo = 0;
|
|
6573
6657
|
let hi = lineOffsets.length - 1;
|
|
6574
6658
|
while (lo < hi) {
|
|
6575
6659
|
const mid = lo + hi + 1 >>> 1;
|
|
6576
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
6660
|
+
if (expectDefined10(lineOffsets[mid]) <= offset) lo = mid;
|
|
6577
6661
|
else hi = mid - 1;
|
|
6578
6662
|
}
|
|
6579
6663
|
return lo + 1;
|
|
6580
6664
|
}
|
|
6581
6665
|
const rootMatch = content.match(/^\s*\{/m);
|
|
6582
6666
|
if (rootMatch) {
|
|
6583
|
-
const offset = rootMatch.index;
|
|
6667
|
+
const offset = expectDefined10(rootMatch.index);
|
|
6584
6668
|
const line = lineFromOffset(offset);
|
|
6585
6669
|
symbols.push(
|
|
6586
6670
|
makeSymbol({
|
|
@@ -6596,8 +6680,8 @@ function regexParse2(opts) {
|
|
|
6596
6680
|
}
|
|
6597
6681
|
const topLevelKeyRegex = /^\s*"([^"]+)"\s*:/gm;
|
|
6598
6682
|
for (let match = topLevelKeyRegex.exec(content); match !== null; match = topLevelKeyRegex.exec(content)) {
|
|
6599
|
-
const key = match[1];
|
|
6600
|
-
const offset = match.index;
|
|
6683
|
+
const key = expectDefined10(match[1]);
|
|
6684
|
+
const offset = match.index ?? 0;
|
|
6601
6685
|
const line = lineFromOffset(offset);
|
|
6602
6686
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6603
6687
|
let kind = "property";
|
|
@@ -6643,7 +6727,7 @@ function regexParse2(opts) {
|
|
|
6643
6727
|
const defsRegex = /"\$defs"\s*:|"\$defs"\s*:/g;
|
|
6644
6728
|
const defsMatch = defsRegex.exec(content);
|
|
6645
6729
|
if (defsMatch !== null) {
|
|
6646
|
-
const offset = defsMatch.index;
|
|
6730
|
+
const offset = expectDefined10(defsMatch.index);
|
|
6647
6731
|
const line = lineFromOffset(offset);
|
|
6648
6732
|
symbols.push(
|
|
6649
6733
|
makeSymbol({
|
|
@@ -6666,9 +6750,9 @@ function regexParse2(opts) {
|
|
|
6666
6750
|
for (const pat of defsPatterns) {
|
|
6667
6751
|
pat.lastIndex = 0;
|
|
6668
6752
|
for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
|
|
6669
|
-
const offset = match.index;
|
|
6753
|
+
const offset = match.index ?? 0;
|
|
6670
6754
|
const line = lineFromOffset(offset);
|
|
6671
|
-
const key = match[0]
|
|
6755
|
+
const key = match[0]?.match(/"([^"]+)"/)?.[1] ?? expectDefined10(match[0]);
|
|
6672
6756
|
symbols.push(
|
|
6673
6757
|
makeSymbol({
|
|
6674
6758
|
name: key,
|
|
@@ -6687,12 +6771,12 @@ function regexParse2(opts) {
|
|
|
6687
6771
|
function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset) {
|
|
6688
6772
|
const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
|
|
6689
6773
|
for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
|
|
6690
|
-
const blockContent = match[0];
|
|
6691
|
-
const blockOffset = match.index;
|
|
6774
|
+
const blockContent = expectDefined10(match[0]);
|
|
6775
|
+
const blockOffset = match.index ?? 0;
|
|
6692
6776
|
const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
|
|
6693
6777
|
for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
|
|
6694
|
-
const key = scriptMatch[1];
|
|
6695
|
-
const keyOffset = blockOffset + scriptMatch.index;
|
|
6778
|
+
const key = expectDefined10(scriptMatch[1]);
|
|
6779
|
+
const keyOffset = blockOffset + expectDefined10(scriptMatch.index);
|
|
6696
6780
|
const line = lineFromOffset(keyOffset);
|
|
6697
6781
|
symbols.push(
|
|
6698
6782
|
makeSymbol({
|
|
@@ -6711,12 +6795,12 @@ function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFr
|
|
|
6711
6795
|
function extractCompilerOptions(content, symbols, file, lang, lineOffsets, parentLine, lineFromOffset) {
|
|
6712
6796
|
const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
|
|
6713
6797
|
for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
|
|
6714
|
-
const blockContent = match[0];
|
|
6715
|
-
const blockOffset = match.index;
|
|
6798
|
+
const blockContent = expectDefined10(match[0]);
|
|
6799
|
+
const blockOffset = match.index ?? 0;
|
|
6716
6800
|
const optKeyRegex = /"(\w[\w]*)"\s*:/g;
|
|
6717
6801
|
for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
|
|
6718
|
-
const key = optMatch[1];
|
|
6719
|
-
const keyOffset = blockOffset + optMatch.index;
|
|
6802
|
+
const key = expectDefined10(optMatch[1]);
|
|
6803
|
+
const keyOffset = blockOffset + expectDefined10(optMatch.index);
|
|
6720
6804
|
const line = lineFromOffset(keyOffset);
|
|
6721
6805
|
if (line <= parentLine) continue;
|
|
6722
6806
|
symbols.push(
|
|
@@ -6750,6 +6834,12 @@ function makeSymbol(opts) {
|
|
|
6750
6834
|
}
|
|
6751
6835
|
|
|
6752
6836
|
// src/codebase-index/yaml-parser.ts
|
|
6837
|
+
function expectDefined11(value) {
|
|
6838
|
+
if (value === null || value === void 0) {
|
|
6839
|
+
throw new Error("Expected value to be defined");
|
|
6840
|
+
}
|
|
6841
|
+
return value;
|
|
6842
|
+
}
|
|
6753
6843
|
function parseSymbols6(opts) {
|
|
6754
6844
|
const { file, content, lang } = opts;
|
|
6755
6845
|
try {
|
|
@@ -6764,22 +6854,22 @@ function regexParse3(opts) {
|
|
|
6764
6854
|
const lines = content.split("\n");
|
|
6765
6855
|
const lineOffsets = [0];
|
|
6766
6856
|
for (let i = 0; i < lines.length; i++) {
|
|
6767
|
-
lineOffsets.push(lineOffsets[i] + lines[i]
|
|
6857
|
+
lineOffsets.push((lineOffsets[i] ?? 0) + (lines[i]?.length ?? 0) + 1);
|
|
6768
6858
|
}
|
|
6769
6859
|
function lineFromOffset(offset) {
|
|
6770
6860
|
let lo = 0;
|
|
6771
6861
|
let hi = lineOffsets.length - 1;
|
|
6772
6862
|
while (lo < hi) {
|
|
6773
6863
|
const mid = lo + hi + 1 >>> 1;
|
|
6774
|
-
if (lineOffsets[mid] <= offset) lo = mid;
|
|
6864
|
+
if (expectDefined11(lineOffsets[mid]) <= offset) lo = mid;
|
|
6775
6865
|
else hi = mid - 1;
|
|
6776
6866
|
}
|
|
6777
6867
|
return lo + 1;
|
|
6778
6868
|
}
|
|
6779
6869
|
const anchorRegex = /&(\w[\w-]*)/g;
|
|
6780
6870
|
for (let match = anchorRegex.exec(content); match !== null; match = anchorRegex.exec(content)) {
|
|
6781
|
-
const name = match[1];
|
|
6782
|
-
const offset = match.index;
|
|
6871
|
+
const name = expectDefined11(match[1]);
|
|
6872
|
+
const offset = match.index ?? 0;
|
|
6783
6873
|
const line = lineFromOffset(offset);
|
|
6784
6874
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6785
6875
|
symbols.push(
|
|
@@ -6796,8 +6886,8 @@ function regexParse3(opts) {
|
|
|
6796
6886
|
}
|
|
6797
6887
|
const aliasRegex = /\*(\w[\w-]*)/g;
|
|
6798
6888
|
for (let match = aliasRegex.exec(content); match !== null; match = aliasRegex.exec(content)) {
|
|
6799
|
-
const name = match[1];
|
|
6800
|
-
const offset = match.index;
|
|
6889
|
+
const name = expectDefined11(match[1]);
|
|
6890
|
+
const offset = match.index ?? 0;
|
|
6801
6891
|
const line = lineFromOffset(offset);
|
|
6802
6892
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6803
6893
|
symbols.push(
|
|
@@ -6814,27 +6904,28 @@ function regexParse3(opts) {
|
|
|
6814
6904
|
}
|
|
6815
6905
|
const kvRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:/gm;
|
|
6816
6906
|
for (let match = kvRegex.exec(content); match !== null; match = kvRegex.exec(content)) {
|
|
6817
|
-
const indent = match[1]
|
|
6907
|
+
const indent = match[1]?.length ?? 0;
|
|
6818
6908
|
const key = match[2];
|
|
6819
|
-
|
|
6909
|
+
if (!key) continue;
|
|
6910
|
+
const offset = match.index ?? 0;
|
|
6820
6911
|
const line = lineFromOffset(offset);
|
|
6821
6912
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6822
6913
|
const lineContent = lines[line - 1] ?? "";
|
|
6823
6914
|
if (/^[|&>]/.test(lineContent.trim())) continue;
|
|
6824
6915
|
if (key === "---" || key === "...") continue;
|
|
6825
6916
|
if (indent > 12) continue;
|
|
6826
|
-
const value = extractValue(content, match.index);
|
|
6917
|
+
const value = extractValue(content, match.index ?? 0);
|
|
6827
6918
|
const kind = isScalar(value) ? "literal" : "property";
|
|
6828
6919
|
const signature = `${key}: ${truncate(value, 60)}`;
|
|
6829
6920
|
symbols.push(makeSymbol2({ name: key, kind, line, col, signature, file, lang }));
|
|
6830
6921
|
}
|
|
6831
6922
|
const listItemRegex = /^-(\s+)([^:#\s][^:#\s]*)\s*:/gm;
|
|
6832
6923
|
for (let match = listItemRegex.exec(content); match !== null; match = listItemRegex.exec(content)) {
|
|
6833
|
-
const key = match[2];
|
|
6834
|
-
const offset = match.index;
|
|
6924
|
+
const key = expectDefined11(match[2]);
|
|
6925
|
+
const offset = match.index ?? 0;
|
|
6835
6926
|
const line = lineFromOffset(offset);
|
|
6836
6927
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6837
|
-
const value = extractValue(content, offset + match[0]
|
|
6928
|
+
const value = extractValue(content, offset + match[0]?.length);
|
|
6838
6929
|
const kind = isScalar(value) ? "literal" : "property";
|
|
6839
6930
|
symbols.push(
|
|
6840
6931
|
makeSymbol2({
|
|
@@ -6850,8 +6941,8 @@ function regexParse3(opts) {
|
|
|
6850
6941
|
}
|
|
6851
6942
|
const blockScalarRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:\s*[|>](\s|$)/gm;
|
|
6852
6943
|
for (let match = blockScalarRegex.exec(content); match !== null; match = blockScalarRegex.exec(content)) {
|
|
6853
|
-
const key = match[2];
|
|
6854
|
-
const offset = match.index;
|
|
6944
|
+
const key = expectDefined11(match[2]);
|
|
6945
|
+
const offset = match.index ?? 0;
|
|
6855
6946
|
const line = lineFromOffset(offset);
|
|
6856
6947
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
6857
6948
|
symbols.push(
|
|
@@ -7070,6 +7161,12 @@ function cancelPendingReindexes() {
|
|
|
7070
7161
|
}
|
|
7071
7162
|
|
|
7072
7163
|
// src/codebase-index/indexer.ts
|
|
7164
|
+
function expectDefined12(value) {
|
|
7165
|
+
if (value === null || value === void 0) {
|
|
7166
|
+
throw new Error("Expected value to be defined");
|
|
7167
|
+
}
|
|
7168
|
+
return value;
|
|
7169
|
+
}
|
|
7073
7170
|
var YIELD_EVERY_N = 50;
|
|
7074
7171
|
function yieldEventLoop() {
|
|
7075
7172
|
return new Promise((resolve7) => setImmediate(resolve7));
|
|
@@ -7178,7 +7275,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
7178
7275
|
for (const meta of store.getAllFileMetas()) existingMeta.set(meta.file, meta);
|
|
7179
7276
|
}
|
|
7180
7277
|
for (let fi = 0; fi < files.length; fi++) {
|
|
7181
|
-
const file = files[fi];
|
|
7278
|
+
const file = expectDefined12(files[fi]);
|
|
7182
7279
|
_setIndexProgress(fi + 1, files.length);
|
|
7183
7280
|
if (fi > 0 && fi % YIELD_EVERY_N === 0) {
|
|
7184
7281
|
await yieldEventLoop();
|
|
@@ -7235,7 +7332,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
7235
7332
|
langStats[lang] = (langStats[lang] ?? 0) + count;
|
|
7236
7333
|
if (parsed.refs && parsed.refs.length > 0) {
|
|
7237
7334
|
for (let i = 0; i < symbolsWithIds.length; i++) {
|
|
7238
|
-
const sym = symbolsWithIds[i];
|
|
7335
|
+
const sym = expectDefined12(symbolsWithIds[i]);
|
|
7239
7336
|
const symRefs = parsed.refs.filter((r) => r.line === sym.line);
|
|
7240
7337
|
if (symRefs.length > 0) {
|
|
7241
7338
|
const refsWithFromId = symRefs.map((r) => ({ ...r, fromId: sym.id }));
|
|
@@ -7406,6 +7503,12 @@ var Bm25Index = class {
|
|
|
7406
7503
|
};
|
|
7407
7504
|
|
|
7408
7505
|
// src/codebase-index/codebase-search-tool.ts
|
|
7506
|
+
function expectDefined13(value) {
|
|
7507
|
+
if (value === null || value === void 0) {
|
|
7508
|
+
throw new Error("Expected value to be defined");
|
|
7509
|
+
}
|
|
7510
|
+
return value;
|
|
7511
|
+
}
|
|
7409
7512
|
var codebaseSearchTool = {
|
|
7410
7513
|
name: "codebase-search",
|
|
7411
7514
|
category: "Project",
|
|
@@ -7495,7 +7598,7 @@ var codebaseSearchTool = {
|
|
|
7495
7598
|
const top = scored.slice(0, limit);
|
|
7496
7599
|
const qTokens = tokenise(input.query);
|
|
7497
7600
|
const results = top.map(({ id, score }) => {
|
|
7498
|
-
const c = candidates.find((c2) => c2.id === id);
|
|
7601
|
+
const c = expectDefined13(candidates.find((c2) => c2.id === id));
|
|
7499
7602
|
const snippet = bm25.extractSnippet(id, qTokens);
|
|
7500
7603
|
return {
|
|
7501
7604
|
...c,
|