@criogaid/pi-hashline-edit 0.13.0 → 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 (152) hide show
  1. package/README.md +18 -12
  2. package/README.zh-CN.md +18 -12
  3. package/package.json +8 -1
  4. package/src/core/AGENTS.md +3 -1
  5. package/src/core/apply.ts +110 -117
  6. package/src/core/character-set.ts +2 -3
  7. package/src/core/copy-span.ts +15 -0
  8. package/src/core/errors.ts +24 -9
  9. package/src/core/lines.ts +71 -17
  10. package/src/core/ranges.ts +5 -4
  11. package/src/core/replace-schema.ts +3 -1
  12. package/src/core/replace.ts +50 -29
  13. package/src/core/search-analysis.ts +21 -22
  14. package/src/core/search.ts +15 -32
  15. package/src/core/types.ts +3 -0
  16. package/src/index.ts +47 -39
  17. package/src/pi/AGENTS.md +30 -19
  18. package/src/pi/action-fusion.ts +284 -211
  19. package/src/pi/argument-diagnostics.ts +50 -37
  20. package/src/pi/argument-error.ts +2 -2
  21. package/src/pi/argument-validation.ts +163 -66
  22. package/src/pi/budgets.ts +12 -0
  23. package/src/pi/diagnostic-buffer.ts +12 -11
  24. package/src/pi/edit-tool.ts +138 -115
  25. package/src/pi/error-text.ts +10 -2
  26. package/src/pi/failure-context.ts +24 -37
  27. package/src/pi/file-commit.ts +131 -164
  28. package/src/pi/file-read.ts +122 -31
  29. package/src/pi/fusion-arguments.ts +214 -0
  30. package/src/pi/fusion-card.ts +102 -60
  31. package/src/pi/grep-candidates.ts +35 -22
  32. package/src/pi/grep-output.ts +197 -190
  33. package/src/pi/grep-render.ts +22 -13
  34. package/src/pi/grep-reread.ts +7 -6
  35. package/src/pi/grep-scope.ts +31 -16
  36. package/src/pi/grep-search.ts +56 -47
  37. package/src/pi/grep-tool.ts +35 -33
  38. package/src/pi/grep-worker.ts +3 -4
  39. package/src/pi/mutation-diff.ts +238 -0
  40. package/src/pi/mutation-result.ts +102 -79
  41. package/src/pi/mutation-runner.ts +107 -84
  42. package/src/pi/native-bash.ts +41 -0
  43. package/src/pi/path.ts +59 -6
  44. package/src/pi/read-tool.ts +173 -138
  45. package/src/pi/regex-worker.ts +14 -8
  46. package/src/pi/render.ts +101 -54
  47. package/src/pi/replace-regex.ts +1 -1
  48. package/src/pi/replace-tool.ts +14 -7
  49. package/src/pi/report-cause.ts +34 -17
  50. package/src/pi/report-schema.ts +184 -85
  51. package/src/pi/report.ts +133 -64
  52. package/src/pi/rg-process.ts +68 -48
  53. package/src/pi/schema.ts +4 -0
  54. package/src/pi/text-stream.ts +81 -87
  55. package/src/pi/workspace-cwd.js +2 -0
  56. package/src/pi/workspace.ts +46 -0
  57. package/src/pi/write-tool.ts +19 -13
  58. package/src/core/apply.test.ts +0 -644
  59. package/src/core/case-fold.test.ts +0 -35
  60. package/src/core/character-set.test.ts +0 -97
  61. package/src/core/errors.test.ts +0 -39
  62. package/src/core/hash.test.ts +0 -64
  63. package/src/core/lines.test.ts +0 -63
  64. package/src/core/ranges.test.ts +0 -123
  65. package/src/core/replace.test.ts +0 -187
  66. package/src/core/search-analysis.test.ts +0 -210
  67. package/src/core/search-matrix.test.ts +0 -64
  68. package/src/core/search-matrix.testing.ts +0 -171
  69. package/src/core/search.test.ts +0 -132
  70. package/src/core/text.test.ts +0 -52
  71. package/src/integration/config-registration.test.ts +0 -291
  72. package/src/integration/fusion-dispatch.test.ts +0 -320
  73. package/src/integration/grep-errors.test.ts +0 -81
  74. package/src/integration/grep-flags.test.ts +0 -76
  75. package/src/integration/grep-js-completeness.test.ts +0 -278
  76. package/src/integration/grep-line-candidates.test.ts +0 -201
  77. package/src/integration/grep-matrix.test.ts +0 -118
  78. package/src/integration/grep-order.test.ts +0 -78
  79. package/src/integration/grep-path-matrix.test.ts +0 -128
  80. package/src/integration/grep-prefilter-coverage.test.ts +0 -204
  81. package/src/integration/grep-process-limits.test.ts +0 -122
  82. package/src/integration/grep-regex.test.ts +0 -412
  83. package/src/integration/grep-rg.test.ts +0 -1659
  84. package/src/integration/grep-scan-budget.test.ts +0 -111
  85. package/src/integration/grep-translation.test.ts +0 -199
  86. package/src/integration/large-text.test.ts +0 -70
  87. package/src/integration/model-budget-lifecycle.test.ts +0 -186
  88. package/src/integration/mutation-file-types.test.ts +0 -30
  89. package/src/integration/mutation-file-types.testing.ts +0 -33
  90. package/src/integration/npm-package.test.ts +0 -19
  91. package/src/integration/npm-package.testing.ts +0 -243
  92. package/src/integration/publication-read-changes.test.ts +0 -454
  93. package/src/integration/read-changes.test.ts +0 -98
  94. package/src/integration/replace-package.test.ts +0 -22
  95. package/src/integration/replace-package.testing.ts +0 -36
  96. package/src/integration/replace-worker-boundary.test.ts +0 -127
  97. package/src/integration/report-replay.test.ts +0 -91
  98. package/src/integration/utf8-errors.test.ts +0 -46
  99. package/src/pi/action-fusion.test.ts +0 -659
  100. package/src/pi/action-fusion.testing.ts +0 -38
  101. package/src/pi/anchor-format.test.ts +0 -124
  102. package/src/pi/argument-error.testing.ts +0 -46
  103. package/src/pi/argument-format.test.ts +0 -196
  104. package/src/pi/argument-validation.test.ts +0 -1007
  105. package/src/pi/codemode.test.ts +0 -101
  106. package/src/pi/config.test.ts +0 -204
  107. package/src/pi/diagnostic-buffer.test.ts +0 -115
  108. package/src/pi/directory-sync.test.ts +0 -57
  109. package/src/pi/execute.test.ts +0 -1257
  110. package/src/pi/extension-loading.test.ts +0 -14
  111. package/src/pi/extension-loading.testing.ts +0 -3
  112. package/src/pi/failure-context.test.ts +0 -370
  113. package/src/pi/failure-path.test.ts +0 -289
  114. package/src/pi/file-commit.test.ts +0 -628
  115. package/src/pi/file-read.test.ts +0 -29
  116. package/src/pi/file-snapshot.test.ts +0 -22
  117. package/src/pi/fusion-card-interaction.test.ts +0 -143
  118. package/src/pi/fusion-card.test.ts +0 -353
  119. package/src/pi/grep-candidates.test.ts +0 -26
  120. package/src/pi/grep-matrix.test.ts +0 -68
  121. package/src/pi/grep-order.test.ts +0 -447
  122. package/src/pi/grep-output.testing.ts +0 -24
  123. package/src/pi/grep-rg.testing.ts +0 -73
  124. package/src/pi/grep.test.ts +0 -1670
  125. package/src/pi/model-budgets.test.ts +0 -96
  126. package/src/pi/mutation-outcome.testing.ts +0 -20
  127. package/src/pi/mutation-result.test.ts +0 -96
  128. package/src/pi/output-budgets.test.ts +0 -221
  129. package/src/pi/pi.test.ts +0 -158
  130. package/src/pi/read-delegation.test.ts +0 -119
  131. package/src/pi/read.test.ts +0 -735
  132. package/src/pi/regex-worker.test.ts +0 -42
  133. package/src/pi/registration.test.ts +0 -549
  134. package/src/pi/render.test.ts +0 -841
  135. package/src/pi/replace.test.ts +0 -634
  136. package/src/pi/report-failure.testing.ts +0 -27
  137. package/src/pi/report.test.ts +0 -533
  138. package/src/pi/result-safety.test.ts +0 -597
  139. package/src/pi/rg-process.test.ts +0 -133
  140. package/src/pi/rg-regex.test.ts +0 -40
  141. package/src/pi/text-stream.test.ts +0 -281
  142. package/src/pi/tool-call.testing.ts +0 -61
  143. package/src/pi/tool-factories.testing.ts +0 -59
  144. package/src/pi/write.test.ts +0 -256
  145. package/src/testing/extension-loader.testing.ts +0 -24
  146. package/src/testing/installation.testing.ts +0 -77
  147. package/src/testing/process.testing.ts +0 -33
  148. package/src/testing/regex-host.testing.ts +0 -20
  149. package/src/testing/regex-translation-corpus.ts +0 -267
  150. package/src/testing/rg-line-listing.fixture.mjs +0 -7
  151. package/src/testing/run-tests.ts +0 -47
  152. package/src/testing/session.testing.ts +0 -127
