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.
Files changed (218) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/chunk-2TRHFMCZ.js +11 -0
  3. package/dist/{chunk-FXNKMNSJ.js → chunk-4GCWGE2C.js} +1 -1
  4. package/dist/chunk-4XMY4H4V.js +1 -0
  5. package/dist/{chunk-3HYXQ4YA.js → chunk-76ZK5ODR.js} +2 -2
  6. package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
  7. package/dist/chunk-CWD4O5PM.js +3 -0
  8. package/dist/chunk-D3WTDA6V.js +2 -0
  9. package/dist/chunk-GXEGY7GV.js +1 -0
  10. package/dist/{chunk-GBLKIB6O.js → chunk-HZEY4GT4.js} +1 -1
  11. package/dist/{chunk-S5LXX32D.js → chunk-LEEQIQ7D.js} +6 -6
  12. package/dist/chunk-NRZO5KJT.js +9 -0
  13. package/dist/chunk-OMVRLWMX.js +5 -0
  14. package/dist/{chunk-KR36BT5E.js → chunk-PGIVHICI.js} +1 -1
  15. package/dist/{chunk-YRF7OATP.js → chunk-PKKDDIWW.js} +1 -1
  16. package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
  17. package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
  18. package/dist/chunk-VMTR74FF.js +2 -0
  19. package/dist/{chunk-PYPPV2F5.js → chunk-WMO6RNE2.js} +1 -1
  20. package/dist/{chunk-3JO7QFIL.js → chunk-WU6ZK6YD.js} +1 -1
  21. package/dist/{chunk-F5YZG77W.js → chunk-XH5WN5XA.js} +1 -1
  22. package/dist/{chunk-AJRIASPQ.js → chunk-YP46DVVP.js} +1 -1
  23. package/dist/entry-11.js +1 -1
  24. package/dist/entry-13.js +1 -1
  25. package/dist/entry-14.js +1 -1
  26. package/dist/entry-15.js +1 -1
  27. package/dist/entry-17.js +1 -1
  28. package/dist/entry-25.js +2 -2
  29. package/dist/entry-26.js +1 -1
  30. package/dist/entry-27.js +2 -2
  31. package/dist/entry-28.js +1 -1
  32. package/dist/entry-29.js +1 -1
  33. package/dist/entry-31.js +13 -12
  34. package/dist/entry-33.js +1 -1
  35. package/dist/entry-37.js +6 -6
  36. package/dist/entry-41.js +1 -1
  37. package/dist/entry-43.js +1 -1
  38. package/dist/entry-44.js +1 -1
  39. package/dist/entry-45.js +13 -14
  40. package/dist/entry-46.js +1 -1
  41. package/dist/entry-49.js +1 -1
  42. package/dist/entry-50.js +1 -1
  43. package/dist/entry-51.js +2 -2
  44. package/dist/entry-53.js +1 -1
  45. package/dist/entry-54.js +1 -1
  46. package/dist/entry-56.js +1 -1
  47. package/dist/entry-57.js +1 -1
  48. package/dist/entry-58.js +1 -1
  49. package/dist/entry-60.js +1 -1
  50. package/dist/entry-62.js +1 -1
  51. package/dist/entry-65.js +1 -1
  52. package/dist/entry-68.js +1 -1
  53. package/dist/entry-70.js +1 -1
  54. package/dist/entry-75.js +1 -1
  55. package/dist/entry-77.js +33 -34
  56. package/dist/entry-78.js +1 -1
  57. package/dist/entry-79.js +1 -1
  58. package/dist/entry-80.js +1 -1
  59. package/dist/entry-82.js +2 -2
  60. package/dist/entry-83.js +1 -1
  61. package/dist/entry-84.js +1 -1
  62. package/dist/entry-85.js +1 -1
  63. package/dist/entry-86.js +1 -1
  64. package/dist/pi-agent-ide.js +14 -9
  65. package/docs/agent-guides/editing.md +35 -46
  66. package/docs/agent-guides/read-resources.md +5 -9
  67. package/docs/agent-guides/search-code.md +12 -17
  68. package/docs/agent-guides/select-code.md +61 -140
  69. package/docs/structured-results.md +27 -62
  70. package/docs/tools.md +6 -10
  71. package/node_modules/pi-agent-doctor/package.json +1 -1
  72. package/node_modules/pi-agent-documentation/package.json +1 -1
  73. package/node_modules/pi-agent-filesystem/index.ts +7 -6
  74. package/node_modules/pi-agent-filesystem/package.json +7 -7
  75. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  76. package/node_modules/pi-agent-filesystem-jq/index.ts +4 -3
  77. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  78. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  79. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  80. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  81. package/node_modules/pi-agent-ide-ast/src/extension.ts +7 -4
  82. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +35 -6
  83. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +1 -1
  84. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +2 -2
  85. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +18 -1
  86. package/node_modules/pi-agent-ide-changes/index.ts +4 -3
  87. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  88. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  89. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  90. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  91. package/node_modules/pi-agent-ide-lsp/index.ts +3 -3
  92. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  93. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
  94. package/node_modules/pi-agent-image/package.json +2 -2
  95. package/node_modules/pi-agent-invariant/package.json +1 -1
  96. package/node_modules/pi-agent-pdf/package.json +2 -2
  97. package/node_modules/pi-agent-read/package.json +7 -7
  98. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  99. package/node_modules/pi-agent-read/src/api/read-parameters.ts +38 -1
  100. package/node_modules/pi-agent-read/src/api/tools/read.ts +7 -1
  101. package/node_modules/pi-agent-read/src/core/extension.ts +7 -1
  102. package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
  103. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
  104. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +9 -2
  105. package/node_modules/pi-agent-resource/package.json +1 -1
  106. package/node_modules/pi-agent-resource/src/result-targets.ts +183 -9
  107. package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
  108. package/node_modules/pi-agent-search/package.json +5 -5
  109. package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
  110. package/node_modules/pi-agent-search-text/index.ts +1 -1
  111. package/node_modules/pi-agent-search-text/package.json +7 -7
  112. package/node_modules/pi-agent-text/package.json +2 -2
  113. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  114. package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
  115. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  116. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
  117. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -3
  118. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  119. package/node_modules/pi-agent-text-editor/package.json +9 -9
  120. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
  121. package/node_modules/pi-agent-text-editor/src/core/extension.ts +10 -3
  122. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +3 -13
  123. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
  124. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +43 -209
  125. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
  126. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
  127. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
  128. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  129. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
  130. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  131. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  132. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  133. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  134. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  135. package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
  136. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  137. package/node_modules/pi-agent-web/index.ts +4 -3
  138. package/node_modules/pi-agent-web/package.json +7 -7
  139. package/node_modules/pi-agent-web-html/package.json +2 -2
  140. package/node_modules/pi-agent-web-image/package.json +3 -3
  141. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  142. package/node_modules/pi-agent-web-text/package.json +3 -3
  143. package/package.json +35 -35
  144. package/src/composite/text-results.ts +221 -0
  145. package/src/documentation/extension.ts +11 -9
  146. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
  147. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  148. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  149. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +4 -3
  150. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  151. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  152. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  153. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +4 -3
  154. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  155. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  156. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  157. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  158. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  159. package/src/extensions/pi-agent-read/package.json +7 -7
  160. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  161. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +38 -1
  162. package/src/extensions/pi-agent-read/src/api/tools/read.ts +7 -1
  163. package/src/extensions/pi-agent-read/src/core/extension.ts +7 -1
  164. package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
  165. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
  166. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +9 -2
  167. package/src/extensions/pi-agent-search/package.json +5 -5
  168. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
  169. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
  170. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
  171. package/src/extensions/pi-agent-text-editor/package.json +9 -9
  172. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  173. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +65 -4
  174. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  175. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
  176. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -3
  177. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  178. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  179. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  180. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
  181. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +10 -3
  182. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +3 -13
  183. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
  184. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +43 -209
  185. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
  186. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
  187. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
  188. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  189. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
  190. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  191. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  192. package/src/pi-agent-ide.ts +4 -1
  193. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  194. package/src/plugins/pi-agent-ide-ast/src/extension.ts +7 -4
  195. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +35 -6
  196. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +1 -1
  197. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +2 -2
  198. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +18 -1
  199. package/src/plugins/pi-agent-ide-changes/index.ts +4 -3
  200. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  201. package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
  202. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
  203. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  204. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  205. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  206. package/src/plugins/pi-agent-ide-lsp/index.ts +3 -3
  207. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  208. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
  209. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
  210. package/src/plugins/pi-agent-ide-vision/index.ts +12 -4
  211. package/dist/chunk-4NIFBFFR.js +0 -11
  212. package/dist/chunk-7LZKOHH2.js +0 -1
  213. package/dist/chunk-FK42RSF4.js +0 -1
  214. package/dist/chunk-KBP3QUDT.js +0 -2
  215. package/dist/chunk-OE7QVAI2.js +0 -5
  216. package/dist/chunk-SILJ3OL4.js +0 -9
  217. package/dist/chunk-SQKAXYIR.js +0 -2
  218. package/dist/chunk-VCGNVTXQ.js +0 -1
