@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.
- package/README.md +21 -7
- package/README.zh-CN.md +22 -8
- package/package.json +7 -6
- package/src/core/AGENTS.md +2 -2
- package/src/core/apply.test.ts +4 -4
- package/src/core/apply.ts +3 -3
- package/src/core/character-set.test.ts +2 -3
- package/src/core/character-set.ts +1 -1
- package/src/core/ranges.test.ts +2 -1
- package/src/core/ranges.ts +1 -1
- package/src/core/regex.ts +6 -2
- package/src/core/replace.test.ts +51 -0
- package/src/core/replace.ts +10 -4
- package/src/core/types.ts +1 -1
- package/src/index.ts +9 -9
- package/src/integration/config-registration.test.ts +8 -10
- package/src/integration/fusion-dispatch.test.ts +2 -2
- package/src/integration/grep-errors.test.ts +3 -3
- package/src/integration/grep-flags.test.ts +5 -5
- package/src/integration/grep-js-completeness.test.ts +12 -11
- package/src/integration/grep-line-candidates.test.ts +5 -3
- package/src/integration/grep-matrix.test.ts +5 -4
- package/src/integration/grep-order.test.ts +4 -4
- package/src/integration/grep-path-matrix.test.ts +5 -4
- package/src/integration/grep-prefilter-coverage.test.ts +17 -5
- package/src/integration/grep-process-limits.test.ts +2 -4
- package/src/integration/grep-regex.test.ts +10 -10
- package/src/integration/grep-rg.test.ts +93 -48
- package/src/integration/grep-scan-budget.test.ts +8 -8
- package/src/integration/grep-translation.test.ts +8 -7
- package/src/integration/large-text.test.ts +5 -5
- package/src/integration/model-budget-lifecycle.test.ts +9 -9
- package/src/integration/mutation-file-types.testing.ts +4 -4
- package/src/integration/npm-package.test.ts +12 -10
- package/src/integration/npm-package.testing.ts +151 -4
- package/src/integration/publication-read-changes.test.ts +54 -54
- package/src/integration/read-changes.test.ts +4 -4
- package/src/integration/replace-worker-boundary.test.ts +1 -1
- package/src/integration/report-replay.test.ts +9 -6
- package/src/integration/utf8-errors.test.ts +4 -4
- package/src/pi/AGENTS.md +13 -12
- package/src/pi/action-fusion.test.ts +125 -105
- package/src/pi/action-fusion.testing.ts +38 -0
- package/src/pi/action-fusion.ts +9 -21
- package/src/pi/argument-diagnostics.ts +4 -3
- package/src/pi/argument-format.test.ts +19 -18
- package/src/pi/argument-validation.test.ts +281 -139
- package/src/pi/argument-validation.ts +21 -31
- package/src/pi/budgets.ts +1 -4
- package/src/pi/codemode.test.ts +7 -2
- package/src/pi/config.test.ts +2 -1
- package/src/pi/config.ts +8 -3
- package/src/pi/diagnostic-buffer.test.ts +23 -13
- package/src/pi/edit-tool.ts +48 -63
- package/src/pi/error-text.ts +7 -2
- package/src/pi/execute.test.ts +178 -157
- package/src/pi/failure-context.test.ts +5 -4
- package/src/pi/failure-context.ts +1 -1
- package/src/pi/failure-path.test.ts +37 -37
- package/src/pi/file-commit.test.ts +47 -19
- package/src/pi/file-commit.ts +36 -9
- package/src/pi/fusion-card.test.ts +22 -21
- package/src/pi/fusion-card.ts +9 -5
- package/src/pi/grep-candidates.test.ts +18 -20
- package/src/pi/grep-candidates.ts +13 -17
- package/src/pi/grep-matrix.test.ts +3 -3
- package/src/pi/grep-order.test.ts +12 -11
- package/src/pi/grep-output.ts +45 -17
- package/src/pi/grep-reread.ts +7 -2
- package/src/pi/grep-rg.testing.ts +70 -0
- package/src/pi/grep-scope.ts +10 -10
- package/src/pi/grep-search.ts +8 -11
- package/src/pi/grep-tool.ts +40 -53
- package/src/pi/grep.test.ts +141 -116
- package/src/pi/model-budgets.test.ts +2 -1
- package/src/pi/mutation-outcome.testing.ts +0 -1
- package/src/pi/mutation-result.test.ts +8 -8
- package/src/pi/mutation-result.ts +1 -1
- package/src/pi/mutation-runner.ts +10 -6
- package/src/pi/output-budgets.test.ts +53 -31
- package/src/pi/pi.test.ts +18 -13
- package/src/pi/read-tool.ts +13 -18
- package/src/pi/read.test.ts +67 -41
- package/src/pi/registration.test.ts +25 -19
- package/src/pi/render.test.ts +94 -32
- package/src/pi/render.ts +7 -4
- package/src/pi/replace-regex.ts +1 -1
- package/src/pi/replace-tool.ts +6 -16
- package/src/pi/replace.test.ts +45 -34
- package/src/pi/report-failure.testing.ts +9 -1
- package/src/pi/report-schema.ts +225 -86
- package/src/pi/report.test.ts +81 -87
- package/src/pi/report.ts +35 -22
- package/src/pi/result-safety.test.ts +121 -100
- package/src/pi/rg-process.test.ts +2 -2
- package/src/pi/rg-process.ts +9 -15
- package/src/pi/rg-regex.test.ts +13 -0
- package/src/pi/rg-regex.ts +2 -2
- package/src/pi/schema.ts +23 -0
- package/src/pi/tool-factories.testing.ts +59 -0
- package/src/pi/write-tool.ts +9 -15
- package/src/pi/write.test.ts +30 -31
- package/src/testing/run-tests.ts +1 -1
package/src/pi/grep.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { MockRg } from "./grep-rg.testing.ts";
|
|
1
2
|
import { rejectsArgument, rejectsArguments } from "./argument-error.testing.ts";
|
|
2
3
|
/**
|
|
3
|
-
* Deterministic grep override tests.
|
|
4
|
+
* Deterministic grep override tests. The ripgrep process module is mocked;
|
|
4
5
|
* fixture files live only in a per-test system temporary directory.
|
|
5
6
|
*/
|
|
6
7
|
import { test } from "node:test";
|
|
@@ -14,21 +15,22 @@ import { join } from "node:path";
|
|
|
14
15
|
import { initTheme } from "@earendil-works/pi-coding-agent";
|
|
15
16
|
import { theme } from "../../node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js";
|
|
16
17
|
import { computeLineHash } from "../core/hash.ts";
|
|
17
|
-
import {
|
|
18
|
+
import { makeMockGrep } from "./grep-rg.testing.ts";
|
|
18
19
|
import { Worker } from "node:worker_threads";
|
|
19
|
-
|
|
20
|
+
const { makeEditOverride } = await import("./tool-factories.testing.ts");
|
|
20
21
|
import { callTool } from "./tool-call.testing.ts";
|
|
21
|
-
|
|
22
|
-
import {
|
|
22
|
+
const { DEFAULT_CONFIG } = await import("./tool-factories.testing.ts");
|
|
23
|
+
import { formatByteSize, outputBudgetsFor } from "./budgets.ts";
|
|
23
24
|
import { reportOf } from "./report.ts";
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { grepCounts } = await import("./grep-output.testing.ts");
|
|
26
|
+
const { parseFileHeader } = await import("./grep-output.ts");
|
|
26
27
|
import { parseHashline } from "./anchor-format.ts";
|
|
27
28
|
import { expectToolFailure } from "./report-failure.testing.ts";
|
|
28
29
|
import { RegExpParser } from "@eslint-community/regexpp";
|
|
29
|
-
import { COMMON_RG_ARGS, LINE_LISTING_ARGS
|
|
30
|
-
import {
|
|
31
|
-
|
|
30
|
+
import { COMMON_RG_ARGS, LINE_LISTING_ARGS } from "./rg-process.ts";
|
|
31
|
+
import { fileCandidateArgs } from "./grep-rg.testing.ts";
|
|
32
|
+
const { DEFAULT_OUTPUT_BUDGETS } = await import("./tool-factories.testing.ts");
|
|
33
|
+
|
|
32
34
|
import { lineCandidatePatterns } from "./rg-regex.ts";
|
|
33
35
|
|
|
34
36
|
type FakeOptions = {
|
|
@@ -68,7 +70,7 @@ function fakeBackend(options: FakeOptions = {}) {
|
|
|
68
70
|
stopped: false,
|
|
69
71
|
};
|
|
70
72
|
};
|
|
71
|
-
const backend:
|
|
73
|
+
const backend: MockRg = {
|
|
72
74
|
runRgPaths: (args, _signal, onPath) => run("paths", args, onPath),
|
|
73
75
|
runRgLines: (args, _signal, _maxLines, onFile) =>
|
|
74
76
|
run("lines", args, (file) => onFile(file, options.lines)),
|
|
@@ -83,7 +85,7 @@ const call = (tool: any, params: any, signal?: AbortSignal) =>
|
|
|
83
85
|
test("explicit JavaScript flags → call rendering shows them", () => {
|
|
84
86
|
initTheme("dark");
|
|
85
87
|
const { backend } = fakeBackend();
|
|
86
|
-
const tool =
|
|
88
|
+
const tool = makeMockGrep(process.cwd(), DEFAULT_CONFIG, backend);
|
|
87
89
|
const rendered = tool.renderCall!(
|
|
88
90
|
{ pattern: ["\\p{Letter}+"], literal: false, flags: "u" },
|
|
89
91
|
theme,
|
|
@@ -96,7 +98,7 @@ test("explicit JavaScript flags → call rendering shows them", () => {
|
|
|
96
98
|
test("streamed grep strings and null fields → render the pattern and default path without a limit", () => {
|
|
97
99
|
initTheme("dark");
|
|
98
100
|
const { backend } = fakeBackend();
|
|
99
|
-
const tool =
|
|
101
|
+
const tool = makeMockGrep(process.cwd(), DEFAULT_CONFIG, backend);
|
|
100
102
|
for (const pattern of ["needle", null]) {
|
|
101
103
|
const args: unknown = { pattern, literal: true, path: null, limit: null };
|
|
102
104
|
const rendered = tool
|
|
@@ -128,7 +130,7 @@ test("configured defaults → descriptions, limits, and context use registered v
|
|
|
128
130
|
...DEFAULT_CONFIG,
|
|
129
131
|
grep: { ...DEFAULT_CONFIG.grep, defaultLimit: 1, defaultContext: 2 },
|
|
130
132
|
};
|
|
131
|
-
const tool =
|
|
133
|
+
const tool = makeMockGrep(dir, config, fake.backend);
|
|
132
134
|
for (const [field, expected] of [
|
|
133
135
|
["limit", 1],
|
|
134
136
|
["context", 2],
|
|
@@ -163,7 +165,7 @@ test("configured defaults → descriptions, limits, and context use registered v
|
|
|
163
165
|
test("grep limit accepts only positive integers", async () => {
|
|
164
166
|
await withDir(async (dir) => {
|
|
165
167
|
const fake = fakeBackend();
|
|
166
|
-
const tool =
|
|
168
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
167
169
|
const limitSchema = tool.parameters.properties.limit;
|
|
168
170
|
assert.equal(limitSchema.type, "number");
|
|
169
171
|
assert.equal("minimum" in limitSchema ? limitSchema.minimum : undefined, 1);
|
|
@@ -182,7 +184,7 @@ test("grep limit accepts only positive integers", async () => {
|
|
|
182
184
|
test("grep schema rejects empty search inputs and fractional context", async () =>
|
|
183
185
|
withDir(async (dir) => {
|
|
184
186
|
const fake = fakeBackend();
|
|
185
|
-
const tool =
|
|
187
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
186
188
|
const invalidArgs = [
|
|
187
189
|
{ literal: true, pattern: "" },
|
|
188
190
|
{ literal: true, pattern: [] },
|
|
@@ -205,7 +207,7 @@ test("grep schema rejects empty search inputs and fractional context", async ()
|
|
|
205
207
|
|
|
206
208
|
test("grep points wildcard paths to glob without changing ordinary missing-path errors", async () => {
|
|
207
209
|
await withDir(async (dir) => {
|
|
208
|
-
const tool =
|
|
210
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fakeBackend().backend);
|
|
209
211
|
await expectToolFailure(
|
|
210
212
|
call(tool, { literal: true, pattern: "value", path: "src/fusion-card*" }),
|
|
211
213
|
"PATH_NOT_FOUND",
|
|
@@ -234,7 +236,7 @@ test("multiple grep paths are missing → reports all resolved paths and selects
|
|
|
234
236
|
[["missing?.txt", "present.txt", "other.txt"], ["missing?.txt", "other.txt"], true],
|
|
235
237
|
] as const) {
|
|
236
238
|
const fake = fakeBackend();
|
|
237
|
-
const tool =
|
|
239
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
238
240
|
const result = await call(tool, { literal: true, pattern: "value", path });
|
|
239
241
|
assert.equal(result.isError, true);
|
|
240
242
|
const block = result.content[0];
|
|
@@ -265,7 +267,7 @@ test("matched files → full-line hash anchors", async () => {
|
|
|
265
267
|
await writeFile(b, "alpha here\n");
|
|
266
268
|
const fake = fakeBackend({ paths: [a, b] });
|
|
267
269
|
|
|
268
|
-
const tool =
|
|
270
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
269
271
|
assert.deepEqual(tool.parameters.required, ["pattern", "literal"]);
|
|
270
272
|
const result = await call(tool, { literal: true, pattern: "alpha" });
|
|
271
273
|
const output = text(result);
|
|
@@ -298,7 +300,7 @@ test("grep payload blocks → only a single complete content or count block omit
|
|
|
298
300
|
grepBytes: truncated ? truncatedBytes : DEFAULT_OUTPUT_BUDGETS.grepBytes,
|
|
299
301
|
};
|
|
300
302
|
const result = await callTool(
|
|
301
|
-
|
|
303
|
+
makeMockGrep(dir, DEFAULT_CONFIG, backend, () => budget),
|
|
302
304
|
{
|
|
303
305
|
path: dir,
|
|
304
306
|
pattern: "needle",
|
|
@@ -325,6 +327,41 @@ test("grep payload blocks → only a single complete content or count block omit
|
|
|
325
327
|
}
|
|
326
328
|
}));
|
|
327
329
|
|
|
330
|
+
test("grep output byte limit → recovery follows output mode and effective context before match limit", async () =>
|
|
331
|
+
withDir(async (dir) => {
|
|
332
|
+
const paths = Array.from({ length: 8 }, (_, index) => join(dir, `file-${index}.txt`));
|
|
333
|
+
await Promise.all(
|
|
334
|
+
paths.map((path) => writeFile(path, "before\nneedle\nafter\nneedle\nafter\nneedle\nafter\n")),
|
|
335
|
+
);
|
|
336
|
+
const budget = outputBudgetsFor(32);
|
|
337
|
+
const config = {
|
|
338
|
+
...DEFAULT_CONFIG,
|
|
339
|
+
grep: { ...DEFAULT_CONFIG.grep, defaultContext: 2 },
|
|
340
|
+
};
|
|
341
|
+
for (const [outputMode, context, limit, expected] of [
|
|
342
|
+
["content", 2, 1000, "Set context to 0 to see more of the omitted matches."],
|
|
343
|
+
["content", undefined, 1000, "Set context to 0 to see more of the omitted matches."],
|
|
344
|
+
["content", 0, 1000, "Narrow path, glob, or pattern to see the omitted output."],
|
|
345
|
+
["files", undefined, 1000, "Narrow path, glob, or pattern to see the omitted output."],
|
|
346
|
+
["count", undefined, 1000, "Narrow path, glob, or pattern to see the omitted output."],
|
|
347
|
+
["content", 2, 12, "Set context to 0 to see more of the omitted matches."],
|
|
348
|
+
["content", 0, 12, "Narrow path, glob, or pattern to see the omitted output."],
|
|
349
|
+
] as const) {
|
|
350
|
+
const { backend } = fakeBackend({ paths });
|
|
351
|
+
const result = await callTool(
|
|
352
|
+
makeMockGrep(dir, config, backend, () => budget),
|
|
353
|
+
{ path: dir, pattern: ["needle"], literal: true, outputMode, context, limit },
|
|
354
|
+
);
|
|
355
|
+
const scenario = JSON.stringify({ outputMode, context, limit });
|
|
356
|
+
assert.equal(result.isError, undefined, scenario);
|
|
357
|
+
const report = reportOf(result, "grep");
|
|
358
|
+
assert.ok(report, scenario);
|
|
359
|
+
assert.equal(report.outputLimit, formatByteSize(budget.grepBytes), scenario);
|
|
360
|
+
assert.equal(report.matchLimit, limit === 12 ? limit : undefined, scenario);
|
|
361
|
+
assert.equal(report.next, expected, scenario);
|
|
362
|
+
}
|
|
363
|
+
}));
|
|
364
|
+
|
|
328
365
|
test("grep output truncates preview rows → reports only displayed preview facts", async () =>
|
|
329
366
|
withDir(async (dir) => {
|
|
330
367
|
const paths = [join(dir, "a.txt"), join(dir, "z.txt")];
|
|
@@ -341,7 +378,7 @@ test("grep output truncates preview rows → reports only displayed preview fact
|
|
|
341
378
|
const { backend } = fakeBackend({ paths });
|
|
342
379
|
const args = { path: dir, pattern: "needle", literal: true };
|
|
343
380
|
const full = await callTool(
|
|
344
|
-
|
|
381
|
+
makeMockGrep(dir, DEFAULT_CONFIG, backend, () => budget),
|
|
345
382
|
args,
|
|
346
383
|
);
|
|
347
384
|
const rows = text(full).split("\n");
|
|
@@ -350,7 +387,7 @@ test("grep output truncates preview rows → reports only displayed preview fact
|
|
|
350
387
|
for (const keptLines of [headerIndex - 1, headerIndex + 1, headerIndex + 2, rows.length]) {
|
|
351
388
|
const expected = rows.slice(0, keptLines).join("\n");
|
|
352
389
|
const result = await callTool(
|
|
353
|
-
|
|
390
|
+
makeMockGrep(dir, DEFAULT_CONFIG, backend, () => ({
|
|
354
391
|
...budget,
|
|
355
392
|
grepBytes: Buffer.byteLength(expected),
|
|
356
393
|
})),
|
|
@@ -380,7 +417,7 @@ test(
|
|
|
380
417
|
const path = join(dir, "outside.txt");
|
|
381
418
|
await writeFile(path, "needle\n");
|
|
382
419
|
const { backend } = fakeBackend({ paths: [path] });
|
|
383
|
-
const result = await callTool(
|
|
420
|
+
const result = await callTool(makeMockGrep(cwd, DEFAULT_CONFIG, backend), {
|
|
384
421
|
path,
|
|
385
422
|
pattern: "needle",
|
|
386
423
|
literal: true,
|
|
@@ -430,16 +467,13 @@ test("file changes after matching → summary modes retain the snapshot and cont
|
|
|
430
467
|
},
|
|
431
468
|
);
|
|
432
469
|
const fake = fakeBackend({ paths });
|
|
433
|
-
const result = await call(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
context: 1,
|
|
441
|
-
},
|
|
442
|
-
);
|
|
470
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
471
|
+
pattern: "needle",
|
|
472
|
+
literal: true,
|
|
473
|
+
multiline,
|
|
474
|
+
outputMode,
|
|
475
|
+
context: 1,
|
|
476
|
+
});
|
|
443
477
|
assert.equal(changed, true);
|
|
444
478
|
if (outputMode !== "content") {
|
|
445
479
|
assert.equal(result.isError, undefined);
|
|
@@ -494,7 +528,7 @@ test("excluded changed file → contributes no preview limit or recovery to comp
|
|
|
494
528
|
},
|
|
495
529
|
);
|
|
496
530
|
const { backend } = fakeBackend({ paths });
|
|
497
|
-
const result = await callTool(
|
|
531
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, backend), {
|
|
498
532
|
pattern: "needle",
|
|
499
533
|
literal: true,
|
|
500
534
|
outputMode: "content",
|
|
@@ -517,28 +551,24 @@ test("excluded changed file → contributes no preview limit or recovery to comp
|
|
|
517
551
|
});
|
|
518
552
|
});
|
|
519
553
|
|
|
520
|
-
test("candidate selection → reports
|
|
554
|
+
test("candidate selection → reports matches without internal strategy facts", async () =>
|
|
521
555
|
withDir(async (dir) => {
|
|
522
556
|
const file = join(dir, "input.txt");
|
|
523
557
|
await writeFile(file, "abc \nneedle");
|
|
524
|
-
for (const [pattern, multiline
|
|
525
|
-
["needle", false
|
|
526
|
-
["needle", true
|
|
527
|
-
["[^x\\s]{3}\\s", true
|
|
558
|
+
for (const [pattern, multiline] of [
|
|
559
|
+
["needle", false],
|
|
560
|
+
["needle", true],
|
|
561
|
+
["[^x\\s]{3}\\s", true],
|
|
528
562
|
] as const) {
|
|
529
563
|
const fake = fakeBackend({ paths: [file] });
|
|
530
|
-
const result = await callTool(
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
multiline,
|
|
537
|
-
},
|
|
538
|
-
);
|
|
564
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
565
|
+
path: file,
|
|
566
|
+
pattern,
|
|
567
|
+
literal: false,
|
|
568
|
+
multiline,
|
|
569
|
+
});
|
|
539
570
|
assert.equal(result.isError, undefined);
|
|
540
571
|
assert.equal(grepCounts(result).matches, 1);
|
|
541
|
-
assert.equal(reportOf(result, "grep")?.scanned, scanned);
|
|
542
572
|
assert.equal(reportOf(result, "grep")?.scanLimit, undefined);
|
|
543
573
|
assert.equal(fake.calls[0].kind, multiline ? "paths" : "lines");
|
|
544
574
|
}
|
|
@@ -553,7 +583,7 @@ test("grep in a subdirectory returns a path that edits the matching file", async
|
|
|
553
583
|
await writeFile(rootFile, original);
|
|
554
584
|
await writeFile(matchedFile, original);
|
|
555
585
|
const fake = fakeBackend({ paths: [matchedFile] });
|
|
556
|
-
const result = await call(
|
|
586
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
557
587
|
literal: true,
|
|
558
588
|
pattern: "status",
|
|
559
589
|
path: "src",
|
|
@@ -566,11 +596,11 @@ test("grep in a subdirectory returns a path that edits the matching file", async
|
|
|
566
596
|
const edit: any = makeEditOverride(dir, DEFAULT_CONFIG);
|
|
567
597
|
await call(edit, {
|
|
568
598
|
path: displayPath,
|
|
569
|
-
|
|
599
|
+
steps: [
|
|
570
600
|
{
|
|
571
601
|
action: "replace",
|
|
572
602
|
anchor: contextAnchor,
|
|
573
|
-
|
|
603
|
+
lines: ["export const context = 2;"],
|
|
574
604
|
},
|
|
575
605
|
],
|
|
576
606
|
});
|
|
@@ -591,7 +621,7 @@ test("context preserves logical CRLF anchors around a matched line", async () =>
|
|
|
591
621
|
);
|
|
592
622
|
const fake = fakeBackend({ paths: [file] });
|
|
593
623
|
|
|
594
|
-
const tool =
|
|
624
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
595
625
|
const contextSchema: any = tool.parameters.properties.context;
|
|
596
626
|
assert.equal(contextSchema.type, "number");
|
|
597
627
|
assert.equal(contextSchema.minimum, 0);
|
|
@@ -618,7 +648,7 @@ test("scope filters and output modes → confirmed files and counts are preserve
|
|
|
618
648
|
await writeFile(b, "foo a.b\n");
|
|
619
649
|
const fake = fakeBackend({ paths: [a, b] });
|
|
620
650
|
|
|
621
|
-
const files = await call(
|
|
651
|
+
const files = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
622
652
|
pattern: ["Foo", "a.b"],
|
|
623
653
|
path: ["a.ts", "b.ts"],
|
|
624
654
|
glob: ["*.ts", "!**/*.test.ts"],
|
|
@@ -631,7 +661,7 @@ test("scope filters and output modes → confirmed files and counts are preserve
|
|
|
631
661
|
);
|
|
632
662
|
assert.deepEqual(fake.calls.at(-1)?.args.slice(-2), [a, b]);
|
|
633
663
|
|
|
634
|
-
const count = await call(
|
|
664
|
+
const count = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
635
665
|
literal: true,
|
|
636
666
|
pattern: "foo",
|
|
637
667
|
outputMode: "count",
|
|
@@ -651,7 +681,7 @@ for (const diagnosticLineCount of [0, 80]) {
|
|
|
651
681
|
"error: missing runtime library",
|
|
652
682
|
].join("\n");
|
|
653
683
|
const fake = fakeBackend({ code: 2, stderr: diagnostic });
|
|
654
|
-
const tool =
|
|
684
|
+
const tool = makeMockGrep(process.cwd(), DEFAULT_CONFIG, fake.backend);
|
|
655
685
|
const args = { pattern: ["(?<=a+)b"], literal: false };
|
|
656
686
|
const failure: Awaited<ReturnType<typeof tool.execute>> = await callTool(tool, args);
|
|
657
687
|
assert.equal(failure.isError, true);
|
|
@@ -674,6 +704,10 @@ for (const diagnosticLineCount of [0, 80]) {
|
|
|
674
704
|
state: {},
|
|
675
705
|
cwd: process.cwd(),
|
|
676
706
|
executionStarted: true,
|
|
707
|
+
durationMs: undefined,
|
|
708
|
+
outputPad: 1,
|
|
709
|
+
keyText: () => "",
|
|
710
|
+
keyHint: (_key, description) => description,
|
|
677
711
|
argsComplete: true,
|
|
678
712
|
isPartial: false,
|
|
679
713
|
expanded,
|
|
@@ -701,7 +735,7 @@ for (const diagnosticLineCount of [0, 80]) {
|
|
|
701
735
|
}
|
|
702
736
|
|
|
703
737
|
test("aligns TUI line numbers across files to the widest result", () => {
|
|
704
|
-
const tool =
|
|
738
|
+
const tool = makeMockGrep(process.cwd(), DEFAULT_CONFIG, fakeBackend().backend);
|
|
705
739
|
const raw = [
|
|
706
740
|
"a.ts · 2 matches",
|
|
707
741
|
"99#ABCD│ alpha",
|
|
@@ -732,7 +766,7 @@ test("matching rows exceed limit → bounded results offer optional continuation
|
|
|
732
766
|
const fake = fakeBackend({ paths: [file] });
|
|
733
767
|
|
|
734
768
|
const limit = 1;
|
|
735
|
-
const result = await call(
|
|
769
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
736
770
|
literal: true,
|
|
737
771
|
pattern: "alpha",
|
|
738
772
|
limit,
|
|
@@ -751,7 +785,7 @@ test("literal punctuation → exact text is matched", async () =>
|
|
|
751
785
|
const file = join(dir, "literal.txt");
|
|
752
786
|
await writeFile(file, "foo(0)\n");
|
|
753
787
|
const fake = fakeBackend({ paths: [file] });
|
|
754
|
-
const tool =
|
|
788
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
755
789
|
const result = await call(tool, { pattern: "foo(0)", literal: true });
|
|
756
790
|
assert.match(text(result), /1#[0-9A-Z]+│foo\(0\)/);
|
|
757
791
|
assert.equal(fake.calls.length, 1);
|
|
@@ -761,7 +795,7 @@ test("literal pipe patterns find no match → alternatives recovery preserves li
|
|
|
761
795
|
withDir(async (dir) => {
|
|
762
796
|
const path = join(dir, "pipe.txt");
|
|
763
797
|
const { backend } = fakeBackend({ paths: [path] });
|
|
764
|
-
const tool =
|
|
798
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, backend);
|
|
765
799
|
for (const { pattern, literal, source, matches, literalPipe } of [
|
|
766
800
|
{ pattern: "foo|bar", literal: true, source: "foo\nbar\n", matches: 0, literalPipe: true },
|
|
767
801
|
{
|
|
@@ -817,7 +851,7 @@ test("invalid JavaScript → its field rejects before file discovery", async ()
|
|
|
817
851
|
["*", undefined, "pattern[0]"],
|
|
818
852
|
] as const) {
|
|
819
853
|
const fake = fakeBackend();
|
|
820
|
-
const tool =
|
|
854
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
821
855
|
await assert.rejects(
|
|
822
856
|
call(tool, { path: "missing.txt", pattern, literal: false, flags }),
|
|
823
857
|
rejectsArgument(field, /Invalid regular expression/),
|
|
@@ -829,7 +863,7 @@ test("invalid JavaScript → its field rejects before file discovery", async ()
|
|
|
829
863
|
test("grep OR arrays accept more than sixteen patterns in one line scan", async () => {
|
|
830
864
|
await withDir(async (dir) => {
|
|
831
865
|
const fake = fakeBackend();
|
|
832
|
-
const tool =
|
|
866
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
833
867
|
const patterns = Array.from({ length: 17 }, (_, index) => `pattern${index}`);
|
|
834
868
|
assert.equal(
|
|
835
869
|
reportOf(await call(tool, { literal: true, pattern: patterns }), "grep")?.matches,
|
|
@@ -842,7 +876,7 @@ test("grep OR arrays accept more than sixteen patterns in one line scan", async
|
|
|
842
876
|
test("character classes, literals, and empty-line searches → valid nonempty patterns", async () => {
|
|
843
877
|
await withDir(async (dir) => {
|
|
844
878
|
const fake = fakeBackend();
|
|
845
|
-
const tool =
|
|
879
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
846
880
|
for (const pattern of ["[\\w.*]*", "^[\\w.*]+$", "[\\w.*]?"]) {
|
|
847
881
|
assert.equal(reportOf(await call(tool, { pattern, literal: false }), "grep")?.matches, 0);
|
|
848
882
|
}
|
|
@@ -856,7 +890,7 @@ test("character classes, literals, and empty-line searches → valid nonempty pa
|
|
|
856
890
|
test("grep accepts nonempty whitespace literals", async () => {
|
|
857
891
|
await withDir(async (dir) => {
|
|
858
892
|
const fake = fakeBackend();
|
|
859
|
-
const tool =
|
|
893
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
860
894
|
for (const pattern of [" ", "\t", ["word", " "]]) {
|
|
861
895
|
assert.equal(reportOf(await call(tool, { pattern, literal: true }), "grep")?.matches, 0);
|
|
862
896
|
}
|
|
@@ -867,7 +901,7 @@ test("grep accepts nonempty whitespace literals", async () => {
|
|
|
867
901
|
test("reports empty output and ripgrep execution failures", async () => {
|
|
868
902
|
await withDir(async (dir) => {
|
|
869
903
|
const empty = fakeBackend({ code: 1 });
|
|
870
|
-
const noMatches = await call(
|
|
904
|
+
const noMatches = await call(makeMockGrep(dir, DEFAULT_CONFIG, empty.backend), {
|
|
871
905
|
literal: true,
|
|
872
906
|
pattern: "missing",
|
|
873
907
|
});
|
|
@@ -877,7 +911,7 @@ test("reports empty output and ripgrep execution failures", async () => {
|
|
|
877
911
|
|
|
878
912
|
const failed = fakeBackend({ code: 2, stderr: "bad regex" });
|
|
879
913
|
await expectToolFailure(
|
|
880
|
-
call(
|
|
914
|
+
call(makeMockGrep(dir, DEFAULT_CONFIG, failed.backend), {
|
|
881
915
|
pattern: "x",
|
|
882
916
|
literal: false,
|
|
883
917
|
}),
|
|
@@ -889,7 +923,7 @@ test("reports empty output and ripgrep execution failures", async () => {
|
|
|
889
923
|
|
|
890
924
|
const rejected = fakeBackend({ error: new Error("spawn failed") });
|
|
891
925
|
await expectToolFailure(
|
|
892
|
-
call(
|
|
926
|
+
call(makeMockGrep(dir, DEFAULT_CONFIG, rejected.backend), {
|
|
893
927
|
literal: true,
|
|
894
928
|
pattern: "x",
|
|
895
929
|
}),
|
|
@@ -908,7 +942,7 @@ test("rejects calls aborted before or during rg execution", async () => {
|
|
|
908
942
|
first.abort();
|
|
909
943
|
await expectToolFailure(
|
|
910
944
|
call(
|
|
911
|
-
|
|
945
|
+
makeMockGrep(dir, DEFAULT_CONFIG, alreadyAborted.backend),
|
|
912
946
|
{ literal: true, pattern: ["x", "y"] },
|
|
913
947
|
first.signal,
|
|
914
948
|
),
|
|
@@ -919,7 +953,7 @@ test("rejects calls aborted before or during rg execution", async () => {
|
|
|
919
953
|
const interrupted = fakeBackend({ onRun: () => controller.abort() });
|
|
920
954
|
await expectToolFailure(
|
|
921
955
|
call(
|
|
922
|
-
|
|
956
|
+
makeMockGrep(dir, DEFAULT_CONFIG, interrupted.backend),
|
|
923
957
|
{ literal: true, pattern: ["x", "y"] },
|
|
924
958
|
controller.signal,
|
|
925
959
|
),
|
|
@@ -933,7 +967,7 @@ test("overlapping OR patterns → each matched line counts once", async () => {
|
|
|
933
967
|
const file = join(dir, "fixture.ts");
|
|
934
968
|
await writeFile(file, "foo bar\n".repeat(4097));
|
|
935
969
|
const fake = fakeBackend({ paths: [file] });
|
|
936
|
-
const result = await call(
|
|
970
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
937
971
|
pattern: ["foo", "bar"],
|
|
938
972
|
literal: true,
|
|
939
973
|
outputMode: "count",
|
|
@@ -950,7 +984,7 @@ test("long matching lines → counts do not depend on content previews", async (
|
|
|
950
984
|
const line = `foo${"x".repeat(600_000)}\n`;
|
|
951
985
|
await writeFile(file, line.repeat(3));
|
|
952
986
|
const fake = fakeBackend({ paths: [file] });
|
|
953
|
-
const result = await call(
|
|
987
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
954
988
|
pattern: "foo",
|
|
955
989
|
literal: true,
|
|
956
990
|
outputMode: "count",
|
|
@@ -968,7 +1002,7 @@ test("grep previews invalid UTF-8 without anchors and skips NUL hits in every mo
|
|
|
968
1002
|
const fake = fakeBackend({
|
|
969
1003
|
paths: [invalid],
|
|
970
1004
|
});
|
|
971
|
-
const result = await call(
|
|
1005
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
972
1006
|
literal: true,
|
|
973
1007
|
pattern: "a",
|
|
974
1008
|
path: invalid,
|
|
@@ -992,10 +1026,13 @@ test("grep previews invalid UTF-8 without anchors and skips NUL hits in every mo
|
|
|
992
1026
|
{ outputMode: "files", multiline: true },
|
|
993
1027
|
{ outputMode: "count", multiline: true },
|
|
994
1028
|
] as const) {
|
|
995
|
-
const skipped = await call(
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1029
|
+
const skipped = await call(makeMockGrep(dir, DEFAULT_CONFIG, binaryBackend.backend), {
|
|
1030
|
+
literal: true,
|
|
1031
|
+
pattern: "a",
|
|
1032
|
+
path: binary,
|
|
1033
|
+
outputMode,
|
|
1034
|
+
multiline,
|
|
1035
|
+
});
|
|
999
1036
|
assert.equal(reportOf(skipped, "grep")?.matches, 0);
|
|
1000
1037
|
assert.equal(skipped.isError, undefined);
|
|
1001
1038
|
}
|
|
@@ -1011,7 +1048,7 @@ test("candidate file disappears before reading → summary modes report incomple
|
|
|
1011
1048
|
const fake = fakeBackend({ paths: [file], onRun: () => rm(file) });
|
|
1012
1049
|
const backend = fake.backend;
|
|
1013
1050
|
await expectToolFailure(
|
|
1014
|
-
call(
|
|
1051
|
+
call(makeMockGrep(dir, DEFAULT_CONFIG, backend), {
|
|
1015
1052
|
literal: true,
|
|
1016
1053
|
pattern: "needle",
|
|
1017
1054
|
path: file,
|
|
@@ -1019,7 +1056,7 @@ test("candidate file disappears before reading → summary modes report incomple
|
|
|
1019
1056
|
}),
|
|
1020
1057
|
"SEARCH_INCOMPLETE",
|
|
1021
1058
|
(report) => {
|
|
1022
|
-
assert.match(report.diagnostics ?? "", /
|
|
1059
|
+
assert.match(report.diagnostics ?? "", /listed\.txt: ENOENT/);
|
|
1023
1060
|
},
|
|
1024
1061
|
);
|
|
1025
1062
|
assert.equal(fake.calls.length, 1);
|
|
@@ -1040,7 +1077,7 @@ test("candidate listing reports errors → all output modes retain confirmed mat
|
|
|
1040
1077
|
code: 2,
|
|
1041
1078
|
stderr: "unreadable.txt: Permission denied",
|
|
1042
1079
|
});
|
|
1043
|
-
const result = await call(
|
|
1080
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1044
1081
|
literal: true,
|
|
1045
1082
|
pattern: "needle",
|
|
1046
1083
|
outputMode,
|
|
@@ -1056,7 +1093,7 @@ test("candidate listing reports errors → all output modes retain confirmed mat
|
|
|
1056
1093
|
}
|
|
1057
1094
|
const fake = fakeBackend({ code: 2, stderr: "Permission denied" });
|
|
1058
1095
|
await expectToolFailure(
|
|
1059
|
-
call(
|
|
1096
|
+
call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1060
1097
|
literal: true,
|
|
1061
1098
|
pattern: "needle",
|
|
1062
1099
|
}),
|
|
@@ -1076,7 +1113,7 @@ test("one candidate cannot be read → matches from other files remain available
|
|
|
1076
1113
|
await writeFile(gone, "needle\n");
|
|
1077
1114
|
const fake = fakeBackend({ paths: [good, gone], onRun: () => rm(gone) });
|
|
1078
1115
|
const backend = fake.backend;
|
|
1079
|
-
const result = await call(
|
|
1116
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, backend), {
|
|
1080
1117
|
literal: true,
|
|
1081
1118
|
pattern: "needle",
|
|
1082
1119
|
});
|
|
@@ -1092,7 +1129,7 @@ for (const admitted of [2, 1, 0]) {
|
|
|
1092
1129
|
await Promise.all(files.map((file) => writeFile(file, "needle\n")));
|
|
1093
1130
|
const fake = fakeBackend({ paths: files.slice(0, admitted) });
|
|
1094
1131
|
const result = await call(
|
|
1095
|
-
|
|
1132
|
+
makeMockGrep(dir, DEFAULT_CONFIG, {
|
|
1096
1133
|
...fake.backend,
|
|
1097
1134
|
runRgPaths: async (...args) => {
|
|
1098
1135
|
const listing = await fake.backend.runRgPaths(...args);
|
|
@@ -1127,7 +1164,7 @@ test("concurrent file searches → all discovered matches remain present", async
|
|
|
1127
1164
|
files.push(file);
|
|
1128
1165
|
}
|
|
1129
1166
|
const fake = fakeBackend({ paths: files });
|
|
1130
|
-
const result = await call(
|
|
1167
|
+
const result = await call(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1131
1168
|
literal: true,
|
|
1132
1169
|
pattern: "match",
|
|
1133
1170
|
});
|
|
@@ -1172,7 +1209,7 @@ test("scope inspection fails for access or traversal reasons → grep preserves
|
|
|
1172
1209
|
syncBuiltinESMExports();
|
|
1173
1210
|
try {
|
|
1174
1211
|
const fake = fakeBackend();
|
|
1175
|
-
const tool =
|
|
1212
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fake.backend);
|
|
1176
1213
|
await expectToolFailure(
|
|
1177
1214
|
callTool(tool, { path, pattern: "needle", literal: true }),
|
|
1178
1215
|
"FILESYSTEM_ERROR",
|
|
@@ -1216,11 +1253,7 @@ test("invalid worker replies → the entire grep call fails", async (t) => {
|
|
|
1216
1253
|
return emit.call(this, event, ...(event === "message" ? [{ result }] : args));
|
|
1217
1254
|
},
|
|
1218
1255
|
);
|
|
1219
|
-
const tool =
|
|
1220
|
-
dir,
|
|
1221
|
-
DEFAULT_CONFIG,
|
|
1222
|
-
fakeBackend({ paths: [path] }).backend,
|
|
1223
|
-
);
|
|
1256
|
+
const tool = makeMockGrep(dir, DEFAULT_CONFIG, fakeBackend({ paths: [path] }).backend);
|
|
1224
1257
|
await expectToolFailure(
|
|
1225
1258
|
callTool(tool, { pattern: "^..$", literal: false, path }),
|
|
1226
1259
|
"REGEX_WORKER_FAILED",
|
|
@@ -1237,7 +1270,7 @@ test("catastrophic worker evaluation → timeout and cancellation fail the searc
|
|
|
1237
1270
|
const path = join(dir, "input.txt");
|
|
1238
1271
|
await writeFile(path, `${"a".repeat(100)}!`);
|
|
1239
1272
|
const config = { ...DEFAULT_CONFIG, grep: { ...DEFAULT_CONFIG.grep, regexTimeoutMs: 3_000 } };
|
|
1240
|
-
const tool =
|
|
1273
|
+
const tool = makeMockGrep(dir, config, fakeBackend({ paths: [path] }).backend);
|
|
1241
1274
|
const params = { path, pattern: "(?=.)^(a+)+$", literal: false };
|
|
1242
1275
|
await expectToolFailure(callTool(tool, params), "REGEX_TIMEOUT", (report) =>
|
|
1243
1276
|
assert.equal(report.timeoutMs, config.grep.regexTimeoutMs),
|
|
@@ -1273,10 +1306,7 @@ test("non-multiline or multiline query → use line candidates or the file prefi
|
|
|
1273
1306
|
multiline,
|
|
1274
1307
|
ignoreCase: false,
|
|
1275
1308
|
};
|
|
1276
|
-
const result = await callTool(
|
|
1277
|
-
makeGrepOverrideWithBackend(dir, DEFAULT_CONFIG, fake.backend),
|
|
1278
|
-
params,
|
|
1279
|
-
);
|
|
1309
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), params);
|
|
1280
1310
|
assert.equal(grepCounts(result).matches, 2);
|
|
1281
1311
|
assert.equal(fake.calls.length, 1);
|
|
1282
1312
|
assert.equal(fake.calls[0].kind, multiline ? "paths" : "lines");
|
|
@@ -1284,7 +1314,7 @@ test("non-multiline or multiline query → use line candidates or the file prefi
|
|
|
1284
1314
|
const candidates = lineCandidatePatterns(query);
|
|
1285
1315
|
assert.ok(candidates);
|
|
1286
1316
|
const prefix = multiline
|
|
1287
|
-
? [...
|
|
1317
|
+
? [...(await fileCandidateArgs(query)), "--null"]
|
|
1288
1318
|
: [
|
|
1289
1319
|
...COMMON_RG_ARGS,
|
|
1290
1320
|
"--engine=default",
|
|
@@ -1319,14 +1349,11 @@ test("line discovery status and emitted files → fallback only for code 2 befor
|
|
|
1319
1349
|
[2, [file], ["lines"]],
|
|
1320
1350
|
] as const) {
|
|
1321
1351
|
const fake = fakeBackend({ code, paths: [...paths], lines: [1] });
|
|
1322
|
-
const result = await callTool(
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
literal: true,
|
|
1328
|
-
},
|
|
1329
|
-
);
|
|
1352
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1353
|
+
path: dir,
|
|
1354
|
+
pattern: "needle",
|
|
1355
|
+
literal: true,
|
|
1356
|
+
});
|
|
1330
1357
|
assert.deepEqual(
|
|
1331
1358
|
fake.calls.map(({ kind }) => kind),
|
|
1332
1359
|
kinds,
|
|
@@ -1342,21 +1369,18 @@ test("sparse, dense, or overflowed candidate lines → matching preserves origin
|
|
|
1342
1369
|
await writeFile(file, "miss\r\nneedle\r\nmiss\nmiss\nneedle\r");
|
|
1343
1370
|
for (const lines of [[2, 5], [1, 2, 4, 5], undefined]) {
|
|
1344
1371
|
const fake = fakeBackend({ paths: [file], lines });
|
|
1345
|
-
const result = await callTool(
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
context: 0,
|
|
1352
|
-
},
|
|
1353
|
-
);
|
|
1372
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1373
|
+
path: file,
|
|
1374
|
+
pattern: "needle",
|
|
1375
|
+
literal: true,
|
|
1376
|
+
context: 0,
|
|
1377
|
+
});
|
|
1354
1378
|
assert.equal(grepCounts(result).matches, 2);
|
|
1355
1379
|
assert.match(text(result), /2#[0-9A-Z]+│needle/);
|
|
1356
1380
|
assert.match(text(result), /5#[0-9A-Z]+│needle␍/);
|
|
1357
1381
|
}
|
|
1358
1382
|
const fake = fakeBackend({ paths: [file], lines: [2, 5] });
|
|
1359
|
-
const result = await callTool(
|
|
1383
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1360
1384
|
path: file,
|
|
1361
1385
|
pattern: "\\r$",
|
|
1362
1386
|
literal: false,
|
|
@@ -1374,7 +1398,7 @@ test("native-valid pattern exceeds parser limits → use the all-file prefilter"
|
|
|
1374
1398
|
throw new RangeError("parser stack limit");
|
|
1375
1399
|
});
|
|
1376
1400
|
const fake = fakeBackend({ paths: [file] });
|
|
1377
|
-
const result = await callTool(
|
|
1401
|
+
const result = await callTool(makeMockGrep(dir, DEFAULT_CONFIG, fake.backend), {
|
|
1378
1402
|
path: file,
|
|
1379
1403
|
pattern: "a",
|
|
1380
1404
|
literal: false,
|
|
@@ -1386,7 +1410,8 @@ test("native-valid pattern exceeds parser limits → use the all-file prefilter"
|
|
|
1386
1410
|
["paths"],
|
|
1387
1411
|
);
|
|
1388
1412
|
assert.deepEqual(fake.calls[0].args, [
|
|
1389
|
-
...
|
|
1413
|
+
...COMMON_RG_ARGS,
|
|
1414
|
+
"--files",
|
|
1390
1415
|
"--null",
|
|
1391
1416
|
"--hidden",
|
|
1392
1417
|
"--glob",
|
|
@@ -1403,7 +1428,7 @@ test("rg rejects line patterns before listing files → successful file fallback
|
|
|
1403
1428
|
const lines = fakeBackend({ code: 2, stderr: "regex too large" });
|
|
1404
1429
|
const paths = fakeBackend({ paths: [file] });
|
|
1405
1430
|
const result = await callTool(
|
|
1406
|
-
|
|
1431
|
+
makeMockGrep(dir, DEFAULT_CONFIG, {
|
|
1407
1432
|
runRgLines: lines.backend.runRgLines,
|
|
1408
1433
|
runRgPaths: paths.backend.runRgPaths,
|
|
1409
1434
|
}),
|