pi-agent-ide 0.7.2 → 0.7.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 +29 -0
- package/README.md +3 -1
- package/dist/{chunk-KOVPDKSJ.js → chunk-2ZMMRINH.js} +1 -1
- package/dist/{chunk-EURHXLN3.js → chunk-BYZSBXUK.js} +1 -1
- package/dist/{chunk-XDG7EQRN.js → chunk-CEX73RI5.js} +1 -1
- package/dist/{chunk-YWQS33DF.js → chunk-DZWTKF2K.js} +1 -1
- package/dist/{chunk-F6IWZKOG.js → chunk-EOKEQ3YH.js} +1 -1
- package/dist/{chunk-SJ4UZ4GU.js → chunk-HZ5BNF3A.js} +1 -1
- package/dist/{chunk-TQGE7RH6.js → chunk-NHKPP2AI.js} +2 -2
- package/dist/{chunk-SNF7PDDX.js → chunk-TXOTNK6B.js} +1 -1
- package/dist/chunk-WLZIUMJL.js +1 -0
- package/dist/entry-11.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-31.js +12 -12
- package/dist/entry-33.js +3 -2
- package/dist/entry-37.js +6 -6
- package/dist/entry-51.js +1 -1
- package/dist/entry-56.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 +56 -51
- package/dist/entry-78.js +8 -7
- package/dist/entry-79.js +1 -1
- package/dist/pi-agent-ide.js +20 -20
- package/docs/agent-guides/editing.md +9 -2
- package/docs/configuration.md +21 -0
- package/docs/development.md +4 -0
- package/docs/directory-operations.md +45 -0
- package/docs/releases.md +8 -0
- package/docs/research/codemode-write-context.md +56 -0
- package/docs/user-hooks.md +26 -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 +7 -7
- 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 +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +3 -1
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +7 -2
- package/node_modules/pi-agent-ide-changes/package.json +9 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +16 -0
- 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 +1 -1
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +2 -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-resource/package.json +1 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- 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/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/api/delete-guard.ts +24 -0
- package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
- package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
- package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +30 -40
- package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -6
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +7 -1
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +55 -12
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +39 -9
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +7 -1
- package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +3 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +51 -1
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +53 -8
- package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -4
- 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 +6 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +33 -18
- 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 +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 +36 -35
- package/src/api/hooks.ts +24 -0
- package/src/composite/nested-tool-rendering.ts +120 -71
- 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/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 +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-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- 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-renderer/src/renderer.ts +33 -18
- 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/delete-guard.ts +24 -0
- package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
- package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
- package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
- package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +30 -40
- package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -6
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +7 -1
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +55 -12
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +39 -9
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +7 -1
- package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +3 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +51 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +53 -8
- package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +6 -4
- 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 +6 -4
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +3 -1
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +7 -2
- package/src/plugins/pi-agent-ide-changes/package.json +9 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +16 -0
- package/src/plugins/pi-agent-ide-debugger/index.ts +3 -1
- 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 +1 -1
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
- package/dist/chunk-PKSQT6TC.js +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
interface TemporaryDirectorySettings {
|
|
6
|
+
readonly mode: "replace" | "extend";
|
|
7
|
+
readonly paths: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Load temporary roots for Delete: defaults, then global, then project settings. */
|
|
11
|
+
export async function loadTemporaryDirectories(projectRoot: string): Promise<readonly string[]> {
|
|
12
|
+
const home = await realpath(os.homedir());
|
|
13
|
+
const agent = process.env.PI_CODING_AGENT_DIR?.trim();
|
|
14
|
+
const names = ["tmp", ".tmp", "temp", ".temp"];
|
|
15
|
+
const system = await existingRoot(os.tmpdir());
|
|
16
|
+
// Named defaults do not grant permission to a symlink's destination outside the root.
|
|
17
|
+
let roots = [
|
|
18
|
+
...names.map((name) => path.join(projectRoot, name)),
|
|
19
|
+
...names.map((name) => path.join(home, name)),
|
|
20
|
+
...(system === undefined ? [] : [system]),
|
|
21
|
+
];
|
|
22
|
+
const layers = [
|
|
23
|
+
{
|
|
24
|
+
file: path.join(
|
|
25
|
+
agent ? path.resolve(agent) : path.join(home, ".pi", "agent"),
|
|
26
|
+
"pi-agent-ide",
|
|
27
|
+
"deletion.json",
|
|
28
|
+
),
|
|
29
|
+
base: home,
|
|
30
|
+
},
|
|
31
|
+
{ file: path.join(projectRoot, ".pi", "pi-agent-ide", "deletion.json"), base: projectRoot },
|
|
32
|
+
];
|
|
33
|
+
for (const { file, base } of layers) {
|
|
34
|
+
const settings = await readSettings(file);
|
|
35
|
+
if (settings === undefined) continue;
|
|
36
|
+
const configured: string[] = [];
|
|
37
|
+
for (const entry of settings.paths) {
|
|
38
|
+
const expanded =
|
|
39
|
+
entry === "~"
|
|
40
|
+
? home
|
|
41
|
+
: entry.startsWith("~/")
|
|
42
|
+
? path.join(home, entry.slice(2))
|
|
43
|
+
: path.resolve(base, entry);
|
|
44
|
+
const root = await existingRoot(expanded);
|
|
45
|
+
if (root !== undefined) configured.push(root);
|
|
46
|
+
}
|
|
47
|
+
roots = settings.mode === "replace" ? configured : [...roots, ...configured];
|
|
48
|
+
}
|
|
49
|
+
return [...new Set(roots)].sort();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function readSettings(file: string): Promise<TemporaryDirectorySettings | undefined> {
|
|
53
|
+
let source: string;
|
|
54
|
+
try {
|
|
55
|
+
source = await readFile(file, "utf8");
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (isMissing(error)) return undefined;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
let value: unknown;
|
|
61
|
+
try {
|
|
62
|
+
value = JSON.parse(source);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new Error(`Invalid JSON in deletion config at ${file}`, { cause: error });
|
|
65
|
+
}
|
|
66
|
+
if (!isRecord(value) || Object.keys(value).some((key) => key !== "temporaryDirectories"))
|
|
67
|
+
throw new Error(`Invalid deletion config at ${file}: expected temporaryDirectories settings`);
|
|
68
|
+
if (value.temporaryDirectories === undefined) return undefined;
|
|
69
|
+
const settings = value.temporaryDirectories;
|
|
70
|
+
if (
|
|
71
|
+
!isRecord(settings) ||
|
|
72
|
+
Object.keys(settings).some((key) => key !== "mode" && key !== "paths") ||
|
|
73
|
+
(settings.mode !== "replace" && settings.mode !== "extend") ||
|
|
74
|
+
!Array.isArray(settings.paths) ||
|
|
75
|
+
settings.paths.some((entry) => typeof entry !== "string" || entry.trim().length === 0)
|
|
76
|
+
)
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Invalid temporaryDirectories at ${file}: use mode replace or extend and a paths array of non-empty strings`,
|
|
79
|
+
);
|
|
80
|
+
return { mode: settings.mode, paths: settings.paths as string[] };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function existingRoot(directory: string): Promise<string | undefined> {
|
|
84
|
+
try {
|
|
85
|
+
return await realpath(directory);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (isMissing(error)) return undefined;
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
92
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
93
|
+
}
|
|
94
|
+
function isMissing(error: unknown): boolean {
|
|
95
|
+
return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
|
|
96
|
+
}
|
|
@@ -411,6 +411,9 @@ export async function executeRegisteredTextBatch(
|
|
|
411
411
|
source: destination ?? outcome.failure.source,
|
|
412
412
|
...(outcome.failure.rollback !== undefined && {
|
|
413
413
|
rollback: {
|
|
414
|
+
restored: outcome.failure.rollback.restored.filter((source) =>
|
|
415
|
+
mutation.edits.has(source),
|
|
416
|
+
),
|
|
414
417
|
failed: outcome.failure.rollback.failed.filter((source) =>
|
|
415
418
|
mutation.edits.has(source),
|
|
416
419
|
),
|
|
@@ -97,6 +97,7 @@ import type {
|
|
|
97
97
|
TextMutationPreviewRequest,
|
|
98
98
|
} from "#src/api/mutation-preview.js";
|
|
99
99
|
|
|
100
|
+
import type { BeforeDeleteEvent, DeleteGuardRegistration } from "#src/api/delete-guard.js";
|
|
100
101
|
type PluginStatus = "active" | "pending";
|
|
101
102
|
|
|
102
103
|
interface PluginLifecycle {
|
|
@@ -215,6 +216,7 @@ interface PluginContributionDraft {
|
|
|
215
216
|
readonly mutationToolListeners?: TextMutationToolListener[];
|
|
216
217
|
readonly editCompletionListeners?: TextEditCompletionListener[];
|
|
217
218
|
readonly mutationGuards?: TextMutationGuardRegistration[];
|
|
219
|
+
readonly deleteGuards?: DeleteGuardRegistration[];
|
|
218
220
|
readonly toolRenderers?: TextEditorToolRendererRegistration[];
|
|
219
221
|
}
|
|
220
222
|
|
|
@@ -264,6 +266,8 @@ export interface TextResourceEditFailure {
|
|
|
264
266
|
readonly rollback?: {
|
|
265
267
|
readonly failed: readonly string[];
|
|
266
268
|
readonly originallyMissing: readonly string[];
|
|
269
|
+
/** Existing resources whose restoration write succeeded. */
|
|
270
|
+
readonly restored: readonly string[];
|
|
267
271
|
};
|
|
268
272
|
}
|
|
269
273
|
|
|
@@ -334,6 +338,8 @@ export interface TextResourcesEditContext
|
|
|
334
338
|
extends ResourceResolverContext, TextMutationGuardContext {}
|
|
335
339
|
|
|
336
340
|
export interface TextEditorCore {
|
|
341
|
+
/** Run whole-object deletion policies in registration order; denial and errors block removal. */
|
|
342
|
+
beforeDelete(event: BeforeDeleteEvent): Promise<void>;
|
|
337
343
|
/** Finalize a surviving local text file after a whole-file operation; binary files are untouched. */
|
|
338
344
|
postProcessFile(source: string, context: ResourceResolverContext): Promise<void>;
|
|
339
345
|
/** Reserve complete file sets. Only an explicit transaction owner may enqueue covered nested edits. */
|
|
@@ -426,6 +432,7 @@ export function createTextEditorCore(
|
|
|
426
432
|
const mutationListeners = new Set<TextMutationToolListener>();
|
|
427
433
|
const editCompletionListeners = new Set<TextEditCompletionListener>();
|
|
428
434
|
const mutationGuards: TextMutationGuardRegistration[] = [];
|
|
435
|
+
const deleteGuards: DeleteGuardRegistration[] = [];
|
|
429
436
|
const toolRenderers = new Map<TextEditorToolId, TextEditorToolRendererRegistration>();
|
|
430
437
|
let registrationQueue = Promise.resolve();
|
|
431
438
|
const scheduler = resourceScheduler;
|
|
@@ -499,6 +506,7 @@ export function createTextEditorCore(
|
|
|
499
506
|
handlers.push(...draft.handlers);
|
|
500
507
|
semanticHandlers.push(...(draft.semanticHandlers ?? []));
|
|
501
508
|
mutationGuards.push(...(draft.mutationGuards ?? []));
|
|
509
|
+
deleteGuards.push(...(draft.deleteGuards ?? []));
|
|
502
510
|
promptContributions.push(...draft.promptContributions);
|
|
503
511
|
writablePromptContributions.push(...draft.writablePromptContributions);
|
|
504
512
|
|
|
@@ -533,6 +541,22 @@ export function createTextEditorCore(
|
|
|
533
541
|
};
|
|
534
542
|
|
|
535
543
|
const core: TextEditorCore = {
|
|
544
|
+
async beforeDelete(event) {
|
|
545
|
+
for (const registration of [...deleteGuards]) {
|
|
546
|
+
event.signal?.throwIfAborted();
|
|
547
|
+
try {
|
|
548
|
+
const decision = await registration.guard(event);
|
|
549
|
+
if (decision.decision !== "allow") throw new Error(decision.reason);
|
|
550
|
+
} catch (error) {
|
|
551
|
+
throw Object.assign(
|
|
552
|
+
new Error(
|
|
553
|
+
`Delete blocked by hook ${registration.id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
554
|
+
),
|
|
555
|
+
{ code: "DELETE_HOOK_REJECTED" },
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
},
|
|
536
560
|
async postProcessFile(source, context) {
|
|
537
561
|
await enqueueMutation(
|
|
538
562
|
async () => {
|
|
@@ -1337,7 +1361,13 @@ async function editTextResources<Result>(
|
|
|
1337
1361
|
resolverId: item.resolverId,
|
|
1338
1362
|
message: `Unable to write ${source}: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
1339
1363
|
cause,
|
|
1340
|
-
rollback: {
|
|
1364
|
+
rollback: {
|
|
1365
|
+
failed: rollbackFailures,
|
|
1366
|
+
originallyMissing,
|
|
1367
|
+
restored: written.filter(
|
|
1368
|
+
(source) => !rollbackFailures.includes(source) && !originallyMissing.includes(source),
|
|
1369
|
+
),
|
|
1370
|
+
},
|
|
1341
1371
|
},
|
|
1342
1372
|
completed: [],
|
|
1343
1373
|
};
|
|
@@ -1995,6 +2025,7 @@ function createPluginContributionController(
|
|
|
1995
2025
|
mutationToolListeners: [],
|
|
1996
2026
|
editCompletionListeners: [],
|
|
1997
2027
|
mutationGuards: [],
|
|
2028
|
+
deleteGuards: [],
|
|
1998
2029
|
toolRenderers: [],
|
|
1999
2030
|
};
|
|
2000
2031
|
let state: "active" | "closed" | "setup" = "setup";
|
|
@@ -2118,6 +2149,25 @@ function createPluginContributionController(
|
|
|
2118
2149
|
toolRenderers: [registration],
|
|
2119
2150
|
});
|
|
2120
2151
|
},
|
|
2152
|
+
addDeleteGuard(registration): void {
|
|
2153
|
+
assertAvailable();
|
|
2154
|
+
if (registration.id.trim().length === 0 || typeof registration.guard !== "function") {
|
|
2155
|
+
throw new TypeError(`Plugin ${pluginId} provided an invalid delete guard`);
|
|
2156
|
+
}
|
|
2157
|
+
if (state === "setup") {
|
|
2158
|
+
requiredValue(setupDraft.deleteGuards).push(registration);
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
registerContributions({
|
|
2162
|
+
resolvers: [],
|
|
2163
|
+
anchorResolvers: [],
|
|
2164
|
+
handlers: [],
|
|
2165
|
+
promptContributions: [],
|
|
2166
|
+
writablePromptContributions: [],
|
|
2167
|
+
tools: [],
|
|
2168
|
+
deleteGuards: [registration],
|
|
2169
|
+
});
|
|
2170
|
+
},
|
|
2121
2171
|
addMutationGuard(registration): void {
|
|
2122
2172
|
assertAvailable();
|
|
2123
2173
|
|
|
@@ -89,6 +89,7 @@ import type { ToolCallAnchorRenderState } from "pi-agent-tool-call-interception"
|
|
|
89
89
|
import type { Static, TSchema } from "typebox";
|
|
90
90
|
import { executeWholeFileTool, isWholeFileInvocation } from "#src/core/file-operation-tools.js";
|
|
91
91
|
import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
|
|
92
|
+
import { writeAgentResult } from "./write-agent-result.js";
|
|
92
93
|
import { mutationResultSchema, structuredMutation } from "./structured-result.js";
|
|
93
94
|
import type { ResultTargetStore } from "pi-agent-resource";
|
|
94
95
|
|
|
@@ -124,8 +125,8 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
124
125
|
description: definition.description,
|
|
125
126
|
parameters: definition.parameters,
|
|
126
127
|
outputSchema: mutationResultSchema(definition.name),
|
|
128
|
+
// oxlint-disable-next-line typescript/no-unsafe-return -- TypeBox resolves only concrete tool schemas.
|
|
127
129
|
prepareArguments: (arguments_) =>
|
|
128
|
-
// oxlint-disable-next-line typescript/no-unsafe-return -- TypeBox resolves only concrete tool schemas.
|
|
129
130
|
prepareGuardedArguments(
|
|
130
131
|
definition.parameters,
|
|
131
132
|
arguments_,
|
|
@@ -220,6 +221,20 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
220
221
|
);
|
|
221
222
|
input = asMutationParameters<TParameters>(prepared.input);
|
|
222
223
|
verifyFileSource = prepared.verifyFileSource;
|
|
224
|
+
if (prepared.noOpTarget !== undefined)
|
|
225
|
+
return {
|
|
226
|
+
content: [
|
|
227
|
+
{
|
|
228
|
+
type: "text",
|
|
229
|
+
text: "No changes: zero-width selections. The result selects the unchanged destination points.",
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
details: {
|
|
233
|
+
results: [],
|
|
234
|
+
effect: "not-applied",
|
|
235
|
+
metadata: { resultTarget: prepared.noOpTarget },
|
|
236
|
+
},
|
|
237
|
+
};
|
|
223
238
|
if (prepared.empty)
|
|
224
239
|
return {
|
|
225
240
|
content: [
|
|
@@ -348,7 +363,18 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
348
363
|
undefined,
|
|
349
364
|
definition.name === "copy",
|
|
350
365
|
);
|
|
351
|
-
return structuredMutation(
|
|
366
|
+
return structuredMutation(
|
|
367
|
+
definition.name === "write"
|
|
368
|
+
? writeAgentResult(
|
|
369
|
+
failed,
|
|
370
|
+
captured.completions,
|
|
371
|
+
asMutationParameters<TParameters>(parameters)[definition.source.field],
|
|
372
|
+
)
|
|
373
|
+
: failed,
|
|
374
|
+
definition.name,
|
|
375
|
+
captured.completions,
|
|
376
|
+
toolCallId,
|
|
377
|
+
);
|
|
352
378
|
}
|
|
353
379
|
const completedValue =
|
|
354
380
|
copyPlan.unchanged && captured.completions.length === 0 && !captured.value.isError
|
|
@@ -362,7 +388,7 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
362
388
|
: captured.value;
|
|
363
389
|
// Live-resource actions have their own receipts, not filesystem editor batches.
|
|
364
390
|
if (captured.completions.every((completion) => completion.resolvedBy === "filesystem"))
|
|
365
|
-
recordNativeTextMutation(core, toolCallId, completedValue);
|
|
391
|
+
recordNativeTextMutation(core, toolCallId, definition.name, completedValue);
|
|
366
392
|
const value =
|
|
367
393
|
resultTargets &&
|
|
368
394
|
["replace", "insert", "write", "copy", "move", "undo"].includes(definition.name)
|
|
@@ -388,7 +414,15 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
388
414
|
)
|
|
389
415
|
: completedValue;
|
|
390
416
|
return structuredMutation(
|
|
391
|
-
definition.name === "copy"
|
|
417
|
+
definition.name === "copy"
|
|
418
|
+
? describeUnavailableCopyTarget(value)
|
|
419
|
+
: definition.name === "write"
|
|
420
|
+
? writeAgentResult(
|
|
421
|
+
value,
|
|
422
|
+
captured.completions,
|
|
423
|
+
asMutationParameters<TParameters>(parameters)[definition.source.field],
|
|
424
|
+
)
|
|
425
|
+
: value,
|
|
392
426
|
definition.name,
|
|
393
427
|
captured.completions,
|
|
394
428
|
toolCallId,
|
|
@@ -410,9 +444,9 @@ export function createTextTool<TParameters extends TSchema>(
|
|
|
410
444
|
insert:
|
|
411
445
|
"For text edits, this result selects the inserted text, including supplied line separators. Specialized resources return their own action result.",
|
|
412
446
|
write:
|
|
413
|
-
"For file writes, this result selects the whole file, not
|
|
447
|
+
"For file writes, this result selects the whole file and returns a compact write receipt, not file content.",
|
|
414
448
|
copy: "This result selects only the copied destination text; a whole-file copy selects the whole destination. Copy edits only the destination.",
|
|
415
|
-
move: "Use the Move result to work with the inserted destination text, including any added line separators. Source removals are not selected. A whole-file move selects the whole destination when a reusable text result is available.",
|
|
449
|
+
move: "Use the Move result to work with the inserted destination text, including any added line separators. Valid empty arrays and paired zero-width selections succeed without writes; paired points select only the unchanged destination points. Source removals are not selected. A whole-file move selects the whole destination when a reusable text result is available.",
|
|
416
450
|
delete: "Delete returns no reusable text selection.",
|
|
417
451
|
undo: "The result selects the whole restored text file, not only the reversed span.",
|
|
418
452
|
} as Record<string, string>
|
|
@@ -1767,7 +1801,9 @@ function failureToolResult(
|
|
|
1767
1801
|
? "The edit was saved, but a post-write step failed. Run Read/Search before editing this resource again."
|
|
1768
1802
|
: effect === "unknown"
|
|
1769
1803
|
? "The operation failed, and its effects are unknown. Read the affected resources before retrying."
|
|
1770
|
-
:
|
|
1804
|
+
: code === "MUTATION_REJECTED"
|
|
1805
|
+
? undefined
|
|
1806
|
+
: "No file was changed."
|
|
1771
1807
|
: rollback.originallyMissing.length > 0
|
|
1772
1808
|
? "The file may now exist. Read the path before retrying."
|
|
1773
1809
|
: uncertain
|
|
@@ -1777,9 +1813,18 @@ function failureToolResult(
|
|
|
1777
1813
|
ok: false,
|
|
1778
1814
|
path: source,
|
|
1779
1815
|
errors: [{ path: source, code, reason }],
|
|
1780
|
-
...(fileChangedStatement === undefined
|
|
1816
|
+
...(fileChangedStatement === undefined
|
|
1817
|
+
? {}
|
|
1818
|
+
: {
|
|
1819
|
+
fileChangedStatement:
|
|
1820
|
+
fileChangedStatement +
|
|
1821
|
+
(rollback !== undefined && rollback.restored.length > 0
|
|
1822
|
+
? `\nRolled back: ${rollback.restored.join(", ")}.`
|
|
1823
|
+
: ""),
|
|
1824
|
+
}),
|
|
1781
1825
|
...(rollback !== undefined && {
|
|
1782
1826
|
rollback: {
|
|
1827
|
+
restoredSources: rollback.restored,
|
|
1783
1828
|
failedSources: [...new Set([...rollback.failed, ...rollback.originallyMissing])],
|
|
1784
1829
|
},
|
|
1785
1830
|
}),
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { TextEditCompletion } from "#src/api/edit-completion.js";
|
|
3
|
+
import type { FileMutationBatchResult, FileMutationResult } from "#src/api/mutation-result.js";
|
|
4
|
+
import { mutationOutcome } from "./structured-result.js";
|
|
5
|
+
|
|
6
|
+
/** Summarize Write problems without quoting diagnostics, diffs, or file text. */
|
|
7
|
+
export function writeProblemNotices(results: readonly FileMutationResult[]): string[] {
|
|
8
|
+
const notices = new Set<string>();
|
|
9
|
+
for (const result of results) {
|
|
10
|
+
if (result.data.formatting?.status === "failed") notices.add("Formatting failed.");
|
|
11
|
+
if (
|
|
12
|
+
result.data.formatting?.status === "skipped-syntax" ||
|
|
13
|
+
result.warnings.some((warning) => warning.severity === "syntax") ||
|
|
14
|
+
result.hints.some((hint) => hint.source === "compiler" && hint.severity === "error")
|
|
15
|
+
)
|
|
16
|
+
notices.add("Syntax diagnostics detected.");
|
|
17
|
+
if (
|
|
18
|
+
result.data.diffStatuses?.some(
|
|
19
|
+
(status) =>
|
|
20
|
+
(status.tone === "warning" || status.tone === "error") &&
|
|
21
|
+
(status.formattingStatus === undefined ||
|
|
22
|
+
status.formattingStatus !== result.data.formatting?.status),
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
notices.add("Post-edit processing was interrupted or incomplete.");
|
|
26
|
+
}
|
|
27
|
+
return [...notices];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Keep the agent's file Write receipt small while retaining full renderer data and targets. */
|
|
31
|
+
export function writeAgentResult(
|
|
32
|
+
result: AgentToolResult<FileMutationBatchResult>,
|
|
33
|
+
completions: readonly TextEditCompletion[],
|
|
34
|
+
requestedPath: unknown,
|
|
35
|
+
): AgentToolResult<FileMutationBatchResult> {
|
|
36
|
+
// Terminal input and other live resources keep their own action receipts.
|
|
37
|
+
if (
|
|
38
|
+
(typeof requestedPath === "string" && requestedPath.startsWith("shell:")) ||
|
|
39
|
+
completions.some((completion) => completion.resolvedBy !== "filesystem")
|
|
40
|
+
)
|
|
41
|
+
return result;
|
|
42
|
+
const outcome = mutationOutcome(result, "write", completions);
|
|
43
|
+
// Write accepts one file. Completion metadata may also name its absolute alias.
|
|
44
|
+
const source = outcome.data?.files[0]?.source;
|
|
45
|
+
const fallback =
|
|
46
|
+
typeof requestedPath === "string" && !requestedPath.startsWith("<system-result")
|
|
47
|
+
? requestedPath
|
|
48
|
+
: undefined;
|
|
49
|
+
const status =
|
|
50
|
+
outcome.data?.effect === "applied"
|
|
51
|
+
? "Saved file."
|
|
52
|
+
: outcome.status === "success" && outcome.data?.effect === "not-applied"
|
|
53
|
+
? "No write needed."
|
|
54
|
+
: outcome.data?.effect === "unknown"
|
|
55
|
+
? "Write outcome unknown."
|
|
56
|
+
: "Write failed; no file was written.";
|
|
57
|
+
const reason = outcome.errors[0]?.message.split(/\r?\n/u)[0]?.slice(0, 200);
|
|
58
|
+
const lines = [
|
|
59
|
+
status,
|
|
60
|
+
...((source ?? fallback) ? [`Path: ${source ?? fallback}`] : []),
|
|
61
|
+
...(reason ? [`Reason: ${reason}`] : []),
|
|
62
|
+
...writeProblemNotices(result.details.results ?? []),
|
|
63
|
+
"Read the file if you need its content.",
|
|
64
|
+
];
|
|
65
|
+
return { ...result, content: [{ type: "text", text: lines.join("\n") }] };
|
|
66
|
+
}
|
|
@@ -32,10 +32,10 @@ export function sourceRangeProperties(descriptions: Partial<Record<"start" | "en
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/** Build the destination selectors shared by copy and move schemas. */
|
|
35
|
-
export function targetProperties() {
|
|
35
|
+
export function targetProperties(directorySemantics: string) {
|
|
36
36
|
return {
|
|
37
37
|
target: resultSourceProperty(
|
|
38
|
-
|
|
38
|
+
`Destination 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 path with text selectors keeps its existing anchor semantics. Whole-object transfers create missing parents and replace regular destination files. ${directorySemantics} Reject symlink destinations, type conflicts, and overlapping directory trees.`,
|
|
39
39
|
),
|
|
40
40
|
targetStart: Type.Optional(
|
|
41
41
|
Type.String({
|
|
@@ -18,10 +18,12 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
|
|
|
18
18
|
export const copySchema = Type.Object(
|
|
19
19
|
{
|
|
20
20
|
path: resultSourceProperty(
|
|
21
|
-
"
|
|
21
|
+
"Filesystem source path, unchanged source result or its UUID; omit start/end for result inputs. Use ordinary paths without selectors to copy whole files, directory trees, or symlink objects without following their targets. 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
|
-
...targetProperties(
|
|
24
|
+
...targetProperties(
|
|
25
|
+
"Directory Copy merges into the exact target path and retains destination-only entries.",
|
|
26
|
+
),
|
|
25
27
|
},
|
|
26
28
|
{ additionalProperties: false },
|
|
27
29
|
);
|
|
@@ -38,9 +40,9 @@ export const copyMutationTool: TextMutationToolRegistration<typeof copySchema> =
|
|
|
38
40
|
name: "copy",
|
|
39
41
|
wholeFileOperation: "copy",
|
|
40
42
|
description:
|
|
41
|
-
"Use copy to copy
|
|
43
|
+
"Use copy to copy a file, directory tree, or symlink object, or to duplicate selected text within or between files.",
|
|
42
44
|
|
|
43
|
-
promptSnippet: "Copy
|
|
45
|
+
promptSnippet: "Copy filesystem objects or selected text",
|
|
44
46
|
parameters: copySchema,
|
|
45
47
|
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
46
48
|
anchors: [
|
|
@@ -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
|
-
"
|
|
21
|
+
"Filesystem path, shell:<session>, debug:<session>, debug:<session>/breakpoint/<id>, unchanged source result or its UUID, or an array of results. An ordinary filesystem path without start/end deletes the object: directories recursively, symlinks only as links. A text result input removes only selected text and keeps the file, even for a whole-file selection. For Read results from symbol:<file>#<selector>, deletion removes only the declaration text; imports and references are unchanged. Omit start/end for result inputs. Omit path when a supplied text anchor identifies the file.",
|
|
22
22
|
),
|
|
23
23
|
...sourceRangeProperties({
|
|
24
24
|
start:
|
|
@@ -38,7 +38,7 @@ export const deleteMutationTool: TextMutationToolRegistration<typeof deleteSchem
|
|
|
38
38
|
name: "delete",
|
|
39
39
|
wholeFileOperation: "delete",
|
|
40
40
|
description:
|
|
41
|
-
"Use delete to remove selected text, permanently delete a
|
|
41
|
+
"Use delete to remove selected text, permanently delete a file or directory, unlink a symlink, terminate a terminal or debugger session, or remove a debugger breakpoint.",
|
|
42
42
|
|
|
43
43
|
promptSnippet:
|
|
44
44
|
"Delete files or selected text, terminate terminal or debugger sessions, or remove debugger breakpoints",
|
|
@@ -20,10 +20,12 @@ import type { TextChange } from "#src/core/text-change-engine.js";
|
|
|
20
20
|
export const moveSchema = Type.Object(
|
|
21
21
|
{
|
|
22
22
|
path: resultSourceProperty(
|
|
23
|
-
"
|
|
23
|
+
"Filesystem source path, unchanged source result or its UUID; omit start/end for result inputs. Use ordinary paths without selectors to move whole files, directory trees, or symlink objects without following their targets. 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
|
-
...targetProperties(
|
|
26
|
+
...targetProperties(
|
|
27
|
+
"Directory Move replaces the exact target directory, removing destination-only entries.",
|
|
28
|
+
),
|
|
27
29
|
},
|
|
28
30
|
{ additionalProperties: false },
|
|
29
31
|
);
|
|
@@ -40,9 +42,9 @@ export const moveMutationTool: TextMutationToolRegistration<typeof moveSchema> =
|
|
|
40
42
|
name: "move",
|
|
41
43
|
wholeFileOperation: "move",
|
|
42
44
|
description:
|
|
43
|
-
"Use move to move or rename
|
|
45
|
+
"Use move to move or rename a file, directory tree, or symlink object, or to relocate selected text within or between files.",
|
|
44
46
|
|
|
45
|
-
promptSnippet: "Move
|
|
47
|
+
promptSnippet: "Move filesystem objects or selected text",
|
|
46
48
|
parameters: moveSchema,
|
|
47
49
|
source: { field: "path", inherited: true, targets: [{ field: "target", fallbackTo: "path" }] },
|
|
48
50
|
anchors: [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-ast",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -31,17 +31,17 @@
|
|
|
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.7.
|
|
35
|
-
"pi-agent-documentation": "0.7.
|
|
36
|
-
"pi-agent-invariant": "0.7.
|
|
37
|
-
"pi-agent-read": "0.7.
|
|
38
|
-
"pi-agent-resource": "0.7.
|
|
39
|
-
"pi-agent-search": "0.7.
|
|
40
|
-
"pi-agent-search-text": "0.7.
|
|
41
|
-
"pi-agent-text": "0.7.
|
|
42
|
-
"pi-agent-text-editor": "0.7.
|
|
43
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
44
|
-
"pi-agent-tool-ui": "0.7.
|
|
34
|
+
"pi-agent-doctor": "0.7.3",
|
|
35
|
+
"pi-agent-documentation": "0.7.3",
|
|
36
|
+
"pi-agent-invariant": "0.7.3",
|
|
37
|
+
"pi-agent-read": "0.7.3",
|
|
38
|
+
"pi-agent-resource": "0.7.3",
|
|
39
|
+
"pi-agent-search": "0.7.3",
|
|
40
|
+
"pi-agent-search-text": "0.7.3",
|
|
41
|
+
"pi-agent-text": "0.7.3",
|
|
42
|
+
"pi-agent-text-editor": "0.7.3",
|
|
43
|
+
"pi-agent-tool-call-interception": "0.7.3",
|
|
44
|
+
"pi-agent-tool-ui": "0.7.3",
|
|
45
45
|
"tree-sitter-cpp": "^0.23.4",
|
|
46
46
|
"tree-sitter-javascript": "^0.25.0",
|
|
47
47
|
"tree-sitter-json": "^0.24.8",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@earendil-works/pi-coding-agent": "*",
|
|
60
60
|
"@earendil-works/pi-tui": "*",
|
|
61
|
-
"pi-agent-ide": "0.7.
|
|
61
|
+
"pi-agent-ide": "0.7.3",
|
|
62
62
|
"typebox": "*"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
@@ -52,7 +52,9 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
|
|
|
52
52
|
stage: "post-read",
|
|
53
53
|
async handler(context) {
|
|
54
54
|
const result = await overflow(context);
|
|
55
|
-
return result.kind === "return"
|
|
55
|
+
return result.kind === "return" || result.transform !== undefined
|
|
56
|
+
? result
|
|
57
|
+
: scopes(result.context);
|
|
56
58
|
},
|
|
57
59
|
});
|
|
58
60
|
api.describe({
|
|
@@ -52,7 +52,7 @@ export const reduceAstReadOutput: ReadOutputReducer = async (result, context, bu
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
/**
|
|
55
|
+
/** Present an overflowing read window as an outline without losing its source data. */
|
|
56
56
|
export function createAstOverflowHandler(): ReadPostReadHandler {
|
|
57
57
|
return async (context) => {
|
|
58
58
|
const { state, result } = context;
|
|
@@ -83,6 +83,11 @@ export function createAstOverflowHandler(): ReadPostReadHandler {
|
|
|
83
83
|
);
|
|
84
84
|
return reduced === undefined
|
|
85
85
|
? { kind: "continue", context }
|
|
86
|
-
: {
|
|
86
|
+
: {
|
|
87
|
+
kind: "continue",
|
|
88
|
+
context,
|
|
89
|
+
// Keep canonical data added by other post-read transforms, including source targets.
|
|
90
|
+
transform: (result) => ({ ...reduced, script: result.script }),
|
|
91
|
+
};
|
|
87
92
|
};
|
|
88
93
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
|
-
"pi-agent-doctor": "0.7.
|
|
17
|
-
"pi-agent-documentation": "0.7.
|
|
18
|
-
"pi-agent-invariant": "0.7.
|
|
19
|
-
"pi-agent-read": "0.7.
|
|
20
|
-
"pi-agent-resource": "0.7.
|
|
21
|
-
"pi-agent-text": "0.7.
|
|
22
|
-
"pi-agent-text-editor": "0.7.
|
|
16
|
+
"pi-agent-doctor": "0.7.3",
|
|
17
|
+
"pi-agent-documentation": "0.7.3",
|
|
18
|
+
"pi-agent-invariant": "0.7.3",
|
|
19
|
+
"pi-agent-read": "0.7.3",
|
|
20
|
+
"pi-agent-resource": "0.7.3",
|
|
21
|
+
"pi-agent-text": "0.7.3",
|
|
22
|
+
"pi-agent-text-editor": "0.7.3"
|
|
23
23
|
},
|
|
24
24
|
"pi": {
|
|
25
25
|
"extensions": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@earendil-works/pi-coding-agent": "*",
|
|
31
|
+
"@earendil-works/pi-tui": "*",
|
|
31
32
|
"typebox": "*"
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type ExtensionAPI,
|
|
9
9
|
withFileMutationQueue,
|
|
10
10
|
} from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
11
12
|
import { Type, type Static } from "typebox";
|
|
12
13
|
import { resultError, structuredResultSchema, withStructuredResult } from "pi-agent-resource";
|
|
13
14
|
const indexDataSchema = Type.Object(
|
|
@@ -127,6 +128,21 @@ export function createIndexChangeTool(
|
|
|
127
128
|
: "Use unstage to remove one selected Git change from the index. Worktree content is kept.",
|
|
128
129
|
parameters,
|
|
129
130
|
outputSchema: indexOutputSchema,
|
|
131
|
+
// The full IDE removes private result metadata before calling this renderer.
|
|
132
|
+
...(action === "stage" && {
|
|
133
|
+
renderResult(result, _options, theme) {
|
|
134
|
+
return new Text(
|
|
135
|
+
theme.fg(
|
|
136
|
+
"toolOutput",
|
|
137
|
+
result.content
|
|
138
|
+
.flatMap((block) => (block.type === "text" ? [block.text] : []))
|
|
139
|
+
.join("\n"),
|
|
140
|
+
),
|
|
141
|
+
0,
|
|
142
|
+
0,
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
130
146
|
async execute(_toolCallId, parameters, signal, _onUpdate, context) {
|
|
131
147
|
try {
|
|
132
148
|
const result = await execute(parameters, signal, context);
|