@@ -1,86 +1,51 @@
1
- # Native IDE results
1
+ # Readable IDE results and private records
2
2
 
3
- Read, Search, text mutations, diff, Git index tools, and debugger creation declare an `outputSchema` and return `structuredContent`. Native Codemode receives that object. Normal calls keep their readable content and existing renderers. Renderer `details` are not a script API.
3
+ IDE tools expose readable text in direct calls and native Codemode. The existing Read views, Search anchors, edit effects and diffs remain the agent-facing output. Select shows its selected text and item references. Agents do not receive the private result records or need to inspect their fields.
4
4
 
5
- The shared envelope is:
5
+ ## Composition
6
6
 
7
- ```ts
8
- { status: "success", data: /* tool data */, errors: [] }
9
- { status: "error" | "partial", data?: /* observed data */, errors: [{ code, message, source? }] }
10
- ```
11
-
12
- `success` means the requested operation completed, including a search with no matches. `partial` means some work completed while other work failed. Output clipping is reported separately; it does not make a successful read an execution failure. `error` and `partial` set native `isError`.
13
-
14
- Check `status` before using data. Domain errors with structured results resolve in native Codemode; they do not automatically throw. Invalid arguments, blocked calls, and cancellation can still reject. A mutation error does not imply rollback. Check its observed effects before retrying.
15
-
16
- ## Data by tool
17
-
18
- - **Read:** `kind` is `text`, `bytes`, `native`, or `resources`. Text has original numbered `lines`, line endings, optional editable `anchors`, and source-level `references`. Bytes have exact `bytes: number[]`, byte offset, selected length, and total size. Native content has ordered text/image `blocks`; pass an image block to `image(...)`. Multi-source selections keep separate child resources.
19
- - **Search:** `matches` have a source, exact line/column range, optional matched text, and optional `references.line` / `references.match` selectors. Columns are zero-based UTF-16 offsets. `complete` describes the backend search; `truncated` describes the public window. `all` selectors exist only for complete registered selections. File searches return paths. Other resolvers return their documented JSON domain data under `kind: "custom"`.
20
- - **Mutations:** `operationId` identifies the call. `effect` and per-source `files` distinguish `pending`, `applied`, `not-applied`, and `unknown`. Recovery candidates and semantic action fields are included when available. `files[].state` reports present/absent/unknown when known. `changes` records exact removed/inserted text and before-snapshot UTF-16 offsets; it is inspection data, not a selector. If that record exceeds 512 KiB serialized, it is omitted with `changesUnavailable`, without clipping text or losing applied effects. Full before/after documents are not copied into receipts.
21
- - **Flush:** `operations` link final effects and errors to accepted child call IDs. It also returns per-source effects. An empty flush succeeds with no operations. A failed flush retains writes that happened and never replays accepted edits.
22
- - **Diff:** returns source identities, equality, added/removed counts, and bounded unified diff text. It does not repeat both source documents.
23
- - **Git index tools:** return action, change selector, file, index state, observed effect, and whether it was already in the requested state.
24
- - **Debugger:** creation returns session, source, and breakpoint resource references plus configuration and status. Debugger mutation actions return selected breakpoint or evaluation fields, not full session snapshots.
25
-
26
- ## Source result composition
27
-
28
- Exact filesystem text Read results and local text/regex, AST, and LSP Search results expose an optional `target: "RESULT#..."`. Each public Search match also has its own target. These handles resolve backend-owned source ranges and snapshots; serializable preview fields do not grant or change write authority.
29
-
30
- Native `search.path`, `replace.path`, `delete.path`, and copy/move `path` / `target` accept a successful result envelope, its data, a target handle, or arrays of compatible results/matches. `write.path` and `undo.file` accept only a single whole-file target; partial scopes never widen to a whole file. A whole result retains its complete stored scope even when its public window is shortened. Pass a matches array to narrow the scope explicitly. Read lines projected to strings or arbitrary coordinates are not editable targets.
7
+ Each result starts with a labelled system-result envelope containing a random UUID. It is not part of a file and must not be edited or inserted into file contents.
31
8
 
