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
@@ -8,6 +8,7 @@ import {
8
8
  type ExtensionAPI,
9
9
  withFileMutationQueue,
10
10
  } from "@earendil-works/pi-coding-agent";
11
+ import { Text } from "@earendil-works/pi-tui";
11
12
  import { Type, type Static } from "typebox";
12
13
  import { resultError, structuredResultSchema, withStructuredResult } from "pi-agent-resource";
13
14
  const indexDataSchema = Type.Object(
@@ -45,6 +46,22 @@ export const indexChangeSchema = Type.Object(
45
46
  { additionalProperties: false },
46
47
  );
47
48
 
49
+ const unstageChangeSchema = Type.Object(
50
+ {
51
+ file: {
52
+ ...indexChangeSchema.properties.file,
53
+ description:
54
+ "Path to a tracked text file in the current Git worktree. Relative paths resolve from the workspace.",
55
+ },
56
+ change: {
57
+ ...indexChangeSchema.properties.change,
58
+ description:
59
+ 'Select one complete current CHANGE#HASH anchor returned by read with views: ["changes"].',
60
+ },
61
+ },
62
+ { additionalProperties: false },
63
+ );
64
+
48
65
  interface IndexChangeToolDetails {
49
66
  readonly action: ChangeIndexAction;
50
67
  readonly change: string;
@@ -70,6 +87,24 @@ export function createIndexChangeTool(
70
87
  ) {
71
88
  const execute = createIndexChangeExecutor(action, executor, queue);
72
89
  const pastTense = action === "stage" ? "Staged" : "Unstaged";
90
+ const parameters =
91
+ action === "stage"
92
+ ? {
93
+ ...indexChangeSchema,
94
+ properties: {
95
+ file: {
96
+ ...indexChangeSchema.properties.file,
97
+ description:
98
+ "Path to the tracked text file, absolute or relative to the current working directory.",
99
+ },
100
+ change: {
101
+ ...indexChangeSchema.properties.change,
102
+ description:
103
+ 'Use the complete current CHANGE#HASH anchor shown by read with views: ["changes"].',
104
+ },
105
+ },
106
+ }
107
+ : unstageChangeSchema;
73
108
 
74
109
  return defineTool<typeof indexChangeSchema, IndexChangeToolDetails>({
75
110
  name: action,
@@ -87,9 +122,27 @@ export function createIndexChangeTool(
87
122
  label: action,
88
123
 
89
124
  promptSnippet: `${pastTense.slice(0, -1)} a selected Git change`,
90
- description: `Use ${action} to ${action === "stage" ? "add one current Git change to the index" : "remove one current Git change from the index"}. Select the change with a CHANGE# anchor; worktree content is kept.`,
91
- parameters: indexChangeSchema,
125
+ description:
126
+ action === "stage"
127
+ ? "Use stage to add one selected Git change to the index without changing the worktree file."
128
+ : "Use unstage to remove one selected Git change from the index. Worktree content is kept.",
129
+ parameters,
92
130
  outputSchema: indexOutputSchema,
131
+ // The full IDE removes private result metadata before calling this renderer.
132
+ ...(action === "stage" && {
133
+ renderResult(result, _options, theme) {
134
+ return new Text(
135
+ theme.fg(
136
+ "toolOutput",
137
+ result.content
138
+ .flatMap((block) => (block.type === "text" ? [block.text] : []))
139
+ .join("\n"),
140
+ ),
141
+ 0,
142
+ 0,
143
+ );
144
+ },
145
+ }),
93
146
  async execute(_toolCallId, parameters, signal, _onUpdate, context) {
94
147
  try {
95
148
  const result = await execute(parameters, signal, context);
@@ -148,7 +201,11 @@ export function createIndexChangeExecutor(
148
201
  const creation = await ChangeService.create(executor, context.cwd, signal);
149
202
 
150
203
  if (creation.status !== "ready") {
151
- throw new Error(creation.message);
204
+ throw new Error(
205
+ action === "stage"
206
+ ? `Cannot stage ${parameters.file}: ${creation.message}`
207
+ : creation.message,
208
+ );
152
209
  }
153
210
 
154
211
  const result = await creation.service.changeIndex(
@@ -163,10 +220,31 @@ export function createIndexChangeExecutor(
163
220
  );
164
221
 
165
222
  if (result.status === "unavailable") {
166
- throw new Error(result.message);
223
+ if (action === "stage" && result.reason === "stale-selector") {
224
+ throw new Error(
225
+ `${result.message}. Read ${parameters.file} with views: ["changes"] and use a current CHANGE# anchor.`,
226
+ );
227
+ }
228
+ if (action === "stage" && result.reason === "index-write-failed" && !signal?.aborted) {
229
+ throw new Error(
230
+ `${result.message}\nThe index may have changed. Read ${parameters.file} with views: ["changes"] before retrying.`,
231
+ );
232
+ }
233
+ throw new Error(
234
+ action === "stage" && result.reason !== "index-write-failed"
235
+ ? `Cannot stage ${parameters.file}: ${result.message}`
236
+ : result.message,
237
+ );
167
238
  }
168
239
 
169
240
  if (result.status === "not-applicable") {
241
+ if (action === "stage") {
242
+ const reason =
243
+ result.reason === "clean"
244
+ ? "the worktree text matches HEAD"
245
+ : "the file is not present in HEAD";
246
+ throw new Error(`Cannot stage ${parameters.file}: ${reason}.`);
247
+ }
170
248
  throw new Error(`${action} is not applicable to ${file}: ${result.reason}`);
171
249
  }
172
250
 
@@ -15,22 +15,20 @@ export const undoSchema = Type.Object(
15
15
  file: Type.Optional({
16
16
  ...resultInputSchema,
17
17
  description:
18
- "File to restore or one whole-file source result; partial and multi-file scopes are rejected. May be omitted to inherit the previous source.",
18
+ "File path or one whole-file source result. Partial and multi-file selections are rejected. Omit file to use the supplied CHANGE anchor's file or the last resolved source.",
19
+ }),
20
+ change: Type.String({
21
+ description:
22
+ 'Use a complete current CHANGE#HASH anchor from read with views: ["changes"] to restore that change to HEAD in both worktree and index. Use last to restore the file\'s latest saved text-editor transaction.',
23
+ pattern: "^(?:CHANGE#[0-9A-F]{4,64}|last)$",
19
24
  }),
20
- change: Type.Optional(
21
- Type.String({
22
- description:
23
- "Complete CHANGE#HASH anchor shown by read, or last for this file's latest text-editor transaction",
24
- pattern: "^(?:CHANGE#[0-9A-F]{4,64}|last)$",
25
- }),
26
- ),
27
25
  },
28
26
  { additionalProperties: false },
29
27
  );
30
28
 
31
29
  interface UndoParameters {
32
30
  readonly file?: unknown;
33
- readonly change?: string;
31
+ readonly change: string;
34
32
  }
35
33
 
36
34
  export function createUndoMutationTool(
@@ -41,7 +39,7 @@ export function createUndoMutationTool(
41
39
  return {
42
40
  name: "undo",
43
41
  description:
44
- "Use undo to revert a selected uncommitted Git change or the latest text-editor transaction for one file. CHANGE# restores that change to HEAD in both worktree and index; last restores one file's latest text edit.",
42
+ "Use undo to restore one selected uncommitted Git change or a file's latest text-editor transaction.",
45
43
 
46
44
  promptSnippet: "Restore a Git change or latest text edit",
47
45
  parameters: undoSchema,
@@ -56,7 +54,6 @@ export function createUndoMutationTool(
56
54
  },
57
55
  ],
58
56
  async mutate(context, parameters: UndoParameters) {
59
- if (parameters.change === undefined) throw new Error("change is required");
60
57
  const source = context.sourceFor("file");
61
58
  let restoredText: string;
62
59
  let afterWrite: (() => Promise<void>) | undefined;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-formatter",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1"
6
+ "pi-agent-doctor": "0.7.3"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "peerDependencies": {
14
14
  "@earendil-works/pi-coding-agent": "*",
15
- "pi-agent-ide": "0.7.1"
15
+ "pi-agent-ide": "0.7.3"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "pi-agent-ide": {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-languages",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1"
6
+ "pi-agent-doctor": "0.7.3"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lint",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1",
7
- "pi-agent-invariant": "0.7.1",
8
- "pi-agent-read": "0.7.1",
9
- "pi-agent-resource": "0.7.1",
10
- "pi-agent-text": "0.7.1"
6
+ "pi-agent-doctor": "0.7.3",
7
+ "pi-agent-invariant": "0.7.3",
8
+ "pi-agent-read": "0.7.3",
9
+ "pi-agent-resource": "0.7.3",
10
+ "pi-agent-text": "0.7.3"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@earendil-works/pi-coding-agent": "*",
19
- "pi-agent-ide": "0.7.1"
19
+ "pi-agent-ide": "0.7.3"
20
20
  },
21
21
  "peerDependenciesMeta": {
22
22
  "pi-agent-ide": {
@@ -143,7 +143,7 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
143
143
  api
144
144
  .tool(operation)
145
145
  .describe(
146
- "Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. Copy/move require an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename." +
146
+ "Use symbol:<file>#<selector> as path to select one exact declaration without start/end. Use parent/child for ambiguous names. For declaration-text Copy/Move, supply an explicit target and destination anchor. This text fallback leaves imports and references unchanged; it is not semantic rename." +
147
147
  (operation === "replace"
148
148
  ? " Use symbol:<file>#<selector>#name with text containing the new name for native LSP rename across references. Omit start/end. A failed server rename never falls back to identifier text replacement."
149
149
  : ""),
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lsp",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "cross-spawn": "^7.0.6",
7
- "pi-agent-doctor": "0.7.1",
8
- "pi-agent-invariant": "0.7.1",
9
- "pi-agent-read": "0.7.1",
10
- "pi-agent-resource": "0.7.1",
11
- "pi-agent-search": "0.7.1",
12
- "pi-agent-text": "0.7.1",
13
- "pi-agent-text-editor": "0.7.1",
7
+ "pi-agent-doctor": "0.7.3",
8
+ "pi-agent-invariant": "0.7.3",
9
+ "pi-agent-read": "0.7.3",
10
+ "pi-agent-resource": "0.7.3",
11
+ "pi-agent-search": "0.7.3",
12
+ "pi-agent-text": "0.7.3",
13
+ "pi-agent-text-editor": "0.7.3",
14
14
  "vscode-jsonrpc": "^9.0.0",
15
15
  "vscode-uri": "^3.1.0"
16
16
  },
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "*",
24
- "pi-agent-ide": "0.7.1"
24
+ "pi-agent-ide": "0.7.3"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "pi-agent-ide": {
@@ -9,7 +9,8 @@ export function createDeclarationTargets(managerFor: LspManagerProvider): TextTa
9
9
  id: "lsp-declaration-target",
10
10
  async tryResolve(value, context) {
11
11
  const reference = parseCodeViewReference(value, "symbol");
12
- if (reference === undefined) return { kind: "not-handled" };
12
+ // #name belongs to the rename pre-edit handler, not declaration-text fallback.
13
+ if (reference === undefined || value.endsWith("#name")) return { kind: "not-handled" };
13
14
  if (reference.selector === undefined)
14
15
  return {
15
16
  kind: "rejected",
@@ -108,7 +108,6 @@ export function createLspSearchResolver(
108
108
  );
109
109
  if (result.complete && result.hits.length)
110
110
  lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact symbol matches.`);
111
- if (!result.complete) lines.push("Incomplete results; not a complete edit scope.");
112
111
  if (result.hits.length > 100) lines.push("Preview shortened; full source targets retained.");
113
112
  return {
114
113
  content: [{ type: "text", text: [heading, ...lines].join("\n") }],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-image",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
@@ -10,7 +10,7 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "pi-agent-resource": "0.7.1"
13
+ "pi-agent-resource": "0.7.3"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "@earendil-works/pi-coding-agent": "*"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-invariant",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-pdf",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
@@ -11,6 +11,6 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "pdfjs-dist": "^6.2.108",
14
- "pi-agent-resource": "0.7.1"
14
+ "pi-agent-resource": "0.7.3"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-read",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -24,12 +24,12 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "pi-agent-documentation": "0.7.1",
28
- "pi-agent-invariant": "0.7.1",
29
- "pi-agent-resource": "0.7.1",
30
- "pi-agent-text": "0.7.1",
31
- "pi-agent-tool-call-interception": "0.7.1",
32
- "pi-agent-tool-ui": "0.7.1"
27
+ "pi-agent-documentation": "0.7.3",
28
+ "pi-agent-invariant": "0.7.3",
29
+ "pi-agent-resource": "0.7.3",
30
+ "pi-agent-text": "0.7.3",
31
+ "pi-agent-tool-call-interception": "0.7.3",
32
+ "pi-agent-tool-ui": "0.7.3"
33
33
  },
34
34
  "pi": {
35
35
  "extensions": [
@@ -34,13 +34,13 @@ export type ReadParameterText = Partial<Record<keyof ReadRequest, string>>;
34
34
 
35
35
  // Keep the shared schema's metadata stable for Diff; these descriptions belong to Read.
36
36
  const coreDescriptions: Record<keyof ReadRequest, string> = {
37
- path: "What to read: a resource path, unchanged source result or its UUID. Pass the whole result to compose tools. Supply a source; an empty call cannot select one. temp:<id> reads saved complete output until this runtime is disposed. raw:<local-file> reads original bytes from a regular file (relative, absolute or file:// path); raw: does not accept views.",
37
+ path: "Source to read: a resource path, unchanged source result or its UUID. Supply a source; an empty call cannot select one. temp:<id> reads saved output. raw:<local-file> reads original bytes from a regular file; relative, absolute and file:// paths are accepted.",
38
38
  offset:
39
39
  "For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",
40
40
  limit:
41
- "For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the bounded default read. Explicit ranges on other content require a source-specific handler; otherwise they fail.",
41
+ "For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the default read. For other non-text sources, use only a range form described for that source.",
42
42
  views:
43
- "Optional source-specific presentations. Omit for the source's default presentation. Values may include settings after a colon; use the syntax below. Combine views only when their contracts allow it. Unknown views can be ignored and reported in ignoredViews; they do not add capabilities. raw: sources reject views.",
43
+ "Source-specific presentations. Omit for the source's default presentation. Supply settings after a colon using the syntax below. Combine views only when their contracts allow it. raw: sources do not accept views.",
44
44
  };
45
45
 
46
46
  /** Build a fresh Read schema snapshot without changing the shared schema or accepted types. */
@@ -107,6 +107,8 @@ export interface FragmentResolverRegistration {
107
107
  */
108
108
  export interface ReadViewRegistration {
109
109
  readonly view: string;
110
+ /** Text views require source lines; native handlers may register views for any content. */
111
+ readonly contentKind?: "text" | "any";
110
112
  /** Requested views whose complete presentation this view already provides. */
111
113
  readonly includes?: readonly string[];
112
114
  readonly presenter: TextLinePresenter;
@@ -164,6 +166,8 @@ export interface UnsupportedContentDetails {
164
166
  }
165
167
 
166
168
  export interface ReadResultDetails extends UnsupportedContentDetails {
169
+ /** Diagnostic readiness shown separately from canonical source lines. */
170
+ readonly diagnosticStatus?: string;
167
171
  /** Explicit diagnostic checks; completed empty reports need no content panel. */
168
172
  readonly diagnosticCheck?: {
169
173
  readonly complete: boolean;
@@ -182,9 +186,13 @@ export interface ReadResultDetails extends UnsupportedContentDetails {
182
186
  readonly totalLines?: number;
183
187
  readonly truncation?: TruncationResult;
184
188
  readonly temporarySource?: string;
189
+ /** Exact appended notice, outside the useful-output budget. */
190
+ readonly outputNotice?: string;
185
191
  readonly lines?: readonly ReadTextLine[];
186
192
  /** Requested view names that no registration backed; they were ignored. */
187
193
  readonly ignoredViews?: readonly string[];
194
+ /** Situational presentation messages, kept outside source lines and script data. */
195
+ readonly viewWarnings?: readonly string[];
188
196
  readonly failure?: ReadFailure;
189
197
  }
190
198
 
@@ -316,6 +324,8 @@ export interface ReadToolPluginApi {
316
324
  ): Promise<ReadToolResult | undefined>;
317
325
  /** Stores complete output for follow-up read access until this runtime is disposed. */
318
326
  saveTemporary(text: string): Promise<string>;
327
+ /** Sets the saver used before the shared text budget truncates a Read result. */
328
+ setOutputSaver(saver: (text: string) => Promise<string>): void;
319
329
  /** Executes the shared pipeline; script results are not clipped to the agent output budget. */
320
330
  read(
321
331
  request: ReadRequest,
@@ -357,6 +367,7 @@ const fragmentResolverRegistrationSchema = Type.Object({
357
367
  });
358
368
  const viewRegistrationSchema = Type.Object({
359
369
  view: Type.String({ pattern: "\\S" }),
370
+ contentKind: Type.Optional(Type.Union([Type.Literal("text"), Type.Literal("any")])),
360
371
  includes: Type.Optional(Type.Array(Type.String({ pattern: "\\S" }))),
361
372
  presenter: Type.Object({ id: Type.String(), present: functionSchema }),
362
373
  priority: Type.Optional(Type.Number()),
@@ -32,7 +32,7 @@ export default async function registerReadCore(
32
32
  connectAgentDocumentation(pi, [
33
33
  await loadPackagedAgentGuide({
34
34
  id: "read-resources",
35
- description: "Resource selection, windows, views, raw bytes, and continuation",
35
+ description: "Read results, selection boundaries, and composition",
36
36
  triggers: [{ tool: "read" }],
37
37
  }),
38
38
  ]);
@@ -201,6 +201,10 @@ function createPluginContributionController(
201
201
  assertAvailable();
202
202
  return read.saveTemporary(text);
203
203
  },
204
+ setOutputSaver(saver) {
205
+ assertAvailable();
206
+ read.setOutputSaver(saver);
207
+ },
204
208
  read(request, context, audience) {
205
209
  assertAvailable();
206
210
  return read.execute(request, context, audience);
@@ -368,7 +372,7 @@ function renderParameterDescriptions(
368
372
  return Object.fromEntries(
369
373
  Object.entries(entries).map(([parameter, descriptions]) => [
370
374
  parameter,
371
- [...new Set(descriptions)].join("\n"),
375
+ [...new Set(descriptions.flatMap((description) => description.split("\n")))].join("\n"),
372
376
  ]),
373
377
  );
374
378
  }
@@ -1,3 +1,4 @@
1
+ import { stat } from "node:fs/promises";
1
2
  import {
2
3
  DEFAULT_MAX_BYTES,
3
4
  DEFAULT_MAX_LINES,
@@ -7,6 +8,7 @@ import {
7
8
  } from "@earendil-works/pi-coding-agent";
8
9
 
9
10
  import type { ReadRequest, ReadResultDetails, ReadToolResult } from "#src/api/tools/read.js";
11
+ import { anchoredStartLine } from "#src/core/tools/read/read-result.js";
10
12
 
11
13
  export interface ReadTruncationOptions {
12
14
  /** Absolute 1-based line where an anchored read's window starts. */
@@ -39,7 +41,7 @@ export async function limitReadOutput(
39
41
  const temporarySource =
40
42
  saveFullOutput === undefined ? undefined : await saveFullOutput(block.text);
41
43
  const baseNotice = truncation.firstLineExceedsLimit
42
- ? oversizedFirstLineNotice(block.text, result.details, request)
44
+ ? await oversizedFirstLineNotice(block.text, result.details, request)
43
45
  : truncatedOutputNotice(truncation, result.details, request, originLine);
44
46
  const notice =
45
47
  temporarySource === undefined
@@ -51,39 +53,88 @@ export async function limitReadOutput(
51
53
  content: [{ ...block, text: appendNotice(truncation.content, notice) }],
52
54
  details: {
53
55
  ...truncatedDetails(result.details, truncation),
56
+ outputNotice: (truncation.content.length ? "\n\n" : "") + notice,
54
57
  ...(temporarySource !== undefined && { temporarySource }),
55
58
  },
56
59
  };
57
60
  }
58
61
 
59
- const notice = explicitLimitNotice(result.details, request, originLine);
60
-
61
- if (notice === undefined) {
62
- return result;
63
- }
62
+ return explainReadWindow(result, request, options);
63
+ }
64
64
 
65
+ /** Explains an empty or explicitly limited text window without changing its source selection. */
66
+ export function explainReadWindow(
67
+ result: ReadToolResult,
68
+ request: ReadRequest,
69
+ options?: ReadTruncationOptions,
70
+ ): ReadToolResult {
71
+ const block = result.content.length === 1 ? result.content[0] : undefined;
72
+ if (result.isError || block?.type !== "text") return result;
73
+ const notice =
74
+ block.text.length === 0
75
+ ? emptyTextNotice(result, request, options?.originLine)
76
+ : explicitLimitNotice(result.details, request, options?.originLine);
77
+ if (notice === undefined) return result;
65
78
  return {
66
79
  ...result,
67
80
  content: [{ ...block, text: appendNotice(block.text, notice) }],
81
+ details: { ...result.details, outputNotice: (block.text.length ? "\n\n" : "") + notice },
68
82
  };
69
83
  }
70
84
 
85
+ function emptyTextNotice(
86
+ result: ReadToolResult,
87
+ request: ReadRequest,
88
+ originLine: number | undefined,
89
+ ): string | undefined {
90
+ const selected = result.script;
91
+ if (result.isError || selected?.kind !== "text" || selected.lines.length !== 0) return undefined;
92
+ if (selected.totalLines === 0) return "[Empty source.]";
93
+ if (request.limit !== undefined && Math.trunc(request.limit) <= 0)
94
+ return "[No lines selected: limit=0.]";
95
+ const offset = Math.trunc(request.offset ?? 1);
96
+ if (anchoredStartLine(offset, selected.totalLines, originLine) > selected.totalLines)
97
+ return `[Offset ${offset} is beyond the end of the source (${selected.totalLines} ${selected.totalLines === 1 ? "line" : "lines"}).]`;
98
+ return undefined;
99
+ }
71
100
  function appendTemporarySource(notice: string, source: string): string {
72
- return `${notice.slice(0, -1)} Full output: ${source}. Available until this runtime is disposed.]`;
101
+ const reference = source.startsWith("temp:") ? source : JSON.stringify(source);
102
+ return `${notice.slice(0, -1)} Full output: ${reference}. Available until this runtime is disposed.]`;
73
103
  }
74
104
 
75
- function oversizedFirstLineNotice(
105
+ async function oversizedFirstLineNotice(
76
106
  text: string,
77
107
  details: ReadResultDetails,
78
108
  request: ReadRequest,
79
- ): string {
109
+ ): Promise<string> {
80
110
  const firstLine = text.split(/\r\n|\r|\n/u, 1)[0] ?? "";
81
111
  const lineSize = formatSize(Buffer.byteLength(firstLine, "utf8"));
82
112
  const sourceLine = sourceStartLine(details, request);
83
113
  const lineLabel = sourceLine === undefined ? "First output line" : `Line ${sourceLine}`;
114
+ const limit = formatSize(READ_OUTPUT_MAX_BYTES);
115
+
116
+ if (
117
+ details.resolvedBy === "filesystem" &&
118
+ request.views?.some((view) => view.startsWith("jq:")) === true
119
+ ) {
120
+ return (
121
+ `[Output line ${sourceLine ?? 1} is ${lineSize}, exceeds the ${limit} output limit. ` +
122
+ "This line was not returned. Narrow the jq filter to return a smaller value.]"
123
+ );
124
+ }
125
+
126
+ if (details.resolvedBy === "filesystem" && details.source !== undefined) {
127
+ const file = await stat(details.source).catch(() => undefined);
128
+ if (file?.isFile() === true) {
129
+ return (
130
+ `[${lineLabel} is ${lineSize}, exceeds the ${limit} output limit. This line was not returned. ` +
131
+ `Read ${JSON.stringify(`raw:${details.source}`)} with offset=0 and limit=4096 to inspect the original bytes.]`
132
+ );
133
+ }
134
+ }
84
135
 
85
136
  return (
86
- `[${lineLabel} is ${lineSize}, exceeds ${formatSize(READ_OUTPUT_MAX_BYTES)} limit. ` +
137
+ `[${lineLabel} is ${lineSize}, exceeds ${limit} limit. ` +
87
138
  "Use a source-specific tool to read this line in smaller byte ranges.]"
88
139
  );
89
140
  }
@@ -97,21 +148,24 @@ function truncatedOutputNotice(
97
148
  const sourceRange = shownSourceRange(truncation, details, request);
98
149
 
99
150
  if (sourceRange !== undefined && sourceRange.endLine < sourceRange.totalLines) {
100
- const byteLimit =
101
- truncation.truncatedBy === "bytes" ? ` (${formatSize(truncation.maxBytes)} limit)` : "";
102
- const nextOffset = continuationOffset(sourceRange.endLine + 1, originLine);
151
+ const limit =
152
+ truncation.truncatedBy === "lines"
153
+ ? `${truncation.maxLines}-line limit`
154
+ : `${formatSize(truncation.maxBytes)} limit`;
155
+ const action = sourceContinuationAction(details, request, sourceRange.endLine + 1, originLine);
103
156
 
104
- return `[Showing lines ${sourceRange.startLine}-${sourceRange.endLine} of ${sourceRange.totalLines}${byteLimit}. Use offset=${nextOffset} to continue.]`;
157
+ return `[Showing lines ${sourceRange.startLine}-${sourceRange.endLine} of ${sourceRange.totalLines} (${limit}). ${action} to continue.]`;
105
158
  }
106
159
 
107
160
  const limit =
108
161
  truncation.truncatedBy === "lines"
109
- ? `${truncation.maxLines} line limit`
162
+ ? `${truncation.maxLines}-line limit`
110
163
  : `${formatSize(truncation.maxBytes)} limit`;
111
164
 
112
165
  return (
113
- `[Output truncated: showing ${truncation.outputLines} of ${truncation.totalLines} rendered lines (${limit}). ` +
114
- "Use a smaller line range to read this source.]"
166
+ `[Output truncated: showing ${truncation.outputLines} of ${truncation.totalLines} output lines (${limit}). ` +
167
+ "No single source-line continuation is available. " +
168
+ "Retry Read with a smaller limit, keeping the same source and views.]"
115
169
  );
116
170
  }
117
171
 
@@ -169,7 +223,26 @@ function explicitLimitNotice(
169
223
  }
170
224
 
171
225
  const remaining = details.totalLines - nextAbsolute + 1;
172
- return `[${remaining} more lines in source. Use offset=${continuationOffset(nextAbsolute, originLine)} to continue.]`;
226
+ const lineLabel = remaining === 1 ? "line" : "lines";
227
+ const action = sourceContinuationAction(details, request, nextAbsolute, originLine);
228
+ return `[${remaining} more ${lineLabel} in source. ${action} to continue.]`;
229
+ }
230
+
231
+ function sourceContinuationAction(
232
+ details: ReadResultDetails,
233
+ request: ReadRequest,
234
+ nextAbsolute: number,
235
+ originLine: number | undefined,
236
+ ): string {
237
+ const action =
238
+ details.source === undefined
239
+ ? `Use offset=${continuationOffset(nextAbsolute, originLine)}`
240
+ : `Read ${JSON.stringify(details.source)} with offset=${nextAbsolute}`;
241
+ const views =
242
+ request.views === undefined || request.views.length === 0
243
+ ? ""
244
+ : ` and views=${JSON.stringify(request.views)}`;
245
+ return action + views;
173
246
  }
174
247
 
175
248
  /** Converts an absolute next line into the offset the agent should send again. */