pi-agent-ide 0.6.3 → 0.7.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 (461) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +10 -3
  3. package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
  4. package/dist/chunk-3HYXQ4YA.js +28 -0
  5. package/dist/chunk-3JO7QFIL.js +1 -0
  6. package/dist/chunk-4NIFBFFR.js +11 -0
  7. package/dist/{chunk-VCTK4JSN.js → chunk-64M3SQPG.js} +1 -1
  8. package/dist/{chunk-5QQABP47.js → chunk-7LD2OQH3.js} +1 -1
  9. package/dist/chunk-7LZKOHH2.js +1 -0
  10. package/dist/chunk-AJRIASPQ.js +2 -0
  11. package/dist/chunk-EAZGN5ND.js +7 -0
  12. package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
  13. package/dist/{chunk-GIRAEVUJ.js → chunk-F5YZG77W.js} +1 -1
  14. package/dist/chunk-FK42RSF4.js +1 -0
  15. package/dist/{chunk-O6LE42GK.js → chunk-FXNKMNSJ.js} +1 -1
  16. package/dist/chunk-GBLKIB6O.js +2 -0
  17. package/dist/chunk-KBP3QUDT.js +2 -0
  18. package/dist/chunk-KR36BT5E.js +1 -0
  19. package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
  20. package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
  21. package/dist/chunk-OE7QVAI2.js +5 -0
  22. package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
  23. package/dist/chunk-PNU3E7IO.js +3 -0
  24. package/dist/chunk-PS2B6THP.js +3 -0
  25. package/dist/chunk-PYPPV2F5.js +25 -0
  26. package/dist/{chunk-25CZ5ZIU.js → chunk-QFTBY67N.js} +3 -3
  27. package/dist/chunk-S5LXX32D.js +28 -0
  28. package/dist/chunk-SILJ3OL4.js +9 -0
  29. package/dist/chunk-SQKAXYIR.js +2 -0
  30. package/dist/chunk-VCGNVTXQ.js +1 -0
  31. package/dist/chunk-XYS4FSCC.js +12 -0
  32. package/dist/chunk-YGGKGZO2.js +1 -0
  33. package/dist/{chunk-L7JMDDSD.js → chunk-YRF7OATP.js} +1 -1
  34. package/dist/chunk-ZPT5D4VP.js +2 -0
  35. package/dist/entry-0.js +1 -1
  36. package/dist/entry-11.js +1 -1
  37. package/dist/entry-13.js +1 -1
  38. package/dist/entry-14.js +1 -1
  39. package/dist/entry-15.js +1 -1
  40. package/dist/entry-16.js +1 -1
  41. package/dist/entry-17.js +1 -1
  42. package/dist/entry-25.js +2 -2
  43. package/dist/entry-26.js +1 -1
  44. package/dist/entry-27.js +1 -1
  45. package/dist/entry-28.js +1 -1
  46. package/dist/entry-29.js +1 -1
  47. package/dist/entry-30.js +1 -1
  48. package/dist/entry-31.js +11 -9
  49. package/dist/entry-33.js +1 -1
  50. package/dist/entry-37.js +6 -6
  51. package/dist/entry-42.js +1 -1
  52. package/dist/entry-44.js +1 -1
  53. package/dist/entry-45.js +12 -11
  54. package/dist/entry-46.js +1 -1
  55. package/dist/entry-49.js +1 -1
  56. package/dist/entry-50.js +3 -6
  57. package/dist/entry-51.js +11 -9
  58. package/dist/entry-52.js +1 -1
  59. package/dist/entry-53.js +1 -1
  60. package/dist/entry-54.js +1 -1
  61. package/dist/entry-55.js +1 -1
  62. package/dist/entry-56.js +1 -1
  63. package/dist/entry-57.js +1 -1
  64. package/dist/entry-58.js +1 -1
  65. package/dist/entry-59.js +1 -1
  66. package/dist/entry-60.js +1 -1
  67. package/dist/entry-61.js +0 -1
  68. package/dist/entry-62.js +1 -0
  69. package/dist/entry-63.js +0 -1
  70. package/dist/entry-64.js +1 -0
  71. package/dist/entry-65.js +1 -1
  72. package/dist/entry-66.js +1 -1
  73. package/dist/entry-67.js +1 -1
  74. package/dist/entry-68.js +1 -1
  75. package/dist/entry-69.js +1 -1
  76. package/dist/entry-70.js +1 -1
  77. package/dist/entry-72.js +1 -1
  78. package/dist/entry-75.js +1 -1
  79. package/dist/entry-77.js +50 -307
  80. package/dist/entry-78.js +14 -26
  81. package/dist/entry-79.js +2 -2
  82. package/dist/entry-80.js +1 -1
  83. package/dist/entry-81.js +1 -1
  84. package/dist/entry-82.js +5 -3
  85. package/dist/entry-83.js +1 -1
  86. package/dist/entry-84.js +1 -1
  87. package/dist/entry-85.js +1 -1
  88. package/dist/entry-86.js +1 -1
  89. package/dist/pi-agent-ide.js +15 -3
  90. package/docs/agent-guides/editing.md +31 -3
  91. package/docs/agent-guides/git-changes.md +1 -1
  92. package/docs/agent-guides/json-reading.md +19 -3
  93. package/docs/agent-guides/read-resources.md +15 -1
  94. package/docs/agent-guides/search-code.md +43 -2
  95. package/docs/agent-guides/select-code.md +194 -0
  96. package/docs/agent-guides/terminal.md +1 -1
  97. package/docs/code-review.md +99 -0
  98. package/docs/configuration.md +36 -7
  99. package/docs/development.md +16 -19
  100. package/docs/nightly.md +7 -0
  101. package/docs/releases.md +42 -0
  102. package/docs/research/apply-native-capability-matrix.md +174 -0
  103. package/docs/research/apply-read-latency.md +2 -0
  104. package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
  105. package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
  106. package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
  107. package/docs/research/native-codemode-batch-decision.md +29 -0
  108. package/docs/research/native-codemode-batching.md +65 -0
  109. package/docs/structured-results.md +86 -0
  110. package/docs/tools.md +24 -4
  111. package/docs/user-hooks.md +1 -1
  112. package/node_modules/pi-agent-doctor/package.json +1 -1
  113. package/node_modules/pi-agent-documentation/package.json +1 -1
  114. package/node_modules/pi-agent-documentation/src/index.ts +1 -1
  115. package/node_modules/pi-agent-filesystem/index.ts +6 -1
  116. package/node_modules/pi-agent-filesystem/package.json +7 -6
  117. package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
  118. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  119. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  120. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  121. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  122. package/node_modules/pi-agent-ide-ast/package.json +15 -10
  123. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  124. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  125. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  126. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  127. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  128. package/node_modules/pi-agent-ide-ast/src/extension.ts +4 -2
  129. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  130. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  131. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  132. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +110 -7
  133. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  134. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
  135. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
  136. package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
  137. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
  138. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +251 -0
  139. package/node_modules/pi-agent-ide-changes/index.ts +2 -24
  140. package/node_modules/pi-agent-ide-changes/package.json +8 -7
  141. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  142. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
  143. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  144. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  145. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  146. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  147. package/node_modules/pi-agent-ide-lsp/index.ts +2 -2
  148. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  149. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  150. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  151. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  152. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  153. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  154. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
  155. package/node_modules/pi-agent-image/package.json +2 -2
  156. package/node_modules/pi-agent-invariant/package.json +1 -1
  157. package/node_modules/pi-agent-pdf/package.json +2 -2
  158. package/node_modules/pi-agent-read/package.json +7 -7
  159. package/node_modules/pi-agent-read/src/api/read-parameters.ts +2 -2
  160. package/node_modules/pi-agent-read/src/api/tools/read.ts +35 -2
  161. package/node_modules/pi-agent-read/src/core/extension.ts +11 -0
  162. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  163. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  164. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  165. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
  166. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +127 -73
  167. package/node_modules/pi-agent-resource/package.json +1 -1
  168. package/node_modules/pi-agent-resource/src/index.ts +22 -0
  169. package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
  170. package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
  171. package/node_modules/pi-agent-resource/src/result-targets.ts +233 -0
  172. package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
  173. package/node_modules/pi-agent-search/package.json +5 -4
  174. package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
  175. package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
  176. package/node_modules/pi-agent-search/src/api/search-parameters.ts +13 -6
  177. package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
  178. package/node_modules/pi-agent-search/src/api/search.ts +39 -0
  179. package/node_modules/pi-agent-search/src/api/structured-result.ts +148 -0
  180. package/node_modules/pi-agent-search/src/core/extension.ts +90 -24
  181. package/node_modules/pi-agent-search/src/core/search-core.ts +145 -78
  182. package/node_modules/pi-agent-search-text/index.ts +6 -1
  183. package/node_modules/pi-agent-search-text/package.json +7 -6
  184. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  185. package/node_modules/pi-agent-search-text/src/resolvers.ts +174 -26
  186. package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
  187. package/node_modules/pi-agent-search-text/src/search-backend.ts +201 -18
  188. package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
  189. package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
  190. package/node_modules/pi-agent-search-text/src/search-renderer.ts +90 -259
  191. package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
  192. package/node_modules/pi-agent-search-text/src/search-session.ts +110 -17
  193. package/node_modules/pi-agent-text/package.json +2 -2
  194. package/node_modules/pi-agent-text/src/text-document.ts +15 -10
  195. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  196. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  197. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  198. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  199. package/node_modules/pi-agent-text-editor/index.ts +4 -7
  200. package/node_modules/pi-agent-text-editor/package.json +20 -21
  201. package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  202. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  203. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  204. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  205. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  206. package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  207. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
  208. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  209. package/node_modules/pi-agent-text-editor/src/core/extension.ts +12 -2
  210. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
  211. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  212. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  213. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  214. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  215. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -0
  216. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  217. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
  218. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  219. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  220. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +412 -0
  221. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
  222. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  223. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
  224. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
  225. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  226. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  227. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  228. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  229. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  230. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  231. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  232. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  233. package/node_modules/pi-agent-text-editor-renderer/index.ts +9 -73
  234. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -5
  235. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
  236. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  237. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  238. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  239. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  240. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  241. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  242. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  243. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  244. package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
  245. package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
  246. package/node_modules/pi-agent-web/index.ts +23 -0
  247. package/node_modules/pi-agent-web/package.json +7 -6
  248. package/node_modules/pi-agent-web/src/search.ts +221 -0
  249. package/node_modules/pi-agent-web-html/package.json +2 -2
  250. package/node_modules/pi-agent-web-image/package.json +3 -3
  251. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  252. package/node_modules/pi-agent-web-text/package.json +3 -3
  253. package/package.json +42 -37
  254. package/skills/capture-code-review-rule/SKILL.md +60 -0
  255. package/src/code-review/config.ts +68 -0
  256. package/src/code-review/extension.ts +105 -0
  257. package/src/code-review/fragments.ts +26 -0
  258. package/src/code-review/reviewer.ts +198 -0
  259. package/src/composite/host-version.ts +13 -0
  260. package/src/composite/module-labels.ts +1 -1
  261. package/src/composite/nested-tool-rendering.ts +298 -0
  262. package/src/composite/preferences.ts +0 -5
  263. package/src/composite/tool-availability.ts +90 -0
  264. package/src/core/extension.ts +2 -0
  265. package/src/documentation/extension.ts +81 -145
  266. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
  267. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
  268. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  269. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  270. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  271. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  272. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
  273. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +23 -0
  274. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -6
  275. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  276. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  277. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  278. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  279. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +221 -0
  280. package/src/extensions/pi-agent-read/package.json +7 -7
  281. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +2 -2
  282. package/src/extensions/pi-agent-read/src/api/tools/read.ts +35 -2
  283. package/src/extensions/pi-agent-read/src/core/extension.ts +11 -0
  284. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  285. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  286. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  287. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +218 -0
  288. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +127 -73
  289. package/src/extensions/pi-agent-search/package.json +5 -4
  290. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +6 -1
  291. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
  292. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  293. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +174 -26
  294. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
  295. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +201 -18
  296. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
  297. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
  298. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +90 -259
  299. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
  300. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +110 -17
  301. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
  302. package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
  303. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +13 -6
  304. package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
  305. package/src/extensions/pi-agent-search/src/api/search.ts +39 -0
  306. package/src/extensions/pi-agent-search/src/api/structured-result.ts +148 -0
  307. package/src/extensions/pi-agent-search/src/core/extension.ts +90 -24
  308. package/src/extensions/pi-agent-search/src/core/search-core.ts +145 -78
  309. package/src/extensions/pi-agent-text-editor/index.ts +4 -7
  310. package/src/extensions/pi-agent-text-editor/package.json +20 -21
  311. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  312. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  313. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  314. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  315. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +9 -73
  316. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -5
  317. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +276 -129
  318. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  319. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  320. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  321. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  322. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  323. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  324. package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  325. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  326. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  327. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  328. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  329. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  330. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +78 -41
  331. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  332. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +12 -2
  333. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +35 -4
  334. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +1 -1
  335. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  336. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  337. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  338. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +820 -0
  339. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  340. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
  341. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  342. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  343. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +412 -0
  344. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +149 -139
  345. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  346. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +236 -185
  347. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +253 -203
  348. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  349. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  350. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -6
  351. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  352. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  353. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  354. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  355. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  356. package/src/pi-agent-ide.ts +61 -8
  357. package/src/plugins/pi-agent-ide-ast/package.json +15 -10
  358. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  359. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  360. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  361. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  362. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  363. package/src/plugins/pi-agent-ide-ast/src/extension.ts +4 -2
  364. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  365. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  366. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  367. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +110 -7
  368. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  369. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
  370. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
  371. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
  372. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
  373. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +251 -0
  374. package/src/plugins/pi-agent-ide-changes/index.ts +2 -24
  375. package/src/plugins/pi-agent-ide-changes/package.json +8 -7
  376. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  377. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +126 -48
  378. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  379. package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
  380. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
  381. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
  382. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
  383. package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
  384. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
  385. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
  386. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  387. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  388. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  389. package/src/plugins/pi-agent-ide-lsp/index.ts +2 -2
  390. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  391. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  392. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  393. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  394. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  395. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  396. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -30
  397. package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
  398. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
  399. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
  400. package/src/plugins/pi-agent-ide-terminal/src/search.ts +16 -37
  401. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
  402. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
  403. package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
  404. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +98 -46
  405. package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
  406. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
  407. package/src/plugins/pi-agent-ide-vision/index.ts +35 -1
  408. package/dist/chunk-3E2NTWCN.js +0 -2
  409. package/dist/chunk-4LUW26BX.js +0 -10
  410. package/dist/chunk-4U2GUKNJ.js +0 -0
  411. package/dist/chunk-5VSE5X5R.js +0 -2
  412. package/dist/chunk-6EYWFBNG.js +0 -0
  413. package/dist/chunk-7WCZOO5I.js +0 -1
  414. package/dist/chunk-CEX3VOJ7.js +0 -2
  415. package/dist/chunk-FA6BKC5Y.js +0 -1
  416. package/dist/chunk-FEDVTZJG.js +0 -1
  417. package/dist/chunk-HMLH43ZS.js +0 -4
  418. package/dist/chunk-ITSNK5YG.js +0 -7
  419. package/dist/chunk-KII2JQC5.js +0 -1
  420. package/dist/chunk-LVWMWWWF.js +0 -28
  421. package/dist/chunk-P7XO5CIP.js +0 -2
  422. package/dist/chunk-PZFOOHY2.js +0 -15
  423. package/dist/chunk-ROXXK6TW.js +0 -0
  424. package/dist/chunk-S3ZPXWX7.js +0 -2
  425. package/dist/chunk-T7CZIACQ.js +0 -27
  426. package/dist/chunk-VXD6FZP5.js +0 -5
  427. package/dist/chunk-YHUTTZC6.js +0 -2
  428. package/dist/chunk-YT42LKFV.js +0 -16
  429. package/docs/agent-guides/apply.md +0 -333
  430. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  431. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
  432. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
  433. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  434. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  435. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  436. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  437. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  438. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  439. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  440. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  441. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -133
  442. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  443. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
  444. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
  445. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
  446. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  447. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -155
  448. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -344
  449. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  450. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  451. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  452. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  453. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  454. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  455. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  456. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  457. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -133
  458. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  459. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -148
  460. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -920
  461. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