32
9
  ```js
33
- const read = await tools.read({ path: "note.txt", offset: 2, limit: 2 });
34
- if (read.status !== "success") throw new Error(JSON.stringify(read.errors));
35
- const found = await tools.search({ path: read, query: "old" });
36
- if (found.status !== "success") throw new Error(JSON.stringify(found.errors));
37
- const changed = await tools.replace({ path: found.data.matches.slice(0, 1), text: "new" });
38
- if (changed.status !== "success") throw new Error(JSON.stringify(changed.errors));
39
- text(changed);
10
+ const source = await tools.read({ path: "notes.txt" });
11
+ const matches = await tools.search({ path: source, query: "old" });
12
+ const selected = await tools.select({ path: matches, operation: { kind: "trim", side: "both" } });
13
+ text(await tools.replace({ path: selected, text: "new" }));
40
14
  ```
41
15
 
42
- Targets belong to the active session/runtime and worktree. A new session, reload or shutdown clears the store. Changing any source bytes makes a non-empty retained target stale; re-read or re-search rather than refreshing implicitly. Existing string `SEARCH#:all` selectors retain their separate refresh policy.
16
+ Pass the unchanged result to a supported source parameter. Direct calls also accept its UUID. Store/load retains the result string across scripts in the same session. Displayed item and capture references allow narrower selections without inspecting private arrays.
43
17
 
44
- Scoped text Search runs each range separately through ripgrep and maps matches back to source UTF-16 coordinates. AST and LSP providers can inspect full documents internally but return only provider ranges wholly contained in one declared region. AST matches expose associated `captures.NAME` arrays of source targets, including every node of a multi capture. LSP matches expose `role` and the originating `symbol` with its provider declaration identity and exact range. Use `navigation: "references"` explicitly to follow symbols represented in the seed scope to references outside it, within the workspace. It preserves inherited completeness and deduplicates by source/range identity. Text Boolean queries and text include/exclude globs remain unsupported for result scopes; AST/LSP keep their provider filters. Unsupported provider/scope combinations fail without falling back to a wider search. Replace rejects incomplete input and contradictory snapshot versions before writing, preserves ordinary resource and mutation guards, and treats an empty set as an explicit successful no-op. Preview edits, deleted diff text, bytes, images and derived views without an exact filesystem mapping cannot supply arbitrary edit targets.
18
+ A result identifies its backend-owned ranges, not the text in its preview. Shortened output does not clip a complete selection or make an incomplete selection complete. Read around a selection may show context without granting authority to edit it.
45
19
 