@@ -1,124 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { test } from "node:test";
3
- import { computeLineHash } from "../core/hash.ts";
4
- import {
5
- anchorPattern,
6
- createAnchorFormatter,
7
- parseAnchorToken,
8
- parseHashline,
9
- parseDisplayRow,
10
- plainRow,
11
- } from "./anchor-format.ts";
12
-
13
- function token(line: number, content: string, hashLen: number): string {
14
- return createAnchorFormatter(hashLen).reference(line, computeLineHash(line, content, hashLen));
15
- }
16
-
17
- test("anchor formatter binds the supplied hash length and hashes undisplayed content", () => {
18
- const formatter = createAnchorFormatter(6);
19
-
20
- assert.equal(token(3, "full content", 6), `3#${computeLineHash(3, "full content", 6)}`);
21
- assert.equal(formatter.reference(3, "ABCDEF"), "3#ABCDEF");
22
- assert.match(token(3, "full content", 6), new RegExp(anchorPattern(6)));
23
- assert.doesNotMatch(token(3, "full content", 6), new RegExp(anchorPattern(4)));
24
- assert.equal(
25
- formatter.row(3, "full content", "full…"),
26
- `3#${computeLineHash(3, "full content", 6)}│full…`,
27
- );
28
- assert.equal(token(3, "full content", 4), `3#${computeLineHash(3, "full content", 4)}`);
29
- });
30
-
31
- test("anchor tokens parse at any hash length so wrong lengths can be explained", () => {
32
- assert.deepEqual(parseAnchorToken("12#GF"), { line: 12, hash: "GF" });
33
- assert.deepEqual(parseAnchorToken("12#GFYR"), { line: 12, hash: "GFYR" });
34
- assert.equal(parseAnchorToken("12#gfyr"), undefined);
35
- assert.equal(parseAnchorToken("0#GFYR"), undefined);
36
- });
37
-
38
- test("anchor rows expose carriage returns while checksums retain source content", () => {
39
- const formatter = createAnchorFormatter(4);
40
- assert.equal(formatter.row(1, "a\rb"), `1#${computeLineHash(1, "a\rb", 4)}│a␍b`);
41
- assert.notEqual(token(1, "a\rb", 4), token(1, "a␍b", 4));
42
- });
43
-
44
- test("anchor syntax rejects characters absent from the checksum alphabet", () => {
45
- const pattern = new RegExp(anchorPattern(4));
46
- for (const hash of ["IIII", "LLLL", "OOOO", "UUUU", "abcd"]) {
47
- assert.doesNotMatch(`1#${hash}`, pattern);
48
- assert.equal(parseAnchorToken(`1#${hash}`), undefined);
49
- assert.equal(parseHashline(`1#${hash}│content`), null);
50
- }
51
- });
52
-
53
- test("display rows accept supported hash lengths and preserve nested anchor-like content", () => {
54
- for (const hashLen of [2, 4, 6, 8]) {
55
- const formatter = createAnchorFormatter(hashLen);
56
- assert.deepEqual(parseHashline(formatter.row(12, "12#abc│content")), {
57
- lineNo: "12",
58
- content: "12#abc│content",
59
- });
60
- }
61
- for (const row of ["0#ABCD│text", "01#ABCD│text", "12#A│text", "12#AAAAAAAAA│text"]) {
62
- assert.equal(parseHashline(row), null);
63
- }
64
- });
65
-
66
- test("plain rows expose carriage returns without creating editable anchors", () => {
67
- assert.equal(plainRow(12, "a\rb│12#ABCD│nested"), "12│a␍b│12#ABCD│nested");
68
- assert.equal(plainRow(1, ""), "1│");
69
- assert.equal(parseHashline(plainRow(12, "content")), null);
70
- assert.equal(parseAnchorToken("12"), undefined);
71
- });
72
-
73
- test("display row parsing accepts plain and anchored rows without changing their content", () => {
74
- for (const hashLen of [2, 4, 6, 8]) {
75
- const anchored = createAnchorFormatter(hashLen).row(12, " nested 7#ABCD│content");
76
- assert.deepEqual(parseDisplayRow(anchored), {
77
- lineNo: "12",
78
- content: " nested 7#ABCD│content",
79
- });
80
- assert.deepEqual(parseDisplayRow(anchored), parseHashline(anchored));
81
- }
82
- assert.deepEqual(parseDisplayRow("123│ �│7#ABCD│nested"), {
83
- lineNo: "123",
84
- content: " �│7#ABCD│nested",
85
- });
86
- assert.deepEqual(parseDisplayRow(plainRow(9, "a\rb")), { lineNo: "9", content: "a␍b" });
87
- assert.deepEqual(parseDisplayRow("1│"), { lineNo: "1", content: "" });
88
- });
89
-
90
- test("display row parsing rejects headers, notices, and invalid line references", () => {
91
- for (const row of [
92
- "",
93
- "file.txt · 2 matches",
94
- "[Invalid UTF-8: plain preview]",
95
- "No matches found",
96
- "0│text",
97
- "01│text",
98
- "-1│text",
99
- " 1│text",
100
- "1:text",
101
- "0#ABCD│text",
102
- "01#ABCD│text",
103
- "1#A│text",
104
- "1#IIII│text",
105
- ]) {
106
- assert.equal(parseDisplayRow(row), null, row);
107
- }
108
- });
109
-
110
- test("Unicode line separators in display rows → preserves the complete content", async (t) => {
111
- const formatter = createAnchorFormatter(4);
112
- for (const separator of ["\u2028", "\u2029"]) {
113
- const content = `before${separator}after`;
114
- for (const [name, row, parse] of [
115
- ["anchored", formatter.row(12, content), parseHashline],
116
- ["anchored display", formatter.row(12, content), parseDisplayRow],
117
- ["plain display", plainRow(12, content), parseDisplayRow],
118
- ] as const) {
119
- await t.test(`${name} ${JSON.stringify(separator)}`, () => {
120
- assert.deepEqual(parse(row), { lineNo: "12", content });
121
- });
122
- }
123
- }
124
- });
@@ -1,46 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import type { ArgumentIssue, Report } from "./report-schema.ts";
3
-
4
- type ArgumentRejection = Omit<Report, "tool" | "path"> & {
5
- error: "INVALID_ARGUMENTS";
6
- issues: ArgumentIssue[];
7
- };
8
-
9
- /** Assert the model-facing JSON contract before inspecting an individual rejection. */
10
- export function argumentError(error: unknown): ArgumentRejection {
11
- assert.ok(error instanceof Error);
12
- const value: unknown = JSON.parse(error.message);
13
- assert.ok(typeof value === "object" && value !== null);
14
- assert.equal(Reflect.get(value, "error"), "INVALID_ARGUMENTS");
15
- assert.equal(Object.hasOwn(value, "tool"), false);
16
- assert.equal(Object.hasOwn(value, "path"), false);
17
- const issues: unknown = Reflect.get(value, "issues");
18
- assert.ok(Array.isArray(issues));
19
- for (const issue of issues) {
20
- assert.ok(typeof issue === "object" && issue !== null);
21
- assert.equal(typeof Reflect.get(issue, "field"), "string");
22
- assert.equal(typeof Reflect.get(issue, "reason"), "string");
23
- }
24
- // The assertions above establish the output boundary's required fields.
25
- return value as ArgumentRejection;
26
- }
27
-
28
- /** Match a precise field and caller-relevant reason, independent of JSON layout. */
29
- export function rejectsArgument(field: string, reason: RegExp = /./) {
30
- return (error: unknown): boolean => {
31
- const result = argumentError(error);
32
- assert.ok(
33
- result.issues.some((issue) => issue.field === field && reason.test(issue.reason)),
34
- JSON.stringify(result),
35
- );
36
- return true;
37
- };
38
- }
39
-
40
- export function rejectsArguments() {
41
- return (error: unknown): boolean => {
42
- const result = argumentError(error);
43
- assert.ok(result.issues.length > 0);
44
- return true;
45
- };
46
- }
@@ -1,196 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { test } from "node:test";
3
- import { makeEditOverride } from "./tool-factories.testing.ts";
4
- import { makeReadOverride } from "./tool-factories.testing.ts";
5
- import { makeGrepOverride } from "./tool-factories.testing.ts";
6
- import { makeWriteOverride } from "./tool-factories.testing.ts";
7
- import { makeReplaceTool } from "./tool-factories.testing.ts";
8
- import { DEFAULT_CONFIG } from "./tool-factories.testing.ts";
9
- import { outputBudgetsFor } from "./budgets.ts";
10
- import { DEFAULT_OUTPUT_BUDGETS } from "./tool-factories.testing.ts";
11
- import { callTool } from "./tool-call.testing.ts";
12
- import { argumentError } from "./argument-error.testing.ts";
13
-
14
- const cwd = process.cwd();
15
-
16
- test("all tools receive invalid arguments → return field diagnostics without an argument copy or execution", async () => {
17
- const cases = [
18
- {
19
- tool: makeEditOverride(cwd, DEFAULT_CONFIG),
20
- args: { path: "unused", steps: [{ action: "append", lines: [] }] },
21
- },
22
- { tool: makeReadOverride(cwd, DEFAULT_CONFIG), args: { path: "unused", limit: 0 } },
23
- { tool: makeGrepOverride(cwd, DEFAULT_CONFIG), args: { pattern: "", literal: true } },
24
- { tool: makeWriteOverride(cwd), args: { path: "unused", content: "bad\0", mode: "create" } },
25
- {
26
- tool: makeReplaceTool(cwd, DEFAULT_CONFIG),
27
- args: { path: "unused", replacements: [{ literal: true, find: "a", replace: "bad\0" }] },
28
- },
29
- ];
30
- for (const { tool, args } of cases) {
31
- let executed = false;
32
- await assert.rejects(
33
- callTool(
34
- {
35
- ...tool,
36
- execute: async () => {
37
- executed = true;
38
- return { content: [] };
39
- },
40
- },
41
- args,
42
- ),
43
- (error: unknown) => {
44
- const result = argumentError(error);
45
- assert.ok(result.issues.length > 0);
46
- assert.equal(Object.hasOwn(result, "arguments"), false);
47
- return true;
48
- },
49
- );
50
- assert.equal(executed, false);
51
- }
52
- });
53
-
54
- test("Pi prepares a singleton operation → semantic and schema paths resolve to the prepared array", async () => {
55
- const tool = makeEditOverride(cwd, DEFAULT_CONFIG);
56
- await assert.rejects(
57
- callTool(tool, { path: "unused", steps: { action: "insert_after", lines: [] } }),
58
- (error: unknown) => {
59
- const result = argumentError(error);
60
- assert.deepEqual(
61
- result.issues.map((issue) => issue.field),
62
- ["steps[0].anchor", "steps[0].lines"],
63
- );
64
- return true;
65
- },
66
- );
67
- await assert.rejects(
68
- callTool(makeReadOverride(cwd, DEFAULT_CONFIG), { path: "unused", offset: "1", limit: 0 }),
69
- (error: unknown) => {
70
- const result = argumentError(error);
71
- assert.deepEqual(
72
- result.issues.map((issue) => issue.field),
73
- ["limit"],
74
- );
75
- assert.equal(result.schemaLimited, undefined);
76
- return true;
77
- },
78
- );
79
- });
80
-
81
- test("JSON diagnostics exceed the budget → retain whole opening and closing issues and label omissions", async () => {
82
- const budget = outputBudgetsFor(4096);
83
- const tool = makeEditOverride(cwd, DEFAULT_CONFIG, undefined, () => budget);
84
- const maxItems: unknown = Reflect.get(tool.parameters.properties.steps, "maxItems");
85
- assert.ok(typeof maxItems === "number");
86
- const steps = Array.from({ length: maxItems }, () => ({
87
- action: "append",
88
- lines: [],
89
- }));
90
- await assert.rejects(callTool(tool, { path: "", steps }), (error: unknown) => {
91
- const result = argumentError(error);
92
- assert.ok(error instanceof Error && Buffer.byteLength(error.message) <= budget.blockBytes);
93
- assert.equal(result.issues[0].field, "steps[0].lines");
94
- assert.equal(result.issues.at(-1)?.field, "path");
95
- assert.ok((result.omittedIssues ?? 0) > 0);
96
- assert.equal(result.issues.length + (result.omittedIssues ?? 0), steps.length + 1);
97
- return true;
98
- });
99
- });
100
-
101
- test("a reason contains an oversized anchor → keep its cause and recovery instruction inside valid JSON", async () => {
102
- const anchor = `${"9".repeat(DEFAULT_OUTPUT_BUDGETS.blockBytes)}#${"A".repeat(DEFAULT_CONFIG.hashLen)}`;
103
- await assert.rejects(
104
- callTool(makeEditOverride(cwd, DEFAULT_CONFIG), {
105
- path: "unused",
106
- steps: [{ action: "delete", anchor }],
107
- }),
108
- (error: unknown) => {
109
- const result = argumentError(error);
110
- assert.ok(
111
- error instanceof Error &&
112
- Buffer.byteLength(error.message) <= DEFAULT_OUTPUT_BUDGETS.blockBytes,
113
- );
114
- assert.equal(result.issues.length, 1);
115
- assert.equal(result.issues[0].field, "steps[0].anchor");
116
- assert.match(result.issues[0].reason, /^line number/);
117
- assert.match(result.issues[0].fix ?? "", /Copy a complete.*latest tool result/);
118
- assert.doesNotMatch(result.issues[0].reason, /Read|grep|Copy/);
119
- return true;
120
- },
121
- );
122
- });
123
-
124
- test("cyclic arguments → retain the field diagnostic", async () => {
125
- const args: { path: string; self?: unknown } = { path: "unused" };
126
- args.self = args;
127
- await assert.rejects(callTool(makeReadOverride(cwd, DEFAULT_CONFIG), args), (error: unknown) => {
128
- const result = argumentError(error);
129
- assert.equal(result.issues[0].field, "self");
130
- assert.match(result.issues[0].reason, /not allowed/);
131
- return true;
132
- });
133
- });
134
-
135
- test("Pi cannot clone an argument → report the original cause in the same JSON envelope", async () => {
136
- await assert.rejects(
137
- callTool(makeReadOverride(cwd, DEFAULT_CONFIG), { path: "unused", extra: () => undefined }),
138
- (error: unknown) => {
139
- const result = argumentError(error);
140
- assert.equal(result.issues[0].field, "$");
141
- assert.match(result.issues[0].reason, /clone/i);
142
- return true;
143
- },
144
- );
145
- });
146
-
147
- test("a non-finite numeric argument → reports its field without JSON encoding the value", async () => {
148
- await assert.rejects(
149
- callTool(makeReadOverride(cwd, DEFAULT_CONFIG), { path: "unused", limit: Infinity }),
150
- (error: unknown) => {
151
- const result = argumentError(error);
152
- assert.equal(result.issues[0].field, "limit");
153
- return true;
154
- },
155
- );
156
- });
157
-
158
- test("a property path exceeds the JSON budget → omit the whole issue and keep another field", async () => {
159
- await assert.rejects(
160
- callTool(makeReadOverride(cwd, DEFAULT_CONFIG), {
161
- path: "",
162
- ['"中🙂'.repeat(DEFAULT_OUTPUT_BUDGETS.blockBytes)]: true,
163
- }),
164
- (error: unknown) => {
165
- const result = argumentError(error);
166
- assert.ok(
167
- error instanceof Error &&
168
- Buffer.byteLength(error.message) <= DEFAULT_OUTPUT_BUDGETS.blockBytes,
169
- );
170
- assert.equal(result.issues.length, 1);
171
- assert.equal(result.issues[0].field, "path");
172
- assert.equal(result.omittedIssues, 1);
173
- return true;
174
- },
175
- );
176
- });
177
-
178
- test("a large valid argument → leaves the diagnostic budget for invalid fields", async () => {
179
- await assert.rejects(
180
- callTool(makeReadOverride(cwd, DEFAULT_CONFIG), {
181
- path: '"中🙂'.repeat(DEFAULT_OUTPUT_BUDGETS.blockBytes),
182
- limit: 0,
183
- }),
184
- (error: unknown) => {
185
- const result = argumentError(error);
186
- assert.ok(
187
- error instanceof Error &&
188
- Buffer.byteLength(error.message) <= DEFAULT_OUTPUT_BUDGETS.blockBytes,
189
- );
190
- assert.equal(result.issues.length, 1);
191
- assert.equal(result.issues[0].field, "limit");
192
- assert.equal(result.omittedIssues, undefined);
193
- return true;
194
- },
195
- );
196
- });