pi-agent-ide 0.6.3 → 0.6.4

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 (355) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +8 -1
  3. package/dist/chunk-2P2OGO3G.js +2 -0
  4. package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
  5. package/dist/chunk-5J43L2RL.js +11 -0
  6. package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
  7. package/dist/chunk-BAYETTZZ.js +16 -0
  8. package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
  9. package/dist/chunk-BVK5A7ED.js +28 -0
  10. package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
  11. package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
  12. package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
  13. package/dist/chunk-FZBCKIJJ.js +1 -0
  14. package/dist/chunk-HPUAIWIH.js +25 -0
  15. package/dist/chunk-I5JLCFUX.js +1 -0
  16. package/dist/chunk-KUPHNMUK.js +2 -0
  17. package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
  18. package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
  19. package/dist/chunk-MIZAFRDR.js +1 -0
  20. package/dist/chunk-PJPA5EEE.js +2 -0
  21. package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
  22. package/dist/chunk-QEJGED4V.js +28 -0
  23. package/dist/chunk-SILJ3OL4.js +9 -0
  24. package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
  25. package/dist/chunk-VBICI5YA.js +1 -0
  26. package/dist/chunk-VWW3RLUX.js +12 -0
  27. package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
  28. package/dist/chunk-YGGKGZO2.js +1 -0
  29. package/dist/chunk-ZODCBFBL.js +2 -0
  30. package/dist/chunk-ZPT5D4VP.js +2 -0
  31. package/dist/entry-0.js +1 -1
  32. package/dist/entry-11.js +1 -1
  33. package/dist/entry-13.js +1 -1
  34. package/dist/entry-14.js +1 -1
  35. package/dist/entry-15.js +1 -1
  36. package/dist/entry-16.js +1 -1
  37. package/dist/entry-17.js +1 -1
  38. package/dist/entry-25.js +2 -2
  39. package/dist/entry-26.js +1 -1
  40. package/dist/entry-27.js +1 -1
  41. package/dist/entry-28.js +1 -1
  42. package/dist/entry-29.js +1 -1
  43. package/dist/entry-30.js +1 -1
  44. package/dist/entry-31.js +11 -11
  45. package/dist/entry-33.js +1 -1
  46. package/dist/entry-37.js +2 -2
  47. package/dist/entry-42.js +1 -1
  48. package/dist/entry-44.js +1 -1
  49. package/dist/entry-45.js +13 -12
  50. package/dist/entry-46.js +1 -1
  51. package/dist/entry-49.js +1 -1
  52. package/dist/entry-50.js +4 -4
  53. package/dist/entry-51.js +9 -9
  54. package/dist/entry-52.js +1 -1
  55. package/dist/entry-53.js +1 -1
  56. package/dist/entry-55.js +1 -1
  57. package/dist/entry-56.js +1 -1
  58. package/dist/entry-57.js +1 -1
  59. package/dist/entry-58.js +1 -1
  60. package/dist/entry-59.js +1 -1
  61. package/dist/entry-60.js +1 -1
  62. package/dist/entry-61.js +1 -1
  63. package/dist/entry-63.js +1 -1
  64. package/dist/entry-66.js +1 -1
  65. package/dist/entry-68.js +1 -1
  66. package/dist/entry-69.js +1 -1
  67. package/dist/entry-70.js +1 -1
  68. package/dist/entry-71.js +1 -0
  69. package/dist/entry-72.js +0 -1
  70. package/dist/entry-73.js +1 -0
  71. package/dist/entry-74.js +0 -1
  72. package/dist/entry-75.js +1 -1
  73. package/dist/entry-76.js +1 -1
  74. package/dist/entry-77.js +1 -324
  75. package/dist/entry-78.js +324 -25
  76. package/dist/entry-79.js +18 -2
  77. package/dist/entry-80.js +2 -1
  78. package/dist/entry-81.js +1 -1
  79. package/dist/entry-82.js +1 -3
  80. package/dist/entry-83.js +5 -3
  81. package/dist/entry-84.js +3 -1
  82. package/dist/entry-85.js +1 -1
  83. package/dist/entry-86.js +1 -1
  84. package/dist/entry-87.js +1 -0
  85. package/dist/pi-agent-ide.js +15 -3
  86. package/docs/agent-guides/editing.md +12 -0
  87. package/docs/agent-guides/json-reading.md +19 -3
  88. package/docs/agent-guides/read-resources.md +6 -0
  89. package/docs/agent-guides/search-code.md +5 -1
  90. package/docs/agent-guides/terminal.md +1 -1
  91. package/docs/code-review.md +99 -0
  92. package/docs/configuration.md +34 -0
  93. package/docs/development.md +15 -19
  94. package/docs/nightly.md +7 -0
  95. package/docs/releases.md +42 -0
  96. package/docs/research/native-codemode-batch-decision.md +27 -0
  97. package/docs/research/native-codemode-batching.md +65 -0
  98. package/docs/structured-results.md +59 -0
  99. package/docs/tools.md +18 -2
  100. package/node_modules/pi-agent-doctor/package.json +1 -1
  101. package/node_modules/pi-agent-documentation/package.json +1 -1
  102. package/node_modules/pi-agent-documentation/src/index.ts +1 -1
  103. package/node_modules/pi-agent-filesystem/index.ts +6 -1
  104. package/node_modules/pi-agent-filesystem/package.json +7 -6
  105. package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
  106. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  107. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  108. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  109. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  110. package/node_modules/pi-agent-ide-ast/package.json +10 -10
  111. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  112. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  113. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +17 -0
  114. package/node_modules/pi-agent-ide-changes/index.ts +3 -9
  115. package/node_modules/pi-agent-ide-changes/package.json +8 -7
  116. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  117. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
  118. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  119. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  120. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  121. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  122. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
  123. package/node_modules/pi-agent-image/package.json +2 -2
  124. package/node_modules/pi-agent-invariant/package.json +1 -1
  125. package/node_modules/pi-agent-pdf/package.json +2 -2
  126. package/node_modules/pi-agent-read/package.json +7 -7
  127. package/node_modules/pi-agent-read/src/api/tools/read.ts +31 -2
  128. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  129. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  130. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
  131. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
  132. package/node_modules/pi-agent-resource/package.json +1 -1
  133. package/node_modules/pi-agent-resource/src/index.ts +12 -0
  134. package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
  135. package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
  136. package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
  137. package/node_modules/pi-agent-search/package.json +5 -4
  138. package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
  139. package/node_modules/pi-agent-search/src/api/search.ts +11 -0
  140. package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
  141. package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
  142. package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
  143. package/node_modules/pi-agent-search-text/index.ts +3 -0
  144. package/node_modules/pi-agent-search-text/package.json +6 -6
  145. package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
  146. package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
  147. package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
  148. package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
  149. package/node_modules/pi-agent-search-text/src/search-renderer.ts +37 -3
  150. package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
  151. package/node_modules/pi-agent-text/package.json +2 -2
  152. package/node_modules/pi-agent-text/src/text-document.ts +15 -10
  153. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  154. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  155. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  156. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  157. package/node_modules/pi-agent-text-editor/index.ts +4 -2
  158. package/node_modules/pi-agent-text-editor/package.json +21 -17
  159. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
  160. package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  161. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  162. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  163. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
  164. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
  165. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
  166. package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
  167. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
  168. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
  169. package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  170. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
  171. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  172. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
  173. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  174. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
  175. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  176. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +314 -0
  177. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
  178. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  179. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
  180. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
  181. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  182. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  183. package/node_modules/pi-agent-text-editor-renderer/index.ts +8 -1
  184. package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
  185. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
  186. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  187. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  188. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  189. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  190. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  191. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  192. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  193. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  194. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
  195. package/node_modules/pi-agent-web/index.ts +20 -0
  196. package/node_modules/pi-agent-web/package.json +8 -7
  197. package/node_modules/pi-agent-web/src/search.ts +112 -0
  198. package/node_modules/pi-agent-web-html/package.json +3 -3
  199. package/node_modules/pi-agent-web-image/package.json +4 -4
  200. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  201. package/node_modules/pi-agent-web-text/package.json +4 -4
  202. package/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
  203. package/package.json +42 -36
  204. package/skills/capture-code-review-rule/SKILL.md +60 -0
  205. package/src/code-review/config.ts +68 -0
  206. package/src/code-review/extension.ts +105 -0
  207. package/src/code-review/fragments.ts +26 -0
  208. package/src/code-review/reviewer.ts +198 -0
  209. package/src/composite/host-version.ts +13 -0
  210. package/src/composite/nested-tool-rendering.ts +298 -0
  211. package/src/composite/tool-availability.ts +90 -0
  212. package/src/core/extension.ts +2 -0
  213. package/src/documentation/extension.ts +81 -145
  214. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
  215. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
  216. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  217. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  218. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  219. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  220. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
  221. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +20 -0
  222. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -7
  223. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  224. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
  230. package/src/extensions/pi-agent-read/package.json +7 -7
  231. package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
  232. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  233. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  234. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
  235. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
  236. package/src/extensions/pi-agent-search/package.json +5 -4
  237. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
  238. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  239. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +17 -0
  240. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
  241. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
  242. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
  243. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +37 -3
  244. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
  245. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
  246. package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
  247. package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
  248. package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
  249. package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
  250. package/src/extensions/pi-agent-text-editor/index.ts +4 -2
  251. package/src/extensions/pi-agent-text-editor/package.json +21 -17
  252. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  253. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  254. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  255. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  256. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +8 -1
  257. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
  258. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  265. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  268. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  269. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  270. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
  271. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
  272. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
  273. package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
  274. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
  275. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
  276. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
  278. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  279. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
  280. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  281. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
  282. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  283. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +314 -0
  284. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
  285. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  286. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
  287. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
  288. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  289. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  290. package/src/pi-agent-ide.ts +61 -2
  291. package/src/plugins/pi-agent-ide-ast/package.json +10 -10
  292. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  293. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  294. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +17 -0
  295. package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
  296. package/src/plugins/pi-agent-ide-changes/package.json +8 -7
  297. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  298. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
  299. package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
  300. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
  301. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
  302. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
  303. package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
  304. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
  305. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
  306. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  307. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  308. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  309. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  310. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
  311. package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
  312. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
  313. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
  314. package/src/plugins/pi-agent-ide-terminal/src/search.ts +13 -8
  315. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
  316. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
  317. package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
  318. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +97 -45
  319. package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
  320. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
  321. package/src/plugins/pi-agent-ide-vision/index.ts +16 -1
  322. package/dist/chunk-3E2NTWCN.js +0 -2
  323. package/dist/chunk-4LUW26BX.js +0 -10
  324. package/dist/chunk-5VSE5X5R.js +0 -2
  325. package/dist/chunk-CEX3VOJ7.js +0 -2
  326. package/dist/chunk-FA6BKC5Y.js +0 -1
  327. package/dist/chunk-FEDVTZJG.js +0 -1
  328. package/dist/chunk-HMLH43ZS.js +0 -4
  329. package/dist/chunk-KII2JQC5.js +0 -1
  330. package/dist/chunk-LVWMWWWF.js +0 -28
  331. package/dist/chunk-P7XO5CIP.js +0 -2
  332. package/dist/chunk-PZFOOHY2.js +0 -15
  333. package/dist/chunk-S3ZPXWX7.js +0 -2
  334. package/dist/chunk-T7CZIACQ.js +0 -27
  335. package/dist/chunk-YT42LKFV.js +0 -16
  336. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
  337. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
  338. package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
  339. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
  340. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
  343. /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
  344. /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
  345. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
  346. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
  347. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
  348. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
  349. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  350. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  351. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  352. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  353. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  354. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  355. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -42,33 +42,37 @@
