@criogaid/pi-hashline-edit 0.10.0 → 0.12.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 (103) hide show
  1. package/README.md +21 -7
  2. package/README.zh-CN.md +22 -8
  3. package/package.json +7 -6
  4. package/src/core/AGENTS.md +2 -2
  5. package/src/core/apply.test.ts +4 -4
  6. package/src/core/apply.ts +3 -3
  7. package/src/core/character-set.test.ts +2 -3
  8. package/src/core/character-set.ts +1 -1
  9. package/src/core/ranges.test.ts +2 -1
  10. package/src/core/ranges.ts +1 -1
  11. package/src/core/regex.ts +6 -2
  12. package/src/core/replace.test.ts +51 -0
  13. package/src/core/replace.ts +10 -4
  14. package/src/core/types.ts +1 -1
  15. package/src/index.ts +9 -9
  16. package/src/integration/config-registration.test.ts +8 -10
  17. package/src/integration/fusion-dispatch.test.ts +2 -2
  18. package/src/integration/grep-errors.test.ts +3 -3
  19. package/src/integration/grep-flags.test.ts +5 -5
  20. package/src/integration/grep-js-completeness.test.ts +12 -11
  21. package/src/integration/grep-line-candidates.test.ts +5 -3
  22. package/src/integration/grep-matrix.test.ts +5 -4
  23. package/src/integration/grep-order.test.ts +4 -4
  24. package/src/integration/grep-path-matrix.test.ts +5 -4
  25. package/src/integration/grep-prefilter-coverage.test.ts +17 -5
  26. package/src/integration/grep-process-limits.test.ts +2 -4
  27. package/src/integration/grep-regex.test.ts +10 -10
  28. package/src/integration/grep-rg.test.ts +93 -48
  29. package/src/integration/grep-scan-budget.test.ts +8 -8
  30. package/src/integration/grep-translation.test.ts +8 -7
  31. package/src/integration/large-text.test.ts +5 -5
  32. package/src/integration/model-budget-lifecycle.test.ts +9 -9
  33. package/src/integration/mutation-file-types.testing.ts +4 -4
  34. package/src/integration/npm-package.test.ts +12 -10
  35. package/src/integration/npm-package.testing.ts +151 -4
  36. package/src/integration/publication-read-changes.test.ts +54 -54
  37. package/src/integration/read-changes.test.ts +4 -4
  38. package/src/integration/replace-worker-boundary.test.ts +1 -1
  39. package/src/integration/report-replay.test.ts +9 -6
  40. package/src/integration/utf8-errors.test.ts +4 -4
  41. package/src/pi/AGENTS.md +13 -12
  42. package/src/pi/action-fusion.test.ts +125 -105
  43. package/src/pi/action-fusion.testing.ts +38 -0
  44. package/src/pi/action-fusion.ts +9 -21
  45. package/src/pi/argument-diagnostics.ts +4 -3
  46. package/src/pi/argument-format.test.ts +19 -18
  47. package/src/pi/argument-validation.test.ts +281 -139
  48. package/src/pi/argument-validation.ts +21 -31
  49. package/src/pi/budgets.ts +1 -4
  50. package/src/pi/codemode.test.ts +7 -2
  51. package/src/pi/config.test.ts +2 -1
  52. package/src/pi/config.ts +8 -3
  53. package/src/pi/diagnostic-buffer.test.ts +23 -13
  54. package/src/pi/edit-tool.ts +48 -63
  55. package/src/pi/error-text.ts +7 -2
  56. package/src/pi/execute.test.ts +178 -157
  57. package/src/pi/failure-context.test.ts +5 -4
  58. package/src/pi/failure-context.ts +1 -1
  59. package/src/pi/failure-path.test.ts +37 -37
  60. package/src/pi/file-commit.test.ts +47 -19
  61. package/src/pi/file-commit.ts +36 -9
  62. package/src/pi/fusion-card.test.ts +22 -21
  63. package/src/pi/fusion-card.ts +9 -5
  64. package/src/pi/grep-candidates.test.ts +18 -20
  65. package/src/pi/grep-candidates.ts +13 -17
  66. package/src/pi/grep-matrix.test.ts +3 -3
  67. package/src/pi/grep-order.test.ts +12 -11
  68. package/src/pi/grep-output.ts +45 -17
  69. package/src/pi/grep-reread.ts +7 -2
  70. package/src/pi/grep-rg.testing.ts +70 -0
  71. package/src/pi/grep-scope.ts +10 -10
  72. package/src/pi/grep-search.ts +8 -11
  73. package/src/pi/grep-tool.ts +40 -53
  74. package/src/pi/grep.test.ts +141 -116
  75. package/src/pi/model-budgets.test.ts +2 -1
  76. package/src/pi/mutation-outcome.testing.ts +0 -1
  77. package/src/pi/mutation-result.test.ts +8 -8
  78. package/src/pi/mutation-result.ts +1 -1
  79. package/src/pi/mutation-runner.ts +10 -6
  80. package/src/pi/output-budgets.test.ts +53 -31
  81. package/src/pi/pi.test.ts +18 -13
  82. package/src/pi/read-tool.ts +13 -18
  83. package/src/pi/read.test.ts +67 -41
  84. package/src/pi/registration.test.ts +25 -19
  85. package/src/pi/render.test.ts +94 -32
  86. package/src/pi/render.ts +7 -4
  87. package/src/pi/replace-regex.ts +1 -1
  88. package/src/pi/replace-tool.ts +6 -16
  89. package/src/pi/replace.test.ts +45 -34
  90. package/src/pi/report-failure.testing.ts +9 -1
  91. package/src/pi/report-schema.ts +225 -86
  92. package/src/pi/report.test.ts +81 -87
  93. package/src/pi/report.ts +35 -22
  94. package/src/pi/result-safety.test.ts +121 -100
  95. package/src/pi/rg-process.test.ts +2 -2
  96. package/src/pi/rg-process.ts +9 -15
  97. package/src/pi/rg-regex.test.ts +13 -0
  98. package/src/pi/rg-regex.ts +2 -2
  99. package/src/pi/schema.ts +23 -0
  100. package/src/pi/tool-factories.testing.ts +59 -0
  101. package/src/pi/write-tool.ts +9 -15
  102. package/src/pi/write.test.ts +30 -31
  103. package/src/testing/run-tests.ts +1 -1