46
- ### Possible-name groups
20
+ ## Reference ownership
47
21
 
48
- After a complete zero result, eligible local and URL identifier searches can add `fuzzy: { status, message?, candidates }`. The original `matches` stays empty. Each candidate has `identifier`, a mechanical `kind` and `reason`, captured `matchCount` and `fileCount`, and a separate `selection` using the normal match/range/reference fields.
22
+ The session registry issues UUIDs and maps them to source handles. A guessed or computed hash has no authority unless the registry issued that reference. UUIDs are opaque references, not content hashes or signatures.
49
23
 
50
- Candidate selections show at most three locations. Their `truncated` flag describes that display window; `complete` describes the exact alternative's capture. Limited capture has lower-bound counts and no complete `all` reference. URL candidates use URL ranges, never editable Search references. A `skipped` branch explains its budget or extra-branch failure without changing the completed ordinary zero into an error.
24
+ The registry validates session/worktree ownership, exact full-output identity, successful source status and live snapshots. Copying a valid ID within its session is intentional reuse, not forgery. Altering the body while keeping the envelope is rejected. An ID cannot grant wider ranges than its original selection.
51
25
 
52
- Registered local candidate selections also expose immutable whole-scope and per-match targets. Their stored scope retains all captured matches even when the candidate preview shows only three. The original zero result remains an empty edit scope. Structured result-scoped queries do not run fuzzy discovery.
26
+ Changed files permanently retire old source and derived references. Restoring the old bytes does not revive them. Actual edit completions and script boundaries observe filesystem generations; retained source bytes are verified before use. Reload and session changes clear the registry.
53
27
 
54
- ## Native editor commits
28
+ Pending edits reserve source handles without granting authority to unconfirmed writes. A dependent source operation commits the batch before using such a handle. Failed or cancelled edits cannot confirm it. Independent peer edits retain their original snapshots until the common commit.
55
29
 
56
- Sequential local edits share original snapshots. Child success with `effect: "pending"` means accepted, not written. Await an explicit flush when the script needs the final receipt:
57
-
58
- ```ts
59
- const found = await tools.search({ query: "old", path: "note.txt" });
60
- if (found.status !== "success") throw new Error(found.errors[0].message);
61
- const changed = await tools.replace({ path: found.data.matches[0].references.match, text: "new" });
62
- if (changed.status !== "success") throw new Error(changed.errors[0].message);
63
- const saved = await tools.flush({});
64
- text(saved);
65
- ```
30
+ Read-only views, raw bytes, images and directory listings do not acquire text-edit authority. Their IDs can identify the resource for another read. Live shell/debugger references can be used only with their owning resource operations. File deletion supplies no reusable text selection.
66
31
 
67
- Resource-owned selectors may commit immediately rather than joining the local batch. Another tool or parent completion also commits pending local edits. The parent Codemode result records automatic commits in `details.editorBatchResults`; those reports contain receipts, not source snapshots. Ordinary script errors keep accepted independent edits. Abort and deadline discard pending edits but do not undo earlier commits.
32
+ ## Internal records
68
33
 
69
- ## Bounds and continuation
34
+ Each tool owns its validated record. Read, Search, Select, Diff, terminals, Git and debugger operations keep their own domain adapters. File edit receipts contain only operation, observed effect, file states and an optional verified selection handle. Delete omits selection fields. Flush separately records committed operation effects and errors; it does not reuse a giant resource-action schema.
70
35
 
71
- Public structured results must be finite plain JSON and fit within 1 MiB. Text windows keep at most 2,000 lines and 512 KiB of serialized line data. Raw byte windows keep at most 32,768 bytes, within the normal raw-read display budget. Ordinary Search match previews keep the first 100 matches and at most 4 KiB of matched text per match; a whole result's target retains its full registered scope. AST capture arrays retain every captured node for each visible parent match, within the shared JSON budget. Huge indivisible capture data fails explicitly rather than silently dropping nodes.
36
+ The text registry stores only ownership, a digest of the issued text, source references, resource identities and whether the result can be consumed. It does not copy line arrays, removed file contents, image bytes or debugger records into a second ledger. Source ranges and snapshots remain in the source-target store.
72
37
 
73
- Read `continuation` is a complete next request with a resolved source and absolute offset. Follow it rather than recomputing offsets from a rendered annotation. `fullResult` identifies retained complete output when available. A huge indivisible block or invalid adapter returns an explicit error rather than a clipped success. Temporary references belong to their runtime.
38
+ The unified registration adapter omits public outputSchema. Pi's supported Codemode execution path therefore returns each tool's existing text instead of structuredContent. Public tool_result hooks register the private source metadata and return the readable text with its envelope. This does not modify Pi, rewrite scripts, add VM methods, or recognize JSON in Codemode output.
74
39
 
