pi-agent-ide 0.2.2 → 0.4.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 (403) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +13 -8
  3. package/dist/chunk-3SE372WC.js +3 -0
  4. package/dist/chunk-5MSNYFDE.js +1 -0
  5. package/dist/chunk-5VSE5X5R.js +2 -0
  6. package/dist/chunk-6DZA4CLO.js +4 -0
  7. package/dist/chunk-6EYWFBNG.js +0 -0
  8. package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
  9. package/dist/chunk-7JYQMAEL.js +14 -0
  10. package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
  11. package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
  12. package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
  13. package/dist/chunk-DQF5QMJ2.js +1 -0
  14. package/dist/chunk-EJ5OACQM.js +1 -0
  15. package/dist/chunk-GFW5QPQV.js +2 -0
  16. package/dist/{chunk-LQYZG62K.js → chunk-GUTQ3PWL.js} +1 -1
  17. package/dist/chunk-HGPUI7F3.js +1 -0
  18. package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
  19. package/dist/chunk-ITSNK5YG.js +7 -0
  20. package/dist/chunk-J34VKQGJ.js +1 -0
  21. package/dist/chunk-KAB3AYA2.js +1 -0
  22. package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
  23. package/dist/chunk-M5MJP7Z2.js +1 -0
  24. package/dist/chunk-NMFQGKPE.js +2 -0
  25. package/dist/chunk-NTYXZ3EL.js +3 -0
  26. package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
  27. package/dist/chunk-ROXXK6TW.js +0 -0
  28. package/dist/{chunk-WNMGUALD.js → chunk-TI5GMJ7Q.js} +1 -1
  29. package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
  30. package/dist/chunk-XSTHESNR.js +25 -0
  31. package/dist/{chunk-THSCUT2L.js → chunk-Y7ZMR4LT.js} +1 -1
  32. package/dist/chunk-YHADTHQM.js +1 -0
  33. package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
  34. package/dist/{chunk-ZXN3TWWW.js → chunk-ZM4L5AGN.js} +1 -1
  35. package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
  36. package/dist/entry-0.js +1 -1
  37. package/dist/entry-1.js +1 -1
  38. package/dist/entry-10.js +1 -1
  39. package/dist/entry-12.js +1 -1
  40. package/dist/entry-13.js +1 -1
  41. package/dist/entry-14.js +1 -1
  42. package/dist/entry-2.js +1 -1
  43. package/dist/entry-21.js +1 -1
  44. package/dist/entry-24.js +1 -1
  45. package/dist/entry-25.js +1 -1
  46. package/dist/entry-26.js +10 -5
  47. package/dist/entry-28.js +1 -1
  48. package/dist/entry-29.js +1 -1
  49. package/dist/entry-31.js +3 -3
  50. package/dist/entry-32.js +6 -5
  51. package/dist/entry-36.js +1 -1
  52. package/dist/entry-37.js +1 -1
  53. package/dist/entry-38.js +1 -1
  54. package/dist/entry-39.js +1 -1
  55. package/dist/entry-4.js +1 -1
  56. package/dist/entry-40.js +12 -8
  57. package/dist/entry-42.js +1 -1
  58. package/dist/entry-43.js +1 -1
  59. package/dist/entry-44.js +1 -1
  60. package/dist/entry-45.js +4 -4
  61. package/dist/entry-46.js +10 -10
  62. package/dist/entry-47.js +1 -1
  63. package/dist/entry-48.js +1 -1
  64. package/dist/entry-49.js +1 -1
  65. package/dist/entry-50.js +1 -1
  66. package/dist/entry-51.js +1 -1
  67. package/dist/entry-52.js +1 -1
  68. package/dist/entry-53.js +1 -1
  69. package/dist/entry-54.js +1 -0
  70. package/dist/entry-55.js +0 -1
  71. package/dist/entry-56.js +1 -0
  72. package/dist/entry-57.js +0 -1
  73. package/dist/entry-58.js +1 -1
  74. package/dist/entry-59.js +1 -1
  75. package/dist/entry-60.js +1 -1
  76. package/dist/entry-61.js +1 -1
  77. package/dist/entry-62.js +1 -1
  78. package/dist/entry-63.js +1 -0
  79. package/dist/entry-64.js +0 -1
  80. package/dist/entry-65.js +1 -0
  81. package/dist/entry-66.js +0 -1
  82. package/dist/entry-67.js +1 -1
  83. package/dist/entry-68.js +1 -1
  84. package/dist/entry-69.js +1 -59
  85. package/dist/entry-70.js +123 -4
  86. package/dist/entry-71.js +30 -1
  87. package/dist/entry-72.js +2 -29
  88. package/dist/entry-73.js +1 -2
  89. package/dist/entry-74.js +1 -1
  90. package/dist/entry-75.js +1 -1
  91. package/dist/entry-76.js +3 -1
  92. package/dist/entry-77.js +1 -3
  93. package/dist/entry-78.js +1 -1
  94. package/dist/entry-79.js +1 -1
  95. package/dist/pi-agent-ide.js +3 -2
  96. package/docs/configuration.md +32 -11
  97. package/docs/tools.md +17 -0
  98. package/node_modules/pi-agent-doctor/package.json +1 -1
  99. package/node_modules/pi-agent-filesystem/package.json +6 -6
  100. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  101. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  102. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  103. package/node_modules/pi-agent-ide-ast/package.json +9 -9
  104. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -3
  105. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  106. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  107. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  108. package/node_modules/pi-agent-ide-changes/index.ts +21 -5
  109. package/node_modules/pi-agent-ide-changes/package.json +6 -6
  110. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  111. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  112. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  113. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
  114. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
  115. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  116. package/node_modules/pi-agent-ide-lint/index.ts +46 -17
  117. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  118. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
  119. package/node_modules/pi-agent-ide-lsp/index.ts +126 -8
  120. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  121. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  122. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  123. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  124. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  125. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  126. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  127. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  128. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  129. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  130. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  131. package/node_modules/pi-agent-image/package.json +2 -2
  132. package/node_modules/pi-agent-invariant/package.json +1 -1
  133. package/node_modules/pi-agent-pdf/package.json +2 -2
  134. package/node_modules/pi-agent-read/package.json +6 -6
  135. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  136. package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
  137. package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
  138. package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
  139. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  140. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  141. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  142. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  143. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  144. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  145. package/node_modules/pi-agent-resource/package.json +1 -1
  146. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  147. package/node_modules/pi-agent-resource/src/resource.ts +2 -0
  148. package/node_modules/pi-agent-search/package.json +3 -3
  149. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  150. package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
  151. package/node_modules/pi-agent-search/src/api/search.ts +55 -1
  152. package/node_modules/pi-agent-search/src/core/extension.ts +2 -23
  153. package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
  154. package/node_modules/pi-agent-search-text/index.ts +44 -4
  155. package/node_modules/pi-agent-search-text/package.json +6 -6
  156. package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
  157. package/node_modules/pi-agent-text/package.json +2 -2
  158. package/node_modules/pi-agent-text/src/text-document.ts +5 -0
  159. package/node_modules/pi-agent-text/src/text-target.ts +4 -0
  160. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  161. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  162. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  163. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  164. package/node_modules/pi-agent-text-editor/index.ts +1 -3
  165. package/node_modules/pi-agent-text-editor/package.json +34 -24
  166. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
  167. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  168. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  169. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  170. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  171. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  172. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  173. package/node_modules/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  174. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  175. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  176. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  177. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  178. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  179. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  180. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  181. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  182. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  183. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  184. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  185. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  186. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  187. package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
  188. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  189. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  190. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  191. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  192. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  193. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  194. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  195. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  196. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  197. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  198. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  199. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  200. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  201. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  202. package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  204. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  205. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  206. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  207. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  208. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  209. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  210. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  211. package/node_modules/pi-agent-web/package.json +7 -7
  212. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  213. package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
  214. package/node_modules/pi-agent-web-html/package.json +3 -3
  215. package/node_modules/pi-agent-web-image/package.json +4 -4
  216. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  217. package/node_modules/pi-agent-web-text/package.json +4 -4
  218. package/package.json +41 -38
  219. package/src/api/plugin-protocol.ts +10 -2
  220. package/src/api/tool-config.ts +73 -2
  221. package/src/code-view/diagnostic-view.ts +22 -3
  222. package/src/composite/builtin-extensions.ts +10 -15
  223. package/src/composite/extensions-config.ts +59 -0
  224. package/src/composite/feature-flags.ts +32 -0
  225. package/src/composite/module-labels.ts +59 -0
  226. package/src/composite/module-settings-store.ts +60 -0
  227. package/src/composite/module-settings.ts +162 -0
  228. package/src/composite/preferences.ts +26 -0
  229. package/src/composite/selection.ts +4 -4
  230. package/src/composite/settings-panel.ts +103 -0
  231. package/src/core/diagnostic-delivery.ts +29 -0
  232. package/src/core/diagnostic-entry.ts +51 -3
  233. package/src/core/diagnostic-store.ts +56 -5
  234. package/src/core/extension.ts +34 -33
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
  247. package/src/extensions/pi-agent-read/package.json +6 -6
  248. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  249. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
  250. package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
  251. package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
  252. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  253. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  254. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +64 -14
  255. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  256. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  257. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  258. package/src/extensions/pi-agent-search/package.json +3 -3
  259. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
  260. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  261. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +65 -25
  262. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  263. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
  264. package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
  265. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -23
  266. package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -3
  267. package/src/extensions/pi-agent-text-editor/index.ts +1 -3
  268. package/src/extensions/pi-agent-text-editor/package.json +34 -24
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  273. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +88 -1
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +20 -12
  277. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  278. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  279. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
  280. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
  281. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  282. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  283. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  284. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  285. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  286. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  287. package/src/extensions/pi-agent-text-editor/src/api/tool-renderer.ts +3 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  293. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  295. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  296. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  297. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  298. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  300. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  301. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
  302. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  303. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  304. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  305. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  306. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  307. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  308. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  309. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  310. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +212 -51
  311. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +273 -11
  312. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  313. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  314. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  315. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  316. package/src/pi-agent-ide.ts +43 -8
  317. package/src/plugins/pi-agent-ide-ast/package.json +9 -9
  318. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
  319. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  320. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  321. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  322. package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
  323. package/src/plugins/pi-agent-ide-changes/package.json +6 -6
  324. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  325. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  326. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
  327. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  328. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
  329. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
  330. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  331. package/src/plugins/pi-agent-ide-lint/index.ts +46 -17
  332. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  333. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
  334. package/src/plugins/pi-agent-ide-lsp/index.ts +126 -8
  335. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  336. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  337. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  338. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  339. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  340. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  341. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  342. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  343. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  344. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  345. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  346. package/src/plugins/pi-agent-ide-terminal/index.ts +34 -0
  347. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +238 -0
  348. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +461 -0
  349. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +127 -0
  350. package/src/plugins/pi-agent-ide-terminal/src/search.ts +159 -0
  351. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +529 -0
  352. package/src/plugins/pi-agent-ide-terminal/src/shell-profile.ts +56 -0
  353. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +157 -0
  354. package/src/plugins/pi-agent-ide-terminal/src/types.ts +66 -0
  355. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +336 -0
  356. package/src/post-edit/gate.ts +15 -2
  357. package/dist/chunk-4U6KGABH.js +0 -1
  358. package/dist/chunk-6ACQQBUY.js +0 -7
  359. package/dist/chunk-GFWDXTOB.js +0 -4
  360. package/dist/chunk-JASLOB2X.js +0 -1
  361. package/dist/chunk-JJVXUL5U.js +0 -2
  362. package/dist/chunk-KCEOTU5Z.js +0 -3
  363. package/dist/chunk-KVGQG43U.js +0 -1
  364. package/dist/chunk-QJFRAMK7.js +0 -2
  365. package/dist/chunk-RAZOACDD.js +0 -2
  366. package/dist/chunk-RIGRP3FD.js +0 -1
  367. package/dist/chunk-VCCMVQXU.js +0 -1
  368. package/dist/chunk-X6MPU7UO.js +0 -3
  369. package/dist/chunk-YPHXLAQF.js +0 -1
  370. package/dist/entry-80.js +0 -1
  371. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  372. package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
  373. package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
  374. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  375. package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
  376. package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
  377. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  378. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  379. package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
  380. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  381. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  382. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
  383. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
  384. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
  385. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  386. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
  387. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
  388. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  389. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  390. /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
  391. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
  392. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  393. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
  394. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
  395. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
  396. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  397. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  398. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  399. /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
  400. /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
  401. /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
  402. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  403. /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
