pi-agent-ide 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +12 -8
  3. package/dist/chunk-5MSNYFDE.js +1 -0
  4. package/dist/chunk-5VSE5X5R.js +2 -0
  5. package/dist/chunk-6EYWFBNG.js +0 -0
  6. package/dist/{chunk-ORAPGW7W.js → chunk-72EEL2DW.js} +1 -1
  7. package/dist/{chunk-T2RPMEM2.js → chunk-7UGNGK7Y.js} +1 -1
  8. package/dist/{chunk-STUZZM5B.js → chunk-AADJ2KIB.js} +1 -1
  9. package/dist/{chunk-XF5PVZOS.js → chunk-B5KB2I7J.js} +1 -1
  10. package/dist/{chunk-WNMGUALD.js → chunk-CEKXBS55.js} +1 -1
  11. package/dist/chunk-CW53ZTU3.js +2 -0
  12. package/dist/chunk-EWNWKDMP.js +4 -0
  13. package/dist/{chunk-LQYZG62K.js → chunk-GUTQ3PWL.js} +1 -1
  14. package/dist/chunk-HGPUI7F3.js +1 -0
  15. package/dist/{chunk-OBWZ5RYN.js → chunk-HKMBQLEK.js} +1 -1
  16. package/dist/chunk-ITSNK5YG.js +7 -0
  17. package/dist/chunk-KAB3AYA2.js +1 -0
  18. package/dist/{chunk-THSCUT2L.js → chunk-LRYE2WCN.js} +1 -1
  19. package/dist/{chunk-76WHES5H.js → chunk-M5L42DWE.js} +5 -5
  20. package/dist/chunk-M5MJP7Z2.js +1 -0
  21. package/dist/chunk-NMFQGKPE.js +2 -0
  22. package/dist/chunk-NTYXZ3EL.js +3 -0
  23. package/dist/{chunk-P6T3Q7LB.js → chunk-QDST6VIU.js} +1 -1
  24. package/dist/chunk-RHV5STR3.js +3 -0
  25. package/dist/chunk-ROXXK6TW.js +0 -0
  26. package/dist/chunk-SSHZEWWV.js +1 -0
  27. package/dist/{chunk-4ZTEPMJO.js → chunk-TPIHQYK2.js} +1 -1
  28. package/dist/chunk-VZJIZXSH.js +14 -0
  29. package/dist/chunk-YHADTHQM.js +1 -0
  30. package/dist/{chunk-KZBAJFCV.js → chunk-Z3VC3S2T.js} +1 -1
  31. package/dist/{chunk-ZXN3TWWW.js → chunk-ZM4L5AGN.js} +1 -1
  32. package/dist/{chunk-E2RESHYR.js → chunk-ZTYWHL2F.js} +1 -1
  33. package/dist/entry-0.js +1 -1
  34. package/dist/entry-1.js +1 -1
  35. package/dist/entry-10.js +1 -1
  36. package/dist/entry-12.js +1 -1
  37. package/dist/entry-13.js +1 -1
  38. package/dist/entry-14.js +1 -1
  39. package/dist/entry-2.js +1 -1
  40. package/dist/entry-21.js +1 -1
  41. package/dist/entry-24.js +1 -1
  42. package/dist/entry-25.js +1 -1
  43. package/dist/entry-26.js +10 -5
  44. package/dist/entry-28.js +1 -1
  45. package/dist/entry-29.js +1 -1
  46. package/dist/entry-31.js +3 -3
  47. package/dist/entry-32.js +6 -5
  48. package/dist/entry-36.js +1 -1
  49. package/dist/entry-37.js +1 -1
  50. package/dist/entry-38.js +1 -1
  51. package/dist/entry-39.js +1 -1
  52. package/dist/entry-4.js +1 -1
  53. package/dist/entry-40.js +12 -8
  54. package/dist/entry-42.js +1 -1
  55. package/dist/entry-43.js +1 -1
  56. package/dist/entry-44.js +1 -1
  57. package/dist/entry-45.js +4 -4
  58. package/dist/entry-46.js +10 -10
  59. package/dist/entry-47.js +1 -1
  60. package/dist/entry-48.js +1 -1
  61. package/dist/entry-49.js +1 -1
  62. package/dist/entry-50.js +1 -1
  63. package/dist/entry-51.js +1 -1
  64. package/dist/entry-52.js +1 -1
  65. package/dist/entry-53.js +1 -1
  66. package/dist/entry-54.js +1 -0
  67. package/dist/entry-55.js +0 -1
  68. package/dist/entry-56.js +1 -0
  69. package/dist/entry-57.js +0 -1
  70. package/dist/entry-58.js +1 -1
  71. package/dist/entry-59.js +1 -1
  72. package/dist/entry-60.js +1 -1
  73. package/dist/entry-61.js +1 -1
  74. package/dist/entry-62.js +1 -1
  75. package/dist/entry-63.js +1 -0
  76. package/dist/entry-64.js +0 -1
  77. package/dist/entry-65.js +1 -0
  78. package/dist/entry-66.js +0 -1
  79. package/dist/entry-67.js +1 -1
  80. package/dist/entry-68.js +1 -1
  81. package/dist/entry-69.js +1 -59
  82. package/dist/entry-70.js +123 -4
  83. package/dist/entry-71.js +30 -1
  84. package/dist/entry-72.js +2 -29
  85. package/dist/entry-73.js +1 -2
  86. package/dist/entry-74.js +1 -1
  87. package/dist/entry-75.js +1 -1
  88. package/dist/entry-76.js +3 -1
  89. package/dist/entry-77.js +1 -3
  90. package/dist/entry-78.js +1 -1
  91. package/dist/entry-79.js +1 -1
  92. package/dist/pi-agent-ide.js +3 -2
  93. package/docs/configuration.md +32 -11
  94. package/docs/tools.md +6 -0
  95. package/node_modules/pi-agent-doctor/package.json +1 -1
  96. package/node_modules/pi-agent-filesystem/package.json +6 -6
  97. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  98. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  99. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  100. package/node_modules/pi-agent-ide-ast/package.json +9 -9
  101. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -3
  102. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  103. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  104. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  105. package/node_modules/pi-agent-ide-changes/index.ts +21 -5
  106. package/node_modules/pi-agent-ide-changes/package.json +6 -6
  107. package/node_modules/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  108. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  109. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  110. package/node_modules/pi-agent-ide-formatter/src/formatter.ts +26 -8
  111. package/node_modules/pi-agent-ide-formatter/src/registry.ts +9 -1
  112. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  113. package/node_modules/pi-agent-ide-lint/index.ts +46 -17
  114. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  115. package/node_modules/pi-agent-ide-lint/src/registry.ts +9 -1
  116. package/node_modules/pi-agent-ide-lsp/index.ts +126 -8
  117. package/node_modules/pi-agent-ide-lsp/package.json +9 -8
  118. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  119. package/node_modules/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  120. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  121. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  122. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  123. package/node_modules/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  124. package/node_modules/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  125. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  126. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  127. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  128. package/node_modules/pi-agent-image/package.json +2 -2
  129. package/node_modules/pi-agent-invariant/package.json +1 -1
  130. package/node_modules/pi-agent-pdf/package.json +2 -2
  131. package/node_modules/pi-agent-read/package.json +6 -6
  132. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  133. package/node_modules/pi-agent-read/src/api/read-parameters.ts +29 -0
  134. package/node_modules/pi-agent-read/src/api/tools/read.ts +73 -1
  135. package/node_modules/pi-agent-read/src/core/read-core.ts +26 -2
  136. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  137. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  138. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +61 -14
  139. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  140. package/node_modules/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  141. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  142. package/node_modules/pi-agent-resource/package.json +1 -1
  143. package/node_modules/pi-agent-resource/src/resolver.ts +2 -0
  144. package/node_modules/pi-agent-search/package.json +3 -3
  145. package/node_modules/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  146. package/node_modules/pi-agent-search/src/api/search-parameters.ts +25 -0
  147. package/node_modules/pi-agent-search/src/api/search.ts +55 -1
  148. package/node_modules/pi-agent-search/src/core/extension.ts +2 -23
  149. package/node_modules/pi-agent-search/src/core/search-core.ts +28 -3
  150. package/node_modules/pi-agent-search-text/index.ts +44 -4
  151. package/node_modules/pi-agent-search-text/package.json +6 -6
  152. package/node_modules/pi-agent-search-text/src/search-session.ts +65 -25
  153. package/node_modules/pi-agent-text/package.json +2 -2
  154. package/node_modules/pi-agent-text/src/text-document.ts +5 -0
  155. package/node_modules/pi-agent-text/src/text-target.ts +4 -0
  156. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  157. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  158. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  159. package/node_modules/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  160. package/node_modules/pi-agent-text-editor/index.ts +1 -3
  161. package/node_modules/pi-agent-text-editor/package.json +34 -24
  162. package/node_modules/pi-agent-text-editor/runtime/entry-69.js +0 -1
  163. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  164. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  165. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  166. package/node_modules/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  167. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  168. package/node_modules/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  169. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  170. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  171. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  172. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  173. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  174. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  175. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  176. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  177. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  178. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  179. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  180. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  181. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  182. package/node_modules/pi-agent-text-editor/src/core/extension.ts +6 -0
  183. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  184. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  185. package/node_modules/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  186. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  187. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  188. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  189. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  190. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  191. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +173 -49
  192. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
  193. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  194. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  195. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  196. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  197. package/node_modules/pi-agent-text-editor-renderer/index.ts +88 -1
  198. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  199. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  200. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -10
  201. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  202. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  203. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  204. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +1 -0
  205. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  206. package/node_modules/pi-agent-web/package.json +7 -7
  207. package/node_modules/pi-agent-web/runtime/entry-75.js +2 -0
  208. package/node_modules/pi-agent-web/src/browser-loader.ts +1 -0
  209. package/node_modules/pi-agent-web-html/package.json +3 -3
  210. package/node_modules/pi-agent-web-image/package.json +4 -4
  211. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  212. package/node_modules/pi-agent-web-text/package.json +4 -4
  213. package/package.json +38 -38
  214. package/src/api/plugin-protocol.ts +10 -2
  215. package/src/api/tool-config.ts +73 -2
  216. package/src/code-view/diagnostic-view.ts +22 -3
  217. package/src/composite/builtin-extensions.ts +4 -15
  218. package/src/composite/extensions-config.ts +41 -0
  219. package/src/composite/feature-flags.ts +32 -0
  220. package/src/composite/module-labels.ts +55 -0
  221. package/src/composite/module-settings-store.ts +44 -0
  222. package/src/composite/module-settings.ts +132 -0
  223. package/src/composite/selection.ts +4 -4
  224. package/src/composite/settings-panel.ts +71 -0
  225. package/src/core/diagnostic-delivery.ts +29 -0
  226. package/src/core/diagnostic-entry.ts +51 -3
  227. package/src/core/diagnostic-store.ts +56 -5
  228. package/src/core/extension.ts +34 -33
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +2 -0
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  239. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +2 -0
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/browser-loader.ts +1 -0
  241. package/src/extensions/pi-agent-read/package.json +6 -6
  242. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  243. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +29 -0
  244. package/src/extensions/pi-agent-read/src/api/tools/read.ts +73 -1
  245. package/src/extensions/pi-agent-read/src/core/read-core.ts +26 -2
  246. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +1 -1
  247. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +113 -0
  248. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +61 -14
  249. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +15 -0
  250. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +35 -126
  251. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +73 -44
  252. package/src/extensions/pi-agent-search/package.json +3 -3
  253. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +44 -4
  254. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  255. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +65 -25
  256. package/src/extensions/pi-agent-search/src/api/plugin-protocol.ts +1 -1
  257. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +25 -0
  258. package/src/extensions/pi-agent-search/src/api/search.ts +55 -1
  259. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -23
  260. package/src/extensions/pi-agent-search/src/core/search-core.ts +28 -3
  261. package/src/extensions/pi-agent-text-editor/index.ts +1 -3
  262. package/src/extensions/pi-agent-text-editor/package.json +34 -24
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/src/read-handler.ts +1 -0
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +88 -1
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +42 -25
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -10
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +33 -0
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  273. package/src/extensions/pi-agent-text-editor/runtime/entry-69.js +0 -1
  274. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +2 -0
  275. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +3 -0
  276. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  277. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +15 -0
  278. package/src/extensions/pi-agent-text-editor/src/api/last-resolved-resource.ts +5 -0
  279. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +15 -1
  280. package/src/extensions/pi-agent-text-editor/src/api/post-edit.ts +3 -0
  281. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +237 -0
  282. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +50 -0
  283. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +11 -0
  284. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +208 -0
  285. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +39 -0
  286. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +216 -0
  287. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +45 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +25 -0
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +324 -0
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +133 -0
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +112 -0
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +132 -0
  293. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +205 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +6 -0
  295. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +76 -0
  296. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +153 -0
  297. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/diff.ts +5 -2
  298. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +1 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +6 -1
  300. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +73 -0
  301. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +10 -2
  302. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +17 -0
  303. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +173 -49
  304. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +261 -9
  305. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
  306. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +1 -1
  307. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
  308. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
  309. package/src/pi-agent-ide.ts +42 -8
  310. package/src/plugins/pi-agent-ide-ast/package.json +9 -9
  311. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -3
  312. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +68 -45
  313. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +8 -1
  314. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +83 -5
  315. package/src/plugins/pi-agent-ide-changes/index.ts +21 -5
  316. package/src/plugins/pi-agent-ide-changes/package.json +6 -6
  317. package/src/plugins/pi-agent-ide-changes/src/last-text-transaction-store.ts +10 -0
  318. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +4 -2
  319. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +62 -11
  320. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  321. package/src/plugins/pi-agent-ide-formatter/src/formatter.ts +26 -8
  322. package/src/plugins/pi-agent-ide-formatter/src/registry.ts +9 -1
  323. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  324. package/src/plugins/pi-agent-ide-lint/index.ts +46 -17
  325. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  326. package/src/plugins/pi-agent-ide-lint/src/registry.ts +9 -1
  327. package/src/plugins/pi-agent-ide-lsp/index.ts +126 -8
  328. package/src/plugins/pi-agent-ide-lsp/package.json +9 -8
  329. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +61 -0
  330. package/src/plugins/pi-agent-ide-lsp/src/diagnostic-source.ts +18 -3
  331. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +4 -0
  332. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +40 -0
  333. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +21 -32
  334. package/src/plugins/pi-agent-ide-lsp/src/lsp/registry.ts +15 -2
  335. package/src/plugins/pi-agent-ide-lsp/src/lsp/rename.ts +1 -1
  336. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +32 -5
  337. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +138 -0
  338. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +9 -2
  339. package/src/post-edit/gate.ts +15 -2
  340. package/dist/chunk-4U6KGABH.js +0 -1
  341. package/dist/chunk-6ACQQBUY.js +0 -7
  342. package/dist/chunk-GFWDXTOB.js +0 -4
  343. package/dist/chunk-JASLOB2X.js +0 -1
  344. package/dist/chunk-JJVXUL5U.js +0 -2
  345. package/dist/chunk-KCEOTU5Z.js +0 -3
  346. package/dist/chunk-KVGQG43U.js +0 -1
  347. package/dist/chunk-QJFRAMK7.js +0 -2
  348. package/dist/chunk-RAZOACDD.js +0 -2
  349. package/dist/chunk-RIGRP3FD.js +0 -1
  350. package/dist/chunk-X6MPU7UO.js +0 -3
  351. package/dist/chunk-YPHXLAQF.js +0 -1
  352. package/dist/entry-80.js +0 -1
  353. package/node_modules/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  354. package/node_modules/pi-agent-text-editor-argument-order/index.ts +0 -26
  355. package/node_modules/pi-agent-text-editor-argument-order/package.json +0 -16
  356. package/node_modules/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  357. package/node_modules/pi-agent-text-editor-overwrite/index.ts +0 -365
  358. package/node_modules/pi-agent-text-editor-overwrite/package.json +0 -17
  359. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  360. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +0 -1
  361. package/node_modules/pi-agent-web-text/runtime/entry-80.js +0 -2
  362. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +0 -2
  363. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +0 -2
  364. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/index.ts +0 -26
  365. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/package.json +0 -16
  366. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/runtime/entry-70.js +0 -2
  367. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-argument-order/src/argument-order-guard.ts +0 -100
  368. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/index.ts +0 -365
  369. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-overwrite/package.json +0 -17
  370. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +0 -2
  371. package/src/extensions/pi-agent-text-editor/src/core/tool-description.ts +0 -14
  372. /package/dist/{chunk-3H2EU7VQ.js → chunk-4U2GUKNJ.js} +0 -0
  373. /package/node_modules/{pi-agent-text-editor-argument-order → pi-agent-text-editor}/runtime/entry-70.js +0 -0
  374. /package/node_modules/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  375. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
  376. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-74.js +0 -0
  377. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-76.js +0 -0
  378. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-77.js +0 -0
  379. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-78.js +0 -0
  380. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-79.js +0 -0
  381. /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
  382. /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
  383. /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
  384. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-overwrite → pi-agent-text-editor-renderer}/runtime/entry-71.js +0 -0
  385. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-72.js +0 -0