75
- Native structured content is not copied into stored session messages. Existing compact renderer details stay separate. Scripts that explicitly print large data still store what they print.
76
- Guides attached to native structured child calls stay on the readable parent result, even when the script prints only selected data. They do not become fields in the public data schema.
40
+ Nested image blocks are delivered on the parent Codemode result; their bytes are not printed as text. Images remain ordinary native image content.
41
+ Read's private native record contains image type and MIME metadata, not another copy of the image bytes. Large images therefore do not overflow the JSON-record budget while their native content stays unchanged.
77
42
 
78
- ## Resolver adapters
43
+ ## Errors and writes
79
44
 
80
- Search resolvers must provide `toScriptData(payload, formattedDetails)`. Select documented JSON domain fields or use `selectionData` from `pi-agent-search/api/search`. Missing adapters fail with `STRUCTURED_ADAPTER_REQUIRED`; invalid schema or non-JSON values fail with `INVALID_STRUCTURED_RESULT`. Neither case falls back to display-text parsing or raw payload dumping.
45
+ Failed tools reject in Codemode. Use try/catch or Promise.allSettled when independent calls may fail. Inspect the readable file/operation effects and final parent result before retrying. An error does not prove rollback.
81
46
 
82
- Standard Read Resources use the core text/bytes/native projection. Read handlers that return their own result must supply `script: ReadScriptData`; custom content needs an explicit supported projection. Source-level references and line anchors come from presenters, not parsed annotations.
47
+ Flush commits writes, not final formatting. Final post-edit processing can retire earlier snapshots. Ordinary script errors keep accepted edits; abort/deadline discards pending writes, not already committed batches.
83
48
 
84
- The shared validation helpers live in `pi-agent-resource`. Read and Search export their data/output schemas through their existing public tool APIs. Text mutation schemas and `structuredMutation` are exported through `pi-agent-text-editor/api/mutation-result`.
49
+ After an exact-text selector fails, the tool returns current anchors and blocks further exact-text edits for that file. Use a current anchor for the next successful edit. Exact text is then available again.
85
50
 
86
- Shell command results keep their separate native process contract. This change does not add a shared result store, cross-session handles, binary editing, or grouped rollback.
51
+ See [editing](./agent-guides/editing.md), [Read](./agent-guides/read-resources.md) and [Select](./agent-guides/select-code.md) for their source and boundary contracts.
package/docs/tools.md CHANGED
@@ -4,9 +4,9 @@ Pi Agent IDE explores a small tool surface for coding agents. The goal is to kee
4
4
 
5
5
  The project is experimental. The behavior below describes the current implementation, not a performance guarantee.
6
6
 
7
- ## Native structured results
7
+ ## Readable results and composition
8
8
 
9
- IDE tools declare native result schemas. Codemode receives typed data and explicit success/error/partial outcomes instead of display strings. Check status and mutation effects before continuing or retrying. See [Native IDE results](./structured-results.md) for fields, resolver adapters, bounds, and `tools.flush({})`.
9
+ IDE tools return readable text in direct calls and Codemode. A leading system-result envelope carries a registered UUID; it is not file content. Pass the unchanged result to another source parameter, or use its UUID in a direct call. The system resolves the private source records. Check the readable file effects before retrying failed edits. See [IDE result composition](./structured-results.md) for reference lifetime and `tools.flush({})`.
10
10
 
11
11
  ## Resource references
12
12
 
@@ -52,7 +52,7 @@ When `path` is a typed text resource, `read` returns one independent chunk for e
52
52
 
53
53
  Use `read({path: "raw:sample.bin", offset: 0, limit: 64})` to inspect original local file bytes, including PDF and image headers. In `raw:` mode only, offset is zero-based in bytes (negative from EOF), and limit is a non-negative byte count. The output shows hexadecimal offsets, hex bytes, and printable ASCII. Follow its returned byte offset to continue. No views or text anchors apply.
54
54
 
55
- Inside native Codemode, check the result’s `status` and use `data.kind: "bytes"`, `source`, `byteOffset`, `byteLength`, `totalBytes` and `bytes: number[]`. The script receives the complete selected range; the displayed answer stays bounded. Use `text(result)` to retain the hex view rather than printing the byte array. This is read-only; byte editing and byte diff are not included.
55
+ Codemode receives the same bounded hex view as a direct call. Use `text(result)` or return it to display that view. Follow the displayed offset or continuation reference. This is read-only; byte editing and byte diff are not included.
56
56
 
57
57
  ### Diagnostic completion
58
58
 
@@ -76,16 +76,12 @@ Window and display capture use `node-screenshots` on Linux and macOS. Desktop or
76
76
 
77
77
  ## Terminal sessions
78
78
 
79
- Native Codemode scripts receive a structured shell result. `output` holds up to 1 MiB of ANSI-free PTY output; empty output is `""`. Longer logs keep their first and last 512 KiB, cut at UTF-8 character boundaries. `truncated` reports missing output, not whether the process has finished. `output_ranges` gives the zero-based, end-exclusive byte ranges joined into `output`, with no added headings or omission marker. `full_output_path` points to the UTF-8 log, which keeps growing while the process runs and stays available until the session is deleted.
80
-
81
- The native fields `exit_code` and `wall_time_seconds` describe the process, not tool transport. `exit_code` is absent until known. IDE fields `session`, `source`, `status`, `background`, `wait_reason`, `completion_reason`, `signal`, and `error` describe the persistent session. A wait timeout leaves a running session, not a failed command. Nonzero exits and shell startup failures still return structured data to scripts. Normal model output and stored renderer details keep the shorter terminal preview limits.
79
+ Codemode receives the same readable shell status and output as direct calls. The result includes its session source and a reference to the complete log when output is shortened. A wait timeout leaves a running session, not a failed command. Inspect the reported exit status and effects; failed tools can reject.
82
80
 