@@ -1,5 +1,24 @@
1
1
  # Configuration
2
2
 
3
+ ## Agent IDE settings
4
+
5
+ Open `/agent-ide-settings` inside Pi and choose Project or Global. The Modules tab lists human-readable module names and descriptions. The Features tab lists registered boolean options. Tab switches tabs; typing filters the current list. Enter changes an override, Ctrl+S saves, and Esc cancels.
6
+
7
+ Default removes the selected scope’s override. Module descriptions show effective state and dependency restrictions. Feature values in project settings override global values. Saving offers a reload; declining leaves changes pending until reload or startup. The command stays available even when every optional module is disabled.
8
+
9
+ Feature overrides are stored under `flags` in `extensions.json`, keyed by their CLI name. Existing `noAnimations` and `noPostProcessing` fields still work; changing the corresponding feature in the menu replaces that field with its flag override.
10
+
11
+ The Features tab includes **Disable Apply** (`pi-agent-ide-no-apply`). Enable it and reload to remove only the `apply` tool; standalone tools remain available. It defaults to off. The obsolete `old-tools` switch has been removed.
12
+
13
+ The UI tab contains animation preferences and **Apply presentation**. Mixed is the default: written helper calls are compacted while the script streams. Code shows the full script (`pi-agent-ide-apply-code: true`). Expanded display exposes the source in either mode. These previews never execute arguments and do not indicate successful edits; operation results are shown separately.
14
+ After the call is complete, its display copy is formatted before Mixed substitutes the tool headers. Incomplete code uses the recoverable source preview. Headers keep supplied anchors and compact long argument expressions with their source size; those sizes are not counts of applied edits. `result(...)` stays visible as JavaScript. Expanded mode shows the full display copy. Execution always receives the original source.
15
+
16
+ All user-configurable presentation and behavior preferences belong in Agent IDE settings. New options must carry a human name, explanation and default in their registration. Presentation options belong in the UI tab.
17
+
18
+ New Agent IDE boolean options must use `createFeatureFlags().register` with an ID, human name, description and default. The same registration supplies the Pi flag and its Features or UI tab; no separate menu entry is needed.
19
+
20
+ Obsolete IDs in `disabled` are ignored. They do not stop IDE startup. Malformed configuration and unknown IDs in `enabled` still report configuration errors.
21
+
3
22
  Pi Agent IDE enables every built-in extension by default. Project and global config files can disable built-ins by their stable IDs and turn on built-ins that are off by default.
