pi-agent-ide 0.8.0 → 0.8.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 (377) hide show
  1. package/CHANGELOG.md +26 -40
  2. package/README.md +12 -7
  3. package/dist/{chunk-MOJ5RR35.js → chunk-246NTPOS.js} +1 -1
  4. package/dist/{chunk-NULNW6GK.js → chunk-2ITKAXHO.js} +1 -1
  5. package/dist/{chunk-SBNR4WZF.js → chunk-3WO2NOEQ.js} +1 -1
  6. package/dist/{chunk-N7LMRL64.js → chunk-47SPPIXK.js} +1 -1
  7. package/dist/{chunk-EY65TFHJ.js → chunk-4HWKBCBH.js} +1 -1
  8. package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
  9. package/dist/{chunk-KL776TGR.js → chunk-7LOVUWNI.js} +1 -1
  10. package/dist/{chunk-7JV4VN73.js → chunk-A64JRDZK.js} +1 -1
  11. package/dist/{chunk-Z3PGADVA.js → chunk-AIT3YWR5.js} +1 -1
  12. package/dist/{chunk-E4HPRLRB.js → chunk-AKNHSDGV.js} +1 -1
  13. package/dist/{chunk-4XPUN4QN.js → chunk-AUL5FGGK.js} +1 -1
  14. package/dist/chunk-BB4A5UI3.js +5 -0
  15. package/dist/{chunk-CTJV77FR.js → chunk-BQAKA3FU.js} +1 -1
  16. package/dist/{chunk-PNP2KNGP.js → chunk-BR7GRH4A.js} +1 -1
  17. package/dist/{chunk-4OYVLXWD.js → chunk-D4IA2MTA.js} +1 -1
  18. package/dist/{chunk-R5XJSEOE.js → chunk-DXONCYWF.js} +3 -3
  19. package/dist/{chunk-TWWND6NI.js → chunk-E2PHA4SQ.js} +1 -1
  20. package/dist/{chunk-MZXX353D.js → chunk-EMRJP6EM.js} +1 -1
  21. package/dist/{chunk-7HDK3NRQ.js → chunk-GEMDU6XW.js} +1 -1
  22. package/dist/chunk-GNACBJM3.js +1 -0
  23. package/dist/{chunk-3G54ZL2L.js → chunk-HCK7OIQ3.js} +1 -1
  24. package/dist/chunk-HFJGCYFO.js +11 -0
  25. package/dist/{chunk-CSXHCSTH.js → chunk-ID4RJIVZ.js} +1 -1
  26. package/dist/{chunk-SBLKPTL3.js → chunk-JKMXND6V.js} +1 -1
  27. package/dist/{chunk-WE42GBGU.js → chunk-LAJQSHEI.js} +1 -1
  28. package/dist/{chunk-HCN5W76B.js → chunk-LLRUJD62.js} +1 -1
  29. package/dist/{chunk-2K65BSXS.js → chunk-M4TVRCMZ.js} +1 -1
  30. package/dist/{chunk-IUSLSROY.js → chunk-N56WAVYA.js} +1 -1
  31. package/dist/chunk-OI3HBIPK.js +2 -0
  32. package/dist/{chunk-GW6NZQTQ.js → chunk-PRLIHLCS.js} +1 -1
  33. package/dist/{chunk-7TJ6DWW3.js → chunk-Q5X6OXNS.js} +1 -1
  34. package/dist/{chunk-75SWXD2Z.js → chunk-SWA5B5B2.js} +1 -1
  35. package/dist/chunk-T7MWQQIF.js +3 -0
  36. package/dist/{chunk-ICDI27GZ.js → chunk-TGC2ZACO.js} +1 -1
  37. package/dist/{chunk-7NS3QUIE.js → chunk-TXG2H7YQ.js} +1 -1
  38. package/dist/{chunk-RAZP42IQ.js → chunk-VAXLSPPU.js} +1 -1
  39. package/dist/chunk-VMGZMXEM.js +10 -0
  40. package/dist/{chunk-CPZJPGLG.js → chunk-VNTY7BKC.js} +1 -1
  41. package/dist/chunk-W3YFF6OO.js +1 -0
  42. package/dist/{chunk-OLI3JPHJ.js → chunk-W7M3V7FR.js} +1 -1
  43. package/dist/{chunk-UUJJRXHG.js → chunk-WMHSVEIT.js} +1 -1
  44. package/dist/{chunk-OJX3RJ5A.js → chunk-WPBQ45ZL.js} +1 -1
  45. package/dist/{chunk-XZDOVPRC.js → chunk-WXGTU2M6.js} +1 -1
  46. package/dist/{chunk-3ZGDMTMD.js → chunk-XSIKDVAR.js} +1 -1
  47. package/dist/{chunk-QP2QSQ4U.js → chunk-YHREORHH.js} +1 -1
  48. package/dist/chunk-YTYLS2UM.js +1 -0
  49. package/dist/chunk-Z2QGNTGQ.js +1 -0
  50. package/dist/{chunk-UBH6X3D3.js → chunk-ZV5ETNLQ.js} +1 -1
  51. package/dist/entry-11.js +1 -1
  52. package/dist/entry-13.js +1 -1
  53. package/dist/entry-14.js +1 -1
  54. package/dist/entry-15.js +1 -1
  55. package/dist/entry-16.js +1 -1
  56. package/dist/entry-17.js +1 -1
  57. package/dist/entry-18.js +1 -0
  58. package/dist/entry-20.js +1 -1
  59. package/dist/entry-21.js +1 -1
  60. package/dist/entry-22.js +1 -1
  61. package/dist/entry-23.js +1 -1
  62. package/dist/entry-24.js +1 -1
  63. package/dist/entry-25.js +1 -1
  64. package/dist/entry-26.js +1 -2
  65. package/dist/entry-27.js +2 -1
  66. package/dist/entry-28.js +1 -4
  67. package/dist/entry-29.js +4 -1
  68. package/dist/entry-30.js +1 -1
  69. package/dist/entry-31.js +1 -1
  70. package/dist/entry-32.js +1 -18
  71. package/dist/entry-33.js +18 -1
  72. package/dist/entry-34.js +1 -1
  73. package/dist/entry-35.js +1 -1
  74. package/dist/entry-36.js +1 -1
  75. package/dist/entry-37.js +1 -1
  76. package/dist/entry-38.js +1 -1
  77. package/dist/entry-39.js +1 -1
  78. package/dist/entry-40.js +1 -1
  79. package/dist/entry-41.js +1 -1
  80. package/dist/entry-42.js +1 -1
  81. package/dist/entry-43.js +1 -1
  82. package/dist/entry-44.js +1 -1
  83. package/dist/entry-45.js +1 -1
  84. package/dist/entry-46.js +1 -25
  85. package/dist/entry-47.js +25 -1
  86. package/dist/entry-48.js +1 -1
  87. package/dist/entry-49.js +1 -1
  88. package/dist/entry-50.js +1 -1
  89. package/dist/entry-51.js +1 -3
  90. package/dist/entry-52.js +3 -13
  91. package/dist/entry-53.js +13 -1
  92. package/dist/entry-54.js +1 -1
  93. package/dist/entry-55.js +1 -1
  94. package/dist/entry-56.js +1 -1
  95. package/dist/entry-57.js +1 -1
  96. package/dist/entry-58.js +1 -1
  97. package/dist/entry-59.js +1 -1
  98. package/dist/entry-6.js +1 -1
  99. package/dist/entry-60.js +1 -1
  100. package/dist/entry-61.js +1 -1
  101. package/dist/entry-62.js +1 -0
  102. package/dist/entry-63.js +0 -1
  103. package/dist/entry-64.js +1 -0
  104. package/dist/entry-65.js +0 -1
  105. package/dist/entry-66.js +1 -1
  106. package/dist/entry-67.js +1 -1
  107. package/dist/entry-68.js +1 -1
  108. package/dist/entry-69.js +1 -1
  109. package/dist/entry-7.js +1 -1
  110. package/dist/entry-70.js +1 -1
  111. package/dist/entry-71.js +1 -1
  112. package/dist/entry-72.js +1 -0
  113. package/dist/entry-73.js +0 -1
  114. package/dist/entry-74.js +1 -0
  115. package/dist/entry-75.js +0 -1
  116. package/dist/entry-76.js +1 -1
  117. package/dist/entry-77.js +1 -1
  118. package/dist/entry-78.js +1 -80
  119. package/dist/entry-79.js +76 -17
  120. package/dist/entry-80.js +22 -2
  121. package/dist/entry-81.js +2 -1
  122. package/dist/entry-82.js +1 -1
  123. package/dist/entry-83.js +1 -1
  124. package/dist/entry-84.js +1 -3
  125. package/dist/entry-85.js +3 -1
  126. package/dist/entry-86.js +1 -1
  127. package/dist/entry-87.js +1 -1
  128. package/dist/entry-88.js +1 -0
  129. package/dist/pi-agent-ide.js +53 -24
  130. package/docs/agent-guides/search-code.md +3 -1
  131. package/docs/agent-guides/ssh.md +1 -1
  132. package/docs/configuration.md +18 -6
  133. package/docs/development.md +1 -13
  134. package/docs/extensions.md +1 -1
  135. package/docs/releases.md +1 -1
  136. package/docs/settings-help.md +39 -0
  137. package/docs/tools.md +1 -0
  138. package/docs/user-hooks.md +3 -1
  139. package/node_modules/pi-agent-doctor/package.json +7 -10
  140. package/node_modules/pi-agent-documentation/package.json +2 -2
  141. package/node_modules/pi-agent-documentation/runtime/entry-26.js +1 -0
  142. package/node_modules/pi-agent-filesystem/package.json +8 -8
  143. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  144. package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
  145. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  146. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  147. package/node_modules/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  148. package/node_modules/pi-agent-ide-ast/package.json +15 -41
  149. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  150. package/node_modules/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  151. package/node_modules/pi-agent-ide-changes/package.json +10 -11
  152. package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  153. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  154. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  155. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  156. package/node_modules/pi-agent-ide-lsp/package.json +10 -13
  157. package/node_modules/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  158. package/node_modules/pi-agent-image/package.json +3 -3
  159. package/node_modules/pi-agent-invariant/package.json +2 -2
  160. package/node_modules/pi-agent-pdf/package.json +3 -4
  161. package/node_modules/pi-agent-read/package.json +12 -12
  162. package/node_modules/pi-agent-read/runtime/entry-46.js +0 -1
  163. package/node_modules/pi-agent-read/runtime/entry-47.js +2 -0
  164. package/node_modules/pi-agent-resource/package.json +2 -2
  165. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -0
  166. package/node_modules/pi-agent-search/package.json +9 -9
  167. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  168. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  169. package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
  170. package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
  171. package/node_modules/pi-agent-search/src/api/search.ts +7 -0
  172. package/node_modules/pi-agent-search/src/core/search-core.ts +23 -3
  173. package/node_modules/pi-agent-search-text/index.ts +2 -0
  174. package/node_modules/pi-agent-search-text/package.json +14 -14
  175. package/node_modules/pi-agent-search-text/runtime/entry-53.js +1 -0
  176. package/node_modules/pi-agent-search-text/src/search-backend.ts +18 -10
  177. package/node_modules/pi-agent-search-text/src/search-session.ts +68 -9
  178. package/node_modules/pi-agent-text/package.json +3 -3
  179. package/node_modules/pi-agent-text/runtime/entry-57.js +1 -0
  180. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  181. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  182. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
  183. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  184. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  185. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  186. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  187. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  188. package/node_modules/pi-agent-text-editor/package.json +26 -34
  189. package/node_modules/pi-agent-text-editor/runtime/entry-78.js +0 -1
  190. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  191. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  192. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  193. package/node_modules/pi-agent-text-editor/src/core/extension.ts +1 -0
  194. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  195. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  196. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  197. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  198. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  199. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  200. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  201. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  202. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +8 -11
  211. package/node_modules/pi-agent-web-html/package.json +3 -5
  212. package/node_modules/pi-agent-web-image/package.json +4 -4
  213. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  214. package/node_modules/pi-agent-web-text/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/runtime/entry-88.js +2 -0
  216. package/package.json +43 -39
  217. package/skills/configure-agent-ide/SKILL.md +38 -0
  218. package/src/api/content.ts +6 -0
  219. package/src/api/tips.ts +3 -0
  220. package/src/composite/nested-tool-rendering.ts +16 -5
  221. package/src/composite/preferences.ts +13 -0
  222. package/src/composite/settings-documentation.ts +59 -0
  223. package/src/composite/settings-help.ts +106 -0
  224. package/src/composite/text-results.ts +50 -22
  225. package/src/documentation/extension.ts +12 -0
  226. package/src/documentation/search.ts +166 -0
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-31.js +2 -0
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +2 -0
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-88.js +2 -0
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +2 -0
  241. package/src/extensions/pi-agent-read/package.json +12 -12
  242. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  243. package/src/extensions/pi-agent-read/runtime/entry-47.js +2 -0
  244. package/src/extensions/pi-agent-search/package.json +9 -9
  245. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +2 -0
  246. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  247. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  248. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
  249. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +18 -10
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +68 -9
  251. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  252. package/src/extensions/pi-agent-search/runtime/entry-52.js +2 -0
  253. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  254. package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
  255. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
  256. package/src/extensions/pi-agent-search/src/api/search.ts +7 -0
  257. package/src/extensions/pi-agent-search/src/core/search-core.ts +23 -3
  258. package/src/extensions/pi-agent-text-editor/package.json +26 -34
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +2 -0
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-60.js +2 -0
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-62.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +22 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +2 -0
  271. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -1
  272. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +2 -0
  273. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  274. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  275. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  276. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +1 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +49 -21
  278. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  279. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +2 -2
  280. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  281. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  282. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  283. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  284. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +6 -8
  285. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  286. package/src/pi-agent-ide.ts +14 -2
  287. package/src/plugins/pi-agent-ide-ast/package.json +15 -41
  288. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  289. package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +2 -0
  290. package/src/plugins/pi-agent-ide-changes/package.json +10 -11
  291. package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +0 -1
  292. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  293. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  294. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  295. package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
  296. package/src/plugins/pi-agent-ide-lsp/runtime/entry-39.js +2 -0
  297. package/src/tips/core.ts +5 -2
  298. package/src/tips/extension.ts +30 -2
  299. package/src/tips/persistence.ts +29 -27
  300. package/src/tips/setup-hint.ts +19 -0
  301. package/dist/chunk-5KFVDYCI.js +0 -1
  302. package/dist/chunk-ABFCAOU5.js +0 -1
  303. package/dist/chunk-BIG45IPN.js +0 -2
  304. package/dist/chunk-BMOJTJJJ.js +0 -3
  305. package/dist/chunk-BQ67M4NC.js +0 -3
  306. package/dist/chunk-IH5NW5JX.js +0 -11
  307. package/dist/chunk-NRZO5KJT.js +0 -9
  308. package/dist/chunk-O36UC74T.js +0 -1
  309. package/dist/chunk-SSWUUBIR.js +0 -1
  310. package/dist/entry-19.js +0 -1
  311. package/docs/research/apply-native-capability-matrix.md +0 -174
  312. package/docs/research/apply-read-latency.md +0 -221
  313. package/docs/research/codemode-write-context.md +0 -56
  314. package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
  315. package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
  316. package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
  317. package/docs/research/native-codemode-batch-decision.md +0 -31
  318. package/docs/research/native-codemode-batching.md +0 -65
  319. package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
  320. package/node_modules/pi-agent-filesystem/runtime/entry-26.js +0 -2
  321. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  322. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  323. package/node_modules/pi-agent-image/runtime/entry-39.js +0 -1
  324. package/node_modules/pi-agent-resource/runtime/entry-47.js +0 -1
  325. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  326. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  327. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  328. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
  329. package/node_modules/pi-agent-tool-call-interception/runtime/entry-81.js +0 -1
  330. package/node_modules/pi-agent-web/runtime/entry-83.js +0 -2
  331. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  332. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +0 -2
  333. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-84.js +0 -2
  334. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  335. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  336. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -2
  337. package/src/extensions/pi-agent-search/runtime/entry-48.js +0 -1
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-58.js +0 -1
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
  343. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  344. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  345. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-25.js +0 -0
  346. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-27.js +0 -0
  347. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  348. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  349. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  350. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  351. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  352. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  353. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
  354. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-40.js +0 -0
  355. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-41.js +0 -0
  356. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-42.js +0 -0
  357. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-48.js +0 -0
  358. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-52.js +0 -0
  359. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-56.js +0 -0
  360. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-79.js +0 -0
  361. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  362. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-82.js +0 -0
  363. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-84.js +0 -0
  364. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  365. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  366. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  367. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-jq → pi-agent-filesystem-image}/runtime/entry-28.js +0 -0
  368. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-jq}/runtime/entry-29.js +0 -0
  369. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-30.js +0 -0
  370. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-85.js +0 -0
  371. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-86.js +0 -0
  372. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-87.js +0 -0
  373. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-80.js +0 -0
  374. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-35.js +0 -0
  375. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-36.js +0 -0
  376. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-37.js +0 -0
  377. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-38.js +0 -0