83
81
  ```ts
84
82
  const result = await tools.bash({ command: "your-command" });
85
- text({
86
- status: result.status,
87
- errors: result.output.split("\n").filter((line) => line.includes("error")),
88
- });
83
+ text(result);
84
+ text(await tools.read({ path: result }));
89
85
  ```
90
86
 
91
87
  `bash` (Linux/WSL) or `powershell` (Windows) starts a command in the user's configured system shell. Its schema and prompt guidance name that shell at runtime, so the agent writes Bash, zsh, PowerShell, or Command Prompt syntax as appropriate. Commands are not translated between shell languages.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-doctor",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-documentation",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
@@ -36,12 +36,13 @@ export default async function registerFilesystemPlugin(pi: ExtensionAPI): Promis
36
36
  renderResult: renderReadResult,
37
37
  recoverFailure: recoverFilesystemPath,
38
38
  });
39
- api.describe(() =>
40
- renderContentDescription(
41
- "File path — file content; directory path — entry listing. Relative, absolute and file:// paths accepted.",
42
- readHost.listDescriptions(),
43
- ),
44
- );
39
+ api.describe({
40
+ path: () =>
41
+ renderContentDescription(
42
+ "File path — file content; directory path — entry listing. Relative, absolute and file:// paths accepted.",
43
+ readHost.listDescriptions(),
44
+ ),
45
+ });
45
46
  },
46
47
  } satisfies ReadPlugin;
47
48
  const textEditorPlugin = {
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-image": "0.7.0",
10
- "pi-agent-invariant": "0.7.0",
11
- "pi-agent-read": "0.7.0",
12
- "pi-agent-resource": "0.7.0",
13
- "pi-agent-text": "0.7.0",
14
- "pi-agent-text-editor": "0.7.0"
9
+ "pi-agent-image": "0.7.1",
10
+ "pi-agent-invariant": "0.7.1",
11
+ "pi-agent-read": "0.7.1",
12
+ "pi-agent-resource": "0.7.1",
13
+ "pi-agent-text": "0.7.1",
14
+ "pi-agent-text-editor": "0.7.1"
15
15
  },
16
16
  "pi": {
17
17
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-image",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#extension": "./index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-image": "0.7.0",
10
- "pi-agent-resource": "0.7.0"
9
+ "pi-agent-image": "0.7.1",
10
+ "pi-agent-resource": "0.7.1"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -71,9 +71,10 @@ const readPlugin = {
71
71
  return { kind: "continue", context: { ...context, state: transformed } };
72
72
  },
73
73
  });
74
- api.describe(
75
- 'JSON files accept views such as ["jq:.scripts | keys"] to query them with the installed jq executable.',
76
- );
74
+ api.describe({
75
+ views:
76
+ 'jq:<filter> — query local JSON text with the installed jq executable, e.g. ["jq:.scripts | keys"]. Exactly one non-empty jq filter is required; it cannot be combined with other views. offset/limit apply to the transformed output, not original source lines.',
77
+ });
77
78
  },
78
79
  } satisfies ReadPlugin;
79
80
 
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-jq",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
9
  "cross-spawn": "^7.0.6",
10
- "pi-agent-doctor": "0.7.0",
11
- "pi-agent-documentation": "0.7.0",
12
- "pi-agent-read": "0.7.0",
13
- "pi-agent-text": "0.7.0"
10
+ "pi-agent-doctor": "0.7.1",
11
+ "pi-agent-documentation": "0.7.1",
12
+ "pi-agent-read": "0.7.1",
13
+ "pi-agent-text": "0.7.1"
14
14
  },
15
15
  "pi": {
16
16
  "extensions": [
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-pdf",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-pdf": "0.7.0",
7
- "pi-agent-resource": "0.7.0"
6
+ "pi-agent-pdf": "0.7.1",
7
+ "pi-agent-resource": "0.7.1"
8
8
  },
9
9
  "pi": {
10
10
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-text",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#extension": "./index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-resource": "0.7.0",
10
- "pi-agent-text": "0.7.0"
9
+ "pi-agent-resource": "0.7.1",
10
+ "pi-agent-text": "0.7.1"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-ide-ast",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
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.0",
35
- "pi-agent-documentation": "0.7.0",
36
- "pi-agent-invariant": "0.7.0",
37
- "pi-agent-read": "0.7.0",
38
- "pi-agent-resource": "0.7.0",
39
- "pi-agent-search": "0.7.0",
40
- "pi-agent-search-text": "0.7.0",
41
- "pi-agent-text": "0.7.0",
42
- "pi-agent-text-editor": "0.7.0",
43
- "pi-agent-tool-call-interception": "0.7.0",
44
- "pi-agent-tool-ui": "0.7.0",
34
+ "pi-agent-doctor": "0.7.1",
35
+ "pi-agent-documentation": "0.7.1",
36
+ "pi-agent-invariant": "0.7.1",
37
+ "pi-agent-read": "0.7.1",
38
+ "pi-agent-resource": "0.7.1",
39
+ "pi-agent-search": "0.7.1",
40
+ "pi-agent-search-text": "0.7.1",
41
+ "pi-agent-text": "0.7.1",
42
+ "pi-agent-text-editor": "0.7.1",
43
+ "pi-agent-tool-call-interception": "0.7.1",
44
+ "pi-agent-tool-ui": "0.7.1",
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.0",
61
+ "pi-agent-ide": "0.7.1",
62
62
  "typebox": "*"
63
63
  },
64
64
  "peerDependenciesMeta": {
@@ -55,9 +55,12 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
55
55
  return result.kind === "return" ? result : scopes(result.context);
56
56
  },
57
57
  });