4
23
 
5
24
  ## Config files
@@ -19,11 +38,11 @@ Example:
19
38
 
20
39
  ```json
21
40
  {
22
- "enabled": ["editor.argument-order"]
41
+ "disabled": ["ide.lsp"]
23
42
  }
24
43
  ```
25
44
 
26
- `editor.argument-order` is off by default, so this config turns it on.
45
+ This config disables the LSP extension.
27
46
 
28
47
  An explicit `disabled` entry always beats an explicit `enabled` entry for the same ID.
29
48
  `enabled` matters only for built-ins marked as off by default; listing an always-on
@@ -38,6 +57,10 @@ Built-in entry modules are imported only after selection. Disabled built-ins, in
38
57
 
39
58
  ## Animations and post-edit processing
40
59
 
60
+ Apply writes happen immediately, but configured formatting runs once per surviving changed file at the end of the call, including after a script error. Batch diagnostics start after every file has finished post-processing. Copied and moved UTF-8 text targets also receive configured post-processing; binary contents stay unchanged. Reads and Git staging inside Apply see the bytes written so far, before final formatting.
61
+
62
+ Automatic diagnostic findings are grouped for five seconds from the first finding. The UI tab’s **Immediate diagnostic notices** option (`pi-agent-ide-no-diagnostic-buffer`) disables this delay. Combined notices keep each file and reporting tool identifiable. Empty completed diagnostic reads tell the agent that checks finished without findings, but do not draw an empty diagnostic panel. Pending, unavailable and incomplete checks are not reported as clean.
63
+
41
64
  Start Pi with either or both flags:
