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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-search",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -20,8 +20,8 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "pi-agent-tool-call-interception": "0.2.2",
24
- "pi-agent-tool-ui": "0.2.2"
23
+ "pi-agent-tool-call-interception": "0.3.0",
24
+ "pi-agent-tool-ui": "0.3.0"
25
25
  },
26
26
  "pi": {
27
27
  "extensions": [
@@ -28,10 +28,17 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
28
28
  event.details === null
29
29
  )
30
30
  return;
31
- const observations = await sessions.observeAfterEdit(
32
- [event.input.path, event.input.start, event.input.end],
33
- ctx.signal,
34
- );
31
+ const metadata = "metadata" in event.details ? event.details.metadata : undefined;
32
+ const recorded =
33
+ metadata && typeof metadata === "object" && "searchObservations" in metadata
34
+ ? metadata.searchObservations
35
+ : undefined;
36
+ const observations = Array.isArray(recorded)
37
+ ? (recorded as Awaited<ReturnType<SearchSessionStore["observeAfterEdit"]>>)
38
+ : await sessions.observeAfterEdit(
39
+ [event.input.path, event.input.start, event.input.end],
40
+ ctx.signal,
41
+ );
35
42
  if (observations.length === 0) return;
36
43
  return {
37
44
  content: [
@@ -80,6 +87,17 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
80
87
  apiVersion: SEARCH_API_VERSION,
81
88
  id: "local",
82
89
  setup(api): void {
90
+ api.addSelectionProvider((selection, context) =>
91
+ sessions.register(
92
+ selection.request.query,
93
+ selection.matches,
94
+ selection.complete,
95
+ context.cwd,
96
+ context.signal,
97
+ { ...selection.request, regex: false },
98
+ selection.refresh,
99
+ ),
100
+ );
83
101
  api.addResolver({ resolver: createRegexResolver(sessions), priority: -10 });
84
102
  api.addResolver({ resolver: createFileResolver(), priority: -10 });
85
103
  api.addResolver({ resolver: createTextResolver(sessions), fallback: true });
@@ -98,6 +116,28 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
98
116
  apiVersion: TEXT_EDITOR_API_VERSION,
99
117
  id: "search-anchors",
100
118
  setup(api): void {
119
+ api.tool("replace").addHandler({
120
+ stage: "text-post-edit",
121
+ async handler(state) {
122
+ if (
123
+ !state.result ||
124
+ typeof state.result !== "object" ||
125
+ !("kind" in state.result) ||
126
+ state.result.kind !== "completed" ||
127
+ !state.input ||
128
+ typeof state.input !== "object"
129
+ )
130
+ return state;
131
+ const input = state.input as Record<string, unknown>;
132
+ const observations = await sessions.observeAfterEdit(
133
+ [input.path, input.start, input.end],
134
+ state.signal,
135
+ );
136
+ return observations.length === 0
137
+ ? state
138
+ : { ...state, metadata: { ...state.metadata, searchObservations: observations } };
139
+ },
140
+ });
101
141
  api.addAnchorResolver({
102
142
  resolver: sessions.anchorResolver(),
103
143
  resources: sessions.resourceResolver(),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-search-text",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -16,11 +16,11 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "pi-agent-doctor": "0.2.2",
20
- "pi-agent-invariant": "0.2.2",
21
- "pi-agent-search": "0.2.2",
22
- "pi-agent-text": "0.2.2",
23
- "pi-agent-text-editor": "0.2.2"
19
+ "pi-agent-doctor": "0.3.0",
20
+ "pi-agent-invariant": "0.3.0",
21
+ "pi-agent-search": "0.3.0",
22
+ "pi-agent-text": "0.3.0",
23
+ "pi-agent-text-editor": "0.3.0"
24
24
  },
25
25
  "pi": {
26
26
  "extensions": [
@@ -1,4 +1,5 @@
1
1
  import { requiredValue } from "pi-agent-invariant";
2
+ import type { SearchSelectionMatch, SearchSelectionRegistration } from "pi-agent-search/api/search";
2
3
  import { createHash } from "node:crypto";
3
4
  import { readFile } from "node:fs/promises";
4
5
  import path from "node:path";
@@ -21,14 +22,7 @@ import { runSearchRecipe, type SearchRecipe } from "#src/search-recipe.js";
21
22
  const searchAnchorPattern = /^SEARCH#([A-F0-9]{4,64}):(all|[1-9]\d*):(line|match)$/u;
22
23
  const minimumSearchSessionIdLength = 4;
23
24
 
24
- export interface TextSearchMatch {
25
- readonly source: string;
26
- readonly lineNumber: number;
27
- readonly startColumn: number;
28
- readonly endColumn: number;
29
- readonly matchedText: string;
30
- readonly lineText: string;
31
- }
25
+ export type TextSearchMatch = SearchSelectionMatch;
32
26
 
33
27
  export interface TextSearchSession {
34
28
  readonly id: string;
@@ -44,6 +38,7 @@ interface SearchSnapshot {
44
38
  }
45
39
 
46
40
  interface StoredSearchSession extends TextSearchSession, SearchSnapshot {
41
+ readonly refresh?: SearchSelectionRegistration["refresh"];
47
42
  readonly recipe: SearchRecipe;
48
43
  readonly cwd: string;
49
44
  readonly refreshedComplete?: SearchSnapshot;
@@ -92,6 +87,7 @@ export function createSearchSessionIdentity(
92
87
  source,
93
88
  match.lineNumber,
94
89
  match.startColumn,
90
+ match.endLineNumber ?? match.lineNumber,
95
91
  match.endColumn,
96
92
  match.matchedText,
97
93
  match.lineText,
@@ -153,6 +149,7 @@ export class SearchSessionStore {
153
149
  query,
154
150
  regex: true,
155
151
  },
152
+ refresh?: SearchSelectionRegistration["refresh"],
156
153
  ): Promise<TextSearchSession> {
157
154
  const matches = sourceMatches
158
155
  .map((match) => ({ ...match, source: path.resolve(match.source) }))
@@ -168,6 +165,7 @@ export class SearchSessionStore {
168
165
  complete,
169
166
  contentBySource,
170
167
  recipe,
168
+ ...(refresh !== undefined && { refresh }),
171
169
  cwd: path.resolve(cwd),
172
170
  };
173
171
  this.#idsByIdentity.set(identity, id);
@@ -206,7 +204,10 @@ export class SearchSessionStore {
206
204
  scope: normalizeRecipe(session.recipe, session.cwd),
207
205
  };
208
206
  try {
209
- const result = await runSearchRecipe(session.recipe, session.cwd, signal);
207
+ const result =
208
+ session.refresh === undefined
209
+ ? await runSearchRecipe(session.recipe, session.cwd, signal)
210
+ : await session.refresh(signal);
210
211
  observations.push({
211
212
  ...base,
212
213
  matches: result.matches.length,
@@ -363,14 +364,21 @@ export class SearchSessionStore {
363
364
  );
364
365
  grouped.set(match.source, ranges);
365
366
  }
366
- const targets: TextTarget[] = [...grouped].map(([source, ranges]) => ({ source, ranges }));
367
+ const targets: TextTarget[] = [...grouped].map(([source, ranges]) => ({
368
+ source,
369
+ ranges,
370
+ expectedContent: snapshot.contentBySource.get(source),
371
+ }));
367
372
  return targets.length === 0
368
373
  ? { kind: "rejected", rejection: { code: "missing", reason: "search anchor has no matches" } }
369
374
  : { kind: "resolved", targets };
370
375
  }
371
376
 
372
377
  async #refresh(session: StoredSearchSession, signal?: AbortSignal): Promise<SearchSnapshot> {
373
- const result = await runSearchRecipe(session.recipe, session.cwd, signal);
378
+ const result =
379
+ session.refresh === undefined
380
+ ? await runSearchRecipe(session.recipe, session.cwd, signal)
381
+ : await session.refresh(signal);
374
382
  const matches = result.matches
375
383
  .map((match) => ({ ...match, source: path.resolve(match.source) }))
376
384
  .sort(compareMatches);
@@ -410,13 +418,28 @@ function selectMatches(
410
418
  }
411
419
 
412
420
  const seenLines = new Set<string>();
413
- return selected.filter((match) => {
414
- const key = `${match.source}\u0000${String(match.lineNumber)}`;
415
- if (seenLines.has(key)) {
416
- return false;
417
- }
418
- seenLines.add(key);
419
- return true;
421
+ return selected.flatMap((match) => {
422
+ const document = createTextDocument(
423
+ match.source,
424
+ session.contentBySource.get(match.source) ?? match.lineText,
425
+ );
426
+ const last = lastContainingLine(match);
427
+ return document.lines.slice(match.lineNumber - 1, last).flatMap((line) => {
428
+ const key = `${match.source}\u0000${String(line.lineNumber)}`;
429
+ if (seenLines.has(key)) return [];
430
+ seenLines.add(key);
431
+ return [
432
+ {
433
+ ...match,
434
+ lineNumber: line.lineNumber,
435
+ endLineNumber: line.lineNumber,
436
+ startColumn: 0,
437
+ endColumn: line.content.length,
438
+ lineText: line.content,
439
+ matchedText: line.content,
440
+ },
441
+ ];
442
+ });
420
443
  });
421
444
  }
422
445
 
@@ -424,6 +447,10 @@ function isMatch(value: TextSearchMatch | undefined): value is TextSearchMatch {
424
447
  return value !== undefined;
425
448
  }
426
449
 
450
+ function lastContainingLine(match: TextSearchMatch): number {
451
+ const end = match.endLineNumber ?? match.lineNumber;
452
+ return end > match.lineNumber && match.endColumn === 0 ? end - 1 : end;
453
+ }
427
454
  function selectionRange(
428
455
  document: ReturnType<typeof createTextDocument>,
429
456
  match: TextSearchMatch,
@@ -432,21 +459,36 @@ function selectionRange(
432
459
  if (mode === "match") {
433
460
  return {
434
461
  start: { lineNumber: match.lineNumber, column: match.startColumn },
435
- end: { lineNumber: match.lineNumber, column: match.endColumn },
462
+ end: { lineNumber: match.endLineNumber ?? match.lineNumber, column: match.endColumn },
436
463
  };
437
464
  }
438
465
 
439
- const line = requiredValue(document.lines[match.lineNumber - 1]);
466
+ const lastLine = lastContainingLine(match);
467
+ const line = requiredValue(document.lines[lastLine - 1]);
440
468
  return {
441
469
  start: { lineNumber: match.lineNumber, column: 0 },
442
470
  end: {
443
- lineNumber: match.lineNumber + (line.lineEnding.length > 0 ? 1 : 0),
471
+ lineNumber: lastLine + (line.lineEnding.length > 0 ? 1 : 0),
444
472
  column: line.lineEnding.length > 0 ? 0 : line.content.length,
445
473
  },
446
474
  linewise: true,
447
475
  };
448
476
  }
449
477
 
478
+ function matchedSourceText(
479
+ document: ReturnType<typeof createTextDocument>,
480
+ match: TextSearchMatch,
481
+ ): string {
482
+ const endLine = match.endLineNumber ?? match.lineNumber;
483
+ return document.lines
484
+ .slice(match.lineNumber - 1, endLine)
485
+ .map((line) => {
486
+ const start = line.lineNumber === match.lineNumber ? match.startColumn : 0;
487
+ const end = line.lineNumber === endLine ? match.endColumn : line.content.length;
488
+ return line.content.slice(start, end) + (line.lineNumber === endLine ? "" : line.lineEnding);
489
+ })
490
+ .join("");
491
+ }
450
492
  async function snapshotContents(
451
493
  matches: readonly TextSearchMatch[],
452
494
  signal?: AbortSignal,
@@ -460,10 +502,7 @@ async function snapshotContents(
460
502
  const document = createTextDocument(source, content);
461
503
  for (const match of matches.filter((candidate) => candidate.source === source)) {
462
504
  const line = document.lines[match.lineNumber - 1]?.content;
463
- if (
464
- line !== match.lineText ||
465
- line.slice(match.startColumn, match.endColumn) !== match.matchedText
466
- ) {
505
+ if (line !== match.lineText || matchedSourceText(document, match) !== match.matchedText) {
467
506
  throw new Error(`Search result in ${source} changed before its anchors were registered.`);
468
507
  }
469
508
  }
@@ -541,6 +580,7 @@ function compareMatches(left: TextSearchMatch, right: TextSearchMatch): number {
541
580
  left.source.localeCompare(right.source) ||
542
581
  left.lineNumber - right.lineNumber ||
543
582
  left.startColumn - right.startColumn ||
583
+ (left.endLineNumber ?? left.lineNumber) - (right.endLineNumber ?? right.lineNumber) ||
544
584
  left.endColumn - right.endColumn
545
585
  );
546
586
  }
@@ -5,7 +5,7 @@ import type { SearchPluginApi } from "#src/api/search.js";
5
5
 
6
6
  export const SEARCH_PROTOCOL = "pi-agent-search" as const;
7
7
 
8
- export const SEARCH_API_VERSION = 1 as const;
8
+ export const SEARCH_API_VERSION = 3 as const;
9
9
 
10
10
  export const SEARCH_CORE_READY_EVENT = "pi-agent-search/core/ready" as const;
11
11
 
@@ -0,0 +1,25 @@
1
+ import { Type } from "typebox";
2
+
3
+ /** Canonical arguments shared by standalone and composed operations. */
4
+ export const searchSchema = Type.Object(
5
+ {
6
+ query: Type.String({
7
+ minLength: 1,
8
+ description:
9
+ "Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching.",
10
+ }),
11
+ path: Type.Optional(
12
+ Type.String({ description: "Optional file or directory scope for local search" }),
13
+ ),
14
+ include: Type.Optional(Type.String({ description: "Optional include glob for local search" })),
15
+ exclude: Type.Optional(Type.String({ description: "Optional exclude glob for local search" })),
16
+ caseSensitive: Type.Optional(
17
+ Type.Boolean({ description: "Match letter case in local search" }),
18
+ ),
19
+ wholeWord: Type.Optional(Type.Boolean({ description: "Match complete words in local search" })),
20
+ limit: Type.Optional(
21
+ Type.Integer({ minimum: 1, maximum: 1000, description: "Maximum results (default 100)" }),
22
+ ),
23
+ },
24
+ { additionalProperties: false },
25
+ );
@@ -62,13 +62,65 @@ export interface SearchActionRegistration {
62
62
  execute(reference: string, input: unknown, context: SearchContext): Promise<unknown>;
63
63
  }
64
64
 
65
+ /** Full resolver data plus registered selection details, separate from rendered output. */
66
+ export interface SearchScriptData {
67
+ readonly resolverId: string;
68
+ readonly data: unknown;
69
+ readonly details: unknown;
70
+ }
71
+
72
+ /** A search execution with optional data for script callers. */
73
+ export interface SearchToolResult extends AgentToolResult<SearchToolDetails> {
74
+ readonly script?: SearchScriptData;
75
+ }
76
+ /** Exact text ranges discovered by any search backend. Columns are zero-based UTF-16 offsets. */
77
+ export interface SearchSelectionMatch {
78
+ readonly source: string;
79
+ readonly lineNumber: number;
80
+ readonly endLineNumber?: number;
81
+ readonly startColumn: number;
82
+ readonly endColumn: number;
83
+ readonly matchedText: string;
84
+ readonly lineText: string;
85
+ }
86
+ export interface SearchSelectionSnapshot {
87
+ readonly matches: readonly SearchSelectionMatch[];
88
+ readonly complete: boolean;
89
+ readonly notices?: readonly string[];
90
+ }
91
+ /** Keep the original backend when refreshing an all-selection or observing an edit. */
92
+ export interface SearchSelectionRegistration extends SearchSelectionSnapshot {
93
+ readonly request: SearchRequest;
94
+ readonly refresh: (signal?: AbortSignal) => Promise<SearchSelectionSnapshot>;
95
+ }
96
+ export interface RegisteredSearchSelection {
97
+ readonly id: string;
98
+ readonly matches: readonly SearchSelectionMatch[];
99
+ readonly complete: boolean;
100
+ }
101
+ export type SearchSelectionProvider = (
102
+ selection: SearchSelectionRegistration,
103
+ context: SearchContext,
104
+ ) => Promise<RegisteredSearchSelection>;
65
105
  export interface SearchPluginApi {
66
106
  addResolver(registration: SearchResolverRegistration): void;
107
+ /** Register the one shared SEARCH reference store. */
108
+ addSelectionProvider(provider: SearchSelectionProvider): void;
109
+ /** Register exact ranges with the shared store, retaining backend refresh behavior. */
110
+ registerSelection(
111
+ selection: SearchSelectionRegistration,
112
+ context: SearchContext,
113
+ ): Promise<RegisteredSearchSelection>;
67
114
  addAction(registration: SearchActionRegistration): void;
68
115
  describe(description: SearchDescriptionSource): void;
69
116
  /** Add an operational guideline while this search plugin is active. */
70
117
  addPromptGuideline(guideline: SearchDescriptionSource): void;
71
- search(request: SearchRequest, context: SearchContext): Promise<AgentToolResult<unknown>>;
118
+ /** Execute configured resolvers and register references before returning script data. */
119
+ search(
120
+ request: SearchRequest,
121
+ context: SearchContext,
122
+ audience?: "agent" | "script",
123
+ ): Promise<SearchToolResult>;
72
124
  runAction(request: SearchActionRequest, context: SearchContext): Promise<unknown>;
73
125
  }
74
126
 
@@ -87,3 +139,5 @@ export interface SearchToolDetails {
87
139
  readonly cause?: unknown;
88
140
  };
89
141
  }
142
+
143
+ export { searchSchema } from "#src/api/search-parameters.js";
@@ -17,7 +17,7 @@ import {
17
17
  ToolCallInterceptionRenderStore,
18
18
  withToolCallInterceptionRendering,
19
19
  } from "pi-agent-tool-call-interception";
20
- import { type Static, Type } from "typebox";
20
+ import type { Static } from "typebox";
21
21
 
22
22
  import {
23
23
  isSearchPluginRegistrationRequest,
@@ -33,28 +33,7 @@ import { runWithSearchTimeout } from "#src/core/search-timeout.js";
33
33
 
34
34
  import type { SearchToolDetails } from "#src/api/search.js";
35
35
 
36
- const searchSchema = Type.Object(
37
- {
38
- query: Type.String({
39
- minLength: 1,
40
- description:
41
- "Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching.",
42
- }),
43
- path: Type.Optional(
44
- Type.String({ description: "Optional file or directory scope for local search" }),
45
- ),
46
- include: Type.Optional(Type.String({ description: "Optional include glob for local search" })),
47
- exclude: Type.Optional(Type.String({ description: "Optional exclude glob for local search" })),
48
- caseSensitive: Type.Optional(
49
- Type.Boolean({ description: "Match letter case in local search" }),
50
- ),
51
- wholeWord: Type.Optional(Type.Boolean({ description: "Match complete words in local search" })),
52
- limit: Type.Optional(
53
- Type.Integer({ minimum: 1, maximum: 1000, description: "Maximum results (default 100)" }),
54
- ),
55
- },
56
- { additionalProperties: false },
57
- );
36
+ import { searchSchema } from "#src/api/search-parameters.js";
58
37
 
59
38
  /** Arguments accepted by the search tool. */
60
39
  export type SearchParameters = Static<typeof searchSchema>;
@@ -3,6 +3,7 @@ import { withBlockedToolResult } from "pi-agent-tool-call-interception";
3
3
  import type { SearchPlugin } from "#src/api/plugin-protocol.js";
4
4
  import type {
5
5
  SearchActionRegistration,
6
+ SearchSelectionProvider,
6
7
  SearchContext,
7
8
  SearchDescriptionSource,
8
9
  SearchPluginApi,
@@ -10,6 +11,7 @@ import type {
10
11
  SearchResolutionAttempt,
11
12
  SearchResolverRegistration,
12
13
  SearchToolDetails,
14
+ SearchToolResult,
13
15
  } from "#src/api/search.js";
14
16
  import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
15
17
 
@@ -25,7 +27,8 @@ export interface SearchCore {
25
27
  execute(
26
28
  request: SearchRequest,
27
29
  context: SearchContext,
28
- ): Promise<AgentToolResult<SearchToolDetails>>;
30
+ audience?: "agent" | "script",
31
+ ): Promise<SearchToolResult>;
29
32
  runAction(
30
33
  reference: string,
31
34
  capability: string,
@@ -41,6 +44,7 @@ export interface SearchCore {
41
44
 
42
45
  export function createSearchCore(): SearchCore {
43
46
  const resolvers: RegisteredResolver[] = [];
47
+ let selectionProvider: SearchSelectionProvider | undefined;
44
48
  const actions = new Map<string, SearchActionRegistration>();
45
49
  const promptGuidelines = new Map<string, SearchDescriptionSource[]>();
46
50
  const descriptions = new Map<string, SearchDescriptionSource>();
@@ -62,9 +66,22 @@ export function createSearchCore(): SearchCore {
62
66
  const ready = queue.then(async () => {
63
67
  const draftResolvers: SearchResolverRegistration[] = [];
64
68
  const draftActions: SearchActionRegistration[] = [];
69
+ let draftSelectionProvider: SearchSelectionProvider | undefined;
65
70
  let draftDescription: SearchDescriptionSource | undefined;
66
71
  const draftPromptGuidelines: SearchDescriptionSource[] = [];
67
72
  const api: SearchPluginApi = {
73
+ addSelectionProvider(provider) {
74
+ if (draftSelectionProvider !== undefined || selectionProvider !== undefined)
75
+ throw new Error("Search selection provider is already registered");
76
+ draftSelectionProvider = provider;
77
+ },
78
+ registerSelection(selection, context) {
79
+ if (selectionProvider === undefined)
80
+ throw new Error(
81
+ "Search selections are unavailable. Enable the shared search selection plugin.",
82
+ );
83
+ return selectionProvider(selection, context);
84
+ },
68
85
  addResolver(registration): void {
69
86
  assertResolver(registration);
70
87
  draftResolvers.push(registration);
@@ -83,7 +100,7 @@ export function createSearchCore(): SearchCore {
83
100
  addPromptGuideline(guideline): void {
84
101
  draftPromptGuidelines.push(normalizeDescriptionSource(guideline));
85
102
  },
86
- search: (request, context) => core.execute(request, context),
103
+ search: (request, context, audience) => core.execute(request, context, audience),
87
104
  runAction(request, context): Promise<unknown> {
88
105
  return core.runAction(
89
106
  request.reference,
@@ -123,6 +140,7 @@ export function createSearchCore(): SearchCore {
123
140
  for (const registration of draftResolvers) {
124
141
  resolvers.push({ pluginId: plugin.id, registration, order: resolvers.length });
125
142
  }
143
+ if (draftSelectionProvider !== undefined) selectionProvider = draftSelectionProvider;
126
144
 
127
145
  for (const action of draftActions) {
128
146
  actions.set(actionKey(action.resolverId, action.capability), action);
@@ -145,7 +163,7 @@ export function createSearchCore(): SearchCore {
145
163
  async waitForPendingPlugins(): Promise<void> {
146
164
  await Promise.all(plugins.values());
147
165
  },
148
- async execute(request, context): Promise<AgentToolResult<SearchToolDetails>> {
166
+ async execute(request, context, audience = "agent"): Promise<SearchToolResult> {
149
167
  if (request.query.trim().length === 0) {
150
168
  return failure("INVALID_REQUEST", "Search query must not be empty");
151
169
  }
@@ -223,6 +241,13 @@ export function createSearchCore(): SearchCore {
223
241
  ]
224
242
  : formatted.content,
225
243
  details: { resolverId: resolver.id, payload: formatted.details },
244
+ ...(audience === "script" && {
245
+ script: {
246
+ resolverId: resolver.id,
247
+ data: attempt.payload,
248
+ details: formatted.details,
249
+ },
250
+ }),
226
251
  ...(formatted.usage !== undefined && { usage: formatted.usage }),
227
252
  };
228
253
  } catch (error) {
@@ -9,9 +9,7 @@ export default async function registerTextEditor(pi: ExtensionAPI): Promise<void
9
9
  const core = await registerTextEditorCore(pi);
10
10
  registerBuiltinEditFilter(pi);
11
11
 
12
- if (!process.argv.includes("--old-tools")) {
13
- registerTextEditorTools(pi, core);
14
- }
12
+ registerTextEditorTools(pi, core);
15
13
 
16
14
  registerTextEditBatching(pi, core);
17
15
  }