pi-agent-ide 0.7.0 → 0.7.1
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/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-FXNKMNSJ.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-3HYXQ4YA.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/{chunk-GBLKIB6O.js → chunk-HZEY4GT4.js} +1 -1
- package/dist/{chunk-S5LXX32D.js → chunk-LEEQIQ7D.js} +6 -6
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-KR36BT5E.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-YRF7OATP.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-PYPPV2F5.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/{chunk-3JO7QFIL.js → chunk-WU6ZK6YD.js} +1 -1
- package/dist/{chunk-F5YZG77W.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/{chunk-AJRIASPQ.js → chunk-YP46DVVP.js} +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +13 -12
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-41.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -14
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +2 -2
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +33 -34
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-82.js +2 -2
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +14 -9
- package/docs/agent-guides/editing.md +35 -46
- package/docs/agent-guides/read-resources.md +5 -9
- package/docs/agent-guides/search-code.md +12 -17
- package/docs/agent-guides/select-code.md +61 -140
- package/docs/structured-results.md +27 -62
- package/docs/tools.md +6 -10
- 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/index.ts +7 -6
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/index.ts +4 -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 +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +7 -4
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/node_modules/pi-agent-ide-changes/index.ts +4 -3
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- 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/index.ts +3 -3
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- 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-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +7 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +7 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/result-targets.ts +183 -9
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
- package/node_modules/pi-agent-search-text/index.ts +1 -1
- package/node_modules/pi-agent-search-text/package.json +7 -7
- 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/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -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/api/mutation-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- 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-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +4 -3
- package/node_modules/pi-agent-web/package.json +7 -7
- 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/composite/text-results.ts +221 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- 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/index.ts +4 -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/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- 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-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
- 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/index.ts +65 -4
- 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-exact/src/anchor.ts +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -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/api/mutation-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +7 -4
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +4 -3
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
- 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/index.ts +3 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +12 -4
- package/dist/chunk-4NIFBFFR.js +0 -11
- package/dist/chunk-7LZKOHH2.js +0 -1
- package/dist/chunk-FK42RSF4.js +0 -1
- package/dist/chunk-KBP3QUDT.js +0 -2
- package/dist/chunk-OE7QVAI2.js +0 -5
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-SQKAXYIR.js +0 -2
- package/dist/chunk-VCGNVTXQ.js +0 -1
|
@@ -19,11 +19,6 @@ export const transferFileParameters = Type.Object(
|
|
|
19
19
|
{
|
|
20
20
|
path: filePath,
|
|
21
21
|
target: filePath,
|
|
22
|
-
overwrite: Type.Optional(
|
|
23
|
-
Type.Boolean({
|
|
24
|
-
description: "Allow replacing an existing regular target file. Defaults to false.",
|
|
25
|
-
}),
|
|
26
|
-
),
|
|
27
22
|
},
|
|
28
23
|
{ additionalProperties: false },
|
|
29
24
|
);
|
|
@@ -76,7 +71,7 @@ export async function executeFileOperation(
|
|
|
76
71
|
throw Object.assign(new Error("Invalid file operation arguments"), {
|
|
77
72
|
code: "INVALID_ARGUMENTS",
|
|
78
73
|
});
|
|
79
|
-
const args = input as { path: string; target?: string
|
|
74
|
+
const args = input as { path: string; target?: string };
|
|
80
75
|
source = path.resolve(cwd, args.path);
|
|
81
76
|
target = args.target === undefined ? undefined : path.resolve(cwd, args.target);
|
|
82
77
|
signal?.throwIfAborted();
|
|
@@ -95,19 +90,14 @@ export async function executeFileOperation(
|
|
|
95
90
|
throw Object.assign(new Error("Source and target are the same file"), {
|
|
96
91
|
code: "SAME_FILE",
|
|
97
92
|
});
|
|
98
|
-
if (args.overwrite !== true)
|
|
99
|
-
throw Object.assign(new Error("Target exists; use overwrite: true to replace it"), {
|
|
100
|
-
code: "EEXIST",
|
|
101
|
-
});
|
|
102
93
|
}
|
|
103
94
|
}
|
|
104
95
|
signal?.throwIfAborted();
|
|
105
96
|
started = true;
|
|
106
97
|
if (operation === "delete") await unlink(source);
|
|
107
98
|
else if (target !== undefined) {
|
|
108
|
-
if (operation === "copy")
|
|
109
|
-
|
|
110
|
-
else await fs.move(source, target, { overwrite: args.overwrite === true });
|
|
99
|
+
if (operation === "copy") await fs.copy(source, target, { overwrite: true });
|
|
100
|
+
else await fs.move(source, target, { overwrite: true });
|
|
111
101
|
}
|
|
112
102
|
return {
|
|
113
103
|
kind: "file-operation",
|
|
@@ -42,10 +42,11 @@ import {
|
|
|
42
42
|
type NativeEditBatchEvent,
|
|
43
43
|
} from "#src/api/native-edit-batch-event.js";
|
|
44
44
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
flushDataSchema,
|
|
46
|
+
flushOutputSchema,
|
|
47
47
|
mutationOutcome,
|
|
48
48
|
type MutationData,
|
|
49
|
+
type FlushData,
|
|
49
50
|
} from "./structured-result.js";
|
|
50
51
|
|
|
51
52
|
interface PendingBatch {
|
|
@@ -62,7 +63,7 @@ interface BatchSummary {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
interface ScriptBatch {
|
|
65
|
-
readonly reports: StructuredResult<
|
|
66
|
+
readonly reports: StructuredResult<FlushData>[];
|
|
66
67
|
reportCursor: number;
|
|
67
68
|
readonly id: string;
|
|
68
69
|
readonly context: ExtensionContext;
|
|
@@ -103,10 +104,7 @@ function receiptEffect(files: MutationData["files"]): MutationData["effect"] {
|
|
|
103
104
|
: "not-applied";
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
function receiptStatus(
|
|
107
|
-
errors: readonly unknown[],
|
|
108
|
-
operations: NonNullable<MutationData["operations"]>,
|
|
109
|
-
) {
|
|
107
|
+
function receiptStatus(errors: readonly unknown[], operations: FlushData["operations"]) {
|
|
110
108
|
return errors.length === 0
|
|
111
109
|
? ("success" as const)
|
|
112
110
|
: operations.some(
|
|
@@ -192,7 +190,7 @@ class NativeTextEditBatchCoordinator {
|
|
|
192
190
|
"Use flush to commit pending native Codemode text edits and return their observed effects. Await tools.flush({}) before depending on a completed write. A failed flush retains applied effects and does not replay edits. Call it only inside native Codemode.",
|
|
193
191
|
promptSnippet: "Commit pending native editor changes and inspect their effects",
|
|
194
192
|
parameters: Type.Object({}, { additionalProperties: false }),
|
|
195
|
-
outputSchema:
|
|
193
|
+
outputSchema: flushOutputSchema,
|
|
196
194
|
execute: async (id) => {
|
|
197
195
|
const script = this.invocations.get(id);
|
|
198
196
|
if (!script) throw new Error("Flush requires an active native Codemode script");
|
|
@@ -209,15 +207,24 @@ class NativeTextEditBatchCoordinator {
|
|
|
209
207
|
content: [
|
|
210
208
|
{
|
|
211
209
|
type: "text",
|
|
212
|
-
text:
|
|
210
|
+
text: [
|
|
213
211
|
errors.length === 0
|
|
214
212
|
? `Flushed ${operations.length} editor operations; ${effect}.`
|
|
215
|
-
: `Editor flush failed; ${effect}
|
|
213
|
+
: `Editor flush failed; ${effect}.`,
|
|
214
|
+
...files.map(
|
|
215
|
+
(file) =>
|
|
216
|
+
`${file.source}: ${file.effect}${file.state ? ` (${file.state})` : ""}`,
|
|
217
|
+
),
|
|
218
|
+
...operations.map(
|
|
219
|
+
(operation) =>
|
|
220
|
+
`${operation.operation}: ${operation.effect}${operation.errors.length ? ` — ${operation.errors.map((error) => error.message).join("; ")}` : ""}`,
|
|
221
|
+
),
|
|
222
|
+
].join("\n"),
|
|
216
223
|
},
|
|
217
224
|
],
|
|
218
225
|
details: { results: [] },
|
|
219
226
|
},
|
|
220
|
-
|
|
227
|
+
flushDataSchema,
|
|
221
228
|
{
|
|
222
229
|
status: receiptStatus(errors, operations),
|
|
223
230
|
data: { operation: "flush", effect, files, operations },
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Type, type Static } from "typebox";
|
|
2
|
-
import { Value } from "typebox/value";
|
|
3
2
|
import {
|
|
4
|
-
MAX_STRUCTURED_BYTES,
|
|
5
3
|
resultError,
|
|
6
4
|
resultErrorSchema,
|
|
7
5
|
structuredResultSchema,
|
|
@@ -23,142 +21,55 @@ const file = Type.Object(
|
|
|
23
21
|
{
|
|
24
22
|
source: Type.String(),
|
|
25
23
|
effect,
|
|
26
|
-
action: Type.Optional(Type.String()),
|
|
27
24
|
state: Type.Optional(
|
|
28
25
|
Type.Union([Type.Literal("present"), Type.Literal("absent"), Type.Literal("unknown")]),
|
|
29
26
|
),
|
|
30
27
|
},
|
|
31
28
|
{ additionalProperties: false },
|
|
32
29
|
);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
const receipt = { effect, files: Type.Array(file) };
|
|
31
|
+
|
|
32
|
+
/** Validate one file tool's result. Recovery, rendering and resource actions stay in details. */
|
|
33
|
+
export function mutationDataSchema(operation: string) {
|
|
34
|
+
return Type.Object(
|
|
35
|
+
{
|
|
36
|
+
operation: Type.Literal(operation),
|
|
37
|
+
...receipt,
|
|
38
|
+
operationId: Type.Optional(Type.String()),
|
|
39
|
+
...(operation === "delete" || operation === "flush"
|
|
40
|
+
? {}
|
|
41
|
+
: {
|
|
42
|
+
target: Type.Optional(Type.String()),
|
|
43
|
+
targetUnavailable: Type.Optional(Type.String()),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
{ additionalProperties: false },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
/** Internal validation schema for a single tool, not an agent-facing return declaration. */
|
|
50
|
+
export function mutationResultSchema(operation: string) {
|
|
51
|
+
return structuredResultSchema(mutationDataSchema(operation));
|
|
52
|
+
}
|
|
53
|
+
const batchOperation = Type.Object(
|
|
54
|
+
{ id: Type.String(), operation: Type.String(), effect, errors: Type.Array(resultErrorSchema) },
|
|
50
55
|
{ additionalProperties: false },
|
|
51
56
|
);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
effect,
|
|
56
|
-
operationId: Type.Optional(Type.String()),
|
|
57
|
-
target: Type.Optional(
|
|
58
|
-
Type.String({
|
|
59
|
-
description:
|
|
60
|
-
"Backend-owned resulting-text scope: replace/insert text, write's whole file, copy/move destinations, or undo's whole restored files. Delete never supplies a live target. Pending handles require a confirmed commit.",
|
|
61
|
-
}),
|
|
62
|
-
),
|
|
63
|
-
targetUnavailable: Type.Optional(
|
|
64
|
-
Type.String({
|
|
65
|
-
description:
|
|
66
|
-
"Why a completed mutation could not provide a safe resulting-text target. The write effect is reported separately.",
|
|
67
|
-
}),
|
|
68
|
-
),
|
|
69
|
-
files: Type.Array(file),
|
|
70
|
-
changes: Type.Optional(
|
|
71
|
-
Type.Array(
|
|
72
|
-
Type.Object(
|
|
73
|
-
{
|
|
74
|
-
source: Type.String(),
|
|
75
|
-
from: Type.Integer({
|
|
76
|
-
description:
|
|
77
|
-
"Inclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector.",
|
|
78
|
-
}),
|
|
79
|
-
to: Type.Integer({
|
|
80
|
-
description:
|
|
81
|
-
"Exclusive zero-based UTF-16 offset in the pre-edit snapshot; not a live selector.",
|
|
82
|
-
}),
|
|
83
|
-
removedText: Type.String(),
|
|
84
|
-
insertedText: Type.String(),
|
|
85
|
-
},
|
|
86
|
-
{ additionalProperties: false },
|
|
87
|
-
),
|
|
88
|
-
),
|
|
89
|
-
),
|
|
90
|
-
changesUnavailable: Type.Optional(
|
|
91
|
-
Type.String({
|
|
92
|
-
description: "Why the exact change record is omitted; applied effects remain reported.",
|
|
93
|
-
}),
|
|
94
|
-
),
|
|
95
|
-
operations: Type.Optional(Type.Array(operation)),
|
|
96
|
-
parentToolCallId: Type.Optional(Type.String()),
|
|
97
|
-
recovery: Type.Optional(
|
|
98
|
-
Type.Array(
|
|
99
|
-
Type.Object({
|
|
100
|
-
source: Type.String(),
|
|
101
|
-
field: Type.String(),
|
|
102
|
-
anchor: Type.String(),
|
|
103
|
-
total: Type.Integer(),
|
|
104
|
-
candidates: Type.Array(
|
|
105
|
-
Type.Object({
|
|
106
|
-
rank: Type.Integer(),
|
|
107
|
-
range: Type.Object({
|
|
108
|
-
start: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
109
|
-
end: Type.Object({ lineNumber: Type.Integer(), column: Type.Integer() }),
|
|
110
|
-
}),
|
|
111
|
-
}),
|
|
112
|
-
),
|
|
113
|
-
}),
|
|
114
|
-
),
|
|
115
|
-
),
|
|
116
|
-
action: Type.Optional(
|
|
117
|
-
Type.Object(
|
|
118
|
-
{
|
|
119
|
-
source: Type.String(),
|
|
120
|
-
kind: Type.Optional(Type.String()),
|
|
121
|
-
status: Type.Optional(Type.String()),
|
|
122
|
-
command: Type.Optional(Type.String()),
|
|
123
|
-
deleted: Type.Optional(Type.Boolean()),
|
|
124
|
-
session: Type.Optional(Type.String()),
|
|
125
|
-
file: Type.Optional(Type.String()),
|
|
126
|
-
line: Type.Optional(Type.Integer()),
|
|
127
|
-
verified: Type.Optional(Type.Boolean()),
|
|
128
|
-
evaluation: Type.Optional(
|
|
129
|
-
Type.Object(
|
|
130
|
-
{
|
|
131
|
-
expression: Type.String(),
|
|
132
|
-
result: Type.String(),
|
|
133
|
-
type: Type.Optional(Type.String()),
|
|
134
|
-
variablesReference: Type.Integer(),
|
|
135
|
-
},
|
|
136
|
-
{ additionalProperties: false },
|
|
137
|
-
),
|
|
138
|
-
),
|
|
139
|
-
breakpoints: Type.Optional(
|
|
140
|
-
Type.Array(
|
|
141
|
-
Type.Object(
|
|
142
|
-
{
|
|
143
|
-
source: Type.String(),
|
|
144
|
-
file: Type.String(),
|
|
145
|
-
line: Type.Integer(),
|
|
146
|
-
verified: Type.Boolean(),
|
|
147
|
-
},
|
|
148
|
-
{ additionalProperties: false },
|
|
149
|
-
),
|
|
150
|
-
),
|
|
151
|
-
),
|
|
152
|
-
},
|
|
153
|
-
{ additionalProperties: false },
|
|
154
|
-
),
|
|
155
|
-
),
|
|
156
|
-
},
|
|
57
|
+
/** Flush owns the batch journal; individual file tools do not carry it. */
|
|
58
|
+
export const flushDataSchema = Type.Object(
|
|
59
|
+
{ operation: Type.Literal("flush"), ...receipt, operations: Type.Array(batchOperation) },
|
|
157
60
|
{ additionalProperties: false },
|
|
158
61
|
);
|
|
159
|
-
export const
|
|
160
|
-
|
|
161
|
-
|
|
62
|
+
export const flushOutputSchema = structuredResultSchema(flushDataSchema);
|
|
63
|
+
export type FlushData = Static<typeof flushDataSchema>;
|
|
64
|
+
/** Small internal receipt used to collect observed file effects. */
|
|
65
|
+
export interface MutationData {
|
|
66
|
+
operation: string;
|
|
67
|
+
effect: Static<typeof effect>;
|
|
68
|
+
files: Static<typeof file>[];
|
|
69
|
+
operationId?: string;
|
|
70
|
+
target?: string;
|
|
71
|
+
targetUnavailable?: string;
|
|
72
|
+
}
|
|
162
73
|
type MutationFile = MutationData["files"][number];
|
|
163
74
|
function record(value: unknown): value is Record<string, unknown> {
|
|
164
75
|
return typeof value === "object" && value !== null;
|
|
@@ -180,16 +91,13 @@ export function mutationOutcome(
|
|
|
180
91
|
data: {
|
|
181
92
|
operation,
|
|
182
93
|
effect: "pending",
|
|
183
|
-
...(typeof details.metadata?.resultTarget === "string"
|
|
94
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
184
95
|
? { target: details.metadata.resultTarget }
|
|
185
96
|
: {}),
|
|
186
97
|
files:
|
|
187
98
|
typeof detailRecord.source === "string"
|
|
188
99
|
? [{ source: detailRecord.source, effect: "pending" }]
|
|
189
100
|
: [],
|
|
190
|
-
...(typeof native.parentToolCallId === "string"
|
|
191
|
-
? { parentToolCallId: native.parentToolCallId }
|
|
192
|
-
: {}),
|
|
193
101
|
},
|
|
194
102
|
};
|
|
195
103
|
const observed = new Set(completions.map((completion) => completion.resourceSource));
|
|
@@ -286,20 +194,6 @@ export function mutationOutcome(
|
|
|
286
194
|
const file = unique.find((file) => file.source === state.source);
|
|
287
195
|
if (file && (state.state === "present" || state.state === "absent")) file.state = state.state;
|
|
288
196
|
}
|
|
289
|
-
const changes = (results ?? [])
|
|
290
|
-
.filter((item) => item.data.ok)
|
|
291
|
-
.flatMap((item) => {
|
|
292
|
-
const source = item.data.path;
|
|
293
|
-
if (source === undefined) return [];
|
|
294
|
-
return (item.data.rawChanges ?? []).map((change) => ({
|
|
295
|
-
source,
|
|
296
|
-
from: change.fromA,
|
|
297
|
-
to: change.toA,
|
|
298
|
-
removedText: change.removedText,
|
|
299
|
-
insertedText: change.insertedText,
|
|
300
|
-
}));
|
|
301
|
-
});
|
|
302
|
-
const changesFit = Buffer.byteLength(JSON.stringify(changes)) <= MAX_STRUCTURED_BYTES / 2;
|
|
303
197
|
const known = unique.some((file) => file.effect === "applied");
|
|
304
198
|
if (result.isError && errors.length === 0)
|
|
305
199
|
errors.push({ code: "MUTATION_FAILED", message: "Mutation failed" });
|
|
@@ -318,46 +212,6 @@ export function mutationOutcome(
|
|
|
318
212
|
: known
|
|
319
213
|
? "applied"
|
|
320
214
|
: "not-applied";
|
|
321
|
-
const action =
|
|
322
|
-
semantic && typeof semantic.source === "string"
|
|
323
|
-
? {
|
|
324
|
-
source: semantic.source,
|
|
325
|
-
...(typeof semantic.kind === "string" ? { kind: semantic.kind } : {}),
|
|
326
|
-
...(typeof semantic.status === "string" ? { status: semantic.status } : {}),
|
|
327
|
-
...(typeof semantic.command === "string" ? { command: semantic.command } : {}),
|
|
328
|
-
...(typeof semantic.deleted === "boolean" ? { deleted: semantic.deleted } : {}),
|
|
329
|
-
...(typeof semantic.session === "string" ? { session: semantic.session } : {}),
|
|
330
|
-
...(typeof semantic.file === "string" ? { file: semantic.file } : {}),
|
|
331
|
-
...(typeof semantic.line === "number" ? { line: semantic.line } : {}),
|
|
332
|
-
...(typeof semantic.verified === "boolean" ? { verified: semantic.verified } : {}),
|
|
333
|
-
...(record(semantic.evaluation)
|
|
334
|
-
? {
|
|
335
|
-
evaluation: {
|
|
336
|
-
expression: semantic.evaluation.expression,
|
|
337
|
-
result: semantic.evaluation.result,
|
|
338
|
-
variablesReference: semantic.evaluation.variablesReference,
|
|
339
|
-
...(typeof semantic.evaluation.type === "string"
|
|
340
|
-
? { type: semantic.evaluation.type }
|
|
341
|
-
: {}),
|
|
342
|
-
},
|
|
343
|
-
}
|
|
344
|
-
: {}),
|
|
345
|
-
...(Array.isArray(semantic.breakpoints)
|
|
346
|
-
? {
|
|
347
|
-
breakpoints: semantic.breakpoints.filter(record).map((breakpoint) => ({
|
|
348
|
-
source: breakpoint.source,
|
|
349
|
-
file: breakpoint.file,
|
|
350
|
-
line: breakpoint.line,
|
|
351
|
-
verified: breakpoint.verified,
|
|
352
|
-
})),
|
|
353
|
-
}
|
|
354
|
-
: {}),
|
|
355
|
-
}
|
|
356
|
-
: undefined;
|
|
357
|
-
const checkedAction =
|
|
358
|
-
action && Value.Check(mutationDataSchema.properties.action, action) ? action : undefined;
|
|
359
|
-
if (action && !checkedAction)
|
|
360
|
-
errors.push(resultError("Action adapter returned invalid fields", "INVALID_STRUCTURED_RESULT"));
|
|
361
215
|
return {
|
|
362
216
|
status:
|
|
363
217
|
errors.length === 0
|
|
@@ -369,32 +223,12 @@ export function mutationOutcome(
|
|
|
369
223
|
operation,
|
|
370
224
|
effect,
|
|
371
225
|
files: unique,
|
|
372
|
-
...(
|
|
373
|
-
? {}
|
|
374
|
-
: changesFit
|
|
375
|
-
? { changes }
|
|
376
|
-
: {
|
|
377
|
-
changesUnavailable:
|
|
378
|
-
"Exact change record exceeds the 512 KiB receipt budget; it was not clipped.",
|
|
379
|
-
}),
|
|
380
|
-
...(typeof details.metadata?.resultTarget === "string"
|
|
226
|
+
...(operation !== "delete" && typeof details.metadata?.resultTarget === "string"
|
|
381
227
|
? { target: details.metadata.resultTarget }
|
|
382
228
|
: {}),
|
|
383
|
-
...(typeof details.metadata?.targetUnavailable === "string"
|
|
229
|
+
...(operation !== "delete" && typeof details.metadata?.targetUnavailable === "string"
|
|
384
230
|
? { targetUnavailable: details.metadata.targetUnavailable }
|
|
385
231
|
: {}),
|
|
386
|
-
...(details.anchorRecoveries === undefined
|
|
387
|
-
? {}
|
|
388
|
-
: {
|
|
389
|
-
recovery: details.anchorRecoveries.map((item) => ({
|
|
390
|
-
source: item.path,
|
|
391
|
-
field: item.field,
|
|
392
|
-
anchor: item.anchor,
|
|
393
|
-
total: item.total,
|
|
394
|
-
candidates: [...item.candidates],
|
|
395
|
-
})),
|
|
396
|
-
}),
|
|
397
|
-
...(checkedAction ? { action: checkedAction } : {}),
|
|
398
232
|
},
|
|
399
233
|
errors,
|
|
400
234
|
};
|
|
@@ -408,5 +242,5 @@ export function structuredMutation(
|
|
|
408
242
|
) {
|
|
409
243
|
const outcome = mutationOutcome(result, operation, completions);
|
|
410
244
|
if (outcome.data && operationId !== undefined) outcome.data.operationId = operationId;
|
|
411
|
-
return withStructuredResult(result, mutationDataSchema, outcome);
|
|
245
|
+
return withStructuredResult(result, mutationDataSchema(operation), outcome);
|
|
412
246
|
}
|
|
@@ -84,7 +84,7 @@ import type { ToolCallAnchorRenderState } from "pi-agent-tool-call-interception"
|
|
|
84
84
|
import type { Static, TSchema } from "typebox";
|
|
85
85
|
import { executeWholeFileTool, isWholeFileInvocation } from "#src/core/file-operation-tools.js";
|
|
86
86
|
import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
|
|
87
|
-
import {
|
|
87
|
+
import { mutationResultSchema, structuredMutation } from "./structured-result.js";
|
|
88
88
|
import type { ResultTargetStore } from "pi-agent-resource";
|
|
89
89
|
|
|
90
90
|
export function createTextTool<TParameters extends TSchema>(
|
|
@@ -118,7 +118,7 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
118
118
|
promptGuidelines: [...EDITING_GUIDELINES, ...(definition.promptGuidelines ?? [])],
|
|
119
119
|
description: definition.description,
|
|
120
120
|
parameters: definition.parameters,
|
|
121
|
-
outputSchema:
|
|
121
|
+
outputSchema: mutationResultSchema(definition.name),
|
|
122
122
|
prepareArguments: (arguments_) =>
|
|
123
123
|
// oxlint-disable-next-line typescript/no-unsafe-return -- TypeBox resolves only concrete tool schemas.
|
|
124
124
|
prepareGuardedArguments(
|
|
@@ -348,19 +348,17 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
348
348
|
(
|
|
349
349
|
{
|
|
350
350
|
replace:
|
|
351
|
-
"
|
|
352
|
-
insert:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
"Deletion returns a change record and file state, never a live target or an empty-position target.",
|
|
359
|
-
undo: "Local data.target selects whole restored text files, not only reversed spans. Restored absence is reported in files[].state without a live target.",
|
|
351
|
+
"This result selects the resulting text; empty replacement selects the resulting position, not the removed text.",
|
|
352
|
+
insert: "This result selects the inserted text, including supplied line separators.",
|
|
353
|
+
write: "This result selects the whole written file, not only its changed span.",
|
|
354
|
+
copy: "This result selects only destination text; a whole-file copy selects the whole destination. The source is unchanged.",
|
|
355
|
+
move: "This result selects only destination text; a whole-file move selects the whole destination. Source removals never become output targets.",
|
|
356
|
+
delete: "Deletion reports file effects but provides no reusable text selection.",
|
|
357
|
+
undo: "This result selects whole restored text files, not only reversed spans. Deleted files provide no text selection.",
|
|
360
358
|
} as Record<string, string>
|
|
361
359
|
)[definition.name] ?? "",
|
|
362
360
|
["replace", "insert", "write", "copy", "move", "undo"].includes(definition.name)
|
|
363
|
-
? "
|
|
361
|
+
? "Pass this unchanged result to another source tool for dependent work. Pending edits commit before the next tool consumes them. If the result reports no verified text selection, inspect the file instead."
|
|
364
362
|
: "",
|
|
365
363
|
definition.source.inherited
|
|
366
364
|
? definition.wholeFileOperation === undefined
|
|
@@ -1406,12 +1404,18 @@ async function anchorFailureToolResult(
|
|
|
1406
1404
|
const results: FileMutationResult[] = [];
|
|
1407
1405
|
const anchorRecoveries: NonNullable<FileMutationBatchResult["anchorRecoveries"]>[number][] = [];
|
|
1408
1406
|
const messages: string[] = [];
|
|
1407
|
+
const exactTextFailures: string[] = [];
|
|
1409
1408
|
for (const item of recovered) {
|
|
1410
1409
|
if (item === undefined) {
|
|
1411
1410
|
continue;
|
|
1412
1411
|
}
|
|
1413
1412
|
results.push(...(item.details.results ?? []));
|
|
1414
1413
|
anchorRecoveries.push(...(item.details.anchorRecoveries ?? []));
|
|
1414
|
+
const failed = item.details.metadata?.exactTextFailures;
|
|
1415
|
+
if (Array.isArray(failed))
|
|
1416
|
+
exactTextFailures.push(
|
|
1417
|
+
...failed.filter((source): source is string => typeof source === "string"),
|
|
1418
|
+
);
|
|
1415
1419
|
for (const block of item.content) {
|
|
1416
1420
|
if (block.type === "text") {
|
|
1417
1421
|
messages.push(block.text);
|
|
@@ -1423,7 +1427,12 @@ async function anchorFailureToolResult(
|
|
|
1423
1427
|
}
|
|
1424
1428
|
return {
|
|
1425
1429
|
content: [{ type: "text", text: messages.join("\n\n") }],
|
|
1426
|
-
details: {
|
|
1430
|
+
details: {
|
|
1431
|
+
results,
|
|
1432
|
+
anchorRecoveries,
|
|
1433
|
+
effect: "not-applied",
|
|
1434
|
+
metadata: { exactTextFailures },
|
|
1435
|
+
},
|
|
1427
1436
|
};
|
|
1428
1437
|
}
|
|
1429
1438
|
if (!(failure.cause instanceof TextMutationAnchorResolutionError)) {
|
|
@@ -1432,15 +1441,10 @@ async function anchorFailureToolResult(
|
|
|
1432
1441
|
|
|
1433
1442
|
const contextual = failure.cause;
|
|
1434
1443
|
const resolution = contextual.resolution;
|
|
1435
|
-
const recovery = await resolveAnchorRecovery(contextual)
|
|
1436
|
-
|
|
1437
|
-
return
|
|
1438
|
-
|
|
1439
|
-
failure.code,
|
|
1440
|
-
`${failure.message}; recovery timed out`,
|
|
1441
|
-
"not-applied",
|
|
1442
|
-
);
|
|
1443
|
-
}
|
|
1444
|
+
const recovery = await resolveAnchorRecovery(contextual).catch(() => {
|
|
1445
|
+
context.signal?.throwIfAborted();
|
|
1446
|
+
return undefined;
|
|
1447
|
+
});
|
|
1444
1448
|
|
|
1445
1449
|
const windows =
|
|
1446
1450
|
recovery?.kind === "candidates"
|
|
@@ -1451,9 +1455,7 @@ async function anchorFailureToolResult(
|
|
|
1451
1455
|
: resolution.rejection?.contextRange === undefined
|
|
1452
1456
|
? []
|
|
1453
1457
|
: [resolution.rejection.contextRange];
|
|
1454
|
-
if (windows.length === 0) {
|
|
1455
|
-
return undefined;
|
|
1456
|
-
}
|
|
1458
|
+
if (windows.length === 0) windows.push({ offset: 1, limit: 40 });
|
|
1457
1459
|
|
|
1458
1460
|
const reads = await Promise.all(
|
|
1459
1461
|
windows.map((range) =>
|
|
@@ -1464,14 +1466,15 @@ async function anchorFailureToolResult(
|
|
|
1464
1466
|
cwd: context.cwd,
|
|
1465
1467
|
...(context.signal !== undefined && { signal: context.signal }),
|
|
1466
1468
|
},
|
|
1467
|
-
)
|
|
1469
|
+
)?.catch(() => {
|
|
1470
|
+
context.signal?.throwIfAborted();
|
|
1471
|
+
return undefined;
|
|
1472
|
+
}),
|
|
1468
1473
|
),
|
|
1469
1474
|
);
|
|
1470
1475
|
const recoveryTexts: string[] = [];
|
|
1471
1476
|
for (const read of reads) {
|
|
1472
|
-
if (read === undefined || read.isError === true)
|
|
1473
|
-
return undefined;
|
|
1474
|
-
}
|
|
1477
|
+
if (read === undefined || read.isError === true) continue;
|
|
1475
1478
|
recoveryTexts.push(
|
|
1476
1479
|
...read.content.filter((block) => block.type === "text").map((block) => block.text),
|
|
1477
1480
|
);
|
|
@@ -1512,6 +1515,9 @@ async function anchorFailureToolResult(
|
|
|
1512
1515
|
results: [result],
|
|
1513
1516
|
effect: "not-applied",
|
|
1514
1517
|
anchorRecovery: true,
|
|
1518
|
+
...(resolution.resolverId === "exact-text" && {
|
|
1519
|
+
metadata: { exactTextFailures: [contextual.source] },
|
|
1520
|
+
}),
|
|
1515
1521
|
...(recovery?.kind === "candidates" && {
|
|
1516
1522
|
anchorRecoveries: [
|
|
1517
1523
|
{
|
|
@@ -1542,8 +1548,8 @@ function formatRejectedAnchorMessage(
|
|
|
1542
1548
|
? "is invalid"
|
|
1543
1549
|
: "could not be resolved";
|
|
1544
1550
|
const guidance =
|
|
1545
|
-
|
|
1546
|
-
? "
|
|
1551
|
+
failure.resolution.resolverId === "exact-text"
|
|
1552
|
+
? "Exact-text editing is now blocked for this file until an anchor-based edit succeeds. Find the intended location among the current anchors below, or use Read/Search for another section, and use its anchor. After that edit, exact text is available again."
|
|
1547
1553
|
: "If the intended text is represented below, use its candidate anchor. Otherwise, reread the relevant section and choose a current anchor.";
|
|
1548
1554
|
const context = recoveryContext.length === 0 ? "" : `\n\n${recoveryContext}`;
|
|
1549
1555
|
return `[SYSTEM] ${failure.toolName} blocked: ${failure.field} anchor "${failure.anchor}" ${state}. ${guidance} (${reason})${context}`;
|
|
@@ -33,12 +33,12 @@ export function sourceRangeProperties() {
|
|
|
33
33
|
export function targetProperties() {
|
|
34
34
|
return {
|
|
35
35
|
target: resultSourceProperty(
|
|
36
|
-
"Destination file path
|
|
36
|
+
"Destination file path, unchanged source result or its UUID. A result replaces its exact ranges (zero-width ranges insert); omit targetStart/targetEnd. Source and destination selections pair in declared order with equal counts. A file path keeps its existing anchor semantics. Whole-file transfers replace an existing regular destination file.",
|
|
37
37
|
),
|
|
38
38
|
targetStart: Type.Optional(
|
|
39
39
|
Type.String({
|
|
40
40
|
description:
|
|
41
|
-
"Registered anchor or unique exact text in the destination. Required for text transfers
|
|
41
|
+
"Registered anchor or unique exact text in the destination. Required for text transfers to a file path; omit for whole-file transfers or a result destination. Without targetEnd, inserts after the last containing line, keeping the selected text. With targetEnd, replacement starts at the first containing line. SEARCH :match also uses these line boundaries.",
|
|
42
42
|
}),
|
|
43
43
|
),
|
|
44
44
|
targetEnd: Type.Optional(
|
|
@@ -47,10 +47,5 @@ export function targetProperties() {
|
|
|
47
47
|
"Optional inclusive destination end. Replaces whole lines through the last line containing this anchor, including SEARCH :match. May differ in type from targetStart; both must resolve uniquely in the target file and in forward order. Omit to insert after targetStart instead.",
|
|
48
48
|
}),
|
|
49
49
|
),
|
|
50
|
-
overwrite: Type.Optional(
|
|
51
|
-
Type.Boolean({
|
|
52
|
-
description: "Allow replacing an existing regular target file. Defaults to false.",
|
|
53
|
-
}),
|
|
54
|
-
),
|
|
55
50
|
};
|
|
56
51
|
}
|
|
@@ -18,7 +18,7 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
18
18
|
export const copySchema = Type.Object(
|
|
19
19
|
{
|
|
20
20
|
path: resultSourceProperty(
|
|
21
|
-
"Source file path or
|
|
21
|
+
"Source file path, unchanged source result or its UUID; omit start/end for result inputs. Use one whole-file result when the destination is a file path without text selectors. Source/destination selections pair in declared order, with equal counts and duplicate ranges removed.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
24
|
...targetProperties(),
|
|
@@ -18,7 +18,7 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
18
18
|
export const deleteSchema = Type.Object(
|
|
19
19
|
{
|
|
20
20
|
path: resultSourceProperty(
|
|
21
|
-
"File path or
|
|
21
|
+
"File path, unchanged source result or its UUID. A result input deletes only its selected text and keeps the file, even for a whole-file selection; omit start/end.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties(),
|
|
24
24
|
},
|
|
@@ -34,7 +34,7 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
|
|
|
34
34
|
name: "delete",
|
|
35
35
|
wholeFileOperation: "delete",
|
|
36
36
|
description:
|
|
37
|
-
"Use delete to permanently delete one regular file when an ordinary string path is supplied without text selectors, or to remove selected text.
|
|
37
|
+
"Use delete to permanently delete one regular file when an ordinary string path is supplied without text selectors, or to remove selected text. A result input removes only its text ranges and keeps the file, even for a whole-file selection. Whole-file deletion rejects directories and symlinks.",
|
|
38
38
|
|
|
39
39
|
promptSnippet: "Delete regular files, or delete selected text using exact matches or anchors",
|
|
40
40
|
parameters: deleteSchema,
|
|
@@ -20,7 +20,7 @@ import type { TextChange } from "#src/core/text-change-engine.js";
|
|
|
20
20
|
export const moveSchema = Type.Object(
|
|
21
21
|
{
|
|
22
22
|
path: resultSourceProperty(
|
|
23
|
-
"Source file path or
|
|
23
|
+
"Source file path, unchanged source result or its UUID; omit start/end for result inputs. Use one whole-file result when the destination is a file path without text selectors. Source/destination selections pair in declared order, with equal counts and duplicate ranges removed. Destinations must not overlap or touch source ranges.",
|
|
24
24
|
),
|
|
25
25
|
...sourceRangeProperties(),
|
|
26
26
|
...targetProperties(),
|