42
65
 
43
66
  ```sh
@@ -218,7 +241,7 @@ Edit tool diffs show every diff row by default. The panel keeps completed rows v
218
241
  - `disabled` and `enabled` must each be an array of unique, non-empty extension IDs.
219
242
  - The project and global lists are merged; a setting wins at either level.
220
243
  - Invalid JSON stops Pi Agent IDE from loading.
221
- - An unknown ID stops Pi Agent IDE from loading. This prevents a typo from silently leaving an extension enabled.
244
+ - Unknown `disabled` IDs are ignored. Unknown `enabled` IDs remain configuration errors.
222
245
  - Disabling a core also disables built-ins that depend on it.
223
246
  - The config controls bundled extensions only. It does not disable external Pi extensions.
224
247
 
@@ -259,14 +282,12 @@ Edit tool diffs show every diff row by default. The panel keeps completed rows v
259
282
 
260
283
  ### Editing and anchors
261
284
 
262
- | ID | Contribution |
263
- | ------------------------- | -------------------------------------------------- |
264
- | `editor.anchor.constant` | `begin` and `end` anchors |
265
- | `editor.anchor.line-hash` | Snapshot-aware line anchors |
266
- | `editor.anchor.exact` | Unique exact text spans and recovery |
267
- | `editor.argument-order` | Stable mutation argument ordering (off by default) |
268
- | `editor.overwrite` | Full-file overwrite protection (off by default) |
269
- | `editor.stale-anchor` | Stale-anchor recovery behavior |
285
+ | ID | Contribution |
286
+ | ------------------------- | ------------------------------------ |
287
+ | `editor.anchor.constant` | `begin` and `end` anchors |
288
+ | `editor.anchor.line-hash` | Snapshot-aware line anchors |
289
+ | `editor.anchor.exact` | Unique exact text spans and recovery |
290
+ | `editor.stale-anchor` | Stale-anchor recovery behavior |
270
291
 
271
292
  ### Code intelligence and feedback
272
293
 
package/docs/tools.md CHANGED
@@ -44,6 +44,12 @@ Browser reads discover `google-chrome`, `google-chrome-stable`, `chromium`, or `
44
44
 
45
45
  When `path` is a typed text resource, `read` returns one independent chunk for each selected range, in resolver order. Each chunk starts at the range's containing line. `offset` and `limit` are applied to every chunk, not across the combined result. The chunks are then joined and the normal aggregate limit of 2,000 lines or 50 KiB is applied.
46
46
 
47
+ ### Original bytes
48
+
49
+ Use `read({path: "raw:sample.bin", offset: 0, limit: 64})` to inspect original local file bytes, including PDF and image headers. In `raw:` mode only, offset is zero-based in bytes (negative from EOF), and limit is a non-negative byte count. The output shows hexadecimal offsets, hex bytes, and printable ASCII. Follow its returned byte offset to continue. No views or text anchors apply.
50
+
51
+ Inside Apply, the same call returns `kind: "bytes"`, `source`, `byteOffset`, `byteLength`, `totalBytes`, `bytes: number[]`, and `ok`. The script receives the complete selected range; the displayed answer stays bounded. Use `result(doc)` to retain the hex view rather than printing the byte array. This is read-only; byte editing and byte diff are not included.
52
+
47
53
  ### Diagnostic completion
48
54
 
49
55
  Edits save before background diagnostics finish. Automatic notifications show only sources with findings, in the chat as soon as they arrive, with a matching hidden message sent to the agent. A new finding wakes an idle agent; during a run it is queued as steering input for the next model call. Each source names the actual reporting command, such as `eslint_d` or `typescript-language-server`, rather than a wrapper extension. Chat summaries show that name in parentheses beside its counts. Pending, unavailable, and empty reports stay silent, including updates that clear earlier findings. Silence does not mean checks passed. Explicit `diagnostics:<path>` reads and the diagnostics view still return details and readiness.
@@ -52,6 +58,17 @@ LSP reads prefer standard pull reports. Servers that advertise a supported compl
52
58
 
53
59
  Other push-only servers return a `snapshot`: the latest publication, with no promise that every check has finished. This also applies to versioned pushes. An empty snapshot is not a completed clean report. For example, clangd publications remain usable C++ snapshots without invoking TypeScript commands. Later pushes from pull-capable or adapter-backed servers trigger a fresh completed request rather than replacing it with a partial publication.
54
60
 
61
+ ## Terminal sessions
62
+
63
+ `run` starts a command in the user's configured system shell. Its schema and prompt guidance name that shell at runtime, so the agent writes Bash, zsh, PowerShell, or Command Prompt syntax as appropriate. Commands are not translated between shell languages.
64
+
65
+ Every run returns a stable `shell:<session>` source. Synchronous runs wait for the real exit status. Background runs return immediately, remain visible below the editor, and send one completion message that wakes the agent; nearby completions are combined without losing individual results. `/terminals` opens the active and recent session overlay.
66
+ The UI tab in `/agent-ide-settings` controls persistent active-terminal presentation: Detailed cards (default), Compact count, or Off. Detailed cards replace the separate active count instead of showing both. This setting does not hide ordinary run results or completion messages.
67
+
68
+ Use `read` on the returned source for status and bounded output. Compact cards show the latest 12 output rows and count omitted earlier rows; expanded cards show all retained rows. Add `views: ["image"]` to receive a PNG of the ANSI-aware virtual terminal screen. Use `write` to send exact text without Enter. Use `insert` for named keys and chords such as `Enter`, `Ctrl+C`, `Ctrl+Shift+Left`, or Unix caret controls such as `^U`; separate multiple keys with spaces or commas. Batched `apply` calls can send several terminal inputs without file formatting or diagnostics. Use `search` with the `shell:<session>` path to search retained output, including rows outside the current screen. `delete` terminates the owned process tree when needed, disposes the virtual screen, and removes the session. `replace` does not apply to terminal sessions.
69
+
70
+ Deleting an active session first requests graceful termination, then forcefully terminates its process tree after the grace period. Deletion does not undo file or network effects. Sessions are owned by the current Pi runtime and are cleaned up on shutdown or reload; they are not reattached after restart.
71
+
55
72
  ## Search
