pi-agent-ide 0.7.1 → 0.7.3

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 (307) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +3 -1
  3. package/dist/{chunk-PKKDDIWW.js → chunk-2ZMMRINH.js} +1 -1
  4. package/dist/chunk-6U5OU77O.js +3 -0
  5. package/dist/chunk-BYZSBXUK.js +2 -0
  6. package/dist/{chunk-LEEQIQ7D.js → chunk-CEX73RI5.js} +6 -6
  7. package/dist/chunk-DZWTKF2K.js +1 -0
  8. package/dist/{chunk-WMO6RNE2.js → chunk-EOKEQ3YH.js} +6 -6
  9. package/dist/{chunk-HZEY4GT4.js → chunk-H445SHSJ.js} +2 -2
  10. package/dist/{chunk-4GCWGE2C.js → chunk-HZ5BNF3A.js} +1 -1
  11. package/dist/chunk-IG56UGSO.js +2 -0
  12. package/dist/chunk-IICJXZBU.js +6 -0
  13. package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
  14. package/dist/chunk-MXLSGMRZ.js +3 -0
  15. package/dist/{chunk-76ZK5ODR.js → chunk-NHKPP2AI.js} +13 -13
  16. package/dist/chunk-OB46OPMZ.js +1 -0
  17. package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
  18. package/dist/chunk-QUYXINGZ.js +7 -0
  19. package/dist/{chunk-OMVRLWMX.js → chunk-SBP3ABH4.js} +1 -1
  20. package/dist/{chunk-YP46DVVP.js → chunk-STBJO3Z3.js} +1 -1
  21. package/dist/{chunk-2TRHFMCZ.js → chunk-TXOTNK6B.js} +1 -1
  22. package/dist/chunk-WLZIUMJL.js +1 -0
  23. package/dist/chunk-ZIWPKIBZ.js +1 -0
  24. package/dist/entry-11.js +1 -1
  25. package/dist/entry-13.js +1 -1
  26. package/dist/entry-14.js +1 -1
  27. package/dist/entry-15.js +1 -1
  28. package/dist/entry-17.js +1 -1
  29. package/dist/entry-25.js +1 -1
  30. package/dist/entry-26.js +1 -1
  31. package/dist/entry-27.js +1 -1
  32. package/dist/entry-28.js +1 -1
  33. package/dist/entry-29.js +1 -1
  34. package/dist/entry-31.js +12 -11
  35. package/dist/entry-33.js +3 -1
  36. package/dist/entry-37.js +6 -6
  37. package/dist/entry-42.js +1 -1
  38. package/dist/entry-44.js +1 -1
  39. package/dist/entry-45.js +20 -12
  40. package/dist/entry-46.js +1 -1
  41. package/dist/entry-49.js +1 -1
  42. package/dist/entry-50.js +1 -1
  43. package/dist/entry-51.js +7 -6
  44. package/dist/entry-52.js +1 -1
  45. package/dist/entry-53.js +1 -1
  46. package/dist/entry-54.js +1 -1
  47. package/dist/entry-56.js +1 -1
  48. package/dist/entry-58.js +1 -1
  49. package/dist/entry-60.js +1 -1
  50. package/dist/entry-62.js +1 -1
  51. package/dist/entry-65.js +1 -1
  52. package/dist/entry-66.js +1 -1
  53. package/dist/entry-68.js +1 -1
  54. package/dist/entry-70.js +1 -1
  55. package/dist/entry-75.js +1 -1
  56. package/dist/entry-77.js +63 -49
  57. package/dist/entry-78.js +15 -14
  58. package/dist/entry-79.js +1 -1
  59. package/dist/entry-82.js +5 -5
  60. package/dist/entry-83.js +1 -1
  61. package/dist/entry-84.js +1 -1
  62. package/dist/entry-85.js +1 -1
  63. package/dist/entry-86.js +1 -1
  64. package/dist/pi-agent-ide.js +34 -11
  65. package/docs/agent-guides/editing.md +14 -7
  66. package/docs/agent-guides/git-changes.md +10 -0
  67. package/docs/agent-guides/read-resources.md +9 -46
  68. package/docs/agent-guides/search-code.md +7 -1
  69. package/docs/agent-guides/select-code.md +1 -0
  70. package/docs/agent-guides/terminal.md +9 -1
  71. package/docs/configuration.md +22 -1
  72. package/docs/development.md +4 -0
  73. package/docs/directory-operations.md +45 -0
  74. package/docs/releases.md +12 -0
  75. package/docs/research/codemode-write-context.md +56 -0
  76. package/docs/research/native-codemode-batch-decision.md +2 -0
  77. package/docs/structured-results.md +2 -2
  78. package/docs/tools.md +10 -2
  79. package/docs/user-hooks.md +26 -0
  80. package/node_modules/pi-agent-doctor/package.json +1 -1
  81. package/node_modules/pi-agent-documentation/package.json +1 -1
  82. package/node_modules/pi-agent-filesystem/package.json +7 -7
  83. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  84. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  85. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +4 -1
  86. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  87. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  88. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  89. package/node_modules/pi-agent-ide-ast/src/extension.ts +3 -3
  90. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
  91. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  92. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +8 -6
  93. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +13 -5
  94. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  95. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
  96. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  97. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  98. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  99. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  100. package/node_modules/pi-agent-ide-lsp/index.ts +1 -1
  101. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  102. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
  103. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  104. package/node_modules/pi-agent-image/package.json +2 -2
  105. package/node_modules/pi-agent-invariant/package.json +1 -1
  106. package/node_modules/pi-agent-pdf/package.json +2 -2
  107. package/node_modules/pi-agent-read/package.json +7 -7
  108. package/node_modules/pi-agent-read/src/api/read-parameters.ts +3 -3
  109. package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -0
  110. package/node_modules/pi-agent-read/src/core/extension.ts +1 -1
  111. package/node_modules/pi-agent-read/src/core/read-core.ts +5 -1
  112. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  113. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  114. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  115. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  116. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  117. package/node_modules/pi-agent-resource/package.json +1 -1
  118. package/node_modules/pi-agent-resource/src/index.ts +1 -0
  119. package/node_modules/pi-agent-resource/src/result-targets.ts +6 -3
  120. package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
  121. package/node_modules/pi-agent-search/package.json +5 -5
  122. package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
  123. package/node_modules/pi-agent-search/src/api/search-parameters.ts +2 -2
  124. package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
  125. package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
  126. package/node_modules/pi-agent-search-text/package.json +7 -7
  127. package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
  128. package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
  129. package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
  130. package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
  131. package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
  132. package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
  133. package/node_modules/pi-agent-text/package.json +2 -2
  134. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  135. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  136. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  137. package/node_modules/pi-agent-text-editor/package.json +9 -9
  138. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
  139. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  140. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  141. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  142. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  143. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
  144. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  145. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
  146. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  147. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  148. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
  149. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +30 -40
  150. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  151. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
  152. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
  153. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
  154. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  155. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
  156. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  157. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
  158. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
  159. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +21 -14
  160. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
  161. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  162. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
  163. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  164. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
  165. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
  166. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
  167. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
  168. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
  169. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  170. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  171. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
  172. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  173. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  174. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  175. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  176. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
  177. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  178. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  179. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  180. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  181. package/node_modules/pi-agent-web/package.json +7 -7
  182. package/node_modules/pi-agent-web/src/resolver.ts +11 -13
  183. package/node_modules/pi-agent-web-html/package.json +2 -2
  184. package/node_modules/pi-agent-web-image/package.json +3 -3
  185. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  186. package/node_modules/pi-agent-web-text/package.json +3 -3
  187. package/package.json +36 -35
  188. package/src/api/hooks.ts +24 -0
  189. package/src/composite/nested-tool-rendering.ts +184 -77
  190. package/src/composite/output-limits.ts +125 -0
  191. package/src/composite/responses-tools.ts +25 -0
  192. package/src/composite/text-results.ts +158 -7
  193. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  194. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  195. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  196. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +4 -1
  197. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  198. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  202. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  203. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  204. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
  205. package/src/extensions/pi-agent-read/package.json +7 -7
  206. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +3 -3
  207. package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -0
  208. package/src/extensions/pi-agent-read/src/core/extension.ts +1 -1
  209. package/src/extensions/pi-agent-read/src/core/read-core.ts +5 -1
  210. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  211. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  212. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  213. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  214. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  215. package/src/extensions/pi-agent-search/package.json +5 -5
  216. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
  217. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
  218. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
  219. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
  220. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
  221. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
  222. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
  223. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
  224. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +2 -2
  225. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
  226. package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
  227. package/src/extensions/pi-agent-text-editor/package.json +9 -9
  228. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  229. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  230. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  231. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  232. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  233. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
  234. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  235. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  236. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
  237. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  238. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  239. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  240. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  241. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
  242. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  243. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
  244. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  245. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  246. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
  247. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +30 -40
  248. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  249. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
  250. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
  251. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
  252. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  253. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
  254. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  255. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
  256. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
  257. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +21 -14
  258. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
  259. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  260. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
  261. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  262. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
  263. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
  264. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
  265. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
  266. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
  267. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  268. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  269. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
  270. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  271. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  272. package/src/pi-agent-ide.ts +11 -0
  273. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  274. package/src/plugins/pi-agent-ide-ast/src/extension.ts +3 -3
  275. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
  276. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  277. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +8 -6
  278. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +13 -5
  279. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  280. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
  281. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  282. package/src/plugins/pi-agent-ide-debugger/index.ts +20 -8
  283. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
  284. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
  285. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +3 -2
  286. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  287. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  288. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  289. package/src/plugins/pi-agent-ide-lsp/index.ts +1 -1
  290. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  291. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
  292. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  293. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
  294. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
  295. package/src/plugins/pi-agent-ide-vision/index.ts +1 -0
  296. package/src/post-edit/gate.ts +13 -2
  297. package/dist/chunk-4XMY4H4V.js +0 -1
  298. package/dist/chunk-64M3SQPG.js +0 -3
  299. package/dist/chunk-CWD4O5PM.js +0 -3
  300. package/dist/chunk-D3WTDA6V.js +0 -2
  301. package/dist/chunk-EAZGN5ND.js +0 -7
  302. package/dist/chunk-GXEGY7GV.js +0 -1
  303. package/dist/chunk-MBUXFKIW.js +0 -3
  304. package/dist/chunk-PGIVHICI.js +0 -1
  305. package/dist/chunk-VMTR74FF.js +0 -2
  306. package/dist/chunk-WU6ZK6YD.js +0 -1
  307. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
