pi-agent-ide 0.5.1 → 0.6.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 (454) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +82 -50
  3. package/assets/social-preview.png +0 -0
  4. package/dist/{chunk-LY6U5EAD.js → chunk-2527OQ4Y.js} +1 -1
  5. package/dist/chunk-4KUFOHWP.js +2 -0
  6. package/dist/chunk-4LDOV7QS.js +28 -0
  7. package/dist/chunk-5JELU6RV.js +7 -0
  8. package/dist/chunk-FA6BKC5Y.js +1 -0
  9. package/dist/chunk-FEDVTZJG.js +1 -0
  10. package/dist/chunk-I6Y3W4X6.js +27 -0
  11. package/dist/chunk-K5G4FDXD.js +1 -0
  12. package/dist/chunk-M5IVSCR2.js +1 -0
  13. package/dist/chunk-MPT3R4BL.js +0 -0
  14. package/dist/chunk-PZFOOHY2.js +15 -0
  15. package/dist/chunk-S6QRG3TQ.js +1 -0
  16. package/dist/chunk-T7I2VX3J.js +1 -0
  17. package/dist/chunk-VCTK4JSN.js +3 -0
  18. package/dist/chunk-W7CASEO3.js +1 -0
  19. package/dist/chunk-YEQOQMU7.js +5 -0
  20. package/dist/chunk-YT42LKFV.js +16 -0
  21. package/dist/entry-10.js +1 -1
  22. package/dist/entry-11.js +1 -1
  23. package/dist/entry-12.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-16.js +1 -0
  28. package/dist/entry-17.js +1 -1
  29. package/dist/entry-19.js +1 -1
  30. package/dist/entry-20.js +1 -1
  31. package/dist/entry-21.js +1 -1
  32. package/dist/entry-22.js +1 -2
  33. package/dist/entry-23.js +1 -1
  34. package/dist/entry-24.js +1 -1
  35. package/dist/entry-25.js +2 -1
  36. package/dist/entry-26.js +1 -1
  37. package/dist/entry-27.js +2 -12
  38. package/dist/entry-28.js +1 -1
  39. package/dist/entry-29.js +1 -1
  40. package/dist/entry-30.js +1 -1
  41. package/dist/entry-31.js +12 -1
  42. package/dist/entry-32.js +1 -4
  43. package/dist/entry-33.js +1 -9
  44. package/dist/entry-34.js +1 -1
  45. package/dist/entry-35.js +1 -1
  46. package/dist/entry-36.js +4 -1
  47. package/dist/entry-37.js +9 -1
  48. package/dist/entry-38.js +1 -1
  49. package/dist/entry-39.js +1 -1
  50. package/dist/entry-40.js +1 -1
  51. package/dist/entry-41.js +1 -18
  52. package/dist/entry-42.js +1 -1
  53. package/dist/entry-43.js +1 -1
  54. package/dist/entry-44.js +1 -1
  55. package/dist/entry-45.js +17 -1
  56. package/dist/entry-46.js +1 -7
  57. package/dist/entry-47.js +1 -11
  58. package/dist/entry-48.js +1 -1
  59. package/dist/entry-49.js +1 -1
  60. package/dist/entry-50.js +6 -1
  61. package/dist/entry-51.js +11 -1
  62. package/dist/entry-52.js +1 -1
  63. package/dist/entry-53.js +1 -1
  64. package/dist/entry-54.js +1 -1
  65. package/dist/entry-55.js +1 -1
  66. package/dist/entry-56.js +1 -0
  67. package/dist/entry-57.js +1 -1
  68. package/dist/entry-58.js +1 -0
  69. package/dist/entry-59.js +1 -1
  70. package/dist/entry-60.js +0 -1
  71. package/dist/entry-61.js +1 -1
  72. package/dist/entry-62.js +0 -1
  73. package/dist/entry-63.js +1 -1
  74. package/dist/entry-64.js +1 -1
  75. package/dist/entry-65.js +1 -0
  76. package/dist/entry-66.js +1 -1
  77. package/dist/entry-67.js +1 -0
  78. package/dist/entry-68.js +1 -1
  79. package/dist/entry-69.js +0 -1
  80. package/dist/entry-70.js +1 -1
  81. package/dist/entry-71.js +0 -203
  82. package/dist/entry-72.js +1 -30
  83. package/dist/entry-73.js +1 -2
  84. package/dist/entry-74.js +1 -1
  85. package/dist/entry-75.js +315 -1
  86. package/dist/entry-76.js +30 -3
  87. package/dist/entry-77.js +2 -3
  88. package/dist/entry-78.js +1 -1
  89. package/dist/entry-79.js +1 -1
  90. package/dist/entry-80.js +3 -1
  91. package/dist/entry-81.js +3 -0
  92. package/dist/entry-82.js +1 -0
  93. package/dist/entry-83.js +1 -0
  94. package/dist/entry-84.js +1 -0
  95. package/dist/entry-9.js +1 -1
  96. package/dist/pi-agent-ide.js +3 -3
  97. package/docs/agent-guides/apply.md +333 -0
  98. package/docs/agent-guides/debugger.md +5 -0
  99. package/docs/agent-guides/diagnostics.md +5 -0
  100. package/docs/agent-guides/editing.md +44 -0
  101. package/docs/agent-guides/git-changes.md +5 -0
  102. package/docs/agent-guides/json-reading.md +41 -0
  103. package/docs/agent-guides/read-resources.md +44 -0
  104. package/docs/agent-guides/search-code.md +29 -0
  105. package/docs/agent-guides/terminal.md +7 -0
  106. package/docs/agent-guides/vision.md +5 -0
  107. package/docs/configuration.md +9 -15
  108. package/docs/research/apply-read-latency.md +219 -0
  109. package/docs/tools.md +12 -0
  110. package/node_modules/pi-agent-doctor/package.json +6 -6
  111. package/node_modules/pi-agent-doctor/runtime/entry-22.js +1 -0
  112. package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
  113. package/node_modules/pi-agent-documentation/package.json +15 -0
  114. package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
  115. package/node_modules/pi-agent-documentation/src/index.ts +69 -0
  116. package/node_modules/pi-agent-filesystem/index.ts +0 -4
  117. package/node_modules/pi-agent-filesystem/package.json +7 -7
  118. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  119. package/node_modules/pi-agent-filesystem-image/runtime/entry-26.js +2 -0
  120. package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
  121. package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
  122. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
  123. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  124. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
  125. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  126. package/node_modules/pi-agent-ide-ast/package.json +12 -11
  127. package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  128. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +8 -6
  129. package/node_modules/pi-agent-ide-changes/index.ts +8 -0
  130. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  131. package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  132. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  133. package/node_modules/pi-agent-ide-formatter/runtime/entry-34.js +2 -0
  134. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
  135. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  136. package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  137. package/node_modules/pi-agent-ide-lint/index.ts +1 -1
  138. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  139. package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  140. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +20 -2
  141. package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
  142. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  143. package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  144. package/node_modules/pi-agent-image/package.json +3 -3
  145. package/node_modules/pi-agent-invariant/package.json +2 -2
  146. package/node_modules/pi-agent-pdf/package.json +3 -3
  147. package/node_modules/pi-agent-read/package.json +12 -11
  148. package/node_modules/pi-agent-read/runtime/entry-41.js +0 -1
  149. package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
  150. package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -4
  151. package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
  152. package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
  153. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  154. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +29 -17
  155. package/node_modules/pi-agent-resource/package.json +2 -2
  156. package/node_modules/pi-agent-resource/runtime/entry-46.js +1 -0
  157. package/node_modules/pi-agent-search/package.json +8 -7
  158. package/node_modules/pi-agent-search/runtime/entry-47.js +1 -0
  159. package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
  160. package/node_modules/pi-agent-search-text/package.json +9 -9
  161. package/node_modules/pi-agent-search-text/runtime/entry-51.js +2 -0
  162. package/node_modules/pi-agent-search-text/runtime/entry-52.js +1 -0
  163. package/node_modules/pi-agent-text/package.json +3 -3
  164. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  165. package/node_modules/pi-agent-text-anchor-exact/index.ts +3 -3
  166. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  167. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
  168. package/node_modules/pi-agent-text-anchor-exact/src/config.ts +2 -2
  169. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  170. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
  171. package/node_modules/pi-agent-text-editor/index.ts +15 -0
  172. package/node_modules/pi-agent-text-editor/package.json +26 -25
  173. package/node_modules/pi-agent-text-editor/runtime/entry-71.js +0 -1
  174. package/node_modules/pi-agent-text-editor/runtime/entry-72.js +1 -0
  175. package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
  176. package/node_modules/pi-agent-text-editor/runtime/entry-75.js +2 -0
  177. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +131 -3
  178. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
  179. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
  180. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +36 -5
  181. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
  182. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
  183. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
  184. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
  185. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
  186. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  187. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  188. package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
  189. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
  190. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
  191. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
  192. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  193. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
  195. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
  196. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
  197. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
  198. package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
  199. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  200. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  201. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  202. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  203. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  204. package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +1 -0
  205. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  206. package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +1 -0
  207. package/node_modules/pi-agent-web/package.json +7 -7
  208. package/node_modules/pi-agent-web-html/package.json +3 -3
  209. package/node_modules/pi-agent-web-html/runtime/entry-81.js +2 -0
  210. package/node_modules/pi-agent-web-image/package.json +4 -4
  211. package/node_modules/pi-agent-web-image/runtime/entry-82.js +2 -0
  212. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  213. package/node_modules/pi-agent-web-pdf/runtime/entry-83.js +2 -0
  214. package/node_modules/pi-agent-web-text/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/runtime/entry-84.js +2 -0
  216. package/package.json +112 -43
  217. package/src/api/documentation.ts +2 -0
  218. package/src/api/path-identity.ts +15 -0
  219. package/src/composite/builtin-extensions.ts +14 -2
  220. package/src/composite/extensions-config.ts +6 -0
  221. package/src/composite/module-labels.ts +9 -0
  222. package/src/composite/module-settings-store.ts +3 -0
  223. package/src/composite/module-settings.ts +71 -17
  224. package/src/composite/preferences.ts +83 -3
  225. package/src/composite/presentation.ts +14 -0
  226. package/src/composite/presets.ts +57 -0
  227. package/src/composite/selection.ts +5 -1
  228. package/src/doctor/inventory.ts +7 -2
  229. package/src/documentation/extension.ts +295 -0
  230. package/src/documentation/registry.ts +98 -0
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-26.js +2 -0
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-81.js +2 -0
  247. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +2 -0
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-83.js +2 -0
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-84.js +2 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +2 -0
  254. package/src/extensions/pi-agent-read/package.json +12 -11
  255. package/src/extensions/pi-agent-read/runtime/entry-41.js +0 -1
  256. package/src/extensions/pi-agent-read/runtime/entry-42.js +1 -0
  257. package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
  258. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -4
  259. package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
  260. package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
  261. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  262. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +29 -17
  263. package/src/extensions/pi-agent-search/package.json +8 -7
  264. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  265. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-51.js +2 -0
  266. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +1 -0
  267. package/src/extensions/pi-agent-search/runtime/entry-47.js +1 -0
  268. package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
  269. package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
  270. package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
  271. package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
  272. package/src/extensions/pi-agent-text-editor/index.ts +15 -0
  273. package/src/extensions/pi-agent-text-editor/package.json +26 -25
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +3 -3
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  277. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +1 -0
  278. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-56.js +2 -0
  279. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/config.ts +2 -2
  280. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  281. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-57.js +1 -0
  282. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-58.js +2 -0
  283. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
  284. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-77.js +2 -0
  289. package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +0 -1
  290. package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +1 -0
  291. package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
  292. package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
  293. package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +2 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +131 -3
  295. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +1 -1
  296. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +14 -0
  297. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +36 -5
  298. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -42
  299. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +50 -5
  300. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +187 -38
  301. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +3 -8
  302. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +770 -237
  303. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  304. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  305. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
  306. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +5 -0
  307. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +4 -4
  308. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +9 -1
  309. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  310. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +53 -0
  311. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +11 -41
  312. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +8 -18
  313. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +11 -41
  314. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -19
  315. package/src/pi-agent-ide.ts +21 -11
  316. package/src/plugins/pi-agent-ide-ast/package.json +12 -11
  317. package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  318. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +8 -6
  319. package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
  320. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  321. package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  322. package/src/plugins/pi-agent-ide-debugger/index.ts +13 -11
  323. package/src/plugins/pi-agent-ide-debugger/src/adapter-executables.ts +31 -0
  324. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +3 -1
  325. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +24 -23
  326. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -2
  327. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +55 -17
  328. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -22
  329. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
  330. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  331. package/src/plugins/pi-agent-ide-formatter/runtime/entry-34.js +2 -0
  332. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +1 -1
  333. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  334. package/src/plugins/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  335. package/src/plugins/pi-agent-ide-lint/index.ts +1 -1
  336. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  337. package/src/plugins/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  338. package/src/plugins/pi-agent-ide-lint/src/command-linter.ts +20 -2
  339. package/src/plugins/pi-agent-ide-lsp/index.ts +0 -3
  340. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  341. package/src/plugins/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  342. package/src/plugins/pi-agent-ide-processes/src/registry.ts +4 -0
  343. package/src/plugins/pi-agent-ide-processes/src/ui.ts +18 -9
  344. package/src/plugins/pi-agent-ide-terminal/index.ts +27 -2
  345. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +1 -0
  346. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
  347. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +1 -4
  348. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  349. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
  350. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +8 -5
  351. package/src/plugins/pi-agent-ide-terminal/src/types.ts +1 -0
  352. package/src/plugins/pi-agent-ide-vision/index.ts +234 -0
  353. package/src/plugins/pi-agent-ide-vision/src/vision.ts +530 -0
  354. package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +30 -0
  355. package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +33 -0
  356. package/dist/chunk-526E364R.js +0 -3
  357. package/dist/chunk-5PLV4HLG.js +0 -1
  358. package/dist/chunk-7ALCBKCW.js +0 -26
  359. package/dist/chunk-DQXPQOF7.js +0 -2
  360. package/dist/chunk-EJ5OACQM.js +0 -1
  361. package/dist/chunk-G725MARR.js +0 -16
  362. package/dist/chunk-HKXDP2FD.js +0 -7
  363. package/dist/chunk-IRECDTJG.js +0 -27
  364. package/dist/chunk-J4RTW44E.js +0 -1
  365. package/dist/chunk-NZYDMBM6.js +0 -1
  366. package/dist/chunk-WGGIQ7IJ.js +0 -1
  367. package/dist/entry-18.js +0 -1
  368. package/node_modules/pi-agent-doctor/runtime/entry-17.js +0 -1
  369. package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
  370. package/node_modules/pi-agent-filesystem/runtime/entry-22.js +0 -2
  371. package/node_modules/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
  372. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
  373. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  374. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  375. package/node_modules/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
  376. package/node_modules/pi-agent-ide-lint/runtime/entry-32.js +0 -2
  377. package/node_modules/pi-agent-image/runtime/entry-34.js +0 -1
  378. package/node_modules/pi-agent-invariant/runtime/entry-35.js +0 -1
  379. package/node_modules/pi-agent-pdf/runtime/entry-36.js +0 -1
  380. package/node_modules/pi-agent-read/runtime/entry-37.js +0 -1
  381. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  382. package/node_modules/pi-agent-search/runtime/entry-46.js +0 -2
  383. package/node_modules/pi-agent-search-text/runtime/entry-47.js +0 -2
  384. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  385. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -2
  386. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
  387. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
  388. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
  389. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
  390. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  391. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  392. package/node_modules/pi-agent-web-image/runtime/entry-78.js +0 -2
  393. package/node_modules/pi-agent-web-pdf/runtime/entry-79.js +0 -2
  394. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-23.js +0 -2
  395. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-24.js +0 -2
  396. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +0 -2
  397. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +0 -2
  398. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-77.js +0 -2
  399. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-78.js +0 -2
  400. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-79.js +0 -2
  401. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  402. package/src/extensions/pi-agent-read/runtime/entry-37.js +0 -1
  403. package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
  404. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  405. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  406. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +0 -2
  407. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -1
  408. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  409. package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -2
  410. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +0 -2
  411. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  412. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +0 -2
  413. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  414. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-72.js +0 -2
  415. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
  416. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  417. package/src/extensions/pi-agent-text-editor/runtime/entry-55.js +0 -1
  418. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
  419. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
  420. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
  421. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  422. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -2
  423. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  424. package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -2
  425. package/src/plugins/pi-agent-ide-formatter/runtime/entry-30.js +0 -2
  426. package/src/plugins/pi-agent-ide-lint/runtime/entry-32.js +0 -2
  427. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem}/runtime/entry-25.js +0 -0
  428. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-jq}/runtime/entry-27.js +0 -0
  429. /package/node_modules/{pi-agent-ide-changes → pi-agent-filesystem-text}/runtime/entry-29.js +0 -0
  430. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  431. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  432. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
  433. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
  434. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
  435. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-42.js +0 -0
  436. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-43.js +0 -0
  437. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  438. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-48.js +0 -0
  439. /package/node_modules/{pi-agent-text → pi-agent-search}/runtime/entry-49.js +0 -0
  440. /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search}/runtime/entry-50.js +0 -0
  441. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text}/runtime/entry-53.js +0 -0
  442. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
  443. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-55.js +0 -0
  444. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-57.js +0 -0
  445. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-74.js +0 -0
  446. /package/node_modules/{pi-agent-web → pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
  447. /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-stale-anchor}/runtime/entry-77.js +0 -0
  448. /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-80.js +0 -0
  449. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-43.js +0 -0
  450. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  451. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-constant}/runtime/entry-54.js +0 -0
  452. /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-renderer}/runtime/entry-76.js +0 -0
  453. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  454. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  } from "pi-agent-tool-call-interception";