58
- api.describe(
59
- 'ast:<path> — compact declaration outline. views: ["ast"] — scope boundaries alongside source text. Oversized code reads may return an outline with source line numbers; offset/limit read a smaller source range.',
60
- );
58
+ api.describe({
59
+ path: "ast:<path> — compact declaration outline for a code file.",
60
+ views: "ast — scope boundaries alongside source text.",
61
+ offset:
62
+ "Oversized code reads may return an outline with source line numbers; offset/limit select a smaller source range.",
63
+ });
61
64
  await registerSelect(pi, api);
62
65
  },
63
66
  } satisfies ReadPlugin;
@@ -86,7 +89,7 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
86
89
  setup(api): void {
87
90
  api.addResolver({ resolver: createAstSearchResolver(api.registerSelection) });
88
91
  api.describe(
89
- "Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use each match's captures.NAME array in native Codemode as Search/replace input. Single captures contain one node; multi captures retain provider nodes, including punctuation. Strict result scopes return only wholly contained matches. These edits do not update imports or references.",
92
+ "Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use the displayed capture NAME reference as a Search/Select/edit source. Single captures contain one node; multi captures retain provider nodes, including punctuation. Strict result scopes return only wholly contained matches. These edits do not update imports or references.",
90
93
  );
91
94
  },
92
95
  }),
@@ -109,6 +109,7 @@ export function createAstSearchResolver(
109
109
  );
110
110
  const data = selectionData(selected.matches, selected.complete, session.id, session);
111
111
  const captures: Record<string, ReturnType<typeof selectionData>["matches"]>[] = [];
