@criogaid/pi-hashline-edit 0.7.0 → 0.8.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 (118) hide show
  1. package/README.md +74 -222
  2. package/README.zh-CN.md +162 -0
  3. package/package.json +2 -1
  4. package/src/core/AGENTS.md +1 -1
  5. package/src/core/apply.test.ts +172 -134
  6. package/src/core/apply.ts +28 -30
  7. package/src/core/case-fold.test.ts +11 -7
  8. package/src/core/case-fold.ts +2 -6
  9. package/src/core/character-set.ts +14 -0
  10. package/src/core/hash.test.ts +1 -25
  11. package/src/core/hash.ts +0 -5
  12. package/src/core/lines.ts +25 -7
  13. package/src/core/ranges.test.ts +41 -9
  14. package/src/core/ranges.ts +11 -4
  15. package/src/core/regex.ts +36 -6
  16. package/src/core/replace-schema.ts +18 -11
  17. package/src/core/replace.test.ts +90 -0
  18. package/src/core/replace.ts +6 -5
  19. package/src/core/search-analysis.test.ts +9 -0
  20. package/src/core/search-analysis.ts +35 -31
  21. package/src/core/search.ts +1 -1
  22. package/src/core/types.ts +5 -7
  23. package/src/index.ts +2 -4
  24. package/src/integration/config-registration.test.ts +16 -8
  25. package/src/integration/fusion-dispatch.test.ts +41 -22
  26. package/src/integration/grep-flags.test.ts +6 -13
  27. package/src/integration/grep-js-completeness.test.ts +41 -31
  28. package/src/integration/grep-order.test.ts +78 -0
  29. package/src/integration/grep-path-matrix.test.ts +4 -3
  30. package/src/integration/grep-regex.test.ts +13 -16
  31. package/src/integration/grep-rg.test.ts +127 -87
  32. package/src/integration/grep-scan-budget.test.ts +27 -5
  33. package/src/integration/large-text.test.ts +3 -4
  34. package/src/integration/model-budget-lifecycle.test.ts +15 -6
  35. package/src/integration/mutation-file-types.test.ts +0 -1
  36. package/src/integration/mutation-file-types.testing.ts +1 -1
  37. package/src/integration/npm-package.testing.ts +6 -32
  38. package/src/integration/publication-read-changes.test.ts +58 -26
  39. package/src/integration/replace-package.testing.ts +4 -1
  40. package/src/integration/replace-worker-boundary.test.ts +34 -24
  41. package/src/integration/report-replay.test.ts +2 -2
  42. package/src/integration/utf8-errors.test.ts +2 -2
  43. package/src/pi/AGENTS.md +12 -13
  44. package/src/pi/action-fusion.test.ts +71 -216
  45. package/src/pi/action-fusion.ts +37 -74
  46. package/src/pi/anchor-format.test.ts +16 -0
  47. package/src/pi/anchor-format.ts +7 -3
  48. package/src/pi/argument-diagnostics.ts +1 -1
  49. package/src/pi/argument-error.testing.ts +7 -4
  50. package/src/pi/argument-error.ts +5 -7
  51. package/src/pi/argument-format.test.ts +5 -16
  52. package/src/pi/argument-validation.test.ts +59 -25
  53. package/src/pi/argument-validation.ts +4 -5
  54. package/src/pi/budgets.ts +5 -7
  55. package/src/pi/config.test.ts +15 -5
  56. package/src/pi/config.ts +6 -6
  57. package/src/pi/diagnostic-buffer.test.ts +2 -3
  58. package/src/pi/diagnostic-buffer.ts +2 -2
  59. package/src/pi/edit-tool.ts +9 -12
  60. package/src/pi/execute.test.ts +80 -149
  61. package/src/pi/failure-context.test.ts +61 -16
  62. package/src/pi/failure-context.ts +12 -9
  63. package/src/pi/failure-path.test.ts +115 -50
  64. package/src/pi/file-commit.test.ts +30 -46
  65. package/src/pi/file-commit.ts +11 -40
  66. package/src/pi/file-revision.ts +25 -0
  67. package/src/pi/fusion-card-interaction.test.ts +143 -0
  68. package/src/pi/fusion-card.test.ts +193 -37
  69. package/src/pi/fusion-card.ts +186 -116
  70. package/src/pi/grep-candidates.ts +25 -27
  71. package/src/pi/grep-matrix.test.ts +1 -1
  72. package/src/pi/grep-order.test.ts +323 -0
  73. package/src/pi/grep-output.testing.ts +24 -0
  74. package/src/pi/grep-output.ts +62 -69
  75. package/src/pi/grep-render.ts +4 -1
  76. package/src/pi/grep-scope.ts +1 -1
  77. package/src/pi/grep-search.ts +85 -56
  78. package/src/pi/grep-tool.ts +17 -48
  79. package/src/pi/grep.test.ts +270 -169
  80. package/src/pi/mutation-outcome.testing.ts +2 -3
  81. package/src/pi/mutation-result.test.ts +26 -19
  82. package/src/pi/mutation-result.ts +25 -40
  83. package/src/pi/mutation-runner.ts +9 -17
  84. package/src/pi/output-budgets.test.ts +25 -16
  85. package/src/pi/path.ts +3 -1
  86. package/src/pi/pi.test.ts +4 -5
  87. package/src/pi/read-tool.ts +32 -80
  88. package/src/pi/read.test.ts +145 -92
  89. package/src/pi/regex-worker-contract.ts +5 -23
  90. package/src/pi/regex-worker.ts +4 -10
  91. package/src/pi/registration.test.ts +54 -49
  92. package/src/pi/render.test.ts +196 -93
  93. package/src/pi/render.ts +32 -22
  94. package/src/pi/replace-regex.ts +3 -5
  95. package/src/pi/replace-tool.ts +27 -26
  96. package/src/pi/replace-worker-contract.ts +3 -12
  97. package/src/pi/replace.test.ts +144 -226
  98. package/src/pi/report-cause.ts +23 -19
  99. package/src/pi/report-failure.testing.ts +2 -2
  100. package/src/pi/report-schema.ts +55 -43
  101. package/src/pi/report.test.ts +138 -71
  102. package/src/pi/report.ts +40 -43
  103. package/src/pi/result-safety.test.ts +157 -117
  104. package/src/pi/rg-process.test.ts +36 -10
  105. package/src/pi/rg-process.ts +9 -3
  106. package/src/pi/rg-regex.test.ts +17 -0
  107. package/src/pi/rg-regex.ts +28 -22
  108. package/src/pi/text-stream.test.ts +35 -36
  109. package/src/pi/text-stream.ts +14 -14
  110. package/src/pi/tool-call.testing.ts +17 -7
  111. package/src/pi/write-tool.ts +9 -11
  112. package/src/pi/write.test.ts +43 -75
  113. package/src/testing/regex-translation-corpus.ts +16 -0
  114. package/src/testing/rg-line-listing.fixture.mjs +1 -1
  115. package/src/integration/forget-grep.test.ts +0 -148
  116. package/src/pi/forget-tool.ts +0 -367
  117. package/src/pi/forget.test.ts +0 -630
  118. package/src/pi/forget.testing.ts +0 -201