8
8
  import { singleLine, type ToolCallHeaderDetail } from "pi-agent-tool-ui";
9
9
  import { NEXT_TOOL_CALL_DRAIN_MS, type MutationAnimationPressure } from "./animation-pressure.js";
10
- import { loadRendererConfig } from "./config.js";
10
+
11
11
  import { freezeMutationViewports, type FrozenMutationViewports } from "./frozen-viewport.js";
12
12
  import { MutationPanel } from "./mutation-panel.js";
13
13
  import {
@@ -21,12 +21,15 @@ import { TYPING_FRAME_INTERVAL_MS, TypingInterpolation } from "./typing-interpol
21
21
 
22
22
  import type { MutationRenderResource } from "./render-resource.js";
23
23
  import type { Theme } from "@earendil-works/pi-coding-agent";
24
+
24
25
  import type { TextMutationPreviewResource } from "pi-agent-text-editor/api/mutation-preview";
25
26
  import type { FileMutationBatchResult } from "pi-agent-text-editor/api/mutation-result";
26
27
  import type { AnyTextMutationToolRegistration } from "pi-agent-text-editor/api/mutation-tool";
27
28
  import type { TextEditorPluginApi } from "pi-agent-text-editor/api/plugin-protocol";
28
29
  import type { TextEditorToolRendererRegistration } from "pi-agent-text-editor/api/tool-renderer";
29
30
 
31
+ type ToolPresentation = "full" | "compact" | "disabled";
32
+
30
33
  type MutationRenderOutcome =
31
34
  | { readonly kind: "completed"; readonly resources: readonly MutationRenderResource[] }
32
35
  | { readonly kind: "failed"; readonly reason: string };
@@ -68,6 +71,7 @@ interface RenderState {
68
71
  theme?: Theme;
69
72
  cwd?: string;
70
73
  expanded?: boolean;
74
+ presentation?: ToolPresentation;
71
75
  invalidate?: () => void;
72
76
  latestGenerated?: string;
73
77
  typing?: TypingInterpolation;
@@ -89,9 +93,12 @@ export function registerMutationRenderers(
89
93
  api: TextEditorPluginApi,
90
94
  animationPressure?: MutationAnimationPressure,
91
95
  animationsEnabled: () => boolean = () => true,
96
+ presentation: ToolPresentation = "compact",
92
97
  ): void {
93
98
  api.onMutationTool((registration) => {
94
- api.addToolRenderer(createRenderer(api, registration, animationPressure, animationsEnabled));
99
+ api.addToolRenderer(
100
+ createRenderer(api, registration, animationPressure, animationsEnabled, presentation),
101
+ );
95
102
  });
96
103
  }
97
104
 
@@ -100,6 +107,7 @@ function createRenderer(
100
107
  registration: AnyTextMutationToolRegistration,
101
108
  animationPressure: MutationAnimationPressure | undefined,
102
109
  animationsEnabled: () => boolean,
110
+ presentation: ToolPresentation,
103
111
  ): TextEditorToolRendererRegistration {
104
112
  const tool = registration.name;
105
113
 
@@ -118,7 +126,10 @@ function createRenderer(
118
126
  state.invalidate = context.invalidate;
119
127
  // renderCall runs on every frame, so reapply the project's viewport policy each time.
120
128
  state.cwd = context.cwd;
121
- component.setExpanded(context.expanded || preferFullDiff(context.cwd));
129
+ const mode = context.expanded ? "full" : presentation;
130
+ state.presentation = presentation;
131
+ component.setExpanded(mode === "full");
132
+ component.setDiffsVisible(mode !== "disabled");
122
133
  state.expanded = context.expanded;
123
134
 
124
135
  component.setResourceLabelsVisible(
@@ -208,6 +219,10 @@ function createRenderer(
208
219
  state.invalidate = context.invalidate;
209
220
 
210
221
  state.expanded = options.expanded;
222
+ state.presentation = presentation;
223
+ const mode = options.expanded ? "full" : presentation;
224
+ state.panel?.setExpanded(mode === "full");
225
+ state.panel?.setDiffsVisible(mode !== "disabled");
211
226
 
212
227
  state.panel?.setBackground(context.isError ? "toolErrorBg" : "toolSuccessBg");
213
228
  cancelPreviewWorker(state);
@@ -301,18 +316,6 @@ function createRenderer(
301
316
  };
302
317
  }
303
318
 
304
- const diffViewCache = new Map<string, boolean>();
305
-
306
- /** Returns whether diffs should render fully by default for the given project. */
307
- function preferFullDiff(cwd: string): boolean {
308
- let preferFull = diffViewCache.get(cwd);
309
- if (preferFull === undefined) {
310
- preferFull = loadRendererConfig(cwd).diffView === "full";
311
- diffViewCache.set(cwd, preferFull);
312
- }
313
- return preferFull;
314
- }
315
-
316
319
  function panel(previous: unknown, theme: Theme, ownsShell: boolean): MutationPanel {
317
320
  const component =
318
321
  previous instanceof MutationPanel ? previous : new MutationPanel(theme, ownsShell);
@@ -626,7 +629,9 @@ function applyResultResources(
626
629
  expanded,
627
630
  );
628
631
  state.panel?.setResultResources(stableResources);
629
- state.panel?.setExpanded(expanded || preferFullDiff(state.cwd ?? process.cwd()));
632
+ const mode = expanded ? "full" : (state.presentation ?? "compact");
633
+ state.panel?.setExpanded(mode === "full");
634
+ state.panel?.setDiffsVisible(mode !== "disabled");
630
635
  clearTypingRuntime(state);
631
636
  }
632
637
 
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-stale-anchor",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-invariant": "0.5.1",
7
- "pi-agent-read": "0.5.1",
8
- "pi-agent-text-editor": "0.5.1"
6
+ "pi-agent-invariant": "0.6.1",
7
+ "pi-agent-read": "0.6.1",
8
+ "pi-agent-text-editor": "0.6.1"
9
9
  },
10
10
  "pi": {
11
11
  "extensions": [
12
- "./runtime/entry-73.js"
12
+ "./runtime/entry-77.js"
13
13
  ]
14
14
  },
15
15
  "peerDependencies": {
@@ -0,0 +1,2 @@
1
+ export * from "../../../../../../dist/entry-77.js";
2
+ export { default } from "../../../../../../dist/entry-77.js";
@@ -1,2 +1 @@
1
1
  export * from "../../../../dist/entry-71.js";
2
- export { default } from "../../../../dist/entry-71.js";
@@ -0,0 +1 @@
1
+ export * from "../../../../dist/entry-72.js";
@@ -0,0 +1 @@
1
+ export * from "../../../../dist/entry-73.js";
@@ -0,0 +1 @@
1
+ export * from "../../../../dist/entry-74.js";
@@ -0,0 +1,2 @@
1
+ export * from "../../../../dist/entry-75.js";
2
+ export { default } from "../../../../dist/entry-75.js";
@@ -10,7 +10,11 @@ import { Value } from "typebox/value";
10
10
  import type { TextEditorCore } from "#src/core/text-editor-core.js";
11
11
  import { ApplyResults } from "#src/core/apply/results.js";
12
12
  import { serializeApplyError, type ApplyRuntimeHost } from "#src/core/apply/runtime.js";
13
- import { executeEditorTransaction } from "#src/core/apply/transaction.js";
13
+ import { executeEditorTransaction, type EditorSnapshot } from "#src/core/apply/transaction.js";
14
+ import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
15
+ import { TextAnchorResolutionError } from "#src/core/text-anchor-registry.js";
16
+ import { buildFailedTextMutationResult } from "#src/core/text-mutation.js";
17
+ import { TextMutationAnchorResolutionError } from "#src/core/text-mutation-anchor-error.js";
14
18
 
15
19
  /** Configured IDE services and ordinary tool schemas, shared with the standalone tools. */
16
20
  export interface ApplyServices {
@@ -41,6 +45,91 @@ export function createApplyExecution(
41
45
  ? "read"
42
46
  : "mutation";
43
47
  let recorded = false;
48
+ const resolveMutationTarget = async (): Promise<unknown> => {
49
+ const request = arguments_ as {
50
+ snapshot?: { id?: unknown; source?: unknown; content?: unknown };
51
+ query?: unknown;
52
+ };
53
+ const snapshot = request.snapshot;
54
+ const content = snapshot?.content;
55
+ if (
56
+ snapshot === undefined ||
57
+ typeof snapshot.id !== "string" ||
58
+ typeof snapshot.source !== "string" ||
59
+ typeof content !== "string" ||
60
+ typeof request.query !== "string"
61
+ )
62
+ throw failure("INVALID_ARGUMENTS", "Invalid mutation-target resolution request");
63
+ let anchor;
64
+ try {
65
+ anchor = await services.editor.resolveAnchorInText({
66
+ source: snapshot.source,
67
+ content,
68
+ value: request.query,
69
+ cwd: context.cwd,
70
+ signal,
71
+ });
72
+ } catch (error) {
73
+ if (!(error instanceof TextAnchorResolutionError)) throw error;
74
+ const cause = new TextMutationAnchorResolutionError(
75
+ "apply",
76
+ "target",
77
+ snapshot.source,
78
+ request.query,
79
+ error,
80
+ );
81
+ const presentation = await buildFailedTextMutationResult(
82
+ services.editor,
83
+ { code: "RESOLVE_FAILED", source: snapshot.source, message: error.message, cause },
84
+ { ...context, signal },
85
+ );
86
+ return {
87
+ selections: [],
88
+ warning: {
89
+ code: "EMPTY_SELECTION",
90
+ message: presentation.content
91
+ .filter((block) => block.type === "text")
92
+ .map((block) => block.text)
93
+ .join("\n"),
94
+ presentation: {
95
+ anchorRecoveries: presentation.details.anchorRecoveries,
96
+ },
97
+ },
98
+ };
99
+ }
100
+ const starts = lineStarts(content);
101
+ if (!TextSelectionAnchor.is(anchor)) {
102
+ const from = starts[anchor.lineNumber - 1];
103
+ if (from === undefined)
104
+ throw failure("INVALID_SELECTION", "Anchor line is outside the opened snapshot");
105
+ const to = starts[anchor.lineNumber] ?? content.length;
106
+ return {
107
+ selections: [
108
+ {
109
+ document: snapshot.id,
110
+ from,
111
+ to,
112
+ text: content.slice(from, to),
113
+ linewise: true,
114
+ },
115
+ ],
116
+ };
117
+ }
118
+ return {
119
+ selections: anchor.ranges.map((range) => {
120
+ const from = positionOffset(starts, range.start.lineNumber, range.start.column);
121
+ const to = positionOffset(starts, range.end.lineNumber, range.end.column);
122
+ return {
123
+ document: snapshot.id,
124
+ from,
125
+ to,
126
+ text: content.slice(from, to),
127
+ ...(range.linewise === true && { linewise: true }),
128
+ };
129
+ }),
130
+ };
131
+ };
132
+ if (tool === "editorResolve") return await resolveMutationTarget();
44
133
  try {
45
134
  if (tool === "editorApply") {
46
135
  let value;
@@ -61,13 +150,42 @@ export function createApplyExecution(
61
150
  if (typeof source === "string") scope.forget(source);
62
151
  throw error;
63
152
  }
64
- results.record(id, "mutation", value);
153
+ const requestedSnapshots =
154
+ (arguments_ as { snapshots?: readonly EditorSnapshot[] }).snapshots ?? [];
155
+ const changedSources = new Set([
156
+ ...value.files.map((file) => file.source),
157
+ ...value.completed,
158
+ ]);
159
+ const refreshed = await Promise.all(
160
+ requestedSnapshots
161
+ .filter((snapshot) => changedSources.has(snapshot.source))
162
+ .map(async (snapshot) => {
163
+ const outcome = await services.read.read(
164
+ { path: snapshot.source },
165
+ { cwd: context.cwd, signal },
166
+ "script",
167
+ );
168
+ const script = outcome.script;
169
+ return !outcome.isError &&
170
+ script?.kind === "text" &&
171
+ typeof script.content === "string"
172
+ ? {
173
+ id: snapshot.id,
174
+ source: outcome.details.source ?? script.source,
175
+ content: script.content,
176
+ lines: script.lines,
177
+ }
178
+ : { id: snapshot.id, unavailable: true };
179
+ }),
180
+ );
181
+ const response = { ...value, snapshots: refreshed };
182
+ results.record(id, "mutation", response);
65
183
  recorded = true;
66
184
  for (const file of value.files) {
67
185
  results.updateFile(file.source, file.before, file.after);
68
186
  lastSource = file.source;
69
187
  }
70
- return value;
188
+ return response;
71
189
  }
72
190
  if (tool === "editorOpen") {
73
191
  if (!Value.Check(readParameters, arguments_))
@@ -199,6 +317,16 @@ export function createApplyExecution(
199
317
  };
200
318
  }
201
319
 
320
+ function lineStarts(content: string): number[] {
321
+ const starts = [0];
322
+ for (let index = 0; index < content.length; index += 1)
323
+ if (content[index] === "\n") starts.push(index + 1);
324
+ return starts;
325
+ }
326
+ function positionOffset(starts: readonly number[], line: number, column: number): number {
327
+ return (starts[line - 1] ?? 0) + column;
328
+ }
329
+
202
330
  function failure(code: string, message: string, details?: unknown): Error {
203
331
  return Object.assign(new Error(message), { code, details });
204
332
  }
@@ -10,7 +10,7 @@ const helpers = new Set([
10
10
  "deleteFile",
11
11
  "copyFile",
12
12
  "moveFile",
13
- "apply",
13
+ "flush",
14
14
  "result",
15
15
  ]);
16
16
 
@@ -28,6 +28,20 @@ export interface ScriptMutationOutcome {
28
28
  readonly effect: "not-applied" | "applied" | "unknown";
29
29
  readonly files: readonly ScriptMutationFile[];
30
30
  readonly completed: readonly string[];
31
+ /** Per-operation outcomes in staging order for Apply transactions. */
32
+ readonly operations?: readonly {
33
+ readonly index: number;
34
+ readonly kind: string;
35
+ readonly status: "applied" | "warning" | "failed" | "unknown" | "blocked";
36
+ readonly effect: "not-applied" | "applied" | "unknown";
37
+ readonly resources: readonly string[];
38
+ readonly error?: { readonly code: string; readonly message: string };
39
+ readonly warning?: {
40
+ readonly code: string;
41
+ readonly message: string;
42
+ readonly presentation?: unknown;
43
+ };
44
+ }[];
31
45
  /** Session-scoped receipt accepted by undo. */
32
46
  readonly transaction?: string;
33
47
  readonly recoveries?: readonly ScriptAnchorRecovery[];
@@ -18,6 +18,7 @@ export interface ApplyOutput {
18
18
  readonly content: Content;
19
19
  readonly level: "full" | "compact" | "summary";
20
20
  readonly temporarySource?: string;
21
+ readonly mutations?: ReturnType<typeof finalApplyMutations>;
21
22
  }
22
23
 
23
24
  /** Presents net file effects once, preserving native images and one combined text budget. */
@@ -42,6 +43,7 @@ export async function renderApplyOutput(
42
43
  for (const operation of selected.automatic) {
43
44
  if (
44
45
  operation.kind === "read" ||
46
+ hasOperationWarnings(operation.value) ||
45
47
  isFailure(operation.value) ||
46
48
  (operation.value !== null &&
47
49
  typeof operation.value === "object" &&
@@ -74,7 +76,7 @@ export async function renderApplyOutput(
74
76
  if (error !== undefined) content.push(text(formatError(error)));
75
77
  if (content.length === 0) content.push(text("No operations or explicit results."));
76
78
  const full = textContent(content);
77
- if (!truncateHead(full).truncated) return { content, level: "full" };
79
+ if (!truncateHead(full).truncated) return { content, level: "full", mutations: finalMutations };
78
80
  const temporarySource = await read.saveTemporary(full);
79
81
  const footer = `\n\nFull Apply output: ${temporarySource}. Read this reference with offset/limit for more.`;
80
82
  if (read.reduceOutput !== undefined && !context.signal?.aborted) {
@@ -101,7 +103,7 @@ export async function renderApplyOutput(
101
103
  compact.push(...content.slice(suffixStart));
102
104
  compact.push(text(footer.trimStart()));
103
105
  if (!truncateHead(textContent(compact)).truncated)
104
- return { content: compact, level: "compact", temporarySource };
106
+ return { content: compact, level: "compact", temporarySource, mutations: finalMutations };
105
107
  }
106
108
  const summary = [
107
109
  `Apply output reduced: ${selected.automatic.length} automatic results, ${selected.explicit.length} explicit results, ${selected.files.length} final files.`,
@@ -119,6 +121,7 @@ export async function renderApplyOutput(
119
121
  content: [text(bounded + footer), ...content.filter((block) => block.type === "image")],
120
122
  level: "summary",
121
123
  temporarySource,
124
+ mutations: finalMutations,
122
125
  };
123
126
  }
124
127
 
@@ -140,6 +143,18 @@ function expandReadSection(section: {
140
143
  ? resources.flatMap((read) => expandReadSection({ content: read.content, read }))
141
144
  : [section];
142
145
  }
146
+ function hasOperationWarnings(value: unknown): boolean {
147
+ return (
148
+ value !== null &&
149
+ typeof value === "object" &&
150
+ "operations" in value &&
151
+ Array.isArray(value.operations) &&
152
+ (value.operations as unknown[]).some(
153
+ (item) =>
154
+ item !== null && typeof item === "object" && "status" in item && item.status === "warning",
155
+ )
156
+ );
157
+ }
143
158
  function isFailure(value: unknown): boolean {
144
159
  return value !== null && typeof value === "object" && "ok" in value && value.ok === false;
145
160
  }
@@ -153,7 +168,7 @@ function formatApplyFailure(code: string, message: string): string {
153
168
  NOT_FOUND:
154
169
  "The requested text or selection was not found. Read the current file and select existing text.",
155
170
  AMBIGUOUS_MATCH:
156
- "The selection matched more than once. Use a larger unique fragment or findAll().",
171
+ "The selection matched more than once. Use a larger unique fragment or a current candidate anchor.",
157
172
  STALE_EDITOR:
158
173
  "This editor handle was already committed. Open the file again before staging more changes.",
159
174
  STALE_SELECTION:
@@ -190,12 +205,14 @@ function renderValue(value: unknown): Content {
190
205
  typeof value.operation === "string"
191
206
  ) {
192
207
  const lines = [
193
- `${value.operation}: ${"effect" in value ? String(value.effect) : isFailure(value) ? "failed" : "completed"}`,
208
+ `${value.operation}: ${isFailure(value) && "effect" in value && value.effect === "applied" ? "partially applied" : "effect" in value ? String(value.effect) : isFailure(value) ? "failed" : "completed"}`,
194
209
  ];
195
210
  if ("path" in value && typeof value.path === "string") lines.push(value.path);
196
211
  if ("target" in value && typeof value.target === "string")
197
212
  lines.push(`Target: ${value.target}`);
198
- if ("errors" in value && Array.isArray(value.errors))
213
+ if ("operations" in value && Array.isArray(value.operations))
214
+ lines.push(...value.operations.map(formatOperationOutcome));
215
+ else if ("errors" in value && Array.isArray(value.errors))
199
216
  lines.push(...value.errors.map(formatReceiptError));
200
217
  if ("error" in value) lines.push(formatReceiptError(value.error));
201
218
  if (
@@ -236,6 +253,20 @@ function asReadResult(value: unknown): ReadToolResult | undefined {
236
253
  return { content: renderValue(value), details: value as ReadResultDetails };
237
254
  }
238
255
 
256
+ function formatOperationOutcome(value: unknown): string {
257
+ if (value === null || typeof value !== "object") return String(value);
258
+ const index = "index" in value ? Number(value.index) + 1 : "?";
259
+ const kind = "kind" in value ? String(value.kind) : "operation";
260
+ const status = "status" in value ? String(value.status) : "unknown";
261
+ const detail =
262
+ "warning" in value
263
+ ? ` — ${formatReceiptError(value.warning)}`
264
+ : "error" in value
265
+ ? ` — ${formatReceiptError(value.error)}`
266
+ : "";
267
+ return `${index}. ${kind}: ${status}${detail}`;
268
+ }
269
+
239
270
  function formatReceiptError(value: unknown): string {
240
271
  if (value === null || typeof value !== "object") return String(value);
241
272
  const source = "source" in value ? String(value.source) : undefined;
@@ -1,50 +1,13 @@
1
1
  const editorGuide = `
2
- Read-only helpers (same arguments as standalone tools):
3
- read({path, offset?, limit?, views?})
4
- search({query, path?, include?, exclude?, caseSensitive?, wholeWord?, limit?})
5
- diff({before, after})
6
- result(value)
2
+ Read-only helpers use the standalone-tool arguments: read({...}), search({...}), and diff({before, after}). Their results are recorded automatically.
7
3
 
8
- Transactional editor:
9
- const file = open(path | {path, views?})
10
- file.source; file.content; file.lines
11
- file.find(text) // exactly one match or an error
12
- file.findAll(text) // stable selections from the original snapshot
13
- file.select(searchMatch) // text, regex, or AST search match
14
- file.between(start, end, {inside?: boolean})
15
- file.line(first, last?)
16
- file.replace(selection, text)
17
- file.remove(selection)
18
- file.insertBefore(selection, text)
19
- file.insertAfter(selection, text)
20
- file.replaceAll(text, replacement)
21
- createFile(path, content)
22
- deleteFile(path)
23
- copyFile(path, target, {overwrite?: boolean})
24
- moveFile(path, target, {overwrite?: boolean})
25
- apply()
4
+ Transactional helpers:
5
+ open(path | {path, views?}); file.find(text); file.select(searchMatch); file.between(start, end, {inside?, lines?}); file.line(first, last?); file.start(); file.end(); file.before(selection); file.after(selection); file.slice(selection, start?, end?); file.union(...selections); file.within(candidates, scopes); file.linesOf(selection); file.replace(selection, text); file.remove(selection); file.insertBefore(selection, text); file.insertAfter(selection, text); file.flush(); file.delete(); replace(selection, text); remove(selection); insertBefore(selection, text); insertAfter(selection, text); copy(source, destination); move(source, destination); createFile(path, content); deleteFile(path); copyFile(path, target, {overwrite?}); moveFile(path, target, {overwrite?}); flush().
26
6
 
27
- open() returns an immutable snapshot. Selection methods produce snapshot-bound ranges. Mutation methods only stage changes; they do not modify files. All selections in one transaction refer to the original snapshots, so earlier staged edits never shift later selections. Missing or ambiguous exact matches and overlapping selections reject the transaction.
28
-
29
- Call apply() explicitly to validate and commit all staged text and file operations together. One transaction may affect several files. A successful commit returns a session-scoped APPLY# receipt; pass it to undo({ transaction: "APPLY#..." }) before any touched path changes to restore the whole transaction. After a successful apply(), old editor handles are stale; call open() again for another transaction. A script may commit several transactions, and later reads observe earlier commits. Staged operations left without apply() do not change files and are reported as uncommitted.
30
-
31
- Before each commit the host verifies snapshots, resource types, ranges, overlaps, source existence, and destination conflicts. A preflight failure changes nothing. If execution fails after writing begins, the host restores captured resources and reports whether rollback completed. Do not describe an incomplete rollback as atomic success.
32
-
33
- Use find() for one expected occurrence, findAll()/replaceAll() for intentional repeated edits, between() for a uniquely delimited block, and line() only when line identity is genuinely part of the task. Generate replacement text with ordinary JavaScript, but never rebuild and submit a complete existing file.
34
-
35
- Example:
36
- const config = open("src/config.ts");
37
- const test = open("tests/config.test.ts");
38
- config.replace(config.find("legacyMode"), "stableMode");
39
- test.replaceAll("legacyMode", "stableMode");
40
- apply();
41
-
42
- Read accepts file paths, URLs, temp/search/debug/shell/diagnostics/symbol/graph resources, and supported views. Search accepts literal, regex:, files:, ast:, and symbols: queries. File changes and read-only calls are shown automatically. Use result(value) only to expose additional calculated data; do not call it merely to display committed changes.
43
-
44
- Do not retry by guessing argument names. Inspect structured error codes such as NOT_FOUND, AMBIGUOUS_MATCH, STALE_SNAPSHOT, INVALID_TRANSACTION, and TRANSACTION_FAILED.
7
+ Selections are immutable and snapshot-bound. Use slice to select occurrences by position, union to combine non-overlapping sets, within to keep candidates contained by scopes, and linesOf to expand matches to whole lines. between accepts strings or SelectionSets as either boundary; {lines:true} expands through both containing lines. Prefer it for blocks identified by content; use line(first,last) only for exact verified line bounds. Use start/end or before/after as zero-width destinations when copy or move should insert instead of replace. Normal completion commits staged operations once; a thrown script commits none. flush() commits every staged operation; file.flush() commits only independent operations for that file while cross-file transfers stay pending. Successful checkpoints can return an APPLY# receipt. Failed operations report structured errors and do not silently guess a recovery.
45
8
  `;
46
9
 
47
- /** Agent-facing guide for the guarded Apply editor. */
10
+ /** Compact callable contract for the guarded Apply editor. */
48
11
  export function applyHelperGuide(): string {
49
12
  return editorGuide;
50
13
  }
@@ -12,6 +12,7 @@ import { preserveEnclosingBackground } from "pi-agent-tool-ui";
12
12
  import type { ApplyResults } from "./results.js";
13
13
  import type { ApplyOutput } from "./output.js";
14
14
 
15
+ type ToolPresentation = "full" | "compact" | "disabled";
15
16
  /** Deliberate user presentation, separate from model-facing operation receipts. */
16
17
  export interface ApplyDisplay {
17
18
  readonly blocks: readonly { readonly text: string; readonly read?: ReadToolResult }[];
@@ -62,7 +63,7 @@ export function createApplyDisplay(
62
63
  ],
63
64
  };
64
65
  }
65
- const mutations = finalApplyMutations(results);
66
+ const mutations = output.mutations ?? finalApplyMutations(results);
66
67
  return {
67
68
  ...(mutations.length > 0 ? { mutations: { results: mutations } } : {}),
68
69
  comparisons,
@@ -110,6 +111,31 @@ export function createApplyDisplay(
110
111
  !Array.isArray(value.errors)
111
112
  )
112
113
  return [];
114
+ if ("operations" in value && Array.isArray(value.operations)) {
115
+ const completed = value.operations.filter(
116
+ (operation: unknown) =>
117
+ operation !== null &&
118
+ typeof operation === "object" &&
119
+ "status" in operation &&
120
+ operation.status === "applied",
121
+ ).length;
122
+ if (completed === value.operations.length) return [];
123
+ const outcomes = value.operations
124
+ .filter(
125
+ (operation: unknown) =>
126
+ operation !== null &&
127
+ typeof operation === "object" &&
128
+ "status" in operation &&
129
+ operation.status !== "applied",
130
+ )
131
+ .map((operation: unknown) => ({ text: formatDisplayOutcome(operation) }));
132
+ return [
133
+ {
134
+ text: `Apply partially applied: ${completed} of ${value.operations.length} operations completed.`,
135
+ },
136
+ ...outcomes,
137
+ ];
138
+ }
113
139
  return value.errors.flatMap((error: unknown) =>
114
140
  error !== null &&
115
141
  typeof error === "object" &&
@@ -129,7 +155,7 @@ export function createApplyDisplay(
129
155
  type RenderState = {
130
156
  applyResultReady?: boolean;
131
157
  displaySource?: string;
132
- codeView?: boolean;
158
+
133
159
  projectSource?: (source: string) => string;
134
160
  };
135
161
 
@@ -185,8 +211,11 @@ export function applyFrameRows(
185
211
  /** Compose compact written calls with a pure configured tool header renderer. */
186
212
  export function createApplyCallRenderer(
187
213
  renderWritten?: (call: ApplyCallPreview, theme: Theme) => string,
214
+ presentation: ToolPresentation = "compact",
188
215
  ): NonNullable<ToolDefinition["renderCall"]> {
189
216
  return (args, theme, context) => {
217
+ if (!context.expanded && presentation === "disabled")
218
+ return new Text(theme.fg("toolTitle", "apply"), 0, 0);
190
219
  const state = context.state as RenderState;
191
220
  const projectSource = (state.projectSource ??= createApplySourceProjection(
192
221
  renderWritten ? (call) => renderWritten(call, theme) : undefined,
@@ -203,14 +232,16 @@ export function createApplyCallRenderer(
203
232
  invalidate() {},
204
233
  render(width) {
205
234
  return applyFrameRows(
206
- state.codeView || context.expanded
235
+ context.expanded || presentation === "full"
207
236
  ? (state.displaySource ?? source)
208
- : compactApplyPreview(projectSource(state.displaySource ?? source)),
237
+ : presentation === "disabled"
238
+ ? ""
239
+ : compactApplyPreview(projectSource(state.displaySource ?? source)),
209
240
  theme,
210
241
  width,
211
242
  "call",
212
243
  !state.applyResultReady,
213
- state.codeView || context.expanded || !renderWritten ? "javascript" : undefined,
244
+ context.expanded || presentation === "full" || !renderWritten ? "javascript" : undefined,
214
245
  );
215
246
  },
216
247
  };
@@ -303,6 +334,8 @@ export function createApplyResultRenderer(
303
334
  const rows = mutationPanel.render(Math.max(1, width - 4));
304
335
  if (body.length > 0 && rows.length > 0) body.push("");
305
336
  body.push(...rows);
337
+ if (rows.length === 0)
338
+ body.push(...(mutations?.results ?? []).map((file) => file.path ?? "Changed file"));
306
339
  } else if (mutations !== undefined)
307
340
  body.push(...(mutations.results ?? []).map((file) => file.path ?? "Changed file"));
308
341
  if (
@@ -329,6 +362,18 @@ export function createApplyResultRenderer(
329
362
  };
330
363
  }
331
364
 
365
+ function formatDisplayOutcome(value: unknown): string {
366
+ if (value === null || typeof value !== "object") return String(value);
367
+ const index = "index" in value ? Number(value.index) + 1 : "?";
368
+ const kind = "kind" in value ? String(value.kind) : "operation";
369
+ const status = "status" in value ? String(value.status) : "unknown";
370
+ const error =
371
+ "error" in value && value.error !== null && typeof value.error === "object"
372
+ ? `: ${"code" in value.error ? String(value.error.code) : "ERROR"}: ${"message" in value.error ? String(value.error.message) : "Operation failed"}`
373
+ : "";
374
+ return `Operation ${index} (${kind}): ${status}${error}`;
375
+ }
376
+
332
377
  function redactApplyReceipts(text: string): string {
333
378
  if (/^(?:Undo transaction:|Undo available)/u.test(text.trim())) return "";
334
379
  try {