@@ -957,9 +957,9 @@ class NativeTextEditBatchCoordinator {
957
957
  .snapshot()
958
958
  .filter((call) => call.state === "completed" && unchangedCopies.get(call.callId)?.all)
959
959
  .map((call) => call.callId),
960
- ...(value.details.copyResults === undefined
960
+ ...(value.details.mutationResults === undefined
961
961
  ? {}
962
- : { copyResults: value.details.copyResults }),
962
+ : { mutationResults: value.details.mutationResults }),
963
963
  result: value,
964
964
  } satisfies NativeEditBatchEvent;
965
965
  script.presentations.push(presentation);
@@ -2,16 +2,19 @@ import path from "node:path";
2
2
  import type { DeleteFileAccess } from "#src/api/delete-guard.js";
3
3
  import { localFileTransferAccess as localFiles } from "#src/api/native-files.js";
4
4
 
5
+ const temporaryNames = new Set(["tmp", ".tmp", "temp", ".temp"]);
6
+
5
7
  interface TemporaryDirectorySettings {
6
8
  readonly mode: "replace" | "extend";
7
9
  readonly paths: readonly string[];
8
10
  }
9
11
 
10
- /** Load Delete roots on their owner: defaults, then native global and project settings.
11
- * A provider without native account defaults keeps the strict deletion policy.
12
+ /** Load temporary removal roots for a resolved path, then apply its owner's settings.
13
+ * A provider without native account defaults keeps the strict removal policy.
12
14
  */
