fascicle 0.13.1 → 0.15.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 (45) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +20 -1
  3. package/dist/acp.d.ts +233 -0
  4. package/dist/acp.js +1919 -0
  5. package/dist/acp.js.map +1 -0
  6. package/dist/adapters.js +1 -2
  7. package/dist/agents.d.ts +1 -1
  8. package/dist/agents.js +1 -1
  9. package/dist/{core-DK7g1Z40.js → core-CDrz0NM1.js} +1 -12
  10. package/dist/core-CDrz0NM1.js.map +1 -0
  11. package/dist/diagram_bin.js +1 -1
  12. package/dist/{engine-BOGuc0X2.js → engine-ha9xmgwE.js} +528 -783
  13. package/dist/engine-ha9xmgwE.js.map +1 -0
  14. package/dist/index.d.ts +468 -622
  15. package/dist/index.js +20 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/{invoke-Beef3R3X.js → invoke-px31fffH.js} +97 -26
  18. package/dist/invoke-px31fffH.js.map +1 -0
  19. package/dist/json_schema_to_standard-BTWD0J6p.js +270 -0
  20. package/dist/json_schema_to_standard-BTWD0J6p.js.map +1 -0
  21. package/dist/leading_system-DfJLqpGi.js +584 -0
  22. package/dist/leading_system-DfJLqpGi.js.map +1 -0
  23. package/dist/mcp.d.ts +20 -19
  24. package/dist/mcp.js +5 -268
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/records-1HU7mWXf.js +22 -0
  27. package/dist/records-1HU7mWXf.js.map +1 -0
  28. package/dist/search-CA_OqFeW.js +579 -0
  29. package/dist/search-CA_OqFeW.js.map +1 -0
  30. package/dist/search_worker.d.ts +1 -0
  31. package/dist/search_worker.js +19 -0
  32. package/dist/search_worker.js.map +1 -0
  33. package/dist/stdio.js +1 -1
  34. package/dist/testing.d.ts +1 -1
  35. package/dist/testing.js +3 -2
  36. package/dist/testing.js.map +1 -1
  37. package/dist/{types-CZ83Q5nm.d.ts → types-De-TVQxS.d.ts} +49 -4
  38. package/dist/viewer-app/assets/index-Fnh5HKSU.js +2 -0
  39. package/dist/viewer-app/index.html +1 -1
  40. package/dist/viewer.js +1 -1
  41. package/package.json +30 -19
  42. package/dist/core-DK7g1Z40.js.map +0 -1
  43. package/dist/engine-BOGuc0X2.js.map +0 -1
  44. package/dist/invoke-Beef3R3X.js.map +0 -1
  45. package/dist/viewer-app/assets/index-DXsB0byD.js +0 -2
