@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.
- package/README.md +18 -12
- package/README.zh-CN.md +18 -12
- package/package.json +8 -1
- package/src/core/AGENTS.md +3 -1
- package/src/core/apply.ts +110 -117
- package/src/core/character-set.ts +2 -3
- package/src/core/copy-span.ts +15 -0
- package/src/core/errors.ts +24 -9
- package/src/core/lines.ts +71 -17
- package/src/core/ranges.ts +5 -4
- package/src/core/replace-schema.ts +3 -1
- package/src/core/replace.ts +50 -29
- package/src/core/search-analysis.ts +21 -22
- package/src/core/search.ts +15 -32
- package/src/core/types.ts +3 -0
- package/src/index.ts +47 -39
- package/src/pi/AGENTS.md +30 -19
- package/src/pi/action-fusion.ts +284 -211
- package/src/pi/argument-diagnostics.ts +50 -37
- package/src/pi/argument-error.ts +2 -2
- package/src/pi/argument-validation.ts +163 -66
- package/src/pi/budgets.ts +12 -0
- package/src/pi/diagnostic-buffer.ts +12 -11
- package/src/pi/edit-tool.ts +138 -115
- package/src/pi/error-text.ts +10 -2
- package/src/pi/failure-context.ts +24 -37
- package/src/pi/file-commit.ts +131 -164
- package/src/pi/file-read.ts +122 -31
- package/src/pi/fusion-arguments.ts +214 -0
- package/src/pi/fusion-card.ts +102 -60
- package/src/pi/grep-candidates.ts +35 -22
- package/src/pi/grep-output.ts +197 -190
- package/src/pi/grep-render.ts +22 -13
- package/src/pi/grep-reread.ts +7 -6
- package/src/pi/grep-scope.ts +31 -16
- package/src/pi/grep-search.ts +56 -47
- package/src/pi/grep-tool.ts +35 -33
- package/src/pi/grep-worker.ts +3 -4
- package/src/pi/mutation-diff.ts +238 -0
- package/src/pi/mutation-result.ts +102 -79
- package/src/pi/mutation-runner.ts +107 -84
- package/src/pi/native-bash.ts +41 -0
- package/src/pi/path.ts +59 -6
- package/src/pi/read-tool.ts +173 -138
- package/src/pi/regex-worker.ts +14 -8
- package/src/pi/render.ts +101 -54
- package/src/pi/replace-regex.ts +1 -1
- package/src/pi/replace-tool.ts +14 -7
- package/src/pi/report-cause.ts +34 -17
- package/src/pi/report-schema.ts +184 -85
- package/src/pi/report.ts +133 -64
- package/src/pi/rg-process.ts +68 -48
- package/src/pi/schema.ts +4 -0
- package/src/pi/text-stream.ts +81 -87
- package/src/pi/workspace-cwd.js +2 -0
- package/src/pi/workspace.ts +46 -0
- package/src/pi/write-tool.ts +19 -13
- package/src/core/apply.test.ts +0 -644
- package/src/core/case-fold.test.ts +0 -35
- package/src/core/character-set.test.ts +0 -97
- package/src/core/errors.test.ts +0 -39
- package/src/core/hash.test.ts +0 -64
- package/src/core/lines.test.ts +0 -63
- package/src/core/ranges.test.ts +0 -123
- package/src/core/replace.test.ts +0 -187
- package/src/core/search-analysis.test.ts +0 -210
- package/src/core/search-matrix.test.ts +0 -64
- package/src/core/search-matrix.testing.ts +0 -171
- package/src/core/search.test.ts +0 -132
- package/src/core/text.test.ts +0 -52
- package/src/integration/config-registration.test.ts +0 -291
- package/src/integration/fusion-dispatch.test.ts +0 -320
- package/src/integration/grep-errors.test.ts +0 -81
- package/src/integration/grep-flags.test.ts +0 -76
- package/src/integration/grep-js-completeness.test.ts +0 -278
- package/src/integration/grep-line-candidates.test.ts +0 -201
- package/src/integration/grep-matrix.test.ts +0 -118
- package/src/integration/grep-order.test.ts +0 -78
- package/src/integration/grep-path-matrix.test.ts +0 -128
- package/src/integration/grep-prefilter-coverage.test.ts +0 -204
- package/src/integration/grep-process-limits.test.ts +0 -122
- package/src/integration/grep-regex.test.ts +0 -412
- package/src/integration/grep-rg.test.ts +0 -1659
- package/src/integration/grep-scan-budget.test.ts +0 -111
- package/src/integration/grep-translation.test.ts +0 -199
- package/src/integration/large-text.test.ts +0 -70
- package/src/integration/model-budget-lifecycle.test.ts +0 -186
- package/src/integration/mutation-file-types.test.ts +0 -30
- package/src/integration/mutation-file-types.testing.ts +0 -33
- package/src/integration/npm-package.test.ts +0 -19
- package/src/integration/npm-package.testing.ts +0 -243
- package/src/integration/publication-read-changes.test.ts +0 -454
- package/src/integration/read-changes.test.ts +0 -98
- package/src/integration/replace-package.test.ts +0 -22
- package/src/integration/replace-package.testing.ts +0 -36
- package/src/integration/replace-worker-boundary.test.ts +0 -127
- package/src/integration/report-replay.test.ts +0 -91
- package/src/integration/utf8-errors.test.ts +0 -46
- package/src/pi/action-fusion.test.ts +0 -659
- package/src/pi/action-fusion.testing.ts +0 -38
- package/src/pi/anchor-format.test.ts +0 -124
- package/src/pi/argument-error.testing.ts +0 -46
- package/src/pi/argument-format.test.ts +0 -196
- package/src/pi/argument-validation.test.ts +0 -1007
- package/src/pi/codemode.test.ts +0 -101
- package/src/pi/config.test.ts +0 -204
- package/src/pi/diagnostic-buffer.test.ts +0 -115
- package/src/pi/directory-sync.test.ts +0 -57
- package/src/pi/execute.test.ts +0 -1257
- package/src/pi/extension-loading.test.ts +0 -14
- package/src/pi/extension-loading.testing.ts +0 -3
- package/src/pi/failure-context.test.ts +0 -370
- package/src/pi/failure-path.test.ts +0 -289
- package/src/pi/file-commit.test.ts +0 -628
- package/src/pi/file-read.test.ts +0 -29
- package/src/pi/file-snapshot.test.ts +0 -22
- package/src/pi/fusion-card-interaction.test.ts +0 -143
- package/src/pi/fusion-card.test.ts +0 -353
- package/src/pi/grep-candidates.test.ts +0 -26
- package/src/pi/grep-matrix.test.ts +0 -68
- package/src/pi/grep-order.test.ts +0 -447
- package/src/pi/grep-output.testing.ts +0 -24
- package/src/pi/grep-rg.testing.ts +0 -73
- package/src/pi/grep.test.ts +0 -1670
- package/src/pi/model-budgets.test.ts +0 -96
- package/src/pi/mutation-outcome.testing.ts +0 -20
- package/src/pi/mutation-result.test.ts +0 -96
- package/src/pi/output-budgets.test.ts +0 -221
- package/src/pi/pi.test.ts +0 -158
- package/src/pi/read-delegation.test.ts +0 -119
- package/src/pi/read.test.ts +0 -735
- package/src/pi/regex-worker.test.ts +0 -42
- package/src/pi/registration.test.ts +0 -549
- package/src/pi/render.test.ts +0 -841
- package/src/pi/replace.test.ts +0 -634
- package/src/pi/report-failure.testing.ts +0 -27
- package/src/pi/report.test.ts +0 -533
- package/src/pi/result-safety.test.ts +0 -597
- package/src/pi/rg-process.test.ts +0 -133
- package/src/pi/rg-regex.test.ts +0 -40
- package/src/pi/text-stream.test.ts +0 -281
- package/src/pi/tool-call.testing.ts +0 -61
- package/src/pi/tool-factories.testing.ts +0 -59
- package/src/pi/write.test.ts +0 -256
- package/src/testing/extension-loader.testing.ts +0 -24
- package/src/testing/installation.testing.ts +0 -77
- package/src/testing/process.testing.ts +0 -33
- package/src/testing/regex-host.testing.ts +0 -20
- package/src/testing/regex-translation-corpus.ts +0 -267
- package/src/testing/rg-line-listing.fixture.mjs +0 -7
- package/src/testing/run-tests.ts +0 -47
- package/src/testing/session.testing.ts +0 -127
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
import { installedExtension } from "../testing/installation.testing.ts";
|
|
4
|
-
import { runTestProcess } from "../testing/process.testing.ts";
|
|
5
|
-
|
|
6
|
-
test("extension installed without devDependencies → loads through Pi's virtual modules", async (t) => {
|
|
7
|
-
const installation = await installedExtension(t);
|
|
8
|
-
await runTestProcess(
|
|
9
|
-
process.execPath,
|
|
10
|
-
[fileURLToPath(new URL("./extension-loading.testing.ts", import.meta.url)), installation.entry],
|
|
11
|
-
installation.root,
|
|
12
|
-
installation.agentDir,
|
|
13
|
-
);
|
|
14
|
-
});
|
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
import { computeLineHash } from "../core/hash.ts";
|
|
4
|
-
import { applyEdits } from "../core/apply.ts";
|
|
5
|
-
import { HashlineError } from "../core/errors.ts";
|
|
6
|
-
import type { AnchorFailure, Edit } from "../core/types.ts";
|
|
7
|
-
import { formatByteSize, outputBudgetsFor } from "./budgets.ts";
|
|
8
|
-
import { DEFAULT_OUTPUT_BUDGETS } from "./tool-factories.testing.ts";
|
|
9
|
-
import { DEFAULT_CONFIG } from "./tool-factories.testing.ts";
|
|
10
|
-
import { createAnchorFormatter } from "./anchor-format.ts";
|
|
11
|
-
import { describeEditFailure } from "./failure-context.ts";
|
|
12
|
-
import { describeMutationFailure } from "./mutation-result.ts";
|
|
13
|
-
import { renderReport } from "./report.ts";
|
|
14
|
-
|
|
15
|
-
function failure(recovery: AnchorFailure["recovery"]): AnchorFailure {
|
|
16
|
-
return {
|
|
17
|
-
opIndex: 0,
|
|
18
|
-
which: "anchor",
|
|
19
|
-
op: "replace",
|
|
20
|
-
cited: { line: 1, hash: "OLD" },
|
|
21
|
-
recovery,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function ambiguous(lines: readonly string[], positions: number[], hashLen = 4): AnchorFailure {
|
|
25
|
-
return failure({
|
|
26
|
-
kind: "ambiguous",
|
|
27
|
-
candidates: positions.map((line) => ({
|
|
28
|
-
line,
|
|
29
|
-
hash: computeLineHash(line, lines[line - 1], hashLen),
|
|
30
|
-
})),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function neighborhoods(text: string, failures: readonly AnchorFailure[], hashLen = 4) {
|
|
34
|
-
const error = describeEditFailure(
|
|
35
|
-
text,
|
|
36
|
-
failures,
|
|
37
|
-
createAnchorFormatter(hashLen),
|
|
38
|
-
DEFAULT_OUTPUT_BUDGETS,
|
|
39
|
-
);
|
|
40
|
-
assert.equal(error.errorCode, "ANCHOR_MISMATCH");
|
|
41
|
-
assert.ok(error.facts);
|
|
42
|
-
assert.equal(error.facts.failures.length, failures.length);
|
|
43
|
-
assert.equal(error.facts.omittedFailures, undefined);
|
|
44
|
-
return error.facts;
|
|
45
|
-
}
|
|
46
|
-
function rows(result: ReturnType<typeof neighborhoods>) {
|
|
47
|
-
return result.candidateNeighborhoods?.flatMap((group) => group.rows) ?? [];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
test("unique and unresolved failures → no ambiguous neighborhoods", () => {
|
|
51
|
-
for (const { text, failures } of [
|
|
52
|
-
{
|
|
53
|
-
text: "a\nb\nc\n",
|
|
54
|
-
failures: [failure({ kind: "found", newLine: 2, newHash: "NEW" }), failure({ kind: "none" })],
|
|
55
|
-
},
|
|
56
|
-
{ text: "", failures: [failure({ kind: "none" })] },
|
|
57
|
-
]) {
|
|
58
|
-
const facts = neighborhoods(text, failures);
|
|
59
|
-
assert.equal(facts.candidateNeighborhoods, undefined);
|
|
60
|
-
assert.equal(facts.omittedNeighborhoodRows, undefined);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("ambiguous CRLF and BOM context → merges sorted windows with copyable anchors", () => {
|
|
65
|
-
const lines = ["\uFEFFfirst", "a", "", "c", "d", "e", "f", "last"];
|
|
66
|
-
const result = neighborhoods(lines.join("\r\n"), [ambiguous(lines, [6, 2], 6)], 6);
|
|
67
|
-
assert.deepEqual(
|
|
68
|
-
result.candidateNeighborhoods?.map((group) => group.lines),
|
|
69
|
-
["1-8"],
|
|
70
|
-
);
|
|
71
|
-
assert.deepEqual(
|
|
72
|
-
rows(result),
|
|
73
|
-
lines.map(
|
|
74
|
-
(content, index) => `${index + 1}#${computeLineHash(index + 1, content, 6)}│${content}`,
|
|
75
|
-
),
|
|
76
|
-
);
|
|
77
|
-
assert.doesNotMatch(rows(result).join("\n"), /\r/);
|
|
78
|
-
assert.equal(result.omittedNeighborhoodRows, undefined);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("ambiguous candidates at BOF and EOF → clipped windows without padding", () => {
|
|
82
|
-
const lines = Array.from({ length: 10 }, (_, index) => `${index + 1}`);
|
|
83
|
-
const result = neighborhoods(lines.join("\n"), [ambiguous(lines, [1, 10])]);
|
|
84
|
-
assert.deepEqual(
|
|
85
|
-
result.candidateNeighborhoods?.map((group) => group.lines),
|
|
86
|
-
["1-4", "7-10"],
|
|
87
|
-
);
|
|
88
|
-
assert.equal(rows(result).length, 8);
|
|
89
|
-
assert.equal(result.omittedNeighborhoodRows, undefined);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("more than forty context rows and repeated windows → no row cap or duplication", () => {
|
|
93
|
-
const lines = Array.from({ length: 60 }, (_, index) => `line-${index + 1}`);
|
|
94
|
-
const result = neighborhoods(lines.join("\n"), [ambiguous(lines, [4, 14, 24, 34, 44, 54])]);
|
|
95
|
-
assert.equal(rows(result).length, 42);
|
|
96
|
-
assert.equal(result.omittedNeighborhoodRows, undefined);
|
|
97
|
-
const repeated = neighborhoods(
|
|
98
|
-
lines.join("\n"),
|
|
99
|
-
Array.from({ length: 50 }, (_, opIndex) => ({ ...ambiguous(lines, [4, 5]), opIndex })),
|
|
100
|
-
);
|
|
101
|
-
assert.equal(rows(repeated).length, 8);
|
|
102
|
-
assert.equal(new Set(rows(repeated)).size, 8);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test("more than eight ambiguous candidates → context uses the same candidate prefix", () => {
|
|
106
|
-
const lines = Array.from({ length: 90 }, (_, index) => `line-${index + 1}`);
|
|
107
|
-
const result = neighborhoods(lines.join("\n"), [
|
|
108
|
-
ambiguous(lines, [4, 14, 24, 34, 44, 54, 64, 74, 84]),
|
|
109
|
-
]);
|
|
110
|
-
assert.equal(rows(result).length, 56);
|
|
111
|
-
assert.ok(rows(result).some((row) => /^77#[0-9A-Z]+│line-77$/.test(row)));
|
|
112
|
-
assert.ok(rows(result).every((row) => !/^8[1-7]#/.test(row)));
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("neighborhood exceeds byte budget → whole rows and explicit omission counts", () => {
|
|
116
|
-
const empty = [{ lines: "1-1", rows: ["1#XXXX│"] }];
|
|
117
|
-
const exact = "x".repeat(
|
|
118
|
-
DEFAULT_OUTPUT_BUDGETS.blockBytes - Buffer.byteLength(JSON.stringify(empty)),
|
|
119
|
-
);
|
|
120
|
-
const cases = [
|
|
121
|
-
{ lines: [exact, "target", "last"], shown: [1], omitted: 2 },
|
|
122
|
-
{ lines: ["界".repeat(6000), "target", "last"], shown: [2, 3], omitted: 1 },
|
|
123
|
-
{ lines: ["short", "界".repeat(6000), "target", "last"], shown: [1, 3, 4], omitted: 1 },
|
|
124
|
-
{
|
|
125
|
-
lines: [
|
|
126
|
-
"x".repeat(DEFAULT_OUTPUT_BUDGETS.fieldBytes),
|
|
127
|
-
"y".repeat(DEFAULT_OUTPUT_BUDGETS.fieldBytes),
|
|
128
|
-
],
|
|
129
|
-
shown: [],
|
|
130
|
-
omitted: 2,
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
for (const { lines, shown, omitted } of cases) {
|
|
134
|
-
const result = neighborhoods(lines.join("\n"), [
|
|
135
|
-
ambiguous(lines, [lines.length - 1, lines.length]),
|
|
136
|
-
]);
|
|
137
|
-
assert.deepEqual(
|
|
138
|
-
rows(result),
|
|
139
|
-
shown.map(
|
|
140
|
-
(position) =>
|
|
141
|
-
`${position}#${computeLineHash(position, lines[position - 1], 4)}│${lines[position - 1]}`,
|
|
142
|
-
),
|
|
143
|
-
);
|
|
144
|
-
assert.equal(result.omittedNeighborhoodRows, omitted);
|
|
145
|
-
assert.ok(
|
|
146
|
-
Buffer.byteLength(JSON.stringify(result.candidateNeighborhoods)) <=
|
|
147
|
-
DEFAULT_OUTPUT_BUDGETS.blockBytes,
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("candidate complete row at its byte limit → kept exactly or omitted whole", () => {
|
|
153
|
-
for (const extra of [0, 1]) {
|
|
154
|
-
const candidate = "x".repeat(
|
|
155
|
-
DEFAULT_OUTPUT_BUDGETS.fieldBytes - Buffer.byteLength("2#XXXXXX│") + extra,
|
|
156
|
-
);
|
|
157
|
-
const lines = ["prefix", candidate, "tail", "other"];
|
|
158
|
-
const result = neighborhoods(lines.join("\n"), [ambiguous(lines, [2, 4], 6)], 6);
|
|
159
|
-
assert.equal(
|
|
160
|
-
rows(result).some((row) => row.startsWith("2#")),
|
|
161
|
-
extra === 0,
|
|
162
|
-
);
|
|
163
|
-
assert.equal(result.omittedNeighborhoodRows, extra === 0 ? undefined : 1);
|
|
164
|
-
assert.ok(rows(result).some((row) => row.startsWith("4#")));
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test("unique candidate inside ambiguous context exceeds limit → context cannot bypass its row limit", () => {
|
|
169
|
-
const lines = ["prefix", "x".repeat(DEFAULT_OUTPUT_BUDGETS.fieldBytes), "match", "match"];
|
|
170
|
-
const result = neighborhoods(lines.join("\n"), [
|
|
171
|
-
ambiguous(lines, [3, 4]),
|
|
172
|
-
failure({
|
|
173
|
-
kind: "found",
|
|
174
|
-
newLine: 2,
|
|
175
|
-
newHash: computeLineHash(2, lines[1], 4),
|
|
176
|
-
}),
|
|
177
|
-
]);
|
|
178
|
-
assert.equal(
|
|
179
|
-
rows(result).some((row) => row.startsWith("2#")),
|
|
180
|
-
false,
|
|
181
|
-
);
|
|
182
|
-
assert.equal(result.omittedNeighborhoodRows, 1);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test("remaining context budget cannot fit an intermediate row → retain shorter later rows", () => {
|
|
186
|
-
const lines = [
|
|
187
|
-
"x".repeat(DEFAULT_OUTPUT_BUDGETS.blockBytes - 100),
|
|
188
|
-
"y".repeat(200),
|
|
189
|
-
"target",
|
|
190
|
-
"other",
|
|
191
|
-
];
|
|
192
|
-
const result = neighborhoods(lines.join("\n"), [ambiguous(lines, [3, 4])]);
|
|
193
|
-
assert.deepEqual(
|
|
194
|
-
rows(result).map((row) => Number(row.split("#")[0])),
|
|
195
|
-
[1, 3, 4],
|
|
196
|
-
);
|
|
197
|
-
assert.equal(result.omittedNeighborhoodRows, 1);
|
|
198
|
-
assert.ok(Buffer.byteLength(rows(result).join("\n") + "\n") <= DEFAULT_OUTPUT_BUDGETS.blockBytes);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
function rejectedEdit(
|
|
202
|
-
text: string,
|
|
203
|
-
edits: Edit[],
|
|
204
|
-
shiftRadius = 0,
|
|
205
|
-
budget = DEFAULT_OUTPUT_BUDGETS,
|
|
206
|
-
) {
|
|
207
|
-
const result = applyEdits(text, edits, DEFAULT_CONFIG.hashLen, shiftRadius);
|
|
208
|
-
assert.ok(!result.ok, "the fixture must reach failure reporting");
|
|
209
|
-
const error = describeEditFailure(
|
|
210
|
-
text,
|
|
211
|
-
result.failures,
|
|
212
|
-
createAnchorFormatter(DEFAULT_CONFIG.hashLen),
|
|
213
|
-
budget,
|
|
214
|
-
);
|
|
215
|
-
return describeMutationFailure("edit", error, { path: "file.txt", budget });
|
|
216
|
-
}
|
|
217
|
-
const oldAnchor = { line: 1, hash: computeLineHash(1, "old", DEFAULT_CONFIG.hashLen) };
|
|
218
|
-
|
|
219
|
-
test("multiple unresolved anchors and candidate context → one recovery survives omitted facts", () => {
|
|
220
|
-
const budget = outputBudgetsFor(DEFAULT_OUTPUT_BUDGETS.fieldBytes);
|
|
221
|
-
const omittedFailureCount = 16;
|
|
222
|
-
const cases = [
|
|
223
|
-
...[2, omittedFailureCount].map((count) => ({
|
|
224
|
-
text: "current\n",
|
|
225
|
-
edits: Array.from({ length: count }, (): Edit => ({ op: "delete", anchor: oldAnchor })),
|
|
226
|
-
radius: 0,
|
|
227
|
-
omitted: count === omittedFailureCount,
|
|
228
|
-
})),
|
|
229
|
-
{
|
|
230
|
-
text: "current\nold\n",
|
|
231
|
-
edits: [{ op: "delete", anchor: oldAnchor }] satisfies Edit[],
|
|
232
|
-
radius: 2,
|
|
233
|
-
omitted: false,
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
text: "current\nold\nold\n",
|
|
237
|
-
edits: [{ op: "delete", anchor: oldAnchor }] satisfies Edit[],
|
|
238
|
-
radius: 2,
|
|
239
|
-
omitted: false,
|
|
240
|
-
},
|
|
241
|
-
...["gone", "neighbor"].map((content) => ({
|
|
242
|
-
text: "current\nneighbor\nold\nold\n",
|
|
243
|
-
edits: [
|
|
244
|
-
{ op: "delete", anchor: oldAnchor },
|
|
245
|
-
{
|
|
246
|
-
op: "delete",
|
|
247
|
-
anchor: {
|
|
248
|
-
line: content === "gone" ? 2 : 1,
|
|
249
|
-
hash: computeLineHash(content === "gone" ? 2 : 1, content, DEFAULT_CONFIG.hashLen),
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
] satisfies Edit[],
|
|
253
|
-
radius: DEFAULT_CONFIG.shiftRadius,
|
|
254
|
-
omitted: false,
|
|
255
|
-
})),
|
|
256
|
-
];
|
|
257
|
-
for (const fixture of cases) {
|
|
258
|
-
const report = rejectedEdit(fixture.text, fixture.edits, fixture.radius, budget);
|
|
259
|
-
assert.equal(report.error, "ANCHOR_MISMATCH");
|
|
260
|
-
assert.equal(
|
|
261
|
-
report.next,
|
|
262
|
-
"Confirm a candidate or observed anchor is the intended target before reusing it; otherwise use read or grep.",
|
|
263
|
-
);
|
|
264
|
-
const { next, ...facts } = report;
|
|
265
|
-
assert.equal(renderReport(report).split(next!).length - 1, 1);
|
|
266
|
-
assert.doesNotMatch(JSON.stringify(facts), /\b(?:confirm|read|grep|retries)\b/i);
|
|
267
|
-
if (fixture.radius === 0) {
|
|
268
|
-
assert.ok(
|
|
269
|
-
report.failures?.every((entry) => /1#[0-9A-Z]+│current/.test(entry.observed ?? "")),
|
|
270
|
-
);
|
|
271
|
-
assert.ok(report.failures && report.failures.length > 0);
|
|
272
|
-
assert.equal(report.failures.length + (report.omittedFailures ?? 0), fixture.edits.length);
|
|
273
|
-
assert.ok(report.failures.every((entry) => entry.result === "unresolved"));
|
|
274
|
-
}
|
|
275
|
-
if (fixture.text === "current\nneighbor\nold\nold\n") {
|
|
276
|
-
const row = createAnchorFormatter(DEFAULT_CONFIG.hashLen).row(2, "neighbor");
|
|
277
|
-
assert.ok(report.candidateNeighborhoods?.some((group) => group.rows.includes(row)));
|
|
278
|
-
const entry = report.failures?.[1];
|
|
279
|
-
assert.ok(entry);
|
|
280
|
-
assert.equal(entry.notShown, undefined);
|
|
281
|
-
if (entry.result === "unresolved") assert.equal(entry.observed, row);
|
|
282
|
-
else {
|
|
283
|
-
assert.equal(entry.result, "shifted");
|
|
284
|
-
assert.equal(entry.content, "neighbor");
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
assert.equal(Boolean(report.omittedFailures), fixture.omitted);
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test("overlapping edits → ordered conflict and shared recovery", () => {
|
|
292
|
-
const text = "a\nb\nc\nd\ne\n";
|
|
293
|
-
const anchor = (line: number, content: string) => ({
|
|
294
|
-
line,
|
|
295
|
-
hash: computeLineHash(line, content, DEFAULT_CONFIG.hashLen),
|
|
296
|
-
});
|
|
297
|
-
const cases: { edits: Edit[] }[] = [
|
|
298
|
-
{
|
|
299
|
-
edits: [
|
|
300
|
-
{ op: "replace", anchor: anchor(2, "b"), body: ["changed"] },
|
|
301
|
-
{ op: "delete", anchor: anchor(4, "d") },
|
|
302
|
-
{ op: "delete", anchor: anchor(1, "a"), end: anchor(2, "b") },
|
|
303
|
-
],
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
edits: [
|
|
307
|
-
{ op: "insert_after", anchor: anchor(2, "b"), body: ["first"] },
|
|
308
|
-
{ op: "delete", anchor: anchor(4, "d") },
|
|
309
|
-
{ op: "insert_before", anchor: anchor(3, "c"), body: ["second"] },
|
|
310
|
-
],
|
|
311
|
-
},
|
|
312
|
-
];
|
|
313
|
-
for (const { edits } of cases) {
|
|
314
|
-
assert.throws(
|
|
315
|
-
() => applyEdits(text, edits, DEFAULT_CONFIG.hashLen, 0),
|
|
316
|
-
(error: unknown) => {
|
|
317
|
-
assert.ok(error instanceof HashlineError);
|
|
318
|
-
const report = describeMutationFailure("edit", error, {
|
|
319
|
-
path: "file.txt",
|
|
320
|
-
budget: DEFAULT_OUTPUT_BUDGETS,
|
|
321
|
-
});
|
|
322
|
-
assert.equal(report.error, "OVERLAPPING_EDITS");
|
|
323
|
-
assert.deepEqual(report.conflict, ["steps[0]", "steps[2]"]);
|
|
324
|
-
assert.equal(report.message, error.message);
|
|
325
|
-
assert.equal(report.publication, "NOT_PUBLISHED");
|
|
326
|
-
assert.match(report.next ?? "", /one step per range or position/);
|
|
327
|
-
return true;
|
|
328
|
-
},
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
test("unresolved row out of range or oversized → omission facts contain no recovery instructions", () => {
|
|
334
|
-
const text = "x".repeat(DEFAULT_OUTPUT_BUDGETS.fieldBytes) + "\n";
|
|
335
|
-
const cases = [
|
|
336
|
-
{
|
|
337
|
-
anchor: oldAnchor,
|
|
338
|
-
reason: new RegExp(`row exceeds ${formatByteSize(DEFAULT_OUTPUT_BUDGETS.fieldBytes)}`),
|
|
339
|
-
},
|
|
340
|
-
{ anchor: { ...oldAnchor, line: 2 }, reason: /cited line is out of range/ },
|
|
341
|
-
];
|
|
342
|
-
for (const { anchor, reason } of cases) {
|
|
343
|
-
const report = rejectedEdit(text, [{ op: "delete", anchor }]);
|
|
344
|
-
assert.equal(report.error, "ANCHOR_MISMATCH");
|
|
345
|
-
assert.match(report.failures?.[0].notShown ?? "", reason);
|
|
346
|
-
assert.equal(report.failures?.[0].observed, undefined);
|
|
347
|
-
assert.doesNotMatch(
|
|
348
|
-
JSON.stringify(report.failures),
|
|
349
|
-
/\b(?:confirm|read|grep|retry|retries)\b/i,
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
test("escaped neighborhood rows → count their JSON bytes before reporting complete rows", () => {
|
|
355
|
-
const budget = outputBudgetsFor(1);
|
|
356
|
-
const report = rejectedEdit(
|
|
357
|
-
`current\n${"\\".repeat(Math.floor(budget.blockBytes * 0.75))}\nold\nold\n`,
|
|
358
|
-
[{ op: "delete", anchor: oldAnchor }],
|
|
359
|
-
4,
|
|
360
|
-
budget,
|
|
361
|
-
);
|
|
362
|
-
assert.ok(report.candidateNeighborhoods);
|
|
363
|
-
assert.ok(Buffer.byteLength(JSON.stringify(report.candidateNeighborhoods)) <= budget.blockBytes);
|
|
364
|
-
const shown = report.candidateNeighborhoods.flatMap((group) => group.rows);
|
|
365
|
-
assert.deepEqual(
|
|
366
|
-
shown.map((row) => Number(row.split("#")[0])),
|
|
367
|
-
[1, 3, 4],
|
|
368
|
-
);
|
|
369
|
-
assert.equal(report.omittedNeighborhoodRows, 1);
|
|
370
|
-
});
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import { commandCompletion, type SessionCommand } from "./action-fusion.testing.ts";
|
|
2
|
-
import fs, { mkdtemp, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { syncBuiltinESMExports } from "node:module";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { test } from "node:test";
|
|
8
|
-
import { createActionFusionExecutor } from "./action-fusion.ts";
|
|
9
|
-
import type { ActionFusionProgress } from "./report-schema.ts";
|
|
10
|
-
import { outputBudgetsFor } from "./budgets.ts";
|
|
11
|
-
import { reportOf } from "./report.ts";
|
|
12
|
-
import { callTool, createToolContext } from "./tool-call.testing.ts";
|
|
13
|
-
import { makeWriteOverride } from "./tool-factories.testing.ts";
|
|
14
|
-
|
|
15
|
-
async function withTemp<T>(run: (dir: string) => Promise<T>): Promise<T> {
|
|
16
|
-
const dir = await mkdtemp(join(tmpdir(), "hashline-failure-"));
|
|
17
|
-
try {
|
|
18
|
-
return await run(await realpath(dir));
|
|
19
|
-
} finally {
|
|
20
|
-
await rm(dir, { recursive: true, force: true });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test("temporary preparation and cleanup failures → preserve the commit failure and target bytes", async (t) =>
|
|
25
|
-
withTemp(async (dir) => {
|
|
26
|
-
const target = join(dir, "unpublished.txt");
|
|
27
|
-
await writeFile(target, "before\n");
|
|
28
|
-
const nativeOpen = fs.open;
|
|
29
|
-
const original = Object.assign(new Error("temporary open failed"), { code: "EIO" });
|
|
30
|
-
let failCleanup = false;
|
|
31
|
-
let cleanupFailed = false;
|
|
32
|
-
try {
|
|
33
|
-
t.mock.method(fs, "open", async (...args: Parameters<typeof nativeOpen>) => {
|
|
34
|
-
if (String(args[0]).includes(".hashline-commit-") && args[1] === "w") throw original;
|
|
35
|
-
return nativeOpen(...args);
|
|
36
|
-
});
|
|
37
|
-
const nativeRm = fs.rm;
|
|
38
|
-
t.mock.method(fs, "rm", async (...args: Parameters<typeof nativeRm>) => {
|
|
39
|
-
if (failCleanup && String(args[0]).includes(".hashline-commit-")) {
|
|
40
|
-
cleanupFailed = true;
|
|
41
|
-
throw Object.assign(new Error("temporary cleanup failed"), { code: "EACCES" });
|
|
42
|
-
}
|
|
43
|
-
return nativeRm(...args);
|
|
44
|
-
});
|
|
45
|
-
syncBuiltinESMExports();
|
|
46
|
-
for (failCleanup of [false, true]) {
|
|
47
|
-
const result = await callTool(makeWriteOverride(dir), {
|
|
48
|
-
path: target,
|
|
49
|
-
mode: "overwrite",
|
|
50
|
-
content: "after\n",
|
|
51
|
-
});
|
|
52
|
-
const report = reportOf(result, "write");
|
|
53
|
-
assert.equal(result.isError, true);
|
|
54
|
-
assert.equal(report?.error, "PUBLISH_FAILED");
|
|
55
|
-
assert.equal(report.publication, "NOT_PUBLISHED");
|
|
56
|
-
assert.deepEqual(report.cause, { code: original.code, message: original.message });
|
|
57
|
-
assert.equal(await readFile(target, "utf8"), "before\n");
|
|
58
|
-
assert.equal(cleanupFailed, failCleanup);
|
|
59
|
-
if (!failCleanup) assert.deepEqual(await readdir(dir), ["unpublished.txt"]);
|
|
60
|
-
}
|
|
61
|
-
} finally {
|
|
62
|
-
t.mock.restoreAll();
|
|
63
|
-
syncBuiltinESMExports();
|
|
64
|
-
}
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
test("publication boundary and observer failures → preserve recovery and emit each diagnostic once", async (t) =>
|
|
68
|
-
withTemp(async (dir) => {
|
|
69
|
-
const budget = outputBudgetsFor(4096);
|
|
70
|
-
const context = await createToolContext(dir, t);
|
|
71
|
-
for (const publication of ["NOT_PUBLISHED", "PUBLISHED", "UNKNOWN"] as const) {
|
|
72
|
-
for (const progressError of [
|
|
73
|
-
undefined,
|
|
74
|
-
"display unavailable",
|
|
75
|
-
Object.assign(new Error("display unavailable " + "界".repeat(budget.fieldBytes)), {
|
|
76
|
-
code: "EIO",
|
|
77
|
-
cause: new Error("nested " + "界".repeat(budget.fieldBytes)),
|
|
78
|
-
}),
|
|
79
|
-
]) {
|
|
80
|
-
const target = join(dir, "boundary.txt");
|
|
81
|
-
await writeFile(target, "before\n");
|
|
82
|
-
const original = Object.assign(new Error("injected filesystem failure"), { code: "EIO" });
|
|
83
|
-
const nativeOpen = fs.open;
|
|
84
|
-
const nativeRename = fs.rename;
|
|
85
|
-
let published = false;
|
|
86
|
-
let commands = 0;
|
|
87
|
-
const progress: ActionFusionProgress[] = [];
|
|
88
|
-
try {
|
|
89
|
-
t.mock.method(fs, "open", async (...args: Parameters<typeof nativeOpen>) => {
|
|
90
|
-
if (
|
|
91
|
-
publication === "NOT_PUBLISHED" &&
|
|
92
|
-
String(args[0]).includes(".hashline-commit-") &&
|
|
93
|
-
args[1] === "w"
|
|
94
|
-
)
|
|
95
|
-
throw original;
|
|
96
|
-
if (publication === "PUBLISHED" && published && String(args[0]) === target)
|
|
97
|
-
throw original;
|
|
98
|
-
return nativeOpen(...args);
|
|
99
|
-
});
|
|
100
|
-
t.mock.method(fs, "rename", async (...args: Parameters<typeof nativeRename>) => {
|
|
101
|
-
if (String(args[1]) === target && publication === "UNKNOWN") throw original;
|
|
102
|
-
await nativeRename(...args);
|
|
103
|
-
published = true;
|
|
104
|
-
});
|
|
105
|
-
syncBuiltinESMExports();
|
|
106
|
-
const executeTool: SessionCommand = async () => {
|
|
107
|
-
commands++;
|
|
108
|
-
return commandCompletion({ content: [] });
|
|
109
|
-
};
|
|
110
|
-
const fusion = createActionFusionExecutor((update) => {
|
|
111
|
-
progress.push(update);
|
|
112
|
-
if (progressError !== undefined) throw progressError;
|
|
113
|
-
});
|
|
114
|
-
const result = await callTool(
|
|
115
|
-
makeWriteOverride(dir, fusion, () => budget),
|
|
116
|
-
{ path: target, mode: "overwrite", content: "after\n", then_run: { command: "check" } },
|
|
117
|
-
{ ctx: { ...context, executeTool } },
|
|
118
|
-
);
|
|
119
|
-
const report = reportOf(result, "write");
|
|
120
|
-
assert.equal(result.isError, true);
|
|
121
|
-
assert.ok(report);
|
|
122
|
-
assert.equal(
|
|
123
|
-
report.error,
|
|
124
|
-
publication === "PUBLISHED" ? "POST_PROCESS_FAILED" : "PUBLISH_FAILED",
|
|
125
|
-
);
|
|
126
|
-
assert.equal(report.publication, publication);
|
|
127
|
-
assert.deepEqual(report.cause, { code: original.code, message: original.message });
|
|
128
|
-
assert.equal(report.then_run?.status, "skipped");
|
|
129
|
-
if (publication === "PUBLISHED")
|
|
130
|
-
assert.match(report.next ?? "", /change is saved; do not repeat/);
|
|
131
|
-
else if (publication === "UNKNOWN")
|
|
132
|
-
assert.match(report.next ?? "", /may or may not be saved/);
|
|
133
|
-
else assert.equal(report.next, undefined);
|
|
134
|
-
assert.equal(result.content.length, 1);
|
|
135
|
-
const block = result.content[0];
|
|
136
|
-
assert.equal(block.type, "text");
|
|
137
|
-
const diagnostic = block.text;
|
|
138
|
-
for (const once of [
|
|
139
|
-
original.message,
|
|
140
|
-
report.message,
|
|
141
|
-
'"then_run"',
|
|
142
|
-
'"status": "skipped"',
|
|
143
|
-
])
|
|
144
|
-
assert.equal(diagnostic.split(once).length - 1, 1);
|
|
145
|
-
assert.equal(commands, 0);
|
|
146
|
-
assert.deepEqual(
|
|
147
|
-
progress.map((update) => update.command),
|
|
148
|
-
["waiting", "skipped"],
|
|
149
|
-
);
|
|
150
|
-
assert.ok(progress.every((update) => !update.mutationCompleted));
|
|
151
|
-
if (typeof progressError === "string") {
|
|
152
|
-
assert.deepEqual(report.progressError, { message: progressError });
|
|
153
|
-
} else if (progressError) {
|
|
154
|
-
assert.equal(report.progressError?.code, "EIO");
|
|
155
|
-
assert.ok(report.progressError.message.startsWith("display unavailable"));
|
|
156
|
-
assert.ok(Buffer.byteLength(report.progressError.message) <= budget.fieldBytes);
|
|
157
|
-
assert.notEqual(report.progressError.message, progressError.message);
|
|
158
|
-
assert.ok(report.progressError.cause);
|
|
159
|
-
assert.ok(report.progressError.cause.message.startsWith("nested"));
|
|
160
|
-
assert.ok(Buffer.byteLength(report.progressError.cause.message) <= budget.fieldBytes);
|
|
161
|
-
assert.notEqual(report.progressError.cause.message, progressError.cause.message);
|
|
162
|
-
} else assert.equal(report.progressError, undefined);
|
|
163
|
-
} finally {
|
|
164
|
-
t.mock.restoreAll();
|
|
165
|
-
syncBuiltinESMExports();
|
|
166
|
-
}
|
|
167
|
-
assert.equal(
|
|
168
|
-
await readFile(target, "utf8"),
|
|
169
|
-
publication === "PUBLISHED" ? "after\n" : "before\n",
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
|
|
175
|
-
test("cancellation after publication → does not rerun mutation and still inspects freshness", async (t) =>
|
|
176
|
-
withTemp(async (dir) => {
|
|
177
|
-
for (const state of ["changed", "missing"] as const) {
|
|
178
|
-
const target = join(dir, `${state}.txt`);
|
|
179
|
-
const controller = new AbortController();
|
|
180
|
-
const executeTool: SessionCommand = async () => {
|
|
181
|
-
if (state === "changed") await writeFile(target, "command changed\n");
|
|
182
|
-
else await rm(target);
|
|
183
|
-
controller.abort();
|
|
184
|
-
return commandCompletion({ content: [{ type: "text", text: "timed out" }] }, true);
|
|
185
|
-
};
|
|
186
|
-
const fusion = createActionFusionExecutor(() => {});
|
|
187
|
-
const result = await callTool(
|
|
188
|
-
makeWriteOverride(dir, fusion),
|
|
189
|
-
{ path: target, mode: "create", content: "mutation\n", then_run: { command: "check" } },
|
|
190
|
-
{ signal: controller.signal, ctx: { ...(await createToolContext(dir, t)), executeTool } },
|
|
191
|
-
);
|
|
192
|
-
const report = reportOf(result, "write");
|
|
193
|
-
assert.equal(report?.publication, "PUBLISHED");
|
|
194
|
-
assert.equal(report?.then_run?.status, "cancelled");
|
|
195
|
-
assert.equal(report?.freshness, state);
|
|
196
|
-
if (state === "changed") assert.equal(await readFile(target, "utf8"), "command changed\n");
|
|
197
|
-
else await assert.rejects(readFile(target), { code: "ENOENT" });
|
|
198
|
-
}
|
|
199
|
-
}));
|
|
200
|
-
|
|
201
|
-
test("first command fails → releases the queue for the next mutation", async (t) =>
|
|
202
|
-
withTemp(async (dir) => {
|
|
203
|
-
const target = join(dir, "queue.txt");
|
|
204
|
-
const ctx = await createToolContext(dir, t);
|
|
205
|
-
let calls = 0;
|
|
206
|
-
const executeTool: SessionCommand = async () => {
|
|
207
|
-
calls++;
|
|
208
|
-
if (calls === 1)
|
|
209
|
-
return commandCompletion(
|
|
210
|
-
{ content: [{ type: "text", text: "first command failed" }] },
|
|
211
|
-
true,
|
|
212
|
-
);
|
|
213
|
-
return commandCompletion({ content: [{ type: "text", text: "ok" }] });
|
|
214
|
-
};
|
|
215
|
-
const fusion = createActionFusionExecutor(() => {});
|
|
216
|
-
for (const content of ["first\n", "second\n"]) {
|
|
217
|
-
const result = await callTool(
|
|
218
|
-
makeWriteOverride(dir, fusion),
|
|
219
|
-
{
|
|
220
|
-
path: target,
|
|
221
|
-
content,
|
|
222
|
-
mode: calls === 0 ? "create" : "overwrite",
|
|
223
|
-
then_run: { command: "check" },
|
|
224
|
-
},
|
|
225
|
-
{ toolCallId: content, ctx: { ...ctx, executeTool } },
|
|
226
|
-
);
|
|
227
|
-
assert.equal(
|
|
228
|
-
reportOf(result, "write")?.then_run?.status,
|
|
229
|
-
calls === 1 ? "failed" : "succeeded",
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
assert.equal(calls, 2);
|
|
233
|
-
assert.equal(await readFile(target, "utf8"), "second\n");
|
|
234
|
-
}));
|
|
235
|
-
|
|
236
|
-
test("command succeeds on an unchanged target → retains the result and completed progress", async (t) =>
|
|
237
|
-
withTemp(async (dir) => {
|
|
238
|
-
const target = join(dir, "finalize.txt");
|
|
239
|
-
const progress: ActionFusionProgress[] = [];
|
|
240
|
-
const executeTool: SessionCommand = async () =>
|
|
241
|
-
commandCompletion({ content: [{ type: "text", text: "command finished" }] });
|
|
242
|
-
const fusion = createActionFusionExecutor((event) => progress.push(event));
|
|
243
|
-
const completed = await callTool(
|
|
244
|
-
makeWriteOverride(dir, fusion),
|
|
245
|
-
{ path: target, content: "saved\n", mode: "create", then_run: { command: "check" } },
|
|
246
|
-
{ ctx: { ...(await createToolContext(dir, t)), executeTool } },
|
|
247
|
-
);
|
|
248
|
-
assert.equal(completed.content.length, 1);
|
|
249
|
-
assert.equal(reportOf(completed, "write")?.then_run?.status, "succeeded");
|
|
250
|
-
assert.equal(reportOf(completed, "write")?.then_run?.output, "command finished");
|
|
251
|
-
assert.equal(progress.filter((event) => event.command === "succeeded").length, 1);
|
|
252
|
-
assert.equal(progress.at(-1)?.freshness, "unchanged");
|
|
253
|
-
assert.deepEqual(progress.at(-1)?.result, {
|
|
254
|
-
content: [{ type: "text", text: "command finished" }],
|
|
255
|
-
details: {},
|
|
256
|
-
});
|
|
257
|
-
}));
|
|
258
|
-
|
|
259
|
-
test("cancellation before mutation → reports a cancelled command without publishing", async (t) =>
|
|
260
|
-
withTemp(async (dir) => {
|
|
261
|
-
const target = join(dir, "cancelled.txt");
|
|
262
|
-
await writeFile(target, "before\n");
|
|
263
|
-
const controller = new AbortController();
|
|
264
|
-
controller.abort();
|
|
265
|
-
let commands = 0;
|
|
266
|
-
const progress: ActionFusionProgress[] = [];
|
|
267
|
-
const executeTool: SessionCommand = async () => {
|
|
268
|
-
commands++;
|
|
269
|
-
return commandCompletion({ content: [] });
|
|
270
|
-
};
|
|
271
|
-
const fusion = createActionFusionExecutor((event) => progress.push(event));
|
|
272
|
-
const result = await callTool(
|
|
273
|
-
makeWriteOverride(dir, fusion),
|
|
274
|
-
{ path: target, mode: "overwrite", content: "after\n", then_run: { command: "check" } },
|
|
275
|
-
{ signal: controller.signal, ctx: { ...(await createToolContext(dir, t)), executeTool } },
|
|
276
|
-
);
|
|
277
|
-
const report = reportOf(result, "write");
|
|
278
|
-
assert.equal(result.isError, true);
|
|
279
|
-
assert.equal(report?.error, "OPERATION_ABORTED");
|
|
280
|
-
assert.equal(report?.publication, "NOT_PUBLISHED");
|
|
281
|
-
assert.equal(report?.then_run?.status, "cancelled");
|
|
282
|
-
assert.deepEqual(
|
|
283
|
-
progress.map((event) => event.command),
|
|
284
|
-
["waiting", "cancelled"],
|
|
285
|
-
);
|
|
286
|
-
assert.ok(progress.every((event) => !event.mutationCompleted));
|
|
287
|
-
assert.equal(commands, 0);
|
|
288
|
-
assert.equal(await readFile(target, "utf8"), "before\n");
|
|
289
|
-
}));
|