42
42
  "types": "./src/api/post-edit.ts",
43
43
  "default": "./runtime/entry-69.js"
44
44
  },
45
+ "./api/native-edit-batch-event": {
46
+ "types": "./src/api/native-edit-batch-event.ts",
47
+ "default": "./runtime/entry-70.js"
48
+ },
45
49
  "./api/mutation-result": {
46
50
  "types": "./src/api/mutation-result.ts",
47
- "default": "./runtime/entry-70.js"
51
+ "default": "./runtime/entry-71.js"
48
52
  },
49
53
  "./api/mutation-guard": {
50
54
  "types": "./src/api/mutation-guard.ts",
51
- "default": "./runtime/entry-71.js"
55
+ "default": "./runtime/entry-72.js"
52
56
  },
53
57
  "./api/mutation-tool": {
54
58
  "types": "./src/api/mutation-tool.ts",
55
- "default": "./runtime/entry-72.js"
59
+ "default": "./runtime/entry-73.js"
56
60
  },
57
61
  "./api/mutation-preview": {
58
62
  "types": "./src/api/mutation-preview.ts",
59
- "default": "./runtime/entry-73.js"
63
+ "default": "./runtime/entry-74.js"
60
64
  },
61
65
  "./api/last-resolved-resource": {
62
66
  "types": "./src/api/last-resolved-resource.ts",
63
- "default": "./runtime/entry-74.js"
67
+ "default": "./runtime/entry-75.js"
64
68
  },
