pi-agent-ide 0.6.2 → 0.6.3
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/CHANGELOG.md +7 -0
- package/dist/entry-77.js +61 -52
- package/docs/agent-guides/apply.md +1 -1
- package/docs/agent-guides/editing.md +4 -0
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +10 -10
- package/node_modules/pi-agent-ide-changes/package.json +7 -7
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-search/package.json +4 -4
- package/node_modules/pi-agent-search-text/package.json +6 -6
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/package.json +6 -6
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-search/package.json +4 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/src/plugins/pi-agent-ide-ast/package.json +10 -10
- package/src/plugins/pi-agent-ide-changes/package.json +7 -7
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-read",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-documentation": "0.6.
|
|
28
|
-
"pi-agent-invariant": "0.6.
|
|
29
|
-
"pi-agent-resource": "0.6.
|
|
30
|
-
"pi-agent-text": "0.6.
|
|
31
|
-
"pi-agent-tool-call-interception": "0.6.
|
|
32
|
-
"pi-agent-tool-ui": "0.6.
|
|
27
|
+
"pi-agent-documentation": "0.6.3",
|
|
28
|
+
"pi-agent-invariant": "0.6.3",
|
|
29
|
+
"pi-agent-resource": "0.6.3",
|
|
30
|
+
"pi-agent-text": "0.6.3",
|
|
31
|
+
"pi-agent-tool-call-interception": "0.6.3",
|
|
32
|
+
"pi-agent-tool-ui": "0.6.3"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"pi-agent-documentation": "0.6.
|
|
24
|
-
"pi-agent-tool-call-interception": "0.6.
|
|
25
|
-
"pi-agent-tool-ui": "0.6.
|
|
23
|
+
"pi-agent-documentation": "0.6.3",
|
|
24
|
+
"pi-agent-tool-call-interception": "0.6.3",
|
|
25
|
+
"pi-agent-tool-ui": "0.6.3"
|
|
26
26
|
},
|
|
27
27
|
"pi": {
|
|
28
28
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search-text",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-doctor": "0.6.
|
|
28
|
-
"pi-agent-invariant": "0.6.
|
|
29
|
-
"pi-agent-search": "0.6.
|
|
30
|
-
"pi-agent-text": "0.6.
|
|
31
|
-
"pi-agent-text-editor": "0.6.
|
|
27
|
+
"pi-agent-doctor": "0.6.3",
|
|
28
|
+
"pi-agent-invariant": "0.6.3",
|
|
29
|
+
"pi-agent-search": "0.6.3",
|
|
30
|
+
"pi-agent-text": "0.6.3",
|
|
31
|
+
"pi-agent-text-editor": "0.6.3"
|
|
32
32
|
},
|
|
33
33
|
"pi": {
|
|
34
34
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"fs-extra": "^11.4.0",
|
|
80
80
|
"oxfmt": "0.64.0",
|
|
81
81
|
"partial-json": "^0.1.7",
|
|
82
|
-
"pi-agent-documentation": "0.6.
|
|
83
|
-
"pi-agent-invariant": "0.6.
|
|
84
|
-
"pi-agent-read": "0.6.
|
|
85
|
-
"pi-agent-resource": "0.6.
|
|
86
|
-
"pi-agent-search": "0.6.
|
|
87
|
-
"pi-agent-text": "0.6.
|
|
88
|
-
"pi-agent-tool-call-interception": "0.6.
|
|
89
|
-
"pi-agent-tool-ui": "0.6.
|
|
82
|
+
"pi-agent-documentation": "0.6.3",
|
|
83
|
+
"pi-agent-invariant": "0.6.3",
|
|
84
|
+
"pi-agent-read": "0.6.3",
|
|
85
|
+
"pi-agent-resource": "0.6.3",
|
|
86
|
+
"pi-agent-search": "0.6.3",
|
|
87
|
+
"pi-agent-text": "0.6.3",
|
|
88
|
+
"pi-agent-tool-call-interception": "0.6.3",
|
|
89
|
+
"pi-agent-tool-ui": "0.6.3",
|
|
90
90
|
"run": "2.1.4",
|
|
91
91
|
"typebox-guard": "npm:typebox@^1.1.38"
|
|
92
92
|
},
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-constant",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-text": "0.6.
|
|
10
|
-
"pi-agent-text-editor": "0.6.
|
|
9
|
+
"pi-agent-text": "0.6.3",
|
|
10
|
+
"pi-agent-text-editor": "0.6.3"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-exact",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"fast-fuzzy": "1.12.0",
|
|
16
|
-
"pi-agent-text": "0.6.
|
|
17
|
-
"pi-agent-text-editor": "0.6.
|
|
16
|
+
"pi-agent-text": "0.6.3",
|
|
17
|
+
"pi-agent-text-editor": "0.6.3"
|
|
18
18
|
},
|
|
19
19
|
"pi": {
|
|
20
20
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-line-hash",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"pi-agent-invariant": "0.6.
|
|
16
|
-
"pi-agent-read": "0.6.
|
|
17
|
-
"pi-agent-text": "0.6.
|
|
18
|
-
"pi-agent-text-editor": "0.6.
|
|
15
|
+
"pi-agent-invariant": "0.6.3",
|
|
16
|
+
"pi-agent-read": "0.6.3",
|
|
17
|
+
"pi-agent-text": "0.6.3",
|
|
18
|
+
"pi-agent-text-editor": "0.6.3"
|
|
19
19
|
},
|
|
20
20
|
"pi": {
|
|
21
21
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-renderer",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"diff": "^9.0.0",
|
|
10
|
-
"pi-agent-invariant": "0.6.
|
|
11
|
-
"pi-agent-text-editor": "0.6.
|
|
12
|
-
"pi-agent-tool-call-interception": "0.6.
|
|
13
|
-
"pi-agent-tool-ui": "0.6.
|
|
10
|
+
"pi-agent-invariant": "0.6.3",
|
|
11
|
+
"pi-agent-text-editor": "0.6.3",
|
|
12
|
+
"pi-agent-tool-call-interception": "0.6.3",
|
|
13
|
+
"pi-agent-tool-ui": "0.6.3"
|
|
14
14
|
},
|
|
15
15
|
"pi": {
|
|
16
16
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.6.
|
|
7
|
-
"pi-agent-read": "0.6.
|
|
8
|
-
"pi-agent-text-editor": "0.6.
|
|
6
|
+
"pi-agent-invariant": "0.6.3",
|
|
7
|
+
"pi-agent-read": "0.6.3",
|
|
8
|
+
"pi-agent-text-editor": "0.6.3"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
@@ -2,7 +2,7 @@ const editorGuide = `
|
|
|
2
2
|
Read-only helpers use the standalone-tool arguments: read({...}), search({...}), and diff({before, after}). Their results are recorded automatically.
|
|
3
3
|
|
|
4
4
|
Transactional helpers:
|
|
5
|
-
open(path | {path, views?}); file.find(text); file.select(searchMatch); file.between(start, end, {inside?, lines?}); file.line(first, last?); file.start(); file.end(); file.before(selection); file.after(selection); file.slice(selection, start?, end?); file.union(...selections); file.within(candidates, scopes); file.linesOf(selection); file.replace(selection, text); file.remove(selection); file.insertBefore(selection, text); file.insertAfter(selection, text); file.flush(); file.delete(); replace(selection, text); remove(selection); insertBefore(selection, text); insertAfter(selection, text); copy(source, destination); move(source, destination); createFile(path, content); deleteFile(path); copyFile(path, target, {overwrite?}); moveFile(path, target, {overwrite?}); flush().
|
|
5
|
+
open(path | {path, views?}); file.find(text); file.select(searchMatch); file.between(start, end, {inside?, lines?}); file.line(first, last?); file.start(); file.end(); file.before(selection); file.after(selection); file.slice(selection, start?, end?); file.union(...selections); file.within(candidates, scopes); file.linesOf(selection); file.replace(selection, text); file.remove(selection); file.insertBefore(selection, text, {separation?: "line" | "blank-line"}); file.insertAfter(selection, text, {separation?: "line" | "blank-line"}); file.flush(); file.delete(); replace(selection, text); remove(selection); insertBefore(selection, text, {separation?: "line" | "blank-line"}); insertAfter(selection, text, {separation?: "line" | "blank-line"}); copy(source, destination); move(source, destination); createFile(path, content); deleteFile(path); copyFile(path, target, {overwrite?}); moveFile(path, target, {overwrite?}); flush().
|
|
6
6
|
|
|
7
7
|
Selections are immutable and snapshot-bound. Use slice to select occurrences by position, union to combine non-overlapping sets, within to keep candidates contained by scopes, and linesOf to expand matches to whole lines. between accepts strings or SelectionSets as either boundary; {lines:true} expands through both containing lines. Prefer it for blocks identified by content; use line(first,last) only for exact verified line bounds. Use start/end or before/after as zero-width destinations when copy or move should insert instead of replace. Normal completion commits staged operations once; a thrown script commits none. flush() commits every staged operation; file.flush() commits only independent operations for that file while cross-file transfers stay pending. Successful checkpoints can return an APPLY# receipt. Failed operations report structured errors and do not silently guess a recovery.
|
|
8
8
|
`;
|
|
@@ -170,7 +170,9 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
170
170
|
const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: target});
|
|
171
171
|
return selectionSet(document, resolved.selections, {kind: "exact", query: target, warning: resolved.warning});
|
|
172
172
|
};
|
|
173
|
-
const stage = (document, target, text, edge) => {
|
|
173
|
+
const stage = (document, target, text, edge, options = {}) => {
|
|
174
|
+
if (edge !== undefined && text.length === 0) throw new Error("Insert text must not be empty.");
|
|
175
|
+
if (options.separation !== undefined && options.separation !== "line" && options.separation !== "blank-line") throw new Error("Invalid separation mode.");
|
|
174
176
|
const selected = targetSet(document, target);
|
|
175
177
|
if (!Array.isArray(selected) || selected.document !== document.id) throw new Error("SelectionSet belongs to another file");
|
|
176
178
|
if (selected.generation !== document.generation) throw Object.assign(new Error("SelectionSet belongs to a stale snapshot"), {code:"STALE_SELECTION"});
|
|
@@ -179,10 +181,17 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
179
181
|
const point = edge === "before" ? range.from : edge === "after" ? range.to : undefined;
|
|
180
182
|
let insert = text;
|
|
181
183
|
if (point !== undefined && range.linewise === true) {
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
const separator = document.content.includes("\\r\\n") ? "\\r\\n" : "\\n";
|
|
185
|
+
const before = document.content.slice(0, point);
|
|
186
|
+
const after = document.content.slice(point);
|
|
187
|
+
const prefix = edge === "after" && before.length > 0 && !before.endsWith("\\n") ? separator : "";
|
|
188
|
+
const following = after.length > 0;
|
|
189
|
+
insert = prefix + insert;
|
|
190
|
+
if (options.separation === "blank-line") {
|
|
191
|
+
if (before.length > 0 && !before.endsWith(separator + separator) && !insert.slice(prefix.length).startsWith(separator)) insert = separator + insert;
|
|
192
|
+
if (following && !insert.endsWith(separator + separator) && !after.startsWith(separator)) insert += insert.endsWith(separator) ? separator : separator + separator;
|
|
193
|
+
}
|
|
194
|
+
if (following && !insert.endsWith("\\n")) insert += separator;
|
|
186
195
|
}
|
|
187
196
|
operations.push({kind: "replace", selection: point === undefined ? range : selection(document, point, point), text: insert});
|
|
188
197
|
}
|
|
@@ -196,10 +205,10 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
196
205
|
if (empty !== undefined) { operations.push({kind:"warning", document:empty.document, query:empty.provenance?.query, warning:empty.provenance?.warning}); return; }
|
|
197
206
|
operations.push({kind, sources:[...source], destinations:[...destination], text:source.map((item) => item.text).join("")});
|
|
198
207
|
};
|
|
199
|
-
const stageSet = (target, text, edge) => {
|
|
208
|
+
const stageSet = (target, text, edge, options) => {
|
|
200
209
|
const document = snapshots.get(target?.document);
|
|
201
210
|
if (document === undefined) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale or unopened snapshot");
|
|
202
|
-
stage(document, target, text, edge);
|
|
211
|
+
stage(document, target, text, edge, options);
|
|
203
212
|
};
|
|
204
213
|
const refreshSnapshots = (value) => {
|
|
205
214
|
for (const refreshed of value?.snapshots ?? []) {
|
|
@@ -326,8 +335,8 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
326
335
|
after: (set) => { assertCurrent(document); const selected = assertSet(document, set); return selectionSet(document, selected.map((item) => ({from: item.to, to: item.to, linewise: item.linewise === true})), {kind: "after", source: selected.provenance}); },
|
|
327
336
|
replace: (target, text) => { assertCurrent(document); stage(document, target, String(text)); },
|
|
328
337
|
remove: (target) => { assertCurrent(document); stage(document, target, ""); },
|
|
329
|
-
insertBefore: (target, text) => { assertCurrent(document); stage(document, target, String(text), "before"); },
|
|
330
|
-
insertAfter: (target, text) => { assertCurrent(document); stage(document, target, String(text), "after"); },
|
|
338
|
+
insertBefore: (target, text, options) => { assertCurrent(document); stage(document, target, String(text), "before", options); },
|
|
339
|
+
insertAfter: (target, text, options) => { assertCurrent(document); stage(document, target, String(text), "after", options); },
|
|
331
340
|
flush: () => flushDocument(document),
|
|
332
341
|
delete: () => { assertCurrent(document); operations.push({kind: "delete", path: document.source}); },
|
|
333
342
|
};
|
|
@@ -342,8 +351,8 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
|
|
|
342
351
|
moveFile: (path, target, options = {}) => operations.push({kind: "move", path, target, overwrite: options.overwrite === true}),
|
|
343
352
|
replace: (target, text) => stageSet(target, String(text)),
|
|
344
353
|
remove: (target) => stageSet(target, ""),
|
|
345
|
-
insertBefore: (target, text) => stageSet(target, String(text), "before"),
|
|
346
|
-
insertAfter: (target, text) => stageSet(target, String(text), "after"),
|
|
354
|
+
insertBefore: (target, text, options) => stageSet(target, String(text), "before", options),
|
|
355
|
+
insertAfter: (target, text, options) => stageSet(target, String(text), "after", options),
|
|
347
356
|
copy: (source, destination) => stageTransfer("text-copy", source, destination),
|
|
348
357
|
move: (source, destination) => stageTransfer("text-move", source, destination),
|
|
349
358
|
flush: () => {
|
|
@@ -24,6 +24,8 @@ export interface TextChangeResult {
|
|
|
24
24
|
readonly changes: readonly AppliedTextChange[];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export type LineSeparation = "line" | "blank-line";
|
|
28
|
+
|
|
27
29
|
export class TextChangeDocument {
|
|
28
30
|
readonly #lineStarts: readonly number[];
|
|
29
31
|
readonly #separator: "\n" | "\r\n";
|
|
@@ -85,18 +87,34 @@ export class TextChangeDocument {
|
|
|
85
87
|
return { ...range, insert: "" };
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
public insertBeforeLine(
|
|
90
|
+
public insertBeforeLine(
|
|
91
|
+
lineNumber: number,
|
|
92
|
+
text: string,
|
|
93
|
+
separation: LineSeparation = "line",
|
|
94
|
+
): TextChange {
|
|
89
95
|
this.#assertLine(lineNumber);
|
|
90
96
|
const from = requiredValue(this.#lineStarts[lineNumber - 1]);
|
|
91
|
-
return {
|
|
97
|
+
return {
|
|
98
|
+
from,
|
|
99
|
+
to: from,
|
|
100
|
+
insert: this.#lineInsertion(from, text, separation, from < this.content.length),
|
|
101
|
+
};
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
public insertAfterLine(
|
|
104
|
+
public insertAfterLine(
|
|
105
|
+
lineNumber: number,
|
|
106
|
+
text: string,
|
|
107
|
+
separation: LineSeparation = "line",
|
|
108
|
+
): TextChange {
|
|
95
109
|
this.#assertLine(lineNumber);
|
|
96
110
|
const nextLine = this.#lineStarts[lineNumber];
|
|
97
111
|
|
|
98
112
|
if (nextLine !== undefined) {
|
|
99
|
-
return {
|
|
113
|
+
return {
|
|
114
|
+
from: nextLine,
|
|
115
|
+
to: nextLine,
|
|
116
|
+
insert: this.#lineInsertion(nextLine, text, separation, nextLine < this.content.length),
|
|
117
|
+
};
|
|
100
118
|
}
|
|
101
119
|
|
|
102
120
|
const prefix =
|
|
@@ -104,7 +122,7 @@ export class TextChangeDocument {
|
|
|
104
122
|
return {
|
|
105
123
|
from: this.content.length,
|
|
106
124
|
to: this.content.length,
|
|
107
|
-
insert:
|
|
125
|
+
insert: this.#lineInsertion(this.content.length, text, separation, false, prefix),
|
|
108
126
|
};
|
|
109
127
|
}
|
|
110
128
|
|
|
@@ -119,8 +137,35 @@ export class TextChangeDocument {
|
|
|
119
137
|
: text;
|
|
120
138
|
}
|
|
121
139
|
|
|
122
|
-
#
|
|
123
|
-
|
|
140
|
+
#lineInsertion(
|
|
141
|
+
from: number,
|
|
142
|
+
text: string,
|
|
143
|
+
separation: LineSeparation,
|
|
144
|
+
following: boolean,
|
|
145
|
+
prefix = "",
|
|
146
|
+
): string {
|
|
147
|
+
if (text.length === 0) throw new Error("Insert text must not be empty.");
|
|
148
|
+
if (separation === "blank-line") {
|
|
149
|
+
if (
|
|
150
|
+
from > 0 &&
|
|
151
|
+
!this.content.slice(0, from).endsWith(this.#separator + this.#separator) &&
|
|
152
|
+
!text.startsWith(this.#separator)
|
|
153
|
+
) {
|
|
154
|
+
prefix += this.#separator;
|
|
155
|
+
}
|
|
156
|
+
if (
|
|
157
|
+
following &&
|
|
158
|
+
!text.endsWith(this.#separator + this.#separator) &&
|
|
159
|
+
!this.content.slice(from).startsWith(this.#separator)
|
|
160
|
+
) {
|
|
161
|
+
return (
|
|
162
|
+
prefix +
|
|
163
|
+
text +
|
|
164
|
+
(endsWithLineBreak(text) ? this.#separator : this.#separator + this.#separator)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return prefix + (following && !endsWithLineBreak(text) ? text + this.#separator : text);
|
|
124
169
|
}
|
|
125
170
|
|
|
126
171
|
#offsetAt(lineNumber: number, column: number): number {
|
|
@@ -242,10 +287,6 @@ function lineBreakOf(text: string): "\n" | "\r\n" | undefined {
|
|
|
242
287
|
return text.endsWith("\r\n") ? "\r\n" : text.endsWith("\n") ? "\n" : undefined;
|
|
243
288
|
}
|
|
244
289
|
|
|
245
|
-
function removeTrailingLineBreak(text: string): string {
|
|
246
|
-
return text.replace(/(?:\r\n|\n)$/u, "");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
290
|
function previousLineBreakStart(text: string, offset: number): number {
|
|
250
291
|
return text[offset - 2] === "\r" && text[offset - 1] === "\n" ? offset - 2 : offset - 1;
|
|
251
292
|
}
|
|
@@ -172,6 +172,7 @@ export function insertionAfterAnchor(
|
|
|
172
172
|
anchors: ReadonlyMap<string, TextAnchor>,
|
|
173
173
|
field: string,
|
|
174
174
|
insert: string,
|
|
175
|
+
separation: "line" | "blank-line" = "line",
|
|
175
176
|
): readonly [string, { readonly from: number; readonly to: number; readonly insert: string }] {
|
|
176
177
|
const span = singleAnchorSpan(context, anchors, field, true);
|
|
177
178
|
const normalizedInsert = targetText(context, span.source, insert);
|
|
@@ -179,7 +180,7 @@ export function insertionAfterAnchor(
|
|
|
179
180
|
const lineNumber = span.linewiseEndLine ?? lineAnchor(anchors, field).lineNumber;
|
|
180
181
|
return [
|
|
181
182
|
span.source,
|
|
182
|
-
context.documentFor(span.source).insertAfterLine(lineNumber, normalizedInsert),
|
|
183
|
+
context.documentFor(span.source).insertAfterLine(lineNumber, normalizedInsert, separation),
|
|
183
184
|
];
|
|
184
185
|
}
|
|
185
186
|
|
|
@@ -189,6 +190,7 @@ export function insertionBeforeAnchor(
|
|
|
189
190
|
anchors: ReadonlyMap<string, TextAnchor>,
|
|
190
191
|
field: string,
|
|
191
192
|
insert: string,
|
|
193
|
+
separation: "line" | "blank-line" = "line",
|
|
192
194
|
): readonly [string, { readonly from: number; readonly to: number; readonly insert: string }] {
|
|
193
195
|
const span = singleAnchorSpan(context, anchors, field, true);
|
|
194
196
|
const normalizedInsert = targetText(context, span.source, insert);
|
|
@@ -196,7 +198,7 @@ export function insertionBeforeAnchor(
|
|
|
196
198
|
const lineNumber = span.linewiseStartLine ?? lineAnchor(anchors, field).lineNumber;
|
|
197
199
|
return [
|
|
198
200
|
span.source,
|
|
199
|
-
context.documentFor(span.source).insertBeforeLine(lineNumber, normalizedInsert),
|
|
201
|
+
context.documentFor(span.source).insertBeforeLine(lineNumber, normalizedInsert, separation),
|
|
200
202
|
];
|
|
201
203
|
}
|
|
202
204
|
|
|
@@ -256,6 +258,7 @@ export function insertionChanges(
|
|
|
256
258
|
selections: ReadonlyMap<string, TextSelectionAnchor>,
|
|
257
259
|
insert: string,
|
|
258
260
|
before = false,
|
|
261
|
+
separation: "line" | "blank-line" = "line",
|
|
259
262
|
): ReadonlyMap<
|
|
260
263
|
string,
|
|
261
264
|
readonly { readonly from: number; readonly to: number; readonly insert: string }[]
|
|
@@ -274,8 +277,8 @@ export function insertionChanges(
|
|
|
274
277
|
const document = context.documentFor(source);
|
|
275
278
|
const normalizedInsert = targetText(context, source, insert);
|
|
276
279
|
return before
|
|
277
|
-
? document.insertBeforeLine(line, normalizedInsert)
|
|
278
|
-
: document.insertAfterLine(line, normalizedInsert);
|
|
280
|
+
? document.insertBeforeLine(line, normalizedInsert, separation)
|
|
281
|
+
: document.insertAfterLine(line, normalizedInsert, separation);
|
|
279
282
|
}),
|
|
280
283
|
]),
|
|
281
284
|
);
|
|
@@ -25,9 +25,16 @@ export const insertSchema = Type.Object(
|
|
|
25
25
|
}),
|
|
26
26
|
),
|
|
27
27
|
text: Type.String({
|
|
28
|
+
minLength: 1,
|
|
28
29
|
description:
|
|
29
|
-
"New text only. The tool supplies the line boundary; do not prefix a newline just to start a new line. For example, 'NEW' inserts one line, while '\\nNEW' intentionally adds a blank line before it. A missing trailing newline is supplied before following text; additional newlines remain intentional blank lines. When appending after an unterminated final line, the tool supplies the separator before the new text
|
|
30
|
+
"New text only. The tool supplies the line boundary; do not prefix a newline just to start a new line. For example, 'NEW' inserts one line, while '\\nNEW' intentionally adds a blank line before it. A missing trailing newline is supplied before following text; additional newlines remain intentional blank lines. When appending after an unterminated final line, the tool supplies the separator before the new text without removing trailing newlines from the payload. Payload line endings follow the destination file's LF/CRLF style.",
|
|
30
31
|
}),
|
|
32
|
+
separation: Type.Optional(
|
|
33
|
+
Type.Union([Type.Literal("line"), Type.Literal("blank-line")], {
|
|
34
|
+
description:
|
|
35
|
+
"Defaults to line. Use blank-line to add only missing blank lines between the inserted block and existing neighboring content; explicit payload newlines remain intact.",
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
31
38
|
before: Type.Optional(
|
|
32
39
|
Type.Boolean({
|
|
33
40
|
description:
|
|
@@ -42,6 +49,7 @@ interface InsertParameters {
|
|
|
42
49
|
readonly path?: string;
|
|
43
50
|
readonly anchor?: string;
|
|
44
51
|
readonly text: string;
|
|
52
|
+
readonly separation?: "line" | "blank-line";
|
|
45
53
|
readonly before?: boolean;
|
|
46
54
|
}
|
|
47
55
|
|
|
@@ -62,11 +70,18 @@ export const insertMutationTool: TextMutationToolRegistration<typeof insertSchem
|
|
|
62
70
|
},
|
|
63
71
|
],
|
|
64
72
|
mutate: async (context, parameters: InsertParameters) => {
|
|
73
|
+
if (parameters.text.length === 0) throw new Error("Insert text must not be empty.");
|
|
65
74
|
const anchors = await context.resolveAnchors("anchor");
|
|
66
75
|
const selections = textSelections(anchors, "anchor");
|
|
67
76
|
|
|
68
77
|
if (selections !== undefined) {
|
|
69
|
-
const changes = insertionChanges(
|
|
78
|
+
const changes = insertionChanges(
|
|
79
|
+
context,
|
|
80
|
+
selections,
|
|
81
|
+
parameters.text,
|
|
82
|
+
parameters.before,
|
|
83
|
+
parameters.separation,
|
|
84
|
+
);
|
|
70
85
|
return {
|
|
71
86
|
edits: new Map(
|
|
72
87
|
[...changes].map(([source, sourceChanges]) => [
|
|
@@ -78,7 +93,13 @@ export const insertMutationTool: TextMutationToolRegistration<typeof insertSchem
|
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
const insertion = parameters.before === true ? insertionBeforeAnchor : insertionAfterAnchor;
|
|
81
|
-
const [source, change] = insertion(
|
|
96
|
+
const [source, change] = insertion(
|
|
97
|
+
context,
|
|
98
|
+
anchors,
|
|
99
|
+
"anchor",
|
|
100
|
+
parameters.text,
|
|
101
|
+
parameters.separation,
|
|
102
|
+
);
|
|
82
103
|
return {
|
|
83
104
|
edits: new Map([[source, { changes: [change], action: "edited" }]]),
|
|
84
105
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-ast",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"@tree-sitter-grammars/tree-sitter-toml": "^0.7.0",
|
|
32
32
|
"@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
|
|
33
33
|
"cross-spawn": "^7.0.6",
|
|
34
|
-
"pi-agent-doctor": "0.6.
|
|
35
|
-
"pi-agent-invariant": "0.6.
|
|
36
|
-
"pi-agent-read": "0.6.
|
|
37
|
-
"pi-agent-resource": "0.6.
|
|
38
|
-
"pi-agent-search": "0.6.
|
|
39
|
-
"pi-agent-search-text": "0.6.
|
|
40
|
-
"pi-agent-text": "0.6.
|
|
41
|
-
"pi-agent-text-editor": "0.6.
|
|
34
|
+
"pi-agent-doctor": "0.6.3",
|
|
35
|
+
"pi-agent-invariant": "0.6.3",
|
|
36
|
+
"pi-agent-read": "0.6.3",
|
|
37
|
+
"pi-agent-resource": "0.6.3",
|
|
38
|
+
"pi-agent-search": "0.6.3",
|
|
39
|
+
"pi-agent-search-text": "0.6.3",
|
|
40
|
+
"pi-agent-text": "0.6.3",
|
|
41
|
+
"pi-agent-text-editor": "0.6.3",
|
|
42
42
|
"tree-sitter-cpp": "^0.23.4",
|
|
43
43
|
"tree-sitter-javascript": "^0.25.0",
|
|
44
44
|
"tree-sitter-json": "^0.24.8",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@earendil-works/pi-coding-agent": "*",
|
|
57
|
-
"pi-agent-ide": "0.6.
|
|
57
|
+
"pi-agent-ide": "0.6.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"pi-agent-ide": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
|
-
"pi-agent-doctor": "0.6.
|
|
17
|
-
"pi-agent-documentation": "0.6.
|
|
18
|
-
"pi-agent-invariant": "0.6.
|
|
19
|
-
"pi-agent-read": "0.6.
|
|
20
|
-
"pi-agent-text": "0.6.
|
|
21
|
-
"pi-agent-text-editor": "0.6.
|
|
16
|
+
"pi-agent-doctor": "0.6.3",
|
|
17
|
+
"pi-agent-documentation": "0.6.3",
|
|
18
|
+
"pi-agent-invariant": "0.6.3",
|
|
19
|
+
"pi-agent-read": "0.6.3",
|
|
20
|
+
"pi-agent-text": "0.6.3",
|
|
21
|
+
"pi-agent-text-editor": "0.6.3"
|
|
22
22
|
},
|
|
23
23
|
"pi": {
|
|
24
24
|
"extensions": [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-formatter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.6.
|
|
6
|
+
"pi-agent-doctor": "0.6.3"
|
|
7
7
|
},
|
|
8
8
|
"pi": {
|
|
9
9
|
"extensions": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@earendil-works/pi-coding-agent": "*",
|
|
15
|
-
"pi-agent-ide": "0.6.
|
|
15
|
+
"pi-agent-ide": "0.6.3"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"pi-agent-ide": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lint",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.6.
|
|
7
|
-
"pi-agent-invariant": "0.6.
|
|
8
|
-
"pi-agent-read": "0.6.
|
|
9
|
-
"pi-agent-resource": "0.6.
|
|
10
|
-
"pi-agent-text": "0.6.
|
|
6
|
+
"pi-agent-doctor": "0.6.3",
|
|
7
|
+
"pi-agent-invariant": "0.6.3",
|
|
8
|
+
"pi-agent-read": "0.6.3",
|
|
9
|
+
"pi-agent-resource": "0.6.3",
|
|
10
|
+
"pi-agent-text": "0.6.3"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
-
"pi-agent-ide": "0.6.
|
|
19
|
+
"pi-agent-ide": "0.6.3"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"pi-agent-ide": {
|