pi-agent-ide 0.2.1 → 0.3.0

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 (490) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +12 -8
  3. package/dist/{chunk-XNXQYPVT.js → chunk-4LUW26BX.js} +1 -1
  4. package/dist/chunk-5MSNYFDE.js +1 -0
  5. package/dist/chunk-5VSE5X5R.js +2 -0
  6. package/dist/chunk-6EYWFBNG.js +0 -0
  7. package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
  8. package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
  9. package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
  10. package/dist/{chunk-SMSIT3CE.js → chunk-B5KB2I7J.js} +1 -1
  11. package/dist/chunk-BHSO2MDK.js +6 -0
  12. package/dist/chunk-BMOJTJJJ.js +3 -0
  13. package/dist/{chunk-EEH4WYI7.js → chunk-CEKXBS55.js} +1 -1
  14. package/dist/chunk-CW53ZTU3.js +2 -0
  15. package/dist/chunk-EWNWKDMP.js +4 -0
  16. package/dist/{chunk-VSP2QQPQ.js → chunk-GIRAEVUJ.js} +1 -1
  17. package/dist/{chunk-MTTKFJV6.js → chunk-GUTQ3PWL.js} +1 -1
  18. package/dist/chunk-HGPUI7F3.js +1 -0
  19. package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
  20. package/dist/chunk-ITSNK5YG.js +7 -0
  21. package/dist/chunk-KAB3AYA2.js +1 -0
  22. package/dist/{chunk-266RH77Z.js → chunk-LRYE2WCN.js} +1 -1
  23. package/dist/chunk-M5L42DWE.js +7 -0
  24. package/dist/chunk-M5MJP7Z2.js +1 -0
  25. package/dist/chunk-NMFQGKPE.js +2 -0
  26. package/dist/chunk-NTYXZ3EL.js +3 -0
  27. package/dist/{chunk-PETQCA7G.js → chunk-QDST6VIU.js} +1 -1
  28. package/dist/chunk-QIJMV2P2.js +2 -0
  29. package/dist/chunk-RHV5STR3.js +3 -0
  30. package/dist/chunk-ROXXK6TW.js +0 -0
  31. package/dist/chunk-S3ZPXWX7.js +2 -0
  32. package/dist/chunk-SSHZEWWV.js +1 -0
  33. package/dist/chunk-TPIHQYK2.js +14 -0
  34. package/dist/chunk-VZJIZXSH.js +14 -0
  35. package/dist/chunk-YHADTHQM.js +1 -0
  36. package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
  37. package/dist/{chunk-SJYDLHEF.js → chunk-ZM4L5AGN.js} +1 -1
  38. package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
  39. package/dist/entry-0.js +1 -1
  40. package/dist/entry-1.js +1 -1
  41. package/dist/entry-10.js +1 -1
  42. package/dist/entry-11.js +1 -1
  43. package/dist/entry-12.js +1 -1
  44. package/dist/entry-13.js +1 -1
  45. package/dist/entry-14.js +1 -1
  46. package/dist/entry-2.js +1 -1
  47. package/dist/entry-21.js +2 -1
  48. package/dist/entry-22.js +1 -1
  49. package/dist/entry-23.js +1 -1
  50. package/dist/entry-24.js +1 -1
  51. package/dist/entry-25.js +1 -1
  52. package/dist/entry-26.js +12 -1
  53. package/dist/entry-28.js +1 -1
  54. package/dist/entry-29.js +1 -1
  55. package/dist/entry-30.js +1 -1
  56. package/dist/entry-31.js +4 -1
  57. package/dist/entry-32.js +9 -1
  58. package/dist/entry-33.js +1 -1
  59. package/dist/entry-35.js +1 -1
  60. package/dist/entry-36.js +1 -1
  61. package/dist/entry-37.js +1 -1
  62. package/dist/entry-38.js +1 -1
  63. package/dist/entry-39.js +1 -1
  64. package/dist/entry-4.js +1 -1
  65. package/dist/entry-40.js +18 -1
  66. package/dist/entry-41.js +1 -1
  67. package/dist/entry-42.js +1 -1
  68. package/dist/entry-43.js +1 -1
  69. package/dist/entry-44.js +1 -1
  70. package/dist/entry-45.js +7 -1
  71. package/dist/entry-46.js +11 -1
  72. package/dist/entry-47.js +1 -1
  73. package/dist/entry-48.js +1 -1
  74. package/dist/entry-49.js +1 -1
  75. package/dist/entry-50.js +1 -1
  76. package/dist/entry-51.js +1 -1
  77. package/dist/entry-52.js +1 -1
  78. package/dist/entry-53.js +1 -1
  79. package/dist/entry-54.js +1 -0
  80. package/dist/entry-55.js +0 -1
  81. package/dist/entry-56.js +1 -0
  82. package/dist/entry-57.js +0 -1
  83. package/dist/entry-58.js +1 -1
  84. package/dist/entry-59.js +1 -1
  85. package/dist/entry-60.js +1 -1
  86. package/dist/entry-61.js +1 -1
  87. package/dist/entry-62.js +1 -1
  88. package/dist/entry-63.js +1 -0
  89. package/dist/entry-64.js +0 -1
  90. package/dist/entry-65.js +1 -0
  91. package/dist/entry-66.js +0 -1
  92. package/dist/entry-67.js +1 -1
  93. package/dist/entry-68.js +1 -1
  94. package/dist/entry-69.js +1 -1
  95. package/dist/entry-70.js +123 -1
  96. package/dist/entry-71.js +30 -1
  97. package/dist/entry-72.js +2 -1
  98. package/dist/entry-73.js +1 -1
  99. package/dist/entry-74.js +1 -1
  100. package/dist/entry-75.js +1 -1
  101. package/dist/entry-76.js +3 -1
  102. package/dist/entry-77.js +1 -1
  103. package/dist/entry-78.js +1 -1
  104. package/dist/entry-79.js +1 -1
  105. package/dist/pi-agent-ide.js +3 -13
  106. package/docs/configuration.md +57 -11
  107. package/docs/extensions.md +4 -2
  108. package/docs/tools.md +7 -1
  109. package/node_modules/pi-agent-doctor/package.json +1 -1
  110. package/node_modules/pi-agent-filesystem/index.ts +2 -2
  111. package/node_modules/pi-agent-filesystem/package.json +6 -6
  112. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  113. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  114. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  115. package/node_modules/pi-agent-ide-ast/package.json +9 -9
  116. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +89 -19
  117. package/node_modules/pi-agent-ide-ast/src/extension.ts +11 -15
  118. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
  119. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  120. package/node_modules/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  121. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  122. package/node_modules/pi-agent-ide-changes/index.ts +22 -10
  123. package/node_modules/pi-agent-ide-changes/package.json +6 -6
  124. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  125. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
  126. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
  127. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  128. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +36 -13
  129. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
  130. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  131. package/node_modules/pi-agent-ide-lint/index.ts +49 -17
  132. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  133. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
  134. package/node_modules/pi-agent-ide-lsp/index.ts +127 -20
  135. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  136. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  137. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
  138. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
  139. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  140. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  141. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  142. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  143. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  144. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  145. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  146. package/node_modules/pi-agent-image/package.json +2 -2
  147. package/node_modules/pi-agent-image/src/image-converter.ts +1 -1
  148. package/node_modules/pi-agent-invariant/package.json +1 -1
  149. package/node_modules/pi-agent-pdf/package.json +2 -2
  150. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +1 -1
  151. package/node_modules/pi-agent-read/package.json +6 -6
  152. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  153. package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
  154. package/node_modules/pi-agent-read/src/api/rendering.ts +3 -0
  155. package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
  156. package/node_modules/pi-agent-read/src/core/read-core.ts +32 -28
  157. package/node_modules/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
  158. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  159. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  160. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
  161. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  162. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  163. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +87 -53
  164. package/node_modules/pi-agent-resource/package.json +1 -1
  165. package/node_modules/pi-agent-resource/src/content-conversion/content-description.ts +1 -8
  166. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  167. package/node_modules/pi-agent-search/package.json +3 -3
  168. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  169. package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
  170. package/node_modules/pi-agent-search/src/api/search.ts +55 -1
  171. package/node_modules/pi-agent-search/src/core/extension.ts +8 -27
  172. package/node_modules/pi-agent-search/src/core/search-core.ts +38 -3
  173. package/node_modules/pi-agent-search-text/index.ts +82 -33
  174. package/node_modules/pi-agent-search-text/package.json +6 -6
  175. package/node_modules/pi-agent-search-text/src/file-search.ts +9 -1
  176. package/node_modules/pi-agent-search-text/src/resolvers.ts +1 -1
  177. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -0
  178. package/node_modules/pi-agent-search-text/src/search-session.ts +112 -24
  179. package/node_modules/pi-agent-text/package.json +2 -2
  180. package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
  181. package/node_modules/pi-agent-text/src/text-document.ts +5 -0
  182. package/node_modules/pi-agent-text/src/text-target.ts +4 -0
  183. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  184. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  185. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +2 -6
  186. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  187. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  188. package/node_modules/pi-agent-text-editor/index.ts +1 -3
  189. package/node_modules/pi-agent-text-editor/package.json +34 -24
  190. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
  191. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  192. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  193. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  194. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  195. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
  196. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  197. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +74 -1
  198. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  199. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  200. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  201. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  202. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  203. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  204. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  205. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  206. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  207. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  208. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  209. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  210. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
  211. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  212. package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -9
  213. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  214. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  215. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  216. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
  217. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
  218. package/node_modules/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
  219. package/node_modules/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
  220. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  221. package/node_modules/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
  222. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  223. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
  224. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
  225. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
  226. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
  227. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
  228. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
  229. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
  230. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
  231. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
  232. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
  233. package/node_modules/pi-agent-text-editor-renderer/index.ts +93 -2
  234. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  235. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
  236. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
  237. package/node_modules/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
  238. package/node_modules/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
  239. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
  240. package/node_modules/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
  241. package/node_modules/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
  242. package/node_modules/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
  243. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
  244. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  245. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  246. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  247. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  248. package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
  249. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  250. package/node_modules/pi-agent-web/index.ts +1 -6
  251. package/node_modules/pi-agent-web/package.json +7 -7
  252. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  253. package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
  254. package/node_modules/pi-agent-web-html/package.json +3 -3
  255. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  256. package/node_modules/pi-agent-web-image/package.json +4 -4
  257. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  258. package/node_modules/pi-agent-web-text/package.json +4 -4
  259. package/package.json +38 -38
  260. package/src/api/plugin-protocol.ts +12 -2
  261. package/src/api/text-editor.ts +7 -0
  262. package/src/api/tool-config.ts +77 -2
  263. package/src/code-view/diagnostic-view.ts +22 -3
  264. package/src/composite/builtin-extensions.ts +138 -67
  265. package/src/composite/extensions-config.ts +59 -0
  266. package/src/composite/feature-flags.ts +32 -0
  267. package/src/composite/module-labels.ts +55 -0
  268. package/src/composite/module-settings-store.ts +44 -0
  269. package/src/composite/module-settings.ts +132 -0
  270. package/src/composite/selection.ts +4 -4
  271. package/src/composite/settings-panel.ts +71 -0
  272. package/src/core/diagnostic-delivery.ts +29 -0
  273. package/src/core/diagnostic-entry.ts +142 -0
  274. package/src/core/diagnostic-store.ts +96 -23
  275. package/src/core/extension.ts +45 -22
  276. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +2 -2
  277. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  278. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  279. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  280. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  281. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +1 -6
  282. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  283. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  284. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  285. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  286. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  287. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  288. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  289. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  290. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
  291. package/src/extensions/pi-agent-read/package.json +6 -6
  292. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  293. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
  294. package/src/extensions/pi-agent-read/src/api/rendering.ts +3 -0
  295. package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
  296. package/src/extensions/pi-agent-read/src/core/read-core.ts +32 -28
  297. package/src/extensions/pi-agent-read/src/core/tools/read/native-resource-renderer.ts +74 -0
  298. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  299. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  300. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +87 -19
  301. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  302. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  303. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +87 -53
  304. package/src/extensions/pi-agent-search/package.json +3 -3
  305. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +82 -33
  306. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  307. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +9 -1
  308. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +1 -1
  309. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -0
  310. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +112 -24
  311. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  312. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
  313. package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
  314. package/src/extensions/pi-agent-search/src/core/extension.ts +8 -27
  315. package/src/extensions/pi-agent-search/src/core/search-core.ts +38 -3
  316. package/src/extensions/pi-agent-text-editor/index.ts +1 -3
  317. package/src/extensions/pi-agent-text-editor/package.json +34 -24
  318. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  319. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  320. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +2 -6
  321. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  322. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  323. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +93 -2
  324. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  325. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +7 -0
  326. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +1 -1
  327. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-viewport.ts +11 -2
  328. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/frozen-viewport.ts +140 -52
  329. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +69 -4
  330. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-result.ts +53 -1
  331. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/persisted-result.ts +8 -2
  332. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/render-resource.ts +10 -0
  333. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +24 -13
  334. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  335. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  336. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
  337. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
  338. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  339. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  340. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  341. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  342. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -0
  343. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  344. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +74 -1
  345. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  346. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  347. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  348. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  349. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  350. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  351. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  352. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  353. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  354. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  355. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  356. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  357. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +4 -12
  358. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  359. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -9
  360. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  361. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  362. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  363. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +28 -2
  364. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +43 -0
  365. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/final-state-fragment.ts +2 -0
  366. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/grouped-replacements.ts +81 -0
  367. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  368. package/src/extensions/pi-agent-text-editor/src/core/text-anchor-registry.ts +5 -2
  369. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  370. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +40 -0
  371. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +178 -58
  372. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +313 -21
  373. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +45 -43
  374. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +18 -8
  375. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +7 -4
  376. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +13 -5
  377. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +18 -8
  378. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +9 -5
  379. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +2 -1
  380. package/src/pi-agent-ide.ts +45 -0
  381. package/src/plugins/pi-agent-ide-ast/package.json +9 -9
  382. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +89 -19
  383. package/src/plugins/pi-agent-ide-ast/src/extension.ts +11 -15
  384. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +83 -0
  385. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  386. package/src/plugins/pi-agent-ide-ast/src/scope-resolver.ts +1 -1
  387. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  388. package/src/plugins/pi-agent-ide-changes/index.ts +22 -10
  389. package/src/plugins/pi-agent-ide-changes/package.json +6 -6
  390. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  391. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +5 -9
  392. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +1 -5
  393. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -26
  394. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  395. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +36 -13
  396. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
  397. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  398. package/src/plugins/pi-agent-ide-lint/index.ts +49 -17
  399. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  400. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
  401. package/src/plugins/pi-agent-ide-lsp/index.ts +127 -20
  402. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  403. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  404. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +25 -7
  405. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +12 -1
  406. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  407. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  408. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  409. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  410. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  411. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  412. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  413. package/src/post-edit/gate.ts +57 -15
  414. package/src/toolchain/types.ts +2 -0
  415. package/dist/chunk-2SKAED2I.js +0 -2
  416. package/dist/chunk-2XYXV5HS.js +0 -4
  417. package/dist/chunk-2ZMYT6ZC.js +0 -1
  418. package/dist/chunk-34ZQTTU2.js +0 -2
  419. package/dist/chunk-4SQQKEVD.js +0 -16
  420. package/dist/chunk-5BWUVAR4.js +0 -1
  421. package/dist/chunk-6DN7NO7L.js +0 -1
  422. package/dist/chunk-6SMFVLTY.js +0 -1
  423. package/dist/chunk-6XQQBKPE.js +0 -58
  424. package/dist/chunk-BYWAG6X3.js +0 -6
  425. package/dist/chunk-EW2KVKCN.js +0 -2
  426. package/dist/chunk-F6SESI3P.js +0 -4
  427. package/dist/chunk-GTK5AREE.js +0 -2
  428. package/dist/chunk-HOBTFFQR.js +0 -1
  429. package/dist/chunk-IMVCVPMP.js +0 -3
  430. package/dist/chunk-IOCABSRL.js +0 -1
  431. package/dist/chunk-JASLOB2X.js +0 -1
  432. package/dist/chunk-KH5KPBCR.js +0 -10
  433. package/dist/chunk-KNMWCDDK.js +0 -7
  434. package/dist/chunk-KYVOMBO5.js +0 -1
  435. package/dist/chunk-L4FA6OD4.js +0 -1
  436. package/dist/chunk-LFV6G5Z3.js +0 -1
  437. package/dist/chunk-LGN7EJYR.js +0 -13
  438. package/dist/chunk-MB6VVVAF.js +0 -2
  439. package/dist/chunk-MTQSGWZJ.js +0 -1
  440. package/dist/chunk-NI2NK4JU.js +0 -1
  441. package/dist/chunk-NXHPO7ER.js +0 -6
  442. package/dist/chunk-OFHVDY4Q.js +0 -2
  443. package/dist/chunk-OIL6BB2S.js +0 -33
  444. package/dist/chunk-ONWUJXUR.js +0 -1
  445. package/dist/chunk-PODWLGNO.js +0 -6
  446. package/dist/chunk-QZANC2IG.js +0 -1
  447. package/dist/chunk-SSZB66C3.js +0 -3
  448. package/dist/chunk-TG6H6EOI.js +0 -1
  449. package/dist/chunk-UTTW55S2.js +0 -1
  450. package/dist/chunk-VEJGSURY.js +0 -8
  451. package/dist/chunk-W3XYKJ5H.js +0 -1
  452. package/dist/chunk-XGUAL3CA.js +0 -1
  453. package/dist/chunk-YPHXLAQF.js +0 -1
  454. package/dist/chunk-ZIHEF6K3.js +0 -3
  455. package/dist/entry-80.js +0 -1
  456. package/node_modules/pi-agent-read/src/core/tools/read/views.ts +0 -29
  457. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  458. package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
  459. package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
  460. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  461. package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
  462. package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
  463. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  464. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  465. package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
  466. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  467. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  468. package/src/extensions/pi-agent-read/src/core/tools/read/views.ts +0 -29
  469. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
  470. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
  471. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
  472. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  473. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
  474. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
  475. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  476. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  477. /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
  478. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
  479. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  480. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
  481. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
  482. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
  483. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  484. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  485. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  486. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  487. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  488. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  489. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  490. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
