pi-agent-ide 0.4.0 → 0.5.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 (410) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +74 -22
  3. package/assets/gallery/apply-editing.png +0 -0
  4. package/assets/gallery/debugging.png +0 -0
  5. package/assets/gallery/read-web.png +0 -0
  6. package/assets/gallery/search-replace.png +0 -0
  7. package/assets/gallery/terminal.png +0 -0
  8. package/assets/gallery/tool-editing.png +0 -0
  9. package/dist/chunk-25CZ5ZIU.js +3 -0
  10. package/dist/chunk-526E364R.js +3 -0
  11. package/dist/chunk-5PLV4HLG.js +1 -0
  12. package/dist/chunk-5QQABP47.js +14 -0
  13. package/dist/{chunk-72EEL2DW.js → chunk-6CZO43OH.js} +1 -1
  14. package/dist/chunk-7ALCBKCW.js +26 -0
  15. package/dist/chunk-AWXVJ5AC.js +1 -0
  16. package/dist/{chunk-GFW5QPQV.js → chunk-DQXPQOF7.js} +1 -1
  17. package/dist/chunk-ESPNEJHK.js +1 -0
  18. package/dist/chunk-G725MARR.js +16 -0
  19. package/dist/{chunk-M5L42DWE.js → chunk-HKXDP2FD.js} +2 -2
  20. package/dist/chunk-IQD6PON5.js +0 -0
  21. package/dist/chunk-IRECDTJG.js +27 -0
  22. package/dist/chunk-J4RTW44E.js +1 -0
  23. package/dist/{chunk-HGPUI7F3.js → chunk-KII2JQC5.js} +1 -1
  24. package/dist/{chunk-TI5GMJ7Q.js → chunk-L7JMDDSD.js} +1 -1
  25. package/dist/{chunk-6DZA4CLO.js → chunk-LY6U5EAD.js} +1 -1
  26. package/dist/{chunk-ERVMDQGX.js → chunk-MGCHOGQD.js} +1 -1
  27. package/dist/chunk-NZYDMBM6.js +1 -0
  28. package/dist/{chunk-Y7ZMR4LT.js → chunk-O6LE42GK.js} +1 -1
  29. package/dist/{chunk-KAB3AYA2.js → chunk-OBNING2A.js} +1 -1
  30. package/dist/chunk-P7XO5CIP.js +2 -0
  31. package/dist/{chunk-VFBLX4TG.js → chunk-T6LX2RX5.js} +1 -1
  32. package/dist/{chunk-AADJ2KIB.js → chunk-U22JNO6N.js} +1 -1
  33. package/dist/chunk-U2JKHKLK.js +0 -0
  34. package/dist/{chunk-DQF5QMJ2.js → chunk-WGGIQ7IJ.js} +1 -1
  35. package/dist/entry-10.js +1 -1
  36. package/dist/entry-11.js +1 -1
  37. package/dist/entry-12.js +1 -1
  38. package/dist/entry-13.js +1 -1
  39. package/dist/entry-14.js +1 -1
  40. package/dist/entry-15.js +1 -0
  41. package/dist/entry-17.js +1 -1
  42. package/dist/entry-18.js +1 -1
  43. package/dist/entry-19.js +1 -1
  44. package/dist/entry-20.js +1 -1
  45. package/dist/entry-21.js +1 -2
  46. package/dist/entry-22.js +2 -1
  47. package/dist/entry-23.js +1 -1
  48. package/dist/entry-24.js +1 -1
  49. package/dist/entry-25.js +1 -1
  50. package/dist/entry-26.js +1 -12
  51. package/dist/entry-27.js +12 -1
  52. package/dist/entry-28.js +1 -1
  53. package/dist/entry-29.js +1 -1
  54. package/dist/entry-30.js +1 -1
  55. package/dist/entry-31.js +1 -4
  56. package/dist/entry-32.js +3 -8
  57. package/dist/entry-33.js +9 -1
  58. package/dist/entry-34.js +1 -1
  59. package/dist/entry-35.js +1 -1
  60. package/dist/entry-36.js +1 -1
  61. package/dist/entry-37.js +1 -1
  62. package/dist/entry-38.js +1 -1
  63. package/dist/entry-39.js +1 -1
  64. package/dist/entry-40.js +1 -18
  65. package/dist/entry-41.js +18 -1
  66. package/dist/entry-42.js +1 -1
  67. package/dist/entry-43.js +1 -1
  68. package/dist/entry-44.js +1 -1
  69. package/dist/entry-45.js +1 -7
  70. package/dist/entry-46.js +7 -11
  71. package/dist/entry-47.js +11 -1
  72. package/dist/entry-48.js +1 -1
  73. package/dist/entry-49.js +1 -1
  74. package/dist/entry-50.js +1 -1
  75. package/dist/entry-51.js +1 -1
  76. package/dist/entry-52.js +1 -1
  77. package/dist/entry-53.js +1 -1
  78. package/dist/entry-54.js +1 -1
  79. package/dist/entry-55.js +1 -0
  80. package/dist/entry-56.js +0 -1
  81. package/dist/entry-57.js +1 -0
  82. package/dist/entry-58.js +0 -1
  83. package/dist/entry-59.js +1 -1
  84. package/dist/entry-60.js +1 -1
  85. package/dist/entry-61.js +1 -1
  86. package/dist/entry-62.js +1 -1
  87. package/dist/entry-63.js +1 -1
  88. package/dist/entry-64.js +1 -0
  89. package/dist/entry-65.js +0 -1
  90. package/dist/entry-66.js +1 -0
  91. package/dist/entry-67.js +0 -1
  92. package/dist/entry-68.js +1 -1
  93. package/dist/entry-69.js +1 -1
  94. package/dist/entry-70.js +1 -123
  95. package/dist/entry-71.js +198 -25
  96. package/dist/entry-72.js +30 -2
  97. package/dist/entry-73.js +2 -1
  98. package/dist/entry-74.js +1 -1
  99. package/dist/entry-75.js +1 -1
  100. package/dist/entry-76.js +3 -3
  101. package/dist/entry-77.js +3 -1
  102. package/dist/entry-78.js +1 -1
  103. package/dist/entry-79.js +1 -1
  104. package/dist/entry-8.js +1 -1
  105. package/dist/entry-80.js +1 -0
  106. package/dist/entry-9.js +1 -1
  107. package/dist/pi-agent-ide.js +3 -3
  108. package/docs/configuration.md +1 -1
  109. package/docs/development.md +0 -6
  110. package/docs/user-hooks.md +68 -0
  111. package/node_modules/pi-agent-doctor/package.json +6 -6
  112. package/node_modules/pi-agent-doctor/runtime/entry-21.js +1 -0
  113. package/node_modules/pi-agent-doctor/src/catalog.ts +9 -1
  114. package/node_modules/pi-agent-doctor/src/plugin-protocol.ts +5 -0
  115. package/node_modules/pi-agent-filesystem/package.json +7 -7
  116. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  117. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  118. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  119. package/node_modules/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  120. package/node_modules/pi-agent-ide-ast/package.json +32 -11
  121. package/node_modules/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  122. package/node_modules/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  123. package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  124. package/node_modules/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  125. package/node_modules/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  126. package/node_modules/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  127. package/node_modules/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  128. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  129. package/node_modules/pi-agent-ide-changes/index.ts +3 -1
  130. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  131. package/node_modules/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  132. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  133. package/node_modules/pi-agent-ide-formatter/package.json +9 -4
  134. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  135. package/node_modules/pi-agent-ide-lint/package.json +13 -8
  136. package/node_modules/pi-agent-ide-lsp/index.ts +4 -1
  137. package/node_modules/pi-agent-ide-lsp/package.json +15 -10
  138. package/node_modules/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  139. package/node_modules/pi-agent-image/package.json +3 -3
  140. package/node_modules/pi-agent-invariant/package.json +2 -2
  141. package/node_modules/pi-agent-pdf/package.json +3 -3
  142. package/node_modules/pi-agent-read/package.json +11 -11
  143. package/node_modules/pi-agent-read/runtime/entry-40.js +0 -1
  144. package/node_modules/pi-agent-read/runtime/entry-41.js +2 -0
  145. package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  146. package/node_modules/pi-agent-read/src/api/rendering.ts +1 -1
  147. package/node_modules/pi-agent-read/src/api/tools/read.ts +32 -0
  148. package/node_modules/pi-agent-read/src/core/read-core.ts +8 -0
  149. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  150. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  151. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  152. package/node_modules/pi-agent-resource/package.json +2 -2
  153. package/node_modules/pi-agent-search/package.json +7 -7
  154. package/node_modules/pi-agent-search/runtime/entry-45.js +0 -1
  155. package/node_modules/pi-agent-search/src/api/search-parameters.ts +5 -1
  156. package/node_modules/pi-agent-search-text/index.ts +1 -1
  157. package/node_modules/pi-agent-search-text/package.json +9 -9
  158. package/node_modules/pi-agent-search-text/runtime/entry-47.js +1 -0
  159. package/node_modules/pi-agent-search-text/src/resolvers.ts +72 -39
  160. package/node_modules/pi-agent-search-text/src/search-backend.ts +6 -15
  161. package/node_modules/pi-agent-search-text/src/search-presentation.ts +80 -0
  162. package/node_modules/pi-agent-search-text/src/search-renderer.ts +17 -1
  163. package/node_modules/pi-agent-search-text/src/search-result.ts +32 -12
  164. package/node_modules/pi-agent-search-text/src/search-session.ts +33 -4
  165. package/node_modules/pi-agent-text/package.json +3 -3
  166. package/node_modules/pi-agent-text/runtime/entry-49.js +1 -0
  167. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  168. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  169. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  170. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  171. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  172. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  173. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  174. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  175. package/node_modules/pi-agent-text-editor/package.json +25 -25
  176. package/node_modules/pi-agent-text-editor/runtime/entry-70.js +0 -1
  177. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  178. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  179. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  180. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  181. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  182. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  183. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  184. package/node_modules/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  185. package/node_modules/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  186. package/node_modules/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  187. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  188. package/node_modules/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  189. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  190. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  191. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  192. package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -2
  193. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  194. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  195. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  196. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  197. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  198. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  199. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  200. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  201. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  202. package/node_modules/pi-agent-text-editor-renderer/index.ts +5 -0
  203. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  204. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  205. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  206. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  207. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  208. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  209. package/node_modules/pi-agent-tool-ui/runtime/entry-75.js +1 -0
  210. package/node_modules/pi-agent-web/package.json +7 -7
  211. package/node_modules/pi-agent-web/src/resolver.ts +128 -1
  212. package/node_modules/pi-agent-web-html/package.json +3 -3
  213. package/node_modules/pi-agent-web-image/package.json +4 -4
  214. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  215. package/node_modules/pi-agent-web-text/package.json +4 -4
  216. package/node_modules/pi-agent-web-text/runtime/entry-80.js +2 -0
  217. package/package.json +59 -39
  218. package/src/api/hooks.ts +168 -0
  219. package/src/api/text-editor.ts +2 -0
  220. package/src/composite/builtin-extensions.ts +7 -0
  221. package/src/composite/module-labels.ts +8 -0
  222. package/src/composite/preferences.ts +3 -3
  223. package/src/core/reload-resource-store.ts +34 -0
  224. package/src/doctor/tip-provider.ts +1 -0
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-25.js +2 -0
  230. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-22.js +2 -0
  231. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  232. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  233. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  234. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  235. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  236. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-80.js +2 -0
  237. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-76.js +2 -0
  238. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +128 -1
  239. package/src/extensions/pi-agent-read/package.json +11 -11
  240. package/src/extensions/pi-agent-read/runtime/entry-40.js +0 -1
  241. package/src/extensions/pi-agent-read/runtime/entry-41.js +2 -0
  242. package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
  243. package/src/extensions/pi-agent-read/src/api/rendering.ts +1 -1
  244. package/src/extensions/pi-agent-read/src/api/tools/read.ts +32 -0
  245. package/src/extensions/pi-agent-read/src/core/read-core.ts +8 -0
  246. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +38 -4
  247. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +63 -4
  248. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +105 -5
  249. package/src/extensions/pi-agent-search/package.json +7 -7
  250. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
  251. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
  252. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-47.js +1 -0
  253. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-48.js +1 -0
  254. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +72 -39
  255. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +6 -15
  256. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +80 -0
  257. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +17 -1
  258. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +32 -12
  259. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +33 -4
  260. package/src/extensions/pi-agent-search/runtime/entry-45.js +0 -1
  261. package/src/extensions/pi-agent-search/runtime/entry-46.js +2 -0
  262. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +5 -1
  263. package/src/extensions/pi-agent-text-editor/package.json +25 -25
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  265. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-50.js +2 -0
  266. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  267. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-51.js +0 -1
  268. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-52.js +2 -0
  269. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  270. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-53.js +0 -1
  271. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-54.js +2 -0
  272. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +5 -0
  273. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  274. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +59 -0
  275. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  276. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-73.js +2 -0
  277. package/src/extensions/pi-agent-text-editor/runtime/entry-70.js +0 -1
  278. package/src/extensions/pi-agent-text-editor/runtime/entry-71.js +2 -0
  279. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +7 -1
  280. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +3 -0
  281. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  282. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +47 -0
  283. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +6 -1
  284. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +155 -0
  285. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +56 -77
  286. package/src/extensions/pi-agent-text-editor/src/core/apply/mixed-source.ts +7 -12
  287. package/src/extensions/pi-agent-text-editor/src/core/apply/mutation-outcome.ts +2 -0
  288. package/src/extensions/pi-agent-text-editor/src/core/apply/output.ts +37 -8
  289. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +42 -37
  290. package/src/extensions/pi-agent-text-editor/src/core/apply/renderer.ts +51 -15
  291. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +119 -20
  292. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +28 -7
  293. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +387 -0
  294. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -2
  295. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +68 -71
  296. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +4 -4
  297. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +11 -0
  298. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +141 -6
  300. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +123 -4
  301. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -4
  302. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +3 -2
  303. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +9 -4
  304. package/src/plugins/pi-agent-ide-ast/package.json +32 -11
  305. package/src/plugins/pi-agent-ide-ast/runtime/entry-26.js +0 -1
  306. package/src/plugins/pi-agent-ide-ast/runtime/entry-27.js +2 -0
  307. package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +16 -8
  308. package/src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts +151 -0
  309. package/src/plugins/pi-agent-ide-ast/src/ast/outline.ts +22 -17
  310. package/src/plugins/pi-agent-ide-ast/src/ast/syntax-tree.ts +25 -0
  311. package/src/plugins/pi-agent-ide-ast/src/doctor-plugin.ts +52 -1
  312. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +4 -1
  313. package/src/plugins/pi-agent-ide-changes/index.ts +3 -1
  314. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  315. package/src/plugins/pi-agent-ide-changes/runtime/entry-28.js +0 -1
  316. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +42 -9
  317. package/src/plugins/pi-agent-ide-debugger/index.ts +573 -0
  318. package/src/plugins/pi-agent-ide-debugger/src/breakpoint-view.ts +73 -0
  319. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +306 -0
  320. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +338 -0
  321. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +349 -0
  322. package/src/plugins/pi-agent-ide-debugger/src/process-provider.ts +39 -0
  323. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +152 -0
  324. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +1344 -0
  325. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +14 -0
  326. package/src/plugins/pi-agent-ide-formatter/package.json +9 -4
  327. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  328. package/src/plugins/pi-agent-ide-lint/package.json +13 -8
  329. package/src/plugins/pi-agent-ide-lsp/index.ts +4 -1
  330. package/src/plugins/pi-agent-ide-lsp/package.json +15 -10
  331. package/src/plugins/pi-agent-ide-lsp/runtime/entry-33.js +2 -0
  332. package/src/plugins/pi-agent-ide-processes/index.ts +28 -0
  333. package/src/plugins/pi-agent-ide-processes/src/registry.ts +83 -0
  334. package/src/plugins/pi-agent-ide-processes/src/ui.ts +260 -0
  335. package/src/plugins/pi-agent-ide-terminal/index.ts +19 -13
  336. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +52 -0
  337. package/src/plugins/pi-agent-ide-terminal/src/process-provider.ts +31 -0
  338. package/src/plugins/pi-agent-ide-terminal/src/renderer.ts +24 -58
  339. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +5 -14
  340. package/src/plugins/pi-agent-ide-terminal/src/search.ts +32 -2
  341. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +114 -1
  342. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +23 -29
  343. package/src/plugins/pi-agent-ide-terminal/src/types.ts +14 -1
  344. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +116 -240
  345. package/dist/chunk-3SE372WC.js +0 -3
  346. package/dist/chunk-5MSNYFDE.js +0 -1
  347. package/dist/chunk-7JYQMAEL.js +0 -14
  348. package/dist/chunk-B5KB2I7J.js +0 -3
  349. package/dist/chunk-NMFQGKPE.js +0 -2
  350. package/dist/chunk-OVUYPHDE.js +0 -1
  351. package/dist/chunk-TPIHQYK2.js +0 -14
  352. package/dist/chunk-XSTHESNR.js +0 -25
  353. package/dist/entry-16.js +0 -1
  354. package/docs/evaluation.md +0 -14
  355. package/node_modules/pi-agent-doctor/runtime/entry-16.js +0 -1
  356. package/node_modules/pi-agent-filesystem/runtime/entry-21.js +0 -2
  357. package/node_modules/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  358. package/node_modules/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  359. package/node_modules/pi-agent-image/runtime/entry-33.js +0 -1
  360. package/node_modules/pi-agent-resource/runtime/entry-41.js +0 -1
  361. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  362. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  363. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  364. package/node_modules/pi-agent-text-editor/runtime/entry-54.js +0 -1
  365. package/node_modules/pi-agent-tool-call-interception/runtime/entry-73.js +0 -1
  366. package/node_modules/pi-agent-web/runtime/entry-75.js +0 -2
  367. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-22.js +0 -2
  368. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-21.js +0 -2
  369. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-76.js +0 -2
  370. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-75.js +0 -2
  371. package/src/extensions/pi-agent-read/runtime/entry-36.js +0 -1
  372. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-46.js +0 -2
  373. package/src/extensions/pi-agent-search/runtime/entry-42.js +0 -1
  374. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-49.js +0 -2
  375. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-50.js +0 -1
  376. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-52.js +0 -1
  377. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-71.js +0 -2
  378. package/src/extensions/pi-agent-text-editor/runtime/entry-54.js +0 -1
  379. package/src/plugins/pi-agent-ide-ast/runtime/entry-25.js +0 -1
  380. package/src/plugins/pi-agent-ide-changes/runtime/entry-27.js +0 -1
  381. /package/node_modules/{pi-agent-filesystem-image → pi-agent-filesystem}/runtime/entry-22.js +0 -0
  382. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  383. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  384. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  385. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  386. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  387. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
  388. /package/node_modules/{pi-agent-invariant → pi-agent-image}/runtime/entry-34.js +0 -0
  389. /package/node_modules/{pi-agent-pdf → pi-agent-invariant}/runtime/entry-35.js +0 -0
  390. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-36.js +0 -0
  391. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-42.js +0 -0
  392. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-46.js +0 -0
  393. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-48.js +0 -0
  394. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-71.js +0 -0
  395. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  396. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-74.js +0 -0
  397. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-76.js +0 -0
  398. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  399. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  400. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  401. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-23.js +0 -0
  402. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-pdf}/runtime/entry-24.js +0 -0
  403. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-77.js +0 -0
  404. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-78.js +0 -0
  405. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-79.js +0 -0
  406. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-72.js +0 -0
  407. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-changes}/runtime/entry-29.js +0 -0
  408. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-formatter}/runtime/entry-30.js +0 -0
  409. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-languages}/runtime/entry-31.js +0 -0
  410. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-lint}/runtime/entry-32.js +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-read",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -8,31 +8,31 @@