56
73
 
57
74
  `search` gives the agent one discovery interface. Built-in resolvers cover:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-doctor",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-image": "0.2.2",
10
- "pi-agent-read": "0.2.2",
11
- "pi-agent-resource": "0.2.2",
12
- "pi-agent-text": "0.2.2",
13
- "pi-agent-text-editor": "0.2.2"
9
+ "pi-agent-image": "0.4.0",
10
+ "pi-agent-read": "0.4.0",
11
+ "pi-agent-resource": "0.4.0",
12
+ "pi-agent-text": "0.4.0",
13
+ "pi-agent-text-editor": "0.4.0"
14
14
  },
15
15
  "pi": {
16
16
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-image",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#extension": "./index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-image": "0.2.2",
10
- "pi-agent-resource": "0.2.2"
9
+ "pi-agent-image": "0.4.0",
10
+ "pi-agent-resource": "0.4.0"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-pdf",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-pdf": "0.2.2",
7
- "pi-agent-resource": "0.2.2"
6
+ "pi-agent-pdf": "0.4.0",
7
+ "pi-agent-resource": "0.4.0"
8
8
  },
9
9
  "pi": {
10
10
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-filesystem-text",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#extension": "./index.ts"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-resource": "0.2.2",
10
- "pi-agent-text": "0.2.2"
9
+ "pi-agent-resource": "0.4.0",
10
+ "pi-agent-text": "0.4.0"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-ide-ast",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -14,13 +14,13 @@
14
14
  "dependencies": {
15
15
  "@tree-sitter-grammars/tree-sitter-toml": "^0.7.0",
16
16
  "@tree-sitter-grammars/tree-sitter-yaml": "^0.7.1",
17
- "pi-agent-doctor": "0.2.2",
18
- "pi-agent-invariant": "0.2.2",
19
- "pi-agent-read": "0.2.2",
20
- "pi-agent-resource": "0.2.2",
21
- "pi-agent-search": "0.2.2",
22
- "pi-agent-text": "0.2.2",
23
- "pi-agent-text-editor": "0.2.2",
17
+ "pi-agent-doctor": "0.4.0",
18
+ "pi-agent-invariant": "0.4.0",
19
+ "pi-agent-read": "0.4.0",
20
+ "pi-agent-resource": "0.4.0",
21
+ "pi-agent-search": "0.4.0",
22
+ "pi-agent-text": "0.4.0",
23
+ "pi-agent-text-editor": "0.4.0",
24
24
  "tree-sitter-cpp": "^0.23.4",
25
25
  "tree-sitter-javascript": "^0.25.0",
26
26
  "tree-sitter-json": "^0.24.8",
@@ -36,6 +36,6 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@earendil-works/pi-coding-agent": "*",
39
- "pi-agent-ide": "0.2.2"
39
+ "pi-agent-ide": "0.4.0"
40
40
  }
41
41
  }
@@ -21,7 +21,7 @@ import {
21
21
  import { AstScopeManager } from "./ast/manager.js";
22
22
  import { astDoctorPlugin } from "./doctor-plugin.js";
23
23
  import { createAstOutlineResolver } from "./outline-resolver.js";
24
- import { createAstOverflowHandler } from "./overflow-handler.js";
24
+ import { createAstOverflowHandler, reduceAstReadOutput } from "./overflow-handler.js";
25
25
  import { createAstScopePostReadHandler, createAstScopePresenter } from "./scope-handler.js";
26
26
  import { createAstScopeAnchorResolver } from "./scope-resolver.js";
27
27
  import { createAstSearchResolver } from "./search-resolver.js";
@@ -45,6 +45,7 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
45
45
  });
46
46
  api.addView({ view: "ast", presenter });
47
47
  const overflow = createAstOverflowHandler();
48
+ api.addOutputReducer(reduceAstReadOutput);
48
49
  const scopes = createAstScopePostReadHandler();
