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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import { connectTextEditorPlugin } from "pi-agent-text-editor/api/connect-plugin";
|
|
2
3
|
import {
|
|
3
4
|
TEXT_EDITOR_API_VERSION,
|
|
@@ -5,22 +6,83 @@ import {
|
|
|
5
6
|
TEXT_SEARCH_ANCHOR_KIND,
|
|
6
7
|
type TextEditorPlugin,
|
|
7
8
|
} from "pi-agent-text-editor/api/plugin-protocol";
|
|
8
|
-
|
|
9
9
|
import { createExactTextAnchorResolver } from "./src/anchor.js";
|
|
10
10
|
import { parseExactTextRecoveryConfig } from "./src/config.js";
|
|
11
|
-
|
|
12
11
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
interface RecoveryDetails {
|
|
14
|
+
metadata?: { exactTextFailures?: string[] };
|
|
15
|
+
source?: string;
|
|
16
|
+
nativeEditBatch?: { state: string };
|
|
17
|
+
results?: { data?: { ok?: boolean; path?: string } }[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Recognize issued source/anchor syntax only after its tool has validated it. */
|
|
21
|
+
function usesRegisteredSelector(input: Record<string, unknown>): boolean {
|
|
22
|
+
return [
|
|
23
|
+
"path",
|
|
24
|
+
"file",
|
|
25
|
+
"target",
|
|
26
|
+
"start",
|
|
27
|
+
"end",
|
|
28
|
+
"anchor",
|
|
29
|
+
"targetStart",
|
|
30
|
+
"targetEnd",
|
|
31
|
+
"change",
|
|
32
|
+
].some((field) => {
|
|
33
|
+
const value = input[field];
|
|
34
|
+
const values: unknown[] = Array.isArray(value) ? value : [value];
|
|
35
|
+
return values.some(
|
|
36
|
+
(value: unknown) =>
|
|
37
|
+
typeof value === "string" &&
|
|
38
|
+
/^(?:RESULT#|SEARCH#|CHANGE#|scope-(?:begin|end)-|\d+#[a-f\d]+$|begin$|end$|<system-result)/iu.test(
|
|
39
|
+
value,
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Register exact text and require an issued selector after an explicit-text failure. */
|
|
15
46
|
export default async function registerExactTextAnchor(pi: ExtensionAPI): Promise<void> {
|
|
47
|
+
const blocked = new Set<string>();
|
|
48
|
+
const pendingRecovery = new Set<string>();
|
|
49
|
+
const key = (source: string, cwd: string) => path.resolve(cwd, source);
|
|
50
|
+
const clear = () => {
|
|
51
|
+
blocked.clear();
|
|
52
|
+
pendingRecovery.clear();
|
|
53
|
+
};
|
|
54
|
+
pi.on("session_start", clear);
|
|
55
|
+
pi.on("session_shutdown", clear);
|
|
56
|
+
pi.on("agent_end", () => pendingRecovery.clear());
|
|
57
|
+
pi.on("tool_result", (event, context) => {
|
|
58
|
+
const details = event.details as RecoveryDetails | undefined;
|
|
59
|
+
for (const source of details?.metadata?.exactTextFailures ?? []) {
|
|
60
|
+
blocked.add(key(source, context.cwd));
|
|
61
|
+
pendingRecovery.delete(key(source, context.cwd));
|
|
62
|
+
}
|
|
63
|
+
if (event.isError || !usesRegisteredSelector(event.input)) return;
|
|
64
|
+
if (details?.nativeEditBatch?.state === "accepted" && details.source) {
|
|
65
|
+
const source = key(details.source, context.cwd);
|
|
66
|
+
if (blocked.has(source)) pendingRecovery.add(source);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
for (const result of details?.results ?? []) {
|
|
70
|
+
if (result.data?.ok && result.data.path) blocked.delete(key(result.data.path, context.cwd));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
16
73
|
const plugin = {
|
|
17
74
|
protocol: TEXT_EDITOR_PROTOCOL,
|
|
18
75
|
apiVersion: TEXT_EDITOR_API_VERSION,
|
|
19
76
|
id: "text-anchor-exact",
|
|
20
77
|
setup(api) {
|
|
78
|
+
api.onDidEdit((completion) => {
|
|
79
|
+
const source = key(completion.resourceSource, completion.cwd);
|
|
80
|
+
if (pendingRecovery.delete(source)) blocked.delete(source);
|
|
81
|
+
});
|
|
21
82
|
api.addAnchorResolver({
|
|
22
83
|
resolver: createExactTextAnchorResolver(
|
|
23
84
|
parseExactTextRecoveryConfig(api.recoveryConfig("exactText")),
|
|
85
|
+
(source, cwd) => blocked.has(key(source, cwd)),
|
|
24
86
|
),
|
|
25
87
|
kind: TEXT_SEARCH_ANCHOR_KIND,
|
|
26
88
|
type: "auxiliary",
|
|
@@ -29,6 +91,5 @@ export default async function registerExactTextAnchor(pi: ExtensionAPI): Promise
|
|
|
29
91
|
});
|
|
30
92
|
},
|
|
31
93
|
} satisfies TextEditorPlugin;
|
|
32
|
-
|
|
33
94
|
await connectTextEditorPlugin(pi, plugin);
|
|
34
95
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-exact",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.
|
|
17
|
-
"pi-agent-text-editor": "0.7.
|
|
16
|
+
"pi-agent-text": "0.7.1",
|
|
17
|
+
"pi-agent-text-editor": "0.7.1"
|
|
18
18
|
},
|
|
19
19
|
"pi": {
|
|
20
20
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts
CHANGED
|
@@ -18,7 +18,10 @@ interface NormalizedText {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** Creates the catch-all resolver for unique exact text spans. */
|
|
21
|
-
export function createExactTextAnchorResolver(
|
|
21
|
+
export function createExactTextAnchorResolver(
|
|
22
|
+
config: ExactTextRecoveryConfig,
|
|
23
|
+
requiresAnchor: (source: string, cwd: string) => boolean = () => false,
|
|
24
|
+
): TextAnchorResolver {
|
|
22
25
|
return {
|
|
23
26
|
id: "exact-text",
|
|
24
27
|
description:
|
|
@@ -30,7 +33,14 @@ export function createExactTextAnchorResolver(config: ExactTextRecoveryConfig):
|
|
|
30
33
|
return "selected text";
|
|
31
34
|
},
|
|
32
35
|
tryResolve(value, context) {
|
|
33
|
-
return Promise.resolve(
|
|
36
|
+
return Promise.resolve(
|
|
37
|
+
requiresAnchor(context.source, context.cwd)
|
|
38
|
+
? rejected(
|
|
39
|
+
"invalid",
|
|
40
|
+
"Exact-text editing is blocked for this file; use a current returned anchor for the next edit.",
|
|
41
|
+
)
|
|
42
|
+
: resolveExactTextAnchor(value, context),
|
|
43
|
+
);
|
|
34
44
|
},
|
|
35
45
|
recover(value, context) {
|
|
36
46
|
return recoverExactText(value, context, config);
|
|
@@ -25,9 +25,10 @@ export default async function registerLineHashTextAnchor(pi: ExtensionAPI): Prom
|
|
|
25
25
|
id: "text-anchor-line-hash",
|
|
26
26
|
setup(api) {
|
|
27
27
|
api.addView({ view: "anchors", presenter });
|
|
28
|
-
api.describe(
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
api.describe({
|
|
29
|
+
views:
|
|
30
|
+
"anchors — annotate text with returned line references in the form LINE#HASH, e.g. 12#A4F0 (line number 12 and its content hash). These references select source lines in edits or path#anchor reads; display annotations are not file content.",
|
|
31
|
+
});
|
|
31
32
|
},
|
|
32
33
|
} satisfies ReadPlugin;
|
|
33
34
|
const editorPlugin = {
|
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.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.
|
|
16
|
-
"pi-agent-read": "0.7.
|
|
17
|
-
"pi-agent-text": "0.7.
|
|
18
|
-
"pi-agent-text-editor": "0.7.
|
|
15
|
+
"pi-agent-invariant": "0.7.1",
|
|
16
|
+
"pi-agent-read": "0.7.1",
|
|
17
|
+
"pi-agent-text": "0.7.1",
|
|
18
|
+
"pi-agent-text-editor": "0.7.1"
|
|
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.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.7.
|
|
11
|
-
"pi-agent-text-editor": "0.7.
|
|
12
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
13
|
-
"pi-agent-tool-ui": "0.7.
|
|
10
|
+
"pi-agent-invariant": "0.7.1",
|
|
11
|
+
"pi-agent-text-editor": "0.7.1",
|
|
12
|
+
"pi-agent-tool-call-interception": "0.7.1",
|
|
13
|
+
"pi-agent-tool-ui": "0.7.1",
|
|
14
14
|
"vscode-diff": "3.0.1"
|
|
15
15
|
},
|
|
16
16
|
"pi": {
|
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.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.7.
|
|
7
|
-
"pi-agent-read": "0.7.
|
|
8
|
-
"pi-agent-text-editor": "0.7.
|
|
6
|
+
"pi-agent-invariant": "0.7.1",
|
|
7
|
+
"pi-agent-read": "0.7.1",
|
|
8
|
+
"pi-agent-text-editor": "0.7.1"
|
|
9
9
|
},
|
|
10
10
|
"pi": {
|
|
11
11
|
"extensions": [
|
|
@@ -27,7 +27,9 @@ export {
|
|
|
27
27
|
export { type ChangedRange, computeChangedRanges } from "#src/core/mutation-result/diff.js";
|
|
28
28
|
export {
|
|
29
29
|
mutationDataSchema,
|
|
30
|
-
|
|
30
|
+
mutationResultSchema,
|
|
31
|
+
flushDataSchema,
|
|
32
|
+
type FlushData,
|
|
31
33
|
structuredMutation,
|
|
32
34
|
type MutationData,
|
|
33
35
|
} from "#src/core/structured-result.js";
|
|
@@ -63,6 +63,9 @@ export default async function registerTextEditorCore(
|
|
|
63
63
|
);
|
|
64
64
|
});
|
|
65
65
|
setTextEditBatchRenderArgumentSink(core, interceptionRendering.resolveArguments);
|
|
66
|
+
core.onDidEdit((completion) => {
|
|
67
|
+
resultTargets.refresh(completion.resourceSource, completion.cwd);
|
|
68
|
+
});
|
|
66
69
|
await core.registerPlugin({
|
|
67
70
|
protocol: TEXT_EDITOR_PROTOCOL,
|
|
68
71
|
apiVersion: TEXT_EDITOR_API_VERSION,
|
|
@@ -90,9 +93,13 @@ export default async function registerTextEditorCore(
|
|
|
90
93
|
api.addTargetResolver({ resolver: core.textTargetResolver() });
|
|
91
94
|
api.addFragmentResolver(createReadFragmentResolver(core));
|
|
92
95
|
|
|
93
|
-
api.describe(
|
|
94
|
-
"path#anchor — source around a returned line or scope anchor, e.g. notes.txt#12#A4F0. SEARCH# references go directly in path, without a file prefix.
|
|
95
|
-
|
|
96
|
+
api.describe({
|
|
97
|
+
path: "path#anchor — source around a returned line or scope anchor, e.g. notes.txt#12#A4F0. SEARCH# and RESULT# references go directly in path, without a file prefix. Returned Read/Search/Select/mutation targets select their verified source ranges.",
|
|
98
|
+
offset:
|
|
99
|
+
"For path#anchor, SEARCH# or RESULT# selections, count from each containing line: omitted, 0 or 1 starts there; 2 starts one line later; -1 starts one line earlier. Output keeps original line numbers.",
|
|
100
|
+
limit:
|
|
101
|
+
"For source selections, limit caps each selected context window separately. Without limit, each selection supplies its natural line count, with at least one line.",
|
|
102
|
+
});
|
|
96
103
|
},
|
|
97
104
|
});
|
|
98
105
|
setTextAnchorRecoveryReader(core, (request, context) => {
|
|
@@ -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 },
|