65
69
  "./api/tool-call-interceptor": {
66
70
  "types": "./src/api/tool-call-interceptor.ts",
67
- "default": "./runtime/entry-75.js"
71
+ "default": "./runtime/entry-76.js"
68
72
  },
69
73
  "./api/tool-renderer": {
70
74
  "types": "./src/api/tool-renderer.ts",
71
- "default": "./runtime/entry-76.js"
75
+ "default": "./runtime/entry-77.js"
72
76
  }
73
77
  },
74
78
  "dependencies": {
@@ -79,20 +83,20 @@
79
83
  "fs-extra": "^11.4.0",
80
84
  "oxfmt": "0.64.0",
81
85
  "partial-json": "^0.1.7",
82
- "pi-agent-documentation": "0.6.3",
83
- "pi-agent-invariant": "0.6.3",
84
- "pi-agent-read": "0.6.3",
85
- "pi-agent-resource": "0.6.3",
86
- "pi-agent-search": "0.6.3",
87
- "pi-agent-text": "0.6.3",
88
- "pi-agent-tool-call-interception": "0.6.3",
89
- "pi-agent-tool-ui": "0.6.3",
86
+ "pi-agent-documentation": "0.6.4",
87
+ "pi-agent-invariant": "0.6.4",
88
+ "pi-agent-read": "0.6.4",
89
+ "pi-agent-resource": "0.6.4",
90
+ "pi-agent-search": "0.6.4",
91
+ "pi-agent-text": "0.6.4",
92
+ "pi-agent-tool-call-interception": "0.6.4",
93
+ "pi-agent-tool-ui": "0.6.4",
90
94
  "run": "2.1.4",
91
95
  "typebox-guard": "npm:typebox@^1.1.38"
92
96
  },