49
50
  api.addHandler({
50
51
  stage: "post-read",
@@ -81,9 +82,9 @@ export default async function registerAst(pi: ExtensionAPI): Promise<void> {
81
82
  apiVersion: SEARCH_API_VERSION,
82
83
  id: "ast-search",
83
84
  setup(api): void {
84
- api.addResolver({ resolver: createAstSearchResolver() });
85
+ api.addResolver({ resolver: createAstSearchResolver(api.registerSelection) });
85
86
  api.describe(
86
- "Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search.",
87
+ "Search code structure with ast:<pattern>, using source-code syntax and placeholders such as $NAME for one node and $$$BODY for several nodes. path, include and exclude narrow the search. Use returned SEARCH# references to read, replace, copy, move or delete exact AST matches, including multiline nodes. A single :match reference becomes stale after its file changes; :all:match reruns the original structural query. Incomplete results do not provide all selections. Use captures in Apply to compute replacement text; these edits do not update imports or references.",
87
88
  );
88
89
  },
89
90
  }),
@@ -1,60 +1,83 @@
1
- import { truncateHead } from "@earendil-works/pi-coding-agent";
2
- import type { ReadPostReadHandler } from "pi-agent-read/api/tools/read";
1
+ import {
2
+ DEFAULT_MAX_BYTES,
3
+ DEFAULT_MAX_LINES,
4
+ truncateHead,
5
+ } from "@earendil-works/pi-coding-agent";
6
+ import type { ReadOutputReducer, ReadPostReadHandler } from "pi-agent-read/api/tools/read";
3
7
  import type { SourceViewBlock } from "pi-agent-ide/api/code-view";
4
8
 
5
- /** Replace an overflowing file window with a source-numbered whole-file outline.
6
- * Small windows and files without a usable outline keep the normal read result.
7
- */
9
+ /** Builds a compact source view from recorded text, never from a newer filesystem snapshot. */
10
+ export const reduceAstReadOutput: ReadOutputReducer = async (result, context, budget) => {
11
+ const { source, resolvedBy, lines, totalLines, startLine } = result.details;
12
+ if (
13
+ source === undefined ||
14
+ resolvedBy !== "filesystem" ||
15
+ lines === undefined ||
16
+ lines.length !== totalLines ||
17
+ (startLine !== undefined && startLine !== 1)
18
+ )
19
+ return undefined;
20
+ try {
21
+ const { AstOutlineManager, isSupportedOutlinePath } = await import("./ast/outline.js");
22
+ if (!isSupportedOutlinePath(source)) return undefined;
23
+ const format = (outline: SourceViewBlock): string =>
24
+ [
25
+ `AST overview of ${outline.path}, source lines 1-${outline.totalLines}: the requested text exceeded the read buffer.`,
26
+ "Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",
27
+ ...outline.renderedLines.map(
28
+ (line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
29
+ ),
30
+ ].join("\n");
31
+ context.signal?.throwIfAborted();
32
+ const outline = await new AstOutlineManager(12).readDocumentOutline(
33
+ source,
34
+ context.cwd,
35
+ lines.map((line) => line.content),
36
+ (candidate) => {
37
+ context.signal?.throwIfAborted();
38
+ return !truncateHead(format(candidate), budget).truncated;
39
+ },
40
+ );
41
+ const text = format(outline);
42
+ if (truncateHead(text, budget).truncated) return undefined;
43
+ return { content: [{ type: "text", text }], details: { source, resolvedBy: "ast-overflow" } };
44
+ } catch {
45
+ context.signal?.throwIfAborted();
46
+ return undefined;
47
+ }
48
+ };
49
+
50
+ /** Replace an overflowing read window with a source-numbered whole-file outline. */
8
51
  export function createAstOverflowHandler(): ReadPostReadHandler {
9
52
  return async (context) => {
10
53
  const { state, result } = context;
11
54
  const block = result?.content.length === 1 ? result.content[0] : undefined;
12
55
  if (
56
+ context.audience === "script" ||
57
+ result === undefined ||
13
58
  state?.contentKind !== "text" ||
14
59
  state.resolvedBy !== "filesystem" ||
15
60
  block?.type !== "text" ||
16
61
  !truncateHead(block.text).truncated
17
- ) {
62
+ )
18
63
  return { kind: "continue", context };
19
- }
20
- try {
21
- const { AstOutlineManager, isSupportedOutlinePath } = await import("./ast/outline.js");
22
- if (!isSupportedOutlinePath(state.source)) {
23
- return { kind: "continue", context };
24
- }
25
- const format = (outline: SourceViewBlock): string =>
26
- [
27
- `AST overview of ${outline.path}, source lines 1-${outline.totalLines}: the requested text exceeded the read buffer.`,
28
- "Source line numbers are on the left. Detail is reduced to fit the buffer; omitted bodies are not exact source text. Read a small source range when needed.",
29
- ...outline.renderedLines.map(
30
- (line) => `${line.sourceLine?.lineNumber ?? "…"} | ${line.text}`,
31
- ),
32
- ].join("\n");
33
- context.resolverContext.signal?.throwIfAborted();
34
- const outline = await new AstOutlineManager(12).readDocumentOutline(
35
- state.source,
36
- context.resolverContext.cwd,
37
- state.text.lines.map((line) => line.content),
38
- (candidate) => {
39
- context.resolverContext.signal?.throwIfAborted();
40
- return !truncateHead(format(candidate)).truncated;
41
- },
42
- );
43
- const text = format(outline);
44
- // Even a pathological source label must respect the output budget.
45
- if (truncateHead(text).truncated) {
46
- return { kind: "continue", context };
47
- }
48
- return {
49
- kind: "return",
50
- result: {
51
- content: [{ type: "text", text }],
52
- details: { source: state.source, resolvedBy: "ast-overflow" },
64
+ const reduced = await reduceAstReadOutput(
65
+ {
66
+ ...result,
67
+ details: {
68
+ ...result.details,
69
+ source: state.source,
70
+ resolvedBy: state.resolvedBy,
71
+ lines: state.text.lines,
72
+ startLine: 1,
73
+ totalLines: state.text.lines.length,
53
74
  },
54
- };
55
- } catch {
56
- context.resolverContext.signal?.throwIfAborted();
57
- return { kind: "continue", context };
58
- }
75
+ },
76
+ context.resolverContext,
77
+ { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES },
78
+ );
79
+ return reduced === undefined
80
+ ? { kind: "continue", context }
81
+ : { kind: "return", result: reduced };
59
82
  };
60
83
  }
@@ -9,6 +9,8 @@ import type { TextLinePresenter } from "pi-agent-text";
9
9
  const AST_SCOPE_METADATA = "pi-agent-ast";
10
10
 
11
11
  interface AstScopeBoundary {
12
+ readonly beginAnchor: string;
13
+ readonly endAnchor: string;
12
14
  readonly endLine: number;
13
15
  }
14
16
 
@@ -106,7 +108,11 @@ function addScopeMarkers(
106
108
  markersByLine.set(scope.startLine, begin);
107
109
 
108
110
  const boundaries = boundariesByLine.get(scope.startLine) ?? [];
109
- boundaries.push({ endLine: scope.endLine });
111
+ boundaries.push({
112
+ endLine: scope.endLine,
113
+ beginAnchor: scope.beginAnchor.value,
114
+ endAnchor: scope.endScopeAnchor.value,
115
+ });
110
116
  boundariesByLine.set(scope.startLine, boundaries);
111
117
 
112
118
  const end = markersByLine.get(scope.endLine) ?? [];
@@ -125,6 +131,7 @@ function addScopeMarkers(
125
131
  return {
126
132
  ...line,
127
133
  ...(markers !== undefined && {
134
+ anchors: [...new Set([...(line.anchors ?? []), ...markers])],
128
135
  presentation: {
129
136
  ...line.presentation,
130
137
  suffix: `${line.presentation?.suffix ?? ""}${markers
@@ -1,4 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { readFile, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import type { SearchPluginApi, SearchSelectionMatch } from "pi-agent-search/api/search";
2
5
 
3
6
  import type { SearchRequest, SearchResolver } from "pi-agent-search/api/search";
4
7
 
@@ -8,13 +11,16 @@ interface AstGrepMatch {
8
11
  readonly lines: string;
9
12
  readonly language: string;
10
13
  readonly range: {
14
+ readonly byteOffset: { readonly start: number; readonly end: number };
11
15
  readonly start: { readonly line: number; readonly column: number };
12
16
  readonly end: { readonly line: number; readonly column: number };
13
17
  };
14
18
  readonly metaVariables?: unknown;
15
19
  }
16
20
 
17
- export function createAstSearchResolver(): SearchResolver {
21
+ export function createAstSearchResolver(
22
+ registerSelection: SearchPluginApi["registerSelection"],
23
+ ): SearchResolver {
18
24
  return {
19
25
  id: "ast",
20
26
  async tryResolve(request, context) {
@@ -28,16 +34,41 @@ export function createAstSearchResolver(): SearchResolver {
28
34
  return { kind: "failed", error: new Error("ast: pattern must not be empty") };
29
35
  }
30
36
 
31
- const matches = await runAstGrep(pattern, request, context.cwd, context.signal);
32
- const limit = request.limit ?? 100;
37
+ const collect = async (signal?: AbortSignal) => {
38
+ const started = Date.now();
39
+ const found = await runAstGrep(pattern, request, context.cwd, signal);
40
+ found.sort(
41
+ (a, b) =>
42
+ path.resolve(context.cwd, a.file).localeCompare(path.resolve(context.cwd, b.file)) ||
43
+ a.range.byteOffset.start - b.range.byteOffset.start ||
44
+ a.range.byteOffset.end - b.range.byteOffset.end,
45
+ );
46
+ const raw = found.slice(0, request.limit ?? 100);
47
+ return {
48
+ raw,
49
+ matches: await selectionMatches(raw, context.cwd, started, signal),
50
+ complete: found.length <= (request.limit ?? 100),
51
+ };
52
+ };
53
+ const selected = await collect(context.signal);
54
+ const session = await registerSelection(
55
+ { request, matches: selected.matches, complete: selected.complete, refresh: collect },
56
+ context,
57
+ );
33
58
  return {
34
59
  kind: "resolved",
35
- payload: { pattern, matches: matches.slice(0, limit), complete: matches.length <= limit },
60
+ payload: {
61
+ pattern,
62
+ matches: selected.raw,
63
+ complete: selected.complete,
64
+ sessionId: session.id,
65
+ },
36
66
  };
37
67
  },
38
68
  format(payload) {
39
69
  const result = payload as {
40
70
  readonly pattern: string;
71
+ readonly sessionId: string;
41
72
  readonly matches: readonly AstGrepMatch[];
42
73
  readonly complete: boolean;
43
74
  };
@@ -47,12 +78,14 @@ export function createAstSearchResolver(): SearchResolver {
47
78
  }
48
79
 
49
80
  const lines = result.matches.flatMap((match, index) => [
50
- `${String(index + 1)}. ${match.file}:${String(match.range.start.line + 1)}:${String(
81
+ `SEARCH#${result.sessionId}:${String(index + 1)}:match ${match.file}:${String(match.range.start.line + 1)}:${String(
51
82
  match.range.start.column + 1,
52
83
  )} ${match.language}`,
53
84
  ` ${match.lines.trim()}`,
54
85
  ]);
55
86
 
87
+ if (result.complete)
88
+ lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact AST matches.`);
56
89
  if (!result.complete) {
57
90
  lines.push("Result limit reached.");
58
91
  }
@@ -62,6 +95,51 @@ export function createAstSearchResolver(): SearchResolver {
62
95
  };
63
96
  }
64
97
 
98
+ async function selectionMatches(
99
+ matches: readonly AstGrepMatch[],
100
+ cwd: string,
101
+ started: number,
102
+ signal?: AbortSignal,
103
+ ): Promise<SearchSelectionMatch[]> {
104
+ const sources = new Map<string, Buffer>();
105
+ for (const match of matches) {
106
+ const source = path.resolve(cwd, match.file);
107
+ if (sources.has(source)) continue;
108
+ const before = await stat(source);
109
+ const bytes = await readFile(source, { signal });
110
+ const after = await stat(source);
111
+ if (before.mtimeMs > started || before.mtimeMs !== after.mtimeMs || before.size !== after.size)
112
+ throw new Error("AST source changed during search. Run the structural query again.");
113
+ sources.set(source, bytes);
114
+ }
115
+ return matches.map((match) => {
116
+ const source = path.resolve(cwd, match.file);
117
+ const bytes = sources.get(source);
118
+ if (bytes === undefined) throw new Error("Missing AST source snapshot");
119
+ const { start, end } = match.range.byteOffset;
120
+ if (
121
+ !Number.isInteger(start) ||
122
+ !Number.isInteger(end) ||
123
+ start < 0 ||
124
+ end < start ||
125
+ end > bytes.length ||
126
+ bytes.subarray(start, end).toString("utf8") !== match.text
127
+ )
128
+ throw new Error("AST range does not match its source snapshot. Search again.");
129
+ const prefix = bytes.subarray(0, start).toString("utf8");
130
+ const throughEnd = bytes.subarray(0, end).toString("utf8");
131
+ const lineNumber = prefix.split("\n").length;
132
+ return {
133
+ source,
134
+ lineNumber,
135
+ endLineNumber: throughEnd.split("\n").length,
136
+ startColumn: prefix.length - prefix.lastIndexOf("\n") - 1,
137
+ endColumn: throughEnd.length - throughEnd.lastIndexOf("\n") - 1,
138
+ matchedText: match.text,
139
+ lineText: bytes.toString("utf8").split("\n")[lineNumber - 1]?.replace(/\r$/u, "") ?? "",
140
+ };
141
+ });
142
+ }
65
143
  function runAstGrep(
66
144
  pattern: string,
67
145
  request: SearchRequest,
@@ -1,3 +1,4 @@
1
+ import { Value } from "typebox/value";
1
2
  import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
3
  import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
3
4
  import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
@@ -19,14 +20,14 @@ import { extensionGitExecutor } from "#src/changes/git-changes-backend.js";
19
20
  import { createCurrentChangePresenter } from "#src/current-change-presenter.js";
20
21
  import { IndexMutationQueue } from "#src/index-mutation-queue.js";
21
22
  import { LastTextTransactionStore } from "#src/last-text-transaction-store.js";
22
- import { registerIndexChangeTools } from "#src/tool-index-change.js";
23
+ import {
24
+ registerIndexChangeTools,
25
+ createIndexChangeTool,
26
+ indexChangeSchema,
27
+ } from "#src/tool-index-change.js";
23
28
  import { createUndoMutationTool } from "#src/tool-text-undo.js";
24
29
 
25
30
  export default async function registerGitChanges(pi: ExtensionAPI): Promise<void> {
26
- if (process.argv.includes("--old-tools")) {
27
- return;
28
- }
29
-
30
31
  const executor = extensionGitExecutor(pi);
31
32
  const transactions = new LastTextTransactionStore();
32
33
  const indexQueue = new IndexMutationQueue();
@@ -57,6 +58,21 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
57
58
  transactions.observe(completion);
58
59
  });
59
60
  api.addMutationTool(createUndoMutationTool(executor, transactions, indexQueue));
61
+ for (const action of ["stage", "unstage"] as const) {
62
+ const tool = createIndexChangeTool(action, executor, indexQueue);
63
+ api.addScriptIndexOperation({
64
+ name: action,
65
+ parameters: indexChangeSchema,
66
+ execute: (input, signal, context) =>
67
+ tool.execute(
68
+ `apply-${action}`,
69
+ Value.Decode(indexChangeSchema, input),
70
+ signal,
71
+ undefined,
72
+ context,
73
+ ),
74
+ });
75
+ }
60
76
  api.addTextPresenter({ presenter });
61
77
  },
62
78
  } satisfies TextEditorPlugin;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-ide-changes",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -13,11 +13,11 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "diff": "^9.0.0",
16
- "pi-agent-doctor": "0.2.2",
17
- "pi-agent-invariant": "0.2.2",
18
- "pi-agent-read": "0.2.2",
19
- "pi-agent-text": "0.2.2",
20
- "pi-agent-text-editor": "0.2.2"
16
+ "pi-agent-doctor": "0.4.0",
17
+ "pi-agent-invariant": "0.4.0",
18
+ "pi-agent-read": "0.4.0",
19
+ "pi-agent-text": "0.4.0",
20
+ "pi-agent-text-editor": "0.4.0"
21
21
  },
22
22
  "pi": {
23
23
  "extensions": [
@@ -15,6 +15,16 @@ export class LastTextTransactionStore {
15
15
 
16
16
  public observe(completion: TextEditCompletion): void {
17
17
  const key = sourceKey(completion.resourceSource, completion.cwd);
18
+ if (completion.postProcessing === "final") {
19
+ const previous = this.#transactions.get(key);
20
+ if (previous && previous.afterDigest === textDigest(completion.before.content))
21
+ this.#transactions.set(key, {
22
+ ...previous,
23
+ afterDigest: textDigest(completion.after.content),
24
+ });
25
+ else this.#transactions.delete(key);
26
+ return;
27
+ }
18
28
 
19
29
  if (
20
30
  completion.intent !== "edit" ||