@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
package/src/pi/argument-error.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* so it travels as the thrown message only. Oversized issues are omitted whole.
|
|
5
5
|
*/
|
|
6
6
|
import type { OutputBudgets } from "./budgets.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { renderReport, type ReportText } from "./report.ts";
|
|
8
|
+
import { boundedText } from "./report-cause.ts";
|
|
8
9
|
import type { ArgumentIssue, FailureReport } from "./report-schema.ts";
|
|
9
10
|
|
|
10
11
|
type ArgumentRejection = ReportText<Extract<FailureReport, { error: "INVALID_ARGUMENTS" }>>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { test } from "node:test";
|
|
3
|
-
import { makeEditOverride } from "./
|
|
4
|
-
import { makeReadOverride } from "./
|
|
5
|
-
import { makeGrepOverride } from "./
|
|
6
|
-
import { makeWriteOverride } from "./
|
|
7
|
-
import { makeReplaceTool } from "./
|
|
8
|
-
import { DEFAULT_CONFIG } from "./
|
|
9
|
-
import {
|
|
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";
|
|
10
11
|
import { callTool } from "./tool-call.testing.ts";
|
|
11
12
|
import { argumentError } from "./argument-error.testing.ts";
|
|
12
13
|
|
|
@@ -16,7 +17,7 @@ test("all tools receive invalid arguments → return field diagnostics without a
|
|
|
16
17
|
const cases = [
|
|
17
18
|
{
|
|
18
19
|
tool: makeEditOverride(cwd, DEFAULT_CONFIG),
|
|
19
|
-
args: { path: "unused",
|
|
20
|
+
args: { path: "unused", steps: [{ action: "append", lines: [] }] },
|
|
20
21
|
},
|
|
21
22
|
{ tool: makeReadOverride(cwd, DEFAULT_CONFIG), args: { path: "unused", limit: 0 } },
|
|
22
23
|
{ tool: makeGrepOverride(cwd, DEFAULT_CONFIG), args: { pattern: "", literal: true } },
|
|
@@ -53,12 +54,12 @@ test("all tools receive invalid arguments → return field diagnostics without a
|
|
|
53
54
|
test("Pi prepares a singleton operation → semantic and schema paths resolve to the prepared array", async () => {
|
|
54
55
|
const tool = makeEditOverride(cwd, DEFAULT_CONFIG);
|
|
55
56
|
await assert.rejects(
|
|
56
|
-
callTool(tool, { path: "unused",
|
|
57
|
+
callTool(tool, { path: "unused", steps: { action: "insert_after", lines: [] } }),
|
|
57
58
|
(error: unknown) => {
|
|
58
59
|
const result = argumentError(error);
|
|
59
60
|
assert.deepEqual(
|
|
60
61
|
result.issues.map((issue) => issue.field),
|
|
61
|
-
["
|
|
62
|
+
["steps[0].anchor", "steps[0].lines"],
|
|
62
63
|
);
|
|
63
64
|
return true;
|
|
64
65
|
},
|
|
@@ -80,19 +81,19 @@ test("Pi prepares a singleton operation → semantic and schema paths resolve to
|
|
|
80
81
|
test("JSON diagnostics exceed the budget → retain whole opening and closing issues and label omissions", async () => {
|
|
81
82
|
const budget = outputBudgetsFor(4096);
|
|
82
83
|
const tool = makeEditOverride(cwd, DEFAULT_CONFIG, undefined, () => budget);
|
|
83
|
-
const maxItems: unknown = Reflect.get(tool.parameters.properties.
|
|
84
|
+
const maxItems: unknown = Reflect.get(tool.parameters.properties.steps, "maxItems");
|
|
84
85
|
assert.ok(typeof maxItems === "number");
|
|
85
|
-
const
|
|
86
|
+
const steps = Array.from({ length: maxItems }, () => ({
|
|
86
87
|
action: "append",
|
|
87
|
-
|
|
88
|
+
lines: [],
|
|
88
89
|
}));
|
|
89
|
-
await assert.rejects(callTool(tool, { path: "",
|
|
90
|
+
await assert.rejects(callTool(tool, { path: "", steps }), (error: unknown) => {
|
|
90
91
|
const result = argumentError(error);
|
|
91
92
|
assert.ok(error instanceof Error && Buffer.byteLength(error.message) <= budget.blockBytes);
|
|
92
|
-
assert.equal(result.issues[0].field, "
|
|
93
|
+
assert.equal(result.issues[0].field, "steps[0].lines");
|
|
93
94
|
assert.equal(result.issues.at(-1)?.field, "path");
|
|
94
95
|
assert.ok((result.omittedIssues ?? 0) > 0);
|
|
95
|
-
assert.equal(result.issues.length + (result.omittedIssues ?? 0),
|
|
96
|
+
assert.equal(result.issues.length + (result.omittedIssues ?? 0), steps.length + 1);
|
|
96
97
|
return true;
|
|
97
98
|
});
|
|
98
99
|
});
|
|
@@ -102,7 +103,7 @@ test("a reason contains an oversized anchor → keep its cause and recovery inst
|
|
|
102
103
|
await assert.rejects(
|
|
103
104
|
callTool(makeEditOverride(cwd, DEFAULT_CONFIG), {
|
|
104
105
|
path: "unused",
|
|
105
|
-
|
|
106
|
+
steps: [{ action: "delete", anchor }],
|
|
106
107
|
}),
|
|
107
108
|
(error: unknown) => {
|
|
108
109
|
const result = argumentError(error);
|
|
@@ -111,7 +112,7 @@ test("a reason contains an oversized anchor → keep its cause and recovery inst
|
|
|
111
112
|
Buffer.byteLength(error.message) <= DEFAULT_OUTPUT_BUDGETS.blockBytes,
|
|
112
113
|
);
|
|
113
114
|
assert.equal(result.issues.length, 1);
|
|
114
|
-
assert.equal(result.issues[0].field, "
|
|
115
|
+
assert.equal(result.issues[0].field, "steps[0].anchor");
|
|
115
116
|
assert.match(result.issues[0].reason, /^line number/);
|
|
116
117
|
assert.match(result.issues[0].fix ?? "", /Copy a complete.*latest tool result/);
|
|
117
118
|
assert.doesNotMatch(result.issues[0].reason, /Read|grep|Copy/);
|