@criogaid/pi-hashline-edit 0.9.0 β 0.11.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 +12 -12
- package/README.zh-CN.md +12 -12
- package/THIRD_PARTY_NOTICES.md +0 -6
- package/package.json +1 -1
- package/src/core/AGENTS.md +4 -5
- package/src/core/apply.test.ts +96 -271
- package/src/core/apply.ts +62 -169
- package/src/core/case-fold.ts +8 -67
- package/src/core/character-set.test.ts +2 -3
- package/src/core/character-set.ts +5 -5
- package/src/core/errors.test.ts +23 -7
- package/src/core/errors.ts +32 -5
- package/src/core/hash.test.ts +8 -16
- package/src/core/hash.ts +3 -23
- package/src/core/lines.ts +2 -4
- package/src/core/ranges.test.ts +2 -1
- package/src/core/ranges.ts +1 -1
- package/src/core/regex.ts +3 -4
- package/src/core/replace.test.ts +47 -1
- package/src/core/replace.ts +19 -13
- package/src/core/search-analysis.test.ts +24 -27
- package/src/core/search-analysis.ts +34 -65
- package/src/core/search-matrix.testing.ts +0 -2
- package/src/core/search.ts +1 -1
- package/src/core/text.test.ts +5 -5
- package/src/core/text.ts +5 -12
- package/src/core/types.ts +8 -44
- package/src/index.ts +8 -8
- package/src/integration/config-registration.test.ts +8 -10
- package/src/integration/fusion-dispatch.test.ts +4 -7
- package/src/integration/grep-errors.test.ts +3 -3
- package/src/integration/grep-flags.test.ts +5 -19
- package/src/integration/grep-js-completeness.test.ts +45 -18
- package/src/integration/grep-line-candidates.test.ts +7 -10
- package/src/integration/grep-matrix.test.ts +6 -9
- package/src/integration/grep-order.test.ts +4 -4
- package/src/integration/grep-path-matrix.test.ts +10 -9
- package/src/integration/grep-prefilter-coverage.test.ts +5 -8
- package/src/integration/grep-process-limits.test.ts +76 -0
- package/src/integration/grep-regex.test.ts +10 -10
- package/src/integration/grep-rg.test.ts +166 -66
- package/src/integration/grep-scan-budget.test.ts +9 -9
- package/src/integration/grep-translation.test.ts +18 -32
- package/src/integration/large-text.test.ts +6 -52
- package/src/integration/model-budget-lifecycle.test.ts +10 -9
- package/src/integration/mutation-file-types.testing.ts +4 -4
- package/src/integration/npm-package.testing.ts +3 -3
- package/src/integration/publication-read-changes.test.ts +161 -83
- package/src/integration/read-changes.test.ts +4 -4
- package/src/integration/replace-worker-boundary.test.ts +22 -12
- package/src/integration/report-replay.test.ts +23 -26
- package/src/integration/utf8-errors.test.ts +4 -4
- package/src/pi/AGENTS.md +18 -17
- package/src/pi/action-fusion.test.ts +241 -353
- package/src/pi/action-fusion.testing.ts +38 -0
- package/src/pi/action-fusion.ts +150 -125
- package/src/pi/anchor-format.test.ts +9 -9
- package/src/pi/anchor-format.ts +6 -8
- package/src/pi/argument-diagnostics.ts +25 -28
- package/src/pi/argument-error.ts +2 -1
- package/src/pi/argument-format.test.ts +19 -18
- package/src/pi/argument-validation.test.ts +334 -283
- package/src/pi/argument-validation.ts +5 -8
- package/src/pi/budgets.ts +6 -8
- package/src/pi/codemode.test.ts +7 -2
- package/src/pi/config.test.ts +7 -3
- package/src/pi/config.ts +12 -9
- package/src/pi/diagnostic-buffer.test.ts +34 -13
- package/src/pi/diagnostic-buffer.ts +1 -2
- package/src/pi/directory-sync.test.ts +0 -1
- package/src/pi/edit-tool.ts +86 -211
- package/src/pi/error-text.ts +10 -9
- package/src/pi/execute.test.ts +249 -345
- package/src/pi/failure-context.test.ts +146 -127
- package/src/pi/failure-context.ts +45 -94
- package/src/pi/failure-path.test.ts +182 -155
- package/src/pi/file-commit.test.ts +156 -71
- package/src/pi/file-commit.ts +126 -146
- package/src/pi/file-snapshot.test.ts +3 -5
- package/src/pi/fusion-card.test.ts +26 -22
- package/src/pi/fusion-card.ts +16 -24
- package/src/pi/grep-candidates.test.ts +19 -120
- package/src/pi/grep-candidates.ts +25 -76
- package/src/pi/grep-matrix.test.ts +5 -5
- package/src/pi/grep-order.test.ts +16 -15
- package/src/pi/grep-output.ts +94 -107
- package/src/pi/grep-render.ts +1 -1
- package/src/pi/grep-reread.ts +97 -0
- package/src/pi/grep-rg.testing.ts +70 -0
- package/src/pi/grep-scope.ts +41 -43
- package/src/pi/grep-search.ts +27 -39
- package/src/pi/grep-tool.ts +63 -106
- package/src/pi/grep.test.ts +177 -156
- package/src/pi/model-budgets.test.ts +27 -24
- package/src/pi/model-budgets.ts +6 -38
- package/src/pi/mutation-outcome.testing.ts +0 -1
- package/src/pi/mutation-result.test.ts +44 -35
- package/src/pi/mutation-result.ts +52 -21
- package/src/pi/mutation-runner.ts +134 -74
- package/src/pi/output-budgets.test.ts +86 -42
- package/src/pi/path.ts +1 -1
- package/src/pi/pi.test.ts +18 -13
- package/src/pi/read-tool.ts +18 -23
- package/src/pi/read.test.ts +22 -41
- package/src/pi/regex-worker-contract.ts +3 -13
- package/src/pi/regex-worker.ts +1 -10
- package/src/pi/registration.test.ts +85 -51
- package/src/pi/render.test.ts +88 -59
- package/src/pi/render.ts +64 -65
- package/src/pi/replace-regex.ts +14 -2
- package/src/pi/replace-tool.ts +22 -94
- package/src/pi/replace-worker.ts +1 -1
- package/src/pi/replace.test.ts +53 -38
- package/src/pi/report-cause.ts +3 -8
- package/src/pi/report-failure.testing.ts +10 -3
- package/src/pi/report-schema.ts +251 -148
- package/src/pi/report.test.ts +215 -67
- package/src/pi/report.ts +50 -98
- package/src/pi/result-safety.test.ts +241 -247
- package/src/pi/rg-process.test.ts +77 -63
- package/src/pi/rg-process.ts +53 -75
- package/src/pi/rg-regex.ts +40 -400
- package/src/pi/schema.ts +35 -0
- package/src/pi/text-stream.test.ts +0 -21
- package/src/pi/text-stream.ts +14 -21
- package/src/pi/tool-factories.testing.ts +59 -0
- package/src/pi/write-tool.ts +36 -71
- package/src/pi/write.test.ts +31 -34
- package/src/testing/regex-translation-corpus.ts +12 -12
- package/src/testing/run-tests.ts +1 -1
- package/src/pi/replace-worker-contract.ts +0 -10
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { searchWithMockRg } from "../pi/grep-rg.testing.ts";
|
|
1
2
|
import assert from "node:assert/strict";
|
|
2
3
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join, resolve } from "node:path";
|
|
5
6
|
import { test } from "node:test";
|
|
6
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
7
7
|
import { searchText, type GrepQuery } from "../core/search.ts";
|
|
8
|
-
import {
|
|
8
|
+
import type { GrepFileMatch } from "../pi/grep-search.ts";
|
|
9
9
|
import { runRgLines, runRgPaths } from "../pi/rg-process.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { fileCandidateArgs } from "../pi/grep-rg.testing.ts";
|
|
11
11
|
import { lineCandidatePatterns } from "../pi/rg-regex.ts";
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
import { REGEX_TRANSLATION_CORPUS } from "../testing/regex-translation-corpus.ts";
|
|
14
14
|
import { unsupportedByHost } from "../testing/regex-host.testing.ts";
|
|
15
15
|
|
|
@@ -71,28 +71,23 @@ test("upstream regex witnesses Γ LF/CRLF/malformed bytes β sound candidates,
|
|
|
71
71
|
inputs.push({ bytes, filePath });
|
|
72
72
|
}
|
|
73
73
|
const candidates = new Map<string, readonly number[] | undefined>();
|
|
74
|
-
const
|
|
75
|
-
const result = await searchFiles({
|
|
74
|
+
const result = await searchWithMockRg({
|
|
76
75
|
backend: {
|
|
77
76
|
runRgPaths: async () => assert.fail("unexpected file fallback"),
|
|
78
|
-
runRgLines: (
|
|
79
|
-
runRgLines(
|
|
77
|
+
runRgLines: (args, signal, maxLines, onFile) =>
|
|
78
|
+
runRgLines(args, signal, maxLines, (path, lines) => {
|
|
80
79
|
candidates.set(resolve(path), lines);
|
|
81
80
|
return onFile(path, lines);
|
|
82
81
|
}),
|
|
83
82
|
},
|
|
84
|
-
rgPath,
|
|
85
83
|
scope: {
|
|
86
84
|
globs: [],
|
|
87
|
-
noIgnore: false,
|
|
88
|
-
follow: false,
|
|
89
85
|
searchPaths: inputs.map((input) => input.filePath),
|
|
90
86
|
},
|
|
91
87
|
query,
|
|
92
88
|
limit: 1000,
|
|
93
89
|
timeoutMs,
|
|
94
90
|
signal: AbortSignal.timeout(timeoutMs),
|
|
95
|
-
warnings,
|
|
96
91
|
});
|
|
97
92
|
const expected = inputs.map(({ bytes, filePath }) => {
|
|
98
93
|
const native = searchText({ source: bytes.toString("utf8"), query, limit: 1000 });
|
|
@@ -112,14 +107,14 @@ test("upstream regex witnesses Γ LF/CRLF/malformed bytes β sound candidates,
|
|
|
112
107
|
}
|
|
113
108
|
return { filePath, rows: native.lines };
|
|
114
109
|
});
|
|
115
|
-
assert.deepEqual(warnings, []);
|
|
110
|
+
assert.deepEqual(result.warnings, []);
|
|
116
111
|
assert.deepEqual(sorted(result.files), sorted(expected));
|
|
117
112
|
},
|
|
118
113
|
);
|
|
119
114
|
}
|
|
120
115
|
});
|
|
121
116
|
|
|
122
|
-
test("real rg AND/OR file prefilter β
|
|
117
|
+
test("real rg AND/OR file prefilter β broad candidates retain exact JS results", async (t) => {
|
|
123
118
|
const directory = await mkdtemp(join(tmpdir(), "hl-regex-conjunction-"));
|
|
124
119
|
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
125
120
|
const fixtures = ["foo\nbar", "baz\nqux", "foo\nqux", "baz\nbar", "foo", "bar", "unrelated"];
|
|
@@ -136,11 +131,8 @@ test("real rg AND/OR file prefilter β excludes incomplete branches before JS v
|
|
|
136
131
|
multiline: true,
|
|
137
132
|
};
|
|
138
133
|
const candidates: string[] = [];
|
|
139
|
-
const listing = await
|
|
140
|
-
|
|
141
|
-
rgPath,
|
|
142
|
-
extractPrefilter(query),
|
|
143
|
-
["--", directory],
|
|
134
|
+
const listing = await runRgPaths(
|
|
135
|
+
[...(await fileCandidateArgs(query)), "--null", "--", directory],
|
|
144
136
|
AbortSignal.timeout(timeoutMs),
|
|
145
137
|
(path) => {
|
|
146
138
|
candidates.push(resolve(path));
|
|
@@ -149,18 +141,15 @@ test("real rg AND/OR file prefilter β excludes incomplete branches before JS v
|
|
|
149
141
|
);
|
|
150
142
|
assert.equal(listing.code, 0);
|
|
151
143
|
assert.equal(listing.stderr, "");
|
|
152
|
-
assert.deepEqual(candidates.sort(), paths
|
|
153
|
-
const
|
|
154
|
-
const result = await searchFiles({
|
|
144
|
+
assert.deepEqual(candidates.sort(), [paths[0], paths[1], paths[2], paths[3], paths[4]].sort());
|
|
145
|
+
const result = await searchWithMockRg({
|
|
155
146
|
backend: { runRgPaths, runRgLines },
|
|
156
|
-
|
|
157
|
-
scope: { globs: [], noIgnore: false, follow: false, searchPaths: [directory] },
|
|
147
|
+
scope: { globs: [], searchPaths: [directory] },
|
|
158
148
|
query,
|
|
159
149
|
limit: 100,
|
|
160
150
|
timeoutMs,
|
|
161
|
-
warnings,
|
|
162
151
|
});
|
|
163
|
-
assert.deepEqual(warnings, []);
|
|
152
|
+
assert.deepEqual(result.warnings, []);
|
|
164
153
|
assert.deepEqual(
|
|
165
154
|
sorted(result.files),
|
|
166
155
|
sorted(
|
|
@@ -181,8 +170,7 @@ test("oversized line translation β file prefilter fallback preserves JS result
|
|
|
181
170
|
const path = join(directory, "long.txt");
|
|
182
171
|
await writeFile(path, pattern);
|
|
183
172
|
let filePasses = 0;
|
|
184
|
-
const
|
|
185
|
-
const result = await searchFiles({
|
|
173
|
+
const result = await searchWithMockRg({
|
|
186
174
|
backend: {
|
|
187
175
|
runRgPaths: (...args) => {
|
|
188
176
|
filePasses++;
|
|
@@ -190,15 +178,13 @@ test("oversized line translation β file prefilter fallback preserves JS result
|
|
|
190
178
|
},
|
|
191
179
|
runRgLines: async () => assert.fail("translation budget must select file prefilter"),
|
|
192
180
|
},
|
|
193
|
-
|
|
194
|
-
scope: { globs: [], noIgnore: false, follow: false, searchPaths: [path] },
|
|
181
|
+
scope: { globs: [], searchPaths: [path] },
|
|
195
182
|
query,
|
|
196
183
|
limit: 10,
|
|
197
184
|
timeoutMs,
|
|
198
|
-
warnings,
|
|
199
185
|
});
|
|
200
186
|
assert.ok(filePasses > 0);
|
|
201
|
-
assert.deepEqual(warnings, []);
|
|
187
|
+
assert.deepEqual(result.warnings, []);
|
|
202
188
|
assert.deepEqual(
|
|
203
189
|
sorted(result.files),
|
|
204
190
|
sorted([{ filePath: path, rows: searchText({ source: pattern, query, limit: 10 }).lines }]),
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
|
-
import { mkdtemp, open,
|
|
3
|
+
import { mkdtemp, open, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { makeReadOverride } from "../pi/
|
|
7
|
-
import {
|
|
8
|
-
import { reportOf } from "../pi/report.ts";
|
|
9
|
-
import { makeGrepOverrideWithBackend } from "../pi/grep-tool.ts";
|
|
6
|
+
import { makeReadOverride } from "../pi/tool-factories.testing.ts";
|
|
7
|
+
import { makeGrepOverride } from "../pi/tool-factories.testing.ts";
|
|
10
8
|
import { computeLineHash } from "../core/hash.ts";
|
|
11
9
|
import { callTool } from "../pi/tool-call.testing.ts";
|
|
12
|
-
import { DEFAULT_CONFIG } from "../pi/
|
|
10
|
+
import { DEFAULT_CONFIG } from "../pi/tool-factories.testing.ts";
|
|
13
11
|
|
|
14
12
|
const call = (tool: any, params: any) => callTool(tool, params, { toolCallId: "large-text" });
|
|
15
13
|
|
|
@@ -17,7 +15,7 @@ test("read and line-based grep retain anchors on LF and CRLF files over 100 MiB"
|
|
|
17
15
|
const directory = await mkdtemp(join(tmpdir(), "hashline-large-text-"));
|
|
18
16
|
try {
|
|
19
17
|
const read = makeReadOverride(directory, DEFAULT_CONFIG);
|
|
20
|
-
const grep =
|
|
18
|
+
const grep = makeGrepOverride(directory, DEFAULT_CONFIG);
|
|
21
19
|
for (const ending of ["\n", "\r\n"]) {
|
|
22
20
|
const path = join(directory, "large.txt");
|
|
23
21
|
const handle = await open(path, "w");
|
|
@@ -58,7 +56,7 @@ test("CRLF snapshots normalize terminators split across read chunks and preserve
|
|
|
58
56
|
try {
|
|
59
57
|
const path = join(directory, "boundary.txt");
|
|
60
58
|
await writeFile(path, "x".repeat(65535) + "\r\nneedle\r\nstandalone\r");
|
|
61
|
-
const grep =
|
|
59
|
+
const grep = makeGrepOverride(directory, DEFAULT_CONFIG);
|
|
62
60
|
const result: any = await call(grep, {
|
|
63
61
|
path,
|
|
64
62
|
pattern: ["needle", "standalone\r"],
|
|
@@ -70,47 +68,3 @@ test("CRLF snapshots normalize terminators split across read chunks and preserve
|
|
|
70
68
|
await rm(directory, { recursive: true, force: true });
|
|
71
69
|
}
|
|
72
70
|
});
|
|
73
|
-
|
|
74
|
-
test("copy/move a 150,000-line block β publish every captured line", async (t) => {
|
|
75
|
-
const directory = await mkdtemp(join(tmpdir(), "hashline-large-transfer-"));
|
|
76
|
-
t.after(() => rm(directory, { recursive: true, force: true }));
|
|
77
|
-
const path = join(directory, "transfer.txt");
|
|
78
|
-
const lineCount = 150_000;
|
|
79
|
-
const block = " valueπ\r\n".repeat(lineCount);
|
|
80
|
-
const source = `\uFEFFSTART\n${block}END`;
|
|
81
|
-
const read = makeReadOverride(directory, DEFAULT_CONFIG);
|
|
82
|
-
const edit = makeEditOverride(directory, DEFAULT_CONFIG);
|
|
83
|
-
const observedAnchor = async (line: number) => {
|
|
84
|
-
const result: Awaited<ReturnType<typeof read.execute>> = await callTool(read, {
|
|
85
|
-
path,
|
|
86
|
-
offset: line,
|
|
87
|
-
limit: 1,
|
|
88
|
-
});
|
|
89
|
-
const rows = result.content
|
|
90
|
-
.filter((part) => part.type === "text")
|
|
91
|
-
.map((part) => part.text)
|
|
92
|
-
.join("\n");
|
|
93
|
-
const match = new RegExp(`^(${line}#[0-9A-Z]+)β`, "m").exec(rows);
|
|
94
|
-
assert(match);
|
|
95
|
-
return match[1];
|
|
96
|
-
};
|
|
97
|
-
for (const op of ["copy", "move"] as const) {
|
|
98
|
-
await writeFile(path, source);
|
|
99
|
-
const [anchor, end, after] = await Promise.all([
|
|
100
|
-
observedAnchor(2),
|
|
101
|
-
observedAnchor(lineCount + 1),
|
|
102
|
-
observedAnchor(lineCount + 2),
|
|
103
|
-
]);
|
|
104
|
-
const result: Awaited<ReturnType<typeof edit.execute>> = await callTool(edit, {
|
|
105
|
-
path,
|
|
106
|
-
edits: [{ action: op, anchor, end, after }],
|
|
107
|
-
});
|
|
108
|
-
const expected = Buffer.from(
|
|
109
|
-
(op === "copy" ? source : "\uFEFFSTART\nEND") + "\r\n" + block.slice(0, -2),
|
|
110
|
-
"utf8",
|
|
111
|
-
);
|
|
112
|
-
assert.deepEqual(await readFile(path), expected);
|
|
113
|
-
assert.equal(result.isError, undefined);
|
|
114
|
-
assert.equal(reportOf(result, "edit")?.publication, "PUBLISHED");
|
|
115
|
-
}
|
|
116
|
-
});
|
|
@@ -5,7 +5,8 @@ import { join } from "node:path";
|
|
|
5
5
|
import hashlineEdit from "../index.ts";
|
|
6
6
|
import { callTool } from "../pi/tool-call.testing.ts";
|
|
7
7
|
import { outputBudgetsFor } from "../pi/budgets.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { reportOf } from "../pi/report.ts";
|
|
9
|
+
import type { Report } from "../pi/report-schema.ts";
|
|
9
10
|
import { openTestSession } from "../testing/session.testing.ts";
|
|
10
11
|
|
|
11
12
|
// Budget invalidation relies on Pi publishing the new model before tool preparation.
|
|
@@ -80,7 +81,7 @@ test("model capacity changes β read and grep grow and shrink without re-regist
|
|
|
80
81
|
assert.ok(large.content[0].text.includes(text));
|
|
81
82
|
await session.setModel({ ...model, id: "small", contextWindow: 65_536 });
|
|
82
83
|
const smallAgain = await callTool(tool, { path }, { ctx });
|
|
83
|
-
assert.
|
|
84
|
+
assert.equal(reportOf(smallAgain, "read")?.lineTooLong, smallReport?.lineTooLong);
|
|
84
85
|
const grep = session.getToolDefinition("grep");
|
|
85
86
|
assert.ok(grep);
|
|
86
87
|
const smallSearch = await callTool(grep, { path, pattern: "δΈζ", literal: true }, { ctx });
|
|
@@ -110,15 +111,15 @@ test("model switches before argument preparation β rejection uses the new budg
|
|
|
110
111
|
assert.ok(prepare);
|
|
111
112
|
const properties: unknown = Reflect.get(tool.parameters, "properties");
|
|
112
113
|
assert.ok(properties && typeof properties === "object");
|
|
113
|
-
const
|
|
114
|
-
assert.ok(
|
|
115
|
-
const maxEdits: unknown = Reflect.get(
|
|
114
|
+
const steps: unknown = Reflect.get(properties, "steps");
|
|
115
|
+
assert.ok(steps && typeof steps === "object");
|
|
116
|
+
const maxEdits: unknown = Reflect.get(steps, "maxItems");
|
|
116
117
|
assert.ok(typeof maxEdits === "number");
|
|
117
118
|
const args = {
|
|
118
119
|
path: "never-opened.txt",
|
|
119
|
-
|
|
120
|
+
steps: Array.from({ length: maxEdits }, () => ({
|
|
120
121
|
action: "append",
|
|
121
|
-
|
|
122
|
+
lines: Array(4).fill("\ud800"),
|
|
122
123
|
})),
|
|
123
124
|
};
|
|
124
125
|
const reports: Report[] = [];
|
|
@@ -133,9 +134,9 @@ test("model switches before argument preparation β rejection uses the new budg
|
|
|
133
134
|
assert.ok(error instanceof Error);
|
|
134
135
|
const budget = outputBudgetsFor(contextWindow);
|
|
135
136
|
assert.ok(Buffer.byteLength(error.message) <= budget.blockBytes);
|
|
136
|
-
const report =
|
|
137
|
+
const report = reportOf({ content: [{ type: "text", text: error.message }] }, "edit");
|
|
137
138
|
assert.ok(report?.issues);
|
|
138
|
-
assert.equal(report.issues.length + (report.omittedIssues ?? 0), args.
|
|
139
|
+
assert.equal(report.issues.length + (report.omittedIssues ?? 0), args.steps.length * 4);
|
|
139
140
|
reports.push(report);
|
|
140
141
|
return true;
|
|
141
142
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Isolate a FIFO open so a regression cannot stall the parent runner's I/O threads. */
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { makeEditOverride } from "../pi/
|
|
5
|
-
import { makeReplaceTool } from "../pi/
|
|
6
|
-
import { DEFAULT_CONFIG } from "../pi/
|
|
4
|
+
import { makeEditOverride } from "../pi/tool-factories.testing.ts";
|
|
5
|
+
import { makeReplaceTool } from "../pi/tool-factories.testing.ts";
|
|
6
|
+
import { DEFAULT_CONFIG } from "../pi/tool-factories.testing.ts";
|
|
7
7
|
import { callTool } from "../pi/tool-call.testing.ts";
|
|
8
8
|
import { expectToolFailure } from "../pi/report-failure.testing.ts";
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ assert.ok(directory);
|
|
|
12
12
|
const cases = [
|
|
13
13
|
{
|
|
14
14
|
tool: makeEditOverride(directory, DEFAULT_CONFIG),
|
|
15
|
-
args: {
|
|
15
|
+
args: { steps: [{ action: "append", lines: ["after"] }] },
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
tool: makeReplaceTool(directory, DEFAULT_CONFIG),
|
|
@@ -5,7 +5,7 @@ import { test } from "node:test";
|
|
|
5
5
|
import type { ToolCall } from "@earendil-works/pi-ai";
|
|
6
6
|
import { loadInstalledExtension } from "../testing/extension-loader.testing.ts";
|
|
7
7
|
import { openTestSession, responseStream, SESSION_TIMEOUT_MS } from "../testing/session.testing.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { reportOf } from "../pi/report.ts";
|
|
9
9
|
|
|
10
10
|
test("packed extension completes file, worker, and command operations", {
|
|
11
11
|
timeout: SESSION_TIMEOUT_MS,
|
|
@@ -64,7 +64,7 @@ test("packed extension completes file, worker, and command operations", {
|
|
|
64
64
|
assert.equal(anchor("grep"), anchor("read"));
|
|
65
65
|
return call("edit", "edit", {
|
|
66
66
|
path: "fixture.txt",
|
|
67
|
-
|
|
67
|
+
steps: [{ action: "replace", anchor: anchor("grep"), lines: ["edited"] }],
|
|
68
68
|
});
|
|
69
69
|
},
|
|
70
70
|
() =>
|
|
@@ -88,7 +88,7 @@ test("packed extension completes file, worker, and command operations", {
|
|
|
88
88
|
for (const id of ["write", "read", "grep", "edit", "replace"]) result(id);
|
|
89
89
|
const command = result("write")
|
|
90
90
|
.content.map((block) =>
|
|
91
|
-
block.type === "text" ?
|
|
91
|
+
block.type === "text" ? reportOf({ content: [block] }, "write")?.then_run : undefined,
|
|
92
92
|
)
|
|
93
93
|
.find((facts) => facts !== undefined);
|
|
94
94
|
assert.equal(command?.status, "succeeded");
|