pi-agent-ide 0.7.1 → 0.7.3

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 (307) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +3 -1
  3. package/dist/{chunk-PKKDDIWW.js → chunk-2ZMMRINH.js} +1 -1
  4. package/dist/chunk-6U5OU77O.js +3 -0
  5. package/dist/chunk-BYZSBXUK.js +2 -0
  6. package/dist/{chunk-LEEQIQ7D.js → chunk-CEX73RI5.js} +6 -6
  7. package/dist/chunk-DZWTKF2K.js +1 -0
  8. package/dist/{chunk-WMO6RNE2.js → chunk-EOKEQ3YH.js} +6 -6
  9. package/dist/{chunk-HZEY4GT4.js → chunk-H445SHSJ.js} +2 -2
  10. package/dist/{chunk-4GCWGE2C.js → chunk-HZ5BNF3A.js} +1 -1
  11. package/dist/chunk-IG56UGSO.js +2 -0
  12. package/dist/chunk-IICJXZBU.js +6 -0
  13. package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
  14. package/dist/chunk-MXLSGMRZ.js +3 -0
  15. package/dist/{chunk-76ZK5ODR.js → chunk-NHKPP2AI.js} +13 -13
  16. package/dist/chunk-OB46OPMZ.js +1 -0
  17. package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
  18. package/dist/chunk-QUYXINGZ.js +7 -0
  19. package/dist/{chunk-OMVRLWMX.js → chunk-SBP3ABH4.js} +1 -1
  20. package/dist/{chunk-YP46DVVP.js → chunk-STBJO3Z3.js} +1 -1
  21. package/dist/{chunk-2TRHFMCZ.js → chunk-TXOTNK6B.js} +1 -1
  22. package/dist/chunk-WLZIUMJL.js +1 -0
  23. package/dist/chunk-ZIWPKIBZ.js +1 -0
  24. package/dist/entry-11.js +1 -1
  25. package/dist/entry-13.js +1 -1
  26. package/dist/entry-14.js +1 -1
  27. package/dist/entry-15.js +1 -1
  28. package/dist/entry-17.js +1 -1
  29. package/dist/entry-25.js +1 -1
  30. package/dist/entry-26.js +1 -1
  31. package/dist/entry-27.js +1 -1
  32. package/dist/entry-28.js +1 -1
  33. package/dist/entry-29.js +1 -1
  34. package/dist/entry-31.js +12 -11
  35. package/dist/entry-33.js +3 -1
  36. package/dist/entry-37.js +6 -6
  37. package/dist/entry-42.js +1 -1
  38. package/dist/entry-44.js +1 -1
  39. package/dist/entry-45.js +20 -12
  40. package/dist/entry-46.js +1 -1
  41. package/dist/entry-49.js +1 -1
  42. package/dist/entry-50.js +1 -1
  43. package/dist/entry-51.js +7 -6
  44. package/dist/entry-52.js +1 -1
  45. package/dist/entry-53.js +1 -1
  46. package/dist/entry-54.js +1 -1
  47. package/dist/entry-56.js +1 -1
  48. package/dist/entry-58.js +1 -1
  49. package/dist/entry-60.js +1 -1
  50. package/dist/entry-62.js +1 -1
  51. package/dist/entry-65.js +1 -1
  52. package/dist/entry-66.js +1 -1
  53. package/dist/entry-68.js +1 -1
  54. package/dist/entry-70.js +1 -1
  55. package/dist/entry-75.js +1 -1
  56. package/dist/entry-77.js +63 -49
  57. package/dist/entry-78.js +15 -14
  58. package/dist/entry-79.js +1 -1
  59. package/dist/entry-82.js +5 -5
  60. package/dist/entry-83.js +1 -1
  61. package/dist/entry-84.js +1 -1
  62. package/dist/entry-85.js +1 -1
  63. package/dist/entry-86.js +1 -1
  64. package/dist/pi-agent-ide.js +34 -11
  65. package/docs/agent-guides/editing.md +14 -7
  66. package/docs/agent-guides/git-changes.md +10 -0
  67. package/docs/agent-guides/read-resources.md +9 -46
  68. package/docs/agent-guides/search-code.md +7 -1
  69. package/docs/agent-guides/select-code.md +1 -0
  70. package/docs/agent-guides/terminal.md +9 -1
  71. package/docs/configuration.md +22 -1
  72. package/docs/development.md +4 -0
  73. package/docs/directory-operations.md +45 -0
  74. package/docs/releases.md +12 -0
  75. package/docs/research/codemode-write-context.md +56 -0
  76. package/docs/research/native-codemode-batch-decision.md +2 -0
  77. package/docs/structured-results.md +2 -2
  78. package/docs/tools.md +10 -2
  79. package/docs/user-hooks.md +26 -0
  80. package/node_modules/pi-agent-doctor/package.json +1 -1
  81. package/node_modules/pi-agent-documentation/package.json +1 -1
  82. package/node_modules/pi-agent-filesystem/package.json +7 -7
  83. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  84. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  85. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +4 -1
  86. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  87. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  88. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  89. package/node_modules/pi-agent-ide-ast/src/extension.ts +3 -3
  90. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
  91. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  92. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +8 -6
  93. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +13 -5
  94. package/node_modules/pi-agent-ide-changes/package.json +9 -8
  95. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
  96. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  97. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  98. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  99. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  100. package/node_modules/pi-agent-ide-lsp/index.ts +1 -1
  101. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  102. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
  103. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  104. package/node_modules/pi-agent-image/package.json +2 -2
  105. package/node_modules/pi-agent-invariant/package.json +1 -1
  106. package/node_modules/pi-agent-pdf/package.json +2 -2
  107. package/node_modules/pi-agent-read/package.json +7 -7
  108. package/node_modules/pi-agent-read/src/api/read-parameters.ts +3 -3
  109. package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -0
  110. package/node_modules/pi-agent-read/src/core/extension.ts +1 -1
  111. package/node_modules/pi-agent-read/src/core/read-core.ts +5 -1
  112. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  113. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  114. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  115. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  116. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  117. package/node_modules/pi-agent-resource/package.json +1 -1
  118. package/node_modules/pi-agent-resource/src/index.ts +1 -0
  119. package/node_modules/pi-agent-resource/src/result-targets.ts +6 -3
  120. package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
  121. package/node_modules/pi-agent-search/package.json +5 -5
  122. package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
  123. package/node_modules/pi-agent-search/src/api/search-parameters.ts +2 -2
  124. package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
  125. package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
  126. package/node_modules/pi-agent-search-text/package.json +7 -7
  127. package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
  128. package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
  129. package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
  130. package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
  131. package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
  132. package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
  133. package/node_modules/pi-agent-text/package.json +2 -2
  134. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  135. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  136. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  137. package/node_modules/pi-agent-text-editor/package.json +9 -9
  138. package/node_modules/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
  139. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  140. package/node_modules/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  141. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  142. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  143. package/node_modules/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
  144. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  145. package/node_modules/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
  146. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  147. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  148. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
  149. package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +30 -40
  150. package/node_modules/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  151. package/node_modules/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
  152. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
  153. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
  154. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  155. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
  156. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  157. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
  158. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
  159. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +21 -14
  160. package/node_modules/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
  161. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  162. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
  163. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  164. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
  165. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
  166. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
  167. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
  168. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
  169. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  170. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  171. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
  172. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  173. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  174. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  175. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  176. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
  177. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  178. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  179. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  180. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  181. package/node_modules/pi-agent-web/package.json +7 -7
  182. package/node_modules/pi-agent-web/src/resolver.ts +11 -13
  183. package/node_modules/pi-agent-web-html/package.json +2 -2
  184. package/node_modules/pi-agent-web-image/package.json +3 -3
  185. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  186. package/node_modules/pi-agent-web-text/package.json +3 -3
  187. package/package.json +36 -35
  188. package/src/api/hooks.ts +24 -0
  189. package/src/composite/nested-tool-rendering.ts +184 -77
  190. package/src/composite/output-limits.ts +125 -0
  191. package/src/composite/responses-tools.ts +25 -0
  192. package/src/composite/text-results.ts +158 -7
  193. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  194. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  195. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  196. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +4 -1
  197. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  198. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  202. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  203. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  204. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
  205. package/src/extensions/pi-agent-read/package.json +7 -7
  206. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +3 -3
  207. package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -0
  208. package/src/extensions/pi-agent-read/src/core/extension.ts +1 -1
  209. package/src/extensions/pi-agent-read/src/core/read-core.ts +5 -1
  210. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  211. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  212. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  213. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  214. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  215. package/src/extensions/pi-agent-search/package.json +5 -5
  216. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
  217. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
  218. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
  219. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
  220. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
  221. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
  222. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
  223. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
  224. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +2 -2
  225. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
  226. package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
  227. package/src/extensions/pi-agent-text-editor/package.json +9 -9
  228. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  229. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  230. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  231. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  232. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  233. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +75 -11
  234. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  235. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  236. package/src/extensions/pi-agent-text-editor/src/api/delete-guard.ts +24 -0
  237. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  238. package/src/extensions/pi-agent-text-editor/src/api/mutation-guard.ts +1 -0
  239. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  240. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  241. package/src/extensions/pi-agent-text-editor/src/api/plugin-protocol.ts +4 -1
  242. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  243. package/src/extensions/pi-agent-text-editor/src/core/delete-policy.ts +284 -0
  244. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  245. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  246. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +32 -3
  247. package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +30 -40
  248. package/src/extensions/pi-agent-text-editor/src/core/file-result-targets.ts +1 -1
  249. package/src/extensions/pi-agent-text-editor/src/core/file-transfers.ts +164 -0
  250. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +36 -12
  251. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +25 -1
  252. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  253. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +286 -162
  254. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  255. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
  256. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +46 -11
  257. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +21 -14
  258. package/src/extensions/pi-agent-text-editor/src/core/temporary-directories.ts +96 -0
  259. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  260. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +155 -22
  261. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  262. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +126 -32
  263. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +428 -189
  264. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +66 -0
  265. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +6 -4
  266. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +15 -6
  267. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  268. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  269. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +6 -4
  270. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  271. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  272. package/src/pi-agent-ide.ts +11 -0
  273. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  274. package/src/plugins/pi-agent-ide-ast/src/extension.ts +3 -3
  275. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +9 -4
  276. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  277. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +8 -6
  278. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +13 -5
  279. package/src/plugins/pi-agent-ide-changes/package.json +9 -8
  280. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +82 -4
  281. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  282. package/src/plugins/pi-agent-ide-debugger/index.ts +20 -8
  283. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
  284. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
  285. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +3 -2
  286. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  287. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  288. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  289. package/src/plugins/pi-agent-ide-lsp/index.ts +1 -1
  290. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  291. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +2 -1
  292. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  293. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
  294. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
  295. package/src/plugins/pi-agent-ide-vision/index.ts +1 -0
  296. package/src/post-edit/gate.ts +13 -2
  297. package/dist/chunk-4XMY4H4V.js +0 -1
  298. package/dist/chunk-64M3SQPG.js +0 -3
  299. package/dist/chunk-CWD4O5PM.js +0 -3
  300. package/dist/chunk-D3WTDA6V.js +0 -2
  301. package/dist/chunk-EAZGN5ND.js +0 -7
  302. package/dist/chunk-GXEGY7GV.js +0 -1
  303. package/dist/chunk-MBUXFKIW.js +0 -3
  304. package/dist/chunk-PGIVHICI.js +0 -1
  305. package/dist/chunk-VMTR74FF.js +0 -2
  306. package/dist/chunk-WU6ZK6YD.js +0 -1
  307. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
