@criogaid/pi-hashline-edit 0.3.1 → 0.4.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 +58 -49
- package/package.json +8 -3
- package/src/core/apply.test.ts +366 -310
- package/src/core/apply.ts +269 -202
- package/src/core/hash.test.ts +61 -23
- package/src/core/hash.ts +45 -16
- package/src/core/lines.test.ts +46 -27
- package/src/core/lines.ts +36 -28
- package/src/core/ranges.test.ts +73 -19
- package/src/core/ranges.ts +15 -15
- package/src/core/text.test.ts +3 -3
- package/src/core/text.ts +28 -9
- package/src/core/types.ts +54 -36
- package/src/index.ts +22 -16
- package/src/integration/grep-rg.test.ts +834 -219
- package/src/integration/large-text.test.ts +62 -0
- package/src/integration/replace-package.test.ts +37 -0
- package/src/pi/action-fusion.test.ts +535 -206
- package/src/pi/action-fusion.ts +469 -244
- package/src/pi/anchor-format.test.ts +30 -19
- package/src/pi/anchor-format.ts +27 -14
- package/src/pi/budgets.ts +20 -0
- package/src/pi/config.test.ts +60 -30
- package/src/pi/config.ts +45 -32
- package/src/pi/directory-sync.test.ts +55 -0
- package/src/pi/e2e-scenarios.test.ts +359 -0
- package/src/pi/edit-tool.ts +426 -262
- package/src/pi/error-text.ts +21 -0
- package/src/pi/execute.test.ts +1593 -712
- package/src/pi/failure-context.test.ts +105 -83
- package/src/pi/failure-context.ts +83 -71
- package/src/pi/failure-path.test.ts +171 -64
- package/src/pi/file-commit.test.ts +446 -233
- package/src/pi/file-commit.ts +347 -203
- package/src/pi/fusion-card.test.ts +118 -83
- package/src/pi/fusion-card.ts +120 -85
- package/src/pi/grep-output.ts +208 -0
- package/src/pi/grep-render.ts +58 -0
- package/src/pi/grep-scope.ts +152 -0
- package/src/pi/grep-search.ts +217 -0
- package/src/pi/grep-tool.ts +191 -766
- package/src/pi/grep.test.ts +562 -150
- package/src/pi/mutation-result.test.ts +37 -0
- package/src/pi/mutation-result.ts +107 -59
- package/src/pi/mutation-runner.ts +168 -0
- package/src/pi/path.ts +20 -12
- package/src/pi/pi.test.ts +95 -52
- package/src/pi/read-tool.ts +215 -132
- package/src/pi/registration.test.ts +274 -113
- package/src/pi/render.test.ts +218 -83
- package/src/pi/render.ts +152 -95
- package/src/pi/replace-apply.ts +109 -0
- package/src/pi/replace-tool.ts +280 -240
- package/src/pi/replace-worker.mjs +4 -0
- package/src/pi/replace-worker.ts +10 -0
- package/src/pi/replace.test.ts +773 -389
- package/src/pi/result-safety.test.ts +779 -342
- package/src/pi/rg-line-filter.test.ts +64 -36
- package/src/pi/rg-line-filter.ts +40 -124
- package/src/pi/rg-line-ranges.test.ts +57 -31
- package/src/pi/rg-line-ranges.ts +44 -82
- package/src/pi/rg-text-view.ts +106 -36
- package/src/pi/schema.ts +27 -0
- package/src/pi/state.ts +7 -7
- package/src/pi/text-stream.test.ts +118 -0
- package/src/pi/text-stream.ts +136 -0
- package/src/pi/tool-call.testing.ts +37 -0
- package/src/pi/write-tool.ts +115 -52
- package/src/pi/write.test.ts +248 -96
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Overrides the built-in read/edit: read outputs "lineNo#hash│content";
|
|
5
5
|
* edit accepts structured hashline ops (edits[] with LINE#HASH anchors), and
|
|
6
|
-
* legacy oldText/newText is rejected
|
|
6
|
+
* legacy oldText/newText is rejected by the schema. grep
|
|
7
7
|
* is overridden the same way so results carry usable anchors. A separate
|
|
8
8
|
* `replace` tool adds location-blind bulk + regex replacement (replaceAll and
|
|
9
9
|
* full JS regex with capture groups) for renames/pattern transforms that
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* @module pi-hashline-edit
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import type { ExtensionAPI, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import type { TSchema } from "typebox";
|
|
16
17
|
import { loadConfig } from "./pi/config.ts";
|
|
17
18
|
import { getState } from "./pi/state.ts";
|
|
18
19
|
import { makeEditOverride } from "./pi/edit-tool.ts";
|
|
@@ -25,21 +26,26 @@ import { registerFusionCards } from "./pi/fusion-card.ts";
|
|
|
25
26
|
import { withMutationStatus } from "./pi/render.ts";
|
|
26
27
|
|
|
27
28
|
export default function (pi: ExtensionAPI) {
|
|
28
|
-
|
|
29
|
+
const cwd = process.cwd();
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const state = getState();
|
|
32
|
+
state.config = loadConfig(cwd);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
// `enabled: false` leaves the extension fully inert — pi's built-in
|
|
35
|
+
// read/edit/grep/replace/write stay in place, as if this package were not installed.
|
|
36
|
+
if (state.config.enabled) {
|
|
37
|
+
const reportProgress = registerFusionCards(pi);
|
|
38
|
+
const fusion = state.config.actionFusion
|
|
39
|
+
? createActionFusionExecutor(undefined, reportProgress)
|
|
40
|
+
: undefined;
|
|
41
|
+
const registerMutation = <TParams extends TSchema, TDetails>(
|
|
42
|
+
tool: ToolDefinition<TParams, TDetails>,
|
|
43
|
+
) => pi.registerTool(fusion ? withMutationStatus(tool) : tool);
|
|
44
|
+
registerMutation(makeWriteOverride(cwd, fusion));
|
|
45
|
+
registerMutation(makeEditOverride(cwd, fusion));
|
|
46
|
+
registerMutation(makeReplaceTool(cwd, fusion));
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
pi.registerTool(makeReadOverride(cwd));
|
|
49
|
+
pi.registerTool(makeGrepOverride(cwd));
|
|
50
|
+
}
|
|
45
51
|
}
|