@@ -0,0 +1,32 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+
3
+ /** Registration metadata drives both Pi flags and the Features settings tab. */
4
+ export interface FeatureFlag {
5
+ readonly id: string;
6
+ readonly name: string;
7
+ readonly description: string;
8
+ readonly default: boolean;
9
+ readonly group?: "ui";
10
+ readonly labels?: { readonly on: string; readonly off: string };
11
+ }
12
+
13
+ /** Register a boolean feature once; expose the same definitions to settings. */
14
+ export function createFeatureFlags(
15
+ pi: Pick<ExtensionAPI, "registerFlag">,
16
+ saved: Readonly<Record<string, boolean>>,
17
+ ) {
18
+ const definitions: FeatureFlag[] = [];
19
+ return {
20
+ definitions,
21
+ register(flag: FeatureFlag): void {
22
+ if (definitions.some((item) => item.id === flag.id))
23
+ throw new Error(`Duplicate feature flag: ${flag.id}`);
24
+ definitions.push(flag);
25
+ pi.registerFlag(flag.id, {
26
+ type: "boolean",
27
+ description: flag.description,
28
+ default: saved[flag.id] ?? flag.default,
29
+ });
30
+ },
31
+ };
32
+ }
@@ -0,0 +1,55 @@
1
+ /** Human-facing module identity, separate from stable configuration IDs. */
2
+ export const moduleLabels = {
3
+ "ide.core": [
4
+ "IDE services",
5
+ "Shared services used by language, formatting and diagnostic modules.",
6
+ ],
7
+ "ide.tips": ["Getting started tips", "Show contextual guidance while setting up a project."],
8
+ "ide.doctor": ["Setup doctor", "Check external tools and help configure project support."],
9
+ "ide.languages": ["Language setup", "Discover languages and their recommended toolchains."],
10
+ "read.core": ["Read tools", "Read sources through the configured readers and views."],
11
+ "read.filesystem": ["Local files", "Resolve files and folders from the local filesystem."],
12
+ "read.filesystem.image": ["Local images", "Read local images as visual content."],
13
+ "read.filesystem.pdf": ["Local PDFs", "Extract readable content from local PDF documents."],
14
+ "read.filesystem.text": ["Local text", "Read local text files with their source coordinates."],
15
+ "read.web": ["Web sources", "Read remote sources over HTTP and HTTPS."],
16
+ "read.web.html": ["Web pages", "Extract readable content from HTML pages."],
17
+ "read.web.image": ["Web images", "Read remote images as visual content."],
18
+ "read.web.pdf": ["Web PDFs", "Extract text from remote PDF documents."],
19
+ "read.web.text": ["Web text", "Read remote plain-text sources."],
20
+ "search.core": ["Search tools", "Run searches through the configured search providers."],
21
+ "search.text": ["Text search", "Find text and files and register reusable search selections."],
22
+ "editor.core": [
23
+ "Editing tools",
24
+ "Apply guarded text and whole-file changes, including Apply scripts.",
25
+ ],
26
+ "editor.renderer": ["Edit previews", "Display changes in the shared colored diff panels."],
27
+ "editor.anchor.constant": [
28
+ "File boundary selectors",
29
+ "Use begin and end to select file boundaries.",
30
+ ],
31
+ "editor.anchor.line-hash": [
32
+ "Checked line selectors",
33
+ "Select lines with hashes that detect stale content.",
34
+ ],
35
+ "editor.anchor.exact": ["Exact text selectors", "Locate edit ranges using unique source text."],
36
+ "editor.stale-anchor": [
37
+ "Stale selection recovery",
38
+ "Provide recovery guidance when an edit selection is outdated.",
39
+ ],
40
+ "ide.ast": [
41
+ "Structural code support",
42
+ "Read code outlines and search or edit exact syntax-tree nodes.",
43
+ ],
44
+ "ide.formatter": ["Code formatting", "Run configured formatters after edits."],
45
+ "ide.lint": ["Lint checks", "Run configured linters and collect their findings."],
46
+ "ide.changes": ["Git changes", "Inspect and manage uncommitted changes and undo history."],
47
+ "ide.lsp": [
48
+ "Language servers",
49
+ "Resolve symbols, rename references and collect language-server diagnostics.",
50
+ ],
51
+ "ide.diagnostics": [
52
+ "Diagnostic views",
53
+ "Show diagnostic findings through read views and sources.",
54
+ ],
55
+ } as const;
@@ -0,0 +1,44 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
4
+ import { readExtensionSettingsScope } from "./extensions-config.js";
5
+
6
+ /** A scope override; default removes this scope's explicit choice. */
7
+ export type ModuleChoice = "default" | "enabled" | "disabled";
8
+
9
+ /** Save only changed module overrides, preserving other settings and unknown IDs. */
10
+ export async function saveModuleChoices(
11
+ configPath: string,
12
+ choices: ReadonlyMap<string, ModuleChoice>,
13
+ featureChoices: ReadonlyMap<string, boolean | undefined> = new Map(),
14
+ ): Promise<void> {
15
+ await withFileMutationQueue(configPath, async () => {
16
+ const settings = await readExtensionSettingsScope(configPath);
17
+ let original: Record<string, unknown> = {};
18
+ try {
19
+ original = JSON.parse(await readFile(configPath, "utf8")) as Record<string, unknown>;
20
+ } catch (error) {
21
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
22
+ }
23
+ const disabled = new Set(settings.disabled);
24
+ const enabled = new Set(settings.enabled);
25
+ for (const [id, choice] of choices) {
26
+ disabled.delete(id);
27
+ enabled.delete(id);
28
+ if (choice === "disabled") disabled.add(id);
29
+ if (choice === "enabled") enabled.add(id);
30
+ }
31
+ const flags = { ...settings.flags };
32
+ for (const [id, value] of featureChoices) {
33
+ if (id === "pi-agent-ide-no-animations") delete original.noAnimations;
34
+ if (id === "pi-agent-ide-no-post-processing") delete original.noPostProcessing;
35
+ if (value === undefined) delete flags[id];
36
+ else flags[id] = value;
37
+ }
38
+ await mkdir(path.dirname(configPath), { recursive: true });
39
+ await writeFile(
40
+ configPath,
41
+ `${JSON.stringify({ ...original, disabled: [...disabled], enabled: [...enabled], ...(featureChoices.size > 0 ? { flags } : {}) }, null, 2)}\n`,
42
+ );
43
+ });
44
+ }
@@ -0,0 +1,132 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { BUILTIN_EXTENSIONS } from "./builtin-extensions.js";
3
+ import {
4
+ configuredFeatureFlags,
5
+ readExtensionSettingsScope,
6
+ resolvePiAgentIdeExtensionsConfigPaths,
7
+ } from "./extensions-config.js";
8
+ import type { FeatureFlag } from "./feature-flags.js";
9
+ import { saveModuleChoices, type ModuleChoice } from "./module-settings-store.js";
10
+ import { createSettingsPanel } from "./settings-panel.js";
11
+ import { selectBuiltinExtensions } from "./selection.js";
12
+
13
+ /** Keep settings available even when every optional module is disabled. */
14
+ export function registerModuleSettings(
15
+ pi: Pick<ExtensionAPI, "registerCommand">,
16
+ flags: readonly FeatureFlag[] = [],
17
+ ): void {
18
+ pi.registerCommand("agent-ide-settings", {
19
+ description: "Configure Agent IDE modules and features",
20
+ async handler(_args, ctx) {
21
+ if (!ctx.hasUI) return;
22
+ try {
23
+ const scope = await ctx.ui.select("Agent IDE settings — save scope", ["Project", "Global"]);
24
+ if (scope === undefined) return;
25
+ const paths = resolvePiAgentIdeExtensionsConfigPaths(process.env, undefined, ctx.cwd);
26
+ const selectedPath = scope === "Project" ? paths.projectPath : paths.globalPath;
27
+ const current = await readExtensionSettingsScope(selectedPath);
28
+ const other = await readExtensionSettingsScope(
29
+ scope === "Project" ? paths.globalPath : paths.projectPath,
30
+ );
31
+ const choices = new Map<string, ModuleChoice>();
32
+ const featureChoices = new Map<string, boolean | undefined>();
33
+ const saved = await ctx.ui.custom<boolean>((tui, theme, _keys, done) => {
34
+ const panel = createSettingsPanel(
35
+ theme,
36
+ () => {
37
+ const disabled = new Set(current.disabled);
38
+ const enabled = new Set(current.enabled);
39
+ for (const [id, choice] of choices) {
40
+ disabled.delete(id);
41
+ enabled.delete(id);
42
+ if (choice === "disabled") disabled.add(id);
43
+ if (choice === "enabled") enabled.add(id);
44
+ }
45
+ const effective = selectBuiltinExtensions(
46
+ BUILTIN_EXTENSIONS,
47
+ [...disabled, ...other.disabled],
48
+ [...enabled, ...other.enabled],
49
+ );
50
+ return {
51
+ modules: BUILTIN_EXTENSIONS.map((module) => ({
52
+ id: module.id,
53
+ label: module.name ?? module.id,
54
+ description: `${module.description ?? ""} Effective: ${effective.disabled.has(module.id) ? "off" : "on"}.${other.disabled.includes(module.id) ? " Disabled in the other scope." : module.dependencies.some((id) => effective.disabled.has(id)) ? " A dependency is disabled." : ""}`,
55
+ currentValue:
56
+ choices.get(module.id) ??
57
+ (current.disabled.includes(module.id)
58
+ ? "disabled"
59
+ : current.enabled.includes(module.id)
60
+ ? "enabled"
61
+ : "default"),
62
+ values: ["default", "enabled", "disabled"],
63
+ })),
64
+ features: flagItems("features"),
65
+ ui: flagItems("ui"),
66
+ };
67
+ function flagItems(group: "features" | "ui") {
68
+ return flags
69
+ .filter((flag) => (flag.group ?? "features") === group)
70
+ .map((flag) => {
71
+ const value = featureChoices.has(flag.id)
72
+ ? featureChoices.get(flag.id)
73
+ : configuredFeatureFlags(current)[flag.id];
74
+ return {
75
+ id: flag.id,
76
+ label: flag.name,
77
+ description: flag.description,
78
+ currentValue:
79
+ value === undefined
80
+ ? "default"
81
+ : value
82
+ ? (flag.labels?.on ?? "enabled")
83
+ : (flag.labels?.off ?? "disabled"),
84
+ values: [
85
+ "default",
86
+ flag.labels?.off ?? "disabled",
87
+ flag.labels?.on ?? "enabled",
88
+ ],
89
+ };
90
+ });
91
+ }
92
+ },
93
+ (tab, id, value) => {
94
+ if (tab === "modules") choices.set(id, value as ModuleChoice);
95
+ else
96
+ featureChoices.set(
97
+ id,
98
+ value === "default"
99
+ ? undefined
100
+ : value === (flags.find((flag) => flag.id === id)?.labels?.on ?? "enabled"),
101
+ );
102
+ },
103
+ done,
104
+ scope,
105
+ );
106
+ return {
107
+ render: (width) => panel.render(width),
108
+ invalidate: () => panel.invalidate(),
109
+ handleInput(data) {
110
+ panel.handleInput(data);
111
+ tui.requestRender();
112
+ },
113
+ };
114
+ });
115
+ if (!saved || choices.size + featureChoices.size === 0) return;
116
+ await saveModuleChoices(selectedPath, choices, featureChoices);
117
+ ctx.ui.notify(`Saved ${scope.toLowerCase()} Agent IDE settings. Reload required.`, "info");
118
+ if (
119
+ await ctx.ui.confirm(
120
+ "Reload Pi?",
121
+ "Reload extensions to apply settings. In-memory extension state may reset.",
122
+ )
123
+ ) {
124
+ await ctx.reload();
125
+ return;
126
+ }
127
+ } catch (error) {
128
+ ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
129
+ }
130
+ },
131
+ });
132
+ }
@@ -5,6 +5,8 @@ One independently usable built-in extension composed into Pi Agent IDE.
5
5
  */
