pi-agent-ide 0.6.3 → 0.6.4

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 (355) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +8 -1
  3. package/dist/chunk-2P2OGO3G.js +2 -0
  4. package/dist/{chunk-5QQABP47.js → chunk-3BBJZSMS.js} +1 -1
  5. package/dist/chunk-5J43L2RL.js +11 -0
  6. package/dist/{chunk-ITSNK5YG.js → chunk-7AVXUV4A.js} +2 -2
  7. package/dist/chunk-BAYETTZZ.js +16 -0
  8. package/dist/{chunk-VCTK4JSN.js → chunk-BSICWXMH.js} +1 -1
  9. package/dist/chunk-BVK5A7ED.js +28 -0
  10. package/dist/{chunk-ZM4L5AGN.js → chunk-EDURPQAV.js} +3 -2
  11. package/dist/{chunk-L7JMDDSD.js → chunk-FBOW7XOV.js} +1 -1
  12. package/dist/{chunk-25CZ5ZIU.js → chunk-FUG2TEKI.js} +1 -1
  13. package/dist/chunk-FZBCKIJJ.js +1 -0
  14. package/dist/chunk-HPUAIWIH.js +25 -0
  15. package/dist/chunk-I5JLCFUX.js +1 -0
  16. package/dist/chunk-KUPHNMUK.js +2 -0
  17. package/dist/{chunk-NTYXZ3EL.js → chunk-KVHDMIZS.js} +1 -1
  18. package/dist/{chunk-QDST6VIU.js → chunk-KZC7TI5M.js} +1 -1
  19. package/dist/chunk-MIZAFRDR.js +1 -0
  20. package/dist/chunk-PJPA5EEE.js +2 -0
  21. package/dist/{chunk-GUTQ3PWL.js → chunk-PLKYHUNT.js} +1 -1
  22. package/dist/chunk-QEJGED4V.js +28 -0
  23. package/dist/chunk-SILJ3OL4.js +9 -0
  24. package/dist/{chunk-VXD6FZP5.js → chunk-TQZBVOTT.js} +3 -3
  25. package/dist/chunk-VBICI5YA.js +1 -0
  26. package/dist/chunk-VWW3RLUX.js +12 -0
  27. package/dist/{chunk-O6LE42GK.js → chunk-WJTHY6AG.js} +1 -1
  28. package/dist/chunk-YGGKGZO2.js +1 -0
  29. package/dist/chunk-ZODCBFBL.js +2 -0
  30. package/dist/chunk-ZPT5D4VP.js +2 -0
  31. package/dist/entry-0.js +1 -1
  32. package/dist/entry-11.js +1 -1
  33. package/dist/entry-13.js +1 -1
  34. package/dist/entry-14.js +1 -1
  35. package/dist/entry-15.js +1 -1
  36. package/dist/entry-16.js +1 -1
  37. package/dist/entry-17.js +1 -1
  38. package/dist/entry-25.js +2 -2
  39. package/dist/entry-26.js +1 -1
  40. package/dist/entry-27.js +1 -1
  41. package/dist/entry-28.js +1 -1
  42. package/dist/entry-29.js +1 -1
  43. package/dist/entry-30.js +1 -1
  44. package/dist/entry-31.js +11 -11
  45. package/dist/entry-33.js +1 -1
  46. package/dist/entry-37.js +2 -2
  47. package/dist/entry-42.js +1 -1
  48. package/dist/entry-44.js +1 -1
  49. package/dist/entry-45.js +13 -12
  50. package/dist/entry-46.js +1 -1
  51. package/dist/entry-49.js +1 -1
  52. package/dist/entry-50.js +4 -4
  53. package/dist/entry-51.js +9 -9
  54. package/dist/entry-52.js +1 -1
  55. package/dist/entry-53.js +1 -1
  56. package/dist/entry-55.js +1 -1
  57. package/dist/entry-56.js +1 -1
  58. package/dist/entry-57.js +1 -1
  59. package/dist/entry-58.js +1 -1
  60. package/dist/entry-59.js +1 -1
  61. package/dist/entry-60.js +1 -1
  62. package/dist/entry-61.js +1 -1
  63. package/dist/entry-63.js +1 -1
  64. package/dist/entry-66.js +1 -1
  65. package/dist/entry-68.js +1 -1
  66. package/dist/entry-69.js +1 -1
  67. package/dist/entry-70.js +1 -1
  68. package/dist/entry-71.js +1 -0
  69. package/dist/entry-72.js +0 -1
  70. package/dist/entry-73.js +1 -0
  71. package/dist/entry-74.js +0 -1
  72. package/dist/entry-75.js +1 -1
  73. package/dist/entry-76.js +1 -1
  74. package/dist/entry-77.js +1 -324
  75. package/dist/entry-78.js +324 -25
  76. package/dist/entry-79.js +18 -2
  77. package/dist/entry-80.js +2 -1
  78. package/dist/entry-81.js +1 -1
  79. package/dist/entry-82.js +1 -3
  80. package/dist/entry-83.js +5 -3
  81. package/dist/entry-84.js +3 -1
  82. package/dist/entry-85.js +1 -1
  83. package/dist/entry-86.js +1 -1
  84. package/dist/entry-87.js +1 -0
  85. package/dist/pi-agent-ide.js +15 -3
  86. package/docs/agent-guides/editing.md +12 -0
  87. package/docs/agent-guides/json-reading.md +19 -3
  88. package/docs/agent-guides/read-resources.md +6 -0
  89. package/docs/agent-guides/search-code.md +5 -1
  90. package/docs/agent-guides/terminal.md +1 -1
  91. package/docs/code-review.md +99 -0
  92. package/docs/configuration.md +34 -0
  93. package/docs/development.md +15 -19
  94. package/docs/nightly.md +7 -0
  95. package/docs/releases.md +42 -0
  96. package/docs/research/native-codemode-batch-decision.md +27 -0
  97. package/docs/research/native-codemode-batching.md +65 -0
  98. package/docs/structured-results.md +59 -0
  99. package/docs/tools.md +18 -2
  100. package/node_modules/pi-agent-doctor/package.json +1 -1
  101. package/node_modules/pi-agent-documentation/package.json +1 -1
  102. package/node_modules/pi-agent-documentation/src/index.ts +1 -1
  103. package/node_modules/pi-agent-filesystem/index.ts +6 -1
  104. package/node_modules/pi-agent-filesystem/package.json +7 -6
  105. package/node_modules/pi-agent-filesystem/src/path-recovery.ts +109 -0
  106. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  107. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  108. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  109. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  110. package/node_modules/pi-agent-ide-ast/package.json +10 -10
  111. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  112. package/node_modules/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  113. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +17 -0
  114. package/node_modules/pi-agent-ide-changes/index.ts +3 -9
  115. package/node_modules/pi-agent-ide-changes/package.json +8 -7
  116. package/node_modules/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  117. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
  118. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  119. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  120. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  121. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  122. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
  123. package/node_modules/pi-agent-image/package.json +2 -2
  124. package/node_modules/pi-agent-invariant/package.json +1 -1
  125. package/node_modules/pi-agent-pdf/package.json +2 -2
  126. package/node_modules/pi-agent-read/package.json +7 -7
  127. package/node_modules/pi-agent-read/src/api/tools/read.ts +31 -2
  128. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  129. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  130. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
  131. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +119 -72
  132. package/node_modules/pi-agent-resource/package.json +1 -1
  133. package/node_modules/pi-agent-resource/src/index.ts +12 -0
  134. package/node_modules/pi-agent-resource/src/resource-access.ts +55 -0
  135. package/node_modules/pi-agent-resource/src/resource-scheduler.ts +204 -0
  136. package/node_modules/pi-agent-resource/src/tool-result.ts +125 -0
  137. package/node_modules/pi-agent-search/package.json +5 -4
  138. package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
  139. package/node_modules/pi-agent-search/src/api/search.ts +11 -0
  140. package/node_modules/pi-agent-search/src/api/structured-result.ts +93 -0
  141. package/node_modules/pi-agent-search/src/core/extension.ts +40 -14
  142. package/node_modules/pi-agent-search/src/core/search-core.ts +136 -77
  143. package/node_modules/pi-agent-search-text/index.ts +3 -0
  144. package/node_modules/pi-agent-search-text/package.json +6 -6
  145. package/node_modules/pi-agent-search-text/src/resolvers.ts +17 -0
  146. package/node_modules/pi-agent-search-text/src/search-backend.ts +104 -8
  147. package/node_modules/pi-agent-search-text/src/search-query.ts +42 -34
  148. package/node_modules/pi-agent-search-text/src/search-recipe.ts +18 -4
  149. package/node_modules/pi-agent-search-text/src/search-renderer.ts +37 -3
  150. package/node_modules/pi-agent-search-text/src/search-session.ts +21 -13
  151. package/node_modules/pi-agent-text/package.json +2 -2
  152. package/node_modules/pi-agent-text/src/text-document.ts +15 -10
  153. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  154. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  155. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  156. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  157. package/node_modules/pi-agent-text-editor/index.ts +4 -2
  158. package/node_modules/pi-agent-text-editor/package.json +21 -17
  159. package/node_modules/pi-agent-text-editor/runtime/entry-77.js +0 -1
  160. package/node_modules/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  161. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  162. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  163. package/node_modules/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
  164. package/node_modules/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
  165. package/node_modules/pi-agent-text-editor/src/core/apply/results.ts +4 -0
  166. package/node_modules/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
  167. package/node_modules/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
  168. package/node_modules/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
  169. package/node_modules/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  170. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
  171. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  172. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
  173. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  174. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
  175. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  176. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +314 -0
  177. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
  178. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  179. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
  180. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
  181. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  182. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  183. package/node_modules/pi-agent-text-editor-renderer/index.ts +8 -1
  184. package/node_modules/pi-agent-text-editor-renderer/package.json +7 -6
  185. package/node_modules/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
  186. package/node_modules/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  187. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  188. package/node_modules/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  189. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  190. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  191. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  192. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  193. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  194. package/node_modules/pi-agent-tool-ui/runtime/entry-82.js +1 -0
  195. package/node_modules/pi-agent-web/index.ts +20 -0
  196. package/node_modules/pi-agent-web/package.json +8 -7
  197. package/node_modules/pi-agent-web/src/search.ts +112 -0
  198. package/node_modules/pi-agent-web-html/package.json +3 -3
  199. package/node_modules/pi-agent-web-image/package.json +4 -4
  200. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  201. package/node_modules/pi-agent-web-text/package.json +4 -4
  202. package/node_modules/pi-agent-web-text/runtime/entry-87.js +2 -0
  203. package/package.json +42 -36
  204. package/skills/capture-code-review-rule/SKILL.md +60 -0
  205. package/src/code-review/config.ts +68 -0
  206. package/src/code-review/extension.ts +105 -0
  207. package/src/code-review/fragments.ts +26 -0
  208. package/src/code-review/reviewer.ts +198 -0
  209. package/src/composite/host-version.ts +13 -0
  210. package/src/composite/nested-tool-rendering.ts +298 -0
  211. package/src/composite/tool-availability.ts +90 -0
  212. package/src/core/extension.ts +2 -0
  213. package/src/documentation/extension.ts +81 -145
  214. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +6 -1
  215. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -6
  216. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  217. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  218. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  219. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  220. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/src/path-recovery.ts +109 -0
  221. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +20 -0
  222. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -7
  223. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  224. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  225. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  226. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  227. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-87.js +2 -0
  228. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-83.js +2 -0
  229. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/search.ts +112 -0
  230. package/src/extensions/pi-agent-read/package.json +7 -7
  231. package/src/extensions/pi-agent-read/src/api/tools/read.ts +31 -2
  232. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +9 -10
  233. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +28 -15
  234. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +216 -0
  235. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +119 -72
  236. package/src/extensions/pi-agent-search/package.json +5 -4
  237. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +3 -0
  238. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +6 -6
  239. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +17 -0
  240. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +104 -8
  241. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-query.ts +42 -34
  242. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +18 -4
  243. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +37 -3
  244. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +21 -13
  245. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
  246. package/src/extensions/pi-agent-search/src/api/search.ts +11 -0
  247. package/src/extensions/pi-agent-search/src/api/structured-result.ts +93 -0
  248. package/src/extensions/pi-agent-search/src/core/extension.ts +40 -14
  249. package/src/extensions/pi-agent-search/src/core/search-core.ts +136 -77
  250. package/src/extensions/pi-agent-text-editor/index.ts +4 -2
  251. package/src/extensions/pi-agent-text-editor/package.json +21 -17
  252. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  253. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  254. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +4 -3
  255. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  256. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +8 -1
  257. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +7 -6
  258. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-model.ts +262 -129
  259. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/diff-renderer.ts +36 -2
  260. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +28 -2
  261. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-projection.ts +40 -10
  262. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +16 -1
  263. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  264. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-80.js +2 -0
  265. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +0 -1
  266. package/src/extensions/pi-agent-text-editor/runtime/entry-78.js +2 -0
  267. package/src/extensions/pi-agent-text-editor/src/api/mutation-preview.ts +2 -0
  268. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +6 -0
  269. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +12 -0
  270. package/src/extensions/pi-agent-text-editor/src/core/apply/apply-undo-store.ts +4 -0
  271. package/src/extensions/pi-agent-text-editor/src/core/apply/execution.ts +95 -34
  272. package/src/extensions/pi-agent-text-editor/src/core/apply/results.ts +4 -0
  273. package/src/extensions/pi-agent-text-editor/src/core/apply/structured-result.ts +251 -0
  274. package/src/extensions/pi-agent-text-editor/src/core/apply/tool.ts +32 -12
  275. package/src/extensions/pi-agent-text-editor/src/core/apply/transaction.ts +154 -132
  276. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit.ts +16 -0
  277. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +74 -18
  278. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +8 -0
  279. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +6 -0
  280. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  281. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +640 -0
  282. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +20 -6
  283. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +314 -0
  284. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +143 -138
  285. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +2 -0
  286. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +242 -116
  287. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +109 -47
  288. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +25 -5
  289. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +8 -4
  290. package/src/pi-agent-ide.ts +61 -2
  291. package/src/plugins/pi-agent-ide-ast/package.json +10 -10
  292. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +6 -1
  293. package/src/plugins/pi-agent-ide-ast/src/scope-handler.ts +6 -2
  294. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +17 -0
  295. package/src/plugins/pi-agent-ide-changes/index.ts +3 -9
  296. package/src/plugins/pi-agent-ide-changes/package.json +8 -7
  297. package/src/plugins/pi-agent-ide-changes/src/current-change-presenter.ts +5 -0
  298. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +125 -47
  299. package/src/plugins/pi-agent-ide-debugger/index.ts +63 -17
  300. package/src/plugins/pi-agent-ide-debugger/src/catalog.ts +18 -2
  301. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +24 -4
  302. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +68 -2
  303. package/src/plugins/pi-agent-ide-debugger/src/java-runtime.ts +357 -0
  304. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +55 -3
  305. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +13 -13
  306. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  307. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  308. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  309. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  310. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +19 -0
  311. package/src/plugins/pi-agent-ide-terminal/index.ts +12 -2
  312. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +1 -1
  313. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +65 -30
  314. package/src/plugins/pi-agent-ide-terminal/src/search.ts +13 -8
  315. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +1 -0
  316. package/src/plugins/pi-agent-ide-terminal/src/shell-result.ts +100 -0
  317. package/src/plugins/pi-agent-ide-terminal/src/steering.ts +62 -0
  318. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +97 -45
  319. package/src/plugins/pi-agent-ide-terminal/src/types.ts +3 -1
  320. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +15 -6
  321. package/src/plugins/pi-agent-ide-vision/index.ts +16 -1
  322. package/dist/chunk-3E2NTWCN.js +0 -2
  323. package/dist/chunk-4LUW26BX.js +0 -10
  324. package/dist/chunk-5VSE5X5R.js +0 -2
  325. package/dist/chunk-CEX3VOJ7.js +0 -2
  326. package/dist/chunk-FA6BKC5Y.js +0 -1
  327. package/dist/chunk-FEDVTZJG.js +0 -1
  328. package/dist/chunk-HMLH43ZS.js +0 -4
  329. package/dist/chunk-KII2JQC5.js +0 -1
  330. package/dist/chunk-LVWMWWWF.js +0 -28
  331. package/dist/chunk-P7XO5CIP.js +0 -2
  332. package/dist/chunk-PZFOOHY2.js +0 -15
  333. package/dist/chunk-S3ZPXWX7.js +0 -2
  334. package/dist/chunk-T7CZIACQ.js +0 -27
  335. package/dist/chunk-YT42LKFV.js +0 -16
  336. package/node_modules/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
  337. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +0 -1
  338. package/node_modules/pi-agent-web/runtime/entry-82.js +0 -2
  339. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-83.js +0 -2
  340. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +0 -2
  341. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +0 -2
  342. package/src/extensions/pi-agent-text-editor/src/core/builtin-edit-filter.ts +0 -52
  343. /package/dist/{chunk-4U2GUKNJ.js → chunk-F7NVAC4Q.js} +0 -0
  344. /package/dist/{chunk-ROXXK6TW.js → chunk-PXWDDBBC.js} +0 -0
  345. /package/node_modules/{pi-agent-text-editor-renderer → pi-agent-text-editor}/runtime/entry-78.js +0 -0
  346. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
  347. /package/node_modules/{pi-agent-tool-ui → pi-agent-tool-call-interception}/runtime/entry-81.js +0 -0
  348. /package/node_modules/{pi-agent-web-html → pi-agent-web}/runtime/entry-83.js +0 -0
  349. /package/node_modules/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  350. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  351. /package/node_modules/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  352. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-image → pi-agent-web-html}/runtime/entry-84.js +0 -0
  353. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-image}/runtime/entry-85.js +0 -0
  354. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-pdf}/runtime/entry-86.js +0 -0
  355. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor-renderer}/runtime/entry-79.js +0 -0