@@ -0,0 +1,148 @@
1
+ import { Type } from "typebox";
2
+ import { structuredResultSchema } from "pi-agent-resource";
3
+
4
+ const position = Type.Object(
5
+ {
6
+ startLine: Type.Integer(),
7
+ startColumn: Type.Integer(),
8
+ endLine: Type.Integer(),
9
+ endColumn: Type.Integer(),
10
+ },
11
+ { additionalProperties: false },
12
+ );
13
+ const references = Type.Object(
14
+ { line: Type.Optional(Type.String()), match: Type.Optional(Type.String()) },
15
+ { additionalProperties: false },
16
+ );
17
+ const sourceMatchFields = {
18
+ source: Type.String(),
19
+ target: Type.Optional(Type.String()),
20
+ range: position,
21
+ matchedText: Type.Optional(Type.String()),
22
+ textTruncated: Type.Optional(Type.Boolean()),
23
+ references: Type.Optional(references),
24
+ };
25
+ const match = Type.Object(
26
+ {
27
+ ...sourceMatchFields,
28
+ captures: Type.Optional(
29
+ Type.Record(
30
+ Type.String(),
31
+ Type.Array(Type.Object(sourceMatchFields, { additionalProperties: false })),
32
+ ),
33
+ ),
34
+ role: Type.Optional(Type.Union([Type.Literal("definition"), Type.Literal("reference")])),
35
+ symbol: Type.Optional(
36
+ Type.Object(
37
+ {
38
+ id: Type.String(),
39
+ name: Type.String(),
40
+ kind: Type.String(),
41
+ source: Type.String(),
42
+ range: position,
43
+ },
44
+ { additionalProperties: false },
45
+ ),
46
+ ),
47
+ },
48
+ { additionalProperties: false },
49
+ );
50
+ const selectionProperties = {
51
+ target: Type.Optional(Type.String()),
52
+ kind: Type.Literal("matches"),
53
+ truncated: Type.Optional(Type.Boolean()),
54
+ fullResult: Type.Optional(Type.String()),
55
+ complete: Type.Boolean(),
56
+ matches: Type.Array(match),
57
+ all: Type.Optional(references),
58
+ notices: Type.Optional(Type.Array(Type.String())),
59
+ };
60
+ /** Separate possible-name groups with exact captured ranges and optional Read references. */
61
+ export const fuzzyDataSchema = Type.Object(
62
+ {
63
+ status: Type.Union([Type.Literal("ready"), Type.Literal("skipped")]),
64
+ message: Type.Optional(Type.String()),
65
+ candidates: Type.Array(
66
+ Type.Object(
67
+ {
68
+ identifier: Type.String(),
69
+ kind: Type.Union([
70
+ Type.Literal("normalized"),
71
+ Type.Literal("component"),
72
+ Type.Literal("typo"),
73
+ ]),
74
+ reason: Type.String(),
75
+ matchCount: Type.Integer(),
76
+ fileCount: Type.Integer(),
77
+ selection: Type.Object(selectionProperties, { additionalProperties: false }),
78
+ },
79
+ { additionalProperties: false },
80
+ ),
81
+ ),
82
+ },
83
+ { additionalProperties: false },
84
+ );
85
+ /** Resolver adapters supply selected domain fields, never renderer details or raw backend objects. */
86
+ export const searchDataSchema = Type.Union([
87
+ Type.Object(
88
+ { ...selectionProperties, fuzzy: Type.Optional(fuzzyDataSchema) },
89
+ { additionalProperties: false },
90
+ ),
91
+ Type.Object(
92
+ { kind: Type.Literal("files"), complete: Type.Boolean(), files: Type.Array(Type.String()) },
93
+ { additionalProperties: false },
94
+ ),
95
+ Type.Object(
96
+ { kind: Type.Literal("custom"), resolverId: Type.String(), value: Type.Unknown() },
97
+ { additionalProperties: false },
98
+ ),
99
+ ]);
100
+ export const searchOutputSchema = structuredResultSchema(searchDataSchema);
101
+
102
+ /** Project a registered selection in its original order. Columns are zero-based UTF-16 offsets. */
103
+ export function selectionData(
104
+ matches: readonly {
105
+ source: string;
106
+ lineNumber: number;
107
+ endLineNumber?: number;
108
+ startColumn: number;
109
+ endColumn: number;
110
+ matchedText: string;
111
+ }[],
112
+ complete: boolean,
113
+ sessionId?: string,
114
+ targets?: { readonly target?: string; readonly matchTargets?: readonly string[] },
115
+ ) {
116
+ return {
117
+ kind: "matches" as const,
118
+ ...(targets?.target === undefined ? {} : { target: targets.target }),
119
+ truncated: matches.length > 100,
120
+ complete,
121
+ matches: matches.slice(0, 100).map((match, index) => ({
122
+ source: match.source,
123
+ ...(targets?.matchTargets?.[index] === undefined
124
+ ? {}
125
+ : { target: targets.matchTargets[index] }),
126
+ range: {
127
+ startLine: match.lineNumber,
128
+ startColumn: match.startColumn,
129
+ endLine: match.endLineNumber ?? match.lineNumber,
130
+ endColumn: match.endColumn,
131
+ },
132
+ ...(Buffer.byteLength(match.matchedText) <= 4096
133
+ ? { matchedText: match.matchedText }
134
+ : { textTruncated: true }),
135
+ ...(sessionId === undefined
136
+ ? {}
137
+ : {
138
+ references: {
139
+ line: `SEARCH#${sessionId}:${index + 1}:line`,
140
+ match: `SEARCH#${sessionId}:${index + 1}:match`,
141
+ },
142
+ }),
143
+ })),
144
+ ...(complete && sessionId !== undefined
145
+ ? { all: { line: `SEARCH#${sessionId}:all:line`, match: `SEARCH#${sessionId}:all:match` } }
146
+ : {}),
147
+ };
148
+ }
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  type AgentToolResult,
3
3
  type ExtensionAPI,