@@ -1,13 +1,14 @@
1
+ import { makeMockGrep } from "../pi/grep-rg.testing.ts";
1
2
  import assert from "node:assert/strict";
2
3
  import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
3
4
  import { tmpdir } from "node:os";
4
5
  import { join } from "node:path";
5
6
  import { test } from "node:test";
6
- import { DEFAULT_CONFIG } from "../pi/config.ts";
7
- import { MAX_MULTILINE_SEARCH_BYTES } from "../pi/grep-search.ts";
8
- import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
7
+ const { DEFAULT_CONFIG, makeGrepOverride } = await import("../pi/tool-factories.testing.ts");
8
+ const MAX_MULTILINE_SEARCH_BYTES = 64 * 1024 * 1024;
9
+
9
10
  import { reportOf } from "../pi/report.ts";
10
- import { grepCounts } from "../pi/grep-output.testing.ts";
11
+ const { grepCounts } = await import("../pi/grep-output.testing.ts");
11
12
  import { COMMON_RG_ARGS, runRgLines, runRgPaths } from "../pi/rg-process.ts";
12
13
  import { searchText } from "../core/search.ts";
13
14
  import { callTool } from "../pi/tool-call.testing.ts";
@@ -28,7 +29,7 @@ test("JS grep: rg discovery retains ignore, hidden, glob, and binary rules", asy
28
29
  await writeFile(join(directory, name), "😀\n");
29
30
  await writeFile(join(directory, ".ignore"), "ignored.txt\n");
30
31
  await writeFile(join(directory, "binary.txt"), "😀\n\0");
31
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
32
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
32
33
  const result = await callTool(tool, {
33
34
  ...query,
34
35
  path: directory,
@@ -55,7 +56,7 @@ test("JS grep: physical rows, context, and limits agree across output modes", as
55
56
  t.after(() => rm(directory, { recursive: true, force: true }));
56
57
  const path = join(directory, "input.txt");
57
58
  await writeFile(path, "head\r\n😀\r\nab\ntail\n");
58
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
59
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
59
60
  for (const outputMode of ["content", "files", "count"] as const) {
60
61
  const result = await callTool(tool, { ...query, path, outputMode, limit: 1, context: 1 });
61
62
  assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
@@ -79,7 +80,7 @@ test("JS grep: malformed UTF-8 matches the preview text without editable anchors
79
80
  t.after(() => rm(directory, { recursive: true, force: true }));
80
81
  const path = join(directory, "invalid.txt");
81
82
  await writeFile(path, Buffer.from([0x61, 0xff, 0x62, 0x0a]));
82
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
83
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
83
84
  const result = await callTool(tool, { path, pattern: "a.b", literal: false });
84
85
  assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
85
86
  assert.equal(grepCounts(result).matches, 1);
@@ -97,7 +98,7 @@ test("oversized line or multiline input → explicit incomplete-search diagnosti
97
98
  const good = join(directory, "good.txt");
98
99
  const oversized = Buffer.alloc(MAX_MULTILINE_SEARCH_BYTES + 1, 0x61);
99
100
  await writeFile(good, "a\n");
100
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
101
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
101
102
  for (const finalNewline of [false, true]) {
102
103
  await writeFile(path, finalNewline ? Buffer.concat([oversized, Buffer.from("\n")]) : oversized);
103
104
  for (const multiline of [false, true]) {
@@ -147,7 +148,7 @@ test("real rg candidates → include every JS row and preserve confirmed output
147
148
  ] as const) {
148
149
  await t.test(`${pattern} /${flags} → identical confirmed results`, async () => {
149
150
  const candidates = new Map<string, readonly number[] | undefined>();
150
- const filtered = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {
151
+ const filtered = makeMockGrep(directory, DEFAULT_CONFIG, {
151
152
  runRgPaths(args, signal, onPath) {
152
153
  return runRgPaths(args, signal, (path) => {
153
154
  candidates.set(path, undefined);
@@ -161,7 +162,7 @@ test("real rg candidates → include every JS row and preserve confirmed output
161
162
  });
162
163
  },
163
164
  });
164
- const full = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {
165
+ const full = makeMockGrep(directory, DEFAULT_CONFIG, {
165
166
  runRgPaths(args, signal, onPath) {
166
167
  const scopeStart = args.indexOf("--null");
167
168
  assert.ok(scopeStart >= 0);
@@ -221,7 +222,7 @@ test("NUL past a search limit → skips oversized line and multiline files witho
221
222
  const path = join(directory, "large-nul.txt");
222
223
  // Place NUL beyond the chunk that first exceeds the search limit.
223
224
  const bytes = Buffer.alloc(MAX_MULTILINE_SEARCH_BYTES + 1024 * 1024, 0x61);
224
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
225
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
225
226
  for (const hasNul of [true, false]) {
226
227
  bytes[bytes.length - 1] = hasNul ? 0 : 0x61;
227
228
  await writeFile(path, bytes);
@@ -1,3 +1,4 @@
1
+ import { searchWithMockRg } from "../pi/grep-rg.testing.ts";
1
2
  import assert from "node:assert/strict";
2
3
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
4
  import { tmpdir } from "node:os";
@@ -5,7 +6,7 @@ import { join } from "node:path";
5
6
  import { test } from "node:test";
6
7
  import { acceptsNative } from "../core/search-matrix.testing.ts";
7
8
  import { searchText, type GrepQuery } from "../core/search.ts";
8
- import { searchFiles, type GrepFileMatch } from "../pi/grep-search.ts";
9
+ import type { GrepFileMatch } from "../pi/grep-search.ts";
9
10
  import { lineCandidatePatterns } from "../pi/rg-regex.ts";
10
11
  import { runRgLines } from "../pi/rg-process.ts";
11
12
  import { REGEX_TRANSLATION_CORPUS } from "../testing/regex-translation-corpus.ts";
@@ -84,6 +85,7 @@ const patterns = [
84
85
  "([[a]--[A]])(?i:\\1)",
85
86
  "((?-i:[[a]--[A]]))(?i:\\1)",
86
87
  "((?-i:[\\q{a|b}]))(?i:\\1)",
88
+ "([\\q{a}])\\1",
87
89
  "((?-i:a))(?i:\\1)",
88
90
  "(?i:([\\q{ks|ab}]))\\1",
89
91
  "[\\q{\\u0558|a}&&\\p{Letter}]",
@@ -125,7 +127,7 @@ const patterns = [
125
127
  "(?m:b$)",
126
128
  ];
127
129
  const processTimeoutMs = 10_000;
128
- const matrixTimeoutMs = 180_000;
130
+ const matrixTimeoutMs = 5 * 60_000;
129
131
  const candidateLineLimit = 65_536;
130
132
 
131
133
  const sortedRows = (files: readonly Pick<GrepFileMatch, "filePath" | "rows">[]) =>
@@ -182,7 +184,7 @@ test("Cartesian adversarial bytes × syntax × flags × assertion positions →
182
184
  const translated = lineCandidatePatterns(query);
183
185
  assert.ok(translated, JSON.stringify(query));
184
186
  const candidates = new Map<string, readonly number[] | undefined>();
185
- const actual = await searchFiles({
187
+ const actual = await searchWithMockRg({
186
188
  backend: {
187
189
  async runRgPaths() {
188
190
  assert.fail(`unexpected file fallback: ${JSON.stringify(query)}`);
@@ -12,10 +12,11 @@ import {
12
12
  MATRIX_INPUTS,
13
13
  } from "../core/search-matrix.testing.ts";
14
14
  import { runRgPaths } from "../pi/rg-process.ts";
15
- import { candidateArgs } from "../pi/grep-candidates.ts";
15
+ import { fileCandidateArgs } from "../pi/grep-rg.testing.ts";
16
16
 
17
17
  interface CandidateCase {
18
18
  readonly prefilter: Prefilter;
19
+ readonly query: GrepQuery;
19
20
  readonly required: Map<string, GrepQuery>;
20
21
  }
21
22
 
@@ -43,7 +44,7 @@ async function checkCandidates(t: TestContext, queries: Iterable<{ readonly quer
43
44
  const key = JSON.stringify(prefilter);
44
45
  let group = groups.get(key);
45
46
  if (!group) {
46
- group = { prefilter, required: new Map() };
47
+ group = { prefilter, query, required: new Map() };
47
48
  groups.set(key, group);
48
49
  }
49
50
  for (const input of inputs) {
@@ -63,10 +64,10 @@ async function checkCandidates(t: TestContext, queries: Iterable<{ readonly quer
63
64
  const workers = await Promise.allSettled(
64
65
  Array.from({ length: concurrency }, async () => {
65
66
  while (next < cases.length) {
66
- const { prefilter, required } = cases[next++];
67
+ const { prefilter, query, required } = cases[next++];
67
68
  const actual = new Set<string>();
68
69
  const result = await runRgPaths(
69
- [...candidateArgs(prefilter), "--null", "--", directory],
70
+ [...(await fileCandidateArgs(query)), "--null", "--", directory],
70
71
  AbortSignal.timeout(processTimeoutMs),
71
72
  (path) => {
72
73
  actual.add(basename(path));
@@ -4,9 +4,9 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { test } from "node:test";
6
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";
7
+ const { DEFAULT_CONFIG, makeGrepOverride } = await import("../pi/tool-factories.testing.ts");
8
+ const { parseFileHeader } = await import("../pi/grep-output.ts");
9
+
10
10
  import { reportOf } from "../pi/report.ts";
11
11
  import { callTool } from "../pi/tool-call.testing.ts";
12
12
 
@@ -20,7 +20,7 @@ test("repeated real-rg query with increasing limits → stable traversal order a
20
20
  for (const name of names) {
21
21
  await writeFile(join(dir, name), `${sourceLine(name, 1)}\n${sourceLine(name, 2)}\n`);
22
22
  }
23
- const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
23
+ const tool = makeGrepOverride(dir, DEFAULT_CONFIG);
24
24
  for (const [roots, expectedNames] of [
25
25
  [["."], ["a.txt", "sub/b.txt", "sub.txt", "z.txt"]],
26
26
  [
@@ -1,13 +1,14 @@
1
+ import { makeMockGrep } from "../pi/grep-rg.testing.ts";
1
2
  import assert from "node:assert/strict";
2
3
  import { test } from "node:test";
3
4
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
4
5
  import { tmpdir } from "node:os";
5
6
  import { basename, join } from "node:path";
6
7
  import { DEFAULT_GREP_FLAGS, searchText } from "../core/search.ts";
7
- import { DEFAULT_CONFIG } from "../pi/config.ts";
8
- import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
8
+ const { DEFAULT_CONFIG } = await import("../pi/tool-factories.testing.ts");
9
+
9
10
  import { reportOf } from "../pi/report.ts";
10
- import { grepCounts } from "../pi/grep-output.testing.ts";
11
+ const { grepCounts } = await import("../pi/grep-output.testing.ts");
11
12
  import { runRgLines, runRgPaths } from "../pi/rg-process.ts";
12
13
  import { callTool } from "../pi/tool-call.testing.ts";
13
14
  import { acceptsNative } from "../core/search-matrix.testing.ts";
@@ -28,7 +29,7 @@ test("Cartesian literal mode × flags × case override × line mode × bytes →
28
29
  for (const input of inputs) await writeFile(join(directory, input.name), input.bytes);
29
30
  const limit = inputs.reduce((sum, input) => sum + input.bytes.length, 0);
30
31
  const candidates = new Map<string, readonly number[] | undefined>();
31
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {
32
+ const tool = makeMockGrep(directory, DEFAULT_CONFIG, {
32
33
  runRgPaths(args, signal, onPath) {
33
34
  return runRgPaths(args, signal, (path) => {
34
35
  candidates.set(basename(path), undefined);
@@ -12,7 +12,7 @@ import {
12
12
  } from "../core/search-matrix.testing.ts";
13
13
  import { searchText, type GrepQuery } from "../core/search.ts";
14
14
  import { runRgPaths } from "../pi/rg-process.ts";
15
- import { candidateArgs } from "../pi/grep-candidates.ts";
15
+ import { fileCandidateArgs } from "../pi/grep-rg.testing.ts";
16
16
 
17
17
  const syntaxCases = [
18
18
  ...MATRIX_SYNTAX,
@@ -41,6 +41,7 @@ const syntaxCases = [
41
41
 
42
42
  interface Coverage {
43
43
  queries: number;
44
+ rejected: number;
44
45
  fullScan: number;
45
46
  withHits: number;
46
47
  nativeFiles: number;
@@ -48,11 +49,12 @@ interface Coverage {
48
49
  }
49
50
 
50
51
  function emptyCoverage(): Coverage {
51
- return { queries: 0, fullScan: 0, withHits: 0, nativeFiles: 0, candidateFiles: 0 };
52
+ return { queries: 0, rejected: 0, fullScan: 0, withHits: 0, nativeFiles: 0, candidateFiles: 0 };
52
53
  }
53
54
 
54
55
  interface CandidateCase {
55
56
  readonly prefilter: Prefilter;
57
+ readonly query: GrepQuery;
56
58
  readonly required: Map<string, GrepQuery>;
57
59
  readonly contributions: Map<Coverage, number>;
58
60
  }
@@ -103,13 +105,14 @@ test("Cartesian prefilter coverage × composition × flags × bytes → real rg
103
105
  const query: GrepQuery = { patterns: [...patterns], flags, multiline, literal: false };
104
106
  if (!acceptsNative(query)) {
105
107
  rejected++;
108
+ for (const stats of composition === "bare" ? [total, row] : [total]) stats.rejected++;
106
109
  continue;
107
110
  }
108
111
  const prefilter = extractPrefilter(query);
109
112
  const key = JSON.stringify(prefilter);
110
113
  let group = groups.get(key);
111
114
  if (!group) {
112
- group = { prefilter, required: new Map(), contributions: new Map() };
115
+ group = { prefilter, query, required: new Map(), contributions: new Map() };
113
116
  groups.set(key, group);
114
117
  }
115
118
  let hits = 0;
@@ -140,7 +143,7 @@ test("Cartesian prefilter coverage × composition × flags × bytes → real rg
140
143
  const group = cases[next++];
141
144
  const actual = new Set<string>();
142
145
  const result = await runRgPaths(
143
- [...candidateArgs(group.prefilter), "--null", "--", directory],
146
+ [...(await fileCandidateArgs(group.query)), "--null", "--", directory],
144
147
  AbortSignal.timeout(processTimeoutMs),
145
148
  (path) => {
146
149
  actual.add(basename(path));
@@ -158,14 +161,19 @@ test("Cartesian prefilter coverage × composition × flags × bytes → real rg
158
161
  }),
159
162
  );
160
163
  for (const worker of workers) if (worker.status === "rejected") throw worker.reason;
164
+ const unsupported = [...syntax]
165
+ .filter(([, stats]) => stats.queries === 0)
166
+ .map(([label]) => label);
161
167
  const unwitnessed = [...syntax]
162
- .filter(([, stats]) => stats.withHits === 0)
168
+ .filter(([, stats]) => stats.queries > 0 && stats.withHits === 0)
163
169
  .map(([label]) => label);
164
170
  t.diagnostic(
165
171
  JSON.stringify({
166
172
  files: inputs.length,
167
173
  syntaxCases: syntaxCases.length,
168
174
  rejected,
175
+ unsupported,
176
+ supportedSyntaxCases: syntax.size - unsupported.length,
169
177
  candidateExpressions: cases.length,
170
178
  checkedFiles,
171
179
  unwitnessed,
@@ -176,6 +184,10 @@ test("Cartesian prefilter coverage × composition × flags × bytes → real rg
176
184
  JSON.stringify({ composition, ...stats, possibleFiles: stats.queries * inputs.length }),
177
185
  );
178
186
  for (const [label, stats] of syntax) t.diagnostic(JSON.stringify({ syntax: label, ...stats }));
187
+ for (const stats of syntax.values())
188
+ assert.equal(stats.queries + stats.rejected, MATRIX_FLAGS.length * 2);
189
+ for (const stats of compositions.values())
190
+ assert.equal(stats.queries + stats.rejected, syntaxCases.length * MATRIX_FLAGS.length * 2);
179
191
  // A NUL-only pattern cannot match grep's searchable (non-NUL) file domain.
180
192
  assert.deepEqual(unwitnessed, ["NUL"]);
181
193
  const requiredLiteral = compositions.get("required literal");
@@ -3,9 +3,9 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { test } from "node:test";
6
- import { DEFAULT_CONFIG } from "../pi/config.ts";
6
+ import { DEFAULT_CONFIG } from "../pi/tool-factories.testing.ts";
7
7
  import { grepCounts } from "../pi/grep-output.testing.ts";
8
- import { makeGrepOverride } from "../pi/grep-tool.ts";
8
+ import { makeGrepOverride } from "../pi/tool-factories.testing.ts";
9
9
  import { expectToolFailure } from "../pi/report-failure.testing.ts";
10
10
  import { reportOf } from "../pi/report.ts";
11
11
  import { callTool } from "../pi/tool-call.testing.ts";
@@ -62,7 +62,6 @@ test("multiline prefilter exceeds the rg pattern budget → scan all files and r
62
62
  });
63
63
  assert.equal(result.isError, undefined, JSON.stringify(reportOf(result, "grep")));
64
64
  assert.deepEqual(grepCounts(result), { matches: count, files: count });
65
- assert.equal(reportOf(result, "grep")?.scanned, "all");
66
65
  },
67
66
  );
68
67
  }
@@ -74,5 +73,4 @@ test("multiline prefilter exceeds the rg pattern budget → scan all files and r
74
73
  });
75
74
  assert.equal(literal.isError, undefined);
76
75
  assert.deepEqual(grepCounts(literal), { matches: 1, files: 1 });
77
- assert.equal(reportOf(literal, "grep")?.scanned, "files");
78
76
  });
@@ -4,10 +4,10 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import { test } from "node:test";
6
6
  import { rejectsArgument } from "../pi/argument-error.testing.ts";
7
- import { DEFAULT_CONFIG } from "../pi/config.ts";
8
- import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
7
+ const { DEFAULT_CONFIG, makeGrepOverride } = await import("../pi/tool-factories.testing.ts");
8
+
9
9
  import { reportOf } from "../pi/report.ts";
10
- import { grepCounts } from "../pi/grep-output.testing.ts";
10
+ const { grepCounts } = await import("../pi/grep-output.testing.ts");
11
11
  import { callTool } from "../pi/tool-call.testing.ts";
12
12
  import { unsupportedByHost } from "../testing/regex-host.testing.ts";
13
13
 
@@ -207,7 +207,7 @@ test("regex and case modes across line endings → real grep agrees with native
207
207
  const directory = await mkdtemp(join(tmpdir(), "hl-grep-js-equivalence-"));
208
208
  t.after(() => rm(directory, { recursive: true, force: true }));
209
209
  const path = join(directory, "fixture.txt");
210
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
210
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
211
211
  for (const scenario of cases) {
212
212
  for (const separator of ["\n", "\r\n"]) {
213
213
  for (const multiline of scenario.multilineOnly ? [true] : [false, true]) {
@@ -249,7 +249,7 @@ test("malformed UTF-8 → character classes match replacement characters in the
249
249
  const directory = await mkdtemp(join(tmpdir(), "hl-grep-js-invalid-"));
250
250
  t.after(() => rm(directory, { recursive: true, force: true }));
251
251
  const path = join(directory, "invalid.txt");
252
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
252
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
253
253
  await writeFile(
254
254
  path,
255
255
  Buffer.concat([Buffer.from("a"), Buffer.from([0xff]), Buffer.from("b\naxb\n")]),
@@ -274,7 +274,7 @@ test("backreference regression: a capture spanning mixed line endings → matche
274
274
  try {
275
275
  const path = join(dir, "mixed.txt");
276
276
  await writeFile(path, "a\r\na\n");
277
- const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
277
+ const tool = makeGrepOverride(dir, DEFAULT_CONFIG);
278
278
  const result = await callTool(tool, {
279
279
  path,
280
280
  pattern: "(a\\n)\\1",
@@ -294,7 +294,7 @@ test("backreference regression: ignoreCase with an ASCII capture → does not ma
294
294
  try {
295
295
  const path = join(dir, "casefold.txt");
296
296
  await writeFile(path, "kK\n");
297
- const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
297
+ const tool = makeGrepOverride(dir, DEFAULT_CONFIG);
298
298
  const result = await callTool(tool, {
299
299
  path,
300
300
  pattern: "(k)\\1",
@@ -331,7 +331,7 @@ test("zero-maximum quantifiers → real grep matches the active capture", async
331
331
  try {
332
332
  const path = join(dir, "input.txt");
333
333
  await writeFile(path, source);
334
- const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
334
+ const tool = makeGrepOverride(dir, DEFAULT_CONFIG);
335
335
  const result = await callTool(tool, {
336
336
  path,
337
337
  pattern,
@@ -353,7 +353,7 @@ test("JS syntax boundary → executes constructs requiring JS", async (t) => {
353
353
  t.after(() => rm(dir, { recursive: true, force: true }));
354
354
  const path = join(dir, "input.txt");
355
355
  await writeFile(path, "😀\naba\nab\n");
356
- const tool = makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, {});
356
+ const tool = makeGrepOverride(dir, DEFAULT_CONFIG);
357
357
  for (const pattern of [
358
358
  "^..$",
359
359
  "^[^a]{2}$",
@@ -378,7 +378,7 @@ test("zero-width assertions at LF and CRLF boundaries → match only empty physi
378
378
  t.after(() => rm(directory, { recursive: true, force: true }));
379
379
  const path = join(directory, "fixture.txt");
380
380
  await writeFile(path, "a\nb\r\nc\n\nd\r\n\r\nx y\n");
381
- const tool = makeGrepOverrideWithBackend(directory, DEFAULT_CONFIG, {});
381
+ const tool = makeGrepOverride(directory, DEFAULT_CONFIG);
382
382
  for (const [pattern, multiline] of [
383
383
  ["^$", false],
384
384
  ["^ *$", false],