pi-agent-ide 0.6.4 → 0.7.1

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 (431) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-AWXVJ5AC.js → chunk-2RTCSZB3.js} +1 -1
  4. package/dist/chunk-2TRHFMCZ.js +11 -0
  5. package/dist/{chunk-WJTHY6AG.js → chunk-4GCWGE2C.js} +1 -1
  6. package/dist/chunk-4XMY4H4V.js +1 -0
  7. package/dist/{chunk-BSICWXMH.js → chunk-64M3SQPG.js} +1 -1
  8. package/dist/{chunk-QEJGED4V.js → chunk-76ZK5ODR.js} +2 -2
  9. package/dist/{chunk-3BBJZSMS.js → chunk-7LD2OQH3.js} +1 -1
  10. package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
  11. package/dist/chunk-CWD4O5PM.js +3 -0
  12. package/dist/chunk-D3WTDA6V.js +2 -0
  13. package/dist/chunk-EAZGN5ND.js +7 -0
  14. package/dist/chunk-GXEGY7GV.js +1 -0
  15. package/dist/chunk-HZEY4GT4.js +2 -0
  16. package/dist/chunk-LEEQIQ7D.js +28 -0
  17. package/dist/chunk-NRZO5KJT.js +9 -0
  18. package/dist/chunk-OMVRLWMX.js +5 -0
  19. package/dist/{chunk-VBICI5YA.js → chunk-PGIVHICI.js} +1 -1
  20. package/dist/{chunk-FBOW7XOV.js → chunk-PKKDDIWW.js} +1 -1
  21. package/dist/chunk-PNU3E7IO.js +3 -0
  22. package/dist/chunk-PS2B6THP.js +3 -0
  23. package/dist/{chunk-FUG2TEKI.js → chunk-QFTBY67N.js} +2 -2
  24. package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
  25. package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
  26. package/dist/chunk-VMTR74FF.js +2 -0
  27. package/dist/{chunk-HPUAIWIH.js → chunk-WMO6RNE2.js} +1 -1
  28. package/dist/chunk-WU6ZK6YD.js +1 -0
  29. package/dist/{chunk-GIRAEVUJ.js → chunk-XH5WN5XA.js} +1 -1
  30. package/dist/chunk-XYS4FSCC.js +12 -0
  31. package/dist/chunk-YP46DVVP.js +2 -0
  32. package/dist/entry-11.js +1 -1
  33. package/dist/entry-13.js +1 -1
  34. package/dist/entry-14.js +1 -1
  35. package/dist/entry-15.js +1 -1
  36. package/dist/entry-17.js +1 -1
  37. package/dist/entry-25.js +2 -2
  38. package/dist/entry-26.js +1 -1
  39. package/dist/entry-27.js +2 -2
  40. package/dist/entry-28.js +1 -1
  41. package/dist/entry-29.js +1 -1
  42. package/dist/entry-30.js +1 -1
  43. package/dist/entry-31.js +12 -9
  44. package/dist/entry-33.js +1 -1
  45. package/dist/entry-37.js +6 -6
  46. package/dist/entry-41.js +1 -1
  47. package/dist/entry-42.js +1 -1
  48. package/dist/entry-43.js +1 -1
  49. package/dist/entry-44.js +1 -1
  50. package/dist/entry-45.js +13 -14
  51. package/dist/entry-46.js +1 -1
  52. package/dist/entry-49.js +1 -1
  53. package/dist/entry-50.js +3 -6
  54. package/dist/entry-51.js +11 -9
  55. package/dist/entry-52.js +1 -1
  56. package/dist/entry-53.js +1 -1
  57. package/dist/entry-54.js +1 -1
  58. package/dist/entry-56.js +1 -1
  59. package/dist/entry-57.js +1 -1
  60. package/dist/entry-58.js +1 -1
  61. package/dist/entry-60.js +1 -1
  62. package/dist/entry-61.js +0 -1
  63. package/dist/entry-62.js +1 -0
  64. package/dist/entry-63.js +0 -1
  65. package/dist/entry-64.js +1 -0
  66. package/dist/entry-65.js +1 -1
  67. package/dist/entry-66.js +1 -1
  68. package/dist/entry-67.js +1 -1
  69. package/dist/entry-68.js +1 -1
  70. package/dist/entry-69.js +1 -1
  71. package/dist/entry-70.js +1 -1
  72. package/dist/entry-71.js +0 -1
  73. package/dist/entry-72.js +1 -0
  74. package/dist/entry-73.js +0 -1
  75. package/dist/entry-74.js +1 -0
  76. package/dist/entry-75.js +1 -1
  77. package/dist/entry-76.js +1 -1
  78. package/dist/entry-77.js +66 -1
  79. package/dist/entry-78.js +14 -325
  80. package/dist/entry-79.js +2 -18
  81. package/dist/entry-80.js +1 -2
  82. package/dist/entry-81.js +1 -1
  83. package/dist/entry-82.js +5 -1
  84. package/dist/entry-83.js +3 -5
  85. package/dist/entry-84.js +1 -3
  86. package/dist/entry-85.js +1 -1
  87. package/dist/entry-86.js +1 -1
  88. package/dist/pi-agent-ide.js +14 -9
  89. package/docs/agent-guides/editing.md +38 -33
  90. package/docs/agent-guides/git-changes.md +1 -1
  91. package/docs/agent-guides/read-resources.md +8 -4
  92. package/docs/agent-guides/search-code.md +34 -2
  93. package/docs/agent-guides/select-code.md +115 -0
  94. package/docs/configuration.md +12 -17
  95. package/docs/development.md +2 -1
  96. package/docs/releases.md +1 -1
  97. package/docs/research/apply-native-capability-matrix.md +174 -0
  98. package/docs/research/apply-read-latency.md +2 -0
  99. package/docs/research/lpt-393-fuzzy-results/file.json +152 -0
  100. package/docs/research/lpt-393-fuzzy-results/repo.json +122 -0
  101. package/docs/research/lpt-393-search-fuzzy-fallback.md +97 -0
  102. package/docs/research/native-codemode-batch-decision.md +2 -0
  103. package/docs/research/native-codemode-batching.md +1 -1
  104. package/docs/structured-results.md +30 -38
  105. package/docs/tools.md +11 -11
  106. package/docs/user-hooks.md +1 -1
  107. package/node_modules/pi-agent-doctor/package.json +1 -1
  108. package/node_modules/pi-agent-documentation/package.json +1 -1
  109. package/node_modules/pi-agent-filesystem/index.ts +7 -6
  110. package/node_modules/pi-agent-filesystem/package.json +7 -7
  111. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  112. package/node_modules/pi-agent-filesystem-jq/index.ts +4 -3
  113. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  114. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  115. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  116. package/node_modules/pi-agent-ide-ast/package.json +15 -10
  117. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  118. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  119. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  120. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  121. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  122. package/node_modules/pi-agent-ide-ast/src/extension.ts +10 -5
  123. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  124. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +142 -27
  125. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  126. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +384 -0
  127. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +41 -0
  128. package/node_modules/pi-agent-ide-ast/src/source-text.ts +92 -0
  129. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +214 -0
  130. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +268 -0
  131. package/node_modules/pi-agent-ide-changes/index.ts +6 -21
  132. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  133. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  134. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  135. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  136. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  137. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  138. package/node_modules/pi-agent-ide-lsp/index.ts +5 -5
  139. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  140. package/node_modules/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  141. package/node_modules/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  142. package/node_modules/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  143. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  144. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  145. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +92 -45
  146. package/node_modules/pi-agent-image/package.json +2 -2
  147. package/node_modules/pi-agent-invariant/package.json +1 -1
  148. package/node_modules/pi-agent-pdf/package.json +2 -2
  149. package/node_modules/pi-agent-read/package.json +7 -7
  150. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  151. package/node_modules/pi-agent-read/src/api/read-parameters.ts +40 -3
  152. package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -1
  153. package/node_modules/pi-agent-read/src/core/extension.ts +18 -1
  154. package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
  155. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  156. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +5 -3
  157. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +17 -3
  158. package/node_modules/pi-agent-resource/package.json +1 -1
  159. package/node_modules/pi-agent-resource/src/index.ts +10 -0
  160. package/node_modules/pi-agent-resource/src/result-targets.ts +407 -0
  161. package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
  162. package/node_modules/pi-agent-search/package.json +5 -5
  163. package/node_modules/pi-agent-search/src/api/fuzzy.ts +208 -0
  164. package/node_modules/pi-agent-search/src/api/presentation.ts +68 -0
  165. package/node_modules/pi-agent-search/src/api/search-parameters.ts +9 -3
  166. package/node_modules/pi-agent-search/src/api/search-scope.ts +22 -0
  167. package/node_modules/pi-agent-search/src/api/search.ts +28 -0
  168. package/node_modules/pi-agent-search/src/api/structured-result.ts +69 -14
  169. package/node_modules/pi-agent-search/src/core/extension.ts +56 -16
  170. package/node_modules/pi-agent-search/src/core/search-core.ts +9 -1
  171. package/node_modules/pi-agent-search-text/index.ts +3 -1
  172. package/node_modules/pi-agent-search-text/package.json +7 -6
  173. package/node_modules/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  174. package/node_modules/pi-agent-search-text/src/resolvers.ts +161 -30
  175. package/node_modules/pi-agent-search-text/src/scoped-search.ts +103 -0
  176. package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -17
  177. package/node_modules/pi-agent-search-text/src/search-renderer.ts +89 -292
  178. package/node_modules/pi-agent-search-text/src/search-result.ts +77 -0
  179. package/node_modules/pi-agent-search-text/src/search-session.ts +96 -11
  180. package/node_modules/pi-agent-text/package.json +2 -2
  181. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  182. package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
  183. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  184. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
  185. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -3
  186. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  187. package/node_modules/pi-agent-text-editor/index.ts +0 -5
  188. package/node_modules/pi-agent-text-editor/package.json +26 -31
  189. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +1 -0
  190. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
  191. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  192. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  193. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  194. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  195. package/node_modules/pi-agent-text-editor/src/core/extension.ts +22 -5
  196. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  197. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -14
  198. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  199. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  200. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  201. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +217 -30
  202. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +22 -0
  203. package/node_modules/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  204. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  205. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +86 -154
  206. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  207. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  208. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
  209. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
  210. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
  211. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  212. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  213. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  214. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  215. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  216. package/node_modules/pi-agent-text-editor-renderer/index.ts +1 -72
  217. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  218. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  219. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  220. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  221. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  222. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  223. package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
  224. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  225. package/node_modules/pi-agent-tool-ui/src/index.ts +7 -0
  226. package/node_modules/pi-agent-tool-ui/src/result-panel.ts +298 -0
  227. package/node_modules/pi-agent-web/index.ts +7 -3
  228. package/node_modules/pi-agent-web/package.json +8 -8
  229. package/node_modules/pi-agent-web/runtime/entry-82.js +2 -0
  230. package/node_modules/pi-agent-web/src/search.ts +111 -2
  231. package/node_modules/pi-agent-web-html/package.json +3 -3
  232. package/node_modules/pi-agent-web-image/package.json +4 -4
  233. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  234. package/node_modules/pi-agent-web-text/package.json +4 -4
  235. package/package.json +35 -36
  236. package/src/composite/module-labels.ts +1 -1
  237. package/src/composite/preferences.ts +0 -5
  238. package/src/composite/text-results.ts +221 -0
  239. package/src/documentation/extension.ts +11 -9
  240. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
  241. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  242. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  243. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +4 -3
  244. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  245. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  246. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  247. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +7 -3
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +2 -0
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +111 -2
  256. package/src/extensions/pi-agent-read/package.json +7 -7
  257. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  258. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +40 -3
  259. package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -1
  260. package/src/extensions/pi-agent-read/src/core/extension.ts +18 -1
  261. package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
  262. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +93 -0
  263. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +5 -3
  264. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +17 -3
  265. package/src/extensions/pi-agent-search/package.json +5 -5
  266. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -1
  267. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -6
  268. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/fuzzy-search.ts +164 -0
  269. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +161 -30
  270. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +103 -0
  271. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -17
  272. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +89 -292
  273. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +77 -0
  274. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +96 -11
  275. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +208 -0
  276. package/src/extensions/pi-agent-search/src/api/presentation.ts +68 -0
  277. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +9 -3
  278. package/src/extensions/pi-agent-search/src/api/search-scope.ts +22 -0
  279. package/src/extensions/pi-agent-search/src/api/search.ts +28 -0
  280. package/src/extensions/pi-agent-search/src/api/structured-result.ts +69 -14
  281. package/src/extensions/pi-agent-search/src/core/extension.ts +56 -16
  282. package/src/extensions/pi-agent-search/src/core/search-core.ts +9 -1
  283. package/src/extensions/pi-agent-text-editor/index.ts +0 -5
  284. package/src/extensions/pi-agent-text-editor/package.json +26 -31
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +65 -4
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -3
  290. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  291. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +1 -72
  292. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  293. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  294. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +19 -5
  295. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +19 -45
  296. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  297. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +1 -0
  298. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
  299. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +3 -1
  300. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +1 -20
  301. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +4 -23
  302. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +2 -2
  303. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +22 -5
  304. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +29 -4
  305. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -14
  306. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +76 -0
  307. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +1 -1
  308. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +168 -0
  309. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +217 -30
  310. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +22 -0
  311. package/src/extensions/pi-agent-text-editor/src/core/result-target-anchors.ts +78 -0
  312. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +175 -0
  313. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +86 -154
  314. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +6 -1
  315. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +0 -75
  316. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +238 -244
  317. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
  318. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +9 -11
  319. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +5 -5
  320. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +5 -5
  321. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -7
  322. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +8 -8
  323. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +8 -3
  324. package/src/pi-agent-ide.ts +4 -7
  325. package/src/plugins/pi-agent-ide-ast/package.json +15 -10
  326. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +193 -0
  327. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +59 -0
  328. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +5 -1
  329. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +204 -0
  330. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +2 -0
  331. package/src/plugins/pi-agent-ide-ast/src/extension.ts +10 -5
  332. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +184 -0
  333. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +142 -27
  334. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +104 -0
  335. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +384 -0
  336. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +41 -0
  337. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +92 -0
  338. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +214 -0
  339. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +268 -0
  340. package/src/plugins/pi-agent-ide-changes/index.ts +6 -21
  341. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  342. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +2 -2
  343. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +11 -40
  344. package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
  345. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
  346. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  347. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  348. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  349. package/src/plugins/pi-agent-ide-lsp/index.ts +5 -5
  350. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  351. package/src/plugins/pi-agent-ide-lsp/src/lsp/client.ts +5 -0
  352. package/src/plugins/pi-agent-ide-lsp/src/lsp/manager.ts +8 -2
  353. package/src/plugins/pi-agent-ide-lsp/src/lsp/project.ts +19 -0
  354. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +204 -118
  355. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +2 -17
  356. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +92 -45
  357. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
  358. package/src/plugins/pi-agent-ide-terminal/src/search.ts +10 -36
  359. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -1
  360. package/src/plugins/pi-agent-ide-vision/index.ts +31 -4
  361. package/dist/chunk-2P2OGO3G.js +0 -2
  362. package/dist/chunk-5J43L2RL.js +0 -11
  363. package/dist/chunk-6EYWFBNG.js +0 -0
  364. package/dist/chunk-7AVXUV4A.js +0 -7
  365. package/dist/chunk-7WCZOO5I.js +0 -1
  366. package/dist/chunk-BAYETTZZ.js +0 -16
  367. package/dist/chunk-BVK5A7ED.js +0 -28
  368. package/dist/chunk-F7NVAC4Q.js +0 -0
  369. package/dist/chunk-FZBCKIJJ.js +0 -1
  370. package/dist/chunk-I5JLCFUX.js +0 -1
  371. package/dist/chunk-KUPHNMUK.js +0 -2
  372. package/dist/chunk-MIZAFRDR.js +0 -1
  373. package/dist/chunk-PJPA5EEE.js +0 -2
  374. package/dist/chunk-PXWDDBBC.js +0 -0
  375. package/dist/chunk-SILJ3OL4.js +0 -9
  376. package/dist/chunk-TQZBVOTT.js +0 -5
  377. package/dist/chunk-VWW3RLUX.js +0 -12
  378. package/dist/chunk-YHUTTZC6.js +0 -2
  379. package/dist/chunk-ZODCBFBL.js +0 -2
  380. package/dist/entry-87.js +0 -1
  381. package/docs/agent-guides/apply.md +0 -333
  382. package/node_modules/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  383. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  384. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  385. package/node_modules/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  386. package/node_modules/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  387. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  388. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  389. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  390. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  391. package/node_modules/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  392. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  393. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  394. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  395. package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  396. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  397. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  398. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  399. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +0 -1
  400. package/node_modules/pi-agent-web-text/runtime/entry-87.js +0 -2
  401. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +0 -2
  402. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +0 -2
  403. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +0 -2
  404. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +0 -2
  405. package/src/extensions/pi-agent-text-editor/src/api/apply-renderer.ts +0 -3
  406. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +0 -159
  407. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +0 -405
  408. package/src/extensions/pi-agent-text-editor/src/core/apply/final-mutations.ts +0 -50
  409. package/src/extensions/pi-agent-text-editor/src/core/apply/format-source.ts +0 -11
  410. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +0 -203
  411. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +0 -55
  412. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +0 -276
  413. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +0 -13
  414. package/src/extensions/pi-agent-text-editor/src/core/apply/queue.ts +0 -25
  415. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +0 -405
  416. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +0 -137
  417. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +0 -369
  418. package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +0 -251
  419. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +0 -168
  420. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +0 -942
  421. /package/node_modules/{pi-agent-text-editor → pi-agent-text-editor-renderer}/runtime/entry-78.js +0 -0
  422. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
  423. /package/node_modules/{pi-agent-tool-call-interception → pi-agent-tool-ui}/runtime/entry-81.js +0 -0
  424. /package/node_modules/{pi-agent-web → pi-agent-web-html}/runtime/entry-83.js +0 -0
  425. /package/node_modules/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  426. /package/node_modules/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  427. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  428. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-html → pi-agent-web-image}/runtime/entry-84.js +0 -0
  429. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-pdf}/runtime/entry-85.js +0 -0
  430. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-text}/runtime/entry-86.js +0 -0
  431. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-renderer → pi-agent-text-editor-stale-anchor}/runtime/entry-79.js +0 -0