6
6
  export interface BuiltinExtension {
7
7
  readonly id: string;
8
+ readonly name?: string;
9
+ readonly description?: string;
8
10
  readonly dependencies: readonly string[];
9
11
  readonly register: (pi: ExtensionAPI) => void | Promise<void>;
10
12
  /**
@@ -44,11 +46,9 @@ export function selectBuiltinExtensions(
44
46
  const explicitDisabled = new Set<string>();
45
47
 
46
48
  for (const id of configuredDisabled) {
47
- if (!byId.has(id)) {
48
- throw new Error(`Unknown Pi Agent IDE extension ID in disabled: ${id}`);
49
+ if (byId.has(id)) {
50
+ explicitDisabled.add(id);
49
51
  }
50
-
51
- explicitDisabled.add(id);
52
52
  }
53
53
 
54
54
  for (const id of configuredEnabled) {
@@ -0,0 +1,71 @@
1
+ import { getSettingsListTheme, type Theme } from "@earendil-works/pi-coding-agent";
2
+ import { matchesKey, SettingsList, Text, type SettingItem } from "@earendil-works/pi-tui";
3
+
4
+ /** Two settings tabs share staged choices; saving and canceling are explicit. */
5
+ export function createSettingsPanel(
6
+ theme: Theme,
7
+ items: () => { modules: SettingItem[]; features: SettingItem[]; ui?: SettingItem[] },
8
+ change: (tab: "modules" | "features" | "ui", id: string, value: string) => void,
9
+ done: (save: boolean) => void,
10
+ scope = "",
11
+ ) {
12
+ const tabs = ["modules", "features", "ui"] as const;
13
+ let tab: (typeof tabs)[number] = "modules";
14
+ const createList = () => {
15
+ const entries = items()[tab] ?? [];
16
+ return new SettingsList(
17
+ entries,
18
+ 12,
19
+ getSettingsListTheme(),
20
+ (id, value) => {
21
+ change(tab, id, value);
22
+ for (const next of items()[tab] ?? []) {
23
+ const entry = entries.find((item) => item.id === next.id);
24
+ if (entry) Object.assign(entry, next);
25
+ }
26
+ },
27
+ () => done(false),
28
+ { enableSearch: true },
29
+ );
30
+ };
31
+ let list = createList();
32
+ return {
33
+ render(width: number): string[] {
34
+ return [
35
+ ...new Text(
36
+ theme.fg("accent", theme.bold(`Agent IDE settings${scope ? ` · ${scope}` : ""}`)),
37
+ 1,
38
+ 0,
39
+ ).render(width),
40
+ ...new Text(
41
+ tabs
42
+ .map((id) => {
43
+ const label = id === "ui" ? "UI" : id === "modules" ? "Modules" : "Features";
44
+ return id === tab ? `[${label}]` : label;
45
+ })
46
+ .join(" "),
47
+ 1,
48
+ 0,
49
+ ).render(width),
50
+ ...list.render(width),
51
+ ...new Text(
52
+ theme.fg("dim", "Tab: switch tab · Enter: change · Ctrl+S: save · Esc: cancel"),
53
+ 1,
54
+ 0,
55
+ ).render(width),
56
+ ];
57
+ },
58
+ invalidate(): void {
59
+ list.invalidate();
60
+ },
61
+ handleInput(data: string): void {
62
+ if (matchesKey(data, "tab") || matchesKey(data, "shift+tab")) {
63
+ tab =
64
+ tabs[(tabs.indexOf(tab) + (matchesKey(data, "shift+tab") ? 2 : 1)) % tabs.length] ??
65
+ "modules";
66
+ list = createList();
67
+ } else if (matchesKey(data, "ctrl+s")) done(true);
68
+ else list.handleInput(data);
69
+ },
70
+ };
71
+ }
@@ -0,0 +1,29 @@
1
+ /** Buffer ready notifications at a fixed first-arrival deadline and serialize flushes. */
2
+ export function createDiagnosticDelivery(
3
+ flush: (cwd: string) => Promise<void>,
4
+ delayMs: number,
5
+ onError: (error: unknown) => void = console.error,
6
+ ): { schedule(cwd: string): void; dispose(): void } {
7
+ const timers = new Map<string, ReturnType<typeof setTimeout>>();
8
+ let closed = false;
9
+ let pending = Promise.resolve();
10
+ return {
11
+ schedule(cwd) {
12
+ if (closed || timers.has(cwd)) return;
13
+ const timer = setTimeout(() => {
14
+ timers.delete(cwd);
15
+ pending = pending
16
+ .then(async () => {
17
+ if (!closed) await flush(cwd);
18
+ })
19
+ .catch(onError);
20
+ }, delayMs);
21
+ timers.set(cwd, timer);
22
+ },
23
+ dispose() {
24
+ closed = true;
25
+ for (const timer of timers.values()) clearTimeout(timer);
26
+ timers.clear();
27
+ },
28
+ };
29
+ }
@@ -68,11 +68,59 @@ export function renderDiagnosticEntry(
68
68
 
69
69
  /** Register durable UI-only entries; appending one never adds model context or starts a turn. */
70
70
  export function registerDiagnosticEntryRenderer(pi: ExtensionAPI): void {
71
- pi.registerEntryRenderer<DiagnosticEntryData>(DIAGNOSTIC_ENTRY_TYPE, (entry, options, theme) =>
72
- renderDiagnosticEntry(requiredValue(entry.data), theme, options.expanded),
73
- );
71
+ pi.registerEntryRenderer<
72
+ DiagnosticEntryData | { readonly files: readonly DiagnosticEntryData[] }
73
+ >(DIAGNOSTIC_ENTRY_TYPE, (entry, options, theme) => {
74
+ const data = requiredValue(entry.data);
75
+ return "files" in data
76
+ ? renderDiagnosticBatch(data.files, theme, options.expanded)
77
+ : renderDiagnosticEntry(data, theme, options.expanded);
78
+ });
74
79
  }
75
80
 
81
+ /** One stable summary per delivery; expansion retains each file and provider. */
82
+ export function renderDiagnosticBatch(
83
+ files: readonly DiagnosticEntryData[],
84
+ theme: Theme,
85
+ expanded = false,
86
+ ): Component {
87
+ return {
88
+ render(width) {
89
+ const visible = files.filter((file) =>
90
+ file.sources.some(
91
+ (source) =>
92
+ source.status !== "pending" &&
93
+ source.status !== "unavailable" &&
94
+ Object.values(source.counts).some((count) => count > 0),
95
+ ),
96
+ );
97
+ if (visible.length === 1 && visible[0])
98
+ return renderDiagnosticEntry(visible[0], theme, expanded).render(width);
99
+ if (visible.length === 0) return [];
100
+ const counts = { error: 0, warning: 0, info: 0, hint: 0 };
101
+ const providers = new Set<string>();
102
+ for (const file of visible)
103
+ for (const source of file.sources) {
104
+ if (source.status === "pending" || source.status === "unavailable") continue;
105
+ providers.add(source.source);
106
+ for (const severity of ["error", "warning", "info", "hint"] as const)
107
+ counts[severity] += source.counts[severity];
108
+ }
109
+ const head = new Text(
110
+ `${theme.fg("accent", "Diagnostics")} · ${visible.length} files · ${renderCounts(counts, theme)} · ${providers.size} tools`,
111
+ 0,
112
+ 0,
113
+ ).render(width);
114
+ return expanded
115
+ ? [
116
+ ...head,
117
+ ...visible.flatMap((file) => renderDiagnosticEntry(file, theme, true).render(width)),
118
+ ]
119
+ : head;
120
+ },
121
+ invalidate() {},
122
+ };
123
+ }
76
124
  function renderCounts(
77
125
  counts: DiagnosticEntryData["sources"][number]["counts"],
78
126
  theme: Theme,
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
 
4
4
  import type {
5
5
  IdeDiagnosticReport,
6
+ IdeDiagnosticReadContext,
6
7
  IdeDiagnosticResult,
7
8
  IdeDiagnosticSnapshot,
8
9
  IdeDiagnosticSource,
@@ -34,10 +35,10 @@ export class DiagnosticStore {
34
35
  private readonly queue: (() => Promise<void>)[] = [];
35
36
  private running = 0;
36
37
  private disposed = false;
37
- private readonly changeListeners = new Set<(cwd: string) => void>();
38
+ private readonly changeListeners = new Set<(cwd: string, findings: boolean) => void>();
38
39
 
39
40
  /** Observe published reports immediately, independently of agent turns. */
40
- onDidChange(listener: (cwd: string) => void): () => void {
41
+ onDidChange(listener: (cwd: string, findings: boolean) => void): () => void {
41
42
  this.changeListeners.add(listener);
42
43
  return () => this.changeListeners.delete(listener);
43
44
  }
@@ -57,20 +58,65 @@ export class DiagnosticStore {
57
58
  }
58
59
 
59
60
  /** Read one current text snapshot; never label unfinished checks as clean. */
60
- async read(filePath: string, { cwd }: ToolContext): Promise<IdeDiagnosticSnapshot> {
61
+ async read(
62
+ filePath: string,
63
+ { cwd, mode, signal }: IdeDiagnosticReadContext,
64
+ ): Promise<IdeDiagnosticSnapshot> {
65
+ signal?.throwIfAborted();
61
66
  this.assertActive();
62
67
  const absolute = path.resolve(cwd, filePath);
63
68
  const content = await readFile(absolute, "utf8");
64
69
  this.assertActive();
65
70
  const state = this.ensure(absolute, content, cwd);
66
- await waitAtMost(Promise.all(state.jobs), this.options.readWaitMs ?? 5000);
71
+ if (mode === "complete") await this.waitComplete(state, signal);
72
+ else if (mode !== "snapshot")
73
+ await waitAtMost(Promise.all(state.jobs), this.options.readWaitMs ?? 5000);
74
+ signal?.throwIfAborted();
67
75
  this.assertActive();
68
76
  const currentText = await readFile(absolute, "utf8");
69
77
  this.assertActive();
70
78
  const current = this.ensure(absolute, currentText, cwd);
79
+ if (mode === "complete" && current !== state)
80
+ throw Object.assign(new Error("File changed during diagnostics"), {
81
+ code: "DIAGNOSTICS_STALE",
82
+ });
71
83
  return { filePath: absolute, content: current.content, results: [...current.results.values()] };
72
84
  }
73
85
 
86
+ private async waitComplete(state: FileState, signal?: AbortSignal): Promise<void> {
87
+ const combined = signal
88
+ ? AbortSignal.any([signal, state.controller.signal])
89
+ : state.controller.signal;
90
+ combined.throwIfAborted();
91
+ const cleanupWaiters: (() => void)[] = [];
92
+ await new Promise<void>((resolve, reject) => {
93
+ const fail = (code: string) =>
94
+ reject(Object.assign(new Error(code), { code, details: [...state.results.values()] }));
95
+ const check = () => {
96
+ const results = [...state.results.values()];
97
+ if (results.some((result) => result.status === "unavailable"))
98
+ fail("DIAGNOSTICS_UNAVAILABLE");
99
+ else if (results.every((result) => result.status === "ready")) resolve();
100
+ };
101
+ const abort = () => reject(combined.reason);
102
+ const detach = this.onDidChange(check);
103
+ const timer = setTimeout(
104
+ () => fail("DIAGNOSTICS_TIMEOUT"),
105
+ this.options.checkTimeoutMs ?? 30_000,
106
+ );
107
+ combined.addEventListener("abort", abort, { once: true });
108
+ const cleanup = () => {
109
+ clearTimeout(timer);
110
+ detach();
111
+ combined.removeEventListener("abort", abort);
112
+ };
113
+ // Cleanup follows either outcome without changing the original rejection.
114
+ void Promise.resolve().then(check);
115
+ cleanupWaiters.push(cleanup);
116
+ }).finally(() => {
117
+ for (const cleanup of cleanupWaiters) cleanup();
118
+ });
119
+ }
74
120
  /** Drain current findings for delivery; pending, unavailable and empty reports stay silent. */
75
121
  async takeNotifications(cwd: string): Promise<DiagnosticNotification[]> {
76
122
  const notifications: DiagnosticNotification[] = [];
@@ -206,7 +252,12 @@ export class DiagnosticStore {
206
252
  if (JSON.stringify(state.results.get(source)) === JSON.stringify(result)) return;
207
253
  state.results.set(source, result);
208
254
  this.dirty.add(state);
209
- for (const listener of this.changeListeners) listener(state.cwd);
255
+ const findings = [...state.results.values()].some(
256
+ (item) =>
257
+ item.status !== "pending" && item.status !== "unavailable" && item.diagnostics.length > 0,
258
+ );
259
+ if (!findings) this.sent.delete(this.key(state.filePath, state.cwd));
260
+ for (const listener of this.changeListeners) listener(state.cwd, findings);
210
261
  }
211
262
 
212
263
  private async check(state: FileState, source: IdeDiagnosticSource): Promise<void> {
@@ -6,6 +6,7 @@ import {
6
6
  isIdePluginRegistrationRequest,
7
7
  } from "#src/api/plugin-protocol.js";
8
8
  import { createIdeCore } from "#src/core/ide-core.js";
9
+ import { createDiagnosticDelivery } from "#src/core/diagnostic-delivery.js";
9
10
  import {
10
11
  diagnosticEntryData,
11
12
  DIAGNOSTIC_ENTRY_TYPE,
@@ -13,7 +14,10 @@ import {
13
14
  } from "#src/core/diagnostic-entry.js";
14
15
  import { runIdePostEditGate } from "#src/post-edit/gate.js";
15
16
  import { resetRegistry } from "#src/toolchain/registry.js";
16
- import { connectTextEditorPostEditHandler } from "pi-agent-text-editor/api/post-edit";
17
+ import {
18
+ connectTextEditorPostEditHandler,
19
+ afterPostEditScope,
20
+ } from "pi-agent-text-editor/api/post-edit";
17
21
 
18
22
  import path from "node:path";
19
23
  import { connectTextEditorPlugin } from "pi-agent-text-editor/api/connect-plugin";
@@ -25,11 +29,6 @@ import {
25
29
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
26
30
 
27
31
  export default async function registerPiAgentIde(pi: ExtensionAPI): Promise<void> {
28
- pi.registerFlag("old-tools", {
29
- description: "Use the old IDE and text editor tools",
30
- type: "boolean",
31
- default: false,
32
- });
33
32
  resetRegistry();
34
33
  const core = createIdeCore();
35
34
  registerDiagnosticEntryRenderer(pi);
@@ -63,42 +62,44 @@ export default async function registerPiAgentIde(pi: ExtensionAPI): Promise<void
63
62
  id: "ide-diagnostics",
64
63
  setup(api) {
65
64
  api.onDidEdit((completion) => {
66
- if (pi.getFlag("pi-agent-ide-no-post-processing") === true) return;
65
+ if (
66
+ pi.getFlag("pi-agent-ide-no-post-processing") === true ||
67
+ completion.postProcessing === "deferred"
68
+ )
69
+ return;
67
70
  if (path.isAbsolute(completion.resourceSource)) {
68
- core.diagnostics.schedule(completion.resourceSource, completion.after.content, {
69
- cwd: completion.cwd,
70
- });
71
+ afterPostEditScope(() =>
72
+ core.diagnostics.schedule(completion.resourceSource, completion.after.content, {
73
+ cwd: completion.cwd,
74
+ }),
75
+ );
71
76
  }
72
77
  });
73
78
  },
74
79
  });
75
- let delivery = Promise.resolve();
76
80
  let closed = false;
77
- const isClosed = () => closed;
78
- const unsubscribeDiagnostics = core.diagnostics.onDidChange((cwd) => {
79
- delivery = delivery
80
- .then(async () => {
81
- if (closed) return;
82
- const notifications = await core.diagnostics.takeNotifications(cwd);
83
- if (isClosed() || notifications.length === 0) return;
84
- pi.sendMessage(
85
- {
86
- customType: "ide-diagnostics",
87
- display: false,
88
- content: `File diagnostics:\n${notifications.map((item) => item.text).join("\n")}`,
89
- },
90
- { triggerTurn: true, deliverAs: "steer" },
91
- );
92
- for (const notification of notifications) {
93
- pi.appendEntry(DIAGNOSTIC_ENTRY_TYPE, diagnosticEntryData(notification));
94
- }
95
- })
96
- .catch((error: unknown) => {
97
- console.error("Diagnostic delivery failed", error);
98
- });
81
+ const delivery = createDiagnosticDelivery(
82
+ async (cwd) => {
83
+ const notifications = await core.diagnostics.takeNotifications(cwd);
84
+ if (closed || notifications.length === 0) return;
85
+ pi.sendMessage(
86
+ {
87
+ customType: "ide-diagnostics",
88
+ display: false,
89
+ content: `File diagnostics:\n${notifications.map((item) => item.text).join("\n")}`,
90
+ },
91
+ { triggerTurn: true, deliverAs: "steer" },
92
+ );
93
+ pi.appendEntry(DIAGNOSTIC_ENTRY_TYPE, { files: notifications.map(diagnosticEntryData) });
94
+ },
95
+ pi.getFlag("pi-agent-ide-no-diagnostic-buffer") === true ? 0 : 5000,
96
+ );
97
+ const unsubscribeDiagnostics = core.diagnostics.onDidChange((cwd, findings) => {
98
+ if (findings) delivery.schedule(cwd);
99
99
  });
100
100
  pi.on("session_shutdown", () => {
101
101
  closed = true;
102
+ delivery.dispose();
102
103
  unsubscribeDiagnostics();
103
104
  });
104
105