93
97
  "pi": {
94
98
  "extensions": [
95
- "./runtime/entry-77.js"
99
+ "./runtime/entry-78.js"
96
100
  ]
97
101
  },
98
102
  "peerDependencies": {
@@ -1,2 +1 @@
1
1
  export * from "../../../dist/entry-77.js";
2
- export { default } from "../../../dist/entry-77.js";
@@ -15,6 +15,8 @@ export type TextMutationPreviewRanges = readonly TextMutationPreviewRange[];
15
15
  export interface TextMutationPreviewResource {
16
16
  readonly path: string;
17
17
  readonly existed?: boolean;
18
+ /** Resolver that owns this snapshot and its write policy. */
19
+ readonly resolvedBy?: string;
18
20
  readonly beforeRanges?: TextMutationPreviewRanges;
19
21
  readonly link?: string;
20
22
  readonly ranges: readonly TextMutationPreviewRange[];
@@ -25,3 +25,9 @@ export {
25
25
  } from "#src/core/mutation-result/file-mutation-result.js";
26
26
 
27
27
  export { type ChangedRange, computeChangedRanges } from "#src/core/mutation-result/diff.js";
28
+ export {
29
+ mutationDataSchema,
30
+ mutationOutputSchema,
31
+ structuredMutation,
32
+ type MutationData,
33
+ } from "#src/core/structured-result.js";
@@ -0,0 +1,12 @@
1
+ import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
2
+ import type { FileMutationBatchResult } from "./mutation-result.js";
3
+
4
+ /** A finished native editor batch, sent through Pi's event bus without saving raw snapshots. */
5
+ export interface NativeEditBatchEvent {
6
+ readonly parentToolCallId: string;
7
+ readonly calls: readonly string[];
8
+ readonly result: AgentToolResult<FileMutationBatchResult>;
9
+ }
10
+
11
+ /** Presentation listeners must compact the result before retaining it in history. */
12
+ export const NATIVE_EDIT_BATCH_EVENT = "pi-agent-text-editor:native-batch-finished";
@@ -72,6 +72,10 @@ export class ApplyUndoStore {
72
72
  return this.#receipts.has(transaction);
73
73
  }
74
74
 
75
+ /** Paths reserved by a receipt; unavailable receipts cannot restore any paths. */
76
+ public sources(transaction: string): readonly string[] {
77
+ return this.#receipts.get(transaction)?.paths.map((state) => state.path) ?? [];
78
+ }
75
79
  public async restore(transaction: string): Promise<ApplyUndoResult> {
76
80
  const receipt = this.#receipts.get(transaction);
77
81
  if (receipt === undefined)
@@ -16,6 +16,9 @@ import { TextAnchorResolutionError } from "#src/core/text-anchor-registry.js";
16
16
  import { buildFailedTextMutationResult } from "#src/core/text-mutation.js";
17
17
  import { TextMutationAnchorResolutionError } from "#src/core/text-mutation-anchor-error.js";
18
18
 
19
+ // Leave room for the runner envelope below its 4 MB host-result limit.
20
+ const MAX_APPLY_BRIDGE_BYTES = 3 * 1024 * 1024;
21
+
19
22
  /** Configured IDE services and ordinary tool schemas, shared with the standalone tools. */
20
23
  export interface ApplyServices {
21
24
  readonly editor: TextEditorCore;
@@ -35,7 +38,7 @@ export function createApplyExecution(
35
38
  finish(): Promise<void>;
36
39
  } {
37
40
  const results = new ApplyResults();
38
- const scope = createPostEditScope();
41
+ const scope = createPostEditScope(context.cwd);
39
42
  let lastSource = services.lastResolvedSource;
40
43
  const host: ApplyRuntimeHost = {
41
44
  async execute(operation, arguments_, signal, id) {
@@ -185,7 +188,61 @@ export function createApplyExecution(
185
188
  results.updateFile(file.source, file.before, file.after);
186
189
  lastSource = file.source;
187
190
  }
188
- return response;
191
+ const fullResultBytes = Buffer.byteLength(JSON.stringify(response));
192
+ if (fullResultBytes <= MAX_APPLY_BRIDGE_BYTES) return response;
193
+ const fullResult = await services.read.saveTemporary(JSON.stringify(response, null, 2));
194
+ Object.assign(response, { truncated: true, fullResult, fullResultBytes });
195
+ const reduced = {
196
+ ...response,
197
+ files: response.files.map(({ source, action }) => ({ source, action })),
198
+ truncated: true,
199
+ fullResult,
200
+ };
201
+ if (Buffer.byteLength(JSON.stringify(reduced)) <= MAX_APPLY_BRIDGE_BYTES) {
202
+ return reduced;
203
+ }
204
+ // Keep committed effects readable even when refreshed snapshots are too large.
205
+ const summary = {
206
+ operation: response.operation,
207
+ ok: response.ok,
208
+ effect: response.effect,
209
+ files: reduced.files,
210
+ completed: response.completed,
211
+ transaction: response.transaction,
212
+ errors: response.errors,
213
+ operations: response.operations,
214
+ snapshots: refreshed.map(({ id }) => ({ id, unavailable: true })),
215
+ truncated: true,
216
+ fullResult,
217
+ };
218
+ // Omitted entries remain available in fullResult; never invent effects for them.
219
+ const counts = {
220
+ operationCount: summary.operations?.length ?? 0,
221
+ fileCount: summary.files.length,
222
+ completedCount: summary.completed.length,
223
+ errorCount: summary.errors.length,
224
+ snapshotCount: summary.snapshots.length,
225
+ };
226
+ while (
227
+ Buffer.byteLength(JSON.stringify({ ...summary, ...counts })) > MAX_APPLY_BRIDGE_BYTES
228
+ ) {
229
+ summary.operations = summary.operations?.slice(
230
+ 0,
231
+ Math.floor(summary.operations.length / 2),
232
+ );
233
+ summary.files = summary.files.slice(0, Math.floor(summary.files.length / 2));
234
+ summary.completed = summary.completed.slice(
235
+ 0,
236
+ Math.floor(summary.completed.length / 2),
237
+ );
238
+ summary.errors = summary.errors.slice(0, Math.floor(summary.errors.length / 2));
239
+ summary.snapshots = summary.snapshots.slice(
240
+ 0,
241
+ Math.floor(summary.snapshots.length / 2),
242
+ );
243
+ }
244
+ Object.assign(summary, counts);
245
+ return summary;
189
246
  }
190
247
  if (tool === "editorOpen") {
191
248
  if (!Value.Check(readParameters, arguments_))
@@ -260,12 +317,13 @@ export function createApplyExecution(
260
317
  const searchFailure = outcome.details.failure;
261
318
  const value = {
262
319
  ...outcome.script,
263
- ok: searchFailure === undefined,
320
+ structured: outcome.structuredContent,
321
+ ok: !outcome.isError && searchFailure === undefined,
264
322
  ...(searchFailure && { error: searchFailure }),
265
323
  };
266
324
  results.record(id, kind, value, { content: outcome.content, details: {} });
267
325
  recorded = true;
268
- if (searchFailure !== undefined)
326
+ if (outcome.isError || searchFailure !== undefined)
269
327
  throw failure("SEARCH_FAILED", "Search failed", searchFailure);
270
328
  return value;
271
329
  } catch (error) {
@@ -282,36 +340,39 @@ export function createApplyExecution(
282
340
  host: { ...host, execute: (...args) => scope.run(() => host.execute(...args)) },
283
341
  results,
284
342
  async finish() {
285
- await services.editor.enqueueFileOperation(() =>
286
- scope.finish((outcome) => {
287
- const source = outcome.after.source;
288
- const previous = results.mutationPresentation(source)?.data;
289
- const formatting = outcome.postEditContributions
290
- .map((item) => item.data)
291
- .findLast(isFormattingContribution)?.formatting;
292
- if (
293
- !previous &&
294
- outcome.before.content === outcome.after.content &&
295
- !formatting?.formatter
296
- )
297
- return;
298
- results.updateFile(source, outcome.before.content, outcome.after.content);
299
- results.rememberMutation(
300
- source,
301
- new FileMutationResult({
302
- ok: true,
303
- path: source,
304
- ...previous,
305
- afterContent: outcome.after.content,
306
- afterDocument: outcome.after,
307
- diffStatuses: outcome.postEditContributions
308
- .map((item) => item.data)
309
- .filter(isDiffStatusContribution)
310
- .flatMap((item) => item.diffStatuses),
311
- formatting: formatting ?? { status: "not-reported" },
312
- }),
313
- );
314
- }),
343
+ await services.editor.enqueueFileOperation(
344
+ () =>
345
+ scope.finish((outcome) => {
346
+ const source = outcome.after.source;
347
+ const previous = results.mutationPresentation(source)?.data;
348
+ const formatting = outcome.postEditContributions
349
+ .map((item) => item.data)
350
+ .findLast(isFormattingContribution)?.formatting;
351
+ if (
352
+ !previous &&
353
+ outcome.before.content === outcome.after.content &&
354
+ !formatting?.formatter
355
+ )
356
+ return;
357
+ results.updateFile(source, outcome.before.content, outcome.after.content);
358
+ results.rememberMutation(
359
+ source,
360
+ new FileMutationResult({
361
+ ok: true,
362
+ path: source,
363
+ ...previous,
364
+ afterContent: outcome.after.content,
365
+ afterDocument: outcome.after,
366
+ diffStatuses: outcome.postEditContributions
367
+ .map((item) => item.data)
368
+ .filter(isDiffStatusContribution)
369
+ .flatMap((item) => item.diffStatuses),
370
+ formatting: formatting ?? { status: "not-reported" },
371
+ }),
372
+ );
373
+ }),
374
+ undefined,
375
+ { cwd: context.cwd, sources: scope.sources() },
315
376
  );
316
377
  },
317
378
  };
@@ -119,6 +119,10 @@ export class ApplyResults {
119
119
  this.#files.delete(source);
120
120
  this.#mutationPresentations.delete(source);
121
121
  }
122
+ /** Every recorded operation, including work hidden by final-state presentation. */
123
+ operations(): readonly OperationResult[] {
124
+ return [...this.#operations.values()];
125
+ }
122
126
  /** Selects output without deleting the underlying operation receipts. */
123
127
  select(): SelectedResults {
124
128
  return {
@@ -0,0 +1,251 @@
1
+ import { Type } from "typebox";
2
+ import {
3
+ resultError,
4
+ resultErrorSchema,
5
+ structuredResultSchema,
6
+ withStructuredResult,
7
+ type ResultError,
8
+ } from "pi-agent-resource";
9
+ import { readDataSchema, structuredRead } from "pi-agent-read/api/tools/read";
10
+ import { searchDataSchema } from "pi-agent-search/api/search";
11
+ import { mutationDataSchema } from "#src/core/structured-result.js";
12
+ import { diffDataSchema, isDiffOutcome } from "#src/core/diff-tool.js";
13
+ import type { ApplyResults } from "./results.js";
14
+ import type { ReadPluginApi } from "pi-agent-read/api/plugin-protocol";
15
+ import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
16
+ import { truncateHead } from "@earendil-works/pi-coding-agent";
17
+ const operationSchema = Type.Object(
18
+ {
19
+ id: Type.String(),
20
+ kind: Type.Union([Type.Literal("read"), Type.Literal("mutation")]),
21
+ fullResultBytes: Type.Optional(Type.Integer({ minimum: 0 })),
22
+ fullResult: Type.Optional(Type.String()),
23
+ status: Type.Union([Type.Literal("success"), Type.Literal("error"), Type.Literal("partial")]),
24
+ data: Type.Optional(
25
+ Type.Union([
26
+ readDataSchema,
27
+ searchDataSchema,
28
+ mutationDataSchema,
29
+ diffDataSchema,
30
+ Type.Object({ source: Type.String() }, { additionalProperties: false }),
31
+ ]),
32
+ ),
33
+ errors: Type.Array(resultErrorSchema),
34
+ },
35
+ { additionalProperties: false },
36
+ );
37
+ export const applyDataSchema = Type.Object(
38
+ {
39
+ operations: Type.Array(operationSchema),
40
+ files: Type.Array(Type.String()),
41
+ transactions: Type.Array(Type.String()),
42
+ values: Type.Array(Type.Unknown()),
43
+ truncated: Type.Boolean(),
44
+ fullResult: Type.Optional(Type.String()),
45
+ },
46
+ { additionalProperties: false },
47
+ );
48
+ export const applyOutputSchema = structuredResultSchema(applyDataSchema);
49
+ function record(value: unknown): value is Record<string, unknown> {
50
+ return value !== null && typeof value === "object";
51
+ }
52
+
53
+ /** Project the host ledger, retaining committed receipts while omitting full source snapshots. */
54
+ export async function structuredApply<D>(
55
+ result: AgentToolResult<D>,
56
+ results: ApplyResults,
57
+ read: ReadPluginApi,
58
+ transactions: readonly string[],
59
+ error?: unknown,
60
+ ) {
61
+ const errors: ResultError[] = error === undefined ? [] : [resultError(error, "APPLY_FAILED")];
62
+ const operations = [];
63
+ let applied = false;
64
+ for (const entry of results.operations()) {
65
+ const value = record(entry.value) ? entry.value : {};
66
+ let data: unknown;
67
+ const failures: ResultError[] = [];
68
+ if (entry.kind === "mutation") {
69
+ const effect =
70
+ value.effect === "applied" || value.effect === "not-applied" || value.effect === "unknown"
71
+ ? value.effect
72
+ : "unknown";
73
+ applied ||= effect === "applied";
74
+ const operationErrors = Array.isArray(value.errors) ? value.errors : [];
75
+ for (const error of operationErrors)
76
+ if (record(error))
77
+ failures.push({
78
+ code: typeof error.code === "string" ? error.code : "MUTATION_FAILED",
79
+ message: typeof error.message === "string" ? error.message : "Mutation failed",
80
+ ...(typeof error.source === "string" ? { source: error.source } : {}),
81
+ });
82
+ const perOperation = Array.isArray(value.operations) ? value.operations.filter(record) : [];
83
+ if (
84
+ value.ok === false &&
85
+ failures.length === 0 &&
86
+ (perOperation.length === 0 ||
87
+ perOperation.some(
88
+ (operation) => operation.status !== "applied" && operation.status !== "warning",
89
+ ))
90
+ )
91
+ failures.push(resultError("Mutation did not complete", "MUTATION_FAILED"));
92
+ if (record(value.error))
93
+ failures.push(
94
+ resultError(
95
+ value.error.message,
96
+ typeof value.error.code === "string" ? value.error.code : "MUTATION_FAILED",
97
+ ),
98
+ );
99
+ data = {
100
+ operation: typeof value.operation === "string" ? value.operation : "apply",
101
+ effect,
102
+ files: Array.isArray(value.files)
103
+ ? value.files
104
+ .filter(record)
105
+ .filter((file) => typeof file.source === "string")
106
+ .map((file) => ({ source: file.source, effect: "applied" }))
107
+ : [],
108
+ operations: perOperation.filter(record).map((operation) => ({
109
+ id: `${entry.id}:${String(operation.index)}`,
110
+ operation: String(operation.kind),
111
+ effect: operation.effect,
112
+ status:
113
+ operation.status === "applied"
114
+ ? "success"
115
+ : operation.status === "warning"
116
+ ? "warning"
117
+ : operation.status === "unknown"
118
+ ? "unknown"
119
+ : "error",
120
+ sources: Array.isArray(operation.resources) ? operation.resources : [],
121
+ ...(record(operation.warning)
122
+ ? { warnings: [resultError(operation.warning.message, String(operation.warning.code))] }
123
+ : {}),
124
+ errors: record(operation.error)
125
+ ? [resultError(operation.error.message, String(operation.error.code))]
126
+ : [],
127
+ })),
128
+ ...(typeof value.transaction === "string" ? { transaction: value.transaction } : {}),
129
+ };
130
+ } else if (isDiffOutcome(value)) {
131
+ const diff = truncateHead(value.diff);
132
+ const fullResult = diff.truncated ? await read.saveTemporary(value.diff) : undefined;
133
+ data = {
134
+ kind: "diff",
135
+ equal: value.equal,
136
+ before: { source: value.before.source, sources: value.before.sources },
137
+ after: { source: value.after.source, sources: value.after.sources },
138
+ stats: value.stats,
139
+ diff: diff.content,
140
+ truncated: diff.truncated,
141
+ ...(fullResult === undefined ? {} : { fullResult }),
142
+ };
143
+ } else if (entry.presentation?.script !== undefined || entry.presentation?.isError) {
144
+ const projected = structuredRead(entry.presentation);
145
+ const outcome = projected.structuredContent;
146
+ if (record(outcome)) {
147
+ data = outcome.data;
148
+ if (Array.isArray(outcome.errors))
149
+ for (const error of outcome.errors)
150
+ if (record(error)) failures.push(resultError(error.message, String(error.code)));
151
+ }
152
+ } else if (record(value.structured)) {
153
+ data = value.structured.data;
154
+ if (Array.isArray(value.structured.errors))
155
+ for (const error of value.structured.errors)
156
+ if (record(error)) failures.push(resultError(error.message, String(error.code)));
157
+ } else if (typeof value.source === "string") {
158
+ data = { source: value.source };
159
+ } else if (value.ok === false) {
160
+ failures.push(
161
+ resultError(
162
+ record(value.error) ? value.error.message : "Operation failed",
163
+ "APPLY_OPERATION_FAILED",
164
+ ),
165
+ );
166
+ } else {
167
+ failures.push(resultError("Operation did not report structured data", "UNKNOWN_RESULT"));
168
+ }
169
+ errors.push(...failures);
170
+ operations.push({
171
+ id: entry.id,
172
+ kind: entry.kind,
173
+ ...(typeof value.fullResult === "string" ? { fullResult: value.fullResult } : {}),
174
+ ...(typeof value.fullResultBytes === "number"
175
+ ? { fullResultBytes: value.fullResultBytes }
176
+ : {}),
177
+ status:
178
+ failures.length === 0
179
+ ? "success"
180
+ : entry.kind === "mutation" && value.effect === "applied"
181
+ ? "partial"
182
+ : "error",
183
+ ...(data === undefined ? {} : { data }),
184
+ errors: failures,
185
+ });
186
+ }
187
+ const selected = results.select();
188
+ const status =
189
+ errors.length === 0
190
+ ? "success"
191
+ : applied || operations.some((operation) => operation.status === "success")
192
+ ? "partial"
193
+ : "error";
194
+ const data = {
195
+ operations,
196
+ files: selected.files.map((file) => file.source),
197
+ transactions: [...transactions],
198
+ values: selected.explicit.filter((entry) => entry.kind === "value").map((entry) => entry.value),
199
+ truncated: false,
200
+ };
201
+ if (
202
+ results.mutationValues().some((value) => record(value) && value.truncated === true) ||
203
+ Buffer.byteLength(JSON.stringify(data)) > 512 * 1024
204
+ ) {
205
+ const fullResult = await read.saveTemporary(JSON.stringify(data, null, 2));
206
+ const oversized = Buffer.byteLength(JSON.stringify(data)) > 512 * 1024;
207
+ const withoutReads = operations.map((operation) => {
208
+ if (!oversized || operation.kind === "mutation") return operation;
209
+ const { data: _detail, ...summary } = operation;
210
+ return summary;
211
+ });
212
+ const mutationsOversized = Buffer.byteLength(JSON.stringify(withoutReads)) > 512 * 1024;
213
+ const summaries = withoutReads.map((operation) => {
214
+ if (!mutationsOversized || !("data" in operation)) return operation;
215
+ const { data: detail, ...summary } = operation;
216
+ const value = record(detail) ? detail : undefined;
217
+ return {
218
+ ...summary,
219
+ ...(operation.kind === "mutation" && value !== undefined
220
+ ? {
221
+ data: {
222
+ operation: value.operation,
223
+ effect: value.effect,
224
+ files: value.files,
225
+ ...(typeof value.transaction === "string"
226
+ ? { transaction: value.transaction }
227
+ : {}),
228
+ },
229
+ }
230
+ : {}),
231
+ };
232
+ });
233
+ return withStructuredResult(result, applyDataSchema, {
234
+ status,
235
+ data: {
236
+ operations: summaries,
237
+ files: data.files,
238
+ transactions: data.transactions,
239
+ values: [],
240
+ truncated: true,
241
+ fullResult,
242
+ },
243
+ errors,
244
+ });
245
+ }
246
+ return withStructuredResult(result, applyDataSchema, {
247
+ status,
248
+ data,
249
+ errors,
250
+ });
251
+ }
@@ -1,4 +1,5 @@
1
1
  import { formatApplySource } from "./format-source.js";
2
+ import { applyOutputSchema, structuredApply } from "./structured-result.js";
2
3
  import { applyHelperGuide } from "#src/core/apply/prompt.js";
3
4
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
5
  import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
@@ -11,6 +12,7 @@ import { connectSearchPlugin } from "pi-agent-search/api/connect-plugin";
11
12
  import { SEARCH_API_VERSION, SEARCH_PROTOCOL } from "pi-agent-search/api/plugin-protocol";
12
13
  import type { SearchPluginApi } from "pi-agent-search/api/search";
13
14
  import { Type } from "typebox";
15
+ import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
14
16
  import {
15
17
  getLastResolvedResource,
16
18
  rememberLastResolvedResource,
@@ -48,6 +50,17 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
48
50
  const operations = getApplyOperations();
49
51
  pi.registerTool({
50
52
  name: "apply",
53
+ exposure: "model-only",
54
+ namespace: {
55
+ name: "ide_edit",
56
+ description: "Edit files and live IDE resources with guarded operations.",
57
+ },
58
+ annotations: {
59
+ readOnlyHint: false,
60
+ destructiveHint: true,
61
+ idempotentHint: false,
62
+ openWorldHint: true,
63
+ },
51
64
  label: "Apply",
52
65
  renderShell: "self",
53
66
  renderCall: (args, theme, context) => {
@@ -63,13 +76,14 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
63
76
  description:
64
77
  `Use apply to run read-only IDE operations and snapshot-guarded editor transactions in JavaScript. Output has one 2000-line/50KB budget. No shell, imports or resume.` +
65
78
  applyHelperGuide(),
66
- promptGuidelines: [],
79
+ promptGuidelines: [...EDITING_GUIDELINES],
67
80
  parameters: Type.Object({
68
81
  source: Type.String({
69
82
  description:
70
83
  "JavaScript function body. Call IDE functions directly without await; each call finishes before the next statement. Read-only results are recorded automatically. The UI may compact written tool calls or format a display copy; execution uses this source unchanged.",
71
84
  }),
72
85
  }),
86
+ outputSchema: applyOutputSchema,
73
87
  async execute(_id, { source }, signal, _onUpdate, context) {
74
88
  if (read === undefined || search === undefined)
75
89
  throw new Error("Apply requires the read and search extensions");
@@ -120,18 +134,24 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
120
134
  text: `Undo transaction: ${transaction}`,
121
135
  })),
122
136
  ];
123
- return {
124
- content,
125
- details: {
126
- failed,
127
- displaySource: await displaySource,
128
- outputLevel: output.level,
129
- display: createApplyDisplay(execution.results, output, error, context.cwd),
130
- temporarySource: output.temporarySource,
131
- files: execution.results.select().files.map(({ source: file }) => file),
132
- transactions,
137
+ return structuredApply(
138
+ {
139
+ content,
140
+ details: {
141
+ failed,
142
+ displaySource: await displaySource,
143
+ outputLevel: output.level,
144
+ display: createApplyDisplay(execution.results, output, error, context.cwd),
145
+ temporarySource: output.temporarySource,
146
+ files: execution.results.select().files.map(({ source: file }) => file),
147
+ transactions,
148
+ },
133
149
  },
134
- };
150
+ execution.results,
151
+ read,
152
+ transactions,
153
+ error,
154
+ );
135
155
  },
136
156
  });
137
157
  pi.on("tool_result", (event) => {