@@ -1,6 +1,14 @@
1
1
  import type { ResourceResolver } from "pi-agent-resource";
2
2
  import {
3
3
  selectionData,
4
+ renderSearchMatches,
5
+ FuzzyVocabulary,
6
+ fuzzyLimits,
7
+ isFuzzyQuery,
8
+ rankFuzzyIdentifiers,
9
+ fuzzyCandidateData,
10
+ formatFuzzyCandidate,
11
+ type FuzzyResult,
4
12
  type SearchRequest,
5
13
  type SearchResolver,
6
14
  type SearchSelectionMatch,
@@ -10,6 +18,7 @@ interface WebSearchResult {
10
18
  readonly source: string;
11
19
  readonly matches: readonly SearchSelectionMatch[];
12
20
  readonly complete: boolean;
21
+ readonly fuzzy?: FuzzyResult;
13
22
  }
14
23
 
15
24
  /** Search the same converted HTTP(S) content as Read, without treating URLs as files. */
@@ -66,14 +75,42 @@ export function createWebSearchResolver(web: ResourceResolver): SearchResolver {
66
75
  });
67
76
  }
68
77
  }
78
+ const fuzzy =
79
+ matches.length === 0 && isFuzzyQuery(request.query)
80
+ ? searchFuzzyText(text, source, request.query, context.signal)
81
+ : undefined;
69
82
  return {
70
83
  kind: "resolved",
71
- payload: { source, matches, complete: true } satisfies WebSearchResult,
84
+ payload: {
85
+ source,
86
+ matches,
87
+ complete: true,
88
+ ...(fuzzy === undefined ? {} : { fuzzy }),
89
+ } satisfies WebSearchResult,
72
90
  };