@@ -0,0 +1,76 @@
1
+ import type { TextEditorCore } from "#src/core/text-editor-core.js";
2
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ import { Text } from "@earendil-works/pi-tui";
4
+ import {
5
+ deleteFileParameters,
6
+ transferFileParameters,
7
+ executeFileOperation,
8
+ } from "#src/core/file-operations.js";
9
+
10
+ /** Register whole-file tools using the same execution service as Apply. */
11
+ export function registerFileOperationTools(pi: ExtensionAPI, core: TextEditorCore): void {
12
+ for (const [name, description] of [
13
+ [
14
+ "delete_file",
15
+ "Use delete_file to permanently delete one regular file. Reject directories and symlinks. This deletes the file, unlike delete which removes selected text.",
16
+ ],
17
+ [
18
+ "move_file",
19
+ "Use move_file to move or rename one regular file. Reject directories and symlinks. Existing targets require overwrite: true. Works across devices. Configured post-processing can format UTF-8 text targets; binary contents remain unchanged.",
20
+ ],
21
+ [
22
+ "copy_file",
23
+ "Use copy_file to copy one regular file. Reject directories and symlinks. Existing targets require overwrite: true. Configured post-processing can format UTF-8 text targets; binary contents remain unchanged.",
24
+ ],
25
+ ] as const) {
26
+ pi.registerTool({
27
+ name,
28
+ label: name.replaceAll("_", " "),
29
+ renderCall(_args, theme) {
30
+ return new Text(theme.fg("toolTitle", theme.bold(name.replaceAll("_", " "))), 0, 0);
31
+ },
32
+ description,
33
+ promptSnippet: description,
34
+ parameters: name === "delete_file" ? deleteFileParameters : transferFileParameters,
35
+ async execute(_id, args, signal, _update, context) {
36
+ const outcome = await core.enqueueFileOperation(
37
+ () => executeFileOperation(name, args, context.cwd, signal),
38
+ signal,
39
+ );
40
+ let postProcessingError: string | undefined;
41
+ if (outcome.ok && outcome.target !== undefined) {
42
+ try {
43
+ await core.postProcessFile(outcome.target, { cwd: context.cwd, signal });
44
+ } catch (error) {
45
+ postProcessingError = error instanceof Error ? error.message : String(error);
46
+ }
47
+ }
48
+ return {
49
+ content: [
50
+ {
51
+ type: "text" as const,
52
+ text: [
53
+ `${name.replaceAll("_", " ")}: ${outcome.effect}`,
54
+ outcome.path,
55
+ postProcessingError === undefined
56
+ ? undefined
57
+ : `Post-processing failed: ${postProcessingError}`,
58
+ outcome.target === undefined ? undefined : `Target: ${outcome.target}`,
59
+ outcome.error === undefined
60
+ ? undefined
61
+ : `${outcome.error.code}: ${outcome.error.message}`,
62
+ ]
63
+ .filter((line) => line !== undefined)
64
+ .join("\n"),
65
+ },
66
+ ],
67
+ details: {
68
+ ...outcome,
69
+ ...(postProcessingError === undefined ? {} : { postProcessingError }),
70
+ },
71
+ isError: !outcome.ok,
72
+ };
73
+ },
74
+ });
75
+ }
76
+ }
@@ -0,0 +1,153 @@
1
+ import { lstat, unlink } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import fs from "fs-extra";
4
+ import { Type } from "typebox";
5
+ import { Value } from "typebox/value";
6
+
7
+ /** Whole-file operations, distinct from text-selection copy/move/remove. */
8
+ export const fileOperations = ["delete_file", "move_file", "copy_file"] as const;
9
+ export type FileOperation = (typeof fileOperations)[number];
10
+ const filePath = Type.String({
11
+ minLength: 1,
12
+ description: "Local regular file path, relative to cwd or absolute.",
13
+ });
14
+ export const deleteFileParameters = Type.Object(
15
+ { path: filePath },
16
+ { additionalProperties: false },
17
+ );
18
+ export const transferFileParameters = Type.Object(
19
+ {
20
+ path: filePath,
21
+ target: filePath,
22
+ overwrite: Type.Optional(
23
+ Type.Boolean({
24
+ description: "Allow replacing an existing regular target file. Defaults to false.",
25
+ }),
26
+ ),
27
+ },
28
+ { additionalProperties: false },
29
+ );
30
+
31
+ /** Plain receipt; unknown means the filesystem call failed after execution began. */
32
+ export interface FileOperationResult {
33
+ readonly kind: "file-operation";
34
+ readonly operation: FileOperation;
35
+ readonly ok: boolean;
36
+ readonly effect: "applied" | "not-applied" | "unknown";
37
+ readonly path?: string;
38
+ readonly target?: string;
39
+ readonly error?: { readonly code: string; readonly message: string };
40
+ }
41
+
42
+ /** Recognize a host-owned whole-file receipt for shared output rendering. */
43
+ export function isFileOperationResult(value: unknown): value is FileOperationResult {
44
+ return (
45
+ value !== null &&
46
+ typeof value === "object" &&
47
+ "kind" in value &&
48
+ value.kind === "file-operation"
49
+ );
50
+ }
51
+
52
+ /** Compact operation summary shared by standalone and Apply output. */
53
+ export function formatFileOperation(value: FileOperationResult): string {
54
+ return [
55
+ `${value.operation}: ${value.effect}`,
56
+ value.path,
57
+ value.target === undefined ? undefined : `Target: ${value.target}`,
58
+ value.error === undefined ? undefined : `${value.error.code}: ${value.error.message}`,
59
+ ]
60
+ .filter((line) => line !== undefined)
61
+ .join("\n");
62
+ }
63
+ /** Uses maintained filesystem primitives; never decodes file contents or recursively deletes. */
64
+ export async function executeFileOperation(
65
+ operation: FileOperation,
66
+ input: unknown,
67
+ cwd: string,
68
+ signal?: AbortSignal,
69
+ ): Promise<FileOperationResult> {
70
+ let started = false;
71
+ let source: string | undefined;
72
+ let target: string | undefined;
73
+ try {
74
+ const schema = operation === "delete_file" ? deleteFileParameters : transferFileParameters;
75
+ if (!Value.Check(schema, input))
76
+ throw Object.assign(new Error("Invalid file operation arguments"), {
77
+ code: "INVALID_ARGUMENTS",
78
+ });
79
+ const args = input as { path: string; target?: string; overwrite?: boolean };
80
+ source = path.resolve(cwd, args.path);
81
+ target = args.target === undefined ? undefined : path.resolve(cwd, args.target);
82
+ signal?.throwIfAborted();
83
+ const sourceStat = await regularFile(source);
84
+ if (target !== undefined) {
85
+ const targetStat = await optionalStat(target);
86
+ if (targetStat !== undefined) {
87
+ if (!targetStat.isFile() || targetStat.isSymbolicLink())
88
+ throw Object.assign(new Error("Target must be a regular file"), {
89
+ code: "INVALID_FILE_TYPE",
90
+ });
91
+ if (
92
+ source === target ||
93
+ (sourceStat.ino === targetStat.ino && sourceStat.dev === targetStat.dev)
94
+ )
95
+ throw Object.assign(new Error("Source and target are the same file"), {
96
+ code: "SAME_FILE",
97
+ });
98
+ if (args.overwrite !== true)
99
+ throw Object.assign(new Error("Target exists; use overwrite: true to replace it"), {
100
+ code: "EEXIST",
101
+ });
102
+ }
103
+ }
104
+ signal?.throwIfAborted();
105
+ started = true;
106
+ if (operation === "delete_file") await unlink(source);
107
+ else if (target !== undefined) {
108
+ if (operation === "copy_file")
109
+ await fs.copy(source, target, { overwrite: args.overwrite === true, errorOnExist: true });
110
+ else await fs.move(source, target, { overwrite: args.overwrite === true });
111
+ }
112
+ return {
113
+ kind: "file-operation",
114
+ operation,
115
+ ok: true,
116
+ effect: "applied",
117
+ path: source,
118
+ ...(target === undefined ? {} : { target }),
119
+ };
120
+ } catch (error) {
121
+ return {
122
+ kind: "file-operation",
123
+ operation,
124
+ ok: false,
125
+ effect: started ? "unknown" : "not-applied",
126
+ ...(source === undefined ? {} : { path: source }),
127
+ ...(target === undefined ? {} : { target }),
128
+ error: {
129
+ code:
130
+ error !== null && typeof error === "object" && "code" in error
131
+ ? String(error.code)
132
+ : "FILE_OPERATION_FAILED",
133
+ message: error instanceof Error ? error.message : String(error),
134
+ },
135
+ };
136
+ }
137
+ }
138
+
139
+ async function regularFile(file: string) {
140
+ const stat = await lstat(file);
141
+ if (!stat.isFile() || stat.isSymbolicLink())
142
+ throw Object.assign(new Error("Source must be a regular file"), { code: "INVALID_FILE_TYPE" });
143
+ return stat;
144
+ }
145
+ async function optionalStat(file: string) {
146
+ try {
147
+ return await lstat(file);
148
+ } catch (error) {
149
+ if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT")
150
+ return undefined;
151
+ throw error;
152
+ }
153
+ }
@@ -15,9 +15,12 @@ export function createUnifiedDiff(
15
15
  path: string,
16
16
  beforeContent: string,
17
17
  afterContent: string,
18
+ afterPath = path,
18
19
  ): UnifiedDiffResult {
19
- const diff = createTwoFilesPatch(path, path, beforeContent, afterContent, "", "", { context: 3 })
20
- .replace(/^Index: .*\n={3,}\n?/m, "")
20
+ const diff = createTwoFilesPatch(path, afterPath, beforeContent, afterContent, "", "", {
21
+ context: 3,
22
+ })
23
+ .replace(/^(?:Index: .*\n)?={3,}\n?/m, "")
21
24
  .trimEnd();
22
25
 
23
26
  return { diff, stats: computeStats(beforeContent, afterContent) };
@@ -1,4 +1,5 @@
1
1
  import { renderAgentDiff } from "./agent-diff.js";
2
+ import { groupReplacements, renderGroupedReplacements } from "./grouped-replacements.js";
2
3
  import { renderFinalStateFragment } from "./final-state-fragment.js";
3
4
  import { type FileMutationResult } from "./file-mutation-result.js";
4
5
 
@@ -23,6 +24,8 @@ export class FileMutationAgentResult {
23
24
  * Returned string is suitable for content[0].text in a tool response.
24
25
  */
25
26
  public toText(): string {
27
+ const grouped = groupReplacements(this.results);
28
+ if (grouped !== undefined) return renderGroupedReplacements(grouped);
26
29
  const parts: string[] = Array.from(this.results, (fmr) => this.formatSingle(fmr));
27
30
 
28
31
  return parts.join("\n\n");
@@ -285,14 +288,37 @@ export class FileMutationAgentResult {
285
288
  // ── Success formatting ────────────────────────────────────────────────
286
289
 
287
290
  private formatSuccess(fmr: FileMutationResult): string {
288
- const blocks: string[] = [];
291
+ const operations = fmr.data.operations ?? [];
292
+ const verbs: Record<string, string> = {
293
+ replace: "Replaced selected text",
294
+ insert: "Inserted new text",
295
+ delete: "Deleted selected text",
296
+ copy: "Copied selected text",
297
+ move: "Moved selected text",
298
+ write: "Wrote file content",
299
+ undo: "Restored file content",
300
+ stage: "Staged selected changes",
301
+ unstage: "Unstaged selected changes",
302
+ };
303
+ const blocks: string[] = [
304
+ operations.length === 0
305
+ ? "Changes applied."
306
+ : operations
307
+ .map(
308
+ ({ operation, changes }) =>
309
+ `${verbs[operation] ?? `Applied ${operation}`}: ${changes} text change(s) in this file.`,
310
+ )
311
+ .join("\n"),
312
+ `Formatting: ${fmr.data.formatting?.status ?? "not-reported"}${fmr.data.formatting?.formatter === undefined ? "" : ` (${fmr.data.formatting.formatter})`}.`,
313
+ ];
289
314
 
315
+ for (const status of fmr.data.diffStatuses ?? []) blocks.push(status.text);
290
316
  for (const diff of fmr.diffs) {
291
317
  const path = /^--- (.+)$/m.exec(diff)?.[1] ?? fmr.path ?? "<unknown file>";
292
318
  blocks.push(renderFinalStateFragment(fmr, path).join("\n"));
293
319
  }
294
320
 
295
- if (blocks.length === 0) {
321
+ if (fmr.diffs.length === 0) {
296
322
  for (const file of fmr.files) {
297
323
  blocks.push(file.path);
298
324
  }
@@ -11,6 +11,34 @@ export interface MutationAnchor {
11
11
  /** Successful mutation output style selected from the anchors used by the edit. */
12
12
  export type MutationResultPresentation = "plain" | "major-anchor";
13
13
 
14
+ /** Observed formatter outcome; it does not imply diagnostics or tests passed. */
15
+ export interface MutationFormatting {
16
+ readonly status:
17
+ | "disabled"
18
+ | "unavailable"
19
+ | "skipped-syntax"
20
+ | "unchanged"
21
+ | "changed"
22
+ | "failed"
23
+ | "not-reported"
24
+ | "deferred";
25
+ readonly formatter?: string;
26
+ }
27
+
28
+ /** Plain-text, per-file status shown beside diff counts and retained in history. */
29
+ export interface MutationDiffStatus {
30
+ /** Formatter identity allows multi-file summaries without parsing display text. */
31
+ readonly formatter?: string;
32
+ readonly text: string;
33
+ readonly tone?: "muted" | "success" | "warning" | "error";
34
+ }
35
+
36
+ /** One successful operation contributing changes to this file. */
37
+ export interface MutationOperationReceipt {
38
+ readonly operation: string;
39
+ readonly changes: number;
40
+ }
41
+
14
42
  export interface MutationSnapshot {
15
43
  readonly content: string;
16
44
  }
@@ -164,6 +192,19 @@ export interface FileMutationData {
164
192
  isPartial?: boolean | undefined;
165
193
 
166
194
  // ── Result fields ──
195
+
196
+ /** Successful operations represented by this result, including batched calls. */
197
+ operations?: readonly MutationOperationReceipt[] | undefined;
198
+ /** Formatter outcome reported by the post-edit integration. */
199
+ formatting?: MutationFormatting | undefined;
200
+
201
+ /** Display-only status contributions from post-edit handlers, in registration order. */
202
+ diffStatuses?: readonly MutationDiffStatus[] | undefined;
203
+
204
+ /** Original character spans owned by other calls in the same batch; display only. */
205
+ diffPeerRanges?:
206
+ | readonly { readonly from: number; readonly to: number; readonly insert: string }[]
207
+ | undefined;
167
208
  diffs?: string[] | undefined;
168
209
  files?: FileChange[] | undefined;
169
210
  warnings?: Warning[] | undefined;
@@ -226,6 +267,8 @@ export interface FileMutationData {
226
267
  * Phases are batch-wide (gate runs once for all files), not per-FMR.
227
268
  */
228
269
  export interface FileMutationBatchResult {
270
+ /** Structured contributions from configured IDE mutation handlers. */
271
+ readonly metadata?: Readonly<Record<string, unknown>>;
229
272
  /**
230
273
  Per-file mutation results (undefined when tool aborted).
231
274
  */
@@ -48,6 +48,8 @@ export function renderFinalStateFragment(fmr: FileMutationResult, path: string):
48
48
  }
49
49
 
50
50
  const range = requiredValue(ranges[rangeIndex]);
51
+
52
+ result.push(`Final text, lines ${range.start}–${range.end}:`);
51
53
  for (let lineNumber = range.start; lineNumber <= range.end; lineNumber += 1) {
52
54
  const content = lines[lineNumber - 1] ?? "";
53
55
  const metadata = metadataForLine(lineNumber, fmr.hints, visibleRanges, allowedSyntaxHints);
@@ -0,0 +1,81 @@
1
+ import type { FileMutationResult } from "./file-mutation-result.js";
2
+
3
+ /** Exact applied replacement pairs and complete per-file counts, before formatting. */
4
+ export interface GroupedReplacements {
5
+ readonly groups: readonly { removedText: string; insertedText: string; count: number }[];
6
+ readonly files: readonly { path: string; groups: readonly number[]; formatting: string }[];
7
+ readonly changes: number;
8
+ }
9
+
10
+ /** Groups successful replacements only when every result has complete applied-change evidence. */
11
+ export function groupReplacements(
12
+ results: readonly FileMutationResult[],
13
+ ): GroupedReplacements | undefined {
14
+ if (results.length === 0) return;
15
+ const groups: { removedText: string; insertedText: string; count: number }[] = [];
16
+ const indexes = new Map<string, number>();
17
+ const files: { path: string; groups: number[]; formatting: string }[] = [];
18
+ let changes = 0;
19
+ for (const result of results) {
20
+ const operations = result.data.operations;
21
+ const raw = result.data.rawChanges;
22
+ if (
23
+ !result.ok ||
24
+ result.isPartial ||
25
+ result.warnings.length > 0 ||
26
+ result.errors.length > 0 ||
27
+ (result.data.hints?.length ?? 0) > 0 ||
28
+ (result.data.diffStatuses?.length ?? 0) > 0 ||
29
+ !result.path ||
30
+ !operations?.length ||
31
+ operations.some((operation) => operation.operation !== "replace") ||
32
+ !raw?.length ||
33
+ operations.reduce((sum, operation) => sum + operation.changes, 0) !== raw.length
34
+ )
35
+ return;
36
+ const counts: number[] = [];
37
+ for (const change of raw) {
38
+ const key = JSON.stringify([change.removedText, change.insertedText]);
39
+ let index = indexes.get(key);
40
+ if (index === undefined) {
41
+ index = groups.length;
42
+ indexes.set(key, index);
43
+ groups.push({
44
+ removedText: change.removedText,
45
+ insertedText: change.insertedText,
46
+ count: 0,
47
+ });
48
+ }
49
+ const group = groups[index];
50
+ if (group === undefined) throw new Error("Missing replacement group");
51
+ group.count++;
52
+ counts[index] = (counts[index] ?? 0) + 1;
53
+ changes++;
54
+ }
55
+ files.push({
56
+ path: result.path,
57
+ groups: counts,
58
+ formatting: result.data.formatting?.status ?? "not-reported",
59
+ });
60
+ }
61
+ // Keep ordinary final-state output when there is nothing repeated to compress.
62
+ if (groups.length === changes) return;
63
+ return { groups, files, changes };
64
+ }
65
+
66
+ /** Renders all unique pairs and every affected file without repeating surrounding source text. */
67
+ export function renderGroupedReplacements(receipt: GroupedReplacements): string {
68
+ return [
69
+ `Applied ${receipt.changes} replacements in ${receipt.files.length} files.`,
70
+ "Exact applied replacements (before any additional formatting; not a full final-file view):",
71
+ ...receipt.groups.map(
72
+ (group, index) =>
73
+ `G${index + 1}: ${JSON.stringify(group.removedText)} -> ${JSON.stringify(group.insertedText)} (${group.count} replacements)`,
74
+ ),
75
+ "Files (complete):",
76
+ ...receipt.files.map(
77
+ (file) =>
78
+ `${file.path}: ${file.groups.flatMap((count, index) => (count ? [`G${index + 1} x ${count}`] : [])).join(", ")}; formatting: ${file.formatting}`,
79
+ ),
80
+ ].join("\n");
81
+ }
@@ -0,0 +1,73 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import type { TextResourceEditOutcome } from "./text-editor-core.js";
3
+
4
+ type Completed = Exclude<TextResourceEditOutcome<unknown>, { readonly kind: "failed" }>;
5
+ type Finalize = () => Promise<Completed>;
6
+ const active = new AsyncLocalStorage<Map<string, Finalize>>();
7
+ const notifications = new AsyncLocalStorage<Array<() => void>>();
8
+
9
+ /** Schedule observers only after every file in the current finalization has settled. */
10
+ export function afterPostEditScope(notify: () => void): void {
11
+ const pending = notifications.getStore();
12
+ if (pending) pending.push(notify);
13
+ else notify();
14
+ }
15
+
16
+ /** Keep post-edit notifications behind the final processing of all files. */
17
+ export async function collectPostEditNotifications<T>(work: () => Promise<T>): Promise<T> {
18
+ if (notifications.getStore()) return work();
19
+ const pending: Array<() => void> = [];
20
+ try {
21
+ return await notifications.run(pending, work);
22
+ } finally {
23
+ for (const notify of pending) notify();
24
+ }
25
+ }
26
+
27
+ /** Replace intermediate post-processing with the latest written state of this resource. */
28
+ export function deferPostEdit(source: string, finalize: Finalize): boolean {
29
+ const pending = active.getStore();
30
+ if (!pending) return false;
31
+ pending.set(source, finalize);
32
+ return true;
33
+ }
34
+
35
+ /** Optional read enrichment must not start checks on an intermediate edited snapshot. */
36
+ export function hasDeferredPostEdit(source: string): boolean {
37
+ return active.getStore()?.has(source) ?? false;
38
+ }
39
+ /** Writes stay immediate; finishing drains each surviving final resource once. */
40
+ export function createPostEditScope() {
41
+ const pending = new Map<string, Finalize>();
42
+ return {
43
+ run<T>(operation: () => T): T {
44
+ return active.run(pending, operation);
45
+ },
46
+ forget(source: string): void {
47
+ pending.delete(source);
48
+ },
49
+ async finish(onCompleted?: (outcome: Completed) => void): Promise<Completed[]> {
50
+ const work = [...pending.values()];
51
+ pending.clear();
52
+ const completed: Completed[] = [];
53
+ const errors: unknown[] = [];
54
+ await collectPostEditNotifications(async () => {
55
+ for (const finalize of work) {
56
+ try {
57
+ const outcome = await finalize();
58
+ completed.push(outcome);
59
+ onCompleted?.(outcome);
60
+ } catch (error) {
61
+ errors.push(error);
62
+ }
63
+ }
64
+ });
65
+ if (errors.length > 0)
66
+ throw new AggregateError(
67
+ errors,
68
+ `Some final post-processing failed; completed edits remain applied. ${errors.map((error) => (error instanceof Error ? error.message : String(error))).join("; ")}`,
69
+ );
70
+ return completed;
71
+ },
72
+ };
73
+ }
@@ -124,9 +124,12 @@ export class TextAnchorRegistry {
124
124
  );
125
125
  }
126
126
 
127
- public renderPromptSection(): string | undefined {
127
+ public renderPromptSection(kinds?: ReadonlySet<string>): string | undefined {
128
128
  const entries = this.#resolvers
129
- .filter(({ describeInPrompt }) => describeInPrompt)
129
+ .filter(
130
+ ({ describeInPrompt, kind }) =>
131
+ describeInPrompt && (kinds === undefined || kinds.has(kind)),
132
+ )
130
133
  .map(({ resolver }) => renderResolverDescription(resolver))
131
134
  .filter((entry): entry is string => entry !== undefined);
132
135
 
@@ -162,13 +162,21 @@ export class TextChangeDocument {
162
162
  }
163
163
  }
164
164
 
165
- export function applyTextChanges(source: string, changes: readonly TextChange[]): TextChangeResult {
165
+ /** Apply validated ranges; creation may have empty text but still creates a resource. */
166
+ export function applyTextChanges(
167
+ source: string,
168
+ changes: readonly TextChange[],
169
+ creating = false,
170
+ ): TextChangeResult {
166
171
  const ordered = changes
167
172
  .map((change, index) => ({ change, index }))
168
173
  .sort((left, right) => left.change.from - right.change.from || left.index - right.index)
169
174
  .map(({ change }) => change);
170
175
  validateChanges(source.length, ordered);
171
- if (ordered.some((change) => source.slice(change.from, change.to) === change.insert)) {
176
+ if (
177
+ !(creating && source.length === 0) &&
178
+ ordered.some((change) => source.slice(change.from, change.to) === change.insert)
179
+ ) {
172
180
  throw new Error("Text changes must change the document.");
173
181
  }
174
182
  const document = Text.of([source]);
@@ -57,6 +57,7 @@ interface TextBatchState {
57
57
  readonly registration: AnyTextMutationToolRegistration;
58
58
  }
59
59
  interface PlannedTextMutation extends TextMutation {
60
+ readonly operation: string;
60
61
  readonly resultPresentations: ReadonlyMap<string, MutationResultPresentation>;
61
62
  }
62
63
 
@@ -100,6 +101,23 @@ export function registerTextEditBatching(pi: ExtensionAPI, core: TextEditorCore)
100
101
  return;
101
102
  }
102
103
 
104
+ // Derived protocol targets need their owning execution pipeline, not snapshot batching.
105
+ const selectorFields = [
106
+ registration.source.field,
107
+ ...(registration.source.targets ?? []).map((target) => target.field),
108
+ ...(registration.anchors ?? []).map((anchor) => anchor.field),
109
+ ];
110
+ if (
111
+ selectorFields.some((field) => {
112
+ const value = call.arguments[field];
113
+ return (
114
+ typeof value === "string" &&
115
+ /^[a-z][a-z\d+.-]+:/iu.test(value) &&
116
+ !value.startsWith("file://")
117
+ );
118
+ })
119
+ )
120
+ return;
103
121
  const explicit = call.arguments[registration.source.field];
104
122
  const inheritedSource =
105
123
  !(typeof explicit === "string" && explicit.length > 0) && registration.source.inherited
@@ -303,6 +321,8 @@ export async function executeRegisteredTextBatch(
303
321
  callId: item.callId,
304
322
  mutation: {
305
323
  ...mutation,
324
+
325
+ operation: item.registration.name,
306
326
  resultPresentations: new Map(
307
327
  [...mutation.edits.keys()].map((source) => [
308
328
  source,
@@ -390,6 +410,19 @@ export async function executeRegisteredTextBatch(
390
410
  edit,
391
411
  ownAfter,
392
412
  mutation.resultPresentations.get(source) ?? "plain",
413
+
414
+ 1,
415
+ [{ operation: mutation.operation, changes: edit.changes.length }],
416
+
417
+ completedMutations.flatMap((peer) =>
418
+ peer.callId === callId
419
+ ? []
420
+ : (peer.mutation.edits.get(source)?.changes ?? []).map(({ from, to, insert }) => ({
421
+ from,
422
+ to,
423
+ insert,
424
+ })),
425
+ ),
393
426
  ),
394
427
  ];
395
428
  });
@@ -424,6 +457,13 @@ export async function executeRegisteredTextBatch(
424
457
  resource.after.content,
425
458
  finalPresentationBySource.get(source) ?? "plain",
426
459
  edits.length,
460
+
461
+ completedMutations.flatMap(({ mutation }) => {
462
+ const edit = mutation.edits.get(source);
463
+ return edit === undefined
464
+ ? []
465
+ : [{ operation: mutation.operation, changes: edit.changes.length }];
466
+ }),
427
467
  );
428
468
  resultsByCallId.get(finalCallId)?.push(result);
429
469
  results.push(result);