8
8
  "exports": {
9
9
  "./api/connect-plugin": {
10
10
  "types": "./src/api/connect-plugin.ts",
11
- "default": "./runtime/entry-36.js"
11
+ "default": "./runtime/entry-37.js"
12
12
  },
13
13
  "./api/rendering": {
14
14
  "types": "./src/api/rendering.ts",
15
- "default": "./runtime/entry-37.js"
15
+ "default": "./runtime/entry-38.js"
16
16
  },
17
17
  "./api/plugin-protocol": {
18
18
  "types": "./src/api/plugin-protocol.ts",
19
- "default": "./runtime/entry-38.js"
19
+ "default": "./runtime/entry-39.js"
20
20
  },
21
21
  "./api/tools/read": {
22
22
  "types": "./src/api/tools/read.ts",
23
- "default": "./runtime/entry-39.js"
23
+ "default": "./runtime/entry-40.js"
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "pi-agent-invariant": "0.4.0",
28
- "pi-agent-resource": "0.4.0",
29
- "pi-agent-text": "0.4.0",
30
- "pi-agent-tool-call-interception": "0.4.0",
31
- "pi-agent-tool-ui": "0.4.0"
27
+ "pi-agent-invariant": "0.5.1",
28
+ "pi-agent-resource": "0.5.1",
29
+ "pi-agent-text": "0.5.1",
30
+ "pi-agent-tool-call-interception": "0.5.1",
31
+ "pi-agent-tool-ui": "0.5.1"
32
32
  },
33
33
  "pi": {
34
34
  "extensions": [
35
- "./runtime/entry-40.js"
35
+ "./runtime/entry-41.js"
36
36
  ]
37
37
  },
38
38
  "peerDependencies": {
@@ -1,2 +1 @@
1
1
  export * from "../../../../dist/entry-40.js";
2
- export { default } from "../../../../dist/entry-40.js";
@@ -0,0 +1,2 @@
1
+ export * from "../../../../dist/entry-41.js";
2
+ export { default } from "../../../../dist/entry-41.js";
@@ -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 = 11;
8
+ export const READ_API_VERSION = 13;
9
9
 
10
10
  export const READ_CORE_READY_EVENT = `${READ_PROTOCOL}/core/ready`;
11
11
 
@@ -8,6 +8,6 @@ export interface ReadResultRendererOptions {
8
8
  readonly nativeResources?: boolean;
9
9
  }
10
10
 
11
- export { createReadResultRenderer } from "#src/core/tools/read/read-renderer.js";
11
+ export { COMPACT_READ_ROWS, createReadResultRenderer } from "#src/core/tools/read/read-renderer.js";
12
12
 
13
13
  export type { ReadResultRenderer } from "#src/api/tools/read.js";
@@ -53,9 +53,14 @@ export interface ReadFailure {
53
53
  }
54
54
 
55
55
  export type ReadResultRenderer = NonNullable<ToolDefinition["renderResult"]>;
56
+ export type ReadCallRenderer = NonNullable<ToolDefinition["renderCall"]>;
56
57
 
57
58
  export interface ResourceResolverRegistration {
58
59
  readonly resolver: ResourceResolver;
60
+ /** Selects a resolver-specific call header before resource resolution. */
61
+ readonly matchesCall?: (source: string) => boolean;
62
+ /** Renders only the read call header; result rendering remains independent. */
63
+ readonly renderCall?: ReadCallRenderer;
59
64
  readonly priority?: number;
60
65
  readonly renderResult?: ReadResultRenderer;
61
66
  readonly preserveTruncatedOutput?: boolean;
@@ -247,6 +252,26 @@ export type ReadOutputReducer = (
247
252
  context: ResourceResolverContext,
248
253
  budget: ReadOutputBudget,
249
254
  ) => Promise<ReadToolResult | undefined>;
255
+ /** A resolved Resource access check that runs before Resource.read(). */
256
+ export interface ReadResourceGuardEvent {
257
+ readonly requestedSource: string;
258
+ readonly resourceSource: string;
259
+ readonly resolvedBy: string;
260
+ readonly cwd: string;
261
+ readonly request: ReadRequest;
262
+ readonly audience: "agent" | "script";
263
+ readonly signal?: AbortSignal;
264
+ }
265
+ export type ReadResourceGuardOutcome =
266
+ | { readonly kind: "accepted" }
267
+ | { readonly kind: "rejected"; readonly reason: string };
268
+ export interface ReadResourceGuardRegistration {
269
+ readonly id: string;
270
+ readonly guard: (
271
+ event: ReadResourceGuardEvent,
272
+ ) => ReadResourceGuardOutcome | Promise<ReadResourceGuardOutcome>;
273
+ }
274
+
250
275
  export interface ReadToolPluginApi {
251
276
  /** Registers a format-aware reducer shared by read and composed output. */
252
277
  addOutputReducer(reducer: ReadOutputReducer): void;
@@ -267,6 +292,8 @@ export interface ReadToolPluginApi {
267
292
  addResolver(registration: ResourceResolverRegistration): void;
268
293
  addTargetResolver(registration: TextTargetResolverRegistration): void;
269
294
  addHandler(registration: ReadHandlerRegistration): void;
295
+ /** Registers a fail-closed check over resolved Resources before their content is read. */
296
+ addResourceGuard(registration: ReadResourceGuardRegistration): void;
270
297
  /** Registers a named view whose presenter runs when a request lists the view. */
271
298
  addView(registration: ReadViewRegistration): void;
272
299
  addFragmentResolver(registration: FragmentResolverRegistration): void;
@@ -279,6 +306,8 @@ export interface ReadToolPluginApi {
279
306
  const functionSchema = Type.Function([], Type.Unknown());
280
307
  const resourceResolverRegistrationSchema = Type.Object({
281
308
  resolver: Type.Unknown(),
309
+ matchesCall: Type.Optional(functionSchema),
310
+ renderCall: Type.Optional(functionSchema),
282
311
  priority: Type.Optional(Type.Number()),
283
312
  renderResult: Type.Optional(functionSchema),
284
313
  preserveTruncatedOutput: Type.Optional(Type.Boolean()),
@@ -342,6 +371,9 @@ export function isResourceResolverRegistration(
342
371
  return (
343
372
  registration.resolver.id !== "any" &&
344
373
  (!("priority" in registration) || typeof registration.priority === "number") &&
374
+ (!("matchesCall" in registration) || typeof registration.matchesCall === "function") &&
375
+ (!("renderCall" in registration) || typeof registration.renderCall === "function") &&
376
+ "matchesCall" in registration === "renderCall" in registration &&
345
377
  (!("renderResult" in registration) || typeof registration.renderResult === "function")
346
378
  );
347
379
  }
@@ -14,6 +14,7 @@ import {
14
14
  type PromptDescriptionSource,
15
15
  type ReadHandlerRegistration,
16
16
  type ReadOutputReducer,
17
+ type ReadResourceGuardRegistration,
17
18
  type ReadViewRegistration,
18
19
  type ResourceResolverRegistration,
19
20
  type TextTargetResolverRegistration,
@@ -166,6 +167,7 @@ function createPluginContributionController(
166
167
  const setupPromptContributions: PromptDescriptionSource[] = [];
167
168
 
168
169
  const setupPromptGuidelines: PromptDescriptionSource[] = [];
170
+ const setupResourceGuards: ReadResourceGuardRegistration[] = [];
169
171
  const setupResolvers: ResourceResolverRegistration[] = [];
170
172
  const setupTargetResolvers: TextTargetResolverRegistration[] = [];
171
173
  const setupReadHandlers: ReadHandlerRegistration[] = [];
@@ -200,6 +202,11 @@ function createPluginContributionController(
200
202
  assertAvailable();
201
203
  return read.execute(request, context, audience);
202
204
  },
205
+ addResourceGuard(registration): void {
206
+ assertAvailable();
207
+ if (state === "setup") setupResourceGuards.push(registration);
208
+ else read.registerContributions(pluginId, { resourceGuards: [registration] });
209
+ },
203
210
  addResolver(registration): void {
204
211
  assertAvailable();
205
212
  if (!isResourceResolverRegistration(registration)) {
@@ -305,6 +312,7 @@ function createPluginContributionController(
305
312
  }
306
313
 
307
314
  read.registerContributions(pluginId, {
315
+ resourceGuards: setupResourceGuards,
308
316
  resolvers: setupResolvers,
309
317
  targetResolvers: setupTargetResolvers,
310
318
  handlers: setupReadHandlers,
@@ -1,8 +1,12 @@
1
- import { open, stat } from "node:fs/promises";
1
+ import { open, realpath, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
- import type { ReadRequest, ReadToolResult } from "#src/api/tools/read.js";
5
+ import type {
6
+ ReadRequest,
7
+ ReadResourceGuardRegistration,
8
+ ReadToolResult,
9
+ } from "#src/api/tools/read.js";
6
10
  import { failureResult } from "#src/core/tools/read/read-result.js";
7
11
  import {
8
12
  READ_OUTPUT_MAX_BYTES,
@@ -14,6 +18,7 @@ export async function readRaw(
14
18
  request: ReadRequest,
15
19
  context: { cwd: string; signal?: AbortSignal },
16
20
  audience: "agent" | "script",
21
+ guards: readonly { readonly registration: ReadResourceGuardRegistration }[] = [],
17
22
  ): Promise<ReadToolResult> {
18
23
  const requested = request.path ?? "";
19
24
  try {
@@ -28,9 +33,39 @@ export async function readRaw(
28
33
  throw new Error("Use an integer byte offset and a non-negative integer byte limit");
29
34
  const input = requested.slice(4);
30
35
  if (input.length === 0) throw new Error("Supply a local file after raw:");
31
- const file = input.startsWith("file://")
36
+ const requestedFile = input.startsWith("file://")
32
37
  ? fileURLToPath(input)
33
38
  : path.resolve(context.cwd, input);
39
+ const file = await realpath(requestedFile);
40
+ const source = `raw:${file}`;
41
+ for (const { registration } of guards) {
42
+ try {
43
+ const outcome = await registration.guard({
44
+ requestedSource: requested,
45
+ resourceSource: source,
46
+ resolvedBy: "raw",
47
+ cwd: context.cwd,
48
+ request,
49
+ audience,
50
+ ...(context.signal !== undefined && { signal: context.signal }),
51
+ });
52
+ if (outcome.kind === "rejected")
53
+ return failureResult({
54
+ code: "READ_FAILED",
55
+ source,
56
+ resolverId: "raw",
57
+ message: `Read blocked by hook ${registration.id}: ${outcome.reason}`,
58
+ });
59
+ } catch (error) {
60
+ return failureResult({
61
+ code: "READ_FAILED",
62
+ source,
63
+ resolverId: "raw",
64
+ message: `Read blocked because hook ${registration.id} failed: ${error instanceof Error ? error.message : String(error)}`,
65
+ cause: error,
66
+ });
67
+ }
68
+ }
34
69
  context.signal?.throwIfAborted();
35
70
  if (!(await stat(file)).isFile()) throw new Error("Raw reads require a regular file");
36
71
  const handle = await open(file, "r");
@@ -58,7 +93,6 @@ export async function readRaw(
58
93
  }
59
94
  context.signal?.throwIfAborted();
60
95
  const bytes = buffer.subarray(0, count);
61
- const source = `raw:${file}`;
62
96
  const nextOffset = start + count;
63
97
  const hasMore = nextOffset < stat.size;
64
98
  const header = `${source}\nBytes ${start}..${nextOffset} (end exclusive), ${stat.size} bytes total`;
@@ -271,24 +271,83 @@ function renderContentRows(state: ReadPanelState, width: number): string[] {
271
271
 
272
272
  if (state.options.kind === "code-view") {
273
273
  const rows =
274
- lines === undefined || hasPresentation(lines)
274
+ lines === undefined
275
275
  ? splitTextRows(text).map((line) => renderCodeViewLabel(line, state.theme, false))
276
- : renderCodeViewLines(lines, state.theme);
276
+ : hasPresentation(lines)
277
+ ? renderPresentedCodeViewLines(lines, !state.expanded, state.theme)
278
+ : renderCodeViewLines(lines, state.theme);
277
279
  return nonEmptyRows(rows, state.theme);
278
280
  }
279
281
 
282
+ const presented = lines !== undefined && hasPresentation(lines);
280
283
  const sourceLines =
281
- lines === undefined || hasPresentation(lines)
284
+ lines === undefined || presented
282
285
  ? splitTextRows(text).map(normalizeText)
283
286
  : lines.map(({ content }) => normalizeText(content));
284
287
  const language = languageFor(state.details, lines);
285
288
  const rows =
286
289
  language === undefined
287
290
  ? sourceLines.map((line) => state.theme.fg("toolOutput", line))
288
- : highlightCode(sourceLines.join("\n"), language);
291
+ : presented
292
+ ? renderHighlightedPresentedLines(lines, language, !state.expanded, state.theme)
293
+ : highlightCode(sourceLines.join("\n"), language);
289
294
  return nonEmptyRows(rows, state.theme);
290
295
  }
291
296
 
297
+ function renderHighlightedPresentedLines(
298
+ lines: readonly ReadTextLine[],
299
+ language: string,
300
+ compact: boolean,
301
+ theme: Theme,
302
+ ): string[] {
303
+ return lines.flatMap((line) => {
304
+ const content = normalizeText(line.content);
305
+ const highlighted = highlightCode(content, language)[0] ?? theme.fg("toolOutput", content);
306
+ let sourceRowRendered = false;
307
+ const presented = renderPresentedTextDocument(
308
+ { source: "", content: line.content, lines: [line] },
309
+ { compact },
310
+ );
311
+ return splitTextRows(presented).map((row) => {
312
+ if (!sourceRowRendered && content.length > 0) {
313
+ const offset = row.indexOf(content);
314
+ if (offset >= 0) {
315
+ sourceRowRendered = true;
316
+ return `${theme.fg("toolOutput", row.slice(0, offset))}${highlighted}${theme.fg(
317
+ "toolOutput",
318
+ row.slice(offset + content.length),
319
+ )}`;
320
+ }
321
+ }
322
+ return theme.fg("toolOutput", row);
323
+ });
324
+ });
325
+ }
326
+ function renderPresentedCodeViewLines(
327
+ lines: readonly ReadTextLine[],
328
+ compact: boolean,
329
+ theme: Theme,
330
+ ): string[] {
331
+ return lines.flatMap((line) => {
332
+ const sourceLine = getTextSourceLine(line);
333
+ if (sourceLine === undefined) {
334
+ const presented = renderPresentedTextDocument(
335
+ { source: "", content: line.content, lines: [line] },
336
+ { compact },
337
+ );
338
+ return splitTextRows(presented).map((row) => renderCodeViewLabel(row, theme, false));
339
+ }
340
+ const language = getLanguageFromPath(sourceLine.source);
341
+ if (language === undefined) {
342
+ const presented = renderPresentedTextDocument(
343
+ { source: "", content: line.content, lines: [line] },
344
+ { compact },
345
+ );
346
+ return splitTextRows(presented).map((row) => theme.fg("toolOutput", row));
347
+ }
348
+ return renderHighlightedPresentedLines([line], language, compact, theme);
349
+ });
350
+ }
292
351
  function renderCodeViewLines(lines: readonly ReadTextLine[], theme: Theme): string[] {
293
352
  return lines.map((line) => {
294
353
  const sourceLine = getTextSourceLine(line);
@@ -32,6 +32,7 @@ import {
32
32
  type ReadPipelineStage,
33
33
  type ReadResultDetails,
34
34
  type ReadResultRenderer,
35
+ type ReadResourceGuardRegistration,
35
36
  type ReadStageOutcome,
36
37
  type ReadState,
37
38
  type ReadToolResult,
@@ -57,8 +58,15 @@ import { readRaw } from "#src/core/tools/read/raw-read.js";
57
58
 
58
59
  const fallbackReadRenderer = createReadResultRenderer({ kind: "source" });
59
60
 
61
+ interface RegisteredResourceGuard {
62
+ readonly pluginId: string;
63
+ readonly registration: ReadResourceGuardRegistration;
64
+ }
65
+
60
66
  interface RegisteredResolver {
61
67
  readonly resolver: ResourceResolver;
68
+ readonly matchesCall?: (source: string) => boolean;
69
+ readonly renderCall?: NonNullable<ToolDefinition["renderCall"]>;
62
70
  readonly renderResult?: ReadResultRenderer;
63
71
  readonly preserveTruncatedOutput: boolean;
64
72
  readonly priority: number;
@@ -88,6 +96,7 @@ interface ViewContribution {
88
96
  }
89
97
 
90
98
  export interface ReadToolContributions {
99
+ readonly resourceGuards?: readonly ReadResourceGuardRegistration[];
91
100
  readonly resolvers?: readonly ResourceResolverRegistration[];
92
101
  readonly targetResolvers?: readonly TextTargetResolverRegistration[];
93
102
  readonly handlers?: readonly ReadHandlerRegistration[];
@@ -122,6 +131,7 @@ export function createReadTool(
122
131
  order: 0,
123
132
  },
124
133
  ];
134
+ const resourceGuards: RegisteredResourceGuard[] = [];
125
135
  const handlers: RegisteredHandler[] = [];
126
136
  const views: RegisteredView[] = [];
127
137
  const fragments: RegisteredFragment[] = [];
@@ -157,7 +167,14 @@ export function createReadTool(
157
167
  ];
158
168
  },
159
169
  parameters: readParameters,
160
- renderCall: renderReadCall,
170
+ renderCall(arguments_, theme, context) {
171
+ const source = typeof arguments_.path === "string" ? arguments_.path : undefined;
172
+ const renderer =
173
+ source === undefined
174
+ ? undefined
175
+ : resolvers.find(({ matchesCall }) => matchesCall?.(source) === true)?.renderCall;
176
+ return (renderer ?? renderReadCall)(arguments_, theme, context);
177
+ },
161
178
  renderResult(result, options, theme, context) {
162
179
  const resolvedBy = result.details.resolvedBy;
163
180
  const renderer =
@@ -180,6 +197,7 @@ export function createReadTool(
180
197
  temporaryResources,
181
198
  fragments,
182
199
  targetResolvers,
200
+ resourceGuards,
183
201
  );
184
202
  },
185
203
  },
@@ -193,15 +211,25 @@ export function createReadTool(
193
211
  temporaryResources,
194
212
  fragments,
195
213
  targetResolvers,
214
+ resourceGuards,
196
215
  audience,
197
216
  );
198
217
  },
199
218
  registerContributions(pluginId, contributions): void {
219
+ const incomingResourceGuards = [...(contributions.resourceGuards ?? [])];
200
220
  const incomingResolvers = [...(contributions.resolvers ?? [])];
201
221
  const incomingTargetResolvers = [...(contributions.targetResolvers ?? [])];
202
222
  const incomingHandlers = [...(contributions.handlers ?? [])];
203
223
  const incomingViews = [...(contributions.views ?? [])];
204
224
  const incomingFragments = [...(contributions.fragments ?? [])];
225
+ const guardIds = new Set(resourceGuards.map(({ registration }) => registration.id));
226
+ for (const registration of incomingResourceGuards) {
227
+ if (registration.id.trim().length === 0 || typeof registration.guard !== "function")
228
+ throw new TypeError(`Plugin ${pluginId} provided an invalid Resource guard`);
229
+ if (guardIds.has(registration.id))
230
+ throw new Error(`Resource guard ${registration.id} is already registered`);
231
+ guardIds.add(registration.id);
232
+ }
205
233
  validateContributions(pluginId, incomingResolvers, incomingHandlers, resolvers, handlers);
206
234
  validateFragmentRegistrations(pluginId, incomingFragments, fragments);
207
235
  const targetResolverIds = new Set(targetResolvers.map(({ resolver }) => resolver.id));
@@ -236,9 +264,16 @@ export function createReadTool(
236
264
  presenterIds.add(key);
237
265
  }
238
266
 
267
+ for (const registration of incomingResourceGuards)
268
+ resourceGuards.push({ pluginId, registration });
269
+
239
270
  for (const registration of incomingResolvers) {
240
271
  resolvers.push({
241
272
  resolver: registration.resolver,
273
+ ...(registration.matchesCall !== undefined && {
274
+ matchesCall: registration.matchesCall,
275
+ renderCall: registration.renderCall,
276
+ }),
242
277
  ...(registration.renderResult !== undefined && {
243
278
  renderResult: registration.renderResult,
244
279
  }),
@@ -291,9 +326,11 @@ async function executeRead(
291
326
  readonly priority: number;
292
327
  readonly order: number;
293
328
  }[],
329
+ resourceGuards: readonly RegisteredResourceGuard[],
294
330
  audience: "agent" | "script" = "agent",
295
331
  ): Promise<ReadToolResult> {
296
- if (request.path?.startsWith("raw:")) return readRaw(request, resolverContext, audience);
332
+ if (request.path?.startsWith("raw:"))
333
+ return readRaw(request, resolverContext, audience, resourceGuards);
297
334
  resolverContext = { ...resolverContext, audience };
298
335
  const limitOutput: typeof limitReadOutput =
299
336
  audience === "script" ? async (result) => result : limitReadOutput;
@@ -329,6 +366,7 @@ async function executeRead(
329
366
  requestedViews,
330
367
  ignoredViews,
331
368
  audience,
369
+ resourceGuards,
332
370
  );
333
371
  if (targeted !== undefined) return targeted;
334
372
  }
@@ -350,7 +388,12 @@ async function executeRead(
350
388
  return failureResult({ code: "INVALID_REQUEST", message: "No source was provided" });
351
389
  }
352
390
 
353
- let resolved = await resolveSource(pipeline, resolverSnapshot);
391
+ let resolved = await resolveSource(
392
+ pipeline,
393
+ resolverSnapshot,
394
+ resourceGuards,
395
+ request.path ?? source,
396
+ );
354
397
  let anchoredFragment: string | undefined;
355
398
 
356
399
  // Resource-first rule: when reading the whole source fails, split off an anchor fragment
@@ -368,7 +411,12 @@ async function executeRead(
368
411
  if (split !== undefined) {
369
412
  const wholeSource = { result: resolved, pipeline };
370
413
  const barePipeline = { ...pipeline, request: { ...pipeline.request, path: split.source } };
371
- const retried = await resolveSource(barePipeline, resolverSnapshot);
414
+ const retried = await resolveSource(
415
+ barePipeline,
416
+ resolverSnapshot,
417
+ resourceGuards,
418
+ request.path ?? source,
419
+ );
372
420
 
373
421
  if (retried.kind === "continue") {
374
422
  resolved = retried;
@@ -470,6 +518,7 @@ async function resolveTextTargets(
470
518
  requestedViews: ReadonlySet<string>,
471
519
  ignoredViews: readonly string[],
472
520
  audience: "agent" | "script",
521
+ resourceGuards: readonly RegisteredResourceGuard[],
473
522
  ): Promise<ReadToolResult | undefined> {
474
523
  const limitOutput: typeof limitReadOutput =
475
524
  audience === "script" ? async (result) => result : limitReadOutput;
@@ -545,7 +594,12 @@ async function resolveTextTargets(
545
594
  }
546
595
  rangePipeline = preRead.context;
547
596
  }
548
- const resolved = await resolveSource(rangePipeline, resolvers);
597
+ const resolved = await resolveSource(
598
+ rangePipeline,
599
+ resolvers,
600
+ resourceGuards,
601
+ request.path ?? target.source,
602
+ );
549
603
  if (resolved.kind === "return") {
550
604
  return withIgnoredViews(resolved.result, ignoredViews);
551
605
  }
@@ -725,6 +779,8 @@ async function resolveAnchoredOrigin(
725
779
  async function resolveSource(
726
780
  initialContext: ReadPipelineContext,
727
781
  resolvers: readonly RegisteredResolver[],
782
+ resourceGuards: readonly RegisteredResourceGuard[],
783
+ requestedSource: string,
728
784
  ): Promise<ReadStageOutcome> {
729
785
  const source = requiredValue(initialContext.request.path);
730
786
  const resolverContext = initialContext.resolverContext;
@@ -792,6 +848,50 @@ async function resolveSource(
792
848
  };
793
849
  }
794
850
 
851
+ for (const { registration } of resourceGuards) {
852
+ try {
853
+ const outcome = await registration.guard({
854
+ requestedSource,
855
+ resourceSource: resource.source,
856
+ resolvedBy: resolver.id,
857
+ cwd: resolverContext.cwd,
858
+ request: initialContext.request,
859
+ audience: initialContext.audience ?? "agent",
860
+ ...(resolverContext.signal !== undefined && { signal: resolverContext.signal }),
861
+ });
862
+ if (outcome.kind === "rejected")
863
+ return {
864
+ kind: "return",
865
+ result: withBlockedToolResult(
866
+ failureResult({
867
+ code: "READ_FAILED",
868
+ source: resource.source,
869
+ resolverId: resolver.id,
870
+ message: `Read blocked by hook ${registration.id}: ${outcome.reason}`,
871
+ }),
872
+ outcome.reason,
873
+ ),
874
+ };
875
+ } catch (error) {
876
+ return {
877
+ kind: "return",
878
+ result: withBlockedToolResult(
879
+ failureResult({
880
+ code: "READ_FAILED",
881
+ source: resource.source,
882
+ resolverId: resolver.id,
883
+ message: appendErrorMessage(
884
+ `Read blocked because hook ${registration.id} failed`,
885
+ error,
886
+ ),
887
+ cause: error,
888
+ }),
889
+ `Hook ${registration.id} failed`,
890
+ ),
891
+ };
892
+ }
893
+ }
894
+
795
895
  let content: unknown;
796
896
 
797
897
  try {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-search",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -8,24 +8,24 @@
8
8
  "exports": {
9
9
  "./api/connect-plugin": {
10
10
  "types": "./src/api/connect-plugin.ts",
11
- "default": "./runtime/entry-42.js"
11
+ "default": "./runtime/entry-43.js"
12
12
  },
13
13
  "./api/plugin-protocol": {
14
14
  "types": "./src/api/plugin-protocol.ts",
15
- "default": "./runtime/entry-43.js"
15
+ "default": "./runtime/entry-44.js"
16
16
  },
17
17
  "./api/search": {
18
18
  "types": "./src/api/search.ts",
19
- "default": "./runtime/entry-44.js"
19
+ "default": "./runtime/entry-45.js"
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "pi-agent-tool-call-interception": "0.4.0",
24
- "pi-agent-tool-ui": "0.4.0"
23
+ "pi-agent-tool-call-interception": "0.5.1",
24
+ "pi-agent-tool-ui": "0.5.1"
25
25
  },
26
26
  "pi": {
27
27
  "extensions": [
28
- "./runtime/entry-45.js"
28
+ "./runtime/entry-46.js"
29
29
  ]
30
30
  },
31
31
  "peerDependencies": {
@@ -106,7 +106,7 @@ export default async function registerTextSearch(pi: ExtensionAPI): Promise<void
106
106
  "Local queries try literal terms first, then unquoted terms as regex when no literal results exist, then separate words for ordinary multi-word queries. Quoted terms stay literal. Boolean conditions stay intact across fallback. Uppercase AND/OR, infix NOT, ||, and space-separated | are Boolean operators; unspaced | and regex groups/classes belong to regex terms. Parentheses containing Boolean operators group Boolean conditions. regex:<pattern> forces regex-only matching; files:<pattern> searches file paths: glob patterns use *, **, ?, character classes and braces; other queries use case-insensitive subsequence matching. Slash-containing globs match cwd-relative paths; basename globs match at any depth.",
107
107
  "The result says when a query was broadened. Empty or unknown prefixes are searched as plain text. A recognized prefixed query returns its own results or error; it does not silently become a text search.",
108
108
  "SEARCH#HASH:N:line selects one containing line; :match selects its exact match. :all:line selects all unique containing lines and :all:match selects all matches. Read returns containing lines for both forms. A SEARCH resource can be used as a read path or mutation path/anchor; omit the file path for an all-selection spanning files.",
109
- "Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Limited or incomplete searches do not provide :all selections.",
109
+ "Use SEARCH references exactly as returned to select the matching content. A single-result reference becomes stale when its file changes; obtain a fresh result before using it again. An :all reference refreshes the original query when a selected file changes. Search compacts noisy files when the detail limit is exceeded; narrow the query to that file to see individual matches. Compaction does not remove complete :all selections.",
110
110
  ].join("\n"),
111
111
  );
112
112
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-search-text",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -8,23 +8,23 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./index.ts",
11
- "default": "./runtime/entry-46.js"
11
+ "default": "./runtime/entry-47.js"
12
12
  },
13
13
  "./search-session": {
14
14
  "types": "./src/search-session.ts",
15
- "default": "./runtime/entry-47.js"
15
+ "default": "./runtime/entry-48.js"
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "pi-agent-doctor": "0.4.0",
20
- "pi-agent-invariant": "0.4.0",
21
- "pi-agent-search": "0.4.0",
22
- "pi-agent-text": "0.4.0",
23
- "pi-agent-text-editor": "0.4.0"
19
+ "pi-agent-doctor": "0.5.1",
20
+ "pi-agent-invariant": "0.5.1",
21
+ "pi-agent-search": "0.5.1",
22
+ "pi-agent-text": "0.5.1",
23
+ "pi-agent-text-editor": "0.5.1"
24
24
  },
25
25
  "pi": {
26
26
  "extensions": [
27
- "./runtime/entry-46.js"
27
+ "./runtime/entry-47.js"
28
28
  ]
29
29
  },
30
30
  "peerDependencies": {
@@ -1 +1,2 @@
1
1
  export * from "../../../../../../dist/entry-47.js";
2
+ export { default } from "../../../../../../dist/entry-47.js";