4
- keyText,
5
4
  type Theme,
6
5
  type ToolRenderResultOptions,
7
6
  } from "@earendil-works/pi-coding-agent";
8
7
  import { type Component, Text } from "@earendil-works/pi-tui";
9
8
  import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
10
9
  import {
10
+ ResultPanel,
11
11
  toolCallHeader,
12
12
  type ToolCallHeaderDetail,
13
13
  type ToolCallHeaderModel,
@@ -35,6 +35,9 @@ import { runWithSearchTimeout } from "#src/core/search-timeout.js";
35
35
  import type { SearchToolDetails } from "#src/api/search.js";
36
36
 
37
37
  import { searchSchema } from "#src/api/search-parameters.js";
38
+ import { searchOutputSchema, searchDataSchema } from "#src/api/structured-result.js";
39
+ import { resultError, withStructuredResult } from "pi-agent-resource";
40
+ import { connectResultTargets } from "pi-agent-resource";
38
41
 
39
42
  /** Arguments accepted by the search tool. */
40
43
  export type SearchParameters = Static<typeof searchSchema>;
@@ -49,12 +52,15 @@ export function searchCallModel(
49
52
  ? []
50
53
  : [
51
54
  {
52
- text: `in ${arguments_.path}`,
55
+ text: typeof arguments_.path === "string" ? `in ${arguments_.path}` : "in result scope",
53
56
  color: "accent" as const,
54
57
  underline: true,
55
58
  truncate: "start" as const,
56
59
  },
57
60
  ]),
61
+ ...(arguments_.navigation === undefined
62
+ ? []
63
+ : [{ text: "reference navigation", color: "warning" as const }]),
58
64
  ...(arguments_.include === undefined ? [] : [{ text: `include ${arguments_.include}` }]),
59
65
  ...(arguments_.exclude === undefined ? [] : [{ text: `exclude ${arguments_.exclude}` }]),
60
66
  ...(arguments_.caseSensitive === true ? [{ text: "case sensitive" }] : []),
@@ -93,6 +99,7 @@ export default async function registerSearchCore(
93
99
  }),
