pi-agent-ide 0.8.4 → 0.9.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 (649) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +24 -29
  3. package/dist/{chunk-CM3XGY72.js → chunk-2AY526TN.js} +1 -1
  4. package/dist/{chunk-LEJKDYCK.js → chunk-2TZDG2JH.js} +1 -1
  5. package/dist/{chunk-DUUOCBS3.js → chunk-35LZOKEW.js} +1 -1
  6. package/dist/chunk-3LVBARLW.js +33 -0
  7. package/dist/{chunk-XBQR74IK.js → chunk-4GBFIGH3.js} +1 -1
  8. package/dist/{chunk-PJL3UVMJ.js → chunk-4IWEKRSP.js} +1 -1
  9. package/dist/chunk-52PFWQMU.js +5 -0
  10. package/dist/chunk-5BGWNYQS.js +1 -0
  11. package/dist/chunk-5PC5INOL.js +1 -0
  12. package/dist/{chunk-QUYXINGZ.js → chunk-5S74Z6Y4.js} +3 -3
  13. package/dist/{chunk-XAHU42FP.js → chunk-6A3ORNW3.js} +2 -2
  14. package/dist/{chunk-ANM3Y5FO.js → chunk-6WCHBHFW.js} +5 -5
  15. package/dist/{chunk-IMGIDBCC.js → chunk-7D7PXIVV.js} +1 -1
  16. package/dist/chunk-7PVDTMEM.js +1 -0
  17. package/dist/chunk-AMIIOWFL.js +1 -0
  18. package/dist/{chunk-TOYN4W4F.js → chunk-B25LXXNV.js} +1 -1
  19. package/dist/chunk-BT2CFM7D.js +11 -0
  20. package/dist/chunk-C2JT2G5K.js +1 -0
  21. package/dist/chunk-DDH3FP4G.js +3 -0
  22. package/dist/{chunk-6T7PSDQW.js → chunk-DVNL5NZE.js} +1 -1
  23. package/dist/chunk-FEZLTM4L.js +1 -0
  24. package/dist/{chunk-CPELC6JE.js → chunk-FHRHYY4M.js} +1 -1
  25. package/dist/chunk-FXPY3V4L.js +10 -0
  26. package/dist/chunk-FYOU4RBH.js +2 -0
  27. package/dist/chunk-G4PRFO6G.js +1 -0
  28. package/dist/chunk-GS5ZRTUG.js +1 -0
  29. package/dist/{chunk-XXLLY66B.js → chunk-GXL4NMHR.js} +1 -1
  30. package/dist/{chunk-QT3EAHOG.js → chunk-H3GEEOOL.js} +1 -1
  31. package/dist/chunk-H5Z54BEU.js +25 -0
  32. package/dist/chunk-H7WAM5RH.js +23 -0
  33. package/dist/{chunk-Z2MNHSJ4.js → chunk-HGCJDIRR.js} +1 -1
  34. package/dist/chunk-HISGZD3C.js +81 -0
  35. package/dist/chunk-HKYVP2Q6.js +3 -0
  36. package/dist/chunk-HRBUY2FF.js +4 -0
  37. package/dist/chunk-IG5DXVDJ.js +1 -0
  38. package/dist/chunk-IOGWZNWT.js +1 -0
  39. package/dist/chunk-IUJUECXH.js +9 -0
  40. package/dist/chunk-KN6VPARZ.js +1 -0
  41. package/dist/{chunk-RW2GTYQI.js → chunk-LF325WYO.js} +1 -1
  42. package/dist/chunk-LXDF2NWX.js +1 -0
  43. package/dist/{chunk-YJ6T3PEP.js → chunk-MDD5ORB6.js} +1 -1
  44. package/dist/{chunk-S72FVLUX.js → chunk-MLFJU2US.js} +1 -1
  45. package/dist/chunk-MPNE25CY.js +5 -0
  46. package/dist/chunk-NA2NEU4V.js +1 -0
  47. package/dist/{chunk-ZJQRLVVV.js → chunk-O7V6G3OO.js} +1 -1
  48. package/dist/chunk-OBTT5INC.js +6 -0
  49. package/dist/{chunk-IICJXZBU.js → chunk-OMNKD7WW.js} +3 -3
  50. package/dist/chunk-OUCVZBOR.js +28 -0
  51. package/dist/chunk-PCGBM2D6.js +17 -0
  52. package/dist/{chunk-235QMMVA.js → chunk-PQWANILR.js} +1 -1
  53. package/dist/{chunk-QRJLIV6P.js → chunk-QJ6V5IAY.js} +6 -6
  54. package/dist/{chunk-SMIFCAAX.js → chunk-RIJRPAL2.js} +1 -1
  55. package/dist/chunk-RIOPUTUJ.js +6 -0
  56. package/dist/{chunk-RMI3NMQY.js → chunk-RIZARTUM.js} +2 -2
  57. package/dist/{chunk-NJ7C4KMA.js → chunk-SRFWT562.js} +1 -1
  58. package/dist/{chunk-U22JNO6N.js → chunk-STUZZM5B.js} +1 -1
  59. package/dist/chunk-T3Z4KXOX.js +2 -0
  60. package/dist/chunk-TSQ6FBTB.js +1 -0
  61. package/dist/chunk-U7YDLVFL.js +1 -0
  62. package/dist/{chunk-KZC7TI5M.js → chunk-UD3DMY3Q.js} +1 -1
  63. package/dist/{chunk-VXP5BMW7.js → chunk-USG6WHAT.js} +1 -1
  64. package/dist/{chunk-ZPT5D4VP.js → chunk-VDJSH3DQ.js} +2 -2
  65. package/dist/{chunk-VMTOFEXF.js → chunk-VMLPXSMK.js} +1 -1
  66. package/dist/chunk-VNWGT367.js +1 -0
  67. package/dist/chunk-WAJW4G4F.js +22 -0
  68. package/dist/chunk-WEE3NM6L.js +1 -0
  69. package/dist/{chunk-IM24DB3K.js → chunk-WES2E4VR.js} +1 -1
  70. package/dist/{chunk-RIJMXO43.js → chunk-WQIMM4SU.js} +1 -1
  71. package/dist/chunk-X2WFNMQR.js +9 -0
  72. package/dist/chunk-XCPIIDFS.js +4 -0
  73. package/dist/chunk-XE4W5YTE.js +2 -0
  74. package/dist/chunk-XUYIK4TX.js +1 -0
  75. package/dist/{chunk-AAC77UD4.js → chunk-YPYROPQF.js} +1 -1
  76. package/dist/chunk-ZXO4D5UB.js +1 -0
  77. package/dist/entry-0.js +1 -1
  78. package/dist/entry-1.js +1 -1
  79. package/dist/entry-10.js +1 -1
  80. package/dist/entry-11.js +1 -1
  81. package/dist/entry-12.js +1 -1
  82. package/dist/entry-13.js +1 -1
  83. package/dist/entry-14.js +1 -1
  84. package/dist/entry-15.js +1 -1
  85. package/dist/entry-16.js +1 -1
  86. package/dist/entry-17.js +1 -1
  87. package/dist/entry-18.js +1 -1
  88. package/dist/entry-19.js +1 -1
  89. package/dist/entry-2.js +1 -1
  90. package/dist/entry-20.js +1 -1
  91. package/dist/entry-21.js +1 -0
  92. package/dist/entry-22.js +1 -1
  93. package/dist/entry-24.js +1 -1
  94. package/dist/entry-25.js +1 -1
  95. package/dist/entry-26.js +1 -1
  96. package/dist/entry-27.js +1 -1
  97. package/dist/entry-28.js +1 -1
  98. package/dist/entry-29.js +1 -2
  99. package/dist/entry-3.js +1 -1
  100. package/dist/entry-30.js +1 -1
  101. package/dist/entry-31.js +2 -4
  102. package/dist/entry-32.js +1 -1
  103. package/dist/entry-33.js +1 -1
  104. package/dist/entry-34.js +1 -1
  105. package/dist/entry-35.js +1 -18
  106. package/dist/entry-36.js +1 -1
  107. package/dist/entry-37.js +1 -1
  108. package/dist/entry-38.js +15 -1
  109. package/dist/entry-39.js +1 -1
  110. package/dist/entry-4.js +1 -1
  111. package/dist/entry-40.js +1 -1
  112. package/dist/entry-41.js +1 -1
  113. package/dist/entry-42.js +1 -1
  114. package/dist/entry-43.js +1 -1
  115. package/dist/entry-44.js +1 -1
  116. package/dist/entry-45.js +1 -1
  117. package/dist/entry-46.js +1 -1
  118. package/dist/entry-47.js +1 -1
  119. package/dist/entry-48.js +1 -1
  120. package/dist/entry-49.js +1 -25
  121. package/dist/entry-5.js +1 -1
  122. package/dist/entry-50.js +1 -1
  123. package/dist/entry-51.js +1 -1
  124. package/dist/entry-52.js +1 -1
  125. package/dist/entry-53.js +1 -1
  126. package/dist/entry-54.js +1 -3
  127. package/dist/entry-55.js +1 -13
  128. package/dist/entry-56.js +1 -1
  129. package/dist/entry-57.js +1 -1
  130. package/dist/entry-58.js +1 -1
  131. package/dist/entry-59.js +1 -1
  132. package/dist/entry-6.js +1 -1
  133. package/dist/entry-60.js +1 -1
  134. package/dist/entry-61.js +1 -1
  135. package/dist/entry-62.js +1 -1
  136. package/dist/entry-63.js +1 -1
  137. package/dist/entry-64.js +1 -1
  138. package/dist/entry-65.js +1 -0
  139. package/dist/entry-66.js +1 -1
  140. package/dist/entry-67.js +1 -0
  141. package/dist/entry-68.js +0 -1
  142. package/dist/entry-69.js +1 -1
  143. package/dist/entry-7.js +1 -1
  144. package/dist/entry-70.js +0 -1
  145. package/dist/entry-71.js +1 -1
  146. package/dist/entry-72.js +1 -1
  147. package/dist/entry-73.js +1 -1
  148. package/dist/entry-74.js +1 -1
  149. package/dist/entry-75.js +1 -0
  150. package/dist/entry-76.js +1 -1
  151. package/dist/entry-77.js +1 -0
  152. package/dist/entry-78.js +0 -1
  153. package/dist/entry-79.js +1 -1
  154. package/dist/entry-8.js +1 -1
  155. package/dist/entry-80.js +0 -1
  156. package/dist/entry-81.js +1 -80
  157. package/dist/entry-82.js +1 -22
  158. package/dist/entry-83.js +1 -2
  159. package/dist/entry-84.js +1 -1
  160. package/dist/entry-85.js +1 -1
  161. package/dist/entry-86.js +2 -1
  162. package/dist/entry-87.js +1 -1
  163. package/dist/entry-88.js +1 -3
  164. package/dist/entry-89.js +1 -1
  165. package/dist/entry-9.js +1 -1
  166. package/dist/entry-90.js +1 -1
  167. package/dist/entry-91.js +3 -1
  168. package/dist/entry-92.js +1 -0
  169. package/dist/entry-93.js +1 -0
  170. package/dist/entry-94.js +1 -0
  171. package/dist/pi-agent-ide.js +13 -34
  172. package/docs/agent-guides/ast-search.md +58 -0
  173. package/docs/agent-guides/debugger.md +1 -1
  174. package/docs/agent-guides/editing.md +29 -58
  175. package/docs/agent-guides/git-changes.md +4 -14
  176. package/docs/agent-guides/search.md +38 -0
  177. package/docs/agent-guides/ssh.md +17 -49
  178. package/docs/agent-guides/terminal.md +9 -15
  179. package/docs/configuration.md +9 -13
  180. package/docs/extensions.md +82 -0
  181. package/docs/settings-help.md +2 -2
  182. package/docs/structured-results.md +33 -11
  183. package/docs/tools.md +24 -23
  184. package/node_modules/pi-agent-doctor/package.json +7 -7
  185. package/node_modules/pi-agent-doctor/runtime/entry-29.js +1 -0
  186. package/node_modules/pi-agent-doctor/src/workspace.ts +0 -5
  187. package/node_modules/pi-agent-documentation/package.json +2 -2
  188. package/node_modules/pi-agent-documentation/runtime/entry-30.js +1 -0
  189. package/node_modules/pi-agent-documentation/src/index.ts +26 -10
  190. package/node_modules/pi-agent-filesystem/index.ts +1 -1
  191. package/node_modules/pi-agent-filesystem/package.json +8 -8
  192. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  193. package/node_modules/pi-agent-filesystem-jq/index.ts +9 -63
  194. package/node_modules/pi-agent-filesystem-jq/package.json +12 -6
  195. package/node_modules/pi-agent-filesystem-jq/runtime/entry-33.js +1 -0
  196. package/node_modules/pi-agent-filesystem-jq/runtime/entry-34.js +2 -0
  197. package/node_modules/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  198. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  199. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  200. package/node_modules/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  201. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  202. package/node_modules/pi-agent-ide-ast/runtime/entry-37.js +1 -0
  203. package/node_modules/pi-agent-ide-ast/src/extension.ts +8 -8
  204. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  205. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  206. package/node_modules/pi-agent-ide-changes/index.ts +1 -2
  207. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  208. package/node_modules/pi-agent-ide-changes/runtime/entry-39.js +1 -0
  209. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  210. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  211. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  212. package/node_modules/pi-agent-ide-languages/runtime/entry-42.js +2 -0
  213. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  214. package/node_modules/pi-agent-ide-lint/runtime/entry-43.js +2 -0
  215. package/node_modules/pi-agent-ide-lsp/index.ts +22 -28
  216. package/node_modules/pi-agent-ide-lsp/package.json +14 -10
  217. package/node_modules/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  218. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  219. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  220. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  222. package/node_modules/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  223. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  224. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  225. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  226. package/node_modules/pi-agent-image/package.json +3 -3
  227. package/node_modules/pi-agent-image/src/image-converter.ts +24 -1
  228. package/node_modules/pi-agent-invariant/package.json +2 -2
  229. package/node_modules/pi-agent-pdf/package.json +3 -3
  230. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +23 -1
  231. package/node_modules/pi-agent-read/package.json +12 -12
  232. package/node_modules/pi-agent-read/runtime/entry-49.js +0 -1
  233. package/node_modules/pi-agent-read/runtime/entry-52.js +2 -0
  234. package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -7
  235. package/node_modules/pi-agent-read/src/api/tools/read.ts +2 -0
  236. package/node_modules/pi-agent-read/src/core/extension.ts +0 -8
  237. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  238. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  239. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  240. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  241. package/node_modules/pi-agent-resource/package.json +2 -2
  242. package/node_modules/pi-agent-resource/src/index.ts +8 -0
  243. package/node_modules/pi-agent-resource/src/resource-error-metadata.ts +89 -0
  244. package/node_modules/pi-agent-resource/src/resource-error.ts +6 -1
  245. package/node_modules/pi-agent-resource/src/result-images.ts +87 -0
  246. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -3
  247. package/node_modules/pi-agent-resource/src/tool-result.ts +17 -0
  248. package/node_modules/pi-agent-search/package.json +9 -9
  249. package/node_modules/pi-agent-search/runtime/entry-54.js +0 -1
  250. package/node_modules/pi-agent-search/runtime/entry-55.js +1 -0
  251. package/node_modules/pi-agent-search/runtime/entry-57.js +2 -0
  252. package/node_modules/pi-agent-search/src/api/glob-list.ts +35 -0
  253. package/node_modules/pi-agent-search/src/api/search-parameters.ts +8 -8
  254. package/node_modules/pi-agent-search/src/api/search.ts +14 -2
  255. package/node_modules/pi-agent-search/src/core/extension.ts +11 -20
  256. package/node_modules/pi-agent-search/src/core/search-core.ts +30 -10
  257. package/node_modules/pi-agent-search-text/index.ts +34 -12
  258. package/node_modules/pi-agent-search-text/package.json +17 -15
  259. package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
  260. package/node_modules/pi-agent-search-text/runtime/entry-60.js +1 -0
  261. package/node_modules/pi-agent-search-text/src/file-search.ts +59 -25
  262. package/node_modules/pi-agent-search-text/src/resolvers.ts +61 -16
  263. package/node_modules/pi-agent-search-text/src/scoped-search.ts +9 -3
  264. package/node_modules/pi-agent-search-text/src/search-backend.ts +44 -48
  265. package/node_modules/pi-agent-search-text/src/search-presentation.ts +19 -15
  266. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -1
  267. package/node_modules/pi-agent-search-text/src/search-result.ts +6 -2
  268. package/node_modules/pi-agent-search-text/src/search-session.ts +1 -0
  269. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +146 -0
  270. package/node_modules/pi-agent-text/package.json +3 -3
  271. package/node_modules/pi-agent-text/runtime/entry-62.js +1 -0
  272. package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
  273. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  274. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  275. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  276. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +1 -0
  277. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  278. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  279. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +1 -2
  280. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  281. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  282. package/node_modules/pi-agent-text-editor/package.json +26 -26
  283. package/node_modules/pi-agent-text-editor/runtime/entry-81.js +0 -1
  284. package/node_modules/pi-agent-text-editor/runtime/entry-82.js +1 -0
  285. package/node_modules/pi-agent-text-editor/runtime/entry-83.js +1 -0
  286. package/node_modules/pi-agent-text-editor/runtime/entry-84.js +2 -0
  287. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  288. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  289. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  290. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  291. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  292. package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -7
  293. package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  294. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +111 -0
  295. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  296. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  297. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  298. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  299. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  300. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  301. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  302. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  303. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +63 -74
  304. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  305. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +7 -10
  306. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -10
  307. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +8 -8
  308. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -8
  309. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  310. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  311. package/node_modules/pi-agent-text-editor-renderer/index.ts +6 -1
  312. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  313. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +2 -0
  314. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  315. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
  316. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  317. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  318. package/node_modules/pi-agent-tool-call-interception/runtime/entry-87.js +1 -0
  319. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  320. package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +1 -0
  321. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +1 -0
  322. package/node_modules/pi-agent-web/index.ts +28 -6
  323. package/node_modules/pi-agent-web/package.json +8 -8
  324. package/node_modules/pi-agent-web-html/package.json +3 -3
  325. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  326. package/node_modules/pi-agent-web-image/package.json +4 -4
  327. package/node_modules/pi-agent-web-image/runtime/entry-92.js +2 -0
  328. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  329. package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +2 -0
  330. package/node_modules/pi-agent-web-text/package.json +4 -4
  331. package/node_modules/pi-agent-web-text/runtime/entry-94.js +2 -0
  332. package/package.json +65 -58
  333. package/src/api/approval.ts +2 -0
  334. package/src/api/capabilities.ts +60 -0
  335. package/src/api/read.ts +2 -0
  336. package/src/api/standalone.ts +7 -0
  337. package/src/backend/doctor-workspace.ts +0 -3
  338. package/src/backend/process-metadata-worker.py +9 -18
  339. package/src/backend/process-metadata.ts +11 -44
  340. package/src/backend/registration.ts +0 -10
  341. package/src/backend/web-browser-worker.mjs +2 -17
  342. package/src/backend/web-browser.ts +1 -26
  343. package/src/composite/builtin-extensions.ts +8 -6
  344. package/src/composite/capabilities.ts +252 -0
  345. package/src/composite/capability-schemas.ts +53 -0
  346. package/src/composite/ide-alias-rendering.ts +18 -2
  347. package/src/composite/module-labels.ts +0 -4
  348. package/src/composite/preferences.ts +0 -36
  349. package/src/composite/responses-tools.ts +27 -9
  350. package/src/composite/settings-documentation.ts +1 -2
  351. package/src/composite/text-results.ts +61 -23
  352. package/src/composite/tool-availability.ts +28 -13
  353. package/src/documentation/extension.ts +39 -15
  354. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +1 -1
  355. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  356. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  357. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +9 -63
  358. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +12 -6
  359. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-33.js +1 -0
  360. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-34.js +2 -0
  361. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  362. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  363. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-35.js +2 -0
  364. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  365. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  366. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-31.js +2 -0
  367. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -6
  368. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  369. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  370. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  371. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  372. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +2 -0
  373. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  374. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +2 -0
  375. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  376. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +2 -0
  377. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-90.js +2 -0
  378. package/src/extensions/pi-agent-read/package.json +12 -12
  379. package/src/extensions/pi-agent-read/runtime/entry-49.js +0 -1
  380. package/src/extensions/pi-agent-read/runtime/entry-50.js +1 -0
  381. package/src/extensions/pi-agent-read/runtime/entry-52.js +2 -0
  382. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -7
  383. package/src/extensions/pi-agent-read/src/api/tools/read.ts +2 -0
  384. package/src/extensions/pi-agent-read/src/core/extension.ts +0 -8
  385. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  386. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  387. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  388. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  389. package/src/extensions/pi-agent-search/package.json +9 -9
  390. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +34 -12
  391. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -15
  392. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
  393. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
  394. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-60.js +1 -0
  395. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +59 -25
  396. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +61 -16
  397. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +9 -3
  398. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +44 -48
  399. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +19 -15
  400. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -1
  401. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +6 -2
  402. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +1 -0
  403. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +146 -0
  404. package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
  405. package/src/extensions/pi-agent-search/runtime/entry-55.js +1 -0
  406. package/src/extensions/pi-agent-search/runtime/entry-56.js +1 -0
  407. package/src/extensions/pi-agent-search/runtime/entry-57.js +2 -0
  408. package/src/extensions/pi-agent-search/src/api/glob-list.ts +35 -0
  409. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +8 -8
  410. package/src/extensions/pi-agent-search/src/api/search.ts +14 -2
  411. package/src/extensions/pi-agent-search/src/core/extension.ts +11 -20
  412. package/src/extensions/pi-agent-search/src/core/search-core.ts +30 -10
  413. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  414. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  415. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  416. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  417. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +1 -0
  418. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  419. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  420. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +1 -2
  421. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  422. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +1 -0
  423. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  424. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +6 -1
  425. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  426. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +2 -0
  427. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  428. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
  429. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  430. package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +0 -1
  431. package/src/extensions/pi-agent-text-editor/runtime/entry-82.js +1 -0
  432. package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +1 -0
  433. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +2 -0
  434. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  435. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  436. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  437. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  438. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  439. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -7
  440. package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  441. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +111 -0
  442. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  443. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  444. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  445. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  446. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  447. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  448. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  449. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  450. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +63 -74
  451. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  452. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +7 -10
  453. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -10
  454. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +8 -8
  455. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -8
  456. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  457. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  458. package/src/pi-agent-ide.ts +12 -16
  459. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  460. package/src/plugins/pi-agent-ide-ast/runtime/entry-37.js +1 -0
  461. package/src/plugins/pi-agent-ide-ast/src/extension.ts +8 -8
  462. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  463. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  464. package/src/plugins/pi-agent-ide-changes/index.ts +1 -2
  465. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  466. package/src/plugins/pi-agent-ide-changes/runtime/entry-39.js +1 -0
  467. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  468. package/src/plugins/pi-agent-ide-debugger/index.ts +31 -13
  469. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +2 -11
  470. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  471. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  472. package/src/plugins/pi-agent-ide-languages/runtime/entry-42.js +2 -0
  473. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  474. package/src/plugins/pi-agent-ide-lint/runtime/entry-43.js +2 -0
  475. package/src/plugins/pi-agent-ide-lsp/index.ts +22 -28
  476. package/src/plugins/pi-agent-ide-lsp/package.json +14 -10
  477. package/src/plugins/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  478. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  479. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  480. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  481. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  482. package/src/plugins/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  483. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  484. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  485. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  486. package/src/plugins/pi-agent-ide-processes/src/ui.ts +61 -16
  487. package/src/plugins/pi-agent-ide-terminal/index.ts +43 -1
  488. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +0 -18
  489. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  490. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -3
  491. package/src/standalone/resource-host.ts +147 -0
  492. package/src/standalone/scoped-api.ts +457 -0
  493. package/dist/chunk-2RTCSZB3.js +0 -1
  494. package/dist/chunk-4DIUPEDF.js +0 -2
  495. package/dist/chunk-6EDOLYOV.js +0 -1
  496. package/dist/chunk-6FGLAVPJ.js +0 -1
  497. package/dist/chunk-6H32W35W.js +0 -1
  498. package/dist/chunk-6OJ565FL.js +0 -2
  499. package/dist/chunk-6R3Y4AD3.js +0 -1
  500. package/dist/chunk-6TJPMBUQ.js +0 -1
  501. package/dist/chunk-6XFUICD7.js +0 -1
  502. package/dist/chunk-BHSO2MDK.js +0 -6
  503. package/dist/chunk-GBUJOR6V.js +0 -28
  504. package/dist/chunk-GSOYVIQS.js +0 -1
  505. package/dist/chunk-HSRH76JN.js +0 -3
  506. package/dist/chunk-HSZ4AQ6L.js +0 -9
  507. package/dist/chunk-I6NPILT5.js +0 -1
  508. package/dist/chunk-K7SRNBIV.js +0 -1
  509. package/dist/chunk-LCWBVOII.js +0 -3
  510. package/dist/chunk-MKEC3U2M.js +0 -4
  511. package/dist/chunk-NUM3YQGK.js +0 -1
  512. package/dist/chunk-OM4LYD3S.js +0 -1
  513. package/dist/chunk-PLKYHUNT.js +0 -1
  514. package/dist/chunk-PT35ZFLH.js +0 -33
  515. package/dist/chunk-QIJMV2P2.js +0 -2
  516. package/dist/chunk-RVU73VKN.js +0 -2
  517. package/dist/chunk-SDAH3ECM.js +0 -5
  518. package/dist/chunk-SGQWRIRJ.js +0 -10
  519. package/dist/chunk-SWBJS3U4.js +0 -1
  520. package/dist/chunk-T7I2VX3J.js +0 -1
  521. package/dist/chunk-T7MWQQIF.js +0 -3
  522. package/dist/chunk-VDP5CQHM.js +0 -3
  523. package/dist/chunk-XG7QNAKW.js +0 -9
  524. package/dist/chunk-XLWCSJMR.js +0 -1
  525. package/dist/chunk-YFP4P2FV.js +0 -1
  526. package/dist/chunk-YIXP2ALP.js +0 -9
  527. package/dist/entry-23.js +0 -1
  528. package/docs/agent-guides/diagnostics.md +0 -5
  529. package/docs/agent-guides/json-reading.md +0 -57
  530. package/docs/agent-guides/read-resources.md +0 -17
  531. package/docs/agent-guides/search-code.md +0 -76
  532. package/docs/agent-guides/select-code.md +0 -119
  533. package/docs/agent-guides/vision.md +0 -11
  534. package/node_modules/pi-agent-doctor/runtime/entry-22.js +0 -1
  535. package/node_modules/pi-agent-doctor/runtime/entry-23.js +0 -1
  536. package/node_modules/pi-agent-filesystem/runtime/entry-29.js +0 -2
  537. package/node_modules/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
  538. package/node_modules/pi-agent-filesystem-text/runtime/entry-33.js +0 -2
  539. package/node_modules/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  540. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  541. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  542. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  543. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  544. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  545. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +0 -387
  546. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +0 -41
  547. package/node_modules/pi-agent-ide-ast/src/source-text.ts +0 -92
  548. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +0 -214
  549. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +0 -277
  550. package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +0 -1
  551. package/node_modules/pi-agent-ide-changes/runtime/entry-37.js +0 -2
  552. package/node_modules/pi-agent-ide-languages/runtime/entry-39.js +0 -2
  553. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  554. package/node_modules/pi-agent-image/runtime/entry-42.js +0 -1
  555. package/node_modules/pi-agent-invariant/runtime/entry-43.js +0 -1
  556. package/node_modules/pi-agent-pdf/runtime/entry-44.js +0 -1
  557. package/node_modules/pi-agent-search/runtime/entry-52.js +0 -1
  558. package/node_modules/pi-agent-search-text/runtime/entry-55.js +0 -2
  559. package/node_modules/pi-agent-search-text/runtime/entry-57.js +0 -1
  560. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  561. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-62.js +0 -2
  562. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-63.js +0 -1
  563. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +0 -2
  564. package/node_modules/pi-agent-text-editor/runtime/entry-65.js +0 -1
  565. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +0 -1
  566. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  567. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
  568. package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +0 -1
  569. package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +0 -1
  570. package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +0 -1
  571. package/node_modules/pi-agent-web/runtime/entry-87.js +0 -2
  572. package/node_modules/pi-agent-web-html/runtime/entry-88.js +0 -2
  573. package/node_modules/pi-agent-web-image/runtime/entry-89.js +0 -2
  574. package/src/backend/vision-capture-worker.py +0 -319
  575. package/src/backend/vision-capture.ts +0 -165
  576. package/src/backend/vision-registration.ts +0 -104
  577. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
  578. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-31.js +0 -2
  579. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-33.js +0 -2
  580. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +0 -2
  581. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-88.js +0 -2
  582. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +0 -2
  583. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-90.js +0 -2
  584. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +0 -2
  585. package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
  586. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  587. package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
  588. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +0 -2
  589. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +0 -1
  590. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +0 -1
  591. package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
  592. package/src/extensions/pi-agent-search/runtime/entry-53.js +0 -1
  593. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  594. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-62.js +0 -2
  595. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-63.js +0 -1
  596. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +0 -2
  597. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  598. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
  599. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +0 -1
  600. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +0 -1
  601. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +0 -1
  602. package/src/plugins/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  603. package/src/plugins/pi-agent-ide-ast/runtime/entry-35.js +0 -2
  604. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  605. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  606. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  607. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  608. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  609. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +0 -387
  610. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +0 -41
  611. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +0 -92
  612. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +0 -214
  613. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +0 -277
  614. package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +0 -1
  615. package/src/plugins/pi-agent-ide-changes/runtime/entry-37.js +0 -2
  616. package/src/plugins/pi-agent-ide-languages/runtime/entry-39.js +0 -2
  617. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  618. package/src/plugins/pi-agent-ide-vision/index.ts +0 -439
  619. package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +0 -47
  620. package/src/plugins/pi-agent-ide-vision/src/vision.ts +0 -585
  621. package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +0 -30
  622. package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +0 -33
  623. /package/dist/{chunk-U2JKHKLK.js → chunk-3PMHFEJY.js} +0 -0
  624. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-28.js +0 -0
  625. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-31.js +0 -0
  626. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-32.js +0 -0
  627. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  628. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-38.js +0 -0
  629. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  630. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  631. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-45.js +0 -0
  632. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-46.js +0 -0
  633. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-47.js +0 -0
  634. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-50.js +0 -0
  635. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-51.js +0 -0
  636. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-53.js +0 -0
  637. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-56.js +0 -0
  638. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-59.js +0 -0
  639. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-61.js +0 -0
  640. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-66.js +0 -0
  641. /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-90.js +0 -0
  642. /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-91.js +0 -0
  643. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-32.js +0 -0
  644. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-91.js +0 -0
  645. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-51.js +0 -0
  646. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-61.js +0 -0
  647. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-38.js +0 -0
  648. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  649. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import { Type, type Static } from "typebox";