73
91
  },
74
92
  toScriptData(payload) {
75
93
  const result = payload as WebSearchResult;
76
- return selectionData(result.matches, result.complete);
94
+ return {
95
+ ...selectionData(result.matches, result.complete),
96
+ ...(result.fuzzy === undefined
97
+ ? {}
98
+ : {
99
+ fuzzy: {
100
+ ...result.fuzzy,
101
+ candidates: result.fuzzy.candidates.map((candidate) =>
102
+ fuzzyCandidateData(candidate),
103
+ ),
104
+ },
105
+ }),
106
+ };
107
+ },
108
+ renderResult(result, options, theme) {
109
+ const data = result.details as WebSearchResult;
110
+ return renderSearchMatches(data.matches, data.complete, theme, options.expanded, undefined, [
111
+ "Web page · read-only",
112
+ ...(!data.complete ? ["Limit reached · incomplete results"] : []),
113
+ ]);
77
114
  },
78
115
  format(payload) {
79
116
  const result = payload as WebSearchResult;
@@ -82,6 +119,15 @@ export function createWebSearchResolver(web: ResourceResolver): SearchResolver {
82
119
  ? `No matches in ${result.source}`
83
120
  : `${result.matches.length}${result.complete ? "" : "+"} matches in ${result.source}${result.complete ? "" : " (limit reached)"}`;
84
121
  const rows = [heading];
122
+ if (result.fuzzy?.status === "skipped")
123
+ rows.push(`Possible-name fallback skipped: ${result.fuzzy.message}`);
124
+ if (result.fuzzy?.candidates.length)
125
+ rows.push(
126
+ "Possible names — spelling suggestions, not equivalent behavior.",
127
+ ...result.fuzzy.candidates.map((candidate) =>
128
+ formatFuzzyCandidate(fuzzyCandidateData(candidate)),
129
+ ),
130
+ );
85
131
  let bytes = Buffer.byteLength(heading);
86
132
  for (const match of result.matches) {
87
133
  const row = `${result.source}:${match.lineNumber}:${match.startColumn + 1} ${previewMatch(match)}`;
@@ -97,6 +143,69 @@ export function createWebSearchResolver(web: ResourceResolver): SearchResolver {
97
143
  };
98
144
  }
99
145
 
146
+ function searchFuzzyText(
147
+ text: string,
148
+ source: string,
149
+ query: string,
150
+ signal?: AbortSignal,
151
+ ): FuzzyResult | undefined {
152
+ signal?.throwIfAborted();
153
+ const start = performance.now();
154
+ const vocabulary = new FuzzyVocabulary();
155
+ vocabulary.addText(text);
156
+ if (vocabulary.limited)
157
+ return {
158
+ status: "skipped",
159
+ message: "name collection reached its byte or unique-name budget",
160
+ candidates: [],
161
+ };
162
+ const candidates = [];
163
+ for (const name of rankFuzzyIdentifiers(query, vocabulary.names)) {
164
+ signal?.throwIfAborted();
165
+ if (performance.now() - start > fuzzyLimits.timeoutMs)
166
+ return { status: "skipped", message: "extra search reached its time budget", candidates: [] };
167
+ const pattern = new RegExp(name.identifier.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), "gu");
168
+ const matches: SearchSelectionMatch[] = [];
169
+ let complete = true;
170
+ let bytes = 0;
171
+ scan: for (const [index, lineText] of text.split(/\r\n|\n|\r/u).entries()) {
172
+ if (performance.now() - start > fuzzyLimits.timeoutMs)
173
+ return {
174
+ status: "skipped",
175
+ message: "extra search reached its time budget",
176
+ candidates: [],
177
+ };
178
+ signal?.throwIfAborted();
179
+ for (const match of lineText.matchAll(pattern)) {
180
+ const startColumn = match.index;
181
+ const endColumn = startColumn + match[0].length;
182
+ if (
183
+ /[\p{L}\p{N}_$]/u.test(lineText[startColumn - 1] ?? "") ||
184
+ /[\p{L}\p{N}_$]/u.test(lineText[endColumn] ?? "")
185
+ )
186
+ continue;
187
+ bytes += Buffer.byteLength(lineText);
188
+ if (
189
+ matches.length === fuzzyLimits.matchesPerCandidate ||
190
+ bytes > fuzzyLimits.verificationBytes
191
+ ) {
192
+ complete = false;
193
+ break scan;
194
+ }
195
+ matches.push({
196
+ source,
197
+ lineNumber: index + 1,
198
+ startColumn,
199
+ endColumn,
200
+ matchedText: match[0],
201
+ lineText,
202
+ });
203
+ }
204
+ }
205
+ if (matches.length > 0) candidates.push({ ...name, matches, complete });
206
+ }
207
+ return candidates.length === 0 ? undefined : { status: "ready", candidates };
208
+ }
100
209
  function previewMatch(match: SearchSelectionMatch): string {
101
210
  const from = Math.max(0, match.startColumn - 64);
102
211
  const to = Math.min(match.lineText.length, match.startColumn + 192);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-read",
3
- "version": "0.6.4",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -24,12 +24,12 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "pi-agent-documentation": "0.6.4",
28
- "pi-agent-invariant": "0.6.4",
29
- "pi-agent-resource": "0.6.4",
30
- "pi-agent-text": "0.6.4",
31
- "pi-agent-tool-call-interception": "0.6.4",
32
- "pi-agent-tool-ui": "0.6.4"
27
+ "pi-agent-documentation": "0.7.1",
28
+ "pi-agent-invariant": "0.7.1",
29
+ "pi-agent-resource": "0.7.1",
30
+ "pi-agent-text": "0.7.1",
31
+ "pi-agent-tool-call-interception": "0.7.1",
32
+ "pi-agent-tool-ui": "0.7.1"
33
33
  },
34
34
  "pi": {
35
35
  "extensions": [
@@ -5,7 +5,7 @@ import type { ReadToolPluginApi } from "#src/api/tools/read.js";
5
5
 
6
6
  export const READ_PROTOCOL = "pi-agent-read";
7
7
 
8
- export const READ_API_VERSION = 13;
8
+ export const READ_API_VERSION = 14;
9
9
 
10
10
  export const READ_CORE_READY_EVENT = `${READ_PROTOCOL}/core/ready`;
11
11
 
@@ -1,17 +1,18 @@
1
- import { Type } from "typebox";
1
+ import { Type, type TSchema } from "typebox";
2
+ import type { ReadRequest } from "#src/api/tools/read.js";
2
3
 
3
4
  /** Canonical arguments shared by standalone and composed operations. */
4
5
  export const readParameters = Type.Object({
5
6
  path: Type.Optional(
6
7
  Type.String({
7
8
  description:
8
- "What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# reference, or registered protocol source. Supply a path; an empty call cannot select a source.",
9
+ "What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source.",
9
10
  }),
10
11
  ),
11
12
  offset: Type.Optional(
12
13
  Type.Number({
13
14
  description:
14
- "For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor or a SEARCH selection, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit.",
15
+ "For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit.",
15
16
  }),
16
17
  ),
17
18
  limit: Type.Optional(
@@ -27,3 +28,39 @@ export const readParameters = Type.Object({
27
28
  }),
28
29
  ),
29
30
  });
31
+
32
+ /** Rendered plugin syntax grouped by Read parameter. */
33
+ export type ReadParameterText = Partial<Record<keyof ReadRequest, string>>;
34
+
35
+ // Keep the shared schema's metadata stable for Diff; these descriptions belong to Read.
36
+ const coreDescriptions: Record<keyof ReadRequest, string> = {
37
+ path: "What to read: a resource path, unchanged source result or its UUID. Pass the whole result to compose tools. Supply a source; an empty call cannot select one. temp:<id> reads saved complete output until this runtime is disposed. raw:<local-file> reads original bytes from a regular file (relative, absolute or file:// path); raw: does not accept views.",
38
+ offset:
39
+ "For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",
40
+ limit:
41
+ "For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the bounded default read. Explicit ranges on other content require a source-specific handler; otherwise they fail.",
42
+ views:
43
+ "Optional source-specific presentations. Omit for the source's default presentation. Values may include settings after a colon; use the syntax below. Combine views only when their contracts allow it. Unknown views can be ignored and reported in ignoredViews; they do not add capabilities. raw: sources reject views.",
44
+ };
45
+
46
+ /** Build a fresh Read schema snapshot without changing the shared schema or accepted types. */
47
+ export function describeReadParameters(descriptions: ReadParameterText): typeof readParameters {
48
+ const describe = <Schema extends TSchema>(
49
+ schema: Schema,
50
+ parameter: keyof ReadRequest,
51
+ ): Schema => ({
52
+ ...schema,
53
+ description: [coreDescriptions[parameter], descriptions[parameter]]
54
+ .filter((value) => value !== undefined)
55
+ .join("\n"),
56
+ });
57
+ return {
58
+ ...readParameters,
59
+ properties: {
60
+ path: describe(readParameters.properties.path, "path"),
61
+ offset: describe(readParameters.properties.offset, "offset"),
62
+ limit: describe(readParameters.properties.limit, "limit"),
63
+ views: describe(readParameters.properties.views, "views"),
64
+ },
65
+ };
66
+ }
@@ -144,6 +144,8 @@ export interface ReadPipelineContext {
144
144
  /** Data execution keeps full requested content; presentation handlers must not compact it. */
145
145
  readonly audience?: "agent" | "script";
146
146
  readonly request: ReadRequest;
147
+ /** Original RESULT# scope bounds source authority even when Read shows surrounding lines. */
148
+ readonly sourceTarget?: string;
147
149
  readonly resolverContext: ResourceResolverContext;
148
150
  readonly state?: ReadState;
149
151
  readonly result?: ReadToolResult;
@@ -199,6 +201,8 @@ export type ReadScriptData =
199
201
  }
200
202
  | {
201
203
  readonly kind: "text";
204
+ /** Strict source-window handle, independent of preview truncation. */
205
+ readonly target?: string;
202
206
  readonly source: string;
203
207
  readonly content: string;
204
208
  readonly lines: readonly ReadTextLine[];
@@ -265,6 +269,11 @@ export type ReadHandlerRegistration =
265
269
 
266
270
  export type PromptDescriptionSource = string | (() => string | undefined);
267
271
 
272
+ /** Source and view syntax attached to the matching Read parameter. Callbacks are evaluated for each schema snapshot; undefined omits that contribution. */
273
+ export type ReadParameterDescriptions = {
274
+ readonly [Parameter in keyof ReadRequest]?: PromptDescriptionSource;
275
+ };
276
+
268
277
  /** Remaining text budget for a format-aware view of already-read data. */
269
278
  export interface ReadOutputBudget {
270
279
  readonly maxBytes: number;
@@ -321,7 +330,8 @@ export interface ReadToolPluginApi {
321
330
  /** Registers a named view whose presenter runs when a request lists the view. */
322
331
  addView(registration: ReadViewRegistration): void;
323
332
  addFragmentResolver(registration: FragmentResolverRegistration): void;
324
- describe(description: PromptDescriptionSource): void;
333
+ /** Adds one parameter-description map per plugin. This documents capabilities without changing validation or registering them. */
334
+ describe(descriptions: ReadParameterDescriptions): void;
325
335
 
326
336
  /** Adds an operational rule to the read tool's system-prompt guidelines. */
327
337
  addPromptGuideline(guideline: PromptDescriptionSource): void;
@@ -1,4 +1,6 @@
1
1
  import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { connectResultTargets } from "pi-agent-resource";
3
+ import { createReadResultTargetHandler } from "#src/core/tools/read/result-target.js";
2
4
  import { connectAgentDocumentation, loadPackagedAgentGuide } from "pi-agent-documentation";
3
5
  import {
4
6
  ToolCallInterceptionRenderStore,
@@ -35,6 +37,15 @@ export default async function registerReadCore(
35
37
  }),
36
38
  ]);
37
39
  const core = createReadCore(parsePresentation(context?.preferences["ui.read"]));
40
+ const targets = connectResultTargets(pi);
41
+ await core.registerPlugin({
42
+ protocol: READ_PROTOCOL,
43
+ apiVersion: READ_API_VERSION,
44
+ id: "result-targets",
45
+ setup(api) {
46
+ api.addHandler({ stage: "post-read", handler: createReadResultTargetHandler(targets) });
47
+ },
48
+ });
38
49
 
39
50
  const unsubscribeRegistration = pi.events.on(READ_PLUGIN_REGISTER_EVENT, (request) => {
40
51
  if (!isReadPluginRegistrationRequest(request)) {
@@ -49,7 +60,13 @@ export default async function registerReadCore(
49
60
  });
50
61
 
51
62
  const interceptionRendering = new ToolCallInterceptionRenderStore();
52
- pi.registerTool(withToolCallInterceptionRendering(core.read.tool, interceptionRendering));
63
+ const definition = withToolCallInterceptionRendering(core.read.tool, interceptionRendering);
64
+ pi.registerTool(definition);
65
+ pi.on("before_agent_start", async () => {
66
+ await core.waitForPendingPlugins();
67
+ // Pi snapshots schemas when it wraps definitions. Refresh current plugin metadata for this run.
68
+ if (pi.getActiveTools().includes("read")) pi.registerTool(definition);
69
+ });
53
70
  pi.on("tool_result", (event) => {
54
71
  if (event.toolName !== "read" || !isRecord(event.details)) {
55
72
  return;
@@ -12,6 +12,7 @@ import {
12
12
  isTextTargetResolverRegistration,
13
13
  type FragmentResolverRegistration,
14
14
  type PromptDescriptionSource,
15
+ type ReadParameterDescriptions,
15
16
  type ReadHandlerRegistration,
16
17
  type ReadOutputReducer,
17
18
  type ReadResourceGuardRegistration,
@@ -20,6 +21,7 @@ import {
20
21
  type TextTargetResolverRegistration,
21
22
  } from "#src/api/tools/read.js";
22
23
  import { createReadTool, type ReadTool } from "#src/core/tools/tool-read.js";
24
+ import { readParameters, type ReadParameterText } from "#src/api/read-parameters.js";
23
25
 
24
26
  type PluginStatus = "active" | "pending";
25
27
 
@@ -30,7 +32,7 @@ interface PluginLifecycle {
30
32
  interface RegisteredPlugin {
31
33
  readonly lifecycle: PluginLifecycle;
32
34
  readonly plugin: ReadPlugin;
33
- readonly promptContributions: PromptDescriptionSource[];
35
+ readonly parameterDescriptions: ReadParameterDescriptions[];
34
36
 
35
37
  readonly promptGuidelines: PromptDescriptionSource[];
36
38
  readonly ready: Promise<void>;
@@ -46,7 +48,6 @@ export interface ReadCore {
46
48
  readonly read: ReadTool;
47
49
  registerPlugin(plugin: ReadPlugin): Promise<void>;
48
50
  waitForPendingPlugins(): Promise<void>;
49
- renderPluginPromptGuideline(): string | undefined;
50
51
  }
51
52
 
52
53
  export function createReadCore(
@@ -55,7 +56,11 @@ export function createReadCore(
55
56
  const outputReducers: ReadOutputReducer[] = [];
56
57
  const pendingPlugins = new Set<Promise<void>>();
57
58
  const plugins = new Map<string, RegisteredPlugin>();
58
- const read = createReadTool(() => renderPromptGuidelines(plugins), presentation);
59
+ const read = createReadTool(
60
+ () => renderPromptGuidelines(plugins),
61
+ presentation,
62
+ () => renderParameterDescriptions(plugins),
63
+ );
59
64
  let registrationQueue = Promise.resolve();
60
65
 
61
66
  return {
@@ -78,14 +83,14 @@ export function createReadCore(
78
83
  }
79
84
 
80
85
  const lifecycle: PluginLifecycle = { status: "pending" };
81
- const promptContributions: PromptDescriptionSource[] = [];
86
+ const parameterDescriptions: ReadParameterDescriptions[] = [];
82
87
 
83
88
  const promptGuidelines: PromptDescriptionSource[] = [];
84
89
  const contributions = createPluginContributionController(
85
90
  plugin.id,
86
91
  read,
87
92
  promptGuidelines,
88
- promptContributions,
93
+ parameterDescriptions,
89
94
  outputReducers,
90
95
  );
91
96
  const ready = registrationQueue.then(async () => {
@@ -103,7 +108,7 @@ export function createReadCore(
103
108
  lifecycle,
104
109
  plugin,
105
110
  promptGuidelines,
106
- promptContributions,
111
+ parameterDescriptions,
107
112
  ready,
108
113
  };
109
114
 
@@ -128,7 +133,6 @@ export function createReadCore(
128
133
 
129
134
  return ready;
130
135
  },
131
- renderPluginPromptGuideline: () => renderPluginPromptGuideline(plugins),
132
136
  async waitForPendingPlugins(): Promise<void> {
133
137
  await Promise.all(pendingPlugins);
134
138
  },
@@ -159,11 +163,11 @@ function createPluginContributionController(
159
163
  pluginId: string,
160
164
  read: ReadTool,
161
165
  promptGuidelines: PromptDescriptionSource[],
162
- promptContributions: PromptDescriptionSource[],
166
+ parameterDescriptions: ReadParameterDescriptions[],
163
167
  outputReducers: ReadOutputReducer[],
164
168
  ): PluginContributionController {
165
169
  const setupOutputReducers: ReadOutputReducer[] = [];
166
- const setupPromptContributions: PromptDescriptionSource[] = [];
170
+ const setupParameterDescriptions: ReadParameterDescriptions[] = [];
167
171
 
168
172
  const setupPromptGuidelines: PromptDescriptionSource[] = [];
169
173
  const setupResourceGuards: ReadResourceGuardRegistration[] = [];
@@ -273,18 +277,18 @@ function createPluginContributionController(
273
277
  describe(description): void {
274
278
  assertAvailable();
275
279
 
276
- if (setupPromptContributions.length > 0 || promptContributions.length > 0) {
280
+ if (setupParameterDescriptions.length > 0 || parameterDescriptions.length > 0) {
277
281
  throw new Error(`Plugin ${pluginId} provides more than one description`);
278
282
  }
279
283
 
280
- const normalized = normalizeDescriptionSource(description);
284
+ const normalized = normalizeParameterDescriptions(description);
281
285
 
282
286
  if (state === "setup") {
283
- setupPromptContributions.push(normalized);
287
+ setupParameterDescriptions.push(normalized);
284
288
  return;
285
289
  }
286
290
 
287
- promptContributions.push(normalized);
291
+ parameterDescriptions.push(normalized);
288
292
  },
289
293
 
290
294
  addPromptGuideline(guideline): void {
@@ -318,7 +322,7 @@ function createPluginContributionController(
318
322
  views: setupViews,
319
323
  fragments: setupFragmentResolvers,
320
324
  });
321
- promptContributions.push(...setupPromptContributions);
325
+ parameterDescriptions.push(...setupParameterDescriptions);
322
326
  outputReducers.push(...setupOutputReducers);
323
327
 
324
328
  promptGuidelines.push(...setupPromptGuidelines);
@@ -346,32 +350,43 @@ function renderPromptGuidelines(plugins: ReadonlyMap<string, RegisteredPlugin>):
346
350
  return guidelines;
347
351
  }
348
352
 
349
- function renderPluginPromptGuideline(
353
+ function renderParameterDescriptions(
350
354
  plugins: ReadonlyMap<string, RegisteredPlugin>,
351
- ): string | undefined {
352
- const entries: string[] = [];
353
-
354
- for (const registeredPlugin of plugins.values()) {
355
- if (registeredPlugin.lifecycle.status !== "active") {
356
- continue;
357
- }
358
-
359
- const source = registeredPlugin.promptContributions[0];
360
-
361
- if (source === undefined) {
362
- continue;
355
+ ): ReadParameterText {
356
+ const entries: Partial<Record<keyof ReadParameterDescriptions, string[]>> = {};
357
+ for (const plugin of plugins.values()) {
358
+ if (plugin.lifecycle.status !== "active") continue;
359
+ for (const descriptions of plugin.parameterDescriptions) {
360
+ for (const parameter of Object.keys(descriptions) as (keyof ReadParameterDescriptions)[]) {
361
+ const source = descriptions[parameter];
362
+ if (source === undefined) continue;
363
+ const description = renderDescriptionSource(source);
364
+ if (description !== undefined) (entries[parameter] ??= []).push(description);
365
+ }
363
366
  }
367
+ }
368
+ return Object.fromEntries(
369
+ Object.entries(entries).map(([parameter, descriptions]) => [
370
+ parameter,
371
+ [...new Set(descriptions)].join("\n"),
372
+ ]),
373
+ );
374
+ }
364
375
 
365
- const description = renderDescriptionSource(source);
366
-
367
- if (description !== undefined) {
368
- entries.push(description);
376
+ function normalizeParameterDescriptions(value: unknown): ReadParameterDescriptions {
377
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
378
+ throw new TypeError("Read plugin parameter descriptions must be an object");
379
+ }
380
+ const entries = Object.entries(value);
381
+ if (entries.length === 0) throw new Error("Read plugin parameter descriptions are empty");
382
+ const normalized: Partial<Record<keyof ReadParameterDescriptions, PromptDescriptionSource>> = {};
383
+ for (const [parameter, source] of entries) {
384
+ if (!Object.hasOwn(readParameters.properties, parameter)) {
385
+ throw new Error(`Read plugin description names an unknown parameter: ${parameter}`);
369
386
  }
387
+ normalized[parameter as keyof ReadParameterDescriptions] = normalizeDescriptionSource(source);
370
388
  }
371
-
372
- return entries.length === 0
373
- ? undefined
374
- : [...new Set(entries.flatMap((entry) => entry.split("\n")))].join("\n");
389
+ return normalized;
375
390
  }
376
391
 
377
392
  function normalizeDescriptionSource(value: unknown): PromptDescriptionSource {
@@ -0,0 +1,93 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import type { ResultRange, ResultTargetStore } from "pi-agent-resource";
3
+ import type { ReadPostReadHandler } from "#src/api/tools/read.js";
4
+
5
+ /** Attach source authority only when the read still maps to exact filesystem text. */
6
+ export function createReadResultTargetHandler(store: ResultTargetStore): ReadPostReadHandler {
7
+ return async (context) => {
8
+ const state = context.state;
9
+ if (state?.contentKind !== "text" || state.resolvedBy !== "filesystem")
10
+ return { kind: "continue", context };
11
+ let content: string;
12
+ try {
13
+ content = await readFile(state.source, {
14
+ encoding: "utf8",
15
+ signal: context.resolverContext.signal,
16
+ });
17
+ } catch {
18
+ context.resolverContext.signal?.throwIfAborted();
19
+ return { kind: "continue", context };
20
+ }
21
+ if (content !== state.text.content) return { kind: "continue", context };
22
+ const input =
23
+ context.sourceTarget === undefined
24
+ ? undefined
25
+ : store.resolve(context.sourceTarget, context.resolverContext.cwd);
26
+ const sources = input?.targets.filter((target) => target.source === state.source);
27
+ if (sources?.some((target) => target.expectedContent !== content))
28
+ return { kind: "continue", context };
29
+ return {
30
+ kind: "continue",
31
+ context,
32
+ transform(result) {
33
+ const script = result.script;
34
+ if (result.isError || script?.kind !== "text" || script.source !== state.source)
35
+ return result;
36
+ if (
37
+ !script.lines.every((line) => {
38
+ const original = state.text.lines[line.lineNumber - 1];
39
+ return original?.content === line.content && original.lineEnding === line.lineEnding;
40
+ })
41
+ )
42
+ return result;
43
+ const first = script.lines[0];
44
+ const last = script.lines.at(-1);
45
+ const window: ResultRange | undefined =
46
+ first === undefined || last === undefined
47
+ ? content.length === 0
48
+ ? {
49
+ start: { lineNumber: 1, column: 0 },
50
+ end: { lineNumber: 1, column: 0 },
51
+ }
52
+ : undefined
53
+ : {
54
+ start: { lineNumber: first.lineNumber, column: 0 },
55
+ end:
56
+ last.lineEnding.length > 0
57
+ ? { lineNumber: last.lineNumber + 1, column: 0 }
58
+ : { lineNumber: last.lineNumber, column: last.content.length },
59
+ linewise: true,
60
+ };
61
+ const ranges =
62
+ window === undefined
63
+ ? []
64
+ : sources === undefined
65
+ ? [window]
66
+ : sources.flatMap((source) =>
67
+ source.ranges.flatMap((range) => intersectRange(range, window)),
68
+ );
69
+ const target = store.register(
70
+ ranges.length === 0 ? [] : [{ source: state.source, expectedContent: content, ranges }],
71
+ context.resolverContext.cwd,
72
+ input?.complete ?? true,
73
+ );
74
+ return { ...result, script: { ...script, target } };
75
+ },
76
+ };
77
+ };
78
+ }
79
+
80
+ function comparePosition(left: ResultRange["start"], right: ResultRange["start"]): number {
81
+ return left.lineNumber - right.lineNumber || left.column - right.column;
82
+ }
83
+
84
+ function intersectRange(range: ResultRange, window: ResultRange): ResultRange[] {
85
+ const start = comparePosition(range.start, window.start) >= 0 ? range.start : window.start;
86
+ const end = comparePosition(range.end, window.end) <= 0 ? range.end : window.end;
87
+ if (
88
+ comparePosition(start, end) > 0 ||
89
+ (comparePosition(start, end) === 0 && comparePosition(range.start, range.end) !== 0)
90
+ )
91
+ return [];
92
+ return [{ start, end }];
93
+ }
@@ -30,6 +30,7 @@ const text = Type.Object(
30
30
  {
31
31
  ...common,
32
32
  kind: Type.Literal("text"),
33
+ target: Type.Optional(Type.String()),
33
34
  lines: Type.Array(line),
34
35
  startLine: Type.Integer(),
35
36
  endLine: Type.Integer(),
@@ -52,7 +53,7 @@ const bytes = Type.Object(
52
53
  const block = Type.Union([
53
54
  Type.Object({ type: Type.Literal("text"), text: Type.String() }, { additionalProperties: false }),
54
55
  Type.Object(
55
- { type: Type.Literal("image"), data: Type.String(), mimeType: Type.String() },
56
+ { type: Type.Literal("image"), mimeType: Type.String() },
56
57
  { additionalProperties: false },
57
58
  ),
58
59
  ]);
@@ -126,6 +127,7 @@ function publicData(value: ReadScriptData): unknown {
126
127
  : {}),
127
128
  };
128
129
  }
130
+ // Image bytes belong to native content, not the composable result record.
129
131
  if (value.kind === "native")
130
132
  return {
131
133
  kind: value.kind,
@@ -133,8 +135,7 @@ function publicData(value: ReadScriptData): unknown {
133
135
  truncated: false,
134
136
  blocks: value.blocks.map((block) => {
135
137
  if (block.type === "text") return { type: block.type, text: block.text };
136
- if (block.type === "image")
137
- return { type: block.type, data: block.data, mimeType: block.mimeType };
138
+ if (block.type === "image") return { type: block.type, mimeType: block.mimeType };
138
139
  throw new TypeError("Custom content requires a structured adapter");
139
140
  }),
140
141
  };
@@ -161,6 +162,7 @@ function publicData(value: ReadScriptData): unknown {
161
162
  endLine: lines.at(-1)?.lineNumber ?? 0,
162
163
  totalLines: value.totalLines,
163
164
  truncated,
165
+ ...(value.target === undefined ? {} : { target: value.target }),
164
166
  ...(value.references === undefined ? {} : { references: value.references }),
165
167
  ...(truncated || endLine < value.totalLines
166
168
  ? { continuation: { path: value.source, offset: endLine + 1 } }