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
@@ -1,10 +1,14 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { requiredValue } from "pi-agent-invariant";
2
3
  import { ResourceScheduler, resourceAccesses } from "pi-agent-resource";
3
4
  import type { TextResourceEditOutcome } from "./text-editor-core.js";
4
5
 
5
6
  type Completed = Exclude<TextResourceEditOutcome<unknown>, { readonly kind: "failed" }>;
6
7
  type Finalize = () => Promise<Completed>;
7
- const active = new AsyncLocalStorage<Map<string, Finalize>>();
8
+ const active = new AsyncLocalStorage<{
9
+ readonly pending: Map<string, Finalize>;
10
+ readonly immediate: boolean;
11
+ }>();
8
12
  const notifications = new AsyncLocalStorage<Array<() => void>>();
9
13
 
10
14
  /** Schedule observers only after every file in the current finalization has settled. */
@@ -27,27 +31,32 @@ export async function collectPostEditNotifications<T>(work: () => Promise<T>): P
27
31
 
28
32
  /** Replace intermediate post-processing with the latest written state of this resource. */
29
33
  export function deferPostEdit(source: string, finalize: Finalize): boolean {
30
- const pending = active.getStore();
31
- if (!pending) return false;
32
- pending.set(source, finalize);
34
+ const scope = active.getStore();
35
+ if (!scope) return false;
36
+ if (scope.immediate) {
37
+ scope.pending.delete(source);
38
+ return false;
39
+ }
40
+ scope.pending.set(source, finalize);
33
41
  return true;
34
42
  }
35
43
 
36
44
  /** Optional read enrichment must not start checks on an intermediate edited snapshot. */
37
45
  export function hasDeferredPostEdit(source: string): boolean {
38
- return active.getStore()?.has(source) ?? false;
46
+ return active.getStore()?.pending.has(source) ?? false;
39
47
  }
40
48
 
41
49
  /** Stop deferred processing when a later operation removes or moves the resource. */
42
50
  export function forgetDeferredPostEdit(source: string): void {
43
- active.getStore()?.delete(source);
51
+ active.getStore()?.pending.delete(source);
44
52
  }
45
53
  /** Writes stay immediate; finishing drains each surviving final resource once. */
