pi-agent-ide 0.8.0 → 0.8.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 (508) hide show
  1. package/CHANGELOG.md +70 -40
  2. package/README.md +15 -8
  3. package/dist/{chunk-ICDI27GZ.js → chunk-235QMMVA.js} +1 -1
  4. package/dist/{chunk-N7LMRL64.js → chunk-47SPPIXK.js} +1 -1
  5. package/dist/chunk-4DIUPEDF.js +2 -0
  6. package/dist/{chunk-JMVDFOTQ.js → chunk-57F5GTHO.js} +1 -1
  7. package/dist/{chunk-NULNW6GK.js → chunk-6FGLAVPJ.js} +1 -1
  8. package/dist/{chunk-KL776TGR.js → chunk-6H32W35W.js} +1 -1
  9. package/dist/{chunk-QP2QSQ4U.js → chunk-6OJ565FL.js} +1 -1
  10. package/dist/{chunk-TWWND6NI.js → chunk-6R3Y4AD3.js} +1 -1
  11. package/dist/{chunk-CPZJPGLG.js → chunk-6T7PSDQW.js} +1 -1
  12. package/dist/{chunk-4OYVLXWD.js → chunk-6TJPMBUQ.js} +1 -1
  13. package/dist/{chunk-SBLKPTL3.js → chunk-6XFUICD7.js} +1 -1
  14. package/dist/chunk-7VSVJRRF.js +28 -0
  15. package/dist/{chunk-7JV4VN73.js → chunk-AAC77UD4.js} +1 -1
  16. package/dist/chunk-ANM3Y5FO.js +11 -0
  17. package/dist/chunk-BB4A5UI3.js +5 -0
  18. package/dist/{chunk-7TJ6DWW3.js → chunk-CPELC6JE.js} +1 -1
  19. package/dist/chunk-FTPC44FP.js +33 -0
  20. package/dist/{chunk-SBNR4WZF.js → chunk-GSOYVIQS.js} +1 -1
  21. package/dist/{chunk-Z3PGADVA.js → chunk-HSRH76JN.js} +1 -1
  22. package/dist/{chunk-CSXHCSTH.js → chunk-HSZ4AQ6L.js} +1 -1
  23. package/dist/chunk-I6NPILT5.js +1 -0
  24. package/dist/chunk-K7SRNBIV.js +1 -0
  25. package/dist/{chunk-R5XJSEOE.js → chunk-LCWBVOII.js} +3 -3
  26. package/dist/{chunk-MZXX353D.js → chunk-LEJKDYCK.js} +1 -1
  27. package/dist/{chunk-3G54ZL2L.js → chunk-NJ7C4KMA.js} +1 -1
  28. package/dist/{chunk-CTJV77FR.js → chunk-NUM3YQGK.js} +1 -1
  29. package/dist/chunk-OJEIX7OZ.js +1 -0
  30. package/dist/{chunk-EY65TFHJ.js → chunk-PJL3UVMJ.js} +1 -1
  31. package/dist/{chunk-E4HPRLRB.js → chunk-QT3EAHOG.js} +1 -1
  32. package/dist/{chunk-HCN5W76B.js → chunk-RIJMXO43.js} +1 -1
  33. package/dist/chunk-RMI3NMQY.js +23 -0
  34. package/dist/chunk-RQ7JJ7GV.js +4 -0
  35. package/dist/{chunk-4XPUN4QN.js → chunk-RVU73VKN.js} +1 -1
  36. package/dist/{chunk-OJX3RJ5A.js → chunk-RW2GTYQI.js} +1 -1
  37. package/dist/{chunk-PNP2KNGP.js → chunk-SDAH3ECM.js} +1 -1
  38. package/dist/chunk-SGQWRIRJ.js +10 -0
  39. package/dist/{chunk-IUSLSROY.js → chunk-SMIFCAAX.js} +1 -1
  40. package/dist/chunk-SWBJS3U4.js +1 -0
  41. package/dist/chunk-T7MWQQIF.js +3 -0
  42. package/dist/{chunk-RAZP42IQ.js → chunk-VAXLSPPU.js} +1 -1
  43. package/dist/{chunk-XZDOVPRC.js → chunk-VMTOFEXF.js} +1 -1
  44. package/dist/{chunk-7HDK3NRQ.js → chunk-VXP5BMW7.js} +1 -1
  45. package/dist/{chunk-WE42GBGU.js → chunk-XAHU42FP.js} +3 -3
  46. package/dist/{chunk-UBH6X3D3.js → chunk-XBQR74IK.js} +1 -1
  47. package/dist/{chunk-7NS3QUIE.js → chunk-XG7QNAKW.js} +1 -1
  48. package/dist/{chunk-GW6NZQTQ.js → chunk-XLWCSJMR.js} +1 -1
  49. package/dist/{chunk-2K65BSXS.js → chunk-XXLLY66B.js} +1 -1
  50. package/dist/chunk-YFP4P2FV.js +1 -0
  51. package/dist/{chunk-75SWXD2Z.js → chunk-YIXP2ALP.js} +1 -1
  52. package/dist/{chunk-MOJ5RR35.js → chunk-ZJQRLVVV.js} +1 -1
  53. package/dist/entry-0.js +1 -1
  54. package/dist/entry-1.js +1 -1
  55. package/dist/entry-10.js +1 -1
  56. package/dist/entry-11.js +1 -1
  57. package/dist/entry-12.js +1 -1
  58. package/dist/entry-13.js +1 -1
  59. package/dist/entry-14.js +1 -1
  60. package/dist/entry-15.js +1 -1
  61. package/dist/entry-16.js +1 -1
  62. package/dist/entry-17.js +1 -1
  63. package/dist/entry-18.js +1 -0
  64. package/dist/entry-19.js +1 -1
  65. package/dist/entry-2.js +1 -1
  66. package/dist/entry-20.js +1 -1
  67. package/dist/entry-22.js +1 -1
  68. package/dist/entry-23.js +1 -1
  69. package/dist/entry-24.js +1 -1
  70. package/dist/entry-25.js +1 -1
  71. package/dist/entry-26.js +1 -2
  72. package/dist/entry-27.js +1 -1
  73. package/dist/entry-28.js +1 -4
  74. package/dist/entry-29.js +2 -1
  75. package/dist/entry-3.js +1 -1
  76. package/dist/entry-30.js +1 -1
  77. package/dist/entry-31.js +4 -1
  78. package/dist/entry-32.js +1 -18
  79. package/dist/entry-33.js +1 -1
  80. package/dist/entry-34.js +1 -1
  81. package/dist/entry-35.js +18 -1
  82. package/dist/entry-36.js +1 -1
  83. package/dist/entry-37.js +1 -1
  84. package/dist/entry-38.js +1 -1
  85. package/dist/entry-39.js +1 -1
  86. package/dist/entry-4.js +1 -1
  87. package/dist/entry-40.js +1 -1
  88. package/dist/entry-41.js +1 -1
  89. package/dist/entry-42.js +1 -1
  90. package/dist/entry-43.js +1 -1
  91. package/dist/entry-44.js +1 -1
  92. package/dist/entry-45.js +1 -1
  93. package/dist/entry-46.js +1 -25
  94. package/dist/entry-47.js +1 -1
  95. package/dist/entry-48.js +1 -1
  96. package/dist/entry-49.js +25 -1
  97. package/dist/entry-5.js +1 -1
  98. package/dist/entry-50.js +1 -1
  99. package/dist/entry-51.js +1 -3
  100. package/dist/entry-52.js +1 -13
  101. package/dist/entry-53.js +1 -1
  102. package/dist/entry-54.js +3 -1
  103. package/dist/entry-55.js +13 -1
  104. package/dist/entry-56.js +1 -1
  105. package/dist/entry-57.js +1 -1
  106. package/dist/entry-58.js +1 -1
  107. package/dist/entry-59.js +1 -1
  108. package/dist/entry-6.js +1 -1
  109. package/dist/entry-60.js +1 -1
  110. package/dist/entry-61.js +1 -1
  111. package/dist/entry-62.js +1 -0
  112. package/dist/entry-63.js +1 -1
  113. package/dist/entry-64.js +1 -0
  114. package/dist/entry-65.js +0 -1
  115. package/dist/entry-66.js +1 -1
  116. package/dist/entry-67.js +0 -1
  117. package/dist/entry-68.js +1 -1
  118. package/dist/entry-69.js +1 -1
  119. package/dist/entry-7.js +1 -1
  120. package/dist/entry-70.js +1 -1
  121. package/dist/entry-71.js +1 -1
  122. package/dist/entry-72.js +1 -0
  123. package/dist/entry-73.js +1 -1
  124. package/dist/entry-74.js +1 -0
  125. package/dist/entry-75.js +0 -1
  126. package/dist/entry-76.js +1 -1
  127. package/dist/entry-77.js +0 -1
  128. package/dist/entry-78.js +1 -80
  129. package/dist/entry-79.js +1 -21
  130. package/dist/entry-8.js +1 -1
  131. package/dist/entry-80.js +1 -2
  132. package/dist/entry-81.js +80 -1
  133. package/dist/entry-82.js +22 -1
  134. package/dist/entry-83.js +2 -1
  135. package/dist/entry-84.js +1 -3
  136. package/dist/entry-85.js +1 -1
  137. package/dist/entry-86.js +1 -1
  138. package/dist/entry-87.js +1 -1
  139. package/dist/entry-88.js +3 -0
  140. package/dist/entry-89.js +1 -0
  141. package/dist/entry-9.js +1 -1
  142. package/dist/entry-90.js +1 -0
  143. package/dist/entry-91.js +1 -0
  144. package/dist/pi-agent-ide.js +53 -31
  145. package/docs/agent-guides/debugger.md +2 -0
  146. package/docs/agent-guides/editing.md +3 -3
  147. package/docs/agent-guides/search-code.md +5 -3
  148. package/docs/agent-guides/select-code.md +9 -6
  149. package/docs/agent-guides/ssh.md +1 -1
  150. package/docs/code-review.md +5 -0
  151. package/docs/configuration.md +52 -8
  152. package/docs/development.md +9 -13
  153. package/docs/directory-operations.md +1 -1
  154. package/docs/extensions.md +99 -2
  155. package/docs/releases.md +1 -1
  156. package/docs/settings-help.md +39 -0
  157. package/docs/structured-results.md +11 -6
  158. package/docs/tools.md +1 -0
  159. package/docs/user-hooks.md +4 -2
  160. package/node_modules/pi-agent-doctor/package.json +7 -10
  161. package/node_modules/pi-agent-doctor/runtime/entry-26.js +1 -0
  162. package/node_modules/pi-agent-doctor/runtime/entry-27.js +1 -0
  163. package/node_modules/pi-agent-documentation/package.json +2 -2
  164. package/node_modules/pi-agent-documentation/runtime/entry-28.js +1 -0
  165. package/node_modules/pi-agent-filesystem/package.json +8 -8
  166. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  167. package/node_modules/pi-agent-filesystem-jq/package.json +6 -7
  168. package/node_modules/pi-agent-filesystem-jq/runtime/entry-31.js +2 -0
  169. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  170. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  171. package/node_modules/pi-agent-filesystem-text/runtime/entry-33.js +2 -0
  172. package/node_modules/pi-agent-ide-ast/package.json +15 -41
  173. package/node_modules/pi-agent-ide-ast/runtime/entry-34.js +1 -0
  174. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +6 -5
  175. package/node_modules/pi-agent-ide-changes/package.json +10 -11
  176. package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +1 -0
  177. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
  178. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  179. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  180. package/node_modules/pi-agent-ide-languages/runtime/entry-39.js +2 -0
  181. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  182. package/node_modules/pi-agent-ide-lint/runtime/entry-40.js +2 -0
  183. package/node_modules/pi-agent-ide-lsp/package.json +10 -13
  184. package/node_modules/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
  185. package/node_modules/pi-agent-image/package.json +3 -3
  186. package/node_modules/pi-agent-invariant/package.json +2 -2
  187. package/node_modules/pi-agent-pdf/package.json +3 -4
  188. package/node_modules/pi-agent-read/package.json +12 -12
  189. package/node_modules/pi-agent-read/runtime/entry-46.js +0 -1
  190. package/node_modules/pi-agent-read/runtime/entry-49.js +2 -0
  191. package/node_modules/pi-agent-resource/package.json +2 -2
  192. package/node_modules/pi-agent-resource/src/resource-error.ts +11 -0
  193. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -0
  194. package/node_modules/pi-agent-search/package.json +9 -9
  195. package/node_modules/pi-agent-search/runtime/entry-51.js +0 -1
  196. package/node_modules/pi-agent-search/runtime/entry-52.js +1 -0
  197. package/node_modules/pi-agent-search/runtime/entry-54.js +2 -0
  198. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  199. package/node_modules/pi-agent-search/src/api/presentation.ts +10 -2
  200. package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
  201. package/node_modules/pi-agent-search/src/api/search.ts +7 -0
  202. package/node_modules/pi-agent-search/src/core/search-core.ts +23 -3
  203. package/node_modules/pi-agent-search-text/index.ts +2 -0
  204. package/node_modules/pi-agent-search-text/package.json +14 -14
  205. package/node_modules/pi-agent-search-text/runtime/entry-55.js +1 -0
  206. package/node_modules/pi-agent-search-text/runtime/entry-57.js +1 -0
  207. package/node_modules/pi-agent-search-text/src/search-backend.ts +18 -10
  208. package/node_modules/pi-agent-search-text/src/search-session.ts +68 -9
  209. package/node_modules/pi-agent-text/package.json +3 -3
  210. package/node_modules/pi-agent-text/runtime/entry-59.js +1 -0
  211. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  212. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-60.js +2 -0
  213. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -6
  214. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-61.js +1 -0
  215. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-62.js +2 -0
  216. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  217. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
  218. package/node_modules/pi-agent-text-editor/index.ts +2 -0
  219. package/node_modules/pi-agent-text-editor/package.json +26 -34
  220. package/node_modules/pi-agent-text-editor/runtime/entry-78.js +0 -1
  221. package/node_modules/pi-agent-text-editor/runtime/entry-79.js +1 -0
  222. package/node_modules/pi-agent-text-editor/runtime/entry-80.js +1 -0
  223. package/node_modules/pi-agent-text-editor/runtime/entry-81.js +2 -0
  224. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  225. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  226. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
  227. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  228. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  229. package/node_modules/pi-agent-text-editor/src/core/extension.ts +4 -1
  230. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +40 -11
  231. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  232. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  233. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +29 -20
  234. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  235. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  236. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  237. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  238. package/node_modules/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
  239. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
  240. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +35 -14
  241. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  242. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
  243. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
  244. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  245. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
  246. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -8
  247. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
  248. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +35 -2
  249. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +17 -0
  250. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -5
  251. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  252. package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +1 -0
  253. package/node_modules/pi-agent-tool-ui/package.json +6 -2
  254. package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +1 -0
  255. package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +1 -0
  256. package/node_modules/pi-agent-tool-ui/src/operation-approval.ts +271 -0
  257. package/node_modules/pi-agent-web/package.json +8 -11
  258. package/node_modules/pi-agent-web-html/package.json +3 -5
  259. package/node_modules/pi-agent-web-html/runtime/entry-88.js +2 -0
  260. package/node_modules/pi-agent-web-image/package.json +4 -4
  261. package/node_modules/pi-agent-web-image/runtime/entry-89.js +2 -0
  262. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  263. package/node_modules/pi-agent-web-pdf/runtime/entry-90.js +2 -0
  264. package/node_modules/pi-agent-web-text/package.json +4 -4
  265. package/node_modules/pi-agent-web-text/runtime/entry-91.js +2 -0
  266. package/package.json +65 -53
  267. package/skills/configure-agent-ide/SKILL.md +38 -0
  268. package/src/api/approval.ts +5 -0
  269. package/src/api/content.ts +6 -0
  270. package/src/api/settings.ts +198 -0
  271. package/src/api/tips.ts +3 -0
  272. package/src/backend/debugger-registration.ts +5 -1
  273. package/src/code-review/extension.ts +10 -4
  274. package/src/code-review/reviewer.ts +8 -0
  275. package/src/composite/host-version.ts +29 -5
  276. package/src/composite/ide-alias-rendering.ts +97 -0
  277. package/src/composite/nested-tool-rendering.ts +90 -9
  278. package/src/composite/preferences.ts +13 -0
  279. package/src/composite/search-facts.ts +45 -0
  280. package/src/composite/settings-documentation.ts +68 -0
  281. package/src/composite/settings-help.ts +106 -0
  282. package/src/composite/settings-registry.ts +94 -0
  283. package/src/composite/text-results.ts +170 -30
  284. package/src/composite/tool-availability.ts +11 -2
  285. package/src/core/diagnostic-entry.ts +31 -8
  286. package/src/core/diagnostic-store.ts +19 -3
  287. package/src/core/extension.ts +7 -2
  288. package/src/documentation/extension.ts +12 -0
  289. package/src/documentation/registry.ts +10 -2
  290. package/src/documentation/search.ts +166 -0
  291. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  292. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  293. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -7
  294. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-31.js +2 -0
  295. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  296. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
  297. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  298. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-33.js +2 -0
  299. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +2 -0
  300. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -11
  301. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -5
  302. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-88.js +2 -0
  303. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  304. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +2 -0
  305. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  306. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-90.js +2 -0
  307. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  308. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-91.js +2 -0
  309. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +2 -0
  310. package/src/extensions/pi-agent-read/package.json +12 -12
  311. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  312. package/src/extensions/pi-agent-read/runtime/entry-47.js +1 -0
  313. package/src/extensions/pi-agent-read/runtime/entry-49.js +2 -0
  314. package/src/extensions/pi-agent-search/package.json +9 -9
  315. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +2 -0
  316. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  317. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
  318. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +1 -0
  319. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +1 -0
  320. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +18 -10
  321. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +68 -9
  322. package/src/extensions/pi-agent-search/runtime/entry-51.js +0 -1
  323. package/src/extensions/pi-agent-search/runtime/entry-52.js +1 -0
  324. package/src/extensions/pi-agent-search/runtime/entry-53.js +1 -0
  325. package/src/extensions/pi-agent-search/runtime/entry-54.js +2 -0
  326. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  327. package/src/extensions/pi-agent-search/src/api/presentation.ts +10 -2
  328. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
  329. package/src/extensions/pi-agent-search/src/api/search.ts +7 -0
  330. package/src/extensions/pi-agent-search/src/core/search-core.ts +23 -3
  331. package/src/extensions/pi-agent-text-editor/index.ts +2 -0
  332. package/src/extensions/pi-agent-text-editor/package.json +26 -34
  333. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  334. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-60.js +2 -0
  335. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -6
  336. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-61.js +1 -0
  337. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-62.js +2 -0
  338. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  339. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-63.js +1 -0
  340. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -8
  342. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
  343. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +35 -2
  344. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +17 -0
  345. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -5
  346. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -1
  347. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +1 -0
  348. package/src/extensions/pi-agent-text-editor/runtime/entry-80.js +1 -0
  349. package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +2 -0
  350. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +1 -1
  351. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  352. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
  353. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +2 -2
  354. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +6 -12
  355. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +4 -1
  356. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +40 -11
  357. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  358. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +18 -9
  359. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +29 -20
  360. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +13 -9
  361. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-coordinator.ts +16 -8
  362. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +118 -36
  363. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +7 -4
  364. package/src/extensions/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
  365. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
  366. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +35 -14
  367. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +22 -1
  368. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
  369. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
  370. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  371. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
  372. package/src/pi-agent-ide.ts +74 -15
  373. package/src/plugins/pi-agent-ide-ast/package.json +15 -41
  374. package/src/plugins/pi-agent-ide-ast/runtime/entry-34.js +1 -0
  375. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +6 -5
  376. package/src/plugins/pi-agent-ide-changes/package.json +10 -11
  377. package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +1 -0
  378. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
  379. package/src/plugins/pi-agent-ide-debugger/index.ts +158 -55
  380. package/src/plugins/pi-agent-ide-debugger/src/debugmcp-client.ts +118 -0
  381. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +47 -0
  382. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +2 -0
  383. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +146 -1
  384. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +12 -0
  385. package/src/plugins/pi-agent-ide-debugger/src/vscode-backend.ts +497 -0
  386. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  387. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  388. package/src/plugins/pi-agent-ide-languages/runtime/entry-39.js +2 -0
  389. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  390. package/src/plugins/pi-agent-ide-lint/runtime/entry-40.js +2 -0
  391. package/src/plugins/pi-agent-ide-lsp/package.json +10 -13
  392. package/src/plugins/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
  393. package/src/plugins/pi-agent-ide-terminal/index.ts +2 -0
  394. package/src/plugins/pi-agent-ide-terminal/src/origin.ts +30 -0
  395. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +34 -0
  396. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +11 -2
  397. package/src/plugins/pi-agent-ide-terminal/src/types.ts +9 -0
  398. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +72 -26
  399. package/src/tips/core.ts +5 -2
  400. package/src/tips/extension.ts +30 -2
  401. package/src/tips/persistence.ts +29 -27
  402. package/src/tips/setup-hint.ts +19 -0
  403. package/dist/chunk-3ZGDMTMD.js +0 -25
  404. package/dist/chunk-5KFVDYCI.js +0 -1
  405. package/dist/chunk-ABFCAOU5.js +0 -1
  406. package/dist/chunk-BIG45IPN.js +0 -2
  407. package/dist/chunk-BMOJTJJJ.js +0 -3
  408. package/dist/chunk-BQ67M4NC.js +0 -3
  409. package/dist/chunk-IH5NW5JX.js +0 -11
  410. package/dist/chunk-NRZO5KJT.js +0 -9
  411. package/dist/chunk-O36UC74T.js +0 -1
  412. package/dist/chunk-OLI3JPHJ.js +0 -28
  413. package/dist/chunk-SSWUUBIR.js +0 -1
  414. package/dist/chunk-UUJJRXHG.js +0 -29
  415. package/dist/entry-21.js +0 -1
  416. package/docs/research/apply-native-capability-matrix.md +0 -174
  417. package/docs/research/apply-read-latency.md +0 -221
  418. package/docs/research/codemode-write-context.md +0 -56
  419. package/docs/research/lpt-393-fuzzy-results/file.json +0 -152
  420. package/docs/research/lpt-393-fuzzy-results/repo.json +0 -122
  421. package/docs/research/lpt-393-search-fuzzy-fallback.md +0 -97
  422. package/docs/research/native-codemode-batch-decision.md +0 -31
  423. package/docs/research/native-codemode-batching.md +0 -65
  424. package/node_modules/pi-agent-doctor/runtime/entry-19.js +0 -1
  425. package/node_modules/pi-agent-doctor/runtime/entry-20.js +0 -1
  426. package/node_modules/pi-agent-doctor/runtime/entry-21.js +0 -1
  427. package/node_modules/pi-agent-filesystem/runtime/entry-26.js +0 -2
  428. package/node_modules/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  429. package/node_modules/pi-agent-filesystem-jq/runtime/entry-28.js +0 -2
  430. package/node_modules/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  431. package/node_modules/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  432. package/node_modules/pi-agent-ide-changes/runtime/entry-34.js +0 -2
  433. package/node_modules/pi-agent-ide-languages/runtime/entry-36.js +0 -2
  434. package/node_modules/pi-agent-image/runtime/entry-39.js +0 -1
  435. package/node_modules/pi-agent-invariant/runtime/entry-40.js +0 -1
  436. package/node_modules/pi-agent-pdf/runtime/entry-41.js +0 -1
  437. package/node_modules/pi-agent-search/runtime/entry-49.js +0 -1
  438. package/node_modules/pi-agent-search-text/runtime/entry-52.js +0 -2
  439. package/node_modules/pi-agent-search-text/runtime/entry-54.js +0 -1
  440. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  441. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -2
  442. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  443. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -2
  444. package/node_modules/pi-agent-text-editor/runtime/entry-62.js +0 -1
  445. package/node_modules/pi-agent-text-editor/runtime/entry-64.js +0 -1
  446. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  447. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  448. package/node_modules/pi-agent-tool-call-interception/runtime/entry-81.js +0 -1
  449. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
  450. package/node_modules/pi-agent-web-html/runtime/entry-84.js +0 -2
  451. package/node_modules/pi-agent-web-image/runtime/entry-85.js +0 -2
  452. package/node_modules/pi-agent-web-pdf/runtime/entry-86.js +0 -2
  453. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-27.js +0 -2
  454. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-28.js +0 -2
  455. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-29.js +0 -2
  456. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-26.js +0 -2
  457. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-84.js +0 -2
  458. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-85.js +0 -2
  459. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-86.js +0 -2
  460. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
  461. package/src/extensions/pi-agent-read/runtime/entry-42.js +0 -1
  462. package/src/extensions/pi-agent-read/runtime/entry-43.js +0 -1
  463. package/src/extensions/pi-agent-read/runtime/entry-44.js +0 -1
  464. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-52.js +0 -2
  465. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +0 -1
  466. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +0 -1
  467. package/src/extensions/pi-agent-search/runtime/entry-49.js +0 -1
  468. package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
  469. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-57.js +0 -2
  470. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -2
  471. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +0 -1
  472. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-61.js +0 -2
  473. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-79.js +0 -2
  474. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  475. package/src/extensions/pi-agent-text-editor/runtime/entry-62.js +0 -1
  476. package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +0 -1
  477. package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +0 -1
  478. package/src/plugins/pi-agent-ide-ast/runtime/entry-31.js +0 -1
  479. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -2
  480. package/src/plugins/pi-agent-ide-changes/runtime/entry-33.js +0 -1
  481. package/src/plugins/pi-agent-ide-changes/runtime/entry-34.js +0 -2
  482. package/src/plugins/pi-agent-ide-languages/runtime/entry-36.js +0 -2
  483. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-25.js +0 -0
  484. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem}/runtime/entry-29.js +0 -0
  485. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
  486. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-32.js +0 -0
  487. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
  488. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
  489. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
  490. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-42.js +0 -0
  491. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-43.js +0 -0
  492. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-44.js +0 -0
  493. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-47.js +0 -0
  494. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-48.js +0 -0
  495. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-50.js +0 -0
  496. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-53.js +0 -0
  497. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-56.js +0 -0
  498. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-58.js +0 -0
  499. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-63.js +0 -0
  500. /package/node_modules/{pi-agent-web → pi-agent-text-editor-stale-anchor}/runtime/entry-83.js +0 -0
  501. /package/node_modules/{pi-agent-web-text → pi-agent-web}/runtime/entry-87.js +0 -0
  502. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
  503. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-48.js +0 -0
  504. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-58.js +0 -0
  505. /package/src/extensions/{pi-agent-read/extensions/pi-agent-web → pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor}/runtime/entry-83.js +0 -0
  506. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
  507. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
  508. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
