pi-agent-ide 0.6.0 → 0.6.2

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 (448) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +146 -68
  3. package/assets/social-preview.png +0 -0
  4. package/assets/summary/debugging.png +0 -0
  5. package/assets/summary/editing.png +0 -0
  6. package/assets/summary/read.png +0 -0
  7. package/assets/summary/search-and-replace.png +0 -0
  8. package/assets/summary/search.png +0 -0
  9. package/assets/summary/settings.png +0 -0
  10. package/assets/summary/terminal.png +0 -0
  11. package/assets/summary/thumbs/debugging.png +0 -0
  12. package/assets/summary/thumbs/editing.png +0 -0
  13. package/assets/summary/thumbs/read.png +0 -0
  14. package/assets/summary/thumbs/search-and-replace.png +0 -0
  15. package/assets/summary/thumbs/search.png +0 -0
  16. package/assets/summary/thumbs/settings.png +0 -0
  17. package/assets/summary/thumbs/terminal.png +0 -0
  18. package/assets/summary/thumbs/user_terminal.png +0 -0
  19. package/assets/summary/user_terminal.png +0 -0
  20. package/dist/chunk-3E2NTWCN.js +2 -0
  21. package/dist/chunk-7WCZOO5I.js +1 -0
  22. package/dist/chunk-CEX3VOJ7.js +2 -0
  23. package/dist/chunk-FA6BKC5Y.js +1 -0
  24. package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
  25. package/dist/chunk-LVWMWWWF.js +28 -0
  26. package/dist/chunk-MPT3R4BL.js +0 -0
  27. package/dist/chunk-PZFOOHY2.js +15 -0
  28. package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
  29. package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
  30. package/dist/{chunk-OYWIZII6.js → chunk-S6QRG3TQ.js} +1 -1
  31. package/dist/chunk-T7CZIACQ.js +27 -0
  32. package/dist/chunk-T7I2VX3J.js +1 -0
  33. package/dist/chunk-VCTK4JSN.js +3 -0
  34. package/dist/chunk-VXD6FZP5.js +5 -0
  35. package/dist/chunk-W7CASEO3.js +1 -0
  36. package/dist/chunk-YT42LKFV.js +16 -0
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-11.js +1 -1
  40. package/dist/entry-12.js +1 -1
  41. package/dist/entry-13.js +1 -1
  42. package/dist/entry-14.js +1 -1
  43. package/dist/entry-15.js +1 -1
  44. package/dist/entry-16.js +1 -1
  45. package/dist/entry-17.js +1 -0
  46. package/dist/entry-19.js +1 -1
  47. package/dist/entry-2.js +1 -1
  48. package/dist/entry-20.js +1 -1
  49. package/dist/entry-21.js +1 -1
  50. package/dist/entry-22.js +1 -1
  51. package/dist/entry-23.js +1 -2
  52. package/dist/entry-24.js +1 -1
  53. package/dist/entry-25.js +2 -1
  54. package/dist/entry-26.js +1 -1
  55. package/dist/entry-27.js +2 -1
  56. package/dist/entry-28.js +1 -12
  57. package/dist/entry-29.js +1 -1
  58. package/dist/entry-30.js +1 -1
  59. package/dist/entry-31.js +13 -1
  60. package/dist/entry-32.js +1 -1
  61. package/dist/entry-33.js +1 -4
  62. package/dist/entry-34.js +1 -9
  63. package/dist/entry-35.js +1 -1
  64. package/dist/entry-36.js +4 -1
  65. package/dist/entry-37.js +9 -1
  66. package/dist/entry-38.js +1 -1
  67. package/dist/entry-39.js +1 -1
  68. package/dist/entry-40.js +1 -1
  69. package/dist/entry-41.js +1 -1
  70. package/dist/entry-42.js +1 -18
  71. package/dist/entry-43.js +1 -1
  72. package/dist/entry-44.js +1 -1
  73. package/dist/entry-45.js +17 -1
  74. package/dist/entry-46.js +1 -1
  75. package/dist/entry-47.js +1 -7
  76. package/dist/entry-48.js +1 -11
  77. package/dist/entry-49.js +1 -1
  78. package/dist/entry-50.js +6 -1
  79. package/dist/entry-51.js +10 -1
  80. package/dist/entry-52.js +1 -1
  81. package/dist/entry-53.js +1 -1
  82. package/dist/entry-54.js +1 -1
  83. package/dist/entry-55.js +1 -1
  84. package/dist/entry-56.js +1 -1
  85. package/dist/entry-57.js +1 -0
  86. package/dist/entry-58.js +1 -1
  87. package/dist/entry-59.js +1 -0
  88. package/dist/entry-60.js +1 -1
  89. package/dist/entry-61.js +1 -1
  90. package/dist/entry-62.js +0 -1
  91. package/dist/entry-63.js +1 -1
  92. package/dist/entry-64.js +0 -1
  93. package/dist/entry-65.js +1 -1
  94. package/dist/entry-66.js +1 -0
  95. package/dist/entry-67.js +1 -1
  96. package/dist/entry-68.js +1 -0
  97. package/dist/entry-69.js +1 -1
  98. package/dist/entry-70.js +1 -1
  99. package/dist/entry-71.js +0 -1
  100. package/dist/entry-72.js +1 -259
  101. package/dist/entry-73.js +0 -30
  102. package/dist/entry-74.js +1 -2
  103. package/dist/entry-75.js +1 -1
  104. package/dist/entry-76.js +1 -1
  105. package/dist/entry-77.js +315 -3
  106. package/dist/entry-78.js +30 -3
  107. package/dist/entry-79.js +2 -1
  108. package/dist/entry-80.js +1 -1
  109. package/dist/entry-81.js +1 -1
  110. package/dist/entry-82.js +3 -0
  111. package/dist/entry-83.js +3 -0
  112. package/dist/entry-84.js +1 -0
  113. package/dist/entry-85.js +1 -0
  114. package/dist/entry-86.js +1 -0
  115. package/dist/entry-9.js +1 -1
  116. package/dist/pi-agent-ide.js +3 -3
  117. package/docs/agent-guides/apply.md +333 -0
  118. package/docs/agent-guides/debugger.md +5 -0
  119. package/docs/agent-guides/diagnostics.md +5 -0
  120. package/docs/agent-guides/editing.md +44 -0
  121. package/docs/agent-guides/git-changes.md +5 -0
  122. package/docs/agent-guides/json-reading.md +41 -0
  123. package/docs/agent-guides/read-resources.md +44 -0
  124. package/docs/agent-guides/search-code.md +29 -0
  125. package/docs/agent-guides/terminal.md +7 -0
  126. package/docs/agent-guides/vision.md +5 -0
  127. package/docs/configuration.md +6 -14
  128. package/docs/research/apply-read-latency.md +219 -0
  129. package/node_modules/pi-agent-doctor/package.json +6 -6
  130. package/node_modules/pi-agent-doctor/runtime/entry-23.js +1 -0
  131. package/node_modules/pi-agent-documentation/package.json +15 -0
  132. package/node_modules/pi-agent-documentation/runtime/entry-24.js +1 -0
  133. package/node_modules/pi-agent-documentation/src/index.ts +69 -0
  134. package/node_modules/pi-agent-filesystem/index.ts +0 -4
  135. package/node_modules/pi-agent-filesystem/package.json +7 -7
  136. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  137. package/node_modules/pi-agent-filesystem-jq/index.ts +134 -0
  138. package/node_modules/pi-agent-filesystem-jq/package.json +23 -0
  139. package/node_modules/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  140. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +107 -0
  141. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  142. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  143. package/node_modules/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  144. package/node_modules/pi-agent-ide-ast/package.json +12 -11
  145. package/node_modules/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  146. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  147. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  148. package/node_modules/pi-agent-ide-changes/index.ts +8 -0
  149. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  150. package/node_modules/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  151. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  152. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +1 -1
  153. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  154. package/node_modules/pi-agent-ide-languages/runtime/entry-35.js +2 -0
  155. package/node_modules/pi-agent-ide-lint/index.ts +1 -1
  156. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  157. package/node_modules/pi-agent-ide-lint/runtime/entry-36.js +2 -0
  158. package/node_modules/pi-agent-ide-lint/src/command-linter.ts +17 -1
  159. package/node_modules/pi-agent-ide-lsp/index.ts +0 -3
  160. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  161. package/node_modules/pi-agent-ide-lsp/runtime/entry-37.js +2 -0
  162. package/node_modules/pi-agent-image/package.json +3 -3
  163. package/node_modules/pi-agent-invariant/package.json +2 -2
  164. package/node_modules/pi-agent-pdf/package.json +3 -3
  165. package/node_modules/pi-agent-read/package.json +12 -11
  166. package/node_modules/pi-agent-read/runtime/entry-42.js +0 -1
  167. package/node_modules/pi-agent-read/runtime/entry-45.js +2 -0
  168. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  169. package/node_modules/pi-agent-read/src/core/extension.ts +16 -2
  170. package/node_modules/pi-agent-read/src/core/read-core.ts +4 -5
  171. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  172. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  173. package/node_modules/pi-agent-resource/package.json +2 -2
  174. package/node_modules/pi-agent-search/package.json +8 -7
  175. package/node_modules/pi-agent-search/runtime/entry-47.js +0 -1
  176. package/node_modules/pi-agent-search/runtime/entry-48.js +1 -0
  177. package/node_modules/pi-agent-search/runtime/entry-50.js +2 -0
  178. package/node_modules/pi-agent-search/src/core/extension.ts +29 -10
  179. package/node_modules/pi-agent-search-text/package.json +17 -9
  180. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  181. package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
  182. package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
  183. package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
  184. package/node_modules/pi-agent-text/package.json +3 -3
  185. package/node_modules/pi-agent-text/runtime/entry-55.js +1 -0
  186. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  187. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  188. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  189. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  190. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  191. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  192. package/node_modules/pi-agent-text-editor/index.ts +15 -0
  193. package/node_modules/pi-agent-text-editor/package.json +26 -25
  194. package/node_modules/pi-agent-text-editor/runtime/entry-72.js +0 -1
  195. package/node_modules/pi-agent-text-editor/runtime/entry-73.js +1 -0
  196. package/node_modules/pi-agent-text-editor/runtime/entry-74.js +1 -0
  197. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  198. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  199. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  200. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  201. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  202. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  203. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  204. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  205. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  206. package/node_modules/pi-agent-text-editor/src/core/extension.ts +0 -11
  207. package/node_modules/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  208. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  209. package/node_modules/pi-agent-text-editor-renderer/index.ts +17 -4
  210. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  211. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  212. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  213. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  214. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  215. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  216. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  217. package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
  218. package/node_modules/pi-agent-web/package.json +7 -7
  219. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  220. package/node_modules/pi-agent-web-html/package.json +3 -3
  221. package/node_modules/pi-agent-web-html/runtime/entry-83.js +2 -0
  222. package/node_modules/pi-agent-web-image/package.json +4 -4
  223. package/node_modules/pi-agent-web-image/runtime/entry-84.js +2 -0
  224. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  225. package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  226. package/node_modules/pi-agent-web-text/package.json +4 -4
  227. package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
  228. package/package.json +108 -44
  229. package/src/api/documentation.ts +2 -0
  230. package/src/api/plugin-protocol.ts +10 -4
  231. package/src/composite/builtin-extensions.ts +7 -0
  232. package/src/composite/extensions-config.ts +6 -0
  233. package/src/composite/module-labels.ts +5 -0
  234. package/src/composite/module-settings-store.ts +3 -0
  235. package/src/composite/module-settings.ts +39 -5
  236. package/src/composite/preferences.ts +37 -0
  237. package/src/composite/presentation.ts +14 -0
  238. package/src/composite/presets.ts +57 -0
  239. package/src/documentation/extension.ts +295 -0
  240. package/src/documentation/registry.ts +98 -0
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +0 -4
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +134 -0
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +23 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-27.js +2 -0
  247. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +107 -0
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-28.js +2 -0
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-29.js +2 -0
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-25.js +2 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  256. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  257. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-84.js +2 -0
  258. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  259. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  260. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  261. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-86.js +2 -0
  262. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  263. package/src/extensions/pi-agent-read/package.json +12 -11
  264. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  265. package/src/extensions/pi-agent-read/runtime/entry-43.js +1 -0
  266. package/src/extensions/pi-agent-read/runtime/entry-45.js +2 -0
  267. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  268. package/src/extensions/pi-agent-read/src/core/extension.ts +16 -2
  269. package/src/extensions/pi-agent-read/src/core/read-core.ts +4 -5
  270. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +62 -8
  271. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +19 -12
  272. package/src/extensions/pi-agent-search/package.json +8 -7
  273. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -9
  274. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  275. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
  276. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
  277. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
  278. package/src/extensions/pi-agent-search/runtime/entry-47.js +0 -1
  279. package/src/extensions/pi-agent-search/runtime/entry-48.js +1 -0
  280. package/src/extensions/pi-agent-search/runtime/entry-49.js +1 -0
  281. package/src/extensions/pi-agent-search/runtime/entry-50.js +2 -0
  282. package/src/extensions/pi-agent-search/src/core/extension.ts +29 -10
  283. package/src/extensions/pi-agent-text-editor/index.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/package.json +26 -25
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-56.js +2 -0
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-57.js +1 -0
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +2 -0
  290. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  291. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +1 -0
  292. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  293. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +17 -4
  294. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  295. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  296. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +23 -11
  297. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +21 -16
  298. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  299. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
  300. package/src/extensions/pi-agent-text-editor/runtime/entry-72.js +0 -1
  301. package/src/extensions/pi-agent-text-editor/runtime/entry-73.js +1 -0
  302. package/src/extensions/pi-agent-text-editor/runtime/entry-74.js +1 -0
  303. package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +1 -0
  304. package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
  305. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +2 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +24 -18
  307. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +4 -2
  308. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +5 -44
  309. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +13 -5
  310. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +124 -26
  311. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +2 -6
  312. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +186 -1
  313. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +2 -2
  315. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +0 -11
  316. package/src/extensions/pi-agent-text-editor/src/core/text-editor-config.ts +1 -1
  317. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +0 -2
  318. package/src/pi-agent-ide.ts +7 -10
  319. package/src/plugins/pi-agent-ide-ast/package.json +12 -11
  320. package/src/plugins/pi-agent-ide-ast/runtime/entry-30.js +1 -0
  321. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  322. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  323. package/src/plugins/pi-agent-ide-changes/index.ts +8 -0
  324. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  325. package/src/plugins/pi-agent-ide-changes/runtime/entry-32.js +1 -0
  326. package/src/plugins/pi-agent-ide-debugger/index.ts +44 -14
  327. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
  328. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
  329. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
  330. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +9 -4
  331. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  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 +17 -1
  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-terminal/index.ts +27 -2
  343. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +27 -2
  344. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +88 -12
  345. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
  346. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  347. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +7 -4
  348. package/src/plugins/pi-agent-ide-vision/index.ts +10 -7
  349. package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
  350. package/assets/gallery/apply-editing.png +0 -0
  351. package/assets/gallery/debugging.png +0 -0
  352. package/assets/gallery/read-web.png +0 -0
  353. package/assets/gallery/search-replace.png +0 -0
  354. package/assets/gallery/terminal.png +0 -0
  355. package/assets/gallery/tool-editing.png +0 -0
  356. package/dist/chunk-22CLOM2D.js +0 -1
  357. package/dist/chunk-3XJ3KDPZ.js +0 -16
  358. package/dist/chunk-526E364R.js +0 -3
  359. package/dist/chunk-DDKHZZDO.js +0 -5
  360. package/dist/chunk-EJ5OACQM.js +0 -1
  361. package/dist/chunk-HSM6R7IB.js +0 -27
  362. package/dist/chunk-PCZH7GOX.js +0 -26
  363. package/dist/chunk-SQ7ZTGOP.js +0 -2
  364. package/dist/entry-18.js +0 -1
  365. package/node_modules/pi-agent-doctor/runtime/entry-18.js +0 -1
  366. package/node_modules/pi-agent-filesystem/runtime/entry-23.js +0 -2
  367. package/node_modules/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  368. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  369. package/node_modules/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  370. package/node_modules/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  371. package/node_modules/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  372. package/node_modules/pi-agent-image/runtime/entry-35.js +0 -1
  373. package/node_modules/pi-agent-invariant/runtime/entry-36.js +0 -1
  374. package/node_modules/pi-agent-pdf/runtime/entry-37.js +0 -1
  375. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  376. package/node_modules/pi-agent-search-text/runtime/entry-48.js +0 -2
  377. package/node_modules/pi-agent-text/runtime/entry-50.js +0 -1
  378. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  379. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  380. package/node_modules/pi-agent-text-editor/runtime/entry-56.js +0 -1
  381. package/node_modules/pi-agent-text-editor/runtime/entry-58.js +0 -1
  382. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +0 -1
  383. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  384. package/node_modules/pi-agent-text-editor-renderer/src/config.ts +0 -73
  385. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  386. package/node_modules/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  387. package/node_modules/pi-agent-web-text/runtime/entry-81.js +0 -2
  388. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-24.js +0 -2
  389. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-25.js +0 -2
  390. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-23.js +0 -2
  391. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-78.js +0 -2
  392. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-79.js +0 -2
  393. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-80.js +0 -2
  394. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-81.js +0 -2
  395. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-77.js +0 -2
  396. package/src/extensions/pi-agent-read/runtime/entry-38.js +0 -1
  397. package/src/extensions/pi-agent-read/runtime/entry-39.js +0 -1
  398. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  399. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +0 -2
  400. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-49.js +0 -1
  401. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  402. package/src/extensions/pi-agent-search/runtime/entry-46.js +0 -1
  403. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-53.js +0 -2
  404. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-55.js +0 -2
  405. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-73.js +0 -2
  406. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/config.ts +0 -73
  407. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-74.js +0 -2
  408. package/src/extensions/pi-agent-text-editor/runtime/entry-56.js +0 -1
  409. package/src/extensions/pi-agent-text-editor/runtime/entry-57.js +0 -1
  410. package/src/extensions/pi-agent-text-editor/runtime/entry-58.js +0 -1
  411. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
  412. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +0 -1
  413. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +0 -1
  414. package/src/plugins/pi-agent-ide-ast/runtime/entry-28.js +0 -2
  415. package/src/plugins/pi-agent-ide-changes/runtime/entry-29.js +0 -1
  416. package/src/plugins/pi-agent-ide-changes/runtime/entry-30.js +0 -2
  417. package/src/plugins/pi-agent-ide-languages/runtime/entry-32.js +0 -2
  418. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-25.js +0 -0
  419. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  420. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-28.js +0 -0
  421. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  422. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  423. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
  424. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-38.js +0 -0
  425. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-39.js +0 -0
  426. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-40.js +0 -0
  427. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-43.js +0 -0
  428. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  429. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-46.js +0 -0
  430. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-49.js +0 -0
  431. /package/node_modules/{pi-agent-text-anchor-constant → pi-agent-search-text}/runtime/entry-51.js +0 -0
  432. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-52.js +0 -0
  433. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-search-text}/runtime/entry-54.js +0 -0
  434. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
  435. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
  436. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-text-editor}/runtime/entry-75.js +0 -0
  437. /package/node_modules/{pi-agent-tool-ui → pi-agent-text-editor}/runtime/entry-76.js +0 -0
  438. /package/node_modules/{pi-agent-web → pi-agent-text-editor}/runtime/entry-77.js +0 -0
  439. /package/node_modules/{pi-agent-web-html → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  440. /package/node_modules/{pi-agent-web-image → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  441. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-26.js +0 -0
  442. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-44.js +0 -0
  443. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-constant → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-51.js +0 -0
  444. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-52.js +0 -0
  445. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-54.js +0 -0
  446. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-31.js +0 -0
  447. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-33.js +0 -0
  448. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-34.js +0 -0
@@ -111,6 +111,10 @@ function applyGuestErrorCode(message: string): string {
111
111
  if (message === "No matches") return "NOT_FOUND";
112
112
  if (message === "Search match is stale") return "STALE_SELECTION";
113
113
  if (message === "Editor handle belongs to a committed transaction") return "STALE_EDITOR";
114
+ if (message === "union() selections overlap" || message === "Expected a SelectionSet")
115
+ return "INVALID_SELECTION";
116
+ if (message === "SelectionSet belongs to another file") return "CROSS_FILE_SELECTION";
117
+ if (message === "SelectionSet belongs to a stale snapshot") return "STALE_SELECTION";
114
118
  if (/^(?:Invalid line range|Line range is outside document)$/u.test(message))
115
119
  return "INVALID_SELECTION";
116
120
  return "RUN_USER_SOURCE_ERROR";
@@ -119,12 +123,12 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
119
123
  const readOperations = enabledOperations.filter(
120
124
  (name) => name === "read" || name === "search" || name === "diff",
121
125
  );
122
- return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile, copy, move, flush, result, __finishApplyScript } = (() => {
123
- const origins = new WeakMap();
126
+ return `const { ${readOperations.join(", ")}, open, createFile, deleteFile, copyFile, moveFile, replace, remove, insertBefore, insertAfter, copy, move, flush, __finishApplyScript } = (() => {
127
+
124
128
  const invoke = (name, args) => {
125
129
  const response = __apply[name](args);
126
130
  if (!response.ok) throw Object.assign(new Error(response.error.message), response.error);
127
- if (response.value !== null && typeof response.value === "object") origins.set(response.value, response.id);
131
+
128
132
  return response.value;
129
133
  };
130
134
  let snapshots = new Map();
@@ -144,6 +148,23 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
144
148
  for (let from = content.indexOf(needle); from >= 0; from = content.indexOf(needle, from + needle.length)) found.push(from);
145
149
  return found;
146
150
  };
151
+ const selectionError = (code, message) => Object.assign(new Error(message), {code});
152
+ const assertSet = (document, set) => {
153
+ if (!Array.isArray(set)) throw selectionError("INVALID_SELECTION", "Expected a SelectionSet");
154
+ if (set.document !== document.id) throw selectionError("CROSS_FILE_SELECTION", "SelectionSet belongs to another file");
155
+ if (set.generation !== document.generation) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale snapshot");
156
+ return set;
157
+ };
158
+ const boundarySet = (document, value) => {
159
+ if (typeof value !== "string") return assertSet(document, value);
160
+ const ranges = occurrences(document.content, value).map((from) => ({from, to: from + value.length}));
161
+ return selectionSet(document, ranges, {kind: "exact", query: value});
162
+ };
163
+ const lineRange = (document, item) => {
164
+ const from = document.content.lastIndexOf("\\n", Math.max(0, item.from - 1)) + 1;
165
+ const newline = document.content.indexOf("\\n", Math.max(item.from, item.to - 1));
166
+ return {from, to: newline < 0 ? document.content.length : newline + 1, linewise: true};
167
+ };
147
168
  const targetSet = (document, target) => {
148
169
  if (typeof target !== "string") return target;
149
170
  const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: target});
@@ -175,6 +196,47 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
175
196
  if (empty !== undefined) { operations.push({kind:"warning", document:empty.document, query:empty.provenance?.query, warning:empty.provenance?.warning}); return; }
176
197
  operations.push({kind, sources:[...source], destinations:[...destination], text:source.map((item) => item.text).join("")});
177
198
  };
199
+ const stageSet = (target, text, edge) => {
200
+ const document = snapshots.get(target?.document);
201
+ if (document === undefined) throw selectionError("STALE_SELECTION", "SelectionSet belongs to a stale or unopened snapshot");
202
+ stage(document, target, text, edge);
203
+ };
204
+ const refreshSnapshots = (value) => {
205
+ for (const refreshed of value?.snapshots ?? []) {
206
+ const document = snapshots.get(refreshed.id);
207
+ if (document !== undefined && refreshed.unavailable === true) snapshots.delete(refreshed.id);
208
+ else if (document !== undefined) {
209
+ document.source = refreshed.source;
210
+ document.content = refreshed.content;
211
+ document.lines = refreshed.lines;
212
+ document.generation += 1;
213
+ }
214
+ }
215
+ };
216
+ const commit = (selected) => {
217
+ if (selected.length === 0) return undefined;
218
+ const value = invoke("editorApply", {snapshots: [...snapshots.values()].map(({id, source, content}) => ({id, source, content})), operations: selected});
219
+ refreshSnapshots(value);
220
+ return value;
221
+ };
222
+ const flushDocument = (document) => {
223
+ assertCurrent(document);
224
+ const participatesInTransfer = operations.some((operation) =>
225
+ (operation.kind === "text-copy" || operation.kind === "text-move") &&
226
+ [...operation.sources, ...operation.destinations].some((item) => item.document === document.id));
227
+ if (participatesInTransfer) return undefined;
228
+ const selected = [];
229
+ const remaining = [];
230
+ for (const operation of operations) {
231
+ const belongs =
232
+ (operation.kind === "replace" && operation.selection.document === document.id) ||
233
+ (operation.kind === "warning" && operation.document === document.id) ||
234
+ (operation.kind === "delete" && operation.path === document.source);
235
+ (belongs ? selected : remaining).push(operation);
236
+ }
237
+ operations = remaining;
238
+ return commit(selected);
239
+ };
178
240
  const makeDocument = (snapshot) => {
179
241
  const document = {id: snapshot.id, source: snapshot.source, content: snapshot.content, lines: snapshot.lines, generation: 0};
180
242
  snapshots.set(document.id, document);
@@ -185,19 +247,56 @@ function guestBindings(enabledOperations: readonly ApplyOperation[]): string {
185
247
  find: (text) => { assertCurrent(document); const ranges = occurrences(document.content, text).map((from) => ({from, to: from + text.length})); if (ranges.length > 0) return selectionSet(document, ranges, {kind: "exact", query: text}); const resolved = invoke("editorResolve", {snapshot: {id: document.id, source: document.source, content: document.content}, query: text}); return selectionSet(document, [], {kind: "exact", query: text, warning: resolved.warning}); },
186
248
  between: (start, end, options = {}) => {
187
249
  assertCurrent(document);
250
+ if (options.inside === true && options.lines === true) throw selectionError("INVALID_SELECTION", "between() cannot combine inside and lines");
251
+ const starts = boundarySet(document, start);
252
+ const ends = boundarySet(document, end);
188
253
  const ranges = [];
189
254
  let cursor = 0;
190
- while (cursor <= document.content.length) {
191
- const from = document.content.indexOf(start, cursor);
192
- if (from < 0) break;
193
- const endFrom = document.content.indexOf(end, from + start.length);
194
- if (endFrom < 0) break;
195
- ranges.push({from: options.inside === true ? from + start.length : from, to: options.inside === true ? endFrom : endFrom + end.length});
196
- cursor = endFrom + end.length;
255
+ for (const left of starts) {
256
+ if (left.from < cursor) continue;
257
+ const right = ends.find((candidate) => candidate.from >= left.to);
258
+ if (right === undefined) break;
259
+ const range = options.lines === true
260
+ ? {from: lineRange(document, left).from, to: lineRange(document, right).to, linewise: true}
261
+ : {
262
+ from: options.inside === true ? left.to : left.from,
263
+ to: options.inside === true ? right.from : right.to,
264
+ linewise: options.inside !== true && left.linewise === true && right.linewise === true,
265
+ };
266
+ ranges.push(range);
267
+ cursor = right.to;
197
268
  }
198
- return selectionSet(document, ranges, {kind: "between", start, end});
269
+ return selectionSet(document, ranges, {kind: "between"});
199
270
  },
200
- select: (match) => {
271
+ slice: (set, start, end) => {
272
+ assertCurrent(document);
273
+ const selected = assertSet(document, set);
274
+ return selectionSet(document, selected.slice(start, end), {kind: "slice", source: selected.provenance, start, end, warning: selected.provenance?.warning});
275
+ },
276
+ union: (...sets) => {
277
+ assertCurrent(document);
278
+ const ranges = sets.flatMap((set) => [...assertSet(document, set)]).sort((left, right) => left.from - right.from || left.to - right.to);
279
+ const unique = ranges.filter((range, index) => index === 0 || range.from !== ranges[index - 1].from || range.to !== ranges[index - 1].to);
280
+ for (let index = 1; index < unique.length; index += 1) {
281
+ if (unique[index].from < unique[index - 1].to) throw selectionError("INVALID_SELECTION", "union() selections overlap");
282
+ }
283
+ return selectionSet(document, unique, {kind: "union", sources: sets.map((set) => set.provenance), warning: sets.find((set) => set.provenance?.warning)?.provenance.warning});
284
+ },
285
+ within: (candidates, scopes) => {
286
+ assertCurrent(document);
287
+ const selected = assertSet(document, candidates);
288
+ const containers = assertSet(document, scopes);
289
+ const ranges = selected.filter((candidate) => containers.some((scope) => scope.from <= candidate.from && candidate.to <= scope.to));
290
+ return selectionSet(document, ranges, {kind: "within", source: selected.provenance, scopes: containers.provenance, warning: selected.provenance?.warning ?? containers.provenance?.warning});
291
+ },
292
+ linesOf: (set) => {
293
+ assertCurrent(document);
294
+ const selected = assertSet(document, set);
295
+ const ranges = selected.map((item) => lineRange(document, item)).sort((left, right) => left.from - right.from);
296
+ const unique = ranges.filter((range, index) => index === 0 || range.from !== ranges[index - 1].from || range.to !== ranges[index - 1].to);
297
+ return selectionSet(document, unique, {kind: "linesOf", source: selected.provenance, warning: selected.provenance?.warning});
298
+ },
299
+ select: (match) => {
201
300
  assertCurrent(document);
202
301
  const candidate = match?.selection ?? match;
203
302
  if (!candidate || typeof candidate !== "object") throw new Error("select() requires a search match");
@@ -219,12 +318,18 @@ select: (match) => {
219
318
  const starts = [0];
220
319
  for (let index = 0; index < document.content.length; index += 1) if (document.content[index] === "\\n") starts.push(index + 1);
221
320
  if (last > starts.length) throw new RangeError("Line range is outside document");
222
- return selectionSet(document, [{from: starts[first - 1], to: starts[last] === undefined ? document.content.length : starts[last]}]);
321
+ return selectionSet(document, [{from: starts[first - 1], to: starts[last] === undefined ? document.content.length : starts[last], linewise: true}], {kind: "line", first, last});
223
322
  },
323
+ start: () => { assertCurrent(document); return selectionSet(document, [{from: 0, to: 0, linewise: true}], {kind: "start"}); },
324
+ end: () => { assertCurrent(document); const point = document.content.length; return selectionSet(document, [{from: point, to: point, linewise: true}], {kind: "end"}); },
325
+ before: (set) => { assertCurrent(document); const selected = assertSet(document, set); return selectionSet(document, selected.map((item) => ({from: item.from, to: item.from, linewise: item.linewise === true})), {kind: "before", source: selected.provenance}); },
326
+ after: (set) => { assertCurrent(document); const selected = assertSet(document, set); return selectionSet(document, selected.map((item) => ({from: item.to, to: item.to, linewise: item.linewise === true})), {kind: "after", source: selected.provenance}); },
224
327
  replace: (target, text) => { assertCurrent(document); stage(document, target, String(text)); },
225
328
  remove: (target) => { assertCurrent(document); stage(document, target, ""); },
226
329
  insertBefore: (target, text) => { assertCurrent(document); stage(document, target, String(text), "before"); },
227
330
  insertAfter: (target, text) => { assertCurrent(document); stage(document, target, String(text), "after"); },
331
+ flush: () => flushDocument(document),
332
+ delete: () => { assertCurrent(document); operations.push({kind: "delete", path: document.source}); },
228
333
  };
229
334
  return Object.freeze(api);
230
335
  };
@@ -235,26 +340,19 @@ select: (match) => {
235
340
  deleteFile: (path) => operations.push({kind: "delete", path}),
236
341
  copyFile: (path, target, options = {}) => operations.push({kind: "copy", path, target, overwrite: options.overwrite === true}),
237
342
  moveFile: (path, target, options = {}) => operations.push({kind: "move", path, target, overwrite: options.overwrite === true}),
343
+ replace: (target, text) => stageSet(target, String(text)),
344
+ remove: (target) => stageSet(target, ""),
345
+ insertBefore: (target, text) => stageSet(target, String(text), "before"),
346
+ insertAfter: (target, text) => stageSet(target, String(text), "after"),
238
347
  copy: (source, destination) => stageTransfer("text-copy", source, destination),
239
348
  move: (source, destination) => stageTransfer("text-move", source, destination),
240
349
  flush: () => {
241
350
  if (operations.length === 0) return undefined;
242
351
  const pending = operations;
243
352
  operations = [];
244
- const value = invoke("editorApply", {snapshots: [...snapshots.values()].map(({id, source, content}) => ({id, source, content})), operations: pending});
245
- for (const refreshed of value?.snapshots ?? []) {
246
- const document = snapshots.get(refreshed.id);
247
- if (document !== undefined && refreshed.unavailable === true) snapshots.delete(refreshed.id);
248
- else if (document !== undefined) {
249
- document.source = refreshed.source;
250
- document.content = refreshed.content;
251
- document.lines = refreshed.lines;
252
- document.generation += 1;
253
- }
254
- }
255
- return value;
353
+ return commit(pending);
256
354
  },
257
- result: (value) => __apply.result(value, value !== null && typeof value === "object" ? origins.get(value) : undefined),
355
+
258
356
  __finishApplyScript: () => { if (operations.length > 0) return api.flush(); },
259
357
  };
260
358
  return api;
@@ -51,8 +51,6 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
51
51
  label: "Apply",
52
52
  renderShell: "self",
53
53
  renderCall: (args, theme, context) => {
54
- (context.state as { codeView?: boolean }).codeView =
55
- pi.getFlag("pi-agent-ide-apply-code") === true;
56
54
  const render = editor.getToolRenderer("apply")?.renderCall ?? renderApplyCall;
57
55
  return render(args, theme, context);
58
56
  },
@@ -65,13 +63,11 @@ export async function registerApply(pi: ExtensionAPI, editor: TextEditorCore): P
65
63
  description:
66
64
  `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.` +
67
65
  applyHelperGuide(),
68
- promptGuidelines: [
69
- "Use Apply for complex, multi-file changes and standalone editor tools for small precise edits.",
70
- ],
66
+ promptGuidelines: [],
71
67
  parameters: Type.Object({
72
68
  source: Type.String({
73
69
  description:
74
- "JavaScript function body. Call IDE functions directly without await; each call finishes before the next statement. Use result(value) for explicit output. The UI may compact written tool calls or format a display copy; execution uses this source unchanged.",
70
+ "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.",
75
71
  }),
76
72
  }),
77
73
  async execute(_id, { source }, signal, _onUpdate, context) {
@@ -111,9 +111,44 @@ export async function executeEditorTransaction(
111
111
  const files: ScriptMutationFile[] = [];
112
112
  const operations: ApplyOperationOutcome[] = [];
113
113
  const cwd = context.cwd;
114
+ const batchedReplacements = new Set<number>();
114
115
 
115
116
  for (const [index, operation] of request.operations.entries()) {
116
117
  const resources = operationResources(operation, snapshots, cwd);
118
+ if (batchedReplacements.has(index)) continue;
119
+ if (operation.kind === "replace") {
120
+ const replacements: Array<{ index: number; operation: TextOperation }> = [];
121
+ for (
122
+ let candidateIndex = index;
123
+ candidateIndex < request.operations.length;
124
+ candidateIndex += 1
125
+ ) {
126
+ const candidate = request.operations[candidateIndex];
127
+ if (
128
+ candidate?.kind !== "replace" ||
129
+ candidate.selection.document !== operation.selection.document
130
+ )
131
+ break;
132
+ replacements.push({ index: candidateIndex, operation: candidate });
133
+ }
134
+ if (replacements.length > 1) {
135
+ for (const replacement of replacements) batchedReplacements.add(replacement.index);
136
+ const outcome = await executeReplacementBatch(
137
+ replacements,
138
+ snapshots,
139
+ accepted,
140
+ editor,
141
+ cwd,
142
+ signal,
143
+ options,
144
+ );
145
+ for (const state of outcome.saved)
146
+ if (!journal.has(state.path)) journal.set(state.path, state);
147
+ files.push(...outcome.files);
148
+ operations.push(...outcome.operations);
149
+ continue;
150
+ }
151
+ }
117
152
  if (operation.kind === "warning") {
118
153
  operations.push({
119
154
  index,
@@ -209,6 +244,141 @@ export async function executeEditorTransaction(
209
244
  };
210
245
  }
211
246
 
247
+ async function executeReplacementBatch(
248
+ replacements: readonly { readonly index: number; readonly operation: TextOperation }[],
249
+ snapshots: ReadonlyMap<string, EditorSnapshot>,
250
+ accepted: Map<string, TextChange[]>,
251
+ editor: TransactionEditor,
252
+ cwd: string,
253
+ signal: AbortSignal,
254
+ options: TransactionExecutionOptions,
255
+ ): Promise<{
256
+ readonly saved: readonly SavedPath[];
257
+ readonly files: readonly ScriptMutationFile[];
258
+ readonly operations: readonly ApplyOperationOutcome[];
259
+ }> {
260
+ const first = requiredValue(replacements[0]);
261
+ const snapshot = snapshots.get(first.operation.selection.document);
262
+ const resources = operationResources(first.operation, snapshots, cwd);
263
+ if (snapshot === undefined)
264
+ return {
265
+ saved: [],
266
+ files: [],
267
+ operations: replacements.map(({ index, operation }) =>
268
+ failed(
269
+ index,
270
+ operation,
271
+ resources,
272
+ invalid("Selection belongs to an unknown editor snapshot"),
273
+ ),
274
+ ),
275
+ };
276
+
277
+ const prior = accepted.get(snapshot.source) ?? [];
278
+ const additions: TextChange[] = [];
279
+ const operationResults = new Map<number, ApplyOperationOutcome>();
280
+ for (const { index, operation } of replacements) {
281
+ try {
282
+ validateSelection(operation, snapshot);
283
+ if (
284
+ prior.some((change) => overlaps(change, operation.selection)) ||
285
+ additions.some((change) => overlaps(change, operation.selection))
286
+ )
287
+ throw invalid(`Overlapping selection in ${snapshot.source}`);
288
+ additions.push({
289
+ from: operation.selection.from,
290
+ to: operation.selection.to,
291
+ insert: preserveLineEnding(operation.selection, operation.text),
292
+ });
293
+ } catch (error) {
294
+ operationResults.set(index, failed(index, operation, resources, error));
295
+ }
296
+ }
297
+ if (additions.length === 0)
298
+ return {
299
+ saved: [],
300
+ files: [],
301
+ operations: replacements.map(({ index }) => requiredValue(operationResults.get(index))),
302
+ };
303
+
304
+ const before = applyTextChanges(snapshot.content, prior).content;
305
+ let current: string;
306
+ try {
307
+ current = await readFile(snapshot.source, "utf8");
308
+ if (current !== before) throw stale(snapshot.source);
309
+ } catch (error) {
310
+ for (const { index, operation } of replacements)
311
+ if (!operationResults.has(index))
312
+ operationResults.set(index, failed(index, operation, resources, error));
313
+ return {
314
+ saved: [],
315
+ files: [],
316
+ operations: replacements.map(({ index }) => requiredValue(operationResults.get(index))),
317
+ };
318
+ }
319
+
320
+ const saved = [await savePath(snapshot.source)];
321
+ const combined = [...prior, ...additions];
322
+ const applied = applyTextChanges(snapshot.content, combined);
323
+ try {
324
+ await editOne(editor, snapshot.source, before, applied.content, cwd, signal, false);
325
+ accepted.set(snapshot.source, combined);
326
+ for (const { index, operation } of replacements)
327
+ if (!operationResults.has(index))
328
+ operationResults.set(index, {
329
+ index,
330
+ kind: operation.kind,
331
+ status: "applied",
332
+ effect: "applied",
333
+ resources,
334
+ });
335
+ return {
336
+ saved,
337
+ files: [
338
+ {
339
+ source: snapshot.source,
340
+ before,
341
+ after: applied.content,
342
+ action: "edited",
343
+ changes: applied.changes.map((change, editIndex) => ({
344
+ editIndex,
345
+ fromA: change.fromBefore,
346
+ toA: change.toBefore,
347
+ fromB: change.fromAfter,
348
+ toB: change.toAfter,
349
+ removedText: change.removedText,
350
+ insertedText: change.insertedText,
351
+ })),
352
+ formatting: { status: "not-reported" },
353
+ },
354
+ ],
355
+ operations: replacements.map(({ index }) => requiredValue(operationResults.get(index))),
356
+ };
357
+ } catch (error) {
358
+ const rollbackErrors = await rollback(saved, options.restorePath);
359
+ for (const { index, operation } of replacements)
360
+ if (!operationResults.has(index))
361
+ operationResults.set(
362
+ index,
363
+ rollbackErrors.length === 0
364
+ ? failed(index, operation, resources, error)
365
+ : {
366
+ index,
367
+ kind: operation.kind,
368
+ status: "unknown",
369
+ effect: "unknown",
370
+ resources,
371
+ error: codedError(error, rollbackErrors),
372
+ },
373
+ );
374
+ return {
375
+ saved: rollbackErrors.length === 0 ? [] : saved,
376
+ files: [],
377
+ operations: replacements.map(({ index }) => requiredValue(operationResults.get(index))),
378
+ };
379
+ }
380
+ }
381
+
212
382
  async function validateOperation(
213
383
  operation: Operation,
214
384
  snapshots: ReadonlyMap<string, EditorSnapshot>,
@@ -370,6 +540,16 @@ function preserveLineEnding(selection: Selection, insert: string): string {
370
540
  function rangesOverlap(left: Selection, right: Selection): boolean {
371
541
  return left.from < right.to && right.from < left.to;
372
542
  }
543
+ function transferInsert(snapshot: EditorSnapshot, destination: Selection, text: string): string {
544
+ if (destination.from !== destination.to || destination.linewise !== true || text.length === 0)
545
+ return text;
546
+ const separator = snapshot.content.includes("\r\n") ? "\r\n" : "\n";
547
+ const before = snapshot.content.slice(0, destination.from);
548
+ const after = snapshot.content.slice(destination.to);
549
+ const prefix = before.length > 0 && !/(?:\r\n|\r|\n)$/u.test(before) ? separator : "";
550
+ const suffix = after.length > 0 && !/(?:\r\n|\r|\n)$/u.test(text) ? separator : "";
551
+ return prefix + text + suffix;
552
+ }
373
553
  async function executeTextTransfer(
374
554
  operation: TextTransferOperation,
375
555
  snapshots: ReadonlyMap<string, EditorSnapshot>,
@@ -382,7 +562,11 @@ async function executeTextTransfer(
382
562
  for (const destination of operation.destinations) {
383
563
  const snapshot = requiredValue(snapshots.get(destination.document));
384
564
  const changes = additions.get(snapshot.source) ?? [];
385
- changes.push({ from: destination.from, to: destination.to, insert: operation.text });
565
+ changes.push({
566
+ from: destination.from,
567
+ to: destination.to,
568
+ insert: transferInsert(snapshot, destination, operation.text),
569
+ });
386
570
  additions.set(snapshot.source, changes);
387
571
  }
388
572
  if (operation.kind === "text-move")
@@ -649,6 +833,7 @@ function selections(value: unknown, label: string): Selection[] {
649
833
  from: integer(item.from, "selection from"),
650
834
  to: integer(item.to, "selection to"),
651
835
  text: text(item.text, "selection text"),
836
+ ...(item.linewise === true && { linewise: true }),
652
837
  };
653
838
  });
654
839
  }
@@ -32,7 +32,7 @@ export function registerBuiltinEditFilter(pi: ExtensionAPI): void {
32
32
  "Use the smallest useful source view: reuse sufficient content and anchors, search for known text, or inspect structure when locating a declaration. Read nearby context when boundaries are unclear; resolve ambiguity rather than guessing.",
33
33
  "Use an available anchor when it selects exactly the intended text; otherwise use minimal unique exact text. Keep the edit limited to the intended content.",
34
34
  "When search broadens to separate words, treat its results as location hints. Refine the query before using those matches for replacement.",
35
- "Submit independent mutations together in one tool-call block. They are evaluated against the original file contents. Combine overlapping changes into one mutation. A rejected mutation does not cancel other valid mutations; check each result and retry only changes that were not applied.",
35
+ "Use standalone mutation tools in one assistant-response batch when each change is known in advance and does not depend on another change. This is the default for several independent edits in one file or across files. Every call is evaluated against the original file snapshots. Combine overlapping changes into one mutation. Use Apply only when edits require computation, conditions, selection composition, checkpoints, or one coherent cross-file transaction. Check each batch result and retry only unapplied changes.",
36
36
  ],
37
37
  parameters: Type.Object({}, { additionalProperties: false }),
38
38
  execute() {
@@ -155,9 +155,9 @@ export function registerDiff(
155
155
  name: "diff",
156
156
  label: "Diff",
157
157
  parameters: diffParameters,
158
- promptSnippet: "Compare two text-readable sources without changing them",
158
+ promptSnippet: "Compare two text-readable sources",
159
159
  description:
160
- "Use diff to compare two sources without modifying them. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",
160
+ "Use diff to compare two sources. before and after accept a source string or a read request {path, offset?, limit?, views?}. Use any source that read can resolve as text. Omit limit to compare complete resolved text; read presentation limits do not clip comparison inputs. Multiple resolved resources are joined with one newline separator in resolver order. Diff line numbers are relative to each selected text, not the original file when a window is selected. Native non-text content is rejected. Output uses the existing text diff and a shared output budget; oversized output has a full temporary reference. The same diff function is available inside Apply.",
161
161
  renderCall(_args, theme) {
162
162
  return new Text(theme.fg("toolTitle", theme.bold("Diff")), 0, 0);
163
163
  },
@@ -55,17 +55,6 @@ export default async function registerTextEditorCore(
55
55
  editor,
56
56
  registration,
57
57
  interceptionRendering,
58
- () =>
59
- [
60
- (registration.anchors?.length ?? 0) > 0
61
- ? editor.renderGeneralPromptGuideline(
62
- new Set(registration.anchors?.flatMap((anchor) => anchor.kinds)),
63
- )
64
- : undefined,
65
- editor.renderToolPromptGuideline(registration.name),
66
- ]
67
- .filter((guideline): guideline is string => guideline !== undefined)
68
- .join("\n\n") || undefined,
69
58
  () => getLastResolvedResource(pi)?.source,
70
59
  ),
71
60
  );
@@ -26,7 +26,7 @@ export function loadTextEditorConfig(cwd: string): LoadedTextEditorConfig {
26
26
  throw new Error(`Invalid text editor config at ${file}`, { cause: error });
27
27
  }
28
28
  const root = record(value, "text editor config");
29
- assertKeys(root, ["recovery", "renderer"], "text editor config");
29
+ assertKeys(root, ["recovery"], "text editor config");
30
30
  if (root.recovery === undefined) {
31
31
  return { contextLines: 15, timeoutMs: 2000, sections: {} };
32
32
  }
@@ -81,7 +81,6 @@ export function createTextTool<TParameters extends TSchema>(
81
81
  core: TextEditorCore,
82
82
  definition: TextMutationToolRegistration<TParameters>,
83
83
  annotations: ToolCallInterceptionRenderStore,
84
- pluginPromptGuideline: () => string | undefined,
85
84
  getLastResolvedSource: () => string | undefined,
86
85
  ): ToolDefinition<TParameters, FileMutationBatchResult> {
87
86
  const renderer = core.getToolRenderer(definition.name);
@@ -178,7 +177,6 @@ export function createTextTool<TParameters extends TSchema>(
178
177
  ? `When ${definition.source.field} is omitted, the tool can reuse the file identified by the supplied anchor, the last read, or the preceding edit in the same batch.`
179
178
  : `When ${definition.source.field} is omitted, the tool can reuse the file identified by a supplied text anchor.`
180
179
  : "",
181
- pluginPromptGuideline() ?? "",
182
180
  ]
183
181
  .filter(Boolean)
184
182
  .join("\n");
@@ -22,7 +22,15 @@ import type { FileMutationBatchResult } from "pi-agent-text-editor/api/mutation-
22
22
 
23
23
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
24
24
 
25
- export default async function registerTextEditorRenderer(pi: ExtensionAPI): Promise<void> {
25
+ function parsePresentation(value: string | undefined): "full" | "compact" | "disabled" {
26
+ return value === "full" || value === "disabled" ? value : "compact";
27
+ }
28
+ export default async function registerTextEditorRenderer(
29
+ pi: ExtensionAPI,
30
+ context?: { readonly preferences: Readonly<Record<string, string>> },
31
+ ): Promise<void> {
32
+ const applyPresentation = parsePresentation(context?.preferences["ui.applyPreview"]);
33
+ const diffPresentation = parsePresentation(context?.preferences["ui.diffs"]);
26
34
  const animationPressure = createMutationAnimationPressure(pi);
27
35
  const plugin = {
28
36
  protocol: TEXT_EDITOR_PROTOCOL,
@@ -46,7 +54,9 @@ export default async function registerTextEditorRenderer(pi: ExtensionAPI): Prom
46
54
  );
47
55
  const panel = new MutationPanel(theme);
48
56
  panel.setBackground("toolSuccessBg");
49
- panel.setExpanded(options.expanded);
57
+ const mode = options.expanded ? "full" : diffPresentation;
58
+ panel.setExpanded(mode === "full");
59
+ panel.setDiffsVisible(mode !== "disabled");
50
60
  panel.setResourceLabelsVisible(true);
51
61
  panel.setResultResources(resolveMutationResultResources(details, undefined));
52
62
  return panel;
@@ -95,11 +105,13 @@ export default async function registerTextEditorRenderer(pi: ExtensionAPI): Prom
95
105
  ? `${display(call.before)} → ${display(call.after)}`
96
106
  : `${source}${call.target ? ` → ${display(call.target)}` : ""}`;
97
107
  return `${theme.fg("toolTitle", theme.bold(call.name))} ${theme.fg("accent", identity)}${suffix}`;
98
- }),
108
+ }, applyPresentation),
99
109
  renderResult: createApplyResultRenderer((details, theme, expanded, cwd) => {
100
110
  const panel = new MutationPanel(theme);
101
111
  panel.setBackground("toolSuccessBg");
102
- panel.setExpanded(expanded);
112
+ const mode = expanded ? "full" : diffPresentation;
113
+ panel.setExpanded(mode === "full");
114
+ panel.setDiffsVisible(mode !== "disabled");
103
115
  panel.setResourceLabelsVisible(true);
104
116
  panel.setResultResources(
105
117
  resolveMutationResultResources(details, undefined).map((resource) => ({
@@ -118,6 +130,7 @@ export default async function registerTextEditorRenderer(pi: ExtensionAPI): Prom
118
130
  api,
119
131
  animationPressure,
120
132
  () => pi.getFlag("pi-agent-ide-no-animations") !== true,
133
+ diffPresentation,
121
134
  );
122
135
  pi.on("tool_result", (event) => {
123
136
  if (
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-renderer",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
9
  "diff": "^9.0.0",
10
- "pi-agent-invariant": "0.6.0",
11
- "pi-agent-text-editor": "0.6.0",
12
- "pi-agent-tool-call-interception": "0.6.0",
13
- "pi-agent-tool-ui": "0.6.0"
10
+ "pi-agent-invariant": "0.6.2",
11
+ "pi-agent-text-editor": "0.6.2",
12
+ "pi-agent-tool-call-interception": "0.6.2",
13
+ "pi-agent-tool-ui": "0.6.2"
14
14
  },
15
15
  "pi": {
16
16
  "extensions": [
17
- "./runtime/entry-73.js"
17
+ "./runtime/entry-78.js"
18
18
  ]
19
19
  },
20
20
  "peerDependencies": {