46
54
  export function createPostEditScope(cwd = process.cwd()) {
47
55
  const pending = new Map<string, Finalize>();
48
56
  return {
49
- run<T>(operation: () => T): T {
50
- return active.run(pending, operation);
57
+ /** Immediate processing replaces older deferred work for the same written resource. */
58
+ run<T>(operation: () => T, immediate = false): T {
59
+ return active.run({ pending, immediate }, operation);
51
60
  },
52
61
  forget(source: string): void {
53
62
  pending.delete(source);
@@ -56,7 +65,11 @@ export function createPostEditScope(cwd = process.cwd()) {
56
65
  sources(): readonly string[] {
57
66
  return [...pending.keys()];
58
67
  },
59
- async finish(onCompleted?: (outcome: Completed) => void): Promise<Completed[]> {
68
+ /** Report each final resource outcome; a failed finalization does not undo its write. */
69
+ async finish(
70
+ onCompleted?: (outcome: Completed) => void,
71
+ onFailed?: (source: string, error: unknown) => void,
72
+ ): Promise<Completed[]> {
60
73
  const work = [...pending];
61
74
  pending.clear();
62
75
  const completed: Completed[] = [];
@@ -68,9 +81,15 @@ export function createPostEditScope(cwd = process.cwd()) {
68
81
  scheduler.run(resourceAccesses(source, cwd, "write"), finalize),
69
82
  ),
70
83
  );
71
- for (const outcome of outcomes) {
84
+ for (const [index, outcome] of outcomes.entries()) {
85
+ const source = requiredValue(work[index])[0];
72
86
  if (outcome.status === "rejected") {
73
87
  errors.push(outcome.reason);
88
+ try {
89
+ onFailed?.(source, outcome.reason);
90
+ } catch (error) {
91
+ errors.push(error);
92
+ }
74
93
  continue;
75
94
  }
76
95
  completed.push(outcome.value);
@@ -78,6 +97,11 @@ export function createPostEditScope(cwd = process.cwd()) {
78
97
  onCompleted?.(outcome.value);
79
98
  } catch (error) {
80
99
  errors.push(error);
100
+ try {
101
+ onFailed?.(source, error);
102
+ } catch (failure) {
103
+ errors.push(failure);
104
+ }
81
105
  }
82
106
  }
83
107
  });
@@ -1,12 +1,30 @@
1
1
  import type { ResolvedResultTargets } from "pi-agent-resource";
2
2
  import { TextChangeDocument } from "./text-change-engine.js";
3
3
 
4
- /** Require a verified selection of one complete file before a whole-file operation. */
5
- export function wholeFileResultSource(result: ResolvedResultTargets): string {
4
+ const writePartialReason =
5
+ "Write received a partial file selection. Use replace to edit that selection, or Read the whole file before deliberately replacing all its contents.";
6
+
7
+ /** Require one complete file; name Write to provide its specific recovery instructions. */
8
+ export function wholeFileResultSource(
9
+ result: ResolvedResultTargets,
10
+ operation?: "write" | "undo",
11
+ ): string {
6
12
  const target = result.targets[0];
7
13
  const range = target?.ranges[0];
8
- if (result.targets.length !== 1 || target?.ranges.length !== 1 || range === undefined)
14
+ if (result.targets.length !== 1 || target?.ranges.length !== 1 || range === undefined) {
15
+ if (operation === "write") {
16
+ if (result.targets.length === 0)
17
+ throw new Error(
18
+ "Write received no file selection. Read the intended whole file before replacing it.",
19
+ );
20
+ if (result.targets.length > 1)
21
+ throw new Error(
22
+ "Write received multiple files. Choose one file and Read its whole contents before replacing it.",
23
+ );
24
+ throw new Error(writePartialReason);
25
+ }
9
26
  throw new Error("This operation requires one whole-file result target.");
27
+ }
10
28
  const document = new TextChangeDocument(target.expectedContent);
11
29
  const selected = document.range(
12
30
  range.start.lineNumber,
@@ -16,7 +34,9 @@ export function wholeFileResultSource(result: ResolvedResultTargets): string {
16
34
  );
17
35
  if (selected.from !== 0 || selected.to !== document.length)
18
36
  throw new Error(
19
- "This operation requires one whole-file result target; partial scopes are not widened.",
37
+ operation === "write"
38
+ ? writePartialReason
39
+ : "This operation requires one whole-file result target; partial scopes are not widened.",
20
40
  );
21
41
  return target.source;
22
42
  }
@@ -4,7 +4,7 @@ import type {
4
4
  TextMutationContext,
5
5
  TextMutationEdit,
6
6
  } from "#src/api/mutation-tool.js";
7
- import type { TextChange } from "./text-change-engine.js";
7
+ import { TextChangeDocument, type TextChange } from "./text-change-engine.js";
8
8
  import {
9
9
  anchorSpanRange,
10
10
  insertionAfterAnchor,
@@ -26,6 +26,8 @@ interface TransferSpan {
26
26
  interface PreparedTransfer {
27
27
  readonly input: Readonly<Record<string, unknown>>;
28
28
  readonly empty: boolean;
29
+ /** Verified unchanged destination points; no editor operation is needed. */
30
+ readonly noOpTarget?: string;
29
31
  readonly verifyFileSource?: () => Promise<void>;
30
32
  readonly mutate?: (context: TextMutationContext) => Promise<TextMutation>;
31
33
  }
@@ -46,7 +48,7 @@ export async function prepareResultTransfer(
46
48
  const selected = store.resolveOrdered(input[field], cwd);
47
49
  if (!selected.complete)
48
50
  throw new Error(
49
- "Incomplete result targets cannot establish a complete transfer; repeat Search.",
51
+ "Incomplete result targets cannot establish a complete transfer. Run Search again with a higher limit or a narrower query, then use the complete result.",
50
52
  );
51
53
  await store.verify(selected, signal);
52
54
  input[field] = store.register(selected.targets, cwd);
@@ -74,6 +76,28 @@ export async function prepareResultTransfer(
74
76
  "Transfer source and destination selection counts must match; no broadcast or concatenation.",
75
77
  );
76
78
  const empty = source?.targets.length === 0 || destination?.targets.length === 0;
79
+ if (operation === "move" && !empty && source !== undefined && destination !== undefined) {
80
+ const spans = (selected: ResolvedResultTargets): TransferSpan[] =>
81
+ selected.targets.map((target) => {
82
+ const range = target.ranges[0];
83
+ if (range === undefined) throw new Error("Transfer selection has no range.");
84
+ return {
85
+ source: target.source,
86
+ ...new TextChangeDocument(target.expectedContent).range(
87
+ range.start.lineNumber,
88
+ range.start.column,
89
+ range.end.lineNumber,
90
+ range.end.column,
91
+ ),
92
+ };
93
+ });
94
+ const sources = spans(source);
95
+ const destinations = spans(destination);
96
+ if ([...sources, ...destinations].every((span) => span.from === span.to)) {
97
+ assertMoveTargets(sources, destinations);
98
+ return { input, empty: false, noOpTarget: store.register(destination.targets, cwd) };
99
+ }
100
+ }
77
101
  return {
78
102
  input,
79
103
  empty,
@@ -157,19 +181,30 @@ export async function prepareResultTransfer(
157
181
  }
158
182
  }
159
183
  if (operation === "move") {
160
- for (const sourceSpan of sources)
161
- for (const transfer of planned)
162
- if (
163
- sourceSpan.source === transfer.target.source &&
164
- sourceSpan.from <= transfer.target.to &&
165
- transfer.target.from <= sourceSpan.to
166
- )
167
- throw new Error("Move target must not overlap or touch any source range.");
184
+ assertMoveTargets(
185
+ sources,
186
+ planned.map((transfer) => transfer.target),
187
+ );
168
188
  for (const span of sources)
169
189
  append(span, { from: span.from, to: span.to, insert: "" }, false);
170
190
  }
171
- for (const transfer of planned) append(transfer.target, transfer.change, true);
191
+ for (const transfer of planned)
192
+ append(
193
+ transfer.target,
194
+ operation === "copy" ? { ...transfer.change, allowUnchanged: true } : transfer.change,
195
+ true,
196
+ );
172
197
  return { edits };
173
198
  },
174
199
  };
175
200
  }
201
+
202
+ function assertMoveTargets(
203
+ sources: readonly TransferSpan[],
204
+ destinations: readonly TransferSpan[],
205
+ ): void {
206
+ for (const source of sources)
207
+ for (const target of destinations)
208
+ if (source.source === target.source && source.from <= target.to && target.from <= source.to)
209
+ throw new Error("Move target must not overlap or touch any source range.");
210
+ }
@@ -1,7 +1,6 @@
1
1
  import { Type, type Static } from "typebox";
2
2
  import {
3
3
  resultError,
4
- resultErrorSchema,
5
4
  structuredResultSchema,
6
5
  withStructuredResult,
7
6
  type StructuredResult,
@@ -36,7 +35,7 @@ export function mutationDataSchema(operation: string) {
36
35
  operation: Type.Literal(operation),
37
36
  ...receipt,
38
37
  operationId: Type.Optional(Type.String()),
39
- ...(operation === "delete" || operation === "flush"
38
+ ...(operation === "delete"
40
39
  ? {}
41
40
  : {
42
41
  target: Type.Optional(Type.String()),
@@ -50,17 +49,18 @@ export function mutationDataSchema(operation: string) {
50
49
  export function mutationResultSchema(operation: string) {
51
50
  return structuredResultSchema(mutationDataSchema(operation));
52
51
  }
53
- const batchOperation = Type.Object(
54
- { id: Type.String(), operation: Type.String(), effect, errors: Type.Array(resultErrorSchema) },
55
- { additionalProperties: false },
56
- );
57
- /** Flush owns the batch journal; individual file tools do not carry it. */
58
- export const flushDataSchema = Type.Object(
59
- { operation: Type.Literal("flush"), ...receipt, operations: Type.Array(batchOperation) },
60
- { additionalProperties: false },
61
- );
62
- export const flushOutputSchema = structuredResultSchema(flushDataSchema);
63
- export type FlushData = Static<typeof flushDataSchema>;
52
+ /** Observed file and operation effects retained on the parent native script. */
53
+ export interface BatchMutationData {
54
+ operation: "batch";
55
+ effect: MutationData["effect"];
56
+ files: MutationData["files"];
57
+ operations: {
58
+ id: string;
59
+ operation: string;
60
+ effect: MutationData["effect"];
61
+ errors: ResultError[];
62
+ }[];
63
+ }
64
64
  /** Small internal receipt used to collect observed file effects. */
65
65
  export interface MutationData {
66
66
  operation: string;
@@ -110,6 +110,8 @@ export function mutationOutcome(
110
110
  ...new Set([
111
111
  ...(data.files ?? []).map((file) => file.path),
112
112
  ...(data.path ? [data.path] : []),
113
+ ...(data.rollback?.failedSources ?? []),
114
+ ...(data.rollback?.restoredSources ?? []),
113
115
  ]),
114
116
  ];
115
117
  for (const source of sources)
@@ -120,7 +122,11 @@ export function mutationOutcome(
120
122
  observed.has(source) ||
121
123
  (data.ok === true && data.files?.some((file) => file.path === source))
122
124
  ? "applied"
123
- : (details.effect ?? "unknown"),
125
+ : data.rollback?.failedSources.includes(source)
126
+ ? "unknown"
127
+ : data.rollback?.restoredSources.includes(source)
128
+ ? "not-applied"
129
+ : (details.effect ?? "unknown"),
124
130
  });
125
131
  for (const error of data.errors ?? [])
126
132
  errors.push({
@@ -206,6 +212,7 @@ export function mutationOutcome(
206
212
  )
207
213
  errors.push({ code: "UNKNOWN_RESULT", message: "Mutation effects were not reported" });
208
214
  const effect =
215
+ details.effect === "unknown" ||
209
216
  unique.some((file) => file.effect === "unknown") ||
210
217
  errors.some((error) => error.code === "UNKNOWN_RESULT")
211
218
  ? "unknown"
@@ -0,0 +1,96 @@
1
+ import { readFile, realpath } from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+
5
+ interface TemporaryDirectorySettings {
6
+ readonly mode: "replace" | "extend";
7
+ readonly paths: readonly string[];
8
+ }
9
+
10
+ /** Load temporary roots for Delete: defaults, then global, then project settings. */
11
+ export async function loadTemporaryDirectories(projectRoot: string): Promise<readonly string[]> {
12
+ const home = await realpath(os.homedir());
13
+ const agent = process.env.PI_CODING_AGENT_DIR?.trim();
14
+ const names = ["tmp", ".tmp", "temp", ".temp"];
15
+ const system = await existingRoot(os.tmpdir());
16
+ // Named defaults do not grant permission to a symlink's destination outside the root.
17
+ let roots = [
18
+ ...names.map((name) => path.join(projectRoot, name)),
19
+ ...names.map((name) => path.join(home, name)),
20
+ ...(system === undefined ? [] : [system]),
21
+ ];
22
+ const layers = [
23
+ {
24
+ file: path.join(
25
+ agent ? path.resolve(agent) : path.join(home, ".pi", "agent"),
26
+ "pi-agent-ide",
27
+ "deletion.json",
28
+ ),
29
+ base: home,
30
+ },
31
+ { file: path.join(projectRoot, ".pi", "pi-agent-ide", "deletion.json"), base: projectRoot },
32
+ ];
33
+ for (const { file, base } of layers) {
34
+ const settings = await readSettings(file);
35
+ if (settings === undefined) continue;
36
+ const configured: string[] = [];
37
+ for (const entry of settings.paths) {
38
+ const expanded =
39
+ entry === "~"
40
+ ? home
41
+ : entry.startsWith("~/")
42
+ ? path.join(home, entry.slice(2))
43
+ : path.resolve(base, entry);
44
+ const root = await existingRoot(expanded);
45
+ if (root !== undefined) configured.push(root);
46
+ }
47
+ roots = settings.mode === "replace" ? configured : [...roots, ...configured];
48
+ }
49
+ return [...new Set(roots)].sort();
50
+ }
51
+
52
+ async function readSettings(file: string): Promise<TemporaryDirectorySettings | undefined> {
53
+ let source: string;
54
+ try {
55
+ source = await readFile(file, "utf8");
56
+ } catch (error) {
57
+ if (isMissing(error)) return undefined;
58
+ throw error;
59
+ }
60
+ let value: unknown;
61
+ try {
62
+ value = JSON.parse(source);
63
+ } catch (error) {
64
+ throw new Error(`Invalid JSON in deletion config at ${file}`, { cause: error });
65
+ }
66
+ if (!isRecord(value) || Object.keys(value).some((key) => key !== "temporaryDirectories"))
67
+ throw new Error(`Invalid deletion config at ${file}: expected temporaryDirectories settings`);
68
+ if (value.temporaryDirectories === undefined) return undefined;
69
+ const settings = value.temporaryDirectories;
70
+ if (
71
+ !isRecord(settings) ||
72
+ Object.keys(settings).some((key) => key !== "mode" && key !== "paths") ||
73
+ (settings.mode !== "replace" && settings.mode !== "extend") ||
74
+ !Array.isArray(settings.paths) ||
75
+ settings.paths.some((entry) => typeof entry !== "string" || entry.trim().length === 0)
76
+ )
77
+ throw new Error(
78
+ `Invalid temporaryDirectories at ${file}: use mode replace or extend and a paths array of non-empty strings`,
79
+ );
80
+ return { mode: settings.mode, paths: settings.paths as string[] };
81
+ }
82
+
83
+ async function existingRoot(directory: string): Promise<string | undefined> {
84
+ try {
85
+ return await realpath(directory);
86
+ } catch (error) {
87
+ if (isMissing(error)) return undefined;
88
+ throw error;
89
+ }
90
+ }
91
+ function isRecord(value: unknown): value is Record<string, unknown> {
92
+ return typeof value === "object" && value !== null && !Array.isArray(value);
93
+ }
94
+ function isMissing(error: unknown): boolean {
95
+ return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
96
+ }
@@ -8,6 +8,8 @@ export interface TextRange {
8
8
 
9
9
  export interface TextChange extends TextRange {
10
10
  readonly insert: string;
11
+ /** Copy may retain a destination range even when its text is already identical. */
12
+ readonly allowUnchanged?: true;
11
13
  }
12
14
 
13
15
  export interface AppliedTextChange {
@@ -220,7 +222,9 @@ export function applyTextChanges(
220
222
  validateChanges(source.length, ordered);
221
223
  if (
222
224
  !(creating && source.length === 0) &&
223
- ordered.some((change) => source.slice(change.from, change.to) === change.insert)
225
+ ordered.some(
226
+ (change) => !change.allowUnchanged && source.slice(change.from, change.to) === change.insert,
227
+ )
224
228
  ) {
225
229
  throw new Error("Text changes must change the document.");
226
230
  }