@@ -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 [
@@ -0,0 +1,38 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ import type { TextEditorCore } from "./text-editor-core.js";
4
+
5
+ const activeOrigin = new AsyncLocalStorage<string>();
6
+ const executionRoots = new WeakMap<TextEditorCore, Map<string, string>>();
7
+
8
+ /** Retain native execution ancestry, never infer ownership from paths or current activity. */
9
+ export function registerTextEditOrigins(pi: ExtensionAPI, core: TextEditorCore): void {
10
+ const roots = new Map<string, string>();
11
+ executionRoots.set(core, roots);
12
+ pi.on("tool_call", (event) => {
13
+ const parent = event.parentToolCallId;
14
+ roots.set(
15
+ event.toolCallId,
16
+ parent === undefined ? event.toolCallId : (roots.get(parent) ?? parent),
17
+ );
18
+ });
19
+ pi.on("tool_result", (event) => {
20
+ roots.delete(event.toolCallId);
21
+ });
22
+ pi.on("agent_end", () => {
23
+ roots.clear();
24
+ });
25
+ pi.on("session_shutdown", () => {
26
+ roots.clear();
27
+ });
28
+ }
29
+
30
+ /** Execute an edit or its delayed batch with the original visible tool-call identity. */
31
+ export function withTextEditOrigin<T>(core: TextEditorCore, toolCallId: string, work: () => T): T {
32
+ return activeOrigin.run(executionRoots.get(core)?.get(toolCallId) ?? toolCallId, work);
33
+ }
34
+
35
+ /** Snapshot this identity before deferring final processing outside its originating call. */
36
+ export function currentTextEditOrigin(): string | undefined {
37
+ return activeOrigin.getStore();
38
+ }
@@ -25,6 +25,7 @@ import {
25
25
  type Resource,
26
26
  type ResourceResolver,
27
27
  type ResourceResolverContext,
28
+ type ResultTargetStore,
28
29
  } from "pi-agent-resource";
29
30
  import {
30
31
  createTextDocument,
@@ -95,6 +96,7 @@ import type {
95
96
  TextAnchorInspectionOutcome,
96
97
  TextAnchorInspectionRequest,
97
98
  } from "#src/api/anchor-inspection.js";
99
+ import { currentTextEditOrigin } from "./text-edit-origin.js";
98
100
  import type {
99
101
  TextEditCompletion,
100
102
  TextEditCompletionListener,
@@ -442,11 +444,13 @@ export interface TextEditorCore {
442
444
  renderToolPromptGuideline(tool: TextEditorToolId): string | undefined;
443
445
  }
444
446
 
447
+ /** Share issued-result authority with streamed anchor inspection, before tool-call normalization. */
445
448
  export function createTextEditorCore(
446
449
  registerMutationTool?: (
447
450
  registration: AnyTextMutationToolRegistration,
448
451
  core: TextEditorCore,
449
452
  ) => void,
453
+ resultTargets?: ResultTargetStore,
450
454
  ): TextEditorCore {
451
455
  const projectConfig = loadTextEditorConfig(process.cwd());
452
456
  const resolvers: RegisteredResolver[] = [];
@@ -784,7 +788,7 @@ export function createTextEditorCore(
784
788
  return toolRenderers.get(tool);
785
789
  },
786
790
  inspectTextAnchors(request): Promise<TextAnchorInspectionOutcome> {
787
- return inspectTextResource(request, [...resolvers], anchorRegistry.snapshot());
791
+ return inspectTextResource(request, [...resolvers], anchorRegistry.snapshot(), resultTargets);
788
792
  },
789
793
  resolveTextAnchorResources(value, kinds, context): Promise<readonly TextTarget[] | undefined> {
790
794
  return anchorRegistry.snapshot().resolveResources(value, context, new Set(kinds));
@@ -993,7 +997,7 @@ export function createTextEditorCore(
993
997
  const contributions = createPluginContributionController(
994
998
  plugin.id,
995
999
  registerContributions,
996
- (request) => inspectTextResource(request, [...resolvers], anchorRegistry.snapshot()),
1000
+ (request) => core.inspectTextAnchors(request),
997
1001
  (listener) => core.onMutationTool(listener),
998
1002
  (listener) => core.onDidEdit(listener),
999
1003
  (request) => previewTextMutation(core, request),
@@ -1110,7 +1114,35 @@ async function inspectTextResource(
1110
1114
  request: TextAnchorInspectionRequest,
1111
1115
  resolvers: readonly RegisteredResolver[],
1112
1116
  anchors: TextAnchorRegistrySnapshot,
1117
+ resultTargets?: ResultTargetStore,
1113
1118
  ): Promise<TextAnchorInspectionOutcome> {
1119
+ if (resultTargets !== undefined) {
1120
+ try {
1121
+ const source = resultTargets.source(request.source, request.cwd);
1122
+ if (Array.isArray(source) || (typeof source === "string" && source.startsWith("RESULT#"))) {
1123
+ const selected = resultTargets.resolve(source, request.cwd);
1124
+ if (!selected.complete)
1125
+ return { kind: "failed", reason: "Incomplete result selections cannot authorize edits." };
1126
+ await resultTargets.verify(selected, request.signal);
1127
+ for (const target of selected.targets) {
1128
+ const inspected = await inspectTextResource(
1129
+ { ...request, source: target.source },
1130
+ resolvers,
1131
+ anchors,
1132
+ );
1133
+ if (inspected.kind !== "valid") return inspected;
1134
+ }
1135
+ return { kind: "valid" };
1136
+ }
1137
+ } catch (error) {
1138
+ request.signal?.throwIfAborted();
1139
+ return {
1140
+ kind: "failed",
1141
+ reason: error instanceof Error ? error.message : String(error),
1142
+ cause: error,
1143
+ };
1144
+ }
1145
+ }
1114
1146
  const context: ResourceResolverContext = {
1115
1147
  cwd: request.cwd,
1116
1148
  ...(request.signal !== undefined && { signal: request.signal }),
@@ -1791,7 +1823,9 @@ async function prepareTextResource(
1791
1823
  }
1792
1824
 
1793
1825
  interface FinalizeTextResourceRequest<Result> {
1826
+ readonly parentToolCallId?: string;
1794
1827
  readonly postProcessingFinal?: boolean;
1828
+ readonly savedText?: string;
1795
1829
  readonly requestedSource: string;
1796
1830
  readonly outcomeSource: string;
1797
1831
  readonly resource: Resource;
@@ -1806,37 +1840,58 @@ interface FinalizeTextResourceRequest<Result> {
1806
1840
  readonly result: Result;
1807
1841
  }
1808
1842
 
1843
+ async function readSavedText(
1844
+ resource: Resource,
1845
+ context: ResourceResolverContext,
1846
+ ): Promise<string> {
1847
+ try {
1848
+ const content = await requiredValue(resource.read)(
1849
+ context.signal === undefined ? {} : { signal: context.signal },
1850
+ );
1851
+ if (isAgentContent(content) && content.length === 1 && content[0].type === "text")
1852
+ return content[0].text;
1853
+ throw new ResourceError("INVALID_RESOURCE_READBACK", resource.source, "applied");
1854
+ } catch (error) {
1855
+ if (error instanceof ResourceError) {
1856
+ if (error.effect === "applied") throw error;
1857
+ throw new ResourceError(error.code, resource.source, "applied", { cause: error });
1858
+ }
1859
+ throw new ResourceError("RESOURCE_READBACK_FAILED", resource.source, "applied");
1860
+ }
1861
+ }
1809
1862
  async function finalizeTextResource<Result>(
1810
1863
  request: FinalizeTextResourceRequest<Result>,
1811
1864
  ): Promise<Exclude<TextResourceEditOutcome<Result>, { readonly kind: "failed" }>> {
1812
1865
  const skipPostEdit = request.resource.skipPostEdit === true;
1866
+ const savedText =
1867
+ !skipPostEdit && request.resource.read
1868
+ ? await readSavedText(request.resource, request.context)
1869
+ : request.requestedText;
1813
1870
  if (
1814
1871
  !skipPostEdit &&
1815
1872
  request.postProcessingFinal &&
1816
1873
  !request.context.signal?.aborted &&
1817
- request.resource.read
1818
- ) {
1819
- const current = await request.resource.read(
1820
- request.context.signal ? { signal: request.context.signal } : {},
1874
+ savedText !== (request.savedText ?? request.requestedText)
1875
+ )
1876
+ throw Object.assign(
1877
+ new Error(`Resource changed before final post-processing: ${request.resource.source}`),
1878
+ { code: "POST_EDIT_STALE", effect: "applied" as const },
1821
1879
  );
1822
- if (
1823
- !isAgentContent(current) ||
1824
- current.length !== 1 ||
1825
- current[0].type !== "text" ||
1826
- current[0].text !== request.requestedText
1827
- )
1828
- throw Object.assign(
1829
- new Error(`Resource changed before final post-processing: ${request.resource.source}`),
1830
- { code: "POST_EDIT_STALE" },
1831
- );
1832
- }
1880
+ const parentToolCallId = request.postProcessingFinal
1881
+ ? request.parentToolCallId
1882
+ : currentTextEditOrigin();
1833
1883
  const deferred =
1834
1884
  !skipPostEdit &&
1835
1885
  !request.postProcessingFinal &&
1836
1886
  deferPostEdit(request.resource.source, () =>
1837
- finalizeTextResource({ ...request, postProcessingFinal: true }),
1887
+ finalizeTextResource({
1888
+ ...request,
1889
+ savedText,
1890
+ ...(parentToolCallId === undefined ? {} : { parentToolCallId }),
1891
+ postProcessingFinal: true,
1892
+ }),
1838
1893
  );
1839
- const requestedAfter = createTextDocument(request.resource.source, request.requestedText);
1894
+ const requestedAfter = createTextDocument(request.resource.source, savedText);
1840
1895
  const transaction: TextPostEditTransaction = {
1841
1896
  source: request.requestedSource,
1842
1897
  resourceSource: request.resource.source,
@@ -1876,24 +1931,14 @@ async function finalizeTextResource<Result>(
1876
1931
  ],
1877
1932
  },
1878
1933
  });
1879
- let finalText = request.requestedText;
1880
-
1881
- if (!skipPostEdit && request.resource.read !== undefined) {
1882
- try {
1883
- const reread = await request.resource.read(
1884
- request.context.signal === undefined ? {} : { signal: request.context.signal },
1885
- );
1886
-
1887
- if (isAgentContent(reread) && reread.length === 1 && reread[0].type === "text") {
1888
- finalText = reread[0].text;
1889
- }
1890
- } catch {
1891
- // The requested mutation remains the successful fallback when a final reread fails.
1892
- }
1893
- }
1934
+ const finalText =
1935
+ !skipPostEdit && !deferred && request.resource.read
1936
+ ? await readSavedText(request.resource, request.context)
1937
+ : savedText;
1894
1938
 
1895
1939
  const finalAfter = createTextDocument(request.resource.source, finalText);
1896
1940
  const completion: TextEditCompletion = {
1941
+ ...(parentToolCallId === undefined ? {} : { parentToolCallId }),
1897
1942
  source: request.requestedSource,
1898
1943
  resourceSource: request.resource.source,
1899
1944
  resolvedBy: request.resolvedBy,
@@ -2145,20 +2190,33 @@ async function editTextResource<Result>(
2145
2190
  };
2146
2191
  }
2147
2192
 
2148
- return finalizeTextResource({
2149
- requestedSource: source,
2150
- outcomeSource: resource.source,
2151
- resource,
2152
- resolvedBy: resolver.id,
2153
- existed: true,
2154
- before,
2155
- requestedText: mutation.text,
2156
- context,
2157
- presenters,
2158
- postEditHandlers,
2159
- editCompletionListeners,
2160
- result: mutation.result,
2161
- });
2193
+ try {
2194
+ return await finalizeTextResource({
2195
+ requestedSource: source,
2196
+ outcomeSource: resource.source,
2197
+ resource,
2198
+ resolvedBy: resolver.id,
2199
+ existed: true,
2200
+ before,
2201
+ requestedText: mutation.text,
2202
+ context,
2203
+ presenters,
2204
+ postEditHandlers,
2205
+ editCompletionListeners,
2206
+ result: mutation.result,
2207
+ });
2208
+ } catch (error) {
2209
+ return {
2210
+ kind: "failed",
2211
+ failure: {
2212
+ code: "POST_WRITE_FAILED",
2213
+ source: resource.source,
2214
+ resolverId: resolver.id,
2215
+ message: error instanceof Error ? error.message : String(error),
2216
+ cause: error,
2217
+ },
2218
+ };
2219
+ }
2162
2220
  }
2163
2221
 
2164
2222
  return {