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
@@ -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.3.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.3.0",
17
+ "pi-agent-invariant": "0.3.0",
18
+ "pi-agent-read": "0.3.0",
19
+ "pi-agent-text": "0.3.0",
20
+ "pi-agent-text-editor": "0.3.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" ||
@@ -14,7 +14,8 @@ import type { ChangeIndexAction } from "#src/changes/change-types.js";
14
14
  import type { GitCommandExecutor } from "#src/changes/git-changes-backend.js";
15
15
  import type { IndexMutationQueue } from "#src/index-mutation-queue.js";
16
16
 
17
- const indexChangeSchema = Type.Object(
17
+ /** Shared validation for standalone and composed index changes. */
18
+ export const indexChangeSchema = Type.Object(
18
19
  {
19
20
  file: Type.String({ description: "Path to the tracked text file" }),
20
21
  change: Type.String({
@@ -42,7 +43,8 @@ export function registerIndexChangeTools(
42
43
  pi.registerTool(createIndexChangeTool("unstage", executor, queue));
43
44
  }
44
45
 
45
- function createIndexChangeTool(
46
+ /** Build one guarded index change shared by standalone tools and Apply. */
47
+ export function createIndexChangeTool(
46
48
  action: ChangeIndexAction,
47
49
  executor: GitCommandExecutor,
48
50
  queue: IndexMutationQueue,
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { hasDeferredPostEdit } from "pi-agent-text-editor/api/post-edit";
2
3
 
3
4
  import {
4
5
  addDiagnosticAnnotations,
@@ -14,6 +15,7 @@ import {
14
15
  IDE_PROTOCOL,
15
16
  type IdePlugin,
16
17
  type IdePluginApi,
18
+ type IdeDiagnosticReadContext,
17
19
  } from "pi-agent-ide/api/plugin-protocol";
18
20
  import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
19
21
  import {
@@ -26,7 +28,7 @@ import { createReadResultRenderer } from "pi-agent-read/api/rendering";
26
28
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
27
29
  import type { ResourceResolutionAttempt, ResourceResolver } from "pi-agent-resource";
28
30
  import type { TextDocument, TextLinePresenter } from "pi-agent-text";
29
- import type { ReadRequest } from "pi-agent-read/api/tools/read";
31
+ import type { ReadRequest, ReadResultDetails } from "pi-agent-read/api/tools/read";
30
32
 
31
33
  const DIAGNOSTIC_SCHEME = "diagnostics";
32
34
  const renderReadResult = createReadResultRenderer({ kind: "code-view", label: "Diagnostics" });
@@ -35,12 +37,12 @@ type ReadDiagnostics = IdePluginApi["readDiagnostics"];
35
37
 
36
38
  export default async function registerDiagnostics(pi: ExtensionAPI): Promise<void> {
37
39
  let readDiagnostics: ReadDiagnostics | undefined;
38
- const collect = (filePath: string, cwd: string) => {
40
+ const collect: CollectDiagnostics = (filePath, cwd, options) => {
39
41
  if (readDiagnostics === undefined) {
40
42
  throw new Error("IDE diagnostics are not connected");
41
43
  }
42
44
 
43
- return readDiagnostics(filePath, { cwd });
45
+ return readDiagnostics(filePath, { cwd, ...options });
44
46
  };
45
47
  const idePlugin = {
46
48
  protocol: IDE_PROTOCOL,
@@ -51,6 +53,8 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
51
53
  },
52
54
  } satisfies IdePlugin;
53
55
  // Keep readiness outside source-line projection, including empty and ranged reads.
56
+ const checks = new WeakMap<ReadRequest, NonNullable<ReadResultDetails["diagnosticCheck"]>>();
57
+ const contents = new WeakMap<object, NonNullable<ReadResultDetails["diagnosticCheck"]>>();
54
58
  const documents = new WeakMap<ReadRequest, TextDocument>();
55
59
  const statuses = new WeakMap<TextDocument, string>();
56
60
  const readPlugin = {
@@ -59,7 +63,7 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
59
63
  id: "diagnostics",
60
64
  setup(api) {
61
65
  api.addResolver({
62
- resolver: createDiagnosticResolver(collect),
66
+ resolver: createDiagnosticResolver(collect, contents),
63
67
  renderResult: renderReadResult,
64
68
  });
65
69
  const mapSource = createSourceMappedTextReadHandler();
@@ -72,7 +76,12 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
72
76
  stage: "read",
73
77
  when: { resolvedBy: "any", contentKind: "text" },
74
78
  handler(context) {
75
- if (context.state?.resolvedBy === "diagnostics") return mapSource(context);
79
+ if (context.state?.resolvedBy === "diagnostics") {
80
+ const content = context.state.content[0];
81
+ const check = contents.get(content);
82
+ if (check) checks.set(context.request, check);
83
+ return mapSource(context);
84
+ }
76
85
  if (
77
86
  context.state?.contentKind === "text" &&
78
87
  context.request.views?.includes("diagnostics")
@@ -85,6 +94,19 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
85
94
  api.addHandler({
86
95
  stage: "post-read",
87
96
  handler(context) {
97
+ const check = checks.get(context.request);
98
+ if (check && context.result) {
99
+ return {
100
+ kind: "continue",
101
+ context: {
102
+ ...context,
103
+ result: {
104
+ ...context.result,
105
+ details: { ...context.result.details, diagnosticCheck: check },
106
+ },
107
+ },
108
+ };
109
+ }
88
110
  const document = documents.get(context.request);
89
111
  const status = document && statuses.get(document);
90
112
  const result = context.result;
@@ -106,7 +128,7 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
106
128
  },
107
129
  });
108
130
  api.describe(
109
- 'diagnostics:<path> — lint and language-server diagnostics. views: ["diagnostics"] — diagnostics alongside source text. Diagnostic sources name the actual reporting tools. Automatic notices include findings only and wake an idle agent as soon as results arrive; silence does not prove the file is clean. Use an explicit diagnostic read to check readiness. Pending results and snapshots are not completed checks; an empty snapshot does not prove the file is clean.',
131
+ 'diagnostics:<path> — lint and language-server diagnostics. views: ["diagnostics"] — diagnostics alongside source text. Diagnostic sources name the actual reporting tools. Automatic notices include findings only and wake an idle agent after the notification buffer (five seconds by default); silence does not prove the file is clean. Use an explicit diagnostic read to check readiness. Pending results and snapshots are not completed checks; an empty snapshot does not prove the file is clean.',
110
132
  );
111
133
  api.addPromptGuideline(
112
134
  "Use read with `diagnostics:<path>` or the `diagnostics` view for per-file diagnostics instead of running equivalent checks through Bash. Project builds and tests remain separate verification.",
@@ -117,11 +139,19 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
117
139
  await Promise.all([connectIdePlugin(pi, idePlugin), connectReadPlugin(pi, readPlugin)]);
118
140
  }
119
141
 
120
- function createDiagnosticResolver(collect: CollectDiagnostics): ResourceResolver {
142
+ function createDiagnosticResolver(
143
+ collect: CollectDiagnostics,
144
+ contents: WeakMap<object, NonNullable<ReadResultDetails["diagnosticCheck"]>>,
145
+ ): ResourceResolver {
121
146
  return {
122
147
  id: "diagnostics",
123
148
  tryResolve(source, context) {
124
- return Promise.resolve(resolveDiagnosticSource(source, context.cwd, collect));
149
+ return Promise.resolve(
150
+ resolveDiagnosticSource(source, context.cwd, collect, contents, {
151
+ signal: context.signal,
152
+ ...(context.audience === "script" && { mode: "complete" }),
153
+ }),
154
+ );
125
155
  },
126
156
  };
127
157
  }
@@ -129,12 +159,15 @@ function createDiagnosticResolver(collect: CollectDiagnostics): ResourceResolver
129
159
  type CollectDiagnostics = (
130
160
  filePath: string,
131
161
  cwd: string,
162
+ options?: Omit<IdeDiagnosticReadContext, "cwd">,
132
163
  ) => ReturnType<IdePluginApi["readDiagnostics"]>;
133
164
 
134
165
  function resolveDiagnosticSource(
135
166
  source: string,
136
167
  cwd: string,
137
168
  collect: CollectDiagnostics,
169
+ contents: WeakMap<object, NonNullable<ReadResultDetails["diagnosticCheck"]>>,
170
+ options?: Omit<IdeDiagnosticReadContext, "cwd">,
138
171
  ): ResourceResolutionAttempt {
139
172
  let filePath: string | undefined;
140
173
 
@@ -153,8 +186,10 @@ function resolveDiagnosticSource(
153
186
  resource: {
154
187
  source: formatDiagnosticViewSource(DIAGNOSTIC_SCHEME, filePath),
155
188
  async read() {
156
- const snapshot = await collect(filePath, cwd);
157
- return [createDiagnosticViewContent(filePath, snapshot.content, snapshot.results)];
189
+ const snapshot = await collect(filePath, cwd, options);
190
+ const content = createDiagnosticViewContent(filePath, snapshot.content, snapshot.results);
191
+ contents.set(content, content.diagnosticCheck);
192
+ return [content];
158
193
  },
159
194
  },
160
195
  };
@@ -171,7 +206,23 @@ function createDiagnosticPresenter(
171
206
  return document;
172
207
  }
173
208
 
174
- const snapshot = await collect(document.source, context.cwd);
209
+ const eager =
210
+ context.audience === "script" && !context.requestedViews?.includes("diagnostics");
211
+ if (eager && hasDeferredPostEdit(document.source)) return document;
212
+ const snapshot = await collect(document.source, context.cwd, {
213
+ signal: context.signal,
214
+ ...(context.audience === "script" && {
215
+ mode: eager ? "snapshot" : "complete",
216
+ }),
217
+ }).catch((error: unknown) => {
218
+ context.signal?.throwIfAborted();
219
+ if (eager) return undefined;
220
+ throw error;
221
+ });
222
+ // Listings and converted documents are not the file's diagnostic source text.
223
+ // Optional enrichment must not reject an otherwise successful read.
224
+ if (snapshot === undefined || (eager && snapshot.content !== document.content))
225
+ return document;
175
226
  if (snapshot.content !== document.content) {
176
227
  throw new Error(
177
228
  "File changed during diagnostic read; read it again for current source lines.",
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-formatter",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.2.2"
6
+ "pi-agent-doctor": "0.3.0"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -12,6 +12,6 @@
12
12
  },
13
13
  "peerDependencies": {
14
14
  "@earendil-works/pi-coding-agent": "*",
15
- "pi-agent-ide": "0.2.2"
15
+ "pi-agent-ide": "0.3.0"
16
16
  }
17
17
  }
@@ -1,5 +1,11 @@
1
- import { configuredExecutableName, runConfiguredFormatter } from "pi-agent-ide/api/tool-config";
1
+ import {
2
+ configuredExecutableName,
3
+ resolveExternalToolProjectRoot,
4
+ runConfiguredFormatter,
5
+ } from "pi-agent-ide/api/tool-config";
6
+ import path from "node:path";
2
7
 
8
+ import { FORMATTER_RECIPES } from "./catalog.js";
3
9
  import { FormatterCommandRegistry } from "./registry.js";
4
10
 
5
11
  import type { Formatter } from "pi-agent-ide/api/toolchain";
@@ -20,8 +26,16 @@ export function createFormatter(): Formatter {
20
26
  return true;
21
27
  },
22
28
  async format({ filePath }, context) {
23
- const registry = await loadRegistry(context.cwd);
24
- const formatter = registry.resolve(filePath, context.cwd);
29
+ const projectRoot = await resolveExternalToolProjectRoot(
30
+ context.cwd,
31
+ filePath,
32
+ "formatters",
33
+ FORMATTER_RECIPES,
34
+ );
35
+ if (projectRoot === undefined) return { ok: true, edits: 0, formatter: null };
36
+ const external = projectRoot !== path.resolve(context.cwd);
37
+ const registry = await loadRegistry(projectRoot, external);
38
+ const formatter = registry.resolve(filePath, projectRoot);
25
39
 
26
40
  if (formatter === undefined) {
27
41
  return { ok: true, edits: 0, formatter: null };
@@ -30,7 +44,7 @@ export function createFormatter(): Formatter {
30
44
  const name = configuredExecutableName(formatter.run.command);
31
45
  try {
32
46
  const result = await runConfiguredFormatter(formatter, {
33
- projectRoot: context.cwd,
47
+ projectRoot,
34
48
  filePath,
35
49
  });
36
50
  return { ok: result.ok, edits: result.changed ? 1 : 0, formatter: name };
@@ -41,12 +55,16 @@ export function createFormatter(): Formatter {
41
55
  };
42
56
  }
43
57
 
44
- async function loadRegistry(cwd: string): Promise<FormatterCommandRegistry> {
45
- let registry = registries.get(cwd);
58
+ async function loadRegistry(cwd: string, external = false): Promise<FormatterCommandRegistry> {
59
+ const key = JSON.stringify([cwd, external]);
60
+ let registry = registries.get(key);
46
61
 
47
62
  if (registry === undefined) {
48
- registry = FormatterCommandRegistry.fromDirectory(cwd);
49
- registries.set(cwd, registry);
63
+ registry = FormatterCommandRegistry.fromDirectory(cwd, {
64
+ includeGlobal: !external,
65
+ requireBuiltInEvidence: external,
66
+ });
67
+ registries.set(key, registry);
50
68
  }
51
69
 
52
70
  return registry;
@@ -56,7 +56,15 @@ export class FormatterCommandRegistry {
56
56
  );
57
57
  return new FormatterCommandRegistry(
58
58
  entries,
59
- new Set(available.filter((entry) => entry.available).map((entry) => entry.id)),
59
+ new Set(
60
+ available
61
+ .filter(
62
+ (entry) =>
63
+ entry.available &&
64
+ (!options.requireBuiltInEvidence || (evidence.get(entry.id)?.score ?? 0) > 0),
65
+ )
66
+ .map((entry) => entry.id),
67
+ ),
60
68
 
61
69
  evidence,
62
70
  );
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-languages",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.2.2"
6
+ "pi-agent-doctor": "0.3.0"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -1,23 +1,40 @@
1
- import { configuredExecutableName } from "pi-agent-ide/api/tool-config";
1
+ import {
2
+ configuredExecutableName,
3
+ resolveExternalToolProjectRoot,
4
+ } from "pi-agent-ide/api/tool-config";
2
5
  import { connectDoctorPlugin } from "pi-agent-doctor/api/connect-plugin";
3
6
  import { connectIdePlugin } from "pi-agent-ide/api/connect-plugin";
4
7
  import { IDE_API_VERSION, IDE_PROTOCOL, type IdePlugin } from "pi-agent-ide/api/plugin-protocol";
5
8
  import type { IdeTool } from "pi-agent-ide/api/toolchain";
9
+ import path from "node:path";
10
+ import { LINTER_RECIPES } from "./src/catalog.js";
6
11
  import { createCommandLinter, runConfiguredLinter } from "./src/command-linter.js";
7
12
  import { lintDoctorPlugin } from "./src/doctor-plugin.js";
8
13
  import { LintCommandRegistry } from "./src/registry.js";
9
14
 
10
15
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
16
+
11
17
  export default async function registerLint(pi: ExtensionAPI): Promise<void> {
12
- let registryCwd: string | undefined;
13
- let registryReady: Promise<LintCommandRegistry> | undefined;
14
- const registryFor = (cwd: string): Promise<LintCommandRegistry> => {
15
- if (registryReady === undefined || registryCwd !== cwd) {
16
- registryCwd = cwd;
17
- registryReady = loadRegistry(cwd);
18
+ const registries = new Map<string, Promise<LintCommandRegistry>>();
19
+ const registryFor = (cwd: string, external = false): Promise<LintCommandRegistry> => {
20
+ const key = JSON.stringify([cwd, external]);
21
+ let registry = registries.get(key);
22
+ if (registry === undefined) {
23
+ registry = loadRegistry(cwd, external);
24
+ registries.set(key, registry);
18
25
  }
19
-
20
- return registryReady;
26
+ return registry;
27
+ };
28
+ const resolveProject = async (filePath: string, cwd: string) => {
29
+ const projectRoot = await resolveExternalToolProjectRoot(
30
+ cwd,
31
+ filePath,
32
+ "linters",
33
+ LINTER_RECIPES,
34
+ );
35
+ return projectRoot === undefined
36
+ ? undefined
37
+ : { projectRoot, external: projectRoot !== path.resolve(cwd) };
21
38
  };
22
39
 
23
40
  const linter = {
@@ -30,8 +47,10 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
30
47
  return true;
31
48
  },
32
49
  async lint(input, context) {
33
- const readyRegistry = await registryFor(context.cwd);
34
- return createCommandLinter(readyRegistry).lint(input, context);
50
+ const project = await resolveProject(input.filePath, context.cwd);
51
+ if (project === undefined) return { ok: true, diagnostics: [] };
52
+ const readyRegistry = await registryFor(project.projectRoot, project.external);
53
+ return createCommandLinter(readyRegistry).lint(input, { cwd: project.projectRoot });
35
54
  },
36
55
  } satisfies IdeTool;
37
56
  const idePlugin = {
@@ -44,9 +63,16 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
44
63
  api.addDiagnosticSource({
45
64
  id: "lint",
46
65
  async diagnose(filePath, context) {
47
- const registry = await registryFor(context.cwd);
66
+ const project = await resolveProject(filePath, context.cwd);
67
+ if (project === undefined)
68
+ return {
69
+ status: "unavailable",
70
+ diagnostics: [],
71
+ reason: "No local linter project found for this file",
72
+ };
73
+ const registry = await registryFor(project.projectRoot, project.external);
48
74
  context.signal.throwIfAborted();
49
- const config = registry.resolve(filePath, context.cwd);
75
+ const config = registry.resolve(filePath, project.projectRoot);
50
76
  if (!config)
51
77
  return {
52
78
  status: "unavailable",
@@ -55,7 +81,7 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
55
81
  };
56
82
  const source = configuredExecutableName(config.check.command);
57
83
  const result = await runConfiguredLinter(config, {
58
- projectRoot: context.cwd,
84
+ projectRoot: project.projectRoot,
59
85
  filePath,
60
86
  signal: context.signal,
61
87
  });
@@ -75,7 +101,10 @@ export default async function registerLint(pi: ExtensionAPI): Promise<void> {
75
101
  await Promise.all([connectIdePlugin(pi, idePlugin), connectDoctorPlugin(pi, lintDoctorPlugin)]);
76
102
  }
77
103
 
78
- async function loadRegistry(cwd: string): Promise<LintCommandRegistry> {
79
- const configDirectory = process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd;
80
- return LintCommandRegistry.fromDirectory(configDirectory);
104
+ async function loadRegistry(cwd: string, external: boolean): Promise<LintCommandRegistry> {
105
+ const configDirectory = external ? cwd : (process.env.PI_AGENT_IDE_CONFIG_DIR ?? cwd);
106
+ return LintCommandRegistry.fromDirectory(configDirectory, {
107
+ includeGlobal: !external,
108
+ requireBuiltInEvidence: external,
109
+ });
81
110
  }