@@ -23,7 +23,9 @@ export async function readRaw(
23
23
  const requested = request.path ?? "";
24
24
  try {
25
25
  if ((request.views?.length ?? 0) > 0)
26
- throw new Error("Raw byte reads do not accept text views");
26
+ throw new Error(
27
+ "Raw byte reads do not accept views. Omit views for bytes, or read the file without raw: to use text views.",
28
+ );
27
29
  const offset = request.offset ?? 0;
28
30
  const limit = request.limit;
29
31
  if (
@@ -97,7 +99,11 @@ export async function readRaw(
97
99
  const hasMore = nextOffset < stat.size;
98
100
  const header = `${source}\nBytes ${start}..${nextOffset} (end exclusive), ${stat.size} bytes total`;
99
101
  const rows = formatRawBytes(bytes, start);
100
- const continuation = hasMore ? `\nUse offset=${nextOffset} to continue in bytes.` : "";
102
+ const continuation = !hasMore
103
+ ? ""
104
+ : length < requestedLength
105
+ ? `\n[Output limited. Read ${JSON.stringify(source)} with offset=${nextOffset} to continue.]`
106
+ : `\nUse offset=${nextOffset} to continue in bytes.`;
101
107
  return {
102
108
  content: [{ type: "text", text: `${header}\n${rows}${continuation}` }],
103
109
  details: {
@@ -239,6 +239,25 @@ export class ReadResultPanel implements Component {
239
239
  compactInput.hasHiddenRows,
240
240
  );
241
241
  const lines = [renderTopBorder(this.state, innerWidth, this.state.theme)];
242
+ const diagnosticStatus = this.state.details.diagnosticStatus;
243
+ if (diagnosticStatus) {
244
+ for (const line of diagnosticStatus.split(/\r\n|\r|\n/u)) {
245
+ for (const row of wrapTextWithAnsi(
246
+ this.state.theme.fg("muted", normalizeText(line)),
247
+ contentWidth,
248
+ )) {
249
+ lines.push(framed(row, innerWidth, this.state.theme));
250
+ }
251
+ }
252
+ }
253
+ for (const warning of this.state.details.viewWarnings ?? []) {
254
+ for (const row of wrapTextWithAnsi(
255
+ this.state.theme.fg("warning", normalizeText(warning)),
256
+ contentWidth,
257
+ )) {
258
+ lines.push(framed(row, innerWidth, this.state.theme));
259
+ }
260
+ }
242
261
 
243
262
  for (const row of rows) {
244
263
  for (const wrappedRow of wrapTextWithAnsi(row, contentWidth)) {
@@ -538,7 +557,25 @@ function cleanText(
538
557
  );
539
558
  }
540
559
 
541
- const text = textBlocks(result);
560
+ const rendered = textBlocks(result);
561
+ const warning = details.viewWarnings?.join("\n");
562
+ let text =
563
+ warning === undefined
564
+ ? rendered
565
+ : rendered === warning
566
+ ? ""
567
+ : rendered.startsWith(`${warning}\n`)
568
+ ? rendered.slice(warning.length + 1)
569
+ : rendered;
570
+ const diagnosticStatus = details.diagnosticStatus;
571
+ if (diagnosticStatus !== undefined) {
572
+ text =
573
+ text === diagnosticStatus
574
+ ? ""
575
+ : text.startsWith(`${diagnosticStatus}\n`)
576
+ ? text.slice(diagnosticStatus.length + 1)
577
+ : text;
578
+ }
542
579
 
543
580
  if (
544
581
  details.truncation === undefined &&
@@ -58,7 +58,8 @@ export function projectReadState(
58
58
  code: "UNSUPPORTED_RANGE",
59
59
  source: state.source,
60
60
  resolverId: state.resolvedBy,
61
- message: "Line ranges require textual content",
61
+ message:
62
+ "Line ranges require textual content. Omit offset and limit to read this content without a line range.",
62
63
  });
63
64
  }
64
65
 
@@ -135,13 +136,67 @@ function renderFinalTextLines(
135
136
  .join("");
136
137
  }
137
138
 
139
+ function readFailureMessage(failure: ReadFailure): string {
140
+ let cause = failure.cause;
141
+ let error: Error | undefined;
142
+ const visited = new Set<Error>();
143
+ while (cause instanceof Error && !visited.has(cause)) {
144
+ visited.add(cause);
145
+ error = cause;
146
+ cause = cause.cause;
147
+ }
148
+ const code = error !== undefined && "code" in error ? error.code : undefined;
149
+ let reason = error?.message || failure.message;
150
+ if (code === "ENOENT")
151
+ reason = failure.candidates?.length
152
+ ? "Source not found."
153
+ : "Source not found. Search for the correct path.";
154
+ else if (code === "EACCES" || code === "EPERM") reason = "Access denied.";
155
+ else if (failure.code === "INVALID_RESOLVER_RESULT")
156
+ reason = "The source provider returned an invalid result.";
157
+ else if (failure.code === "INVALID_RESOURCE_CONTENT")
158
+ reason = "The source provider returned invalid content.";
159
+ else if (failure.code === "UNSUPPORTED_CAPABILITY")
160
+ reason = "This source does not support reading.";
161
+ else if (failure.code === "NO_RESOLVER")
162
+ reason = "This source is not supported. Choose a supported source from the path parameter.";
163
+ else if (failure.code === "NO_FRAGMENT_RESOLVER")
164
+ reason = "This anchor is not supported. Read the source without the anchor.";
165
+ if (failure.code === "INVALID_REQUEST")
166
+ reason += ". Supply path with a source or an unchanged result reference.";
167
+ else if (failure.code === "FRAGMENT_FAILED" && failure.source !== undefined)
168
+ reason += `\nRead ${JSON.stringify(failure.source)} with views=["anchors"] and choose a current anchor.`;
169
+ const source = failure.source === undefined ? "" : ` for ${JSON.stringify(failure.source)}`;
170
+ return `Read failed${source}: ${reason}`;
171
+ }
172
+
173
+ /** Describe a caller-cancelled failed Read without changing its private record or exceptions. */
174
+ export function withReadCancellation(
175
+ result: ReadToolResult,
176
+ requestedSource: string | undefined,
177
+ signal: AbortSignal | undefined,
178
+ ): ReadToolResult {
179
+ if (!signal?.aborted || !result.isError) return result;
180
+ const source = result.details.source ?? result.details.failure?.source ?? requestedSource;
181
+ return {
182
+ ...result,
183
+ content: [
184
+ {
185
+ type: "text",
186
+ text: `Read cancelled${source === undefined ? "" : ` for ${JSON.stringify(source)}`}. No completed result was returned.`,
187
+ },
188
+ ],
189
+ };
190
+ }
191
+
192
+ /** Show an actionable failure while retaining the original record for private adapters. */
138
193
  export function failureResult(failure: ReadFailure): ReadToolResult {
139
194
  return {
140
195
  content: [
141
196
  {
142
197
  type: "text",
143
198
  text: [
144
- `${failure.code}: ${failure.message}`,
199
+ readFailureMessage(failure),
145
200
  ...(failure.candidates?.length
146
201
  ? [
147
202
  "",
@@ -43,18 +43,15 @@ import {
43
43
  type ResourceResolverRegistration,
44
44
  type TextTargetResolverRegistration,
45
45
  } from "#src/api/tools/read.js";
46
- import {
47
- limitReadOutput,
48
- READ_OUTPUT_MAX_BYTES,
49
- READ_OUTPUT_MAX_LINES,
50
- } from "#src/core/tools/read/output-truncation.js";
46
+ import { explainReadWindow, limitReadOutput } from "#src/core/tools/read/output-truncation.js";
51
47
  import { createReadResultRenderer, renderReadCall } from "#src/core/tools/read/read-renderer.js";
52
48
  import {
53
49
  createReadState,
54
50
  failureResult,
55
51
  projectReadState,
52
+ withReadCancellation,
56
53
  } from "#src/core/tools/read/read-result.js";
57
- import { TempResourceStore } from "#src/core/tools/read/temp-resource-store.js";
54
+ import { TempResourceStore } from "pi-agent-resource";
58
55
 
59
56
  import {
60
57
  type readParameters,
@@ -116,6 +113,8 @@ export interface ReadToolContributions {
116
113
  export interface ReadTool {
117
114
  /** Shares the read runtime's temporary resource store with composed operations. */
118
115
  saveTemporary(text: string): Promise<string>;
116
+ /** Sets the saver used before agent-facing text is truncated. */
117
+ setOutputSaver(saver: (text: string) => Promise<string>): void;
119
118
  readonly tool: ToolDefinition<typeof readParameters, ReadResultDetails>;
120
119
  execute(
121
120
  request: ReadPipelineContext["request"],
@@ -133,6 +132,7 @@ export function createReadTool(
133
132
  parameterDescriptions?: () => ReadParameterText,
134
133
  ): ReadTool {
135
134
  const temporaryResources = new TempResourceStore();
135
+ let outputSaver: ((text: string) => Promise<string>) | undefined;
136
136
  const resolvers: RegisteredResolver[] = [
137
137
  {
138
138
  resolver: temporaryResources.resolver,
@@ -154,6 +154,9 @@ export function createReadTool(
154
154
 
155
155
  return {
156
156
  saveTemporary: (text) => temporaryResources.save(text),
157
+ setOutputSaver(saver) {
158
+ outputSaver = saver;
159
+ },
157
160
  tool: {
158
161
  name: toolId,
159
162
  exposure: "direct",
@@ -168,9 +171,7 @@ export function createReadTool(
168
171
  label: toolId,
169
172
 
170
173
  promptSnippet: "Read supported sources as text or bytes, with optional views",
171
- get description(): string {
172
- return `Use read to inspect supported resources. path selects the source; offset and limit select a bounded window; views request source-specific presentations. Text output is limited to ${READ_OUTPUT_MAX_LINES} lines or ${READ_OUTPUT_MAX_BYTES / 1024}KB; follow a returned continuation offset or temp: reference when present.`;
173
- },
174
+ description: "Use read to inspect files and other supported resources.",
174
175
  get promptGuidelines(): string[] {
175
176
  return [
176
177
  "Use read to inspect supported sources and search to locate workspace content.",
@@ -226,8 +227,10 @@ export function createReadTool(
226
227
  fragments,
227
228
  targetResolvers,
228
229
  resourceGuards,
230
+ "agent",
231
+ outputSaver,
229
232
  );
230
- return structuredRead(result);
233
+ return structuredRead(withReadCancellation(result, parameters.path, signal));
231
234
  } catch (error) {
232
235
  if (signal?.aborted) throw error;
233
236
  return structuredRead(
@@ -240,8 +243,8 @@ export function createReadTool(
240
243
  }
241
244
  },
242
245
  },
243
- execute(request, context, audience = "agent"): Promise<ReadToolResult> {
244
- return executeRead(
246
+ async execute(request, context, audience = "agent"): Promise<ReadToolResult> {
247
+ const result = await executeRead(
245
248
  request,
246
249
  context,
247
250
  resolvers,
@@ -252,7 +255,9 @@ export function createReadTool(
252
255
  targetResolvers,
253
256
  resourceGuards,
254
257
  audience,
258
+ outputSaver,
255
259
  );
260
+ return withReadCancellation(result, request.path, context.signal);
256
261
  },
257
262
  registerContributions(pluginId, contributions): void {
258
263
  const incomingResourceGuards = [...(contributions.resourceGuards ?? [])];
@@ -370,12 +375,16 @@ async function executeRead(
370
375
  }[],
371
376
  resourceGuards: readonly RegisteredResourceGuard[],
372
377
  audience: "agent" | "script" = "agent",
378
+ outputSaver?: (text: string) => Promise<string>,
373
379
  ): Promise<ReadToolResult> {
374
380
  if (request.path?.startsWith("raw:"))
375
381
  return readRaw(request, resolverContext, audience, resourceGuards);
376
382
  resolverContext = { ...resolverContext, audience };
377
383
  const limitOutput: typeof limitReadOutput =
378
- audience === "script" ? async (result) => result : limitReadOutput;
384
+ audience === "script"
385
+ ? async (result) => result
386
+ : (result, request, fallback, options) =>
387
+ limitReadOutput(result, request, outputSaver ?? fallback, options);
379
388
  const resolverSnapshot = [...resolvers].sort(
380
389
  (left, right) => left.priority - right.priority || left.order - right.order,
381
390
  );
@@ -397,7 +406,18 @@ async function executeRead(
397
406
  ];
398
407
  const requestedViews = new Set(rawRequestedViews.map(viewName));
399
408
  const knownViews = new Set([...viewSnapshot.map(({ registration }) => registration.view)]);
400
- const ignoredViews = rawRequestedViews.filter((view) => !knownViews.has(viewName(view)));
409
+ const explicitViews = [...new Set(request.views ?? [])];
410
+ const nativeViews = new Set(
411
+ viewSnapshot
412
+ .filter(({ registration }) => registration.contentKind === "any")
413
+ .map(({ registration }) => registration.view),
414
+ );
415
+ const viewWarnings: ReadViewWarnings = {
416
+ ignored: explicitViews.filter((view) => !knownViews.has(viewName(view))),
417
+ textOnly: explicitViews.filter(
418
+ (view) => knownViews.has(viewName(view)) && !nativeViews.has(viewName(view)),
419
+ ),
420
+ };
401
421
  if (request.path !== undefined && targetSnapshot.length > 0) {
402
422
  const targeted = await resolveTextTargets(
403
423
  request,
@@ -407,9 +427,10 @@ async function executeRead(
407
427
  handlerSnapshot,
408
428
  viewSnapshot,
409
429
  requestedViews,
410
- ignoredViews,
430
+ viewWarnings,
411
431
  audience,
412
432
  resourceGuards,
433
+ outputSaver,
413
434
  );
414
435
  if (targeted !== undefined) return targeted;
415
436
  }
@@ -419,7 +440,7 @@ async function executeRead(
419
440
  const preRead = await runPreReadHandlers(pipeline, handlerSnapshot);
420
441
 
421
442
  if (preRead.kind === "return") {
422
- return withIgnoredViews(await limitOutput(preRead.result, pipeline.request), ignoredViews);
443
+ return withViewWarnings(await limitOutput(preRead.result, pipeline.request), viewWarnings);
423
444
  }
424
445
 
425
446
  pipeline = preRead.context;
@@ -489,23 +510,23 @@ async function executeRead(
489
510
  }
490
511
 
491
512
  if (pipeline.state?.textMode === "final") {
492
- return withIgnoredViews(
513
+ return withViewWarnings(
493
514
  await limitOutput(
494
515
  projectReadState(pipeline.state, pipeline.request, { originLine: origin, audience }),
495
516
  pipeline.request,
496
517
  undefined,
497
518
  { originLine: origin },
498
519
  ),
499
- ignoredViews,
520
+ viewWarnings,
500
521
  );
501
522
  }
502
523
 
503
524
  const processed = await runReadHandlers(pipeline, handlerSnapshot);
504
525
 
505
526
  if (processed.kind === "return") {
506
- return withIgnoredViews(
527
+ return withViewWarnings(
507
528
  await limitOutput(processed.result, pipeline.request, undefined, { originLine: origin }),
508
- ignoredViews,
529
+ viewWarnings,
509
530
  );
510
531
  }
511
532
 
@@ -523,9 +544,9 @@ async function executeRead(
523
544
  pipeline.request.limit === undefined && pipeline.state?.preserveTruncatedOutput === true
524
545
  ? (text: string): Promise<string> => temporaryResources.save(text)
525
546
  : undefined;
526
- return withIgnoredViews(
547
+ return withViewWarnings(
527
548
  await limitOutput(result, pipeline.request, saveFullOutput, { originLine: origin }),
528
- ignoredViews,
549
+ viewWarnings,
529
550
  );
530
551
  }
531
552
 
@@ -559,12 +580,16 @@ async function resolveTextTargets(
559
580
  handlers: readonly RegisteredHandler[],
560
581
  views: readonly RegisteredView[],
561
582
  requestedViews: ReadonlySet<string>,
562
- ignoredViews: readonly string[],
583
+ viewWarnings: ReadViewWarnings,
563
584
  audience: "agent" | "script",
564
585
  resourceGuards: readonly RegisteredResourceGuard[],
586
+ outputSaver?: (text: string) => Promise<string>,
565
587
  ): Promise<ReadToolResult | undefined> {
566
588
  const limitOutput: typeof limitReadOutput =
567
- audience === "script" ? async (result) => result : limitReadOutput;
589
+ audience === "script"
590
+ ? async (result) => result
591
+ : (result, request, fallback, options) =>
592
+ limitReadOutput(result, request, outputSaver ?? fallback, options);
568
593
  for (const { resolver } of targetResolvers) {
569
594
  let rawAttempt: unknown;
570
595
  try {
@@ -634,7 +659,7 @@ async function resolveTextTargets(
634
659
  const preRead = await runPreReadHandlers(rangePipeline, handlers);
635
660
  if (preRead.kind === "return") {
636
661
  if (preRead.result.isError === true)
637
- return withIgnoredViews(preRead.result, ignoredViews);
662
+ return withViewWarnings(preRead.result, viewWarnings);
638
663
  return preRead.result;
639
664
  }
640
665
  rangePipeline = preRead.context;
@@ -646,12 +671,12 @@ async function resolveTextTargets(
646
671
  request.path ?? target.source,
647
672
  );
648
673
  if (resolved.kind === "return") {
649
- return withIgnoredViews(resolved.result, ignoredViews);
674
+ return withViewWarnings(resolved.result, viewWarnings);
650
675
  }
651
676
  const processed = await runReadHandlers(resolved.context, handlers);
652
677
  if (processed.kind === "return") {
653
678
  if (processed.result.isError === true)
654
- return withIgnoredViews(processed.result, ignoredViews);
679
+ return withViewWarnings(processed.result, viewWarnings);
655
680
  return processed.result;
656
681
  }
657
682
  const presented = await runTextPresenters(processed.context, views, requestedViews);
@@ -660,18 +685,26 @@ async function resolveTextTargets(
660
685
  originLine: range.start.lineNumber,
661
686
  });
662
687
  const postRead = await runPostReadHandlers({ ...presented, result: projected }, handlers);
663
- if (projected.isError === true) return withIgnoredViews(projected, ignoredViews);
688
+ if (projected.isError === true) return withViewWarnings(projected, viewWarnings);
664
689
  const result =
665
690
  postRead.kind === "return" ? postRead.result : requiredValue(postRead.context.result);
666
- if (result.isError === true) return withIgnoredViews(result, ignoredViews);
667
- return result;
691
+ if (result.isError === true) return withViewWarnings(result, viewWarnings);
692
+ return audience === "script"
693
+ ? result
694
+ : explainReadWindow(
695
+ result,
696
+ { ...presented.request, limit: request.limit },
697
+ {
698
+ originLine: range.start.lineNumber,
699
+ },
700
+ );
668
701
  });
669
702
  });
670
703
  const completed = await Promise.allSettled(pending);
671
704
  for (const outcome of completed) {
672
705
  if (outcome.status === "rejected") throw outcome.reason;
673
706
  const result = outcome.value;
674
- if (result.isError === true) return withIgnoredViews(result, ignoredViews);
707
+ if (result.isError === true) return withViewWarnings(result, viewWarnings);
675
708
  for (const block of result.content) {
676
709
  if (block.type === "text") chunks.push(block.text);
677
710
  }
@@ -693,9 +726,9 @@ async function resolveTextTargets(
693
726
  ? { source: request.path, resources }
694
727
  : (firstDetails ?? { source: request.path }),
695
728
  } satisfies ReadToolResult;
696
- return withIgnoredViews(
729
+ return withViewWarnings(
697
730
  await limitOutput(aggregate, { path: request.path, views: request.views }),
698
- ignoredViews,
731
+ viewWarnings,
699
732
  );
700
733
  }
701
734
  return undefined;
@@ -733,7 +766,7 @@ async function resolveAnchoredOrigin(
733
766
  code: "UNSUPPORTED_RANGE",
734
767
  source: state.source,
735
768
  resolverId: state.resolvedBy,
736
- message: "Anchored reads require textual content",
769
+ message: "Anchored reads require textual content. Read this source without an anchor.",
737
770
  });
738
771
  }
739
772
 
@@ -1110,21 +1143,43 @@ function viewName(view: string): string {
1110
1143
  return separator < 0 ? view : view.slice(0, separator);
1111
1144
  }
1112
1145
 
1113
- /** Prepends a note listing unknown view names so the agent can correct the request. */
1114
- function withIgnoredViews(result: ReadToolResult, ignoredViews: readonly string[]): ReadToolResult {
1115
- if (ignoredViews.length === 0) {
1116
- return result;
1117
- }
1146
+ interface ReadViewWarnings {
1147
+ readonly ignored: readonly string[];
1148
+ readonly textOnly: readonly string[];
1149
+ }
1118
1150
 
1119
- const note = `note: ignored unknown views: ${ignoredViews.join(", ")}`;
1120
- const block = result.content[0];
1151
+ /** Reports unused views without changing source data or discarding native content. */
1152
+ function withViewWarnings(result: ReadToolResult, requested: ReadViewWarnings): ReadToolResult {
1153
+ const messages: string[] = [];
1154
+ if (requested.ignored.length > 0) {
1155
+ messages.push(
1156
+ requested.ignored.length === 1
1157
+ ? `Unknown view ignored: ${requested.ignored[0]}. Remove it or choose a supported view from the views parameter.`
1158
+ : `Unknown views ignored: ${requested.ignored.join(", ")}. Remove these entries or choose supported views from the views parameter.`,
1159
+ );
1160
+ }
1161
+ if (result.isError !== true && result.content.some((block) => block.type !== "text")) {
1162
+ for (const view of requested.textOnly) {
1163
+ messages.push(
1164
+ `View not applied: ${view} requires text. Read a text source to use ${viewName(view)}.`,
1165
+ );
1166
+ }
1167
+ }
1168
+ if (messages.length === 0 || result.details.viewWarnings !== undefined) return result;
1169
+ const note = messages.join("\n");
1170
+ const first = result.content[0];
1121
1171
  const content =
1122
- block?.type === "text" ? [{ ...block, text: `${note}\n${block.text}` }] : [...result.content];
1123
-
1172
+ result.content.length === 1 && first?.type === "text"
1173
+ ? [{ ...first, text: `${note}\n${first.text}` }]
1174
+ : [{ type: "text" as const, text: note }, ...result.content];
1124
1175
  return {
1125
1176
  ...result,
1126
1177
  content,
1127
- details: { ...result.details, ignoredViews },
1178
+ details: {
1179
+ ...result.details,
1180
+ ...(requested.ignored.length === 0 ? {} : { ignoredViews: requested.ignored }),
1181
+ viewWarnings: messages,
1182
+ },
1128
1183
  };
1129
1184
  }
1130
1185
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-resource",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "imports": {
@@ -1,5 +1,6 @@
1
1
  export { ResourceScheduler, resourceScheduler, type ResourceAccess } from "./resource-scheduler.js";
2
2
  export { resourceAccesses } from "./resource-access.js";
3
+ export { TempResourceStore, type TempResourceStoreOptions } from "./temp-resource-store.js";
3
4
  export {
4
5
  assertJsonData,
5
6
  MAX_STRUCTURED_BYTES,
@@ -226,18 +226,21 @@ export class ResultTargetStore {
226
226
  const result = this.#results.get(id);
227
227
  // Existing backend selection handles share RESULT# syntax, but never accept an unknown UUID.
228
228
  if (!result && !envelope && input.startsWith(prefix) && this.#entries.has(input)) return input;
229
- if (!result) throw new Error("Result reference expired or unknown; repeat the source tool.");
229
+ if (!result)
230
+ throw new Error(
231
+ "Result reference expired or unknown. Run Read/Search again and use the new result.",
232
+ );
230
233
  if (result.cwd !== path.resolve(cwd)) throw new Error("Result belongs to another worktree.");
231
234
  if (envelope && createHash("sha256").update(input).digest("hex") !== result.digest)
232
235
  throw new Error("Result text changed; pass the original result or its UUID.");
233
236
  for (const resource of result.resources) this.refresh(resource, cwd);
234
237
  if (!this.#results.has(id))
235
- throw new Error("Result reference expired; repeat the source tool.");
238
+ throw new Error("Result reference expired. Run Read/Search again and use the new result.");
236
239
  if (!result.consumable) throw new Error("Only successful source results can be consumed.");
237
240
  for (const reference of result.references) {
238
241
  if (!this.#entries.has(reference)) {
239
242
  this.#results.delete(id);
240
- throw new Error("Result reference expired; repeat the source tool.");
243
+ throw new Error("Result reference expired. Run Read/Search again and use the new result.");
241
244
  }
242
245
  }
243
246
  if (result.references.length === 1) return result.references[0];
@@ -3,7 +3,8 @@ import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import path from "node:path";
5
5
 
6
- import type { AgentContent, ResourceResolutionAttempt, ResourceResolver } from "pi-agent-resource";
6
+ import type { AgentContent } from "./content.js";
7
+ import type { ResourceResolutionAttempt, ResourceResolver } from "./resolver.js";
7
8
 
8
9
  export interface TempResourceStoreOptions {
9
10
  /** Parent folder for this store's private temporary directory. */
@@ -28,12 +29,21 @@ export class TempResourceStore {
28
29
  }
29
30
 
30
31
  /** Saves text and returns a reference owned by this store. Rejects after disposal starts. */
31
- async save(text: string): Promise<string> {
32
+ save(text: string): Promise<string> {
33
+ return this.#startSave(text, false);
34
+ }
35
+
36
+ /** Saves complete text to a private file readable through filesystem and raw byte reads. */
37
+ saveFile(text: string): Promise<string> {
38
+ return this.#startSave(text, true);
39
+ }
40
+
41
+ async #startSave(text: string, asFile: boolean): Promise<string> {
32
42
  if (this.#disposal !== undefined) {
33
43
  throw new Error("Temporary resource store is closed");
34
44
  }
35
45
 
36
- const saving = this.#save(text);
46
+ const saving = this.#save(text, asFile);
37
47
  this.#pendingSaves.add(saving);
38
48
  try {
39
49
  return await saving;
@@ -48,14 +58,14 @@ export class TempResourceStore {
48
58
  return this.#disposal;
49
59
  }
50
60
 
51
- async #save(text: string): Promise<string> {
61
+ async #save(text: string, asFile: boolean): Promise<string> {
52
62
  const directory = await this.#getDirectory();
53
63
  const id = randomUUID();
54
64
  const source = `temp:${id}`;
55
65
  const filePath = path.join(directory, `${id}.txt`);
56
- await writeFile(filePath, text, { encoding: "utf8", flag: "wx" });
57
- this.#entries.set(source, filePath);
58
- return source;
66
+ await writeFile(filePath, text, { encoding: "utf8", flag: "wx", mode: 0o600 });
67
+ if (!asFile) this.#entries.set(source, filePath);
68
+ return asFile ? filePath : source;
59
69
  }
60
70
 
61
71
  async #dispose(): Promise<void> {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-search",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -20,10 +20,10 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "pi-agent-documentation": "0.7.1",
24
- "pi-agent-resource": "0.7.1",
25
- "pi-agent-tool-call-interception": "0.7.1",
26
- "pi-agent-tool-ui": "0.7.1"
23
+ "pi-agent-documentation": "0.7.3",
24
+ "pi-agent-resource": "0.7.3",
25
+ "pi-agent-tool-call-interception": "0.7.3",
26
+ "pi-agent-tool-ui": "0.7.3"
27
27
  },
28
28
  "pi": {
29
29
  "extensions": [
@@ -200,7 +200,11 @@ export function formatFuzzyCandidate(candidate: FuzzyCandidateData): string {
200
200
  `Possible name: ${candidate.identifier} (${candidate.reason})`,
201
201
  `${candidate.matchCount}${suffix} ${candidate.matchCount === 1 && candidate.selection.complete ? "match" : "matches"} in ${candidate.fileCount}${suffix} ${candidate.fileCount === 1 && candidate.selection.complete ? "file" : "files"}`,
202
202
  `Exact alternative: ${JSON.stringify(candidate.identifier)} (case-sensitive, whole identifier)`,
203
- ...(candidate.selection.complete ? [] : ["Capture limit reached; no complete all reference."]),
203
+ ...(candidate.selection.complete
204
+ ? []
205
+ : [
206
+ "Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set.",
207
+ ]),
204
208
  ...(read
205
209
  ? [`Read: ${read}${reference || !first ? "" : ` · line ${first.range.startLine}`}`]
206
210
  : []),
@@ -7,7 +7,7 @@ export const searchSchema = Type.Object(
7
7
  query: Type.String({
8
8
  minLength: 1,
9
9
  description:
10
- "Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching.",
10
+ "Text to find or a Boolean expression. Quote text to keep it literal. Use regex:<pattern> for regular expressions, files:<pattern> for file paths, ast:<pattern> for syntax patterns, symbols:<query> for language symbols, or process:<query> for running processes.",
11
11
  }),
12
12
  path: Type.Optional({
13
13
  ...resultInputSchema,
@@ -28,7 +28,7 @@ export const searchSchema = Type.Object(
28
28
  Type.Integer({
29
29
  minimum: 1,
30
30
  maximum: 1000,
31
- description: "Maximum detailed results returned to the agent (default 50)",
31
+ description: "Maximum displayed items, including compact file summaries (default 50).",
32
32
  }),
33
33
  ),
34
34
  },
@@ -125,7 +125,8 @@ export default async function registerSearchCore(
125
125
  openWorldHint: false,
126
126
  },
127
127
  label: "search",
128
- description: "Use search to locate workspace text, file paths, and code structures.",
128
+ description:
129
+ "Use search to find text, file paths, syntax patterns, language symbols, web-page text, and running processes.",
129
130
  promptSnippet:
130
131
  "Search files and text with literals or regular expressions, plus syntax trees and language symbols",
131
132
  get promptGuidelines(): string[] {