13
15
  export async function loadTemporaryDirectories(
14
16
  projectRoot: string,
17
+ resolvedPath: string,
15
18
  files: DeleteFileAccess = localFiles,
16
19
  signal?: AbortSignal,
17
20
  ): Promise<readonly string[]> {
@@ -20,14 +23,15 @@ export async function loadTemporaryDirectories(
20
23
  const environment = await files.temporaryEnvironment(signal);
21
24
  const paths = files.pathStyle === "native" ? path : path.posix;
22
25
  const home = await files.realpath(environment.home);
23
- const names = ["tmp", ".tmp", "temp", ".temp"];
24
26
  const system = await existingRoot(environment.temporary, files, signal);
25
- // Named defaults do not grant permission to a symlink's destination outside the root.
26
- let roots = [
27
- ...names.map((name) => paths.join(projectRoot, name)),
28
- ...names.map((name) => paths.join(home, name)),
29
- ...(system === undefined ? [] : [system]),
30
- ];
27
+ let roots = system === undefined ? [] : [system];
28
+ // The caller has resolved parent links; only real path components grant the default exception.
29
+ for (let directory = resolvedPath; ;) {
30
+ if (temporaryNames.has(paths.basename(directory))) roots.push(directory);
31
+ const parent = paths.dirname(directory);
32
+ if (parent === directory) break;
33
+ directory = parent;
34
+ }
31
35
  const layers = [
32
36
  {
33
37
  file: paths.join(
@@ -28,9 +28,11 @@ export interface BatchCallCandidate<TState = unknown> {
28
28
  export interface ToolBatchDefinition<TState = unknown> {
29
29
  readonly sourceTools: readonly string[];
30
30
  readonly syntheticTool: string;
31
+ /** Use the current worktree/session to keep registered selections out of plain-path plans. */
31
32
  readonly resolveCall: (
32
33
  call: OriginalToolCall,
33
34
  inheritedState: TState | undefined,
35
+ context: ExtensionContext,
34
36
  ) => BatchCallCandidate<TState> | undefined;
35
37
  readonly buildArguments: (
36
38
  calls: readonly BatchCallCandidate<TState>[],
@@ -133,7 +135,12 @@ function publishRenderArguments(
133
135
  }
134
136
  }
135
137
 
136
- function rewriteMessage(state: CoordinatorState, message: unknown, createPlans: boolean): unknown {
138
+ function rewriteMessage(
139
+ state: CoordinatorState,
140
+ message: unknown,
141
+ createPlans: boolean,
142
+ context: ExtensionContext,
143
+ ): unknown {
137
144
  if (
138
145
  !isObjectNotArray(message) ||
139
146
  message.role !== "assistant" ||
@@ -154,6 +161,7 @@ function rewriteMessage(state: CoordinatorState, message: unknown, createPlans:
154
161
  ? definition.resolveCall(
155
162
  first,
156
163
  inheritedDefinition === definition ? inheritedState : undefined,
164
+ context,
157
165
  )
158
166
  : undefined;
159
167
 
@@ -176,7 +184,7 @@ function rewriteMessage(state: CoordinatorState, message: unknown, createPlans:
176
184
  break;
177
185
  }
178
186
 
179
- const candidate = definition.resolveCall(next, requiredValue(run.at(-1)).state);
187
+ const candidate = definition.resolveCall(next, requiredValue(run.at(-1)).state, context);
180
188
 
181
189
  if (!candidate) {
182
190
  break;
@@ -522,12 +530,12 @@ function coordinatorFor(pi: ExtensionAPI): CoordinatorState {
522
530
 
523
531
  if (!state.registered) {
524
532
  state.registered = true;
525
- pi.on("message_update", (event) => {
526
- rewriteMessage(state, event.message, false);
533
+ pi.on("message_update", (event, context) => {
534
+ rewriteMessage(state, event.message, false, context);
527
535
  return;
528
536
  });
529
- pi.on("message_end", (event) => {
530
- rewriteMessage(state, event.message, true);
537
+ pi.on("message_end", (event, context) => {
538
+ rewriteMessage(state, event.message, true, context);
531
539
  return;
532
540
  });
533
541
  pi.on("before_provider_request", (event) => filterProviderTools(state, event));
@@ -550,8 +558,8 @@ export function registerToolBatch<TState>(
550
558
  const definitionForCoordinator: ToolBatchDefinition = {
551
559
  sourceTools: definition.sourceTools,
552
560
  syntheticTool: definition.syntheticTool,
553
- resolveCall: (call, inheritedState) =>
554
- definition.resolveCall(call, inheritedState as TState | undefined),
561
+ resolveCall: (call, inheritedState, context) =>
562
+ definition.resolveCall(call, inheritedState as TState | undefined, context),
555
563
  buildArguments: (calls) =>
556
564
  definition.buildArguments(calls as readonly BatchCallCandidate<TState>[]),
557
565
  execute: definition.execute,
@@ -1,8 +1,15 @@
1
- import { connectResultTargets, type ResultTargetStore } from "pi-agent-resource";
1
+ import {
2
+ connectResultTargets,
3
+ type ResultTargetStore,
4
+ type ResultSourceTarget,
5
+ } from "pi-agent-resource";
6
+ import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
7
+ import { isResultInput } from "./result-transfer.js";
2
8
  import {
3
9
  committedMutationTargets,
4
10
  describeUnavailableCopyTarget,
5
11
  unchangedCopySources,
12
+ verifyMutationTargets,
6
13
  } from "./mutation-result-targets.js";
7
14
  import { requiredValue } from "pi-agent-invariant";
8
15
  import { postWriteFailureEffect } from "./text-mutation.js";
@@ -68,6 +75,7 @@ import type {
68
75
  } from "@earendil-works/pi-coding-agent";
69
76
 
70
77
  interface TextBatchState {
78
+ readonly selection?: ResultSourceTarget;
71
79
  readonly source: string;
72
80
  readonly registration: AnyTextMutationToolRegistration;
73
81
  }
@@ -111,7 +119,7 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
111
119
  const definition: ToolBatchDefinition<TextBatchState> = {
112
120
  sourceTools,
113
121
  syntheticTool: "__pi_agent_text_editor_batch",
114
- resolveCall(call, inherited) {
122
+ resolveCall(call, inherited, context) {
115
123
  const registration = registrations.get(call.name);
116
124
 
117
125
  if (registration === undefined) {
@@ -135,7 +143,44 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
135
143
  })
136
144
  )
137
145
  return;
138
- const explicit = call.arguments[registration.source.field];
146
+ // Capture issued selections before any peer can commit a write.
147
+ let selection: ResultSourceTarget | undefined;
148
+ try {
149
+ const input = resultTargets.source(call.arguments[registration.source.field], context.cwd);
150
+ if (isResultInput(input)) {
151
+ if (
152
+ !["replace", "delete", "insert"].includes(registration.name) ||
153
+ (registration.source.targets ?? []).length > 0 ||
154
+ (registration.anchors ?? []).some(({ field }) => call.arguments[field] !== undefined)
155
+ )
156
+ return;
157
+ const resolved = resultTargets.resolve(input, context.cwd);
158
+ if (!resolved.complete || resolved.targets.length !== 1) return;
159
+ selection = resolved.targets[0];
160
+ if (
161
+ selection === undefined ||
162
+ selection.source.includes("://") ||
163
+ selection.ranges.length === 0
164
+ )
165
+ return;
166
+ } else if (
167
+ (registration.source.targets ?? []).some(({ field }) =>
168
+ isResultInput(resultTargets.source(call.arguments[field], context.cwd)),
169
+ )
170
+ )
171
+ return;
172
+ } catch {
173
+ // The direct source boundary reports unknown or expired references safely.
174
+ return;
175
+ }
176
+ // Whole-object Delete belongs to the filesystem pipeline, not the text planner.
177
+ if (
178
+ registration.name === "delete" &&
179
+ selection === undefined &&
180
+ (registration.anchors ?? []).every(({ field }) => call.arguments[field] === undefined)
181
+ )
182
+ return;
183
+ const explicit = selection?.source ?? call.arguments[registration.source.field];
139
184
  const inheritedSource =
140
185
  !(typeof explicit === "string" && explicit.length > 0) && registration.source.inherited
141
186
  ? inherited?.source
@@ -147,7 +192,7 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
147
192
  ? undefined
148
193
  : {
149
194
  call,
150
- state: { source, registration },
195
+ state: { source, registration, ...(selection !== undefined && { selection }) },
151
196
  ...(inheritedSource !== undefined && {
152
197
  renderArgumentPatch: { [registration.source.field]: inheritedSource },
153
198
  }),
@@ -161,7 +206,12 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
161
206
  op: state.registration.name,
162
207
  path: state.source,
163
208
  }));
164
- return { edits } satisfies TextBatchParams;
209
+ const selections = new Map(
210
+ calls.flatMap(({ call, state }) =>
211
+ state.selection === undefined ? [] : [[call.id, state.selection] as const],
212
+ ),
213
+ );
214
+ return { edits, selections } satisfies TextBatchParams;
165
215
  },
166
216
  execute: (_toolCallId, parameters, signal, onUpdate, context, reporter) =>
167
217
  executeRegisteredTextBatch(
@@ -206,6 +256,9 @@ export async function planRegisteredTextBatch(
206
256
  const planned = await Promise.allSettled(
207
257
  parameters.edits.map(async (entry): Promise<PlannedTextBatch["mutations"][number]> => {
208
258
  const registration = requiredValue(registrations.get(entry.op));
259
+ const selection = parameters.selections?.get(entry.callId);
260
+ if (selection !== undefined && texts.get(selection.source) !== selection.expectedContent)
261
+ throw new Error("The selected source changed before the edit batch. Resolve it again.");
209
262
  const { callId, op: _op, ...input } = entry;
210
263
  const sources = mutationSources(registration, input);
211
264
  const sourceFor = (field: string): string => requiredValue(sources.get(field));
@@ -219,6 +272,15 @@ export async function planRegisteredTextBatch(
219
272
  const resolveAnchors = async (field: string) => {
220
273
  const descriptor = (registration.anchors ?? []).find((anchor) => anchor.field === field);
221
274
  const value = input[field];
275
+ if (
276
+ selection !== undefined &&
277
+ descriptor?.sourceField === registration.source.field &&
278
+ value === undefined
279
+ ) {
280
+ return new Map([
281
+ [selection.source, new TextSelectionAnchor(field, selection.source, selection.ranges)],
282
+ ]);
283
+ }
222
284
  const source = descriptor === undefined ? undefined : sources.get(descriptor.sourceField);
223
285
  if (descriptor === undefined || typeof value !== "string" || source === undefined) {
224
286
  publish(field, { kind: "failed" });
@@ -396,7 +458,7 @@ export async function executeRegisteredTextBatch(
396
458
  }
397
459
 
398
460
  if (outcome.kind === "failed") {
399
- const copyResults = new Map<string, AgentToolResult<FileMutationBatchResult>>();
461
+ const mutationResults = new Map<string, AgentToolResult<FileMutationBatchResult>>();
400
462
  if (outcome.failure.code === "WRITE_FAILED") {
401
463
  for (const { callId, mutation } of executionPlan?.mutations ?? []) {
402
464
  if (mutation.operation !== "copy") continue;
@@ -404,7 +466,7 @@ export async function executeRegisteredTextBatch(
404
466
  (source) => mutation.edits.has(source),
405
467
  );
406
468
  const destination = unrestored[0] ?? mutation.edits.keys().next().value;
407
- copyResults.set(
469
+ mutationResults.set(
408
470
  callId,
409
471
  buildFailedCopyWriteResult(
410
472
  {
@@ -435,7 +497,7 @@ export async function executeRegisteredTextBatch(
435
497
  outcome.failure,
436
498
  context,
437
499
  reporter,
438
- copyResults,
500
+ mutationResults,
439
501
  );
440
502
  }
441
503
 
@@ -551,12 +613,13 @@ export async function executeRegisteredTextBatch(
551
613
  callIdsByResult.push(finalCallId);
552
614
  }
553
615
 
554
- const copyResults = new Map<string, AgentToolResult<FileMutationBatchResult>>();
616
+ const mutationResults = new Map<string, AgentToolResult<FileMutationBatchResult>>();
555
617
  if (resultTargets) {
556
- const copies = completedMutations.filter(
557
- ({ mutation }) => mutation.operation === "copy" && mutation.edits.size > 0,
618
+ const selectable = completedMutations.filter(
619
+ ({ mutation }) =>
620
+ ["copy", "replace", "insert"].includes(mutation.operation) && mutation.edits.size > 0,
558
621
  );
559
- for (const { callId, mutation } of copies) {
622
+ for (const { callId, mutation } of selectable) {
560
623
  const sources = new Set(mutation.edits.keys());
561
624
  let metadata: FileMutationBatchResult["metadata"];
562
625
  try {
@@ -565,7 +628,6 @@ export async function executeRegisteredTextBatch(
565
628
  callId,
566
629
  edits: new Map([...mutation.edits].filter(([source]) => sources.has(source))),
567
630
  })),
568
- // Copy read these destinations successfully, so they existed before the batch.
569
631
  outcome.resources
570
632
  .filter((resource) => sources.has(resource.source))
571
633
  .map((resource) => ({
@@ -584,35 +646,55 @@ export async function executeRegisteredTextBatch(
584
646
  ).length;
585
647
  if (!targets || targets.length !== expectedTargets)
586
648
  throw new Error("This operation did not produce confirmed filesystem targets.");
587
- const reference = resultTargets.register(targets, context.cwd);
588
- await resultTargets.verify(resultTargets.resolve(reference, context.cwd), signal);
589
- metadata = { resultTarget: reference };
649
+ const verified = await verifyMutationTargets(
650
+ core,
651
+ targets,
652
+ resultTargets,
653
+ context.cwd,
654
+ signal,
655
+ );
656
+ metadata = { resultTarget: resultTargets.register(verified, context.cwd) };
590
657
  } catch (error) {
591
658
  signal?.throwIfAborted();
592
659
  metadata = { targetUnavailable: errorMessage(error) };
593
660
  }
661
+ const copy = mutation.operation === "copy";
594
662
  const unchanged =
595
- unchangedCopySources(mutation, guardedSnapshots).size === mutation.edits.size;
663
+ copy && unchangedCopySources(mutation, guardedSnapshots).size === mutation.edits.size;
596
664
  const ownResults = resultsByCallId.get(callId) ?? [];
597
665
  const displayed = displayResultsByCallId.get(callId) ?? [];
598
666
  const receipt = textBatchResult(
599
- ownResults.length > 0 ? ownResults : displayed,
667
+ copy && ownResults.length === 0 ? displayed : ownResults,
600
668
  [],
601
669
  displayed,
602
670
  [],
603
671
  );
604
- copyResults.set(
605
- callId,
606
- describeUnavailableCopyTarget({
607
- ...receipt,
608
- ...(unchanged
672
+ const ownReceipt = {
673
+ ...receipt,
674
+ ...(unchanged
675
+ ? {
676
+ content: [
677
+ { type: "text" as const, text: "No changes: destination already has this text." },
678
+ ],
679
+ }
680
+ : !copy && ownResults.length === 0
609
681
  ? {
610
- content: [{ type: "text", text: "No changes: destination already has this text." }],
682
+ content: [
683
+ {
684
+ type: "text" as const,
685
+ text: "Batch edit applied; the final file result is in the last successful tool call for that file.",
686
+ },
687
+ ],
611
688
  }
612
689
  : {}),
613
- details: { ...receipt.details, effect: unchanged ? "not-applied" : "applied", metadata },
614
- }),
615
- );
690
+ details: {
691
+ ...receipt.details,
692
+ ...(!copy && { results: displayed }),
693
+ effect: unchanged ? ("not-applied" as const) : ("applied" as const),
694
+ metadata,
695
+ },
696
+ };
697
+ mutationResults.set(callId, copy ? describeUnavailableCopyTarget(ownReceipt) : ownReceipt);
616
698
  }
617
699
  }
618
700
  for (const { callId } of completedMutations) {
@@ -620,7 +702,7 @@ export async function executeRegisteredTextBatch(
620
702
  const callDisplayResults = displayResultsByCallId.get(callId) ?? [];
621
703
  reporter.complete(
622
704
  callId,
623
- copyResults.get(callId) ??
705
+ mutationResults.get(callId) ??
624
706
  textBatchResult(
625
707
  callResults,
626
708
  callResults.map(() => callId),
@@ -682,9 +764,9 @@ export async function executeRegisteredTextBatch(
682
764
  },
683
765
  });
684
766
  const result = textBatchResult(results, callIdsByResult, displayResults, callIdsByDisplayResult);
685
- return copyResults.size === 0
767
+ return mutationResults.size === 0
686
768
  ? result
687
- : { ...result, details: { ...result.details, copyResults } };
769
+ : { ...result, details: { ...result.details, mutationResults } };
688
770
  }
689
771
 
690
772
  async function failTextBatch(
@@ -693,7 +775,7 @@ async function failTextBatch(
693
775
  error: unknown,
694
776
  context: ExtensionContext,
695
777
  reporter: BatchExecutionReporter,
696
- copyResults: ReadonlyMap<string, AgentToolResult<FileMutationBatchResult>> = new Map(),
778
+ mutationResults: ReadonlyMap<string, AgentToolResult<FileMutationBatchResult>> = new Map(),
697
779
  ): Promise<AgentToolResult<TextBatchDetails>> {
698
780
  const failure = isTextResourceEditFailure(error)
699
781
  ? error
@@ -709,11 +791,11 @@ async function failTextBatch(
709
791
  const results: FileMutationResult[] = [];
710
792
  const callIdsByResult: string[] = [];
711
793
  for (const callId of callIds) {
712
- const copyResult = copyResults.get(callId);
713
- const result = copyResult ?? (callId === failedCallId ? failedResult : undefined);
794
+ const mutationResult = mutationResults.get(callId);
795
+ const result = mutationResult ?? (callId === failedCallId ? failedResult : undefined);
714
796
  reporter.fail(callId, {
715
797
  error: cause,
716
- effect: copyResult?.details.effect ?? failedResult.details.effect ?? "not-applied",
798
+ effect: mutationResult?.details.effect ?? failedResult.details.effect ?? "not-applied",
717
799
  ...(result !== undefined && { result }),
718
800
  });
719
801
  for (const item of result?.details.results ?? []) {
@@ -722,9 +804,9 @@ async function failTextBatch(
722
804
  }
723
805
  }
724
806
  const result = textBatchResult(results, callIdsByResult);
725
- return copyResults.size === 0
807
+ return mutationResults.size === 0
726
808
  ? result
727
- : { ...result, details: { ...result.details, copyResults } };
809
+ : { ...result, details: { ...result.details, mutationResults } };
728
810
  }
729
811
 
730
812
  function isTextResourceEditFailure(value: unknown): value is TextResourceEditFailure {
@@ -3,11 +3,14 @@ import { type FileMutationBatchResult, FileMutationResult } from "#src/api/mutat
3
3
  import { createUnifiedDiff } from "#src/core/mutation-result/diff.js";
4
4
  import { FileMutationAgentResult } from "#src/core/mutation-result/file-mutation-agent-result.js";
5
5
 
6
+ import type { ResultSourceTarget } from "pi-agent-resource";
6
7
  import type { OriginalToolCall } from "#src/core/text-edit-batch-coordinator.js";
7
8
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
8
9
 
9
10
  export interface TextBatchParams {
10
11
  readonly edits: readonly TextBatchEntry[];
12
+ /** Backend-owned selections captured before any call in this batch writes. */
13
+ readonly selections?: ReadonlyMap<string, ResultSourceTarget>;
11
14
  /** Optional whole-file revisions that every affected source must still match. */
12
15
  readonly expectedContent?: ReadonlyMap<string, string>;
13
16
  /** Reject creation or deletion by another writer while a batch is pending. */
@@ -28,8 +31,8 @@ export interface TextBatchDetails extends FileMutationBatchResult {
28
31
  readonly displayResults?: readonly FileMutationResult[];
29
32
  /** Original call id for each user-facing result. */
30
33
  readonly callIdsByDisplayResult?: readonly string[];
31
- /** Per-call Copy receipts retain destination authority and their own failure evidence. */
32
- readonly copyResults?: ReadonlyMap<string, AgentToolResult<FileMutationBatchResult>>;
34
+ /** Per-call receipts retain only their own output selection and failure evidence. */
35
+ readonly mutationResults?: ReadonlyMap<string, AgentToolResult<FileMutationBatchResult>>;
33
36
  }
34
37
 
35
38
  function resultPath(result: FileMutationResult): string | undefined {
@@ -56,8 +59,8 @@ export function splitTextBatchResult(
56
59
 
57
60
  return new Map(
58
61
  calls.map((call) => {
59
- const copyResult = details?.copyResults?.get(call.id);
60
- if (copyResult) return [call.id, copyResult];
62
+ const mutationResult = details?.mutationResults?.get(call.id);
63
+ if (mutationResult) return [call.id, mutationResult];
61
64
  const agentResults = coalesceResults(agentResultsByCall.get(call.id) ?? []);
62
65
  const displayResults = coalesceResults(displayResultsByCall.get(call.id) ?? []);
63
66
  return [
@@ -14,6 +14,7 @@ import type {
14
14
  import {
15
15
  type AgentToolResult,
16
16
  defineTool,
17
+ type ExtensionAPI,
17
18
  type ExtensionContext,
18
19
  type ToolDefinition,
19
20
  } from "@earendil-works/pi-coding-agent";
@@ -94,12 +95,14 @@ import { writeAgentResult } from "./write-agent-result.js";
94
95
  import { mutationResultSchema, structuredMutation } from "./structured-result.js";
95
96
  import type { ResultTargetStore } from "pi-agent-resource";
96
97
 
98
+ /** Build a mutation tool; host events report terminal filesystem approvals to Herdr. */
97
99
  export function createTextTool<TParameters extends TSchema>(
98
100
  core: TextEditorCore,
99
101
  definition: TextMutationToolRegistration<TParameters>,
100
102
  annotations: ToolCallInterceptionRenderStore,
101
103
  getLastResolvedSource: () => string | undefined,
102
104
  resultTargets?: ResultTargetStore,
105
+ events?: Pick<ExtensionAPI["events"], "emit">,
103
106
  ): ToolDefinition<TParameters, FileMutationBatchResult> {
104
107
  const renderer = core.getToolRenderer(definition.name);
105
108
  const initialRenderCall = renderer?.renderCall;
@@ -332,6 +335,7 @@ export function createTextTool<TParameters extends TSchema>(
332
335
  signal,
333
336
  context,
334
337
  verifyFileSource,
338
+ events,
335
339
  );
336
340
  }
337
341
  const directExecute = () =>
@@ -347,15 +351,9 @@ export function createTextTool<TParameters extends TSchema>(
347
351
  }),
348
352
  getLastResolvedSource(),
349
353
  );
350
- return executeTextToolWithBatch(
351
- toolCallId,
352
- directExecute,
353
- signal,
354
- onUpdate,
355
- context,
356
- );
354
+ return directExecute();
357
355
  };
358
- return execute();
356
+ return executeTextToolWithBatch(toolCallId, execute, signal, onUpdate, context);
359
357
  }),
360
358
  definition.name === "write",
361
359
  );
@@ -3,7 +3,7 @@ Runtime for intercepting streamed Pi tool calls.
3
3
  */
4
4
 
5
5
  import { Allow } from "partial-json";
6
- import { resultError, withStructuredResult } from "pi-agent-resource";
6
+ import { assertJsonData, resultError, withStructuredResult } from "pi-agent-resource";
7
7
  import { mutationDataSchema } from "#src/core/structured-result.js";
8
8
  import {
9
9
  isToolCallAnnotation,
@@ -328,6 +328,27 @@ class InterceptorImpl implements ToolCallInterceptor {
328
328
  await this.finalizeRecovery();
329
329
  this.annotateIncompleteCalls();
330
330
 
331
+ if (event.message.role === "toolResult") {
332
+ const record = this.toolCallRecords.get(event.message.toolCallId);
333
+ const guardResult = record?.blockExecution ? record.guardResult : undefined;
334
+ if (guardResult) {
335
+ // Schema validation can finish before tool_call/tool_result for an aborted prefix.
336
+ // Keep the saved guard outcome; never make the incomplete call executable.
337
+ this.toolCallRecords.delete(event.message.toolCallId);
338
+ const details = guardResult.details;
339
+ if (details !== undefined) assertJsonData(details);
340
+ const batchEntryIndex = this.toolCallBatchEntryIndexes.get(event.message.toolCallId);
341
+ if (batchEntryIndex !== undefined) this.completedBatchEntryIndexes.add(batchEntryIndex);
342
+ return {
343
+ message: {
344
+ ...event.message,
345
+ content: guardResult.content,
346
+ ...(details !== undefined && { details }),
347
+ isError: true,
348
+ },
349
+ };
350
+ }
351
+ }
331
352
  if (event.message.role !== "assistant") {
332
353
  return;
333
354
  }
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-renderer",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
- "diff": "^9.0.0",
10
- "pi-agent-invariant": "0.8.0",
11
- "pi-agent-text-editor": "0.8.0",
12
- "pi-agent-tool-call-interception": "0.8.0",
13
- "pi-agent-tool-ui": "0.8.0",
14
- "vscode-diff": "3.0.1"
9
+ "pi-agent-invariant": "0.8.1",
10
+ "pi-agent-text-editor": "0.8.1",
11
+ "pi-agent-tool-call-interception": "0.8.1",
12
+ "pi-agent-tool-ui": "0.8.1"
15
13
  },
16
14
  "pi": {
17
15
  "extensions": [
18
- "./runtime/entry-79.js"
16
+ "./runtime/entry-80.js"
19
17
  ]
20
18
  },
21
19
  "peerDependencies": {
@@ -953,6 +953,12 @@ function wholeFileOperationSummary(details: unknown):
953
953
 
954
954
  function wholeFileFailureCause(code: string): string {
955
955
  switch (code) {
956
+ case "WRITE_FAILED": {
957
+ return "resource write failed";
958
+ }
959
+ case "POST_WRITE_FAILED": {
960
+ return "post-write processing failed";
961
+ }
956
962
  case "APPLY_UNDO_OWNER_CHANGED": {
957
963
  return "resource owner changed";
958
964
  }
@@ -1002,6 +1008,22 @@ function wholeFileFailureCause(code: string): string {
1002
1008
  function userFacingFailure(
1003
1009
  agentOutput: string,
1004
1010
  details: FileMutationBatchResult | undefined,
1011
+ ): string {
1012
+ const causes = new Set(
1013
+ details?.results?.flatMap((result) =>
1014
+ // Provider reasons can contain private data; decode only public editor failure codes.
1015
+ (result.data.errors ?? []).map((error) => wholeFileFailureCause(error.code ?? "")),
1016
+ ),
1017
+ );
1018
+ return [
1019
+ mutationFailureSummary(agentOutput, details),
1020
+ ...[...causes].map((cause) => `Reason: ${cause}`),
1021
+ ...(details?.effect === "unknown" ? ["Read the affected resource before retrying."] : []),
1022
+ ].join("\n");
1023
+ }
1024
+ function mutationFailureSummary(
1025
+ agentOutput: string,
1026
+ details: FileMutationBatchResult | undefined,
1005
1027
  ): string {
1006
1028
  const rollbacks =
1007
1029
  details?.results?.flatMap((result) => (result.data.rollback ? [result.data.rollback] : [])) ??
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-stale-anchor",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-invariant": "0.8.0",
7
- "pi-agent-read": "0.8.0",
8
- "pi-agent-text-editor": "0.8.0"
6
+ "pi-agent-invariant": "0.8.1",
7
+ "pi-agent-read": "0.8.1",
8
+ "pi-agent-text-editor": "0.8.1"
9
9
  },
10
10
  "pi": {
11
11
  "extensions": [
12
- "./runtime/entry-80.js"
12
+ "./runtime/entry-81.js"
13
13
  ]
14
14
  },
15
15
  "peerDependencies": {
@@ -0,0 +1,2 @@
1
+ export * from "../../../dist/entry-81.js";
2
+ export { default } from "../../../dist/entry-81.js";
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-tool-call-interception",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./src/index.ts",
9
- "default": "./runtime/entry-81.js"
9
+ "default": "./runtime/entry-82.js"
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "pi-agent-tool-ui": "0.8.0"
13
+ "pi-agent-tool-ui": "0.8.1"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "@earendil-works/pi-coding-agent": "*",