@@ -0,0 +1,579 @@
1
+ import { t as as_record } from "./records-1HU7mWXf.js";
2
+ import { t as json_schema_to_standard } from "./json_schema_to_standard-BTWD0J6p.js";
3
+ import { open, readdir, readlink, realpath, stat } from "node:fs/promises";
4
+ import { basename, dirname, extname, isAbsolute, join, matchesGlob, relative, resolve, sep } from "node:path";
5
+ import { Worker } from "node:worker_threads";
6
+ //#region src/acp/tools/containment.ts
7
+ /**
8
+ * Containment: the boundary the workspace file tools keep. A path, absolute
9
+ * or relative to the session's `cwd`, is allowed only when its real path
10
+ * lands under one of the session's roots, which are real paths themselves,
11
+ * resolved once at `session/new`.
12
+ *
13
+ * Real paths on both sides are the point. A symlink inside the workspace
14
+ * that points out of it is the classic escape, and checking the path as
15
+ * written would let it through. A `cwd` behind a symlink (macOS's `/tmp` and
16
+ * `/var` both are) would refuse every file in the project if the roots
17
+ * stayed as the client sent them. A path that doesn't exist yet resolves
18
+ * through its nearest existing ancestor, and a dangling symlink through its
19
+ * target, so a path outside the roots is refused the same way whether or
20
+ * not it exists.
21
+ */
22
+ /** The error codes that mean a path, or a directory on the way to it, doesn't exist. */
23
+ const MISSING = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
24
+ /**
25
+ * How many symlinks a missing path may pass through before resolving it
26
+ * gives up. `path.resolve` folds `missing/..` away where the kernel would
27
+ * fail on it, so a link such as `a -> missing/../a` would otherwise loop.
28
+ */
29
+ const MAX_LINK_HOPS = 40;
30
+ /**
31
+ * The code a Node file system error carries, such as `ENOENT`. Every
32
+ * caller hands in an error from `node:fs`, which always has one.
33
+ */
34
+ function error_code(err) {
35
+ return Reflect.get(Object(err), "code");
36
+ }
37
+ /**
38
+ * Resolve one root the client sent to its real path, refusing a relative
39
+ * path (which would resolve against wherever the agent was launched), a path
40
+ * that doesn't exist, and a file.
41
+ */
42
+ async function resolve_root(root) {
43
+ if (!isAbsolute(root)) throw new Error(`the workspace root ${root} is a relative path; send session/new with absolute paths`);
44
+ const real = await realpath(root).catch((err) => {
45
+ throw new Error(`the workspace root ${root} can't be opened (${String(error_code(err))}); send session/new with a directory that exists`);
46
+ });
47
+ if (!(await stat(real)).isDirectory()) throw new Error(`the workspace root ${root} is a file; send session/new with a directory`);
48
+ return real;
49
+ }
50
+ /**
51
+ * Resolve a session's roots (its `cwd`, then each additional directory) to
52
+ * their real paths, once, when the session starts. The error names the
53
+ * first root that isn't an absolute path to an existing directory.
54
+ */
55
+ async function resolve_roots(roots) {
56
+ return Promise.all(roots.map(resolve_root));
57
+ }
58
+ /**
59
+ * Whether `target` is `root` or lies beneath it. Both are compared as they
60
+ * are, so the caller hands in real paths for a containment check.
61
+ */
62
+ function is_within(root, target) {
63
+ return target === root || target.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
64
+ }
65
+ /**
66
+ * A symlink's target as written, or `undefined` when the path isn't a
67
+ * symlink or isn't there.
68
+ */
69
+ async function link_target(path) {
70
+ return readlink(path).catch(() => void 0);
71
+ }
72
+ /**
73
+ * The real path of `path`, existing or not. A path that exists is the file
74
+ * system's own answer. A missing one is its parent's real path plus its
75
+ * name, unless it's a dangling symlink, whose real path is its target's:
76
+ * writing through it would land there.
77
+ */
78
+ async function real_path(path, hops_left) {
79
+ try {
80
+ return await realpath(path);
81
+ } catch (err) {
82
+ if (!MISSING.has(error_code(err))) throw err;
83
+ }
84
+ const parent = await real_path(dirname(path), hops_left);
85
+ const target = await link_target(path);
86
+ if (target === void 0) return join(parent, basename(path));
87
+ if (hops_left === 0) throw new Error(`${path} passes through too many symbolic links to resolve`);
88
+ return real_path(resolve(parent, target), hops_left - 1);
89
+ }
90
+ /**
91
+ * Check that a path a tool was handed lands inside the session's workspace,
92
+ * and return it both ways. The refusal is an ordinary error naming the roots
93
+ * in the client's terms, since the model reads it as a tool result and can
94
+ * try a path that fits.
95
+ */
96
+ async function contain(session, requested) {
97
+ const path = resolve(session.cwd, requested);
98
+ const real = await real_path(path, MAX_LINK_HOPS);
99
+ if (session.roots.some((root) => is_within(root, real))) return {
100
+ path,
101
+ real
102
+ };
103
+ const allowed = [session.cwd, ...session.additional_directories].join(", ");
104
+ throw new Error(`${requested} is outside the workspace; the file tools only reach paths under ${allowed}`);
105
+ }
106
+ /**
107
+ * A path as a tool shows it to the model: relative to `cwd` when it's under
108
+ * it, and absolute otherwise, as for a file in an additional directory.
109
+ * Either form reads back through `contain`.
110
+ */
111
+ function shown_path(session, path) {
112
+ return is_within(session.cwd, path) ? relative(session.cwd, path) || "." : path;
113
+ }
114
+ //#endregion
115
+ //#region src/acp/tools/read_file.ts
116
+ /**
117
+ * read_file: read a text file in the workspace with its lines numbered, a
118
+ * window at a time.
119
+ *
120
+ * A window stops at `read_limit_lines` and says where the next one starts,
121
+ * and a line past LINE_WIDTH characters is cut with a marker, because a
122
+ * minified bundle or a source map can be one line of megabytes and nothing
123
+ * else keeps it out of the model's context. A file with a NUL byte in its
124
+ * first 8 KB is refused as binary, the test `examples/pr-improve` uses. The
125
+ * file streams line by line, so a window near the top of a huge file reads
126
+ * only as far as it shows.
127
+ */
128
+ /** The longest line `read_file` returns whole, the width Claude Code's Read cuts at. */
129
+ const LINE_WIDTH$1 = 2e3;
130
+ /** How much of a file's head is checked for a NUL byte, the sign of a binary file. */
131
+ const BINARY_SNIFF_BYTES = 8192;
132
+ /**
133
+ * Whether a value counts lines: a whole number of at least 1.
134
+ */
135
+ function is_count(value) {
136
+ return Number.isInteger(value) && Number(value) >= 1;
137
+ }
138
+ /**
139
+ * Read the call's window out of its input, with `limit` held to the cap.
140
+ * The tool loop has already checked the types against the schema, but a
141
+ * flow that wraps the tool can call `execute` directly, and the schema's
142
+ * `minimum` is advice to the model rather than something the loop enforces.
143
+ */
144
+ function read_request(input, read_limit_lines) {
145
+ const { path, offset = 1, limit = read_limit_lines } = as_record(input) ?? {};
146
+ if (typeof path !== "string") throw new Error("read_file needs a path, as a string");
147
+ if (!is_count(offset) || !is_count(limit)) throw new Error("read_file counts offset and limit in lines from 1, so each has to be a whole number of at least 1");
148
+ return {
149
+ path,
150
+ offset,
151
+ limit: Math.min(limit, read_limit_lines)
152
+ };
153
+ }
154
+ /**
155
+ * Whether the file's first BINARY_SNIFF_BYTES hold a NUL byte. `search`
156
+ * skips a file this calls binary, so the two tools agree on what is text.
157
+ */
158
+ async function is_binary(handle) {
159
+ const head = Buffer.alloc(BINARY_SNIFF_BYTES);
160
+ const { bytesRead } = await handle.read(head, 0, BINARY_SNIFF_BYTES, 0);
161
+ return head.subarray(0, bytesRead).includes(0);
162
+ }
163
+ /**
164
+ * One line as the model sees it: its number, a tab, and its text, cut at
165
+ * LINE_WIDTH with a marker that says how long it was.
166
+ */
167
+ function numbered(line_number, line) {
168
+ const text = line.length > LINE_WIDTH$1 ? `${line.slice(0, LINE_WIDTH$1)} [line cut at ${LINE_WIDTH$1} of ${line.length} characters]` : line;
169
+ return `${String(line_number).padStart(6)}\t${text}`;
170
+ }
171
+ /**
172
+ * Number the window's lines, reading one line past it to learn whether the
173
+ * file goes on, and say where to start the next read when it does.
174
+ */
175
+ async function read_lines(handle, request) {
176
+ const last = request.offset + request.limit - 1;
177
+ const shown = [];
178
+ let count = 0;
179
+ let more = false;
180
+ for await (const line of handle.readLines()) {
181
+ count += 1;
182
+ if (count > last) {
183
+ more = true;
184
+ break;
185
+ }
186
+ if (count >= request.offset) shown.push(numbered(count, line));
187
+ }
188
+ if (count === 0) return `${request.path} is empty`;
189
+ if (shown.length === 0) throw new Error(`offset ${request.offset} is past the end of ${request.path}, which has ${count} lines`);
190
+ const body = shown.join("\n");
191
+ if (!more) return body;
192
+ return `${body}\n\n[lines ${request.offset} to ${last} shown; the file goes on, so read on with offset ${last + 1}]`;
193
+ }
194
+ /**
195
+ * Read a contained file's window, refusing what isn't a regular text file.
196
+ * The type is checked before the file opens, since opening a FIFO would
197
+ * wait for a writer that never comes.
198
+ */
199
+ async function read_contained(real, request) {
200
+ const info = await stat(real).catch((err) => {
201
+ throw error_code(err) === "ENOENT" ? /* @__PURE__ */ new Error(`${request.path} doesn't exist`) : err;
202
+ });
203
+ if (info.isDirectory()) throw new Error(`${request.path} is a directory; list_files shows what's in it`);
204
+ if (!info.isFile()) throw new Error(`${request.path} isn't a regular file, so read_file can't read it`);
205
+ const handle = await open(real);
206
+ try {
207
+ if (await is_binary(handle)) throw new Error(`${request.path} is a binary file (it has a NUL byte in its first 8 KB), so read_file won't read it`);
208
+ return await read_lines(handle, request);
209
+ } finally {
210
+ await handle.close();
211
+ }
212
+ }
213
+ /**
214
+ * The `read_file` tool for one session: numbered lines from a file inside
215
+ * its workspace, at most `read_limit_lines` per call.
216
+ */
217
+ function read_file_tool(session, read_limit_lines) {
218
+ return {
219
+ name: "read_file",
220
+ description: `Read a text file in the workspace. Returns its lines numbered from 1, at most ${read_limit_lines} per call; pass offset (the first line to read) and limit to read part of a longer file. Lines over ${LINE_WIDTH$1} characters are cut. The path is absolute or relative to the workspace root.`,
221
+ input_schema: json_schema_to_standard({
222
+ type: "object",
223
+ properties: {
224
+ path: {
225
+ type: "string",
226
+ description: "The file to read, absolute or relative to the workspace root"
227
+ },
228
+ offset: {
229
+ type: "integer",
230
+ minimum: 1,
231
+ description: "The first line to read, counting from 1; default: 1"
232
+ },
233
+ limit: {
234
+ type: "integer",
235
+ minimum: 1,
236
+ description: `How many lines to read; default and most: ${read_limit_lines}`
237
+ }
238
+ },
239
+ required: ["path"],
240
+ additionalProperties: false
241
+ }),
242
+ execute: async (input) => {
243
+ const request = read_request(input, read_limit_lines);
244
+ const { real } = await contain(session, request.path);
245
+ return read_contained(real, request);
246
+ }
247
+ };
248
+ }
249
+ //#endregion
250
+ //#region src/acp/tools/list_files.ts
251
+ /** What `list_files` matches when the call names no pattern. */
252
+ const ALL_FILES$1 = "**/*";
253
+ /**
254
+ * Read the call's pattern and directory out of its input, refusing a
255
+ * pattern that reaches past the directory: it could never match, and the
256
+ * model is better told to pass the directory as `path`.
257
+ */
258
+ function list_request(input) {
259
+ const { pattern = ALL_FILES$1, path = "." } = as_record(input) ?? {};
260
+ if (typeof pattern !== "string" || typeof path !== "string") throw new Error("list_files takes its pattern and path as strings");
261
+ if (isAbsolute(pattern) || pattern.split(/[\\/]/).includes("..")) throw new Error(`list_files matches its pattern under path, so ${pattern} can't be absolute or climb with ..; pass the directory as path instead`);
262
+ return {
263
+ pattern,
264
+ path
265
+ };
266
+ }
267
+ /**
268
+ * Walk one directory, depth first: descend into each subdirectory and keep
269
+ * each regular file that matches, skipping ignored names. A symlink is
270
+ * neither a directory nor a file to a `readdir` entry, so the walk never
271
+ * follows one. `search` walks with it too, so both tools see the same files.
272
+ */
273
+ async function walk(directory, below, work) {
274
+ work.abort.throwIfAborted();
275
+ const entries = await readdir(directory, { withFileTypes: true });
276
+ for (const entry of entries) {
277
+ if (work.ignored.has(entry.name)) continue;
278
+ const relative = join(below, entry.name);
279
+ if (entry.isDirectory()) await walk(join(directory, entry.name), relative, work);
280
+ else if (entry.isFile() && matchesGlob(relative, work.pattern)) work.found.push(relative);
281
+ }
282
+ }
283
+ /**
284
+ * The files under the request's directory that match its pattern, in the
285
+ * model's terms and sorted.
286
+ */
287
+ async function matching_files(session, request, ignored, abort) {
288
+ const base = await contain(session, request.path);
289
+ if (!(await stat(base.real)).isDirectory()) throw new Error(`${request.path} is a file; list_files lists a directory, and read_file reads a file`);
290
+ const found = [];
291
+ await walk(base.real, "", {
292
+ pattern: request.pattern,
293
+ ignored,
294
+ abort,
295
+ found
296
+ });
297
+ return found.map((relative) => shown_path(session, join(base.path, relative))).toSorted();
298
+ }
299
+ /**
300
+ * The files as the model reads them, one to a line, and past `limit` the
301
+ * first `limit` of them with a note giving the total. The walk has already
302
+ * found every match to sort them, so the total costs nothing to count.
303
+ */
304
+ function listing(files, limit) {
305
+ if (files.length <= limit) return files.join("\n");
306
+ const note = `[the first ${limit} of ${files.length} files; narrow pattern or path to see the rest]`;
307
+ return [
308
+ ...files.slice(0, limit),
309
+ "",
310
+ note
311
+ ].join("\n");
312
+ }
313
+ /**
314
+ * The `list_files` tool for one session: the files under a directory in
315
+ * its workspace that match a glob, skipping the `ignore` names, at most
316
+ * `limit` per call.
317
+ */
318
+ function list_files_tool(session, ignore, limit) {
319
+ const ignored = new Set(ignore);
320
+ return {
321
+ name: "list_files",
322
+ description: [
323
+ `List the files in the workspace that match a glob pattern, one per line and at most ${limit} per call; a path under the workspace root is shown relative to it.`,
324
+ `The pattern matches under path (default: the workspace root) and defaults to ${ALL_FILES$1}.`,
325
+ "As in a shell, * and ** skip names that start with a dot, so name the dot to list hidden files (.github/**/*).",
326
+ ...ignore.length === 0 ? [] : [`Skips ${ignore.join(", ")}.`]
327
+ ].join(" "),
328
+ input_schema: json_schema_to_standard({
329
+ type: "object",
330
+ properties: {
331
+ pattern: {
332
+ type: "string",
333
+ description: `A glob such as src/**/*.ts; default: ${ALL_FILES$1}`
334
+ },
335
+ path: {
336
+ type: "string",
337
+ description: "The directory to search, absolute or relative to the workspace root; default: the root"
338
+ }
339
+ },
340
+ additionalProperties: false
341
+ }),
342
+ execute: async (input, ctx) => {
343
+ const request = list_request(input);
344
+ const files = await matching_files(session, request, ignored, ctx.abort);
345
+ return files.length === 0 ? `no files match ${request.pattern} under ${request.path}` : listing(files, limit);
346
+ }
347
+ };
348
+ }
349
+ //#endregion
350
+ //#region src/acp/tools/search.ts
351
+ /**
352
+ * search: find the lines in the workspace's files that match a regular
353
+ * expression.
354
+ *
355
+ * The pattern is the model's, and JavaScript's `RegExp` backtracks, so a
356
+ * pattern such as `(a+)+$` against one long line can run for minutes. No
357
+ * abort interrupts synchronous code, and one agent process serves every
358
+ * session, so a search on the main thread could leave even `session/cancel`
359
+ * unanswered. Each search runs in a worker thread instead, which the turn's
360
+ * abort and a time budget can terminate mid-match. The worker is a thin
361
+ * shell, `search_worker.ts`: what it runs is `search_files`, here, where
362
+ * the tests call it on the main thread.
363
+ *
364
+ * The search walks the files itself, with `list_files`' walk, rather than
365
+ * handing the work to `rg`, because the module keeps child processes to
366
+ * `run_command`.
367
+ */
368
+ /** What `search` matches when the call names no glob. */
369
+ const ALL_FILES = "**/*";
370
+ /** The most matches one call returns. */
371
+ const MATCH_LIMIT = 100;
372
+ /**
373
+ * The longest matching line shown whole. A longer one is shown as a window
374
+ * this wide around its match, since a minified bundle is one line of
375
+ * megabytes and every match in it would otherwise carry the whole line.
376
+ */
377
+ const LINE_WIDTH = 500;
378
+ /** How much of a long line its window shows before the match. */
379
+ const LINE_LEAD = 100;
380
+ /**
381
+ * The search worker, beside this module with its extension: `.ts` in the
382
+ * source tree, where vitest and Stryker run it, and `.js` once built.
383
+ */
384
+ const SEARCH_WORKER = new URL(`./search_worker${extname(import.meta.url)}`, import.meta.url);
385
+ /**
386
+ * Read the call's pattern, path, and glob out of its input. The pattern
387
+ * compiles in the worker, which reports one that isn't a regular expression
388
+ * with the engine's own message.
389
+ */
390
+ function search_request(input) {
391
+ const { pattern, path = ".", glob = ALL_FILES } = as_record(input) ?? {};
392
+ if (typeof pattern !== "string" || typeof path !== "string" || typeof glob !== "string") throw new Error("search needs a pattern, and takes its pattern, path, and glob as strings");
393
+ return {
394
+ pattern,
395
+ path,
396
+ glob
397
+ };
398
+ }
399
+ /**
400
+ * The glob as the walk matches it. Like `rg --glob`, a glob without a slash
401
+ * names files at any depth, so `*.ts` reaches `src/a.ts`, while one with a
402
+ * slash matches the path under the searched directory.
403
+ */
404
+ function walk_glob(glob) {
405
+ return glob.includes("/") ? glob : `**/${glob}`;
406
+ }
407
+ /**
408
+ * The files a job searches, relative to its base: the one file, or every
409
+ * file the walk keeps, sorted so the same search stops at the same match
410
+ * every time.
411
+ */
412
+ async function files_of(job) {
413
+ if (!job.directory) return [""];
414
+ const found = [];
415
+ const abort = new AbortController().signal;
416
+ await walk(job.base, "", {
417
+ pattern: job.glob,
418
+ ignored: new Set(job.ignore),
419
+ abort,
420
+ found
421
+ });
422
+ return found.toSorted();
423
+ }
424
+ /**
425
+ * A file's text, or nothing for a binary file, which then has no lines to
426
+ * search.
427
+ */
428
+ async function file_text(path) {
429
+ const handle = await open(path);
430
+ try {
431
+ return await is_binary(handle) ? "" : await handle.readFile("utf8");
432
+ } finally {
433
+ await handle.close();
434
+ }
435
+ }
436
+ /**
437
+ * A text's lines without their endings, and without the empty one after a
438
+ * final newline, which isn't a line of the file.
439
+ */
440
+ function lines_of(text) {
441
+ const lines = text.split(/\r?\n/);
442
+ if (lines.at(-1) === "") lines.pop();
443
+ return lines;
444
+ }
445
+ /**
446
+ * A matching line as `search` shows it: whole up to LINE_WIDTH characters,
447
+ * and past that, a window that wide starting LINE_LEAD characters before
448
+ * the match, kept inside the line, with the columns it covers.
449
+ */
450
+ function excerpt(line, at) {
451
+ if (line.length <= LINE_WIDTH) return line;
452
+ const start = Math.max(0, Math.min(at - LINE_LEAD, line.length - LINE_WIDTH));
453
+ return `${line.slice(start, start + LINE_WIDTH)} [columns ${start + 1} to ${start + LINE_WIDTH} of ${line.length}]`;
454
+ }
455
+ /**
456
+ * Search a job's files, in order, for the lines its pattern matches,
457
+ * stopping at the first match past the limit, which says there are more.
458
+ * The search worker runs this, and the tests call it on the main thread,
459
+ * where Stryker can switch its mutants on.
460
+ */
461
+ async function search_files(job) {
462
+ const regex = new RegExp(job.pattern);
463
+ const matches = [];
464
+ for (const file of await files_of(job)) for (const [index, line] of lines_of(await file_text(join(job.base, file))).entries()) {
465
+ const found = regex.exec(line);
466
+ if (found === null) continue;
467
+ if (matches.length === job.limit) return {
468
+ matches,
469
+ more: true
470
+ };
471
+ matches.push({
472
+ file,
473
+ line: index + 1,
474
+ text: excerpt(line, found.index)
475
+ });
476
+ }
477
+ return {
478
+ matches,
479
+ more: false
480
+ };
481
+ }
482
+ /**
483
+ * Run one job in a search worker. The turn's abort and the budget each
484
+ * terminate the thread, mid-match if need be, which nothing could do to a
485
+ * pattern running on the main thread. However the search ends, the abort
486
+ * listener and the budget's timer go with it.
487
+ */
488
+ async function in_worker(job, budget_ms, abort) {
489
+ abort.throwIfAborted();
490
+ const worker = new Worker(SEARCH_WORKER, { workerData: job });
491
+ const { promise, resolve, reject } = Promise.withResolvers();
492
+ const stop = (reason) => {
493
+ worker.terminate();
494
+ reject(reason);
495
+ };
496
+ const on_abort = () => {
497
+ stop(abort.reason);
498
+ };
499
+ const over_budget = /* @__PURE__ */ new Error(`search stopped after ${budget_ms / 1e3} s without finishing: the pattern may backtrack without end, as nested quantifiers such as (a+)+ can, or there may be too much to search; simplify the pattern, or narrow path or glob`);
500
+ const budget = setTimeout(stop, budget_ms, over_budget);
501
+ abort.addEventListener("abort", on_abort);
502
+ worker.once("message", resolve);
503
+ worker.once("error", reject);
504
+ try {
505
+ return await promise;
506
+ } finally {
507
+ clearTimeout(budget);
508
+ abort.removeEventListener("abort", on_abort);
509
+ }
510
+ }
511
+ /**
512
+ * The matches as the model reads them, one `path:line: text` to a line, and
513
+ * a note when the search stopped at its limit.
514
+ */
515
+ function report(session, base, request, result) {
516
+ if (result.matches.length === 0) return `no lines match ${request.pattern} under ${request.path} in files matching ${request.glob}`;
517
+ const lines = result.matches.map((match) => `${shown_path(session, join(base, match.file))}:${match.line}: ${match.text}`);
518
+ if (result.more) lines.push("", `[the first ${result.matches.length} matches; narrow the pattern, path, or glob to see the rest]`);
519
+ return lines.join("\n");
520
+ }
521
+ /**
522
+ * The `search` tool for one session: the lines under a path in its
523
+ * workspace that match a regular expression, skipping binary files and the
524
+ * `ignore` names, at most MATCH_LIMIT per call, each search in a worker
525
+ * that the turn's abort and `budget_ms` can terminate.
526
+ */
527
+ function search_tool(session, ignore, budget_ms) {
528
+ return {
529
+ name: "search",
530
+ description: [
531
+ `Search the workspace's files for lines that match a regular expression, at most ${MATCH_LIMIT} per call,`,
532
+ "each shown as path:line: text; a path under the workspace root is shown relative to it.",
533
+ "The pattern is a JavaScript regular expression matched against one line at a time; write (?i:...) for a part that ignores case.",
534
+ "path (default: the workspace root) is the directory to search, or a single file.",
535
+ "glob picks the files: without a slash it matches a file name at any depth (*.ts, *.{ts,tsx}),",
536
+ "and with one it matches the path under path (src/**/*.ts).",
537
+ "As in a shell, * and ** skip names that start with a dot, so name the dot to search hidden files (.github/**/*).",
538
+ ignore.length === 0 ? "Skips binary files." : `Skips binary files and ${ignore.join(", ")}.`
539
+ ].join(" "),
540
+ input_schema: json_schema_to_standard({
541
+ type: "object",
542
+ properties: {
543
+ pattern: {
544
+ type: "string",
545
+ description: "A JavaScript regular expression, such as function\\s+\\w+"
546
+ },
547
+ path: {
548
+ type: "string",
549
+ description: "The directory or file to search, absolute or relative to the workspace root; default: the root"
550
+ },
551
+ glob: {
552
+ type: "string",
553
+ description: `Which files to search, such as *.ts or src/**/*.ts; default: ${ALL_FILES}`
554
+ }
555
+ },
556
+ required: ["pattern"],
557
+ additionalProperties: false
558
+ }),
559
+ execute: async (input, ctx) => {
560
+ const request = search_request(input);
561
+ const base = await contain(session, request.path);
562
+ const info = await stat(base.real);
563
+ if (!info.isDirectory() && !info.isFile()) throw new Error(`${request.path} isn't a directory or a regular file, so search can't read it`);
564
+ const job = {
565
+ base: base.real,
566
+ directory: info.isDirectory(),
567
+ pattern: request.pattern,
568
+ glob: walk_glob(request.glob),
569
+ ignore,
570
+ limit: MATCH_LIMIT
571
+ };
572
+ return report(session, base.path, request, await in_worker(job, budget_ms, ctx.abort));
573
+ }
574
+ };
575
+ }
576
+ //#endregion
577
+ export { read_file_tool as a, resolve_roots as c, is_binary as i, shown_path as l, search_tool as n, contain as o, list_files_tool as r, error_code as s, search_files as t };
578
+
579
+ //# sourceMappingURL=search-CA_OqFeW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-CA_OqFeW.js","names":["LINE_WIDTH","ALL_FILES"],"sources":["../src/acp/tools/containment.ts","../src/acp/tools/read_file.ts","../src/acp/tools/list_files.ts","../src/acp/tools/search.ts"],"sourcesContent":["/**\n * Containment: the boundary the workspace file tools keep. A path, absolute\n * or relative to the session's `cwd`, is allowed only when its real path\n * lands under one of the session's roots, which are real paths themselves,\n * resolved once at `session/new`.\n *\n * Real paths on both sides are the point. A symlink inside the workspace\n * that points out of it is the classic escape, and checking the path as\n * written would let it through. A `cwd` behind a symlink (macOS's `/tmp` and\n * `/var` both are) would refuse every file in the project if the roots\n * stayed as the client sent them. A path that doesn't exist yet resolves\n * through its nearest existing ancestor, and a dangling symlink through its\n * target, so a path outside the roots is refused the same way whether or\n * not it exists.\n */\n\nimport { readlink, realpath, stat } from 'node:fs/promises'\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport type { AcpSession } from '../types.js'\n\n/** A path a tool may touch, both as the client names it and as the file system resolves it. */\nexport type ContainedPath = {\n /** Absolute, under the `cwd` the client sent: what the client and the model are shown. */\n readonly path: string\n /** Symlinks resolved: what the tool opens. */\n readonly real: string\n}\n\n/** The error codes that mean a path, or a directory on the way to it, doesn't exist. */\nconst MISSING: ReadonlySet<unknown> = new Set(['ENOENT', 'ENOTDIR'])\n\n/**\n * How many symlinks a missing path may pass through before resolving it\n * gives up. `path.resolve` folds `missing/..` away where the kernel would\n * fail on it, so a link such as `a -> missing/../a` would otherwise loop.\n */\nconst MAX_LINK_HOPS = 40\n\n/**\n * The code a Node file system error carries, such as `ENOENT`. Every\n * caller hands in an error from `node:fs`, which always has one.\n */\nexport function error_code(err: unknown): unknown {\n return Reflect.get(Object(err), 'code')\n}\n\n/**\n * Resolve one root the client sent to its real path, refusing a relative\n * path (which would resolve against wherever the agent was launched), a path\n * that doesn't exist, and a file.\n */\nasync function resolve_root(root: string): Promise<string> {\n if (!isAbsolute(root)) {\n throw new Error(`the workspace root ${root} is a relative path; send session/new with absolute paths`)\n }\n const real = await realpath(root).catch((err: unknown) => {\n throw new Error(\n `the workspace root ${root} can't be opened (${String(error_code(err))}); send session/new with a directory that exists`,\n )\n })\n if (!(await stat(real)).isDirectory()) {\n throw new Error(`the workspace root ${root} is a file; send session/new with a directory`)\n }\n return real\n}\n\n/**\n * Resolve a session's roots (its `cwd`, then each additional directory) to\n * their real paths, once, when the session starts. The error names the\n * first root that isn't an absolute path to an existing directory.\n */\nexport async function resolve_roots(roots: ReadonlyArray<string>): Promise<string[]> {\n return Promise.all(roots.map(resolve_root))\n}\n\n/**\n * Whether `target` is `root` or lies beneath it. Both are compared as they\n * are, so the caller hands in real paths for a containment check.\n */\nfunction is_within(root: string, target: string): boolean {\n return target === root || target.startsWith(root.endsWith(sep) ? root : `${root}${sep}`)\n}\n\n/**\n * A symlink's target as written, or `undefined` when the path isn't a\n * symlink or isn't there.\n */\nasync function link_target(path: string): Promise<string | undefined> {\n return readlink(path).catch(() => undefined)\n}\n\n/**\n * The real path of `path`, existing or not. A path that exists is the file\n * system's own answer. A missing one is its parent's real path plus its\n * name, unless it's a dangling symlink, whose real path is its target's:\n * writing through it would land there.\n */\nasync function real_path(path: string, hops_left: number): Promise<string> {\n try {\n return await realpath(path)\n } catch (err: unknown) {\n if (!MISSING.has(error_code(err))) throw err\n }\n const parent = await real_path(dirname(path), hops_left)\n const target = await link_target(path)\n if (target === undefined) return join(parent, basename(path))\n if (hops_left === 0) throw new Error(`${path} passes through too many symbolic links to resolve`)\n return real_path(resolve(parent, target), hops_left - 1)\n}\n\n/**\n * Check that a path a tool was handed lands inside the session's workspace,\n * and return it both ways. The refusal is an ordinary error naming the roots\n * in the client's terms, since the model reads it as a tool result and can\n * try a path that fits.\n */\nexport async function contain(session: AcpSession, requested: string): Promise<ContainedPath> {\n const path = resolve(session.cwd, requested)\n const real = await real_path(path, MAX_LINK_HOPS)\n if (session.roots.some((root) => is_within(root, real))) return { path, real }\n const allowed = [session.cwd, ...session.additional_directories].join(', ')\n throw new Error(`${requested} is outside the workspace; the file tools only reach paths under ${allowed}`)\n}\n\n/**\n * A path as a tool shows it to the model: relative to `cwd` when it's under\n * it, and absolute otherwise, as for a file in an additional directory.\n * Either form reads back through `contain`.\n */\nexport function shown_path(session: AcpSession, path: string): string {\n return is_within(session.cwd, path) ? relative(session.cwd, path) || '.' : path\n}\n","/**\n * read_file: read a text file in the workspace with its lines numbered, a\n * window at a time.\n *\n * A window stops at `read_limit_lines` and says where the next one starts,\n * and a line past LINE_WIDTH characters is cut with a marker, because a\n * minified bundle or a source map can be one line of megabytes and nothing\n * else keeps it out of the model's context. A file with a NUL byte in its\n * first 8 KB is refused as binary, the test `examples/pr-improve` uses. The\n * file streams line by line, so a window near the top of a huge file reads\n * only as far as it shows.\n */\n\nimport { open, stat } from 'node:fs/promises'\nimport type { FileHandle } from 'node:fs/promises'\nimport type { Tool } from '#engine'\nimport { as_record, json_schema_to_standard } from '#schema'\nimport type { AcpSession } from '../types.js'\nimport { contain, error_code } from './containment.js'\n\n/** The longest line `read_file` returns whole, the width Claude Code's Read cuts at. */\nconst LINE_WIDTH = 2000\n\n/** How much of a file's head is checked for a NUL byte, the sign of a binary file. */\nconst BINARY_SNIFF_BYTES = 8192\n\n/** One read: the path as the model gave it, and the lines it covers. */\ntype ReadRequest = {\n readonly path: string\n readonly offset: number\n readonly limit: number\n}\n\n/**\n * Whether a value counts lines: a whole number of at least 1.\n */\nfunction is_count(value: unknown): value is number {\n return Number.isInteger(value) && Number(value) >= 1\n}\n\n/**\n * Read the call's window out of its input, with `limit` held to the cap.\n * The tool loop has already checked the types against the schema, but a\n * flow that wraps the tool can call `execute` directly, and the schema's\n * `minimum` is advice to the model rather than something the loop enforces.\n */\nfunction read_request(input: unknown, read_limit_lines: number): ReadRequest {\n const fields: Record<string, unknown> = as_record(input) ?? {}\n const { path, offset = 1, limit = read_limit_lines } = fields\n if (typeof path !== 'string') throw new Error('read_file needs a path, as a string')\n if (!is_count(offset) || !is_count(limit)) {\n throw new Error('read_file counts offset and limit in lines from 1, so each has to be a whole number of at least 1')\n }\n return { path, offset, limit: Math.min(limit, read_limit_lines) }\n}\n\n/**\n * Whether the file's first BINARY_SNIFF_BYTES hold a NUL byte. `search`\n * skips a file this calls binary, so the two tools agree on what is text.\n */\nexport async function is_binary(handle: FileHandle): Promise<boolean> {\n const head = Buffer.alloc(BINARY_SNIFF_BYTES)\n const { bytesRead } = await handle.read(head, 0, BINARY_SNIFF_BYTES, 0)\n return head.subarray(0, bytesRead).includes(0)\n}\n\n/**\n * One line as the model sees it: its number, a tab, and its text, cut at\n * LINE_WIDTH with a marker that says how long it was.\n */\nfunction numbered(line_number: number, line: string): string {\n const text =\n line.length > LINE_WIDTH ? `${line.slice(0, LINE_WIDTH)} [line cut at ${LINE_WIDTH} of ${line.length} characters]` : line\n return `${String(line_number).padStart(6)}\\t${text}`\n}\n\n/**\n * Number the window's lines, reading one line past it to learn whether the\n * file goes on, and say where to start the next read when it does.\n */\nasync function read_lines(handle: FileHandle, request: ReadRequest): Promise<string> {\n const last = request.offset + request.limit - 1\n const shown: string[] = []\n let count = 0\n let more = false\n // The binary check reads at an explicit position, which leaves the\n // handle's own position at the top, where these lines start.\n for await (const line of handle.readLines()) {\n count += 1\n if (count > last) {\n more = true\n break\n }\n if (count >= request.offset) shown.push(numbered(count, line))\n }\n if (count === 0) return `${request.path} is empty`\n if (shown.length === 0) {\n throw new Error(`offset ${request.offset} is past the end of ${request.path}, which has ${count} lines`)\n }\n const body = shown.join('\\n')\n if (!more) return body\n return `${body}\\n\\n[lines ${request.offset} to ${last} shown; the file goes on, so read on with offset ${last + 1}]`\n}\n\n/**\n * Read a contained file's window, refusing what isn't a regular text file.\n * The type is checked before the file opens, since opening a FIFO would\n * wait for a writer that never comes.\n */\nasync function read_contained(real: string, request: ReadRequest): Promise<string> {\n const info = await stat(real).catch((err: unknown) => {\n throw error_code(err) === 'ENOENT' ? new Error(`${request.path} doesn't exist`) : err\n })\n if (info.isDirectory()) throw new Error(`${request.path} is a directory; list_files shows what's in it`)\n if (!info.isFile()) throw new Error(`${request.path} isn't a regular file, so read_file can't read it`)\n const handle = await open(real)\n try {\n if (await is_binary(handle)) {\n throw new Error(`${request.path} is a binary file (it has a NUL byte in its first 8 KB), so read_file won't read it`)\n }\n return await read_lines(handle, request)\n } finally {\n await handle.close()\n }\n}\n\n/**\n * The `read_file` tool for one session: numbered lines from a file inside\n * its workspace, at most `read_limit_lines` per call.\n */\nexport function read_file_tool(session: AcpSession, read_limit_lines: number): Tool {\n return {\n name: 'read_file',\n description:\n `Read a text file in the workspace. Returns its lines numbered from 1, at most ${read_limit_lines} per call; ` +\n `pass offset (the first line to read) and limit to read part of a longer file. ` +\n `Lines over ${LINE_WIDTH} characters are cut. The path is absolute or relative to the workspace root.`,\n input_schema: json_schema_to_standard({\n type: 'object',\n properties: {\n path: { type: 'string', description: 'The file to read, absolute or relative to the workspace root' },\n offset: { type: 'integer', minimum: 1, description: 'The first line to read, counting from 1; default: 1' },\n limit: {\n type: 'integer',\n minimum: 1,\n description: `How many lines to read; default and most: ${read_limit_lines}`,\n },\n },\n required: ['path'],\n additionalProperties: false,\n }),\n execute: async (input) => {\n const request = read_request(input, read_limit_lines)\n const { real } = await contain(session, request.path)\n return read_contained(real, request)\n },\n }\n}\n","/**\n * list_files: list the workspace's files that match a glob.\n *\n * It walks the directory itself and matches each file with `path`'s\n * `matchesGlob`, rather than handing the walk to `fs/promises`' `glob`.\n * That `glob` steps through a symlinked directory whenever a pattern names\n * it, passes over its `exclude` callback for a pattern that names its\n * segments, swallows a directory it can't read, and, with an `exclude`\n * callback under Stryker's runner, dropped a whole directory it had already\n * listed. The walk here never follows a symlink and never enters an ignored\n * name, so every file it lists lies under the searched directory, which\n * `contain` has already placed inside a root, and its matches follow the\n * same glob rules as `glob`'s.\n */\n\nimport type { Dirent } from 'node:fs'\nimport { readdir, stat } from 'node:fs/promises'\nimport { isAbsolute, join, matchesGlob } from 'node:path'\nimport type { Tool } from '#engine'\nimport { as_record, json_schema_to_standard } from '#schema'\nimport type { AcpSession } from '../types.js'\nimport { contain, shown_path } from './containment.js'\n\n/** What `list_files` matches when the call names no pattern. */\nconst ALL_FILES = '**/*'\n\n/** One listing: the glob, and the directory it runs in, as the model gave them. */\ntype ListRequest = {\n readonly pattern: string\n readonly path: string\n}\n\n/** What one walk needs besides the directory it's in. */\nexport type Walk = {\n readonly pattern: string\n readonly ignored: ReadonlySet<string>\n readonly abort: AbortSignal\n readonly found: string[]\n}\n\n/**\n * Read the call's pattern and directory out of its input, refusing a\n * pattern that reaches past the directory: it could never match, and the\n * model is better told to pass the directory as `path`.\n */\nfunction list_request(input: unknown): ListRequest {\n const fields: Record<string, unknown> = as_record(input) ?? {}\n const { pattern = ALL_FILES, path = '.' } = fields\n if (typeof pattern !== 'string' || typeof path !== 'string') {\n throw new Error('list_files takes its pattern and path as strings')\n }\n if (isAbsolute(pattern) || pattern.split(/[\\\\/]/).includes('..')) {\n throw new Error(\n `list_files matches its pattern under path, so ${pattern} can't be absolute or climb with ..; pass the directory as path instead`,\n )\n }\n return { pattern, path }\n}\n\n/**\n * Walk one directory, depth first: descend into each subdirectory and keep\n * each regular file that matches, skipping ignored names. A symlink is\n * neither a directory nor a file to a `readdir` entry, so the walk never\n * follows one. `search` walks with it too, so both tools see the same files.\n */\nexport async function walk(directory: string, below: string, work: Walk): Promise<void> {\n work.abort.throwIfAborted()\n const entries: Dirent[] = await readdir(directory, { withFileTypes: true })\n for (const entry of entries) {\n if (work.ignored.has(entry.name)) continue\n const relative = join(below, entry.name)\n if (entry.isDirectory()) await walk(join(directory, entry.name), relative, work)\n else if (entry.isFile() && matchesGlob(relative, work.pattern)) work.found.push(relative)\n }\n}\n\n/**\n * The files under the request's directory that match its pattern, in the\n * model's terms and sorted.\n */\nasync function matching_files(\n session: AcpSession,\n request: ListRequest,\n ignored: ReadonlySet<string>,\n abort: AbortSignal,\n): Promise<string[]> {\n const base = await contain(session, request.path)\n if (!(await stat(base.real)).isDirectory()) {\n throw new Error(`${request.path} is a file; list_files lists a directory, and read_file reads a file`)\n }\n const found: string[] = []\n await walk(base.real, '', { pattern: request.pattern, ignored, abort, found })\n return found.map((relative) => shown_path(session, join(base.path, relative))).toSorted()\n}\n\n/**\n * The files as the model reads them, one to a line, and past `limit` the\n * first `limit` of them with a note giving the total. The walk has already\n * found every match to sort them, so the total costs nothing to count.\n */\nfunction listing(files: ReadonlyArray<string>, limit: number): string {\n if (files.length <= limit) return files.join('\\n')\n const note = `[the first ${limit} of ${files.length} files; narrow pattern or path to see the rest]`\n return [...files.slice(0, limit), '', note].join('\\n')\n}\n\n/**\n * The `list_files` tool for one session: the files under a directory in\n * its workspace that match a glob, skipping the `ignore` names, at most\n * `limit` per call.\n */\nexport function list_files_tool(session: AcpSession, ignore: ReadonlyArray<string>, limit: number): Tool {\n const ignored = new Set(ignore)\n return {\n name: 'list_files',\n description: [\n `List the files in the workspace that match a glob pattern, one per line and at most ${limit} per call; a path under the workspace root is shown relative to it.`,\n `The pattern matches under path (default: the workspace root) and defaults to ${ALL_FILES}.`,\n 'As in a shell, * and ** skip names that start with a dot, so name the dot to list hidden files (.github/**/*).',\n ...(ignore.length === 0 ? [] : [`Skips ${ignore.join(', ')}.`]),\n ].join(' '),\n input_schema: json_schema_to_standard({\n type: 'object',\n properties: {\n pattern: { type: 'string', description: `A glob such as src/**/*.ts; default: ${ALL_FILES}` },\n path: {\n type: 'string',\n description: 'The directory to search, absolute or relative to the workspace root; default: the root',\n },\n },\n additionalProperties: false,\n }),\n execute: async (input, ctx) => {\n const request = list_request(input)\n const files = await matching_files(session, request, ignored, ctx.abort)\n return files.length === 0 ? `no files match ${request.pattern} under ${request.path}` : listing(files, limit)\n },\n }\n}\n","/**\n * search: find the lines in the workspace's files that match a regular\n * expression.\n *\n * The pattern is the model's, and JavaScript's `RegExp` backtracks, so a\n * pattern such as `(a+)+$` against one long line can run for minutes. No\n * abort interrupts synchronous code, and one agent process serves every\n * session, so a search on the main thread could leave even `session/cancel`\n * unanswered. Each search runs in a worker thread instead, which the turn's\n * abort and a time budget can terminate mid-match. The worker is a thin\n * shell, `search_worker.ts`: what it runs is `search_files`, here, where\n * the tests call it on the main thread.\n *\n * The search walks the files itself, with `list_files`' walk, rather than\n * handing the work to `rg`, because the module keeps child processes to\n * `run_command`.\n */\n\nimport { open, stat } from 'node:fs/promises'\nimport { extname, join } from 'node:path'\nimport { Worker } from 'node:worker_threads'\nimport type { Tool } from '#engine'\nimport { as_record, json_schema_to_standard } from '#schema'\nimport type { AcpSession } from '../types.js'\nimport { contain, shown_path } from './containment.js'\nimport { walk } from './list_files.js'\nimport { is_binary } from './read_file.js'\n\n/** What `search` matches when the call names no glob. */\nconst ALL_FILES = '**/*'\n\n/** The most matches one call returns. */\nconst MATCH_LIMIT = 100\n\n/**\n * The longest matching line shown whole. A longer one is shown as a window\n * this wide around its match, since a minified bundle is one line of\n * megabytes and every match in it would otherwise carry the whole line.\n */\nconst LINE_WIDTH = 500\n\n/** How much of a long line its window shows before the match. */\nconst LINE_LEAD = 100\n\n/**\n * The search worker, beside this module with its extension: `.ts` in the\n * source tree, where vitest and Stryker run it, and `.js` once built.\n */\nconst SEARCH_WORKER = new URL(`./search_worker${extname(import.meta.url)}`, import.meta.url)\n\n/** One search as the model asked for it. */\ntype SearchRequest = {\n readonly pattern: string\n readonly path: string\n readonly glob: string\n}\n\n/** One search as the worker runs it: plain data, since it crosses to another thread. */\ntype SearchJob = {\n /** The real path of the directory to walk, or of the one file to search. */\n readonly base: string\n readonly directory: boolean\n readonly pattern: string\n /** The glob as the walk matches it, relative to `base`. */\n readonly glob: string\n readonly ignore: ReadonlyArray<string>\n readonly limit: number\n}\n\n/**\n * One matching line: its file relative to the job's base (empty when the\n * base is that file), its number counting from 1, and its text.\n */\ntype SearchMatch = {\n readonly file: string\n readonly line: number\n readonly text: string\n}\n\n/** The matches, and whether the search stopped at its limit with more to find. */\ntype SearchResult = {\n readonly matches: ReadonlyArray<SearchMatch>\n readonly more: boolean\n}\n\n/**\n * Read the call's pattern, path, and glob out of its input. The pattern\n * compiles in the worker, which reports one that isn't a regular expression\n * with the engine's own message.\n */\nfunction search_request(input: unknown): SearchRequest {\n const fields: Record<string, unknown> = as_record(input) ?? {}\n const { pattern, path = '.', glob = ALL_FILES } = fields\n if (typeof pattern !== 'string' || typeof path !== 'string' || typeof glob !== 'string') {\n throw new Error('search needs a pattern, and takes its pattern, path, and glob as strings')\n }\n return { pattern, path, glob }\n}\n\n/**\n * The glob as the walk matches it. Like `rg --glob`, a glob without a slash\n * names files at any depth, so `*.ts` reaches `src/a.ts`, while one with a\n * slash matches the path under the searched directory.\n */\nfunction walk_glob(glob: string): string {\n return glob.includes('/') ? glob : `**/${glob}`\n}\n\n/**\n * The files a job searches, relative to its base: the one file, or every\n * file the walk keeps, sorted so the same search stops at the same match\n * every time.\n */\nasync function files_of(job: SearchJob): Promise<string[]> {\n if (!job.directory) return ['']\n const found: string[] = []\n // Nothing inside the worker cancels the walk: the turn's abort and the\n // budget terminate the whole thread instead.\n const abort = new AbortController().signal\n await walk(job.base, '', { pattern: job.glob, ignored: new Set(job.ignore), abort, found })\n return found.toSorted()\n}\n\n/**\n * A file's text, or nothing for a binary file, which then has no lines to\n * search.\n */\nasync function file_text(path: string): Promise<string> {\n const handle = await open(path)\n try {\n // The binary check reads at an explicit position, which leaves the\n // handle's own position at the top, where readFile starts.\n return (await is_binary(handle)) ? '' : await handle.readFile('utf8')\n } finally {\n await handle.close()\n }\n}\n\n/**\n * A text's lines without their endings, and without the empty one after a\n * final newline, which isn't a line of the file.\n */\nfunction lines_of(text: string): string[] {\n const lines = text.split(/\\r?\\n/)\n if (lines.at(-1) === '') lines.pop()\n return lines\n}\n\n/**\n * A matching line as `search` shows it: whole up to LINE_WIDTH characters,\n * and past that, a window that wide starting LINE_LEAD characters before\n * the match, kept inside the line, with the columns it covers.\n */\nfunction excerpt(line: string, at: number): string {\n if (line.length <= LINE_WIDTH) return line\n const start = Math.max(0, Math.min(at - LINE_LEAD, line.length - LINE_WIDTH))\n return `${line.slice(start, start + LINE_WIDTH)} [columns ${start + 1} to ${start + LINE_WIDTH} of ${line.length}]`\n}\n\n/**\n * Search a job's files, in order, for the lines its pattern matches,\n * stopping at the first match past the limit, which says there are more.\n * The search worker runs this, and the tests call it on the main thread,\n * where Stryker can switch its mutants on.\n */\nexport async function search_files(job: SearchJob): Promise<SearchResult> {\n const regex = new RegExp(job.pattern)\n const matches: SearchMatch[] = []\n for (const file of await files_of(job)) {\n for (const [index, line] of lines_of(await file_text(join(job.base, file))).entries()) {\n const found = regex.exec(line)\n if (found === null) continue\n if (matches.length === job.limit) return { matches, more: true }\n matches.push({ file, line: index + 1, text: excerpt(line, found.index) })\n }\n }\n return { matches, more: false }\n}\n\n/**\n * Run one job in a search worker. The turn's abort and the budget each\n * terminate the thread, mid-match if need be, which nothing could do to a\n * pattern running on the main thread. However the search ends, the abort\n * listener and the budget's timer go with it.\n */\nasync function in_worker(job: SearchJob, budget_ms: number, abort: AbortSignal): Promise<SearchResult> {\n abort.throwIfAborted()\n const worker = new Worker(SEARCH_WORKER, { workerData: job })\n const { promise, resolve, reject } = Promise.withResolvers<SearchResult>()\n const stop = (reason: unknown): void => {\n void worker.terminate()\n reject(reason)\n }\n const on_abort = (): void => {\n stop(abort.reason)\n }\n const over_budget = new Error(\n `search stopped after ${budget_ms / 1000} s without finishing: the pattern may backtrack without end, ` +\n 'as nested quantifiers such as (a+)+ can, or there may be too much to search; ' +\n 'simplify the pattern, or narrow path or glob',\n )\n const budget = setTimeout(stop, budget_ms, over_budget)\n abort.addEventListener('abort', on_abort)\n worker.once('message', resolve)\n worker.once('error', reject)\n try {\n return await promise\n } finally {\n clearTimeout(budget)\n abort.removeEventListener('abort', on_abort)\n }\n}\n\n/**\n * The matches as the model reads them, one `path:line: text` to a line, and\n * a note when the search stopped at its limit.\n */\nfunction report(session: AcpSession, base: string, request: SearchRequest, result: SearchResult): string {\n if (result.matches.length === 0) {\n return `no lines match ${request.pattern} under ${request.path} in files matching ${request.glob}`\n }\n const lines = result.matches.map(\n (match) => `${shown_path(session, join(base, match.file))}:${match.line}: ${match.text}`,\n )\n if (result.more) {\n lines.push('', `[the first ${result.matches.length} matches; narrow the pattern, path, or glob to see the rest]`)\n }\n return lines.join('\\n')\n}\n\n/**\n * The `search` tool for one session: the lines under a path in its\n * workspace that match a regular expression, skipping binary files and the\n * `ignore` names, at most MATCH_LIMIT per call, each search in a worker\n * that the turn's abort and `budget_ms` can terminate.\n */\nexport function search_tool(session: AcpSession, ignore: ReadonlyArray<string>, budget_ms: number): Tool {\n return {\n name: 'search',\n description: [\n `Search the workspace's files for lines that match a regular expression, at most ${MATCH_LIMIT} per call,`,\n 'each shown as path:line: text; a path under the workspace root is shown relative to it.',\n 'The pattern is a JavaScript regular expression matched against one line at a time; write (?i:...) for a part that ignores case.',\n 'path (default: the workspace root) is the directory to search, or a single file.',\n 'glob picks the files: without a slash it matches a file name at any depth (*.ts, *.{ts,tsx}),',\n 'and with one it matches the path under path (src/**/*.ts).',\n 'As in a shell, * and ** skip names that start with a dot, so name the dot to search hidden files (.github/**/*).',\n ignore.length === 0 ? 'Skips binary files.' : `Skips binary files and ${ignore.join(', ')}.`,\n ].join(' '),\n input_schema: json_schema_to_standard({\n type: 'object',\n properties: {\n pattern: { type: 'string', description: 'A JavaScript regular expression, such as function\\\\s+\\\\w+' },\n path: {\n type: 'string',\n description: 'The directory or file to search, absolute or relative to the workspace root; default: the root',\n },\n glob: { type: 'string', description: `Which files to search, such as *.ts or src/**/*.ts; default: ${ALL_FILES}` },\n },\n required: ['pattern'],\n additionalProperties: false,\n }),\n execute: async (input, ctx) => {\n const request = search_request(input)\n const base = await contain(session, request.path)\n const info = await stat(base.real)\n if (!info.isDirectory() && !info.isFile()) {\n throw new Error(`${request.path} isn't a directory or a regular file, so search can't read it`)\n }\n const job: SearchJob = {\n base: base.real,\n directory: info.isDirectory(),\n pattern: request.pattern,\n glob: walk_glob(request.glob),\n ignore,\n limit: MATCH_LIMIT,\n }\n return report(session, base.path, request, await in_worker(job,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