@criogaid/pi-hashline-edit 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +21 -7
  2. package/README.zh-CN.md +22 -8
  3. package/package.json +7 -6
  4. package/src/core/AGENTS.md +2 -2
  5. package/src/core/apply.test.ts +4 -4
  6. package/src/core/apply.ts +3 -3
  7. package/src/core/character-set.test.ts +2 -3
  8. package/src/core/character-set.ts +1 -1
  9. package/src/core/ranges.test.ts +2 -1
  10. package/src/core/ranges.ts +1 -1
  11. package/src/core/regex.ts +6 -2
  12. package/src/core/replace.test.ts +51 -0
  13. package/src/core/replace.ts +10 -4
  14. package/src/core/types.ts +1 -1
  15. package/src/index.ts +9 -9
  16. package/src/integration/config-registration.test.ts +8 -10
  17. package/src/integration/fusion-dispatch.test.ts +2 -2
  18. package/src/integration/grep-errors.test.ts +3 -3
  19. package/src/integration/grep-flags.test.ts +5 -5
  20. package/src/integration/grep-js-completeness.test.ts +12 -11
  21. package/src/integration/grep-line-candidates.test.ts +5 -3
  22. package/src/integration/grep-matrix.test.ts +5 -4
  23. package/src/integration/grep-order.test.ts +4 -4
  24. package/src/integration/grep-path-matrix.test.ts +5 -4
  25. package/src/integration/grep-prefilter-coverage.test.ts +17 -5
  26. package/src/integration/grep-process-limits.test.ts +2 -4
  27. package/src/integration/grep-regex.test.ts +10 -10
  28. package/src/integration/grep-rg.test.ts +93 -48
  29. package/src/integration/grep-scan-budget.test.ts +8 -8
  30. package/src/integration/grep-translation.test.ts +8 -7
  31. package/src/integration/large-text.test.ts +5 -5
  32. package/src/integration/model-budget-lifecycle.test.ts +9 -9
  33. package/src/integration/mutation-file-types.testing.ts +4 -4
  34. package/src/integration/npm-package.test.ts +12 -10
  35. package/src/integration/npm-package.testing.ts +151 -4
  36. package/src/integration/publication-read-changes.test.ts +54 -54
  37. package/src/integration/read-changes.test.ts +4 -4
  38. package/src/integration/replace-worker-boundary.test.ts +1 -1
  39. package/src/integration/report-replay.test.ts +9 -6
  40. package/src/integration/utf8-errors.test.ts +4 -4
  41. package/src/pi/AGENTS.md +13 -12
  42. package/src/pi/action-fusion.test.ts +125 -105
  43. package/src/pi/action-fusion.testing.ts +38 -0
  44. package/src/pi/action-fusion.ts +9 -21
  45. package/src/pi/argument-diagnostics.ts +4 -3
  46. package/src/pi/argument-format.test.ts +19 -18
  47. package/src/pi/argument-validation.test.ts +281 -139
  48. package/src/pi/argument-validation.ts +21 -31
  49. package/src/pi/budgets.ts +1 -4
  50. package/src/pi/codemode.test.ts +7 -2
  51. package/src/pi/config.test.ts +2 -1
  52. package/src/pi/config.ts +8 -3
  53. package/src/pi/diagnostic-buffer.test.ts +23 -13
  54. package/src/pi/edit-tool.ts +48 -63
  55. package/src/pi/error-text.ts +7 -2
  56. package/src/pi/execute.test.ts +178 -157
  57. package/src/pi/failure-context.test.ts +5 -4
  58. package/src/pi/failure-context.ts +1 -1
  59. package/src/pi/failure-path.test.ts +37 -37
  60. package/src/pi/file-commit.test.ts +47 -19
  61. package/src/pi/file-commit.ts +36 -9
  62. package/src/pi/fusion-card.test.ts +22 -21
  63. package/src/pi/fusion-card.ts +9 -5
  64. package/src/pi/grep-candidates.test.ts +18 -20
  65. package/src/pi/grep-candidates.ts +13 -17
  66. package/src/pi/grep-matrix.test.ts +3 -3
  67. package/src/pi/grep-order.test.ts +12 -11
  68. package/src/pi/grep-output.ts +45 -17
  69. package/src/pi/grep-reread.ts +7 -2
  70. package/src/pi/grep-rg.testing.ts +70 -0
  71. package/src/pi/grep-scope.ts +10 -10
  72. package/src/pi/grep-search.ts +8 -11
  73. package/src/pi/grep-tool.ts +40 -53
  74. package/src/pi/grep.test.ts +141 -116
  75. package/src/pi/model-budgets.test.ts +2 -1
  76. package/src/pi/mutation-outcome.testing.ts +0 -1
  77. package/src/pi/mutation-result.test.ts +8 -8
  78. package/src/pi/mutation-result.ts +1 -1
  79. package/src/pi/mutation-runner.ts +10 -6
  80. package/src/pi/output-budgets.test.ts +53 -31
  81. package/src/pi/pi.test.ts +18 -13
  82. package/src/pi/read-tool.ts +13 -18
  83. package/src/pi/read.test.ts +67 -41
  84. package/src/pi/registration.test.ts +25 -19
  85. package/src/pi/render.test.ts +94 -32
  86. package/src/pi/render.ts +7 -4
  87. package/src/pi/replace-regex.ts +1 -1
  88. package/src/pi/replace-tool.ts +6 -16
  89. package/src/pi/replace.test.ts +45 -34
  90. package/src/pi/report-failure.testing.ts +9 -1
  91. package/src/pi/report-schema.ts +225 -86
  92. package/src/pi/report.test.ts +81 -87
  93. package/src/pi/report.ts +35 -22
  94. package/src/pi/result-safety.test.ts +121 -100
  95. package/src/pi/rg-process.test.ts +2 -2
  96. package/src/pi/rg-process.ts +9 -15
  97. package/src/pi/rg-regex.test.ts +13 -0
  98. package/src/pi/rg-regex.ts +2 -2
  99. package/src/pi/schema.ts +23 -0
  100. package/src/pi/tool-factories.testing.ts +59 -0
  101. package/src/pi/write-tool.ts +9 -15
  102. package/src/pi/write.test.ts +30 -31
  103. package/src/testing/run-tests.ts +1 -1
@@ -1,12 +1,13 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { test } from "node:test";
3
- import { makeEditOverride } from "./edit-tool.ts";
4
- import { makeReadOverride } from "./read-tool.ts";
5
- import { makeGrepOverride } from "./grep-tool.ts";
6
- import { makeWriteOverride } from "./write-tool.ts";
7
- import { makeReplaceTool } from "./replace-tool.ts";
8
- import { DEFAULT_CONFIG } from "./config.ts";
9
- import { DEFAULT_OUTPUT_BUDGETS, outputBudgetsFor } from "./budgets.ts";
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", edits: [{ action: "append", body: [] }] },
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", edits: { action: "insert_after", body: [] } }),
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
- ["edits[0].anchor", "edits[0].body"],
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.edits, "maxItems");
84
+ const maxItems: unknown = Reflect.get(tool.parameters.properties.steps, "maxItems");
84
85
  assert.ok(typeof maxItems === "number");
85
- const edits = Array.from({ length: maxItems }, () => ({
86
+ const steps = Array.from({ length: maxItems }, () => ({
86
87
  action: "append",
87
- body: [],
88
+ lines: [],
88
89
  }));
89
- await assert.rejects(callTool(tool, { path: "", edits }), (error: unknown) => {
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, "edits[0].body");
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), edits.length + 1);
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
- edits: [{ action: "delete", anchor }],
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, "edits[0].anchor");
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/);