@@ -7,6 +7,7 @@ import { DEFAULT_CONFIG } from "../pi/config.ts";
7
7
  import { MAX_MULTILINE_SEARCH_BYTES } from "../pi/grep-search.ts";
8
8
  import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
9
9
  import { reportOf } from "../pi/report.ts";
10
+ import { grepCounts } from "../pi/grep-output.testing.ts";
10
11
  import { COMMON_RG_ARGS, runRgLines, runRgPaths } from "../pi/rg-process.ts";
11
12
  import { searchText } from "../core/search.ts";
12
13
  import { callTool } from "../pi/tool-call.testing.ts";
@@ -34,8 +35,8 @@ test("JS grep: rg discovery retains ignore, hidden, glob, and binary rules", asy
34
35
  glob: "!excluded.txt",
35
36
  outputMode: "files",
36
37
  });
37
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
38
- assert.equal(reportOf(result)?.files, 3);
38
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
39
+ assert.equal(grepCounts(result).files, 3);
39
40
  const body = result.content[0];
40
41
  assert.ok(body.type === "text");
41
42
  for (const name of ["allowed.txt", ".hidden.txt", "child.txt"])
@@ -46,7 +47,7 @@ test("JS grep: rg discovery retains ignore, hidden, glob, and binary rules", asy
46
47
  path: join(directory, "ignored.txt"),
47
48
  glob: "*.txt",
48
49
  });