2
2
  import {
3
3
  resultError,
4
+ resourceErrorMetadataOf,
4
5
  structuredResultSchema,
5
6
  withStructuredResult,
6
7
  type StructuredResult,
@@ -128,12 +129,15 @@ export function mutationOutcome(
128
129
  ? "not-applied"
129
130
  : (details.effect ?? "unknown"),
130
131
  });
131
- for (const error of data.errors ?? [])
132
+ for (const error of data.errors ?? []) {
133
+ const metadata = resourceErrorMetadataOf(error);
132
134
  errors.push({
133
135
  code: error.code ?? "MUTATION_FAILED",
134
136
  message: error.reason ?? "Mutation failed",
135
137
  source: error.path,
138
+ ...(metadata === undefined ? {} : { metadata }),
136
139
  });
140
+ }
137
141
  if (data.ok === false && (data.errors?.length ?? 0) === 0)
138
142
  errors.push({
139
143
  code: "MUTATION_FAILED",
@@ -80,13 +80,21 @@ export class TextChangeDocument {
80
80
  }
81
81
 
82
82
  public deleteLines(firstLine: number, lastLine: number): TextChange {
83
- const range = this.lineRange(firstLine, lastLine);
84
-
85
- if (range.to === this.content.length && range.from > 0 && !endsWithLineBreak(this.content)) {
86
- return { from: previousLineBreakStart(this.content, range.from), to: range.to, insert: "" };
87
- }
83
+ return this.replaceLines(firstLine, lastLine, "");
84
+ }
88
85
 
89
- return { ...range, insert: "" };
86
+ /** Insert at a character boundary; separators are added only when requested. */
87
+ public insertAt(from: number, text: string, separation?: LineSeparation): TextChange {
88
+ this.#assertRange({ from, to: from });
89
+ if (text.length === 0) throw new Error("Insert text must not be empty.");
90
+ if (separation === undefined) return { from, to: from, insert: text };
91
+ const prefix =
92
+ from > 0 && !endsWithLineBreak(this.content.slice(0, from)) ? this.#separator : "";
93
+ return {
94
+ from,
95
+ to: from,
96
+ insert: this.#lineInsertion(from, text, separation, from < this.content.length, prefix),
97
+ };
90
98
  }
91
99
 
92
100
  public insertBeforeLine(
@@ -94,13 +102,7 @@ export class TextChangeDocument {
94
102
  text: string,
95
103
  separation: LineSeparation = "line",
96
104
  ): TextChange {
97
- this.#assertLine(lineNumber);
98
- const from = requiredValue(this.#lineStarts[lineNumber - 1]);
99
- return {
100
- from,
101
- to: from,
102
- insert: this.#lineInsertion(from, text, separation, from < this.content.length),
103
- };
105
+ return this.insertAt(this.lineRange(lineNumber, lineNumber).from, text, separation);
104
106
  }
105
107
 
106
108
  public insertAfterLine(
@@ -108,24 +110,7 @@ export class TextChangeDocument {
108
110
  text: string,
109
111
  separation: LineSeparation = "line",
110
112
  ): TextChange {
111
- this.#assertLine(lineNumber);
112
- const nextLine = this.#lineStarts[lineNumber];
113
-
114
- if (nextLine !== undefined) {
115
- return {
116
- from: nextLine,
117
- to: nextLine,
118
- insert: this.#lineInsertion(nextLine, text, separation, nextLine < this.content.length),
119
- };
120
- }
121
-
122
- const prefix =
123
- this.content.length > 0 && !endsWithLineBreak(this.content) ? this.#separator : "";
124
- return {
125
- from: this.content.length,
126
- to: this.content.length,
127
- insert: this.#lineInsertion(this.content.length, text, separation, false, prefix),
128
- };
113
+ return this.insertAt(this.lineRange(lineNumber, lineNumber).to, text, separation);
129
114
  }
130
115
 
131
116
  public replaceAll(text: string): TextChange {
@@ -134,7 +119,7 @@ export class TextChangeDocument {
134
119
 
135
120
  #replacementText(range: TextRange, text: string): string {
136
121
  const selected = this.text(range);
137
- return endsWithLineBreak(selected) && !endsWithLineBreak(text)
122
+ return text.length > 0 && endsWithLineBreak(selected) && !endsWithLineBreak(text)
138
123
  ? text + requiredValue(lineBreakOf(selected))
139
124
  : text;
140
125
  }
@@ -290,7 +275,3 @@ function endsWithLineBreak(text: string): boolean {
290
275
  function lineBreakOf(text: string): "\n" | "\r\n" | undefined {
291
276
  return text.endsWith("\r\n") ? "\r\n" : text.endsWith("\n") ? "\n" : undefined;
292
277
  }
293
-
294
- function previousLineBreakStart(text: string, offset: number): number {
295
- return text[offset - 2] === "\r" && text[offset - 1] === "\n" ? offset - 2 : offset - 1;
296
- }
@@ -4,6 +4,7 @@ import {
4
4
  type ResultSourceTarget,
5
5
  } from "pi-agent-resource";
6
6
  import { TextSelectionAnchor } from "#src/api/text-selection-anchor.js";
7
+ import { withoutEmptyOptionalAnchors } from "#src/api/mutation-tool.js";
7
8
  import { isResultInput } from "./result-transfer.js";
8
9
  import {
9
10
  committedMutationTargets,
@@ -119,12 +120,17 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
119
120
  const definition: ToolBatchDefinition<TextBatchState> = {
120
121
  sourceTools,
121
122
  syntheticTool: "__pi_agent_text_editor_batch",
122
- resolveCall(call, inherited, context) {
123
- const registration = registrations.get(call.name);
123
+ resolveCall(rawCall, inherited, context) {
124
+ const registration = registrations.get(rawCall.name);
124
125
 
125
126
  if (registration === undefined) {
126
127
  return;
127
128
  }
129
+ // Batched calls bypass prepareArguments, so apply the same empty-anchor rule here.
130
+ const call = {
131
+ ...rawCall,
132
+ arguments: withoutEmptyOptionalAnchors(registration.anchors, rawCall.arguments),
133
+ };
128
134
 
129
135
  // Derived protocol targets need their owning execution pipeline, not snapshot batching.
130
136
  const selectorFields = [
@@ -1,4 +1,4 @@
1
- import { lstat, readFile } from "node:fs/promises";
1
+ import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
2
2
  import type {
3
3
  FileOperation,
4
4
  FileOperationInput,
@@ -10,7 +10,11 @@ import {
10
10
  isUriSource,
11
11
  type FileOperationContext,
12
12
  } from "#src/core/file-operations.js";
13
- import { guardFileOperation, type FileGuardSnapshot } from "#src/core/file-operation-guards.js";
13
+ import {
14
+ guardFileChanges,
15
+ guardFileOperation,
16
+ type FileGuardSnapshot,
17
+ } from "#src/core/file-operation-guards.js";
14
18
  import path from "node:path";
15
19
  import { deferPostEdit, collectPostEditNotifications } from "#src/core/post-edit-scope.js";
16
20
  import { requiredValue } from "pi-agent-invariant";
@@ -211,6 +215,8 @@ interface PromptContribution {
211
215
  readonly description: string;
212
216
  readonly pluginId: string;
213
217
  readonly tool: TextEditorToolId;
218
+ /** Schema field this text describes; absent for the tool description. */
219
+ readonly field?: string;
214
220
  }
215
221
 
216
222
  interface WritablePromptContribution {
@@ -386,6 +392,14 @@ export interface TextEditorCore {
386
392
  signal?: AbortSignal,
387
393
  deletion?: FileOperationContext,
388
394
  ): Promise<FileOperationResult>;
395
+ /**
396
+ * Replace whole local files with bytes after the mutation guards accept them; callers
397
+ * serialize it with enqueueFileOperation. A failure while writing has an unknown effect.
398
+ */
399
+ writeFiles(
400
+ files: readonly { readonly source: string; readonly bytes: Uint8Array }[],
401
+ context: ResourceResolverContext,
402
+ ): Promise<void>;
389
403
  inspectTextAnchors(request: TextAnchorInspectionRequest): Promise<TextAnchorInspectionOutcome>;
390
404
  addAnchorResolver(registration: TextAnchorResolverRegistration): void;
391
405
  resolveTextAnchorResources(
@@ -442,6 +456,8 @@ export interface TextEditorCore {
442
456
  /** Returns the configured number of lines around recovery candidates. */
443
457
  recoveryContextLines(): number;
444
458
  renderToolPromptGuideline(tool: TextEditorToolId): string | undefined;
459
+ /** Plugin text for one schema field of a tool, from active plugins only. */
460
+ renderToolFieldDescription(tool: TextEditorToolId, field: string): string | undefined;
445
461
  }
446
462
 
447
463
  /** Share issued-result authority with streamed anchor inspection, before tool-call normalization. */
@@ -746,6 +762,36 @@ export function createTextEditorCore(
746
762
  [...fileOperationResolvers],
747
763
  (kind, args) => guardOwnedFiles(kind, args, { cwd, signal }),
748
764
  ),
765
+ async writeFiles(files, context) {
766
+ const read = (source: string) =>
767
+ readFileGuardSnapshot(
768
+ source,
769
+ context,
770
+ [...resolvers].sort(
771
+ (left, right) => left.priority - right.priority || left.order - right.order,
772
+ ),
773
+ );
774
+ const changes = await Promise.all(
775
+ files.map(async (file) => ({ before: await read(file.source), after: file.bytes })),
776
+ );
777
+ await guardFileChanges(
778
+ changes,
779
+ changes.map((change) => change.before),
780
+ { ...context, intent: "edit" },
781
+ read,
782
+ [...mutationGuards],
783
+ );
784
+ try {
785
+ for (const file of files) {
786
+ await mkdir(path.dirname(file.source), { recursive: true });
787
+ await writeFile(file.source, file.bytes, { signal: context.signal });
788
+ }
789
+ } catch (error) {
790
+ throw Object.assign(error instanceof Error ? error : new Error(String(error)), {
791
+ effect: "unknown",
792
+ });
793
+ }
794
+ },
749
795
  addAnchorResolver(registration): void {
750
796
  if (!isTextAnchorResolverRegistration(registration)) {
751
797
  throw new TypeError("Invalid text anchor resolver");
@@ -1088,7 +1134,9 @@ export function createTextEditorCore(
1088
1134
 
1089
1135
  const contribution = promptContributions.find(
1090
1136
  (candidate) =>
1091
- candidate.pluginId === registeredPlugin.plugin.id && candidate.tool === tool,
1137
+ candidate.pluginId === registeredPlugin.plugin.id &&
1138
+ candidate.tool === tool &&
1139
+ candidate.field === undefined,
1092
1140
  );
1093
1141
 
1094
1142
  if (contribution !== undefined) {
@@ -1098,6 +1146,28 @@ export function createTextEditorCore(
1098
1146
 
1099
1147
  return entries.length === 0 ? undefined : entries.join("\n");
1100
1148
  },
1149
+ renderToolFieldDescription(tool, field): string | undefined {
1150
+ const entries: string[] = [];
1151
+
1152
+ for (const registeredPlugin of plugins.values()) {
1153
+ if (registeredPlugin.lifecycle.status !== "active") {
1154
+ continue;
1155
+ }
1156
+
1157
+ const contribution = promptContributions.find(
1158
+ (candidate) =>
1159
+ candidate.pluginId === registeredPlugin.plugin.id &&
1160
+ candidate.tool === tool &&
1161
+ candidate.field === field,
1162
+ );
1163
+
1164
+ if (contribution !== undefined) {
1165
+ entries.push(contribution.description);
1166
+ }
1167
+ }
1168
+
1169
+ return entries.length === 0 ? undefined : entries.join(" ");
1170
+ },
1101
1171
  async waitForPendingPlugins(): Promise<void> {
1102
1172
  await Promise.all(pendingPlugins);
1103
1173
  },
@@ -2350,6 +2420,22 @@ function createPluginContributionController(
2350
2420
  throw new Error(`Plugin ${pluginId} API is closed`);
2351
2421
  }
2352
2422
  };
2423
+ const addPromptContribution = (contribution: PromptContribution): void => {
2424
+ if (state === "setup") {
2425
+ assertNoDraftDescription(setupDraft.promptContributions, contribution);
2426
+ setupDraft.promptContributions.push(contribution);
2427
+ return;
2428
+ }
2429
+
2430
+ registerContributions({
2431
+ resolvers: [],
2432
+ anchorResolvers: [],
2433
+ handlers: [],
2434
+ promptContributions: [contribution],
2435
+ writablePromptContributions: [],
2436
+ tools: [],
2437
+ });
2438
+ };
2353
2439
  const createToolApi = (tool: TextEditorToolId): TextEditorToolPluginApi => ({
2354
2440
  addSemanticHandler(handler): void {
2355
2441
  assertAvailable();
@@ -2401,25 +2487,22 @@ function createPluginContributionController(
2401
2487
  },
2402
2488
  describe(description): void {
2403
2489
  assertAvailable();
2404
- const contribution: PromptContribution = {
2490
+ addPromptContribution({
2405
2491
  description: normalizeDescription(`Plugin prompt description for ${tool}`, description),
2406
2492
  pluginId,
2407
2493
  tool,
2408
- };
2409
-
2410
- if (state === "setup") {
2411
- assertNoDraftDescription(setupDraft.promptContributions, contribution);
2412
- setupDraft.promptContributions.push(contribution);
2413
- return;
2414
- }
2415
-
2416
- registerContributions({
2417
- resolvers: [],
2418
- anchorResolvers: [],
2419
- handlers: [],
2420
- promptContributions: [contribution],
2421
- writablePromptContributions: [],
2422
- tools: [],
2494
+ });
2495
+ },
2496
+ describeField(field, description): void {
2497
+ assertAvailable();
2498
+ addPromptContribution({
2499
+ description: normalizeDescription(
2500
+ `Plugin prompt description for ${tool}.${field}`,
2501
+ description,
2502
+ ),
2503
+ pluginId,
2504
+ tool,
2505
+ field,
2423
2506
  });
2424
2507
  },
2425
2508
  });
@@ -2845,7 +2928,7 @@ function handlerKey(handler: RegisteredHandler): string {
2845
2928
  }
2846
2929
 
2847
2930
  function descriptionKey(contribution: PromptContribution): string {
2848
- return `${contribution.pluginId}\0${contribution.tool}`;
2931
+ return `${contribution.pluginId}\0${contribution.tool}\0${contribution.field ?? ""}`;
2849
2932
  }
2850
2933
 
2851
2934
  function normalizeDescriptionSource(value: unknown): PromptDescriptionSource {
@@ -1,5 +1,9 @@
1
1
  import { requiredValue } from "pi-agent-invariant";
2
- import { ResourceError } from "pi-agent-resource";
2
+ import {
3
+ ResourceError,
4
+ resourceErrorMetadataOf,
5
+ type ResourceErrorMetadata,
6
+ } from "pi-agent-resource";
3
7
  import path from "node:path";
4
8
  import { AsyncLocalStorage } from "node:async_hooks";
5
9
  import type { TextEditCompletion } from "#src/api/edit-completion.js";
@@ -32,6 +36,8 @@ import {
32
36
  type TextMutationContext,
33
37
  type TextMutationEdit,
34
38
  type TextMutationToolRegistration,
39
+ type TextSemanticMutationResult,
40
+ withoutEmptyOptionalAnchors,
35
41
  } from "#src/api/mutation-tool.js";
36
42
  import {
37
43
  isFormattingContribution,
@@ -43,6 +49,7 @@ import {
43
49
  type StaleAnchorMessageDetails,
44
50
  } from "#src/api/stale-anchor-message.js";
45
51
  import { createUnifiedDiff } from "#src/core/mutation-result/diff.js";
52
+ import { imageWriteResult, planImageWrite } from "#src/core/image-write.js";
46
53
  import { FileMutationAgentResult } from "#src/core/mutation-result/file-mutation-agent-result.js";
47
54
  import { readTextAnchorRecovery } from "#src/core/text-anchor-recovery.js";
48
55
  import { applyTextChanges, TextChangeDocument } from "#src/core/text-change-engine.js";
@@ -93,7 +100,7 @@ import { executeWholeFileTool, isWholeFileInvocation } from "#src/core/file-oper
93
100
  import { EDITING_GUIDELINES } from "#src/core/editing-guidelines.js";
94
101
  import { writeAgentResult } from "./write-agent-result.js";
95
102
  import { mutationResultSchema, structuredMutation } from "./structured-result.js";
96
- import type { ResultTargetStore } from "pi-agent-resource";
103
+ import type { ResultImageStore, ResultTargetStore } from "pi-agent-resource";
97
104
 
98
105
  /** Build a mutation tool; host events report terminal filesystem approvals to Herdr. */
99
106
  export function createTextTool<TParameters extends TSchema>(
@@ -103,6 +110,7 @@ export function createTextTool<TParameters extends TSchema>(
103
110
  getLastResolvedSource: () => string | undefined,
104
111
  resultTargets?: ResultTargetStore,
105
112
  events?: Pick<ExtensionAPI["events"], "emit">,
113
+ resultImages?: ResultImageStore,
106
114
  ): ToolDefinition<TParameters, FileMutationBatchResult> {
107
115
  const renderer = core.getToolRenderer(definition.name);
108
116
  const initialRenderCall = renderer?.renderCall;
@@ -160,6 +168,16 @@ export function createTextTool<TParameters extends TSchema>(
160
168
  captureScriptMutation(core, async () => {
161
169
  const execute = async (): Promise<AgentToolResult<FileMutationBatchResult>> => {
162
170
  let input = asMutationParameters<TParameters>(parameters);
171
+ if (definition.name === "write") {
172
+ const written = await writeImageContent(
173
+ core,
174
+ resultImages,
175
+ input,
176
+ context.cwd,
177
+ signal,
178
+ );
179
+ if (written !== undefined) return written;
180
+ }
163
181
  if (
164
182
  ["replace", "write", "delete", "undo", "insert"].includes(definition.name) &&
165
183
  isResultInput(input[definition.source.field])
@@ -300,19 +318,7 @@ export function createTextTool<TParameters extends TSchema>(
300
318
  { cwd: context.cwd, ...(signal !== undefined && { signal }) },
301
319
  input,
302
320
  );
303
- return {
304
- content: [{ type: "text", text: action.summary }],
305
- details: {
306
- results: [],
307
- metadata: {
308
- semanticAction: {
309
- ...action.data,
310
- source: action.source,
311
- ...(action.script !== undefined && { script: action.script }),
312
- },
313
- },
314
- },
315
- };
321
+ return semanticActionResult(action);
316
322
  } catch (error) {
317
323
  const code =
318
324
  error !== null && typeof error === "object" && "code" in error
@@ -449,37 +455,41 @@ export function createTextTool<TParameters extends TSchema>(
449
455
  }),
450
456
  annotations,
451
457
  );
458
+ let fieldDescriptionsKey = "";
459
+ let describedParameters = definition.parameters;
460
+ Object.defineProperty(tool, "parameters", {
461
+ enumerable: true,
462
+ get(): TParameters {
463
+ const properties = (definition.parameters as { properties?: Record<string, TSchema> })
464
+ .properties;
465
+ if (properties === undefined) return definition.parameters;
466
+ const additions = Object.keys(properties).map(
467
+ (field) => [field, core.renderToolFieldDescription(definition.name, field)] as const,
468
+ );
469
+ const key = JSON.stringify(additions);
470
+ if (key === fieldDescriptionsKey) return describedParameters;
471
+ fieldDescriptionsKey = key;
472
+ const described = { ...properties };
473
+ for (const [field, addition] of additions) {
474
+ if (addition === undefined) continue;
475
+ const base = described[field] as TSchema & { description?: string };
476
+ described[field] = {
477
+ ...base,
478
+ description: [base.description, addition].filter(Boolean).join(" "),
479
+ };
480
+ }
481
+ describedParameters = { ...definition.parameters, properties: described };
482
+ return describedParameters;
483
+ },
484
+ });
452
485
  Object.defineProperty(tool, "description", {
453
486
  enumerable: true,
454
487
  get(): string {
455
488
  return [
456
489
  definition.description,
457
490
  core.renderToolPromptGuideline(definition.name) ?? "",
458
- (
459
- {
460
- replace:
461
- "This result selects the resulting text; empty replacement selects the resulting position, not the removed text.",
462
- insert:
463
- "For text edits, this result selects the inserted text, including supplied line separators. Specialized resources return their own action result.",
464
- write:
465
- "For file writes, this result selects the whole file and returns a compact write receipt, not file content.",
466
- copy: "This result selects only the copied destination text; a whole-file copy selects the whole destination. Copy edits only the destination.",
467
- move: "Use the Move result to work with the inserted destination text, including any added line separators. Valid empty arrays and paired zero-width selections succeed without writes; paired points select only the unchanged destination points. Source removals are not selected. A whole-file move selects the whole destination when a reusable text result is available.",
468
- delete: "Delete returns no reusable text selection.",
469
- undo: "The result selects the whole restored text file, not only the reversed span.",
470
- } as Record<string, string>
471
- )[definition.name] ?? "",
472
- definition.name === "replace"
473
- ? "Pass the unchanged result to another source tool to use its selection. If it has no text selection, read the file again."
474
- : definition.name === "write"
475
- ? "For file writes, pass this unchanged result to another source tool for dependent work. If the result reports no verified text selection, inspect the file instead."
476
- : definition.name === "undo"
477
- ? "Pass the unchanged result to another source tool for dependent work. If no verified text selection is returned, read the file again."
478
- : ["insert", "copy", "move"].includes(definition.name)
479
- ? "Pass this unchanged result to another source tool for dependent work." +
480
- " If the result reports no verified text selection, inspect the file instead."
481
- : "",
482
- definition.source.inherited && !["delete", "undo"].includes(definition.name)
491
+ definition.source.inherited &&
492
+ !["delete", "undo", "insert", "move", "copy", "replace"].includes(definition.name)
483
493
  ? definition.wholeFileOperation === undefined
484
494
  ? `When ${definition.source.field} is omitted, the tool can reuse the file identified by the supplied anchor, the last read, or the preceding edit in the same batch.`
485
495
  : `When ${definition.source.field} is omitted, the tool can reuse the file identified by a supplied text anchor.`
@@ -502,10 +512,12 @@ function prepareGuardedArguments<TParameters extends TSchema>(
502
512
  ): ReturnType<
503
513
  NonNullable<ToolDefinition<TParameters, FileMutationBatchResult>["prepareArguments"]>
504
514
  > {
505
- const prepared =
515
+ const prepared = withoutEmptyOptionalAnchors(
516
+ anchorFields,
506
517
  arguments_ !== null && typeof arguments_ === "object" && !Array.isArray(arguments_)
507
518
  ? { ...(arguments_ as Record<string, unknown>) }
508
- : {};
519
+ : {},
520
+ );
509
521
  const required = (schema as { required?: unknown }).required;
510
522
  const properties = (schema as { properties?: Record<string, { type?: unknown }> }).properties;
511
523
 
@@ -748,10 +760,14 @@ function mergeTargets(left: readonly TextTarget[], right: readonly TextTarget[])
748
760
  return [...merged.values()];
749
761
  }
750
762
 
763
+ function selectionRangeKey(range: TextSelectionRange): string {
764
+ return JSON.stringify({ start: range.start, end: range.end });
765
+ }
766
+
751
767
  function deduplicateRanges(ranges: readonly TextSelectionRange[]): readonly TextSelectionRange[] {
752
768
  const merged = new Map<string, TextSelectionRange>();
753
769
  for (const range of ranges) {
754
- const key = JSON.stringify({ start: range.start, end: range.end });
770
+ const key = selectionRangeKey(range);
755
771
  const previous = merged.get(key);
756
772
  merged.set(key, {
757
773
  ...range,
@@ -812,7 +828,29 @@ function mergeResolvedAnchors(
812
828
  throw new Error(`Anchor ${field} selections overlap or are ambiguous.`);
813
829
  }
814
830
  }
815
- return [source, new TextSelectionAnchor(field, source, unique)] as const;
831
+ // A typed source can duplicate an explicit literal's linewise selection.
832
+ // Keep the explicit endpoint extent when deduplicating that selection.
833
+ const explicitEndpoints = explicitSelection.endpointRanges;
834
+ const endpoints =
835
+ explicitEndpoints === undefined
836
+ ? undefined
837
+ : new Map(
838
+ explicitSelection.ranges.map((range, index) => [
839
+ selectionRangeKey(range),
840
+ requiredValue(explicitEndpoints[index]),
841
+ ]),
842
+ );
843
+ return [
844
+ source,
845
+ new TextSelectionAnchor(
846
+ field,
847
+ source,
848
+ unique,
849
+ endpoints === undefined
850
+ ? undefined
851
+ : unique.map((range) => endpoints.get(selectionRangeKey(range)) ?? range),
852
+ ),
853
+ ] as const;
816
854
  }),
817
855
  );
818
856
  }
@@ -1510,27 +1548,13 @@ async function buildToolResult(
1510
1548
  effect,
1511
1549
  outcome.failure.rollback,
1512
1550
  outcome.failure.code,
1551
+ false,
1552
+ resourceErrorMetadataOf(safe),
1513
1553
  );
1514
1554
  }
1515
1555
 
1516
1556
  const mutation = outcome.result as ExecutedTextMutation;
1517
- if (mutation.semanticAction !== undefined) {
1518
- return {
1519
- content: [{ type: "text", text: mutation.semanticAction.summary }],
1520
- details: {
1521
- results: [],
1522
- metadata: {
1523
- semanticAction: {
1524
- ...mutation.semanticAction.data,
1525
- source: mutation.semanticAction.source,
1526
- ...(mutation.semanticAction.script !== undefined && {
1527
- script: mutation.semanticAction.script,
1528
- }),
1529
- },
1530
- },
1531
- },
1532
- };
1533
- }
1557
+ if (mutation.semanticAction !== undefined) return semanticActionResult(mutation.semanticAction);
1534
1558
  if (operation === "write" && outcome.resources.length === 0 && mutation.unchangedWrite) {
1535
1559
  const { source: unchangedSource, content } = mutation.unchangedWrite;
1536
1560
  return {
@@ -1855,6 +1879,57 @@ function declaredMutationEffect(error: unknown): "applied" | "not-applied" | "un
1855
1879
  return error.effect;
1856
1880
  return "unknown";
1857
1881
  }
1882
+ /**
1883
+ * The tool result of a semantic or direct action: its summary, then any images it returned for the model.
1884
+ * Image data stays out of details, which carry only the receipt and the script value.
1885
+ */
1886
+ function semanticActionResult(
1887
+ action: TextSemanticMutationResult,
1888
+ ): AgentToolResult<FileMutationBatchResult> {
1889
+ return {
1890
+ content: [{ type: "text", text: action.summary }, ...(action.images ?? [])],
1891
+ details: {
1892
+ results: [],
1893
+ metadata: {
1894
+ semanticAction: {
1895
+ ...action.data,
1896
+ source: action.source,
1897
+ ...(action.script !== undefined && { script: action.script }),
1898
+ },
1899
+ },
1900
+ },
1901
+ };
1902
+ }
1903
+ /** Write images named by Write content; returns undefined when the content is ordinary text. */
1904
+ async function writeImageContent(
1905
+ core: TextEditorCore,
1906
+ store: ResultImageStore | undefined,
1907
+ input: Readonly<Record<string, unknown>>,
1908
+ cwd: string,
1909
+ signal: AbortSignal | undefined,
1910
+ ): Promise<AgentToolResult<FileMutationBatchResult> | undefined> {
1911
+ const target = typeof input.path === "string" ? input.path : "";
1912
+ try {
1913
+ const files = await planImageWrite(input.path, input.content, store, cwd);
1914
+ if (files === undefined) return undefined;
1915
+ await core.enqueueFileOperation(
1916
+ () => core.writeFiles(files, { cwd, ...(signal !== undefined && { signal }) }),
1917
+ signal,
1918
+ { cwd, sources: files.map((file) => file.source) },
1919
+ );
1920
+ return imageWriteResult(files);
1921
+ } catch (error) {
1922
+ signal?.throwIfAborted();
1923
+ const declared = error !== null && typeof error === "object";
1924
+ return failureToolResult(
1925
+ target,
1926
+ declared && "code" in error ? String(error.code) : "IMAGE_WRITE_FAILED",
1927
+ errorMessage(error),
1928
+ // Only the write step marks its effect; earlier failures changed nothing.
1929
+ declared && "effect" in error ? declaredMutationEffect(error) : "not-applied",
1930
+ );
1931
+ }
1932
+ }
1858
1933
  function failureToolResult(
1859
1934
  source: string,
1860
1935
  code: string,
@@ -1863,6 +1938,7 @@ function failureToolResult(
1863
1938
  rollback?: TextResourceEditFailure["rollback"],
1864
1939
  stage?: string,
1865
1940
  copyExecutionFailure = false,
1941
+ metadata?: ResourceErrorMetadata,
1866
1942
  ): { content: [{ type: "text"; text: string }]; details: FileMutationBatchResult } {
1867
1943
  const uncertain =
1868
1944
  effect === "unknown" ||
@@ -1889,7 +1965,15 @@ function failureToolResult(
1889
1965
  const result = new FileMutationResult({
1890
1966
  ok: false,
1891
1967
  path: source,
1892
- errors: [{ path: source, code, reason, ...(stage === undefined ? {} : { stage }) }],
1968
+ errors: [
1969
+ {
1970
+ path: source,
1971
+ code,
1972
+ reason,
1973
+ ...(stage === undefined ? {} : { stage }),
1974
+ ...(metadata === undefined ? {} : { metadata }),
1975
+ },
1976
+ ],
1893
1977
  ...(fileChangedStatement === undefined
1894
1978
  ? {}
1895
1979
  : {