@@ -10,6 +10,7 @@ import { terminalProcessProvider } from "#src/plugins/pi-agent-ide-terminal/src/
10
10
  import { registerTerminalResources } from "#src/plugins/pi-agent-ide-terminal/src/resources.js";
11
11
  import { registerTerminalSearch } from "#src/plugins/pi-agent-ide-terminal/src/search.js";
12
12
  import { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
13
+ import { observeQueuedSteering } from "#src/plugins/pi-agent-ide-terminal/src/steering.js";
13
14
  import { resolveShellProfile } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
14
15
  import { registerTerminalTools } from "#src/plugins/pi-agent-ide-terminal/src/tools.js";
15
16
  import { TerminalUi } from "#src/plugins/pi-agent-ide-terminal/src/ui.js";
@@ -27,6 +28,7 @@ export default async function registerTerminal(
27
28
  description: "Foreground and background commands, shell resources, and processes",
28
29
  triggers: [
29
30
  { tool: "bash" },
31
+ { tool: "powershell" },
30
32
  ...["read", "write", "insert", "delete"].map((tool) => ({
31
33
  tool,
32
34
  resourcePrefixes: ["shell:", "process:"],
@@ -42,7 +44,7 @@ export default async function registerTerminal(
42
44
  const removeProcessProvider = agentIdeProcessRegistry(pi).add(terminalProcessProvider(manager));
43
45
 
44
46
  await Promise.all([registerTerminalResources(pi, manager), registerTerminalSearch(pi, manager)]);
45
- registerTerminalTools(
47
+ const releaseForegroundWaits = registerTerminalTools(
46
48
  pi,
47
49
  manager,
48
50
  profile,
@@ -50,9 +52,17 @@ export default async function registerTerminal(
50
52
  toolPresentation(context?.preferences["ui.terminal"]),
51
53
  );
52
54
 
53
- pi.on("session_start", (_event, context) => ui.bind(context));
55
+ let removeSteeringObserver = (): void => {};
56
+ pi.on("session_start", (_event, context) => {
57
+ ui.bind(context);
58
+ removeSteeringObserver();
59
+ removeSteeringObserver = observeQueuedSteering((session) => {
60
+ if (session.sessionManager === context.sessionManager) releaseForegroundWaits();
61
+ });
62
+ });
54
63
  pi.on("agent_settled", (_event, context) => ui.onAgentSettled(context));
55
64
  pi.on("session_shutdown", async (event) => {
65
+ removeSteeringObserver();
56
66
  ui.dispose();
57
67
  removeProcessProvider();
58
68
  if (event.reason !== "quit") {
@@ -32,7 +32,7 @@ export function formatAgentTerminalSnapshot(snapshot: TerminalSessionSnapshot):
32
32
  snapshot.completionReason === undefined
33
33
  ? undefined
34
34
  : `completionReason: ${snapshot.completionReason}`,
35
- snapshot.waitReason === undefined
35
+ snapshot.waitReason === undefined || snapshot.status !== "running"
36
36
  ? undefined
37
37
  : `next: Read ${snapshot.source} to inspect it, then use write or insert to send input.`,
38
38
  `outputRange: ${snapshot.outputStart}-${snapshot.outputEnd}`,
@@ -13,6 +13,8 @@ import {
13
13
  type TextEditorPlugin,
14
14
  } from "pi-agent-text-editor/api/plugin-protocol";
15
15
  import type { AgentContent, ResourceResolver } from "pi-agent-resource";
16
+ import { withStructuredResult, resultError } from "pi-agent-resource";
17
+ import { mutationDataSchema } from "pi-agent-text-editor/api/mutation-result";
16
18
 
17
19
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
18
20
 
@@ -166,6 +168,7 @@ export async function registerTerminalResources(
166
168
  kind: "return",
167
169
  result: {
168
170
  content,
171
+ script: { kind: "native" as const, source: session.source, blocks: content },
169
172
  details: {
170
173
  source: session.source,
171
174
  resolvedBy: "terminal",
@@ -259,16 +262,23 @@ export async function registerTerminalResources(
259
262
  typeof requestedSource === "string" &&
260
263
  isShellSource(requestedSource)
261
264
  ) {
262
- return {
263
- content: [
264
- {
265
- type: "text",
266
- text: `replace is unsupported for ${requestedSource}; use write for text, insert for keys, or delete to terminate and remove the session.`,
265
+ const message = `replace is unsupported for ${requestedSource}; use write for text, insert for keys, or delete to terminate and remove the session.`;
266
+ return withStructuredResult(
267
+ {
268
+ content: [{ type: "text", text: message }],
269
+ details: event.details,
270
+ },
271
+ mutationDataSchema,
272
+ {
273
+ status: "error",
274
+ errors: [resultError(message, "UNSUPPORTED_OPERATION", requestedSource)],
275
+ data: {
276
+ operation: "replace",
277
+ effect: "not-applied",
278
+ files: [{ source: requestedSource, effect: "not-applied" }],
267
279
  },
268
- ],
269
- details: event.details,
270
- isError: true,
271
- };
280
+ },
281
+ );
272
282
  }
273
283
  if (
274
284
  event.toolName === "delete" &&
@@ -279,27 +289,49 @@ export async function registerTerminalResources(
279
289
  if (session === undefined) return;
280
290
  const snapshot = manager.snapshot(session);
281
291
  return manager.delete(requestedSource).then(
282
- () => ({
283
- content: [
284
- { type: "text" as const, text: `Deleted terminal session ${requestedSource}.` },
285
- ],
286
- details: {
287
- source: requestedSource,
288
- deleted: true,
289
- snapshot,
290
- action: "delete" as const,
291
- input: "session",
292
- changedLines: [],
293
- } satisfies TerminalActionDetails,
294
- isError: false,
295
- }),
296
- (error: unknown) => ({
297
- content: [
298
- { type: "text" as const, text: error instanceof Error ? error.message : String(error) },
299
- ],
300
- details: { source: requestedSource, deleted: false },
301
- isError: true,
302
- }),
292
+ () =>
293
+ withStructuredResult(
294
+ {
295
+ content: [{ type: "text", text: `Deleted terminal session ${requestedSource}.` }],
296
+ details: {
297
+ source: requestedSource,
298
+ deleted: true,
299
+ snapshot,
300
+ action: "delete",
301
+ input: "session",
302
+ changedLines: [],
303
+ } satisfies TerminalActionDetails,
304
+ },
305
+ mutationDataSchema,
306
+ {
307
+ status: "success",
308
+ errors: [],
309
+ data: {
310
+ operation: "delete",
311
+ effect: "applied",
312
+ files: [{ source: requestedSource, effect: "applied" }],
313
+ },
314
+ },
315
+ ),
316
+ (error: unknown) =>
317
+ withStructuredResult(
318
+ {
319
+ content: [
320
+ { type: "text", text: error instanceof Error ? error.message : String(error) },
321
+ ],
322
+ details: { source: requestedSource, deleted: false },
323
+ },
324
+ mutationDataSchema,
325
+ {
326
+ status: "error",
327
+ errors: [resultError(error, "TERMINAL_DELETE_FAILED", requestedSource)],
328
+ data: {
329
+ operation: "delete",
330
+ effect: "unknown",
331
+ files: [{ source: requestedSource, effect: "unknown" }],
332
+ },
333
+ },
334
+ ),
303
335
  );
304
336
  }
305
337
  if (event.toolName !== "write" && event.toolName !== "insert") return;
@@ -342,6 +374,9 @@ export async function registerTerminalResources(
342
374
  changedLines: region.lines,
343
375
  } satisfies TerminalActionDetails,
344
376
  isError: event.isError,
377
+ ...(event.structuredContent === undefined
378
+ ? {}
379
+ : { structuredContent: event.structuredContent }),
345
380
  };
346
381
  });
347
382
  }
@@ -5,9 +5,10 @@ import {
5
5
  type SearchPlugin,
6
6
  } from "pi-agent-search/api/plugin-protocol";
7
7
  import type { SearchRequest, SearchSelectionMatch } from "pi-agent-search/api/search";
8
+ import { selectionData } from "pi-agent-search/api/search";
8
9
 
9
10
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
10
- import type { Component } from "@earendil-works/pi-tui";
11
+ import { truncateToWidth, visibleWidth, type Component } from "@earendil-works/pi-tui";
11
12
 
12
13
  import { renderTerminalAction } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
13
14
  import type { TerminalSessionManager } from "#src/plugins/pi-agent-ide-terminal/src/session-manager.js";
@@ -40,7 +41,13 @@ export async function registerTerminalSearch(
40
41
 
41
42
  function terminalSearchResolver(manager: TerminalSessionManager) {
42
43
  return {
44
+ readResources: (request: SearchRequest) =>
45
+ request.path?.startsWith("shell:") ? [request.path] : [],
43
46
  id: "terminal",
47
+ toScriptData(payload: unknown) {
48
+ const result = parsePayload(payload);
49
+ return selectionData(result.matches, false);
50
+ },
44
51
  async tryResolve(request: SearchRequest) {
45
52
  if (request.path === undefined || !request.path.startsWith("shell:")) {
46
53
  return { kind: "not-handled" as const };
@@ -114,13 +121,11 @@ export class TerminalSearchPanel implements Component {
114
121
  const rows = this.content.render(width);
115
122
  if (this.expanded || rows.length <= COMPACT_TERMINAL_SEARCH_ROWS) return rows;
116
123
  const shown = COMPACT_TERMINAL_SEARCH_ROWS - 1;
117
- return [
118
- ...rows.slice(0, shown),
119
- this.theme.fg(
120
- "muted",
121
- `… ${String(rows.length - shown)} visual rows omitted · ctrl+o to expand`,
122
- ),
123
- ];
124
+ const omitted = String(rows.length - shown);
125
+ const fullHint = `… ${omitted} visual rows omitted · ctrl+o to expand`;
126
+ const hint =
127
+ visibleWidth(fullHint) <= width ? fullHint : `… ${omitted} visual rows omitted · ctrl+o`;
128
+ return [...rows.slice(0, shown), this.theme.fg("muted", truncateToWidth(hint, width))];
124
129
  }
125
130
 
126
131
  public invalidate(): void {
@@ -132,6 +132,7 @@ export class TerminalSessionManager {
132
132
  completion,
133
133
  resolveCompletion,
134
134
  completionDelivered: false,
135
+ staleReminderDelivered: false,
135
136
  };
136
137
 
137
138
  let process: IPty;
@@ -0,0 +1,100 @@
1
+ import { open } from "node:fs/promises";
2
+ import { Type } from "typebox";
3
+ import type { TerminalSessionSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
4
+
5
+ const MAX_OUTPUT_BYTES = 1024 * 1024;
6
+
7
+ /** Native shell fields plus IDE session lifecycle and exact UTF-8 log ranges. */
8
+ export const shellOutputSchema = Type.Object({
9
+ output: Type.String({
10
+ description:
11
+ "ANSI-free PTY output, up to 1 MiB. Longer output joins the first and last 512 KiB without adding labels or an omission marker. See output_ranges for the gap.",
12
+ }),
13
+ truncated: Type.Boolean({
14
+ description:
15
+ "Whether output omits bytes from the retained log. This is independent of whether the process has finished.",
16
+ }),
17
+ full_output_path: Type.String({
18
+ description:
19
+ "UTF-8 log of all output received so far. Available until the shell session is deleted.",
20
+ }),
21
+ output_ranges: Type.Array(Type.Object({ start: Type.Integer(), end: Type.Integer() }), {
22
+ description:
23
+ "Zero-based, end-exclusive UTF-8 byte ranges in the log, concatenated into output.",
24
+ }),
25
+ exit_code: Type.Optional(Type.Number({ description: "Process exit code, only when known." })),
26
+ wall_time_seconds: Type.Number(),
27
+ session: Type.String({ description: "Session ID." }),
28
+ source: Type.String({ description: "Persistent shell: source for Read, input and termination." }),
29
+ status: Type.Union(
30
+ ["running", "completed", "failed", "stopping", "stopped", "cancelled", "lost"].map((value) =>
31
+ Type.Literal(value),
32
+ ),
33
+ ),
34
+ background: Type.Boolean(),
35
+ wait_reason: Type.Optional(
36
+ Type.Union([Type.Literal("timeout"), Type.Literal("interactive"), Type.Literal("steering")]),
37
+ ),
38
+ completion_reason: Type.Optional(Type.Literal("timeout")),
39
+ signal: Type.Optional(Type.Number()),
40
+ error: Type.Optional(Type.String()),
41
+ });
42
+
43
+ /** Read a bounded point-in-time result from the existing log, not the rolling preview. */
44
+ export async function structuredShellResult(snapshot: TerminalSessionSnapshot) {
45
+ const file = await open(snapshot.fullOutputPath, "r");
46
+ try {
47
+ const size = (await file.stat()).size;
48
+ const readRange = async (start: number, length: number) => {
49
+ const buffer = Buffer.alloc(length);
50
+ let read = 0;
51
+ while (read < length) {
52
+ const chunk = await file.read(buffer, read, length - read, start + read);
53
+ if (chunk.bytesRead === 0)
54
+ throw new Error("Shell output log ended before its snapshot size");
55
+ read += chunk.bytesRead;
56
+ }
57
+ return buffer;
58
+ };
59
+ let output: string;
60
+ let outputRanges: { start: number; end: number }[];
61
+ const truncated = size > MAX_OUTPUT_BYTES;
62
+ if (!truncated) {
63
+ output = (await readRange(0, size)).toString("utf8");
64
+ outputRanges = [{ start: 0, end: size }];
65
+ } else {
66
+ const half = MAX_OUTPUT_BYTES / 2;
67
+ const head = await readRange(0, half);
68
+ const tail = await readRange(size - half, half);
69
+ const headText = new TextDecoder().decode(head, { stream: true });
70
+ let tailStart = 0;
71
+ while (tailStart < tail.length && (tail.readUInt8(tailStart) & 0xc0) === 0x80) tailStart++;
72
+ const tailText = tail.subarray(tailStart).toString("utf8");
73
+ output = headText + tailText;
74
+ outputRanges = [
75
+ { start: 0, end: Buffer.byteLength(headText) },
76
+ { start: size - half + tailStart, end: size },
77
+ ];
78
+ }
79
+ return {
80
+ output,
81
+ truncated,
82
+ full_output_path: snapshot.fullOutputPath,
83
+ output_ranges: outputRanges,
84
+ ...(snapshot.exitCode === undefined ? {} : { exit_code: snapshot.exitCode }),
85
+ wall_time_seconds: snapshot.elapsedMs / 1000,
86
+ session: snapshot.id,
87
+ source: snapshot.source,
88
+ status: snapshot.status,
89
+ background: snapshot.background,
90
+ ...(snapshot.waitReason === undefined ? {} : { wait_reason: snapshot.waitReason }),
91
+ ...(snapshot.completionReason === undefined
92
+ ? {}
93
+ : { completion_reason: snapshot.completionReason }),
94
+ ...(snapshot.signal === undefined ? {} : { signal: snapshot.signal }),
95
+ ...(snapshot.error === undefined ? {} : { error: snapshot.error }),
96
+ };
97
+ } finally {
98
+ await file.close();
99
+ }
100
+ }
@@ -0,0 +1,62 @@
1
+ import { AgentSession } from "@earendil-works/pi-coding-agent";
2
+
3
+ type SteeringObserver = (session: AgentSession) => void;
4
+ const observersKey = Symbol.for("pi-agent-ide.terminal-steering-observers");
5
+ interface SteeringObservers {
6
+ readonly listeners: Set<SteeringObserver>;
7
+ readonly restore: () => void;
8
+ }
9
+ type ObservedPrototype = typeof AgentSession.prototype & {
10
+ [observersKey]?: SteeringObservers;
11
+ };
12
+
13
+ /** Observe accepted user steering after Pi queues it, without bypassing its input handlers. */
14
+ export function observeQueuedSteering(observer: SteeringObserver): () => void {
15
+ const prototype = AgentSession.prototype as ObservedPrototype;
16
+ const observers = prototype[observersKey] ?? installObservers(prototype);
17
+ observers.listeners.add(observer);
18
+ return () => {
19
+ observers.listeners.delete(observer);
20
+ if (observers.listeners.size === 0) observers.restore();
21
+ };
22
+ }
23
+
24
+ function installObservers(prototype: ObservedPrototype): SteeringObservers {
25
+ const originalPrompt = prototype.prompt;
26
+ const originalSteer = prototype.steer;
27
+ const listeners = new Set<SteeringObserver>();
28
+ const notify = (session: AgentSession): void => {
29
+ for (const listener of [...listeners]) listener(session);
30
+ };
31
+
32
+ // TUI Enter calls prompt, while RPC and queue editing call steer directly.
33
+ // The preflight hook runs after queue insertion and distinguishes consumed input.
34
+ const prompt: AgentSession["prompt"] = function (this: AgentSession, text, options) {
35
+ if (options?.streamingBehavior !== "steer") return originalPrompt.call(this, text, options);
36
+ return originalPrompt.call(this, text, {
37
+ ...options,
38
+ preflightResult: (disposition) => {
39
+ options.preflightResult?.(disposition);
40
+ if (disposition === "queued") notify(this);
41
+ },
42
+ });
43
+ };
44
+ const steer: AgentSession["steer"] = async function (this: AgentSession, ...args) {
45
+ const disposition = await originalSteer.apply(this, args);
46
+ if (disposition === "queued") notify(this);
47
+ return disposition;
48
+ };
49
+ prototype.prompt = prompt;
50
+ prototype.steer = steer;
51
+ const observers: SteeringObservers = {
52
+ listeners,
53
+ restore: () => {
54
+ if (prototype[observersKey] !== observers) return;
55
+ if (prototype.prompt === prompt) prototype.prompt = originalPrompt;
56
+ if (prototype.steer === steer) prototype.steer = originalSteer;
57
+ delete prototype[observersKey];
58
+ },
59
+ };
60
+ prototype[observersKey] = observers;
61
+ return observers;
62
+ }
@@ -6,7 +6,14 @@ import { Type } from "typebox";
6
6
  import { Text } from "@earendil-works/pi-tui";
7
7
 
8
8
  import { COMPACT_READ_ROWS } from "#src/extensions/pi-agent-read/src/core/tools/read/read-renderer.js";
9
- import { formatAgentTerminalSnapshot } from "#src/plugins/pi-agent-ide-terminal/src/output-limits.js";
9
+ import {
10
+ formatAgentTerminalSnapshot,
11
+ terminalOutputTail,
12
+ } from "#src/plugins/pi-agent-ide-terminal/src/output-limits.js";
13
+ import {
14
+ shellOutputSchema,
15
+ structuredShellResult,
16
+ } from "#src/plugins/pi-agent-ide-terminal/src/shell-result.js";
10
17
  import { renderRunCall, renderRunResult } from "#src/plugins/pi-agent-ide-terminal/src/renderer.js";
11
18
 
12
19
  import { shellSyntaxGuidance } from "#src/plugins/pi-agent-ide-terminal/src/shell-profile.js";
@@ -17,59 +24,76 @@ import type {
17
24
  TerminalSessionSnapshot,
18
25
  } from "#src/plugins/pi-agent-ide-terminal/src/types.js";
19
26
 
20
- const runParameters = Type.Object(
21
- {
22
- command: Type.String({
23
- minLength: 1,
24
- description: "Command written in the syntax of the configured system shell",
25
- }),
26
- background: Type.Optional(
27
- Type.Boolean({
28
- description: "Return immediately while the terminal session continues. Defaults to false.",
29
- }),
30
- ),
31
- timeoutSeconds: Type.Optional(
32
- Type.Number({
33
- minimum: 0.1,
34
- maximum: 86_400,
35
- description:
36
- "Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
27
+ const createRunParameters = (profile: ShellProfile) =>
28
+ Type.Object(
29
+ {
30
+ command: Type.String({
31
+ minLength: 1,
32
+ description: `Command for ${profile.displayName} (${profile.executable}). ${shellSyntaxGuidance(profile)}`,
37
33
  }),
38
- ),
39
- cwd: Type.Optional(
40
- Type.String({
41
- description: "Working directory. Relative paths resolve from the current workspace.",
42
- }),
43
- ),
44
- cols: Type.Optional(
45
- Type.Integer({ minimum: 20, maximum: 300, description: "Virtual terminal width in cells" }),
46
- ),
47
- rows: Type.Optional(
48
- Type.Integer({ minimum: 5, maximum: 120, description: "Virtual terminal height in cells" }),
49
- ),
50
- },
51
- { additionalProperties: false },
52
- );
34
+ background: Type.Optional(
35
+ Type.Boolean({
36
+ description:
37
+ "Return immediately while the terminal session continues. Defaults to false.",
38
+ }),
39
+ ),
40
+ timeoutSeconds: Type.Optional(
41
+ Type.Number({
42
+ minimum: 0.1,
43
+ maximum: 86_400,
44
+ description:
45
+ "Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
46
+ }),
47
+ ),
48
+ cwd: Type.Optional(
49
+ Type.String({
50
+ description: "Working directory. Relative paths resolve from the current workspace.",
51
+ }),
52
+ ),
53
+ cols: Type.Optional(
54
+ Type.Integer({ minimum: 20, maximum: 300, description: "Virtual terminal width in cells" }),
55
+ ),
56
+ rows: Type.Optional(
57
+ Type.Integer({ minimum: 5, maximum: 120, description: "Virtual terminal height in cells" }),
58
+ ),
59
+ },
60
+ { additionalProperties: false },
61
+ );
53
62
 
54
- /** Register terminal process lifecycle tools with platform-specific shell guidance. */
63
+ /** Register shell tools and return a callback that releases their active waits on steering. */
55
64
  export function registerTerminalTools(
56
- pi: ExtensionAPI,
65
+ pi: Pick<ExtensionAPI, "registerTool">,
57
66
  manager: TerminalSessionManager,
58
67
  profile: ShellProfile,
59
68
  ui: Pick<TerminalUi, "bind" | "notifyWaitTransition">,
60
69
  presentation: "full" | "compact" | "disabled" = "compact",
61
- ): void {
70
+ ): () => void {
71
+ // Keep wait cancellation in this registration, not in a PTY manager retained from older code.
72
+ const foregroundWaits = new Set<AbortController>();
62
73
  const toolName = process.platform === "win32" ? "powershell" : "bash";
74
+ const runParameters = createRunParameters(profile);
63
75
  pi.registerTool(
64
76
  defineTool<typeof runParameters, TerminalSessionSnapshot>({
65
77
  name: toolName,
78
+ exposure: "direct",
79
+ namespace: {
80
+ name: "ide_terminal",
81
+ description: "Run shell commands in persistent terminal sessions.",
82
+ },
83
+ annotations: {
84
+ readOnlyHint: false,
85
+ destructiveHint: true,
86
+ idempotentHint: false,
87
+ openWorldHint: true,
88
+ },
66
89
  label: profile.displayName,
67
90
  promptSnippet: `Execute ${profile.displayName} commands in synchronous or background terminal sessions`,
68
91
  promptGuidelines: [
69
92
  `Do not use ${toolName} commands or scripts to edit files. Use Apply or the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`,
70
93
  ],
71
- description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions are treated as potentially stale after two minutes and wake an idle agent for inspection. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated. ${shellSyntaxGuidance(profile)}`,
94
+ description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions wake an idle agent once for inspection after two minutes, with no further stale reminders for that session. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated.`,
72
95
  parameters: runParameters,
96
+ outputSchema: shellOutputSchema,
73
97
  async execute(_toolCallId, input, signal, onUpdate, context) {
74
98
  ui.bind(context);
75
99
  const cwd = input.cwd === undefined ? context.cwd : path.resolve(context.cwd, input.cwd);
@@ -87,10 +111,22 @@ export function registerTerminalTools(
87
111
  return terminalResult(manager.snapshot(session));
88
112
  }
89
113
  if (session.status === "failed") return terminalResult(manager.snapshot(session));
90
- const outcome = await manager.waitForForeground(session.source, {
91
- signal,
92
- timeoutMs: (input.timeoutSeconds ?? 60) * 1_000,
93
- });
114
+ const steering = new AbortController();
115
+ foregroundWaits.add(steering);
116
+ let outcome;
117
+ try {
118
+ outcome = await manager.waitForForeground(session.source, {
119
+ signal:
120
+ signal === undefined ? steering.signal : AbortSignal.any([signal, steering.signal]),
121
+ timeoutMs: (input.timeoutSeconds ?? 60) * 1_000,
122
+ });
123
+ } finally {
124
+ foregroundWaits.delete(steering);
125
+ }
126
+ if (outcome.reason === "aborted" && steering.signal.aborted && signal?.aborted !== true) {
127
+ outcome.session.waitReason = "steering";
128
+ return terminalResult(manager.snapshot(outcome.session));
129
+ }
94
130
  if (outcome.reason === "aborted") ui.notifyWaitTransition(outcome.session);
95
131
  return terminalResult(manager.snapshot(outcome.session));
96
132
  },
@@ -111,19 +147,35 @@ export function registerTerminalTools(
111
147
  },
112
148
  }),
113
149
  );
150
+ return () => {
151
+ for (const wait of foregroundWaits) wait.abort();
152
+ };
114
153
  }
115
154
 
116
- function terminalResult(snapshot: TerminalSessionSnapshot) {
155
+ function terminalPreview(snapshot: TerminalSessionSnapshot) {
156
+ const output = terminalOutputTail(snapshot.output).content;
117
157
  return {
118
158
  content: [{ type: "text" as const, text: formatAgentTerminalSnapshot(snapshot) }],
119
- details: snapshot,
159
+ details: {
160
+ ...snapshot,
161
+ output,
162
+ outputStart: snapshot.outputEnd - output.length,
163
+ truncated: snapshot.truncated || output.length < snapshot.output.length,
164
+ },
120
165
  isError: snapshot.status === "failed" || snapshot.status === "lost",
121
166
  };
122
167
  }
168
+
169
+ async function terminalResult(snapshot: TerminalSessionSnapshot) {
170
+ return {
171
+ ...terminalPreview(snapshot),
172
+ structuredContent: await structuredShellResult(snapshot),
173
+ };
174
+ }
123
175
  async function captureInitialBackgroundPreview(
124
176
  manager: TerminalSessionManager,
125
177
  session: ReturnType<TerminalSessionManager["start"]>,
126
- onUpdate: ((result: ReturnType<typeof terminalResult>) => void) | undefined,
178
+ onUpdate: ((result: ReturnType<typeof terminalPreview>) => void) | undefined,
127
179
  ): Promise<void> {
128
180
  await new Promise<void>((resolve) => {
129
181
  let settled = false;
@@ -138,7 +190,7 @@ async function captureInitialBackgroundPreview(
138
190
  };
139
191
  const publish = (): void => {
140
192
  const snapshot = manager.snapshot(session);
141
- onUpdate?.(terminalResult(snapshot));
193
+ onUpdate?.(terminalPreview(snapshot));
142
194
  const rows = stripVTControlCharacters(snapshot.output)
143
195
  .replaceAll("\r", "")
144
196
  .split("\n")
@@ -1,7 +1,7 @@
1
1
  import type { IPty } from "node-pty";
2
2
  import type { Terminal } from "@xterm/headless";
3
3
 
4
- export type TerminalWaitReason = "timeout" | "interactive";
4
+ export type TerminalWaitReason = "timeout" | "interactive" | "steering";
5
5
  export type TerminalWaitOutcomeReason = TerminalWaitReason | "aborted";
6
6
  export type TerminalCompletionReason = "timeout";
7
7
 
@@ -45,6 +45,8 @@ export interface TerminalSession {
45
45
  completion: Promise<TerminalSession>;
46
46
  resolveCompletion: (session: TerminalSession) => void;
47
47
  completionDelivered: boolean;
48
+ /** Keep the one-time stale reminder state when this session survives a reload. */
49
+ staleReminderDelivered: boolean;
48
50
  waitReason?: TerminalWaitReason;
49
51
  completionReason?: TerminalCompletionReason;
50
52
  lastActivityAt: number;
@@ -96,7 +96,13 @@ export class TerminalUi {
96
96
 
97
97
  #refreshStaleTimer(session: TerminalSession, checkNow = false): void {
98
98
  this.#clearStaleTimer(session.id);
99
- if (this.#closed || !session.background || session.status !== "running") return;
99
+ if (
100
+ this.#closed ||
101
+ session.staleReminderDelivered ||
102
+ !session.background ||
103
+ session.status !== "running"
104
+ )
105
+ return;
100
106
  const snapshot = this.manager.snapshot(session);
101
107
  const remaining = Math.max(0, this.staleIntervalMs - snapshot.idleMs);
102
108
  if (checkNow && remaining === 0) {
@@ -111,11 +117,18 @@ export class TerminalUi {
111
117
 
112
118
  #handleStale(session: TerminalSession): void {
113
119
  this.#staleTimers.delete(session.id);
114
- if (this.#closed || session.status !== "running" || !session.background) return;
120
+ if (
121
+ this.#closed ||
122
+ session.staleReminderDelivered ||
123
+ session.status !== "running" ||
124
+ !session.background
125
+ )
126
+ return;
115
127
  if (this.#context?.isIdle() !== true) {
116
128
  this.#overdue.add(session.id);
117
129
  return;
118
130
  }
131
+ session.staleReminderDelivered = true;
119
132
  const snapshot = this.manager.snapshot(session);
120
133
  this.pi.sendMessage(
121
134
  {
@@ -126,10 +139,6 @@ export class TerminalUi {
126
139
  },
127
140
  { triggerTurn: true, deliverAs: "followUp" },
128
141
  );
129
- this.#staleTimers.set(
130
- session.id,
131
- setTimeout(() => this.#handleStale(session), this.staleIntervalMs),
132
- );
133
142
  }
134
143
 
135
144
  #clearStaleTimer(id: string): void {