49
- assert.equal(reportOf(explicit)?.matches, 1);
50
+ assert.equal(grepCounts(explicit).matches, 1);
50
51
  });
51
52
 
52
53
  test("JS grep: physical rows, context, and limits agree across output modes", async (t) => {
@@ -57,10 +58,10 @@ test("JS grep: physical rows, context, and limits agree across output modes", as
57
58
  const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
58
59
  for (const outputMode of ["content", "files", "count"] as const) {
59
60
  const result = await callTool(tool, { ...query, path, outputMode, limit: 1, context: 1 });
60
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
61
- assert.equal(reportOf(result)?.matches, 1);
62
- assert.equal(reportOf(result)?.files, 1);
63
- assert.equal(reportOf(result)?.matchLimit, 1);
61
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
62
+ assert.equal(grepCounts(result).matches, 1);
63
+ assert.equal(grepCounts(result).files, 1);
64
+ assert.equal(reportOf(result, "grep")?.matchLimit, 1);
64
65
  const body = result.content[0];
65
66
  assert.ok(body.type === "text");
66
67
  if (outputMode === "content") {
@@ -80,9 +81,9 @@ test("JS grep: malformed UTF-8 matches the preview text without editable anchors
80
81
  await writeFile(path, Buffer.from([0x61, 0xff, 0x62, 0x0a]));
81
82
  const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
82
83
  const result = await callTool(tool, { path, pattern: "a.b", literal: false });
83
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
84
- assert.equal(reportOf(result)?.matches, 1);
85
- assert.equal(reportOf(result)?.invalidUtf8?.length, 1);
84
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
85
+ assert.equal(grepCounts(result).matches, 1);
86
+ assert.equal(reportOf(result, "grep")?.invalidUtf8?.length, 1);
86
87
  const body = result.content[0];
87
88
  assert.ok(body.type === "text");
88
89
  assert.match(body.text, /1│a�b/);
@@ -94,25 +95,34 @@ test("oversized line or multiline input → explicit incomplete-search diagnosti
94
95
  t.after(() => rm(directory, { recursive: true, force: true }));
95
96
  const path = join(directory, "large.txt");
96
97
  const good = join(directory, "good.txt");
97
- await writeFile(path, Buffer.alloc(MAX_MULTILINE_SEARCH_BYTES + 1, 0x61));
98
+ const oversized = Buffer.alloc(MAX_MULTILINE_SEARCH_BYTES + 1, 0x61);
98
99
  await writeFile(good, "a\n");
99
100
  const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
100
- for (const multiline of [false, true]) {
101
- for (const includeGood of [false, true]) {
102
- const result = await callTool(tool, {
103
- path: includeGood ? [path, good] : path,
104
- pattern: "a",
105
- literal: true,
106
- multiline,
107
- });
108
- assert.match(reportOf(result)?.diagnostics ?? "", /large\.txt/);
109
- if (includeGood) {
110
- assert.equal(result.isError, undefined);
111
- assert.equal(reportOf(result)?.matches, 1);
112
- assert.equal(result.details?.incomplete, true);
113
- } else {
114
- assert.equal(result.isError, true);
115
- assert.equal(reportOf(result)?.error, "SEARCH_INCOMPLETE");
101
+ for (const finalNewline of [false, true]) {
102
+ await writeFile(path, finalNewline ? Buffer.concat([oversized, Buffer.from("\n")]) : oversized);
103
+ for (const multiline of [false, true]) {
104
+ for (const includeGood of [false, true]) {
105
+ await t.test(
106
+ `finalNewline=${finalNewline}, multiline=${multiline}, includeGood=${includeGood}`,
107
+ async () => {
108
+ const result = await callTool(tool, {
109
+ path: includeGood ? [path, good] : path,
110
+ pattern: "a",
111
+ literal: true,
112
+ multiline,
113
+ });
114
+ const diagnostics = reportOf(result, "grep")?.diagnostics ?? "";
115
+ assert.match(diagnostics, /large\.txt/);
116
+ assert.match(diagnostics, multiline ? /MiB/ : /UTF-16 code units/);
117
+ if (includeGood) {
118
+ assert.equal(result.isError, undefined);
119
+ assert.equal(grepCounts(result).matches, 1);
120
+ } else {
121
+ assert.equal(result.isError, true);
122
+ assert.equal(reportOf(result, "grep")?.error, "SEARCH_INCOMPLETE");
123
+ }
124
+ },
125
+ );
116
126
  }
117
127
  }
118
128
  }
@@ -177,10 +187,10 @@ test("real rg candidates → include every JS row and preserve confirmed output
177
187
  const params = { path: directory, pattern, flags, multiline, literal: false, outputMode };
178
188
  const actual = await callTool(filtered, params);
179
189
  const expected = await callTool(full, params);
180
- assert.equal(actual.isError, undefined, JSON.stringify(reportOf(actual)));
181
- assert.equal(expected.isError, undefined, JSON.stringify(reportOf(expected)));
182
- assert.equal(reportOf(actual)?.matches, matches);
183
- assert.equal(reportOf(expected)?.matches, matches);
190
+ assert.equal(actual.isError, undefined, JSON.stringify(reportOf(actual, "grep")));
191
+ assert.equal(expected.isError, undefined, JSON.stringify(reportOf(expected, "grep")));
192
+ assert.equal(grepCounts(actual).matches, matches);
193
+ assert.equal(grepCounts(expected).matches, matches);
184
194
  const actualText = actual.content[0];
185
195
  const expectedText = expected.content[0];
186
196
  assert.ok(actualText.type === "text" && expectedText.type === "text");
@@ -0,0 +1,78 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { test } from "node:test";
6
+ import { computeLineHash } from "../core/hash.ts";
7
+ import { DEFAULT_CONFIG } from "../pi/config.ts";
8
+ import { parseFileHeader } from "../pi/grep-output.ts";
9
+ import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
10
+ import { reportOf } from "../pi/report.ts";
11
+ import { callTool } from "../pi/tool-call.testing.ts";
12
+
13
+ test("repeated real-rg query with increasing limits → stable traversal order and a growing row prefix", async (t) => {
14
+ const dir = await mkdtemp(join(tmpdir(), "hl-grep-order-integration-"));
15
+ t.after(() => rm(dir, { recursive: true, force: true }));
16
+ await mkdir(join(dir, "sub"));
17
+ await writeFile(join(dir, ".ignore"), "a-ignored.txt\n");
18
+ const names = ["z.txt", "sub/b.txt", "sub.txt", "a.txt", "sub/a-ignored.txt"];
19
+ const sourceLine = (name: string, line: number) => `needle ${name} ${line}`;
20
+ for (const name of names) {
21
+ await writeFile(join(dir, name), `${sourceLine(name, 1)}\n${sourceLine(name, 2)}\n`);
22
+ }
23
+ const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
24
+ for (const [roots, expectedNames] of [
25
+ [["."], ["a.txt", "sub/b.txt", "sub.txt", "z.txt"]],
26
+ [
27
+ ["z.txt", "sub", "a.txt"],
28
+ ["z.txt", "sub/b.txt", "a.txt"],
29
+ ],
30
+ [
31
+ ["sub", ".", "sub/a-ignored.txt"],
32
+ ["sub/b.txt", "a.txt", "sub.txt", "z.txt", "sub/a-ignored.txt"],
33
+ ],
34
+ [
35
+ ["sub/a-ignored.txt", ".", "a.txt"],
36
+ ["sub/a-ignored.txt", "a.txt", "sub/b.txt", "sub.txt", "z.txt"],
37
+ ],
38
+ ]) {
39
+ const expected = expectedNames.flatMap((name) =>
40
+ [1, 2].map((line) => {
41
+ const source = sourceLine(name, line);
42
+ return `${name}\n${line}#${computeLineHash(line, source, DEFAULT_CONFIG.hashLen)}│${source}`;
43
+ }),
44
+ );
45
+ for (const multiline of [false, true]) {
46
+ await t.test(JSON.stringify({ roots, multiline }), async () => {
47
+ let previous: string[] = [];
48
+ for (const limit of [1, 3, expected.length]) {
49
+ const query = {
50
+ path: roots.map((root) => join(dir, root)),
51
+ pattern: "needle",
52
+ literal: true,
53
+ multiline,
54
+ limit,
55
+ };
56
+ const first = await callTool(tool, query);
57
+ const second = await callTool(tool, query);
58
+ for (const result of [first, second]) {
59
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
60
+ }
61
+ assert.deepEqual(first.content, second.content);
62
+ const body = first.content[0];
63
+ assert.ok(body.type === "text");
64
+ const rows: string[] = [];
65
+ let path = "";
66
+ for (const line of body.text.split("\n")) {
67
+ const header = parseFileHeader(line);
68
+ if (header) path = header.path;
69
+ else if (/^\d+#[0-9A-Z]+│/.test(line)) rows.push(`${path}\n${line}`);
70
+ }
71
+ assert.deepEqual(rows, expected.slice(0, limit));
72
+ assert.deepEqual(rows.slice(0, previous.length), previous);
73
+ previous = rows;
74
+ }
75
+ });
76
+ }
77
+ }
78
+ });
@@ -7,6 +7,7 @@ import { DEFAULT_GREP_FLAGS, searchText } from "../core/search.ts";
7
7
  import { DEFAULT_CONFIG } from "../pi/config.ts";
8
8
  import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
9
9
  import { reportOf } from "../pi/report.ts";
10
+ import { grepCounts } from "../pi/grep-output.testing.ts";
10
11
  import { runRgLines, runRgPaths } from "../pi/rg-process.ts";
11
12
  import { callTool } from "../pi/tool-call.testing.ts";
12
13
  import { acceptsNative } from "../core/search-matrix.testing.ts";
@@ -83,14 +84,14 @@ test("Cartesian literal mode × flags × case override × line mode × bytes →
83
84
  assert.equal(
84
85
  actual.isError,
85
86
  undefined,
86
- `${context}: ${JSON.stringify(reportOf(actual))}`,
87
+ `${context}: ${JSON.stringify(reportOf(actual, "grep"))}`,
87
88
  );
88
89
  assert.equal(
89
- reportOf(actual)?.matches,
90
+ grepCounts(actual).matches,
90
91
  expected.reduce((sum, input) => sum + input.rows.length, 0),
91
92
  context,
92
93
  );
93
- assert.equal(reportOf(actual)?.files, expected.length, context);
94
+ assert.equal(grepCounts(actual).files, expected.length, context);
94
95
  for (const input of expected) {
95
96
  nativeMatchingFiles++;
96
97
  assert.ok(candidates.has(input.name), `${context}: rg dropped ${input.name}`);
@@ -7,6 +7,7 @@ import { rejectsArgument } from "../pi/argument-error.testing.ts";
7
7
  import { DEFAULT_CONFIG } from "../pi/config.ts";
8
8
  import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
9
9
  import { reportOf } from "../pi/report.ts";
10
+ import { grepCounts } from "../pi/grep-output.testing.ts";
10
11
  import { callTool } from "../pi/tool-call.testing.ts";
11
12
  import { unsupportedByHost } from "../testing/regex-host.testing.ts";
12
13
 
@@ -229,14 +230,14 @@ test("regex and case modes across line endings → real grep agrees with native
229
230
  ignoreCase: scenario.ignoreCase,
230
231
  multiline,
231
232
  });
232
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
233
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
233
234
  const body = result.content[0];
234
235
  assert.ok(body.type === "text");
235
236
  const actual = [...body.text.matchAll(/^(\d+)#[0-9A-Z]+│/gm)].map((match) =>
236
237
  Number(match[1]),
237
238
  );
238
239
  assert.deepEqual(actual, expected);
239
- assert.equal(reportOf(result)?.matches, expected.length);
240
+ assert.equal(grepCounts(result).matches, expected.length);
240
241
  },
241
242
  );
242
243
  }
@@ -259,7 +260,7 @@ test("malformed UTF-8 → character classes match replacement characters in the
259
260
  ]) {
260
261
  const result = await callTool(tool, { path, pattern, literal: false, ignoreCase: false });
261
262
  assert.equal(result.isError, undefined);
262
- assert.equal(reportOf(result)?.matches, 2);
263
+ assert.equal(grepCounts(result).matches, 2);
263
264
  const body = result.content[0];
264
265
  assert.ok(body.type === "text");
265
266
  assert.match(body.text, /2│axb/);
@@ -281,8 +282,8 @@ test("backreference regression: a capture spanning mixed line endings → matche
281
282
  multiline: true,
282
283
  ignoreCase: false,
283
284
  });
284
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
285
- assert.equal(reportOf(result)?.matches, 2);
285
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
286
+ assert.equal(grepCounts(result).matches, 2);
286
287
  } finally {
287
288
  await rm(dir, { recursive: true, force: true });
288
289
  }
@@ -301,7 +302,7 @@ test("backreference regression: ignoreCase with an ASCII capture → does not ma
301
302
  ignoreCase: true,
302
303
  });
303
304
  assert.equal(result.isError, undefined, JSON.stringify(result));
304
- assert.equal(reportOf(result)?.matches, 0);
305
+ assert.equal(grepCounts(result).matches, 0);
305
306
  } finally {
306
307
  await rm(dir, { recursive: true, force: true });
307
308
  }
@@ -339,7 +340,7 @@ test("zero-maximum quantifiers → real grep matches the active capture", async
339
340
  ignoreCase,
340
341
  });
341
342
  assert.equal(result.isError, undefined, JSON.stringify(result));
342
- assert.equal(reportOf(result)?.matches, 1);
343
+ assert.equal(grepCounts(result).matches, 1);
343
344
  } finally {
344
345
  await rm(dir, { recursive: true, force: true });
345
346
  }
@@ -347,16 +348,12 @@ test("zero-maximum quantifiers → real grep matches the active capture", async
347
348
  }
348
349
  });
349
350
 
350
- test("JS syntax boundary rejects rg-only syntax and executes constructs requiring JS", async (t) => {
351
+ test("JS syntax boundary → executes constructs requiring JS", async (t) => {
351
352
  const dir = await mkdtemp(join(tmpdir(), "hashline-grep-strict-js-"));
352
353
  t.after(() => rm(dir, { recursive: true, force: true }));
353
354
  const path = join(dir, "input.txt");
354
355
  await writeFile(path, "😀\naba\nab\n");
355
356
  const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
356
- await assert.rejects(
357
- () => callTool(tool, { path, pattern: "(?i)abc", literal: false }),
358
- rejectsArgument("pattern"),
359
- );
360
357
  for (const pattern of [
361
358
  "^..$",
362
359
  "^[^a]{2}$",
@@ -367,9 +364,9 @@ test("JS syntax boundary rejects rg-only syntax and executes constructs requirin
367
364
  ]) {
368
365
  await t.test(pattern, async () => {
369
366
  const result = await callTool(tool, { path, pattern, literal: false, ignoreCase: false });
370
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
367
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
371
368
  assert.equal(
372
- reportOf(result)?.matches,
369
+ grepCounts(result).matches,
373
370
  jsLines("😀\naba\nab\n", [pattern], false, false).length,
374
371
  );
375
372
  });
@@ -399,12 +396,12 @@ test("zero-width assertions at LF and CRLF boundaries → match only empty physi
399
396
  ignoreCase: false,
400
397
  multiline,
401
398
  });
402
- assert.equal(result.isError, undefined, JSON.stringify(reportOf(result)));
399
+ assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
403
400
  const body = result.content[0];
404
401
  assert.ok(body.type === "text");
405
402
  const lines = [...body.text.matchAll(/^(\d+)#[0-9A-Z]+│/gm)].map((match) => Number(match[1]));
406
403
  assert.deepEqual(lines, [4, 6]);
407
- assert.equal(reportOf(result)?.matches, 2);
404
+ assert.equal(grepCounts(result).matches, 2);
408
405
  });
409
406
  }
410
407
  });