94
100
  ]);
95
101
  const core = createSearchCore();
102
+ const targets = connectResultTargets(pi);
96
103
  const interceptionRendering = new ToolCallInterceptionRenderStore();
97
104
  const unsubscribe = pi.events.on(SEARCH_PLUGIN_REGISTER_EVENT, (request) => {
98
105
  if (!isSearchPluginRegistrationRequest(request)) {
@@ -106,6 +113,17 @@ export default async function registerSearchCore(
106
113
  withToolCallInterceptionRendering(
107
114
  {
108
115
  name: "search",
116
+ exposure: "direct",
117
+ namespace: {
118
+ name: "ide_search",
119
+ description: "Find workspace text, paths and code structures.",
120
+ },
121
+ annotations: {
122
+ readOnlyHint: true,
123
+ destructiveHint: false,
124
+ idempotentHint: false,
125
+ openWorldHint: false,
126
+ },
109
127
  label: "search",
110
128
  description: "Use search to locate workspace text, file paths, and code structures.",
111
129
  promptSnippet:
@@ -117,6 +135,7 @@ export default async function registerSearchCore(
117
135
  ];
118
136
  },
119
137
  parameters: searchSchema,
138
+ outputSchema: searchOutputSchema,
120
139
  renderCall(arguments_, theme, renderContext): Component {
121
140
  const mode = renderContext.expanded ? "full" : presentation;
122
141
  if (mode === "disabled") return new Text(theme.fg("toolTitle", "search"), 0, 0);
@@ -135,8 +154,13 @@ export default async function registerSearchCore(
135
154
  const renderer =
136
155
  details?.resolverId === undefined ? undefined : core.renderer(details.resolverId);
137
156
 
138
- if (renderer !== undefined) {
139
- const inner = { ...result, details: details?.payload };
157
+ if (
158
+ renderer !== undefined &&
159
+ details?.payload !== undefined &&
160
+ !context.isError &&
161
+ !options.isPartial
162
+ ) {
163
+ const inner = { ...result, details: details.payload };
140
164
  return renderer(inner, options, theme, context);
141
165
  }
142
166
 
@@ -149,21 +173,50 @@ export default async function registerSearchCore(
149
173
  onUpdate,
150
174
  context,
151
175
  ): Promise<AgentToolResult<SearchToolDetails>> {
152
- const config = await loadSearchConfig(
153
- resolveSearchConfigPaths(process.env, os.homedir(), context.cwd),
154
- );
155
- return runWithSearchTimeout(config.timeoutMs, signal, async (operationSignal) => {
156
- await core.waitForPendingPlugins();
157
- return core.execute(parameters, {
158
- cwd: context.cwd,
159
- ...(operationSignal !== undefined && { signal: operationSignal }),
160
- ...(onUpdate !== undefined && {
161
- onUpdate: (update) => {
162
- onUpdate(update);
176
+ try {
177
+ const config = await loadSearchConfig(
178
+ resolveSearchConfigPaths(process.env, os.homedir(), context.cwd),
179
+ );
180
+ return await runWithSearchTimeout(config.timeoutMs, signal, async (operationSignal) => {
181
+ await core.waitForPendingPlugins();
182
+ const scoped =
183
+ parameters.path !== undefined &&
184
+ (typeof parameters.path !== "string" || parameters.path.startsWith("RESULT#"));
185
+ const scope = scoped ? targets.resolve(parameters.path, context.cwd) : undefined;
186
+ if (scope !== undefined) {
187
+ await targets.verify(scope, operationSignal);
188
+ if (/^(?:files|symbol|graph|process):/u.test(parameters.query))
189
+ throw new Error("This query provider does not support result scopes yet.");
190
+ }
191
+ return core.execute(
192
+ {
193
+ ...parameters,
194
+ path:
195
+ typeof parameters.path === "string" && !scoped ? parameters.path : undefined,
196
+ },
197
+ {
198
+ cwd: context.cwd,
199
+ ...(scope === undefined ? {} : { scope }),
200
+ ...(operationSignal !== undefined && { signal: operationSignal }),
201
+ ...(onUpdate !== undefined && { onUpdate }),
163
202
  },
164
- }),
203
+ );
165
204
  });
166
- });
205
+ } catch (error) {
206
+ if (signal?.aborted) throw error;
207
+ const message = error instanceof Error ? error.message : String(error);
208
+ return withStructuredResult(
209
+ {
210
+ content: [{ type: "text", text: message }],
211
+ details: { failure: { code: "RESOLVE_FAILED", message } },
212
+ },
213
+ searchDataSchema,
214
+ {
215
+ status: "error",
216
+ errors: [resultError(error, "SEARCH_FAILED")],
217
+ },
218
+ );
219
+ }
167
220
  },
168
221
  },
169
222
  interceptionRendering,
@@ -179,7 +232,15 @@ export default async function registerSearchCore(
179
232
  function searchCallDetails(arguments_: SearchParameters): ToolCallHeaderDetail[] {
180
233
  return [
181
234
  { label: "query", value: JSON.stringify(arguments_.query) },
182
- ...optionalDetail("path", arguments_.path),
235
+ ...optionalDetail(
236
+ "path",
237
+ arguments_.path === undefined
238
+ ? undefined
239
+ : typeof arguments_.path === "string"
240
+ ? arguments_.path
241
+ : "result scope",
242
+ ),
243
+ ...optionalDetail("navigation", arguments_.navigation),
183
244
  ...optionalDetail("include", arguments_.include),
184
245
  ...optionalDetail("exclude", arguments_.exclude),
185
246
  ...optionalDetail(
@@ -209,10 +270,15 @@ function fallbackResult(
209
270
  const text = result.content
210
271
  .flatMap((part) => (part.type === "text" ? [part.text] : []))
211
272
  .join("\n");
212
- const preview = options.expanded ? text : text.split("\n").slice(0, 8).join("\n");
213
- const hint =
214
- !options.expanded && text.split("\n").length > 8
215
- ? `\n${theme.fg("dim", `${keyText("app.tools.expand")} to expand`)}`
216
- : "";
217
- return new Text(`${theme.fg("muted", preview)}${hint}`, 0, 0);
273
+ return new ResultPanel(
274
+ {
275
+ summary:
276
+ result.details && typeof result.details === "object" && "failure" in result.details
277
+ ? "Search failed"
278
+ : "Search results",
279
+ rows: text.split("\n").map((line) => ({ kind: "note", text: line })),
280
+ },
281
+ theme,
282
+ options.expanded,
283
+ );
218
284
  }
@@ -1,4 +1,6 @@
1
1
  import { withBlockedToolResult } from "pi-agent-tool-call-interception";
2
+ import { resourceAccesses, resourceScheduler, withStructuredResult } from "pi-agent-resource";
3
+ import { searchDataSchema } from "#src/api/structured-result.js";
2
4
 
3
5
  import type { SearchPlugin } from "#src/api/plugin-protocol.js";
4
6
  import type {
@@ -168,6 +170,9 @@ export function createSearchCore(): SearchCore {
168
170
  return failure("INVALID_REQUEST", "Search query must not be empty");
169
171
  }
170
172
 
173
+ if (request.navigation !== undefined && !request.query.startsWith("symbols:"))
174
+ return failure("INVALID_REQUEST", "navigation is supported only for symbols: queries.");
175
+
171
176
  const snapshot = [...resolvers].sort(
172
177
  (left, right) =>
173
178
  Number(left.registration.fallback === true) -
@@ -179,13 +184,134 @@ export function createSearchCore(): SearchCore {
179
184
  const emptyProtocol = /^[a-z][\w-]*:\s*$/iu.test(request.query);
180
185
  const protocolLike = /^[a-z][\w-]*:/iu.test(request.query);
181
186
  for (const entry of snapshot) {
182
- if (emptyProtocol && !entry.registration.fallback) continue;
187
+ if (context.scope !== undefined && entry.registration.resolver.supportsResultScope !== true)
188
+ continue;
189
+ const structuralProtocol = /^(?:ast|symbols):/u.test(request.query);
190
+ if (entry.registration.fallback && structuralProtocol && context.scope !== undefined)
191
+ continue;
192
+ if (emptyProtocol && !entry.registration.fallback && context.scope === undefined) continue;
183
193
  const resolver = entry.registration.resolver;
184
- let attempt: unknown;
185
-
186
194
  try {
187
- context.signal?.throwIfAborted();
188
- attempt = await resolver.tryResolve(request, context);
195
+ const scope = Promise.resolve().then(async () => {
196
+ const sources = await resolver.readResources?.(request, context);
197
+ if (sources === undefined) return [{ resource: "*", mode: "read" as const }];
198
+ return (
199
+ await Promise.all(
200
+ sources.map((source) => resourceAccesses(source, context.cwd, "read")),
201
+ )
202
+ ).flat();
203
+ });
204
+ const result = await resourceScheduler.run(
205
+ scope,
206
+ async (): Promise<SearchToolResult | undefined> => {
207
+ let attempt: unknown;
208
+
209
+ try {
210
+ context.signal?.throwIfAborted();
211
+ attempt = await resolver.tryResolve(request, context);
212
+ } catch (error) {
213
+ return failure(
214
+ "RESOLVE_FAILED",
215
+ messageFor(error, `Resolver ${resolver.id} failed`),
216
+ resolver.id,
217
+ error,
218
+ );
219
+ }
220
+
221
+ if (!isAttempt(attempt)) {
222
+ return failure(
223
+ "INVALID_RESOLVER_RESULT",
224
+ `Resolver ${resolver.id} returned an invalid result`,
225
+ resolver.id,
226
+ );
227
+ }
228
+
229
+ if (attempt.kind === "not-handled") {
230
+ return undefined;
231
+ }
232
+
233
+ if (attempt.kind === "failed") {
234
+ return failure(
235
+ "RESOLVE_FAILED",
236
+ messageFor(attempt.error, `Resolver ${resolver.id} failed`),
237
+ resolver.id,
238
+ attempt.error,
239
+ );
240
+ }
241
+
242
+ try {
243
+ const formatted = await resolver.format(attempt.payload, context);
244
+
245
+ if (!isAgentToolResult(formatted)) {
246
+ return failure(
247
+ "FORMAT_FAILED",
248
+ `Resolver ${resolver.id} formatter returned an invalid result`,
249
+ resolver.id,
250
+ );
251
+ }
252
+
253
+ const data = resolver.toScriptData?.(attempt.payload, formatted.details);
254
+ const missingAdapter = data === undefined;
255
+ return withStructuredResult(
256
+ {
257
+ content:
258
+ entry.registration.fallback && protocolLike
259
+ ? [
260
+ {
261
+ type: "text",
262
+ text: emptyProtocol
263
+ ? "Search fallback: empty protocol query; searched the original text."
264
+ : "Search fallback: unhandled protocol query; searched the original text.",
265
+ },
266
+ ...formatted.content,
267
+ ]
268
+ : formatted.content,
269
+ details: { resolverId: resolver.id, payload: formatted.details },
270
+ ...(audience === "script" && {
271
+ script: {
272
+ resolverId: resolver.id,
273
+ data: attempt.payload,
274
+ details: formatted.details,
275
+ },
276
+ }),
277
+ ...(formatted.usage !== undefined && { usage: formatted.usage }),
278
+ },
279
+ searchDataSchema,
280
+ missingAdapter
281
+ ? {
282
+ status: "error",
283
+ errors: [
284
+ {
285
+ code: "STRUCTURED_ADAPTER_REQUIRED",
286
+ message: `Search resolver ${resolver.id} must provide toScriptData`,
287
+ },
288
+ ],
289
+ }
290
+ : formatted.isError
291
+ ? {
292
+ status: "error",
293
+ data,
294
+ errors: [
295
+ {
296
+ code: "RESOLVE_FAILED",
297
+ message: `Search resolver ${resolver.id} returned an error`,
298
+ },
299
+ ],
300
+ }
301
+ : { status: "success", data, errors: [] },
302
+ );
303
+ } catch (error) {
304
+ return failure(
305
+ "FORMAT_FAILED",
306
+ messageFor(error, `Resolver ${resolver.id} formatter failed`),
307
+ resolver.id,
308
+ error,
309
+ );
310
+ }
311
+ },
312
+ context.signal,
313
+ );
314
+ if (result !== undefined) return result;
189
315
  } catch (error) {
190
316
  return failure(
191
317
  "RESOLVE_FAILED",
@@ -194,70 +320,6 @@ export function createSearchCore(): SearchCore {
194
320
  error,
195
321
  );
196
322
  }
197
-
198
- if (!isAttempt(attempt)) {
199
- return failure(
200
- "INVALID_RESOLVER_RESULT",
201
- `Resolver ${resolver.id} returned an invalid result`,
202
- resolver.id,
203
- );
204
- }
205
-
206
- if (attempt.kind === "not-handled") {
207
- continue;
208
- }
209
-
210
- if (attempt.kind === "failed") {
211
- return failure(
212
- "RESOLVE_FAILED",
213
- messageFor(attempt.error, `Resolver ${resolver.id} failed`),
214
- resolver.id,
215
- attempt.error,
216
- );
217
- }
218
-
219
- try {
220
- const formatted = await resolver.format(attempt.payload, context);
221
-
222
- if (!isAgentToolResult(formatted)) {
223
- return failure(
224
- "FORMAT_FAILED",
225
- `Resolver ${resolver.id} formatter returned an invalid result`,
226
- resolver.id,
227
- );
228
- }
229
-
230
- return {
231
- content:
232
- entry.registration.fallback && protocolLike
233
- ? [
234
- {
235
- type: "text",
236
- text: emptyProtocol
237
- ? "Search fallback: empty protocol query; searched the original text."
238
- : "Search fallback: unhandled protocol query; searched the original text.",
239
- },
240
- ...formatted.content,
241
- ]
242
- : formatted.content,
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
- }),
251
- ...(formatted.usage !== undefined && { usage: formatted.usage }),
252
- };
253
- } catch (error) {
254
- return failure(
255
- "FORMAT_FAILED",
256
- messageFor(error, `Resolver ${resolver.id} formatter failed`),
257
- resolver.id,
258
- error,
259
- );
260
- }
261
323
  }
262
324
 
263
325
  const reason = `No search resolver handled ${request.query}`;
@@ -361,17 +423,22 @@ function failure(
361
423
  resolverId?: string,
362
424
  cause?: unknown,
363
425
  ): AgentToolResult<SearchToolDetails> {
364
- return {
365
- content: [{ type: "text", text: message }],
366
- details: {
367
- failure: {
368
- code,
369
- message,
370
- ...(resolverId !== undefined && { resolverId }),
371
- ...(cause !== undefined && { cause }),
426
+ return withStructuredResult(
427
+ {
428
+ isError: true,
429
+ content: [{ type: "text", text: message }],
430
+ details: {
431
+ failure: {
432
+ code,
433
+ message,
434
+ ...(resolverId !== undefined && { resolverId }),
435
+ ...(cause !== undefined && { cause }),
436
+ },
372
437
  },
373
438
  },
374
- };
439
+ searchDataSchema,
440
+ { status: "error", errors: [{ code, message }] },
441
+ );
375
442
  }
376
443
 
377
444
  function normalizeDescriptionSource(value: unknown): SearchDescriptionSource {
@@ -1,18 +1,14 @@
1
1
  import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
3
3
 
4
- import { registerBuiltinEditFilter } from "./src/core/builtin-edit-filter.js";
4
+ import { hideBuiltinEdit } from "./src/core/builtin-edit.js";
5
5
  import registerTextEditorCore from "./src/core/extension.js";
6
6
  import { registerTextEditBatching } from "./src/core/text-edit-batch-registrar.js";
7
+ import { registerNativeTextEditBatching } from "./src/core/native-text-edit-batch.js";
7
8
  import { registerTextEditorTools } from "./src/tools/extension.js";
8
9
 
9
10
  export default async function registerTextEditor(pi: ExtensionAPI): Promise<void> {
10
11
  connectAgentDocumentation(pi, [
11
- await loadPackagedAgentGuide({
12
- id: "apply",
13
- description: "Guarded Apply scripting, selections, transactions, and file operations",
14
- triggers: [{ tool: "apply" }],
15
- }),
16
12
  await loadPackagedAgentGuide({
17
13
  id: "editing",
18
14
  description: "Precise standalone text and file edits",
@@ -22,9 +18,10 @@ export default async function registerTextEditor(pi: ExtensionAPI): Promise<void
22
18
  }),
23
19
  ]);
24
20
  const core = await registerTextEditorCore(pi);
25
- registerBuiltinEditFilter(pi);
21
+ hideBuiltinEdit(pi);
26
22
 
27
23
  registerTextEditorTools(pi, core);
28
24
 
29
25
  registerTextEditBatching(pi, core);
26
+ registerNativeTextEditBatching(pi, core);
30
27
  }