@@ -0,0 +1,164 @@
1
+ import type { Stats } from "node:fs";
2
+ import { lstat, readdir, readlink, realpath } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import {
5
+ assertUnprotectedTransferPath,
6
+ prepareDeletionGuard,
7
+ type DeletePolicyContext,
8
+ type DeletionGuard,
9
+ } from "./delete-policy.js";
10
+
11
+ /** Object kinds supported by byte-preserving whole-object transfers. */
12
+ export type TransferKind = "file" | "directory" | "symlink";
13
+
14
+ /** Preflight transfers and retain canonical paths; never dereference the final link. */
15
+ export async function prepareFileTransfer(
16
+ operation: "copy" | "move",
17
+ source: string,
18
+ target: string,
19
+ cwd: string,
20
+ context: DeletePolicyContext,
21
+ signal?: AbortSignal,
22
+ ): Promise<{ source: string; target: string; sourceKind: TransferKind }> {
23
+ const before = await inspectTransfer(operation, source, target, cwd, signal);
24
+ const guards: DeletionGuard[] = [];
25
+ if (operation === "move" && before.sourceKind !== "file") {
26
+ guards.push(await prepareDeletionGuard(source, cwd, context, signal));
27
+ if (before.targetExists) guards.push(await prepareDeletionGuard(target, cwd, context, signal));
28
+ }
29
+ // A later dialog or hook can change an earlier approved object. Recheck all approvals together.
30
+ for (const guard of guards) await guard.verify();
31
+ const after = await inspectTransfer(operation, source, target, cwd, signal);
32
+ if (before.snapshot !== after.snapshot)
33
+ fail(
34
+ "TRANSFER_TARGET_CHANGED",
35
+ "Transfer paths or contents changed during preflight. Nothing was transferred; make a new request.",
36
+ );
37
+ signal?.throwIfAborted();
38
+ return { source: before.source, target: before.target, sourceKind: before.sourceKind };
39
+ }
40
+
41
+ async function inspectTransfer(
42
+ operation: "copy" | "move",
43
+ source: string,
44
+ target: string,
45
+ cwd: string,
46
+ signal?: AbortSignal,
47
+ ) {
48
+ signal?.throwIfAborted();
49
+ const resolvedSource = await resolveLeaf(source);
50
+ const resolvedTarget = await resolveLeaf(target);
51
+ const sourceStat = await lstat(resolvedSource);
52
+ const targetStat = await optionalStat(resolvedTarget);
53
+ const sourceKind = kind(sourceStat);
54
+ validatePair(resolvedSource, sourceStat, resolvedTarget, targetStat);
55
+ if (
56
+ sourceKind === "directory" &&
57
+ (contains(resolvedSource, resolvedTarget) || contains(resolvedTarget, resolvedSource))
58
+ )
59
+ fail("OVERLAPPING_PATHS", "Source and target directory trees overlap.");
60
+ if (operation === "move") await assertUnprotectedTransferPath(resolvedSource, cwd, signal);
61
+ if (operation === "move" || sourceKind !== "file")
62
+ await assertUnprotectedTransferPath(resolvedTarget, cwd, signal);
63
+ const entries: unknown[] = [resolvedSource, resolvedTarget];
64
+ await inspectTree(resolvedSource, resolvedTarget, operation === "copy", entries, signal);
65
+ // Move removes the destination as one object; it does not merge child paths.
66
+ if (operation === "move") entries.push(snapshot(targetStat));
67
+ return {
68
+ source: resolvedSource,
69
+ target: resolvedTarget,
70
+ sourceKind,
71
+ targetExists: targetStat !== undefined,
72
+ snapshot: JSON.stringify(entries),
73
+ };
74
+ }
75
+
76
+ async function inspectTree(
77
+ source: string,
78
+ target: string,
79
+ merge: boolean,
80
+ entries: unknown[],
81
+ signal?: AbortSignal,
82
+ ): Promise<void> {
83
+ signal?.throwIfAborted();
84
+ const sourceStat = await lstat(source);
85
+ const sourceKind = kind(sourceStat);
86
+ const targetStat = merge ? await optionalStat(target) : undefined;
87
+ if (merge) validatePair(source, sourceStat, target, targetStat);
88
+ entries.push(source, snapshot(sourceStat), snapshot(targetStat));
89
+ if (sourceKind === "symlink") entries.push(await readlink(source));
90
+ if (sourceKind !== "directory") return;
91
+ for (const name of (await readdir(source)).sort())
92
+ await inspectTree(path.join(source, name), path.join(target, name), merge, entries, signal);
93
+ }
94
+
95
+ function validatePair(
96
+ source: string,
97
+ sourceStat: Stats,
98
+ target: string,
99
+ targetStat: Stats | undefined,
100
+ ) {
101
+ if (
102
+ source === target ||
103
+ (targetStat !== undefined &&
104
+ sourceStat.dev === targetStat.dev &&
105
+ sourceStat.ino === targetStat.ino)
106
+ )
107
+ fail("SAME_FILE", "Source and target are the same filesystem object.");
108
+ if (targetStat === undefined) return;
109
+ if (targetStat.isSymbolicLink())
110
+ fail("INVALID_FILE_TYPE", "Transfer destination must not be a symlink.");
111
+ if (kind(sourceStat) !== kind(targetStat))
112
+ fail("INVALID_FILE_TYPE", "Source and target must have the same object type.");
113
+ }
114
+
115
+ function kind(stat: Stats): TransferKind {
116
+ if (stat.isSymbolicLink()) return "symlink";
117
+ if (stat.isDirectory()) return "directory";
118
+ if (stat.isFile()) return "file";
119
+ fail("INVALID_FILE_TYPE", "Transfers support regular files, directories, and symlinks only.");
120
+ }
121
+
122
+ function snapshot(stat: Stats | undefined) {
123
+ return stat === undefined
124
+ ? null
125
+ : [stat.dev, stat.ino, stat.mode, stat.size, stat.birthtimeMs, stat.ctimeMs, stat.mtimeMs];
126
+ }
127
+
128
+ async function optionalStat(file: string) {
129
+ try {
130
+ return await lstat(file);
131
+ } catch (error) {
132
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
133
+ throw error;
134
+ }
135
+ }
136
+
137
+ async function resolveLeaf(file: string): Promise<string> {
138
+ return path.join(await resolveParent(path.dirname(file)), path.basename(file));
139
+ }
140
+
141
+ async function resolveParent(directory: string): Promise<string> {
142
+ try {
143
+ return await realpath(directory);
144
+ } catch (error) {
145
+ if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
146
+ // A dangling parent link is not a missing directory that we may create.
147
+ if (await optionalStat(directory)) throw error;
148
+ return path.join(await resolveParent(path.dirname(directory)), path.basename(directory));
149
+ }
150
+ }
151
+
152
+ function contains(parent: string, child: string) {
153
+ const relative = path.relative(parent, child);
154
+ return (
155
+ relative === "" ||
156
+ // This compares containment, not a parent-relative filesystem argument.
157
+ // eslint-disable-next-line repo/no-parent-paths
158
+ (!path.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path.sep}`))
159
+ );
160
+ }
161
+
162
+ function fail(code: string, message: string): never {
163
+ throw Object.assign(new Error(message), { code });
164
+ }
@@ -220,14 +220,9 @@ export class FileMutationAgentResult {
220
220
  }
221
221
  }
222
222
 
223
- // A rejected mutation describes only the blocked operation, not changes
224
- // already applied by the batch.
225
- const isMutationRejected = fmr.errors.some((error) => error.code === "MUTATION_REJECTED");
226
-
223
+ // A failed call alone does not prove that files stayed unchanged.
227
224
  if (fmr.fileChangedStatement !== undefined) {
228
225
  lines.push("", fmr.fileChangedStatement);
229
- } else if (!isMutationRejected) {
230
- lines.push("", "No file was changed.");
231
226
  }
232
227
 
233
228
  // File-level errors (WriteResultDetails blocked/failed, etc.)
@@ -287,6 +282,27 @@ export class FileMutationAgentResult {
287
282
 
288
283
  // ── Success formatting ────────────────────────────────────────────────
289
284
 
285
+ private formatFormatting(formatting: FileMutationResult["data"]["formatting"]): string {
286
+ const by = formatting?.formatter === undefined ? "" : ` (${formatting.formatter})`;
287
+ switch (formatting?.status) {
288
+ case "changed": {
289
+ return `Formatted${by}.`;
290
+ }
291
+ case "unchanged": {
292
+ return `Already formatted${by}.`;
293
+ }
294
+ case "unavailable": {
295
+ return "No formatter is available for this file.";
296
+ }
297
+ case "failed": {
298
+ return `Formatting failed${by}. Read the saved file before retrying.`;
299
+ }
300
+ default: {
301
+ return `Formatting: ${formatting?.status ?? "not-reported"}${by}.`;
302
+ }
303
+ }
304
+ }
305
+
290
306
  private formatSuccess(fmr: FileMutationResult): string {
291
307
  const operations = fmr.data.operations ?? [];
292
308
  const verbs: Record<string, string> = {
@@ -295,7 +311,6 @@ export class FileMutationAgentResult {
295
311
  delete: "Deleted selected text",
296
312
  copy: "Copied selected text",
297
313
  move: "Moved selected text",
298
- write: "Wrote file content",
299
314
  undo: "Restored file content",
300
315
  stage: "Staged selected changes",
301
316
  unstage: "Unstaged selected changes",
@@ -304,15 +319,24 @@ export class FileMutationAgentResult {
304
319
  operations.length === 0
305
320
  ? "Changes applied."
306
321
  : operations
307
- .map(
308
- ({ operation, changes }) =>
309
- `${verbs[operation] ?? `Applied ${operation}`}: ${changes} text change(s) in this file.`,
322
+ .map(({ operation, changes }) =>
323
+ operation === "write"
324
+ ? "Saved file."
325
+ : `${verbs[operation] ?? `Applied ${operation}`}: ${changes} text change(s) in this file.`,
310
326
  )
311
327
  .join("\n"),
312
- `Formatting: ${fmr.data.formatting?.status ?? "not-reported"}${fmr.data.formatting?.formatter === undefined ? "" : ` (${fmr.data.formatting.formatter})`}.`,
328
+ this.formatFormatting(fmr.data.formatting),
313
329
  ];
314
330
 
315
- for (const status of fmr.data.diffStatuses ?? []) blocks.push(status.text);
331
+ for (const status of fmr.data.diffStatuses ?? []) {
332
+ if (
333
+ status.formattingStatus !== undefined &&
334
+ status.formattingStatus === fmr.data.formatting?.status &&
335
+ status.formatter === fmr.data.formatting.formatter
336
+ )
337
+ continue;
338
+ blocks.push(status.text);
339
+ }
316
340
  for (const diff of fmr.diffs) {
317
341
  const path = /^--- (.+)$/m.exec(diff)?.[1] ?? fmr.path ?? "<unknown file>";
318
342
  blocks.push(renderFinalStateFragment(fmr, path).join("\n"));
@@ -29,6 +29,8 @@ export interface MutationFormatting {
29
29
  export interface MutationDiffStatus {
30
30
  /** Formatter identity allows multi-file summaries without parsing display text. */
31
31
  readonly formatter?: string;
32
+ /** Observed formatter state for this label, kept distinct from file edit counts. */
33
+ readonly formattingStatus?: MutationFormatting["status"];
32
34
  readonly text: string;
33
35
  readonly tone?: "muted" | "success" | "warning" | "error";
34
36
  }
@@ -236,6 +238,14 @@ export interface FileMutationData {
236
238
 
237
239
  staleDiagnostic?: StaleAnchorDiagnostic | undefined;
238
240
  fileChangedStatement?: string | undefined;
241
+ /** Failed rollback resources; an empty list means all attempted writes were restored. */
242
+ rollback?:
243
+ | {
244
+ readonly failedSources: readonly string[];
245
+ /** Existing resources whose restoration write succeeded. */
246
+ readonly restoredSources: readonly string[];
247
+ }
248
+ | undefined;
239
249
 
240
250
  // ── Transient engine fields ──
241
251
  snapshot?: MutationSnapshot | undefined;
@@ -325,7 +335,21 @@ export class FileMutationResult {
325
335
  readonly data: FileMutationData;
326
336
 
327
337
  public constructor(data?: FileMutationData) {
328
- this.data = data ?? {};
338
+ const formatting = data?.formatting;
339
+ this.data =
340
+ formatting === undefined || data?.diffStatuses === undefined
341
+ ? (data ?? {})
342
+ : {
343
+ ...data,
344
+ diffStatuses: data.diffStatuses.map((status) =>
345
+ status.formattingStatus !== undefined ||
346
+ formatting.formatter === undefined ||
347
+ status.formatter !== formatting.formatter ||
348
+ (status.tone !== "success" && status.tone !== "error")
349
+ ? status
350
+ : { ...status, formattingStatus: formatting.status },
351
+ ),
352
+ };
329
353
  }
330
354
 
331
355
  // ── Getters ──
@@ -1,10 +1,12 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
1
3
  import type { ResultRange, ResultSourceTarget } from "pi-agent-resource";
2
4
  import type { ResultTargetStore } from "pi-agent-resource";
3
5
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
4
6
  import type { FileMutationBatchResult } from "#src/api/mutation-result.js";
5
7
  import { createTextDocument } from "pi-agent-text";
6
8
  import type { TextEditCompletion } from "#src/api/edit-completion.js";
7
- import type { TextMutationEdit } from "#src/api/mutation-tool.js";
9
+ import type { TextMutation, TextMutationEdit } from "#src/api/mutation-tool.js";
8
10
  import { applyTextChanges } from "./text-change-engine.js";
9
11
  import { attachFileMutationTargets } from "./file-result-targets.js";
10
12
 
@@ -14,10 +16,36 @@ export interface OwnedMutationChanges {
14
16
  readonly edits: ReadonlyMap<string, TextMutationEdit>;
15
17
  }
16
18
 
17
- /** Map each call to its actual inserted text, including shifts from all batch peers. */
19
+ /** Find Copy destinations with identical text and no secondary resource action. */
20
+ export function unchangedCopySources(
21
+ mutation: TextMutation,
22
+ snapshots: ReadonlyMap<string, string>,
23
+ ): ReadonlySet<string> {
24
+ if (mutation.afterWrite !== undefined || mutation.semanticAction !== undefined) return new Set();
25
+ return new Set(
26
+ [...mutation.edits]
27
+ .filter(([source, edit]) => {
28
+ const before = snapshots.get(source);
29
+ return (
30
+ before !== undefined &&
31
+ edit.changes.length > 0 &&
32
+ edit.changes.every(
33
+ (change) =>
34
+ change.allowUnchanged && before.slice(change.from, change.to) === change.insert,
35
+ )
36
+ );
37
+ })
38
+ .map(([source]) => source),
39
+ );
40
+ }
41
+ /** Map final resource snapshots and unchanged Copy ranges; verify before publishing. */
18
42
  export function committedMutationTargets(
19
43
  mutations: readonly OwnedMutationChanges[],
20
- completions: readonly TextEditCompletion[],
44
+ completions: readonly Pick<
45
+ TextEditCompletion,
46
+ "source" | "resourceSource" | "resolvedBy" | "before" | "after" | "existed"
47
+ >[],
48
+ unchangedSnapshots: ReadonlyMap<string, string> = new Map(),
21
49
  ): ReadonlyMap<string, readonly ResultSourceTarget[]> {
22
50
  const targets = new Map<string, ResultSourceTarget[]>();
23
51
  const sources = new Set(mutations.flatMap((mutation) => [...mutation.edits.keys()]));
@@ -25,7 +53,7 @@ export function committedMutationTargets(
25
53
  const completion = completions.findLast(
26
54
  (item) => item.source === source || item.resourceSource === source,
27
55
  );
28
- if (!completion || completion.resolvedBy !== "filesystem") continue;
56
+ if (completion && completion.resolvedBy !== "filesystem") continue;
29
57
  const changes = mutations
30
58
  .flatMap((mutation) =>
31
59
  (mutation.edits.get(source)?.changes ?? []).map((change, index) => ({
@@ -35,12 +63,22 @@ export function committedMutationTargets(
35
63
  })),
36
64
  )
37
65
  .sort((left, right) => left.from - right.from);
38
- const before = completion.before.content;
39
- const after = completion.after.content;
40
- if (applyTextChanges(before, changes, !completion.existed).content !== after)
66
+ const before = completion?.before.content ?? unchangedSnapshots.get(source);
67
+ if (before === undefined) continue;
68
+ if (
69
+ !completion &&
70
+ changes.some(
71
+ (change) =>
72
+ !change.allowUnchanged || before.slice(change.from, change.to) !== change.insert,
73
+ )
74
+ )
75
+ continue;
76
+ const after = completion?.after.content ?? before;
77
+ const resourceSource = completion?.resourceSource ?? source;
78
+ if (applyTextChanges(before, changes, completion?.existed === false).content !== after)
41
79
  throw new Error("Mutation targets cannot be mapped to the actual written snapshot.");
42
80
  const starts = [0];
43
- for (const line of createTextDocument(completion.resourceSource, after).lines)
81
+ for (const line of createTextDocument(resourceSource, after).lines)
44
82
  if (line.lineEnding.length > 0)
45
83
  starts.push((starts.at(-1) ?? 0) + line.content.length + line.lineEnding.length);
46
84
  const position = (offset: number): ResultRange["start"] => {
@@ -71,7 +109,7 @@ export function committedMutationTargets(
71
109
  for (const [callId, selected] of ranges) {
72
110
  const own = targets.get(callId) ?? [];
73
111
  own.push({
74
- source: completion.resourceSource,
112
+ source: resourceSource,
75
113
  expectedContent: after,
76
114
  ranges: selected,
77
115
  });
@@ -81,6 +119,81 @@ export function committedMutationTargets(
81
119
  return targets;
82
120
  }
83
121
 
122
+ /** Explain missing Copy authority without changing its write outcome. */
123
+ export function describeUnavailableCopyTarget(
124
+ result: AgentToolResult<FileMutationBatchResult>,
125
+ ): AgentToolResult<FileMutationBatchResult> {
126
+ const notice = "No verified text selection. Read the destination before further edits.";
127
+ if (
128
+ result.isError ||
129
+ typeof result.details.metadata?.targetUnavailable !== "string" ||
130
+ result.content.some((block) => block.type === "text" && block.text === notice)
131
+ )
132
+ return result;
133
+ return {
134
+ ...result,
135
+ content: [
136
+ ...result.content,
137
+ {
138
+ type: "text",
139
+ text: notice,
140
+ },
141
+ ],
142
+ };
143
+ }
144
+
145
+ /** Publish filesystem Write snapshots, never grant file authority to live resources. */
146
+ export async function attachWriteTarget(
147
+ result: AgentToolResult<FileMutationBatchResult>,
148
+ completions: readonly TextEditCompletion[],
149
+ store: ResultTargetStore,
150
+ cwd: string,
151
+ signal?: AbortSignal,
152
+ ): Promise<AgentToolResult<FileMutationBatchResult>> {
153
+ if (result.isError) return result;
154
+ const file = result.details.results?.[0]?.data;
155
+ if (file?.path === undefined || file.afterContent === undefined) return result;
156
+ if (completions.some((completion) => completion.resolvedBy !== "filesystem")) return result;
157
+ try {
158
+ const content = file.afterContent;
159
+ const lines = content.split(/\r\n|\r|\n/u);
160
+ const targets: ResultSourceTarget[] = [
161
+ {
162
+ source: path.resolve(
163
+ cwd,
164
+ file.path.startsWith("file://") ? fileURLToPath(file.path) : file.path,
165
+ ),
166
+ expectedContent: content,
167
+ ranges: [
168
+ {
169
+ start: { lineNumber: 1, column: 0 },
170
+ end: { lineNumber: lines.length, column: lines.at(-1)?.length ?? 0 },
171
+ },
172
+ ],
173
+ },
174
+ ];
175
+ await store.verify({ targets, complete: true }, signal);
176
+ return {
177
+ ...result,
178
+ details: {
179
+ ...result.details,
180
+ metadata: { ...result.details.metadata, resultTarget: store.register(targets, cwd) },
181
+ },
182
+ };
183
+ } catch (error) {
184
+ signal?.throwIfAborted();
185
+ return {
186
+ ...result,
187
+ details: {
188
+ ...result.details,
189
+ metadata: {
190
+ ...result.details.metadata,
191
+ targetUnavailable: error instanceof Error ? error.message : String(error),
192
+ },
193
+ },
194
+ };
195
+ }
196
+ }
84
197
  /** Publish immediate results only when their committed range mapping is verified. */
85
198
  export async function attachCommittedMutationTarget(
86
199
  result: AgentToolResult<FileMutationBatchResult>,
@@ -92,8 +205,14 @@ export async function attachCommittedMutationTarget(
92
205
  wholeFile = false,
93
206
  plannedEdits?: ReadonlyMap<string, TextMutationEdit>,
94
207
  destinationOnly = false,
208
+ unchangedSnapshots: ReadonlyMap<string, string> = new Map(),
95
209
  ): Promise<AgentToolResult<FileMutationBatchResult>> {
96
- if (result.isError || typeof result.details.metadata?.resultTarget === "string") return result;
210
+ if (
211
+ result.isError ||
212
+ typeof result.details.metadata?.resultTarget === "string" ||
213
+ completions.some((completion) => completion.resolvedBy !== "filesystem")
214
+ )
215
+ return result;
97
216
  result = await attachFileMutationTargets(result, store, cwd, signal);
98
217
  if (
99
218
  typeof result.details.metadata?.resultTarget === "string" ||
@@ -135,9 +254,11 @@ export async function attachCommittedMutationTarget(
135
254
  },
136
255
  );
137
256
  }
257
+ for (const [source, edit] of plannedEdits ?? [])
258
+ if (!edits.has(source) && unchangedSnapshots.has(source)) edits.set(source, edit);
138
259
  if (edits.size === 0 && result.details.metadata?.emptyTargets !== true) return result;
139
260
  try {
140
- const mapped = committedMutationTargets([{ callId, edits }], completions);
261
+ const mapped = committedMutationTargets([{ callId, edits }], completions, unchangedSnapshots);
141
262
  const targets = mapped.get(callId) ?? [];
142
263
  const outputCount = [...edits.values()].filter(
143
264
  (edit) => edit.resultChanges?.length !== 0,