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,6 +1,8 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { statSync } from "node:fs";
|
|
2
3
|
import { readFile } from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
4
6
|
import { Type } from "typebox";
|
|
5
7
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
6
8
|
|
|
@@ -24,12 +26,8 @@ export interface ResolvedResultTargets {
|
|
|
24
26
|
readonly complete: boolean;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
/**
|
|
28
|
-
export const resultInputSchema = Type.Union([
|
|
29
|
-
Type.String(),
|
|
30
|
-
Type.Object({}, { additionalProperties: true }),
|
|
31
|
-
Type.Array(Type.Unknown()),
|
|
32
|
-
]);
|
|
29
|
+
/** Public source inputs are paths, unchanged text results, issued IDs or arrays of those strings. */
|
|
30
|
+
export const resultInputSchema = Type.Union([Type.String(), Type.Array(Type.String())]);
|
|
33
31
|
|
|
34
32
|
const prefix = "RESULT#";
|
|
35
33
|
const event = "pi-agent-resource:result-targets";
|
|
@@ -43,14 +41,27 @@ type ResultEntry = { readonly cwd: string } & (
|
|
|
43
41
|
/** Stores immutable source selections for one extension runtime, isolated by worktree. */
|
|
44
42
|
export class ResultTargetStore {
|
|
45
43
|
readonly #entries = new Map<string, ResultEntry>();
|
|
44
|
+
readonly #matchReferences = new Map<string, string>();
|
|
45
|
+
readonly #snapshots = new Map<
|
|
46
|
+
string,
|
|
47
|
+
{ source: string; cwd: string; stamp: string | undefined }
|
|
48
|
+
>();
|
|
49
|
+
readonly #results = new Map<
|
|
50
|
+
string,
|
|
51
|
+
{ cwd: string; digest: string; consumable: boolean; references: string[]; resources: string[] }
|
|
52
|
+
>();
|
|
46
53
|
|
|
47
54
|
/** Forget results when the session closes or the extensions reload. */
|
|
48
55
|
public clear(): void {
|
|
49
56
|
this.#entries.clear();
|
|
57
|
+
this.#matchReferences.clear();
|
|
58
|
+
this.#snapshots.clear();
|
|
59
|
+
this.#results.clear();
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
/** Register trusted resolver data, not a live Resource or agent-supplied coordinates. */
|
|
53
63
|
public register(targets: readonly ResultSourceTarget[], cwd: string, complete = true): string {
|
|
64
|
+
for (const target of targets) this.refresh(target.source, cwd);
|
|
54
65
|
const reference = `${prefix}${randomUUID()}`;
|
|
55
66
|
this.#entries.set(reference, {
|
|
56
67
|
state: "ready",
|
|
@@ -73,6 +84,7 @@ export class ResultTargetStore {
|
|
|
73
84
|
const entry = this.#entries.get(reference);
|
|
74
85
|
if (entry?.state !== "pending" || entry.cwd !== path.resolve(cwd))
|
|
75
86
|
throw new Error("Only a pending result in this worktree can be confirmed.");
|
|
87
|
+
for (const target of targets) this.refresh(target.source, cwd);
|
|
76
88
|
this.#entries.set(reference, {
|
|
77
89
|
state: "ready",
|
|
78
90
|
cwd: entry.cwd,
|
|
@@ -90,6 +102,7 @@ export class ResultTargetStore {
|
|
|
90
102
|
|
|
91
103
|
/** Traverse supported result shapes and resolve only registered source targets. */
|
|
92
104
|
public resolve(input: unknown, cwd: string): ResolvedResultTargets {
|
|
105
|
+
input = this.source(input, cwd);
|
|
93
106
|
const references = this.#references(input);
|
|
94
107
|
const targets: ResultSourceTarget[] = [];
|
|
95
108
|
let complete = true;
|
|
@@ -102,6 +115,9 @@ export class ResultTargetStore {
|
|
|
102
115
|
if (entry.state === "pending")
|
|
103
116
|
throw new Error("Result target is pending; its write has not been confirmed.");
|
|
104
117
|
if (entry.state === "rejected") throw new Error(entry.reason);
|
|
118
|
+
for (const target of entry.targets) this.refresh(target.source, cwd);
|
|
119
|
+
if (!this.#entries.has(reference))
|
|
120
|
+
throw new Error("Result target expired after its snapshot changed; repeat Read/Search.");
|
|
105
121
|
complete &&= entry.complete;
|
|
106
122
|
targets.push(...entry.targets);
|
|
107
123
|
}
|
|
@@ -113,7 +129,7 @@ export class ResultTargetStore {
|
|
|
113
129
|
const resolved = this.resolve(input, cwd);
|
|
114
130
|
const targets: ResultSourceTarget[] = [];
|
|
115
131
|
const seen = new Set<string>();
|
|
116
|
-
for (const reference of new Set(this.#references(input))) {
|
|
132
|
+
for (const reference of new Set(this.#references(this.source(input, cwd)))) {
|
|
117
133
|
for (const target of this.resolve(reference, cwd).targets) {
|
|
118
134
|
for (const range of target.ranges) {
|
|
119
135
|
const identity = JSON.stringify([target.source, range]);
|
|
@@ -128,9 +144,148 @@ export class ResultTargetStore {
|
|
|
128
144
|
|
|
129
145
|
/** Reject changed source bytes before a consumer uses a retained selection. */
|
|
130
146
|
public async verify(result: ResolvedResultTargets, signal?: AbortSignal): Promise<void> {
|
|
131
|
-
|
|
147
|
+
try {
|
|
148
|
+
await verifyResultTargets(result, signal);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (!signal?.aborted) for (const target of result.targets) this.invalidate(target.source);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Register readable output without exposing the stored tool data to the agent. */
|
|
156
|
+
public publish(outcome: unknown, text: string, cwd: string, resources: string[] = []): string {
|
|
157
|
+
const id = randomUUID();
|
|
158
|
+
for (const source of resources) this.refresh(source, cwd);
|
|
159
|
+
let references: string[] = [];
|
|
160
|
+
try {
|
|
161
|
+
references = this.#references(outcome);
|
|
162
|
+
} catch {
|
|
163
|
+
/* Not every result grants a text selection. */
|
|
164
|
+
}
|
|
165
|
+
const shown = `<system-result note="Internal reference; not part of the file. Do not edit."><uuid>${id}</uuid></system-result>\n${text}`;
|
|
166
|
+
const consumable =
|
|
167
|
+
outcome !== null &&
|
|
168
|
+
typeof outcome === "object" &&
|
|
169
|
+
"status" in outcome &&
|
|
170
|
+
outcome.status === "success";
|
|
171
|
+
if (consumable && "data" in outcome) {
|
|
172
|
+
const data = outcome.data;
|
|
173
|
+
if (
|
|
174
|
+
data !== null &&
|
|
175
|
+
typeof data === "object" &&
|
|
176
|
+
"matches" in data &&
|
|
177
|
+
Array.isArray(data.matches)
|
|
178
|
+
) {
|
|
179
|
+
const matches: unknown[] = data.matches;
|
|
180
|
+
for (const match of matches) {
|
|
181
|
+
if (
|
|
182
|
+
match === null ||
|
|
183
|
+
typeof match !== "object" ||
|
|
184
|
+
!("target" in match) ||
|
|
185
|
+
typeof match.target !== "string" ||
|
|
186
|
+
!this.#entries.has(match.target) ||
|
|
187
|
+
!("references" in match)
|
|
188
|
+
)
|
|
189
|
+
continue;
|
|
190
|
+
const references = match.references;
|
|
191
|
+
if (
|
|
192
|
+
references !== null &&
|
|
193
|
+
typeof references === "object" &&
|
|
194
|
+
"match" in references &&
|
|
195
|
+
typeof references.match === "string" &&
|
|
196
|
+
/^SEARCH#[A-F\d]+:\d+:match$/u.test(references.match)
|
|
197
|
+
)
|
|
198
|
+
this.#matchReferences.set(references.match, match.target);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
this.#results.set(id, {
|
|
203
|
+
cwd: path.resolve(cwd),
|
|
204
|
+
digest: createHash("sha256").update(shown).digest("hex"),
|
|
205
|
+
consumable,
|
|
206
|
+
references,
|
|
207
|
+
resources,
|
|
208
|
+
});
|
|
209
|
+
return shown;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Resolve only issued result strings or IDs. Preview text never defines source authority. */
|
|
213
|
+
public source(input: unknown, cwd: string, allowResource: boolean | "live" = false): unknown {
|
|
214
|
+
if (Array.isArray(input)) return input.map((item) => this.source(item, cwd, allowResource));
|
|
215
|
+
if (typeof input !== "string") return input;
|
|
216
|
+
const matchTarget = this.#matchReferences.get(input);
|
|
217
|
+
if (matchTarget) return this.source(matchTarget, cwd, allowResource);
|
|
218
|
+
const envelope =
|
|
219
|
+
/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid><\/system-result>(?:\n|$)/u.exec(input);
|
|
220
|
+
const id = envelope?.[1] ?? (input.startsWith(prefix) ? input.slice(prefix.length) : input);
|
|
221
|
+
const isId = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u.test(id);
|
|
222
|
+
if (!envelope && !isId) {
|
|
223
|
+
if (input.startsWith("<system-result")) throw new Error("Invalid system result reference.");
|
|
224
|
+
return input;
|
|
225
|
+
}
|
|
226
|
+
const result = this.#results.get(id);
|
|
227
|
+
// Existing backend selection handles share RESULT# syntax, but never accept an unknown UUID.
|
|
228
|
+
if (!result && !envelope && input.startsWith(prefix) && this.#entries.has(input)) return input;
|
|
229
|
+
if (!result) throw new Error("Result reference expired or unknown; repeat the source tool.");
|
|
230
|
+
if (result.cwd !== path.resolve(cwd)) throw new Error("Result belongs to another worktree.");
|
|
231
|
+
if (envelope && createHash("sha256").update(input).digest("hex") !== result.digest)
|
|
232
|
+
throw new Error("Result text changed; pass the original result or its UUID.");
|
|
233
|
+
for (const resource of result.resources) this.refresh(resource, cwd);
|
|
234
|
+
if (!this.#results.has(id))
|
|
235
|
+
throw new Error("Result reference expired; repeat the source tool.");
|
|
236
|
+
if (!result.consumable) throw new Error("Only successful source results can be consumed.");
|
|
237
|
+
for (const reference of result.references) {
|
|
238
|
+
if (!this.#entries.has(reference)) {
|
|
239
|
+
this.#results.delete(id);
|
|
240
|
+
throw new Error("Result reference expired; repeat the source tool.");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (result.references.length === 1) return result.references[0];
|
|
244
|
+
if (result.references.length > 1) return result.references;
|
|
245
|
+
const resource = result.resources.length === 1 ? result.resources[0] : undefined;
|
|
246
|
+
if (
|
|
247
|
+
resource &&
|
|
248
|
+
(allowResource === true || (allowResource === "live" && /^(?:shell|debug):/u.test(resource)))
|
|
249
|
+
)
|
|
250
|
+
return resource;
|
|
251
|
+
throw new Error("This result has no reusable text selection.");
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Permanently retire every ready selection of a changed file, including derived results. */
|
|
255
|
+
public invalidate(source: string): void {
|
|
256
|
+
const removed = new Set<string>();
|
|
257
|
+
for (const [reference, entry] of this.#entries) {
|
|
258
|
+
if (
|
|
259
|
+
entry.state === "ready" &&
|
|
260
|
+
entry.targets.some((target) => sourcePath(target.source, entry.cwd) === source)
|
|
261
|
+
) {
|
|
262
|
+
this.#entries.delete(reference);
|
|
263
|
+
removed.add(reference);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const [id, result] of this.#results)
|
|
267
|
+
if (
|
|
268
|
+
result.resources.some((resource) => sourcePath(resource, result.cwd) === source) ||
|
|
269
|
+
result.references.some((reference) => removed.has(reference))
|
|
270
|
+
)
|
|
271
|
+
this.#results.delete(id);
|
|
132
272
|
}
|
|
133
273
|
|
|
274
|
+
/** Detect filesystem generations, so restoring old bytes never revives an old reference. */
|
|
275
|
+
public refresh(source: string, cwd: string): void {
|
|
276
|
+
const identity = sourcePath(source, cwd);
|
|
277
|
+
const key = JSON.stringify([path.resolve(cwd), identity]);
|
|
278
|
+
const stamp = fileStamp(source, cwd);
|
|
279
|
+
const previous = this.#snapshots.get(key);
|
|
280
|
+
if (previous && previous.stamp !== stamp) this.invalidate(identity);
|
|
281
|
+
this.#snapshots.set(key, { source, cwd, stamp });
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Check surviving snapshots at a script boundary, including final formatting. */
|
|
285
|
+
public refreshAll(): void {
|
|
286
|
+
for (const snapshot of [...this.#snapshots.values()])
|
|
287
|
+
this.refresh(snapshot.source, snapshot.cwd);
|
|
288
|
+
}
|
|
134
289
|
#references(input: unknown): string[] {
|
|
135
290
|
if (typeof input === "string" && input.startsWith(prefix)) return [input];
|
|
136
291
|
if (Array.isArray(input)) return input.flatMap((child) => this.#references(child));
|
|
@@ -150,6 +305,25 @@ export class ResultTargetStore {
|
|
|
150
305
|
}
|
|
151
306
|
}
|
|
152
307
|
|
|
308
|
+
function sourcePath(source: string, cwd: string): string {
|
|
309
|
+
const file = source.startsWith("raw:") ? source.slice(4) : source;
|
|
310
|
+
if (file.startsWith("file:")) {
|
|
311
|
+
try {
|
|
312
|
+
return fileURLToPath(file);
|
|
313
|
+
} catch {
|
|
314
|
+
/* Unresolved protocol labels have no filesystem stamp. */
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return path.resolve(cwd, file);
|
|
318
|
+
}
|
|
319
|
+
function fileStamp(source: string, cwd: string): string | undefined {
|
|
320
|
+
try {
|
|
321
|
+
const stat = statSync(sourcePath(source, cwd), { bigint: true });
|
|
322
|
+
return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
323
|
+
} catch {
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
153
327
|
/** Verify retained source snapshots for tools and provider refresh operations. */
|
|
154
328
|
export async function verifyResultTargets(
|
|
155
329
|
result: ResolvedResultTargets,
|
|
@@ -25,7 +25,7 @@ export const resultErrorSchema = Type.Object(
|
|
|
25
25
|
|
|
26
26
|
/** Build the common result contract around one tool's data schema. */
|
|
27
27
|
export function structuredResultSchema(data: TSchema) {
|
|
28
|
-
|
|
28
|
+
const outcomes = Type.Union([
|
|
29
29
|
Type.Object(
|
|
30
30
|
{
|
|
31
31
|
status: Type.Literal("success"),
|
|
@@ -43,6 +43,18 @@ export function structuredResultSchema(data: TSchema) {
|
|
|
43
43
|
{ additionalProperties: false },
|
|
44
44
|
),
|
|
45
45
|
]);
|
|
46
|
+
// Expose the common object fields without weakening outcome-specific validation.
|
|
47
|
+
return {
|
|
48
|
+
...outcomes,
|
|
49
|
+
type: "object" as const,
|
|
50
|
+
properties: {
|
|
51
|
+
status: Type.Union([Type.Literal("success"), Type.Literal("error"), Type.Literal("partial")]),
|
|
52
|
+
data: Type.Optional(data),
|
|
53
|
+
errors: Type.Array(resultErrorSchema),
|
|
54
|
+
},
|
|
55
|
+
required: ["status", "errors"],
|
|
56
|
+
additionalProperties: false,
|
|
57
|
+
};
|
|
46
58
|
}
|
|
47
59
|
/** Maximum serialized public data; callers expose a smaller window or a full-result resource. */
|
|
48
60
|
export const MAX_STRUCTURED_BYTES = 1024 * 1024;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"pi-agent-documentation": "0.7.
|
|
24
|
-
"pi-agent-resource": "0.7.
|
|
25
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
26
|
-
"pi-agent-tool-ui": "0.7.
|
|
23
|
+
"pi-agent-documentation": "0.7.1",
|
|
24
|
+
"pi-agent-resource": "0.7.1",
|
|
25
|
+
"pi-agent-tool-call-interception": "0.7.1",
|
|
26
|
+
"pi-agent-tool-ui": "0.7.1"
|
|
27
27
|
},
|
|
28
28
|
"pi": {
|
|
29
29
|
"extensions": [
|
|
@@ -12,7 +12,7 @@ export const searchSchema = Type.Object(
|
|
|
12
12
|
path: Type.Optional({
|
|
13
13
|
...resultInputSchema,
|
|
14
14
|
description:
|
|
15
|
-
"File, directory, URL,
|
|
15
|
+
"File, directory, URL, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Results select only their registered ranges unless symbols: navigation follows external references.",
|
|
16
16
|
}),
|
|
17
17
|
navigation: Type.Optional(
|
|
18
18
|
Type.Literal("references", {
|
|
@@ -108,7 +108,7 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
|
|
|
108
108
|
api.describe(
|
|
109
109
|
[
|
|
110
110
|
"Local queries try literal terms first, then unquoted terms as regex when no literal results exist, then separate words for ordinary multi-word queries. Quoted terms stay literal. Boolean conditions stay intact across fallback. Uppercase AND/OR, infix NOT, ||, and space-separated | are Boolean operators; unspaced | and regex groups/classes belong to regex terms. Parentheses containing Boolean operators group Boolean conditions. regex:<pattern> forces regex-only matching; files:<pattern> searches file paths: glob patterns use *, **, ?, character classes and braces; other queries use case-insensitive subsequence matching. Slash-containing globs match cwd-relative paths; basename globs match at any depth.",
|
|
111
|
-
"After a complete zero result, a single unquoted ASCII identifier may produce separate possible-name groups: naming-style changes, one leading/trailing component, then small typos. Each group reports a verified case-sensitive whole-identifier alternative in the same scope, its count/completeness, and Read references. Budget skips are explicit. A candidate all-reference refreshes that exact alternative, not the fuzzy ranking. Registered local candidate selections also expose strict snapshot targets.
|
|
111
|
+
"After a complete zero result, a single unquoted ASCII identifier may produce separate possible-name groups: naming-style changes, one leading/trailing component, then small typos. Each group reports a verified case-sensitive whole-identifier alternative in the same scope, its count/completeness, and Read references. Budget skips are explicit. A candidate all-reference refreshes that exact alternative, not the fuzzy ranking. Registered local candidate selections also expose strict snapshot targets. Result scopes stay exact and do not run this extra branch.",
|
|
112
112
|
"The result says when a query was broadened. Empty or unknown prefixes are searched as plain text. A recognized prefixed query returns its own results or error; it does not silently become a text search.",
|
|
113
113
|
"SEARCH#HASH:N:line selects one containing line; :match selects its exact match. :all:line selects all unique containing lines and :all:match selects all matches. Read returns containing lines for both forms. A SEARCH resource can be used as a read path or mutation path/anchor; omit the file path for an all-selection spanning files.",
|
|
114
114
|
"Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Search compacts noisy files when the detail limit is exceeded; narrow the query to that file to see individual matches. Compaction does not remove complete :all selections.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search-text",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-doctor": "0.7.
|
|
28
|
-
"pi-agent-invariant": "0.7.
|
|
29
|
-
"pi-agent-search": "0.7.
|
|
30
|
-
"pi-agent-text": "0.7.
|
|
31
|
-
"pi-agent-text-editor": "0.7.
|
|
32
|
-
"pi-agent-tool-ui": "0.7.
|
|
27
|
+
"pi-agent-doctor": "0.7.1",
|
|
28
|
+
"pi-agent-invariant": "0.7.1",
|
|
29
|
+
"pi-agent-search": "0.7.1",
|
|
30
|
+
"pi-agent-text": "0.7.1",
|
|
31
|
+
"pi-agent-text-editor": "0.7.1",
|
|
32
|
+
"pi-agent-tool-ui": "0.7.1"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./src/index.ts",
|
|
6
6
|
"imports": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"pi-agent-resource": "0.7.
|
|
16
|
+
"pi-agent-resource": "0.7.1"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"typebox": "*"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-constant",
|
|
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
|
-
"pi-agent-text": "0.7.
|
|
10
|
-
"pi-agent-text-editor": "0.7.
|
|
9
|
+
"pi-agent-text": "0.7.1",
|
|
10
|
+
"pi-agent-text-editor": "0.7.1"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -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": [
|
|
@@ -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 = {
|
|
@@ -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": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"fs-extra": "^11.4.0",
|
|
80
80
|
"oxfmt": "0.64.0",
|
|
81
81
|
"partial-json": "^0.1.7",
|
|
82
|
-
"pi-agent-documentation": "0.7.
|
|
83
|
-
"pi-agent-invariant": "0.7.
|
|
84
|
-
"pi-agent-read": "0.7.
|
|
85
|
-
"pi-agent-resource": "0.7.
|
|
86
|
-
"pi-agent-search": "0.7.
|
|
87
|
-
"pi-agent-text": "0.7.
|
|
88
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
89
|
-
"pi-agent-tool-ui": "0.7.
|
|
82
|
+
"pi-agent-documentation": "0.7.1",
|
|
83
|
+
"pi-agent-invariant": "0.7.1",
|
|
84
|
+
"pi-agent-read": "0.7.1",
|
|
85
|
+
"pi-agent-resource": "0.7.1",
|
|
86
|
+
"pi-agent-search": "0.7.1",
|
|
87
|
+
"pi-agent-text": "0.7.1",
|
|
88
|
+
"pi-agent-tool-call-interception": "0.7.1",
|
|
89
|
+
"pi-agent-tool-ui": "0.7.1",
|
|
90
90
|
"typebox-guard": "npm:typebox@^1.1.38"
|
|
91
91
|
},
|
|
92
92
|
"pi": {
|
|
@@ -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) => {
|