@xynogen/pix-edit 0.1.9 → 0.1.11
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 +16 -0
- package/package.json +3 -2
- package/src/edit.ts +19 -3
package/README.md
CHANGED
|
@@ -6,6 +6,22 @@ Pi tool — precise text replacement edit with diff rendering.
|
|
|
6
6
|
|
|
7
7
|
Replaces Pi's default `edit` tool with an enhanced version that renders a side-by-side split diff after every edit. The diff is syntax-highlighted with gutter markers, line numbers, and a change summary produced by `pix-pretty`'s diff engine. Batched edits (multiple `{oldText, newText}` pairs in one call) each render their own diff block. Call labels show the target file path and the number of edits being applied. Depends on `@xynogen/pix-pretty`, installed automatically as a dependency.
|
|
8
8
|
|
|
9
|
+
## Auto-collapse
|
|
10
|
+
|
|
11
|
+
After a configurable delay (default 10 seconds) the diff card automatically collapses. Controlled via the `collapse` section of `~/.pi/agent/pix.json`:
|
|
12
|
+
|
|
13
|
+
```jsonc
|
|
14
|
+
{
|
|
15
|
+
"collapse": {
|
|
16
|
+
"enabled": true,
|
|
17
|
+
"delayMs": 10000,
|
|
18
|
+
"tools": { "edit": true }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Set `collapse.tools.edit: false` to disable for this tool only. See `@xynogen/pix-data/collapse` for the full API.
|
|
24
|
+
|
|
9
25
|
## Install
|
|
10
26
|
|
|
11
27
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-edit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Pi tool — precise text replacement edit with diff rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xynogen/pix-pretty": "^1.7.9"
|
|
37
|
+
"@xynogen/pix-pretty": "^1.7.9",
|
|
38
|
+
"@xynogen/pix-data": "workspace:*"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/edit.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ToolRenderResultOptions,
|
|
7
7
|
} from "@earendil-works/pi-coding-agent";
|
|
8
8
|
|
|
9
|
+
import { type CollapseState, tickCollapse } from "@xynogen/pix-data/collapse";
|
|
9
10
|
import { MAX_RENDER_LINES } from "@xynogen/pix-pretty/config";
|
|
10
11
|
import type { ToolContext } from "@xynogen/pix-pretty/context";
|
|
11
12
|
import { parseDiff } from "@xynogen/pix-pretty/diff";
|
|
@@ -136,12 +137,14 @@ export function registerEditTool(
|
|
|
136
137
|
const { diffs, summary } = summarizeEditOperations(operations);
|
|
137
138
|
|
|
138
139
|
if (operations.length === 1) {
|
|
140
|
+
const op0 = operations[0];
|
|
141
|
+
if (!op0) return result;
|
|
139
142
|
setResultDetails(result, {
|
|
140
143
|
_type: "editInfo",
|
|
141
144
|
summary,
|
|
142
|
-
editLine: opEditLine(fp,
|
|
143
|
-
oldContent:
|
|
144
|
-
newContent:
|
|
145
|
+
editLine: opEditLine(fp, op0.newText),
|
|
146
|
+
oldContent: op0.oldText,
|
|
147
|
+
newContent: op0.newText,
|
|
145
148
|
language: fileLang,
|
|
146
149
|
filePath: fp,
|
|
147
150
|
});
|
|
@@ -201,6 +204,19 @@ export function registerEditTool(
|
|
|
201
204
|
}
|
|
202
205
|
const d = result.details as Record<string, unknown> | undefined;
|
|
203
206
|
|
|
207
|
+
// Auto-collapse: show summary line after delay
|
|
208
|
+
const cs = renderCtx.state as CollapseState;
|
|
209
|
+
if (tickCollapse("edit", cs, renderCtx.invalidate)) {
|
|
210
|
+
const summary =
|
|
211
|
+
d?._type === "editInfo"
|
|
212
|
+
? (d.summary as string)
|
|
213
|
+
: d?._type === "multiEditInfo"
|
|
214
|
+
? `${d.editCount} edits ${d.summary}`
|
|
215
|
+
: "edited";
|
|
216
|
+
text.setText(fillToolBackground(` ${theme.fg("muted", summary)}`));
|
|
217
|
+
return text;
|
|
218
|
+
}
|
|
219
|
+
|
|
204
220
|
// Single edit — full split diff
|
|
205
221
|
if (d?._type === "editInfo") {
|
|
206
222
|
const key = `ed:${diffThemeCacheKey(theme)}:${termW()}:${d.summary}:${(d.oldContent as string).length}:${(d.newContent as string).length}:${d.language ?? ""}`;
|