112
+ const captureGroups: Record<string, { target: string; nodes: number }>[] = [];
112
113
  for (const raw of selected.raw.slice(0, data.matches.length)) {
113
114
  const groups = Object.entries({
114
115
  ...Object.fromEntries(
@@ -117,6 +118,7 @@ export function createAstSearchResolver(
117
118
  ...raw.metaVariables?.multi,
118
119
  });
119
120
  const projected = [];
121
+ const groupsForMatch: Record<string, { target: string; nodes: number }> = {};
120
122
  for (const [name, nodes] of groups) {
121
123
  for (const node of nodes) {
122
124
  if (
@@ -130,6 +132,23 @@ export function createAstSearchResolver(
130
132
  context.cwd,
131
133
  context.signal,
132
134
  );
135
+ const group = await registerSelection(
136
+ {
137
+ request,
138
+ matches,
139
+ complete: selected.complete,
140
+ refresh: async () => {
141
+ throw new Error("Capture snapshots cannot refresh; repeat the AST search.");
142
+ },
143
+ },
144
+ context,
145
+ );
146
+ groupsForMatch[name] = {
147
+ target: requiredValue(
148
+ selectionData(matches, selected.complete, undefined, group).target,
149
+ ),
150
+ nodes: matches.length,
151
+ };
133
152
  const nodesData: ReturnType<typeof selectionData>["matches"] = [];
134
153
  // Shared Search previews hold 100 nodes. Register every capture chunk without dropping nodes.
135
154
  for (let offset = 0; offset < matches.length; offset += 100) {
@@ -150,6 +169,7 @@ export function createAstSearchResolver(
150
169
  projected.push([name, nodesData] as const);
151
170
  }
152
171
  captures.push(Object.fromEntries(projected));
172
+ captureGroups.push(groupsForMatch);
153
173
  }
154
174
  if (context.scope !== undefined) await verifyResultTargets(context.scope, context.signal);
155
175
  return {
@@ -159,6 +179,7 @@ export function createAstSearchResolver(
159
179
  ...data,
160
180
  matches: data.matches.map((match, index) => ({ ...match, captures: captures[index] })),
161
181
  },
182
+ captureGroups,
162
183
  pattern,
163
184
  matches: selected.raw.map((match, index) => ({
164
185
  ...match,
@@ -181,7 +202,11 @@ export function createAstSearchResolver(
181
202
  },
182
203
  format(payload) {
183
204
  const result = payload as {
205
+ readonly data: {
206
+ matches: { captures?: Record<string, ReturnType<typeof selectionData>["matches"]> }[];
207
+ };
184
208
  readonly pattern: string;
209
+ readonly captureGroups: Record<string, { target: string; nodes: number }>[];
185
210
  readonly sessionId: string;
186
211
  readonly matches: readonly AstGrepMatch[];
187
212
  readonly complete: boolean;
@@ -195,12 +220,16 @@ export function createAstSearchResolver(
195
220
  };
196
221
  }
197
222
 
198
- const lines = result.matches.flatMap((match, index) => [
199
- `SEARCH#${result.sessionId}:${String(index + 1)}:match ${match.file}:${String(match.range.start.line + 1)}:${String(
200
- match.range.start.column + 1,
201
- )} ${match.language}`,
202
- ` ${match.lines.trim()}`,
203
- ]);
223
+ const lines = result.matches.flatMap((match, index) => {
224
+ const rows = [
225
+ `SEARCH#${result.sessionId}:${index + 1}:match ${match.file}:${match.range.start.line + 1}:${match.range.start.column + 1} ${match.language}`,
226
+ ` ${match.lines.trim()}`,
227
+ ];
228
+ for (const [name, group] of Object.entries(result.captureGroups[index] ?? {})) {
229
+ rows.push(` capture ${name}: ${group.target} ${group.nodes} node(s)`);
230
+ }
231
+ return rows;
232
+ });
204
233
 
205
234
  if (result.complete)
206
235
  lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact AST matches.`);
@@ -91,7 +91,7 @@ export function selectPresentation(
91
91
  rows.push({
92
92
  kind: "note",
93
93
  expandedOnly: true,
94
- text: "… more origins retained in structured result",
94
+ text: "… more origins retained in this result reference",
95
95
  });
96
96
  }
97
97
  }
@@ -120,7 +120,7 @@ function scopedOperation<const Kind extends "within" | "intersection" | "differe
120
120
  scopes: {
121
121
  ...resultInputSchema,
122
122
  description:
123
- "Comparison scopes: verified results, data, targets, item arrays, or a readable source string. Match sets by source, not array position.",
123
+ "Comparison scopes: unchanged results, issued UUIDs or item references, arrays of those strings, or a readable source path. Match sets by source, not array position.",
124
124
  },
125
125
  },
126
126
  { additionalProperties: false, description },
@@ -287,7 +287,7 @@ export const selectSchema = Type.Object(
287
287
  path: {
288
288
  ...resultInputSchema,
289
289
  description:
290
- "Pass a compatible source result, its data or RESULT# target, a returned-item array, or a file path. Preview text and reconstructed coordinates are not source targets.",
290
+ "File path, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Pass the whole result; do not rebuild it from preview text.",
291
291
  },
292
292
  operation: Type.Union([
293
293
  structuralOperationSchema,
@@ -9,6 +9,7 @@ import {
9
9
  withToolCallInterceptionRendering,
10
10
  } from "pi-agent-tool-call-interception";
11
11
  import { selectPresentation } from "./select-presentation.js";
12
+
12
13
  import { selectStructuralRegions } from "./ast/selection.js";
13
14
  import { publicRange } from "./selection-region.js";
14
15
  import { selectTextRegions } from "./text-selection.js";
@@ -21,6 +22,22 @@ import {
21
22
  type SelectParameters,
22
23
  type GeometrySelectOperation,
23
24
  } from "./select-schema.js";
25
+ /** Show selected text and opaque item references, never the internal selection record. */
26
+ function selectionText(data: SelectionData): string {
27
+ const rows = [`${data.totalItems} selection(s)${data.complete ? "" : " · incomplete input"}`];
28
+ if (data.missingInputs) rows.push(`${data.missingInputs} input(s) without a selection`);
29
+ for (const item of data.items) {
30
+ const range = item.range;
31
+ rows.push(
32
+ `${item.target} ${item.source}:${range.startLine}:${range.startColumn}–${range.endLine}:${range.endColumn}${item.syntax ? ` ${item.syntax.object}${item.syntax.part ? `/${item.syntax.part}` : ""}` : ""}`,
33
+ item.preview,
34
+ );
35
+ if (item.textTruncated)
36
+ rows.push("… preview shortened; reference retains the complete selection");
37
+ }
38
+ if (data.truncated) rows.push("… more selections retained in the whole result");
39
+ return rows.join("\n");
40
+ }
24
41
 
25
42
  function operationLabel(operation: SelectParameters["operation"]): string {
26
43
  switch (operation.kind) {
@@ -219,7 +236,7 @@ export async function registerSelect(pi: ExtensionAPI, read: ReadPluginApi): Pro
219
236
  };
220
237
  return withStructuredResult(
221
238
  {
222
- content: [{ type: "text", text: JSON.stringify(data) }],
239
+ content: [{ type: "text", text: selectionText(data) }],
223
240
  details: selectPresentation(
224
241
  selected.regions,
225
242
  verified.complete,
@@ -42,9 +42,10 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
42
42
  id: "current-git-changes",
43
43
  setup(api) {
44
44
  api.addView({ view: "changes", presenter });
45
- api.describe(
46
- 'views: ["changes"] — uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.',
47
- );
45
+ api.describe({
46
+ views:
47
+ "changes — uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.",
48
+ });
48
49
  },
49
50
  } satisfies ReadPlugin;
50
51
  const editorPlugin = {