@linxiraos/pi-tui 1.4.6 → 1.4.9

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 (399) hide show
  1. package/CHANGELOG.md +162 -244
  2. package/README.md +41 -35
  3. package/dist/types/app-keybindings.d.ts +20 -0
  4. package/dist/types/apps/session-picker.d.ts +5 -0
  5. package/dist/types/charts/chart-plan.d.ts +9 -7
  6. package/dist/types/charts/table-data.d.ts +4 -2
  7. package/dist/types/chat/assistant-message.d.ts +15 -3
  8. package/dist/types/chat/bash-execution.d.ts +6 -1
  9. package/dist/types/chat/display-preferences.d.ts +2 -0
  10. package/dist/types/chat/eval-execution.d.ts +2 -0
  11. package/dist/types/chat/execution-shared.d.ts +14 -8
  12. package/dist/types/chat/extension-types.d.ts +31 -0
  13. package/dist/types/chat/figure-markdown.d.ts +2 -0
  14. package/dist/types/chat/reply-write.d.ts +48 -0
  15. package/dist/types/chat/svg-figure.d.ts +5 -0
  16. package/dist/types/chat/table-chart.d.ts +6 -3
  17. package/dist/types/chat/tool-execution.d.ts +1 -2
  18. package/dist/types/chat/transcript-outline.d.ts +7 -0
  19. package/dist/types/chat/transcript-render-helpers.d.ts +13 -3
  20. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  21. package/dist/types/chrome/index.d.ts +1 -0
  22. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  23. package/dist/types/chrome/transcript-status.d.ts +21 -9
  24. package/dist/types/components/editor.d.ts +23 -6
  25. package/dist/types/components/image.d.ts +6 -0
  26. package/dist/types/components/loader.d.ts +2 -0
  27. package/dist/types/components/markdown.d.ts +7 -0
  28. package/dist/types/keybinding-matchers.d.ts +7 -0
  29. package/dist/types/native/blobs.d.ts +2 -1
  30. package/dist/types/native/describe.d.ts +4 -2
  31. package/dist/types/native/node.d.ts +2 -3
  32. package/dist/types/native/overlay.d.ts +42 -2
  33. package/dist/types/native/picker.d.ts +4 -4
  34. package/dist/types/native/state.d.ts +4 -0
  35. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  36. package/dist/types/overlays/annotation-types.d.ts +28 -0
  37. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  38. package/dist/types/overlays/btw-history.d.ts +24 -0
  39. package/dist/types/overlays/btw-inject.d.ts +22 -0
  40. package/dist/types/overlays/btw-panel.d.ts +7 -0
  41. package/dist/types/overlays/hook-editor.d.ts +2 -0
  42. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  43. package/dist/types/overlays/login-dialog.d.ts +5 -1
  44. package/dist/types/overlays/model-browser.d.ts +11 -2
  45. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  46. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  47. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  48. package/dist/types/overlays/session-selector.d.ts +33 -4
  49. package/dist/types/prompt/composer.d.ts +56 -5
  50. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  51. package/dist/types/render/extension-links.d.ts +65 -0
  52. package/dist/types/render/hyperlink.d.ts +25 -7
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/render-utils.d.ts +23 -1
  55. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  56. package/dist/types/setup/scenes/model.d.ts +1 -1
  57. package/dist/types/setup/scenes/outro.d.ts +5 -4
  58. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  59. package/dist/types/setup/scenes/types.d.ts +16 -1
  60. package/dist/types/setup/startup-splash.d.ts +1 -1
  61. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  62. package/dist/types/setup/wizard.d.ts +5 -1
  63. package/dist/types/status-line/component.d.ts +1 -1
  64. package/dist/types/status-line/context-usage.d.ts +28 -6
  65. package/dist/types/status-line/host.d.ts +6 -2
  66. package/dist/types/status-line/startup.d.ts +0 -15
  67. package/dist/types/terminal-capabilities.d.ts +1 -1
  68. package/dist/types/theme/symbols.d.ts +3 -1
  69. package/dist/types/theme/theme-class.d.ts +1 -0
  70. package/dist/types/theme/theme.d.ts +1 -24
  71. package/dist/types/theme/tui-adapters.d.ts +2 -0
  72. package/dist/types/thinking.d.ts +8 -6
  73. package/dist/types/tools/ast-grep.d.ts +2 -0
  74. package/dist/types/tools/bash-interactive.d.ts +6 -0
  75. package/dist/types/tools/bash.d.ts +2 -0
  76. package/dist/types/tools/default-renderer.d.ts +6 -4
  77. package/dist/types/tools/eval.d.ts +2 -0
  78. package/dist/types/tools/find.d.ts +1 -1
  79. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  80. package/dist/types/tools/hashline-format.d.ts +5 -0
  81. package/dist/types/tools/irc.d.ts +6 -0
  82. package/dist/types/tools/json-tree.d.ts +23 -4
  83. package/dist/types/tools/lsp.d.ts +2 -0
  84. package/dist/types/tools/mcp.d.ts +6 -5
  85. package/dist/types/tools/native-view.d.ts +3 -1
  86. package/dist/types/tools/output-meta.d.ts +27 -0
  87. package/dist/types/tools/read.d.ts +14 -4
  88. package/dist/types/tools/renderer.d.ts +2 -0
  89. package/dist/types/tools/streaming-output.d.ts +11 -0
  90. package/dist/types/tools/task.d.ts +13 -4
  91. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  92. package/dist/types/tools/wait.d.ts +2 -0
  93. package/dist/types/tools/yield.d.ts +1 -1
  94. package/dist/types/tui.d.ts +19 -2
  95. package/dist/types/utils.d.ts +4 -0
  96. package/package.json +10 -14
  97. package/src/app-keybindings.d.ts +20 -0
  98. package/src/app-keybindings.ts +20 -0
  99. package/src/apps/git/git-tui.ts +10 -17
  100. package/src/apps/git/sidebar.ts +21 -35
  101. package/src/apps/ps-top.ts +4 -12
  102. package/src/apps/session-picker.ts +7 -0
  103. package/src/charts/chart-plan.d.ts +9 -7
  104. package/src/charts/chart-plan.ts +20 -79
  105. package/src/charts/table-data.d.ts +4 -2
  106. package/src/charts/table-data.ts +55 -6
  107. package/src/chat/advisor-message.ts +2 -0
  108. package/src/chat/assistant-message.d.ts +15 -3
  109. package/src/chat/assistant-message.ts +137 -19
  110. package/src/chat/background-tan-message.ts +4 -0
  111. package/src/chat/bash-execution.d.ts +6 -1
  112. package/src/chat/bash-execution.ts +26 -9
  113. package/src/chat/chat-transcript-builder.ts +63 -30
  114. package/src/chat/compaction-summary-message.ts +2 -1
  115. package/src/chat/display-preferences.d.ts +2 -0
  116. package/src/chat/display-preferences.ts +3 -0
  117. package/src/chat/eval-execution.d.ts +2 -0
  118. package/src/chat/eval-execution.ts +14 -7
  119. package/src/chat/execution-shared.d.ts +14 -8
  120. package/src/chat/execution-shared.ts +39 -18
  121. package/src/chat/extension-types.d.ts +31 -0
  122. package/src/chat/extension-types.ts +34 -0
  123. package/src/chat/figure-markdown.d.ts +2 -0
  124. package/src/chat/figure-markdown.ts +6 -4
  125. package/src/chat/read-tool-group.ts +56 -36
  126. package/src/chat/reply-write.d.ts +48 -0
  127. package/src/chat/reply-write.ts +127 -0
  128. package/src/chat/svg-figure.d.ts +5 -0
  129. package/src/chat/svg-figure.ts +55 -16
  130. package/src/chat/table-chart.d.ts +6 -3
  131. package/src/chat/table-chart.ts +29 -6
  132. package/src/chat/tool-execution.d.ts +1 -2
  133. package/src/chat/tool-execution.ts +20 -13
  134. package/src/chat/transcript-outline.d.ts +7 -0
  135. package/src/chat/transcript-outline.ts +27 -0
  136. package/src/chat/transcript-render-helpers.d.ts +13 -3
  137. package/src/chat/transcript-render-helpers.ts +134 -44
  138. package/src/chrome/dynamic-border.d.ts +6 -0
  139. package/src/chrome/dynamic-border.ts +28 -2
  140. package/src/chrome/index.ts +1 -0
  141. package/src/chrome/transcript-notice.d.ts +35 -0
  142. package/src/chrome/transcript-notice.ts +83 -0
  143. package/src/chrome/transcript-status.d.ts +21 -9
  144. package/src/chrome/transcript-status.ts +32 -30
  145. package/src/components/editor.d.ts +23 -6
  146. package/src/components/editor.ts +133 -25
  147. package/src/components/image.d.ts +6 -0
  148. package/src/components/image.ts +13 -0
  149. package/src/components/key-value-list.ts +9 -9
  150. package/src/components/loader.d.ts +2 -0
  151. package/src/components/loader.ts +7 -0
  152. package/src/components/markdown.d.ts +7 -0
  153. package/src/components/markdown.ts +116 -6
  154. package/src/components/section.ts +1 -9
  155. package/src/components/table.ts +1 -9
  156. package/src/hotkeys-markdown.ts +1 -0
  157. package/src/keybinding-matchers.d.ts +7 -0
  158. package/src/keybinding-matchers.ts +13 -0
  159. package/src/native/backend.ts +10 -67
  160. package/src/native/blobs.d.ts +2 -1
  161. package/src/native/blobs.ts +3 -2
  162. package/src/native/describe.d.ts +4 -2
  163. package/src/native/describe.ts +9 -4
  164. package/src/native/node.d.ts +2 -3
  165. package/src/native/node.ts +2 -3
  166. package/src/native/overlay.d.ts +42 -2
  167. package/src/native/overlay.ts +124 -16
  168. package/src/native/picker.d.ts +4 -4
  169. package/src/native/picker.ts +4 -4
  170. package/src/native/state.d.ts +4 -0
  171. package/src/native/state.ts +25 -5
  172. package/src/overlays/advisor-config.ts +1 -10
  173. package/src/overlays/annotation-overlay.ts +125 -37
  174. package/src/overlays/annotation-types.ts +24 -0
  175. package/src/overlays/btw-history-panel.ts +106 -14
  176. package/src/overlays/btw-history.ts +65 -0
  177. package/src/overlays/btw-inject.ts +91 -0
  178. package/src/overlays/btw-panel.ts +53 -12
  179. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  180. package/src/overlays/hook-editor.ts +6 -0
  181. package/src/overlays/hook-selector.ts +2 -2
  182. package/src/overlays/jobs-panel.ts +82 -22
  183. package/src/overlays/login-dialog.ts +39 -31
  184. package/src/overlays/mcp-add-wizard.ts +1 -1
  185. package/src/overlays/model-browser.ts +106 -10
  186. package/src/overlays/model-hub.ts +1 -7
  187. package/src/overlays/model-picker.ts +1 -10
  188. package/src/overlays/oauth-selector.ts +44 -6
  189. package/src/overlays/plan-review-overlay.ts +13 -2
  190. package/src/overlays/rewind-selector.ts +29 -12
  191. package/src/overlays/session-selector.ts +338 -47
  192. package/src/overlays/settings-defs.ts +2 -2
  193. package/src/overlays/tree-selector.ts +83 -27
  194. package/src/overlays/usage-dashboard.ts +9 -18
  195. package/src/prompt/composer.ts +233 -6
  196. package/src/prompt/custom-editor.ts +6 -1
  197. package/src/prompt/emoji-autocomplete.ts +0 -2
  198. package/src/prompt/interactive-context-helpers.ts +29 -4
  199. package/src/render/code-cell.ts +1 -1
  200. package/src/render/extension-links.d.ts +65 -0
  201. package/src/render/extension-links.ts +214 -0
  202. package/src/render/file-list.ts +4 -7
  203. package/src/render/hyperlink.d.ts +25 -7
  204. package/src/render/hyperlink.ts +65 -9
  205. package/src/render/index.d.ts +1 -0
  206. package/src/render/index.ts +1 -0
  207. package/src/render/render-utils.d.ts +23 -1
  208. package/src/render/render-utils.ts +38 -6
  209. package/src/setup/scenes/composer.ts +2 -0
  210. package/src/setup/scenes/glyph.ts +4 -2
  211. package/src/setup/scenes/model.ts +192 -29
  212. package/src/setup/scenes/outro.ts +33 -15
  213. package/src/setup/scenes/sign-in.ts +196 -400
  214. package/src/setup/scenes/theme.ts +2 -0
  215. package/src/setup/scenes/types.ts +18 -1
  216. package/src/setup/startup-splash.ts +8 -7
  217. package/src/setup/wizard-overlay.ts +164 -35
  218. package/src/setup/wizard.ts +11 -2
  219. package/src/status-line/component.ts +4 -10
  220. package/src/status-line/context-usage.ts +72 -21
  221. package/src/status-line/host.ts +6 -2
  222. package/src/status-line/startup.ts +36 -70
  223. package/src/terminal-capabilities.d.ts +1 -1
  224. package/src/terminal-capabilities.ts +5 -0
  225. package/src/terminal.ts +24 -2
  226. package/src/theme/defaults.json +1 -0
  227. package/src/theme/loader.ts +1 -1
  228. package/src/theme/symbols.d.ts +3 -1
  229. package/src/theme/symbols.ts +16 -9
  230. package/src/theme/theme-class.d.ts +1 -0
  231. package/src/theme/theme-class.ts +15 -3
  232. package/src/theme/theme.d.ts +1 -24
  233. package/src/theme/theme.ts +3 -75
  234. package/src/theme/tui-adapters.d.ts +2 -0
  235. package/src/theme/tui-adapters.ts +8 -3
  236. package/src/thinking.d.ts +8 -6
  237. package/src/thinking.ts +17 -11
  238. package/src/tmux.ts +1 -0
  239. package/src/tools/agent-tree.ts +13 -11
  240. package/src/tools/ask.ts +24 -37
  241. package/src/tools/ast-edit.ts +48 -93
  242. package/src/tools/ast-grep.d.ts +2 -0
  243. package/src/tools/ast-grep.ts +31 -67
  244. package/src/tools/bash-interactive.d.ts +49 -0
  245. package/src/tools/bash-interactive.ts +6 -1
  246. package/src/tools/bash.d.ts +2 -0
  247. package/src/tools/bash.ts +9 -0
  248. package/src/tools/default-renderer.d.ts +6 -4
  249. package/src/tools/default-renderer.ts +10 -7
  250. package/src/tools/edit.ts +50 -43
  251. package/src/tools/eval.d.ts +2 -0
  252. package/src/tools/eval.ts +16 -4
  253. package/src/tools/fetch.ts +2 -1
  254. package/src/tools/find.d.ts +1 -1
  255. package/src/tools/find.ts +13 -5
  256. package/src/tools/github.ts +14 -46
  257. package/src/tools/glob.ts +2 -1
  258. package/src/tools/grep.ts +47 -277
  259. package/src/tools/grouped-file-output.d.ts +100 -19
  260. package/src/tools/grouped-file-output.ts +414 -103
  261. package/src/tools/hashline-format.d.ts +5 -0
  262. package/src/tools/hashline-format.ts +5 -0
  263. package/src/tools/irc.d.ts +6 -0
  264. package/src/tools/irc.ts +6 -0
  265. package/src/tools/job-widget.ts +13 -1
  266. package/src/tools/json-tree.d.ts +23 -4
  267. package/src/tools/json-tree.ts +132 -46
  268. package/src/tools/lsp.d.ts +2 -0
  269. package/src/tools/lsp.ts +246 -47
  270. package/src/tools/mcp.d.ts +6 -5
  271. package/src/tools/mcp.ts +20 -12
  272. package/src/tools/native-view.d.ts +3 -1
  273. package/src/tools/native-view.ts +12 -6
  274. package/src/tools/output-meta.d.ts +27 -0
  275. package/src/tools/output-meta.ts +68 -4
  276. package/src/tools/proc-render.ts +3 -3
  277. package/src/tools/read.d.ts +14 -4
  278. package/src/tools/read.ts +20 -5
  279. package/src/tools/renderer.d.ts +2 -0
  280. package/src/tools/renderer.ts +2 -0
  281. package/src/tools/streaming-output.d.ts +11 -0
  282. package/src/tools/streaming-output.ts +41 -0
  283. package/src/tools/task.d.ts +13 -4
  284. package/src/tools/task.ts +100 -97
  285. package/src/tools/url-scheme-host.d.ts +17 -0
  286. package/src/tools/url-scheme-host.ts +21 -0
  287. package/src/tools/vibe.ts +4 -4
  288. package/src/tools/wait.d.ts +2 -0
  289. package/src/tools/wait.ts +8 -5
  290. package/src/tools/write.ts +17 -27
  291. package/src/tools/yield.d.ts +1 -1
  292. package/src/tools/yield.ts +19 -10
  293. package/src/tui.d.ts +19 -2
  294. package/src/tui.ts +134 -24
  295. package/src/utils.d.ts +4 -0
  296. package/src/utils.ts +10 -0
  297. package/dist/types/theme/defaults/index.d.ts +0 -10289
  298. package/src/theme/defaults/alabaster.json +0 -103
  299. package/src/theme/defaults/amethyst.json +0 -106
  300. package/src/theme/defaults/anthracite.json +0 -103
  301. package/src/theme/defaults/basalt.json +0 -101
  302. package/src/theme/defaults/birch.json +0 -105
  303. package/src/theme/defaults/dark-abyss.json +0 -101
  304. package/src/theme/defaults/dark-arctic.json +0 -114
  305. package/src/theme/defaults/dark-aurora.json +0 -105
  306. package/src/theme/defaults/dark-catppuccin.json +0 -117
  307. package/src/theme/defaults/dark-cavern.json +0 -101
  308. package/src/theme/defaults/dark-celestial.json +0 -116
  309. package/src/theme/defaults/dark-copper.json +0 -105
  310. package/src/theme/defaults/dark-cosmos.json +0 -100
  311. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  312. package/src/theme/defaults/dark-dracula.json +0 -108
  313. package/src/theme/defaults/dark-eclipse.json +0 -101
  314. package/src/theme/defaults/dark-ember.json +0 -105
  315. package/src/theme/defaults/dark-equinox.json +0 -100
  316. package/src/theme/defaults/dark-forest.json +0 -106
  317. package/src/theme/defaults/dark-github.json +0 -115
  318. package/src/theme/defaults/dark-gruvbox.json +0 -122
  319. package/src/theme/defaults/dark-lavender.json +0 -105
  320. package/src/theme/defaults/dark-lunar.json +0 -99
  321. package/src/theme/defaults/dark-midnight.json +0 -105
  322. package/src/theme/defaults/dark-monochrome.json +0 -104
  323. package/src/theme/defaults/dark-monokai.json +0 -108
  324. package/src/theme/defaults/dark-nebula.json +0 -100
  325. package/src/theme/defaults/dark-neon-noir.json +0 -110
  326. package/src/theme/defaults/dark-nord.json +0 -108
  327. package/src/theme/defaults/dark-ocean.json +0 -111
  328. package/src/theme/defaults/dark-one.json +0 -110
  329. package/src/theme/defaults/dark-poimandres.json +0 -125
  330. package/src/theme/defaults/dark-rainforest.json +0 -101
  331. package/src/theme/defaults/dark-reef.json +0 -101
  332. package/src/theme/defaults/dark-retro.json +0 -102
  333. package/src/theme/defaults/dark-rose-pine.json +0 -106
  334. package/src/theme/defaults/dark-sakura.json +0 -105
  335. package/src/theme/defaults/dark-slate.json +0 -105
  336. package/src/theme/defaults/dark-solarized.json +0 -107
  337. package/src/theme/defaults/dark-solstice.json +0 -100
  338. package/src/theme/defaults/dark-starfall.json +0 -101
  339. package/src/theme/defaults/dark-sunset.json +0 -109
  340. package/src/theme/defaults/dark-swamp.json +0 -100
  341. package/src/theme/defaults/dark-synthwave.json +0 -113
  342. package/src/theme/defaults/dark-taiga.json +0 -101
  343. package/src/theme/defaults/dark-terminal.json +0 -105
  344. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  345. package/src/theme/defaults/dark-tundra.json +0 -101
  346. package/src/theme/defaults/dark-twilight.json +0 -101
  347. package/src/theme/defaults/dark-volcanic.json +0 -101
  348. package/src/theme/defaults/graphite.json +0 -102
  349. package/src/theme/defaults/index.d.ts +0 -10289
  350. package/src/theme/defaults/index.ts +0 -203
  351. package/src/theme/defaults/light-arctic.json +0 -117
  352. package/src/theme/defaults/light-aurora-day.json +0 -101
  353. package/src/theme/defaults/light-canyon.json +0 -101
  354. package/src/theme/defaults/light-catppuccin.json +0 -116
  355. package/src/theme/defaults/light-cirrus.json +0 -100
  356. package/src/theme/defaults/light-coral.json +0 -105
  357. package/src/theme/defaults/light-cyberpunk.json +0 -106
  358. package/src/theme/defaults/light-dawn.json +0 -100
  359. package/src/theme/defaults/light-dunes.json +0 -101
  360. package/src/theme/defaults/light-eucalyptus.json +0 -105
  361. package/src/theme/defaults/light-forest.json +0 -110
  362. package/src/theme/defaults/light-frost.json +0 -105
  363. package/src/theme/defaults/light-github.json +0 -125
  364. package/src/theme/defaults/light-glacier.json +0 -101
  365. package/src/theme/defaults/light-gruvbox.json +0 -118
  366. package/src/theme/defaults/light-haze.json +0 -100
  367. package/src/theme/defaults/light-honeycomb.json +0 -105
  368. package/src/theme/defaults/light-lagoon.json +0 -101
  369. package/src/theme/defaults/light-lavender.json +0 -105
  370. package/src/theme/defaults/light-meadow.json +0 -101
  371. package/src/theme/defaults/light-mint.json +0 -105
  372. package/src/theme/defaults/light-monochrome.json +0 -111
  373. package/src/theme/defaults/light-ocean.json +0 -109
  374. package/src/theme/defaults/light-one.json +0 -109
  375. package/src/theme/defaults/light-opal.json +0 -101
  376. package/src/theme/defaults/light-orchard.json +0 -101
  377. package/src/theme/defaults/light-paper.json +0 -105
  378. package/src/theme/defaults/light-poimandres.json +0 -125
  379. package/src/theme/defaults/light-prism.json +0 -100
  380. package/src/theme/defaults/light-retro.json +0 -108
  381. package/src/theme/defaults/light-sand.json +0 -105
  382. package/src/theme/defaults/light-savanna.json +0 -101
  383. package/src/theme/defaults/light-solarized.json +0 -112
  384. package/src/theme/defaults/light-soleil.json +0 -100
  385. package/src/theme/defaults/light-sunset.json +0 -109
  386. package/src/theme/defaults/light-synthwave.json +0 -108
  387. package/src/theme/defaults/light-tokyo-night.json +0 -121
  388. package/src/theme/defaults/light-wetland.json +0 -101
  389. package/src/theme/defaults/light-zenith.json +0 -99
  390. package/src/theme/defaults/limestone.json +0 -104
  391. package/src/theme/defaults/mahogany.json +0 -107
  392. package/src/theme/defaults/marble.json +0 -103
  393. package/src/theme/defaults/obsidian.json +0 -101
  394. package/src/theme/defaults/onyx.json +0 -101
  395. package/src/theme/defaults/pearl.json +0 -103
  396. package/src/theme/defaults/porcelain.json +0 -101
  397. package/src/theme/defaults/quartz.json +0 -106
  398. package/src/theme/defaults/sandstone.json +0 -105
  399. package/src/theme/defaults/titanium.json +0 -100
package/src/tools/ask.ts CHANGED
@@ -25,8 +25,13 @@ import { outputBlockContentWidth, renderStatusLine } from "../render";
25
25
  import { framedToolCard } from "../render/tool-card";
26
26
  import { wrapPrefixedLine } from "../render/hanging-wrap";
27
27
 
28
- import { formatErrorMessage, formatMeta, formatTitle, sanitizeCarriageReturns } from "../render/render-utils";
29
- import { tuiText, tuiTextFmt } from "../i18n";
28
+ import {
29
+ formatErrorMessage,
30
+ formatMeta,
31
+ formatStatusIcon,
32
+ formatTitle,
33
+ sanitizeCarriageReturns,
34
+ } from "../render/render-utils";
30
35
 
31
36
  /** Result for a single question */
32
37
  export interface QuestionResult {
@@ -177,10 +182,11 @@ function normalizeRenderQuestions(raw: unknown): NonNullable<AskRenderArgs["ques
177
182
  /** Render a custom free-text answer as a status line plus indented continuation rows. */
178
183
  function renderCustomInputLines(uiTheme: Theme, customInput: string): string[] {
179
184
  const lines = customInput.split("\n");
180
- const out: string[] = [
181
- ` ${uiTheme.styledSymbol("status.success", "success")} ${uiTheme.fg("toolOutput", lines[0] ?? "")}`,
182
- ];
183
- for (let i = 1; i < lines.length; i++) out.push(` ${uiTheme.fg("toolOutput", lines[i])}`);
185
+ const icon = formatStatusIcon("success", uiTheme);
186
+ // Continuation rows line up under the answer text, past the glyph's own width.
187
+ const indent = " ".repeat(visibleWidth(icon) + 2);
188
+ const out: string[] = [` ${icon} ${uiTheme.fg("toolOutput", lines[0] ?? "")}`];
189
+ for (let i = 1; i < lines.length; i++) out.push(`${indent}${uiTheme.fg("toolOutput", lines[i])}`);
184
190
  return out;
185
191
  }
186
192
 
@@ -283,9 +289,7 @@ function renderAnswerOptionLines(
283
289
 
284
290
  // Nothing was chosen (and no custom answer) → a lone cancelled marker.
285
291
  if (selected.size === 0 && customInput === undefined && note === undefined) {
286
- return [
287
- ` ${uiTheme.styledSymbol("status.warning", "warning")} ${uiTheme.fg("warning", tuiText("askCancelledLabel", "Cancelled"))}`,
288
- ];
292
+ return [` ${formatStatusIcon("warning", uiTheme)} ${uiTheme.fg("warning", "Cancelled")}`];
289
293
  }
290
294
 
291
295
  const out: string[] = [];
@@ -457,7 +461,7 @@ export const askToolRenderer = {
457
461
  },
458
462
  mergeCallAndResult: true,
459
463
  renderCall(args: AskRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component {
460
- const label = formatTitle(tuiText("askTitle", "Ask"), uiTheme);
464
+ const label = formatTitle("Ask", uiTheme);
461
465
  const mdTheme = getMarkdownTheme();
462
466
  const accentStyle = { color: (t: string) => uiTheme.fg("accent", t) };
463
467
  const md = (text: string, width: number) =>
@@ -468,16 +472,11 @@ export const askToolRenderer = {
468
472
  // throw here takes down the whole TUI render loop — normalize first.
469
473
  const questions = normalizeRenderQuestions(args.questions);
470
474
  if (questions && questions.length > 0) {
471
- const header = `${label} ${uiTheme.fg(
472
- "muted",
473
- questions.length === 1
474
- ? tuiText("askQuestionOne", "1 question")
475
- : tuiTextFmt("askQuestionManyFmt", "%d questions", questions.length),
476
- )}`;
475
+ const header = `${label} ${uiTheme.fg("muted", `${questions.length} questions`)}`;
477
476
  return framedToolCard(uiTheme, ({ width, contentWidth }) => {
478
477
  const sections = questions.map(q => {
479
478
  const meta: string[] = [];
480
- if (q.multi) meta.push(tuiText("askMultiMeta", "multi"));
479
+ if (q.multi) meta.push("multi");
481
480
  if (q.options?.length) meta.push(`options:${q.options.length}`);
482
481
  const metaStr = meta.length > 0 ? uiTheme.fg("dim", ` · ${meta.join(" · ")}`) : "";
483
482
  // md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
@@ -493,7 +492,7 @@ export const askToolRenderer = {
493
492
 
494
493
  // Single question
495
494
  if (typeof args.question !== "string" || !args.question) {
496
- const errorLine = formatErrorMessage(tuiText("askErrNoQuestion", "No question provided"), uiTheme);
495
+ const errorLine = formatErrorMessage("No question provided", uiTheme);
497
496
  return framedToolCard(uiTheme, () => ({
498
497
  header: errorLine,
499
498
  sections: [],
@@ -538,7 +537,7 @@ export const askToolRenderer = {
538
537
  if (!rawDetails) {
539
538
  const txt = result.content[0];
540
539
  const fallback = txt?.type === "text" && txt.text ? sanitizeCarriageReturns(txt.text) : "";
541
- const header = renderStatusLine({ icon: "warning", title: tuiText("askTitle", "Ask") }, uiTheme);
540
+ const header = renderStatusLine({ icon: "warning", title: "Ask" }, uiTheme);
542
541
  const body = fallback ? `\n${uiTheme.fg("dim", fallback)}` : "";
543
542
  return new Text(`${header}${body}`, 0, 0);
544
543
  }
@@ -546,14 +545,7 @@ export const askToolRenderer = {
546
545
 
547
546
  // Chat redirect: user chose "Chat about this" instead of answering.
548
547
  if (details.chatRedirect) {
549
- const header = renderStatusLine(
550
- {
551
- icon: "info",
552
- title: tuiText("askTitle", "Ask"),
553
- meta: [tuiText("askChatRedirectMeta", "chat redirect")],
554
- },
555
- uiTheme,
556
- );
548
+ const header = renderStatusLine({ icon: "info", title: "Ask", meta: ["chat redirect"] }, uiTheme);
557
549
  const questions = details.questions ?? [];
558
550
  return framedToolCard(uiTheme, ({ width }) => ({
559
551
  header,
@@ -575,11 +567,8 @@ export const askToolRenderer = {
575
567
  const header = renderStatusLine(
576
568
  {
577
569
  icon: hasAnySelection ? "success" : "warning",
578
- title: tuiText("askTitle", "Ask"),
579
- meta:
580
- results.length === 1
581
- ? [tuiText("askQuestionOne", "1 question")]
582
- : [tuiTextFmt("askQuestionManyFmt", "%d questions", results.length)],
570
+ title: "Ask",
571
+ meta: [`${results.length} questions`],
583
572
  },
584
573
  uiTheme,
585
574
  );
@@ -629,8 +618,8 @@ export const askToolRenderer = {
629
618
  (details.selectedOptions && details.selectedOptions.length > 0);
630
619
  const header = renderStatusLine(
631
620
  hasSelection
632
- ? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title: tuiText("askTitle", "Ask") }
633
- : { icon: "warning", title: tuiText("askTitle", "Ask") },
621
+ ? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title: "Ask" }
622
+ : { icon: "warning", title: "Ask" },
634
623
  uiTheme,
635
624
  );
636
625
  const dOptions = details.options;
@@ -658,9 +647,7 @@ export const askToolRenderer = {
658
647
  ];
659
648
  if (dTimedOut) {
660
649
  // Distinguish auto-selection from a real user choice in the transcript.
661
- bodyLines.push(
662
- uiTheme.fg("dim", tuiText("askAutoSelected", "auto-selected after timeout — not a user choice")),
663
- );
650
+ bodyLines.push(uiTheme.fg("dim", "auto-selected after timeout — not a user choice"));
664
651
  }
665
652
  return {
666
653
  header,
@@ -1,19 +1,24 @@
1
- import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
2
1
  import type { Component } from "../tui";
3
2
  import { Text } from "../components/text";
4
- import { replaceTabs } from "../utils";
5
3
  import type { Theme } from "../theme/theme";
6
- import { Ellipsis, fileHyperlink, renderStatusLine, truncateToWidth } from "../render";
4
+ import { Ellipsis, renderStatusLine, truncateToWidth } from "../render";
7
5
  import { framedToolCard } from "../render/tool-card";
8
6
  import {
9
7
  appendParseErrorsBulletList,
10
8
  formatCount,
11
9
  formatErrorDetail,
12
- formatMoreItems,
13
10
  formatParseErrorsCountLabel,
14
11
  PREVIEW_LIMITS,
15
12
  } from "../render/render-utils";
16
- import { classifyGroupedLines, groupLineIndicesByBlank } from "./grouped-file-output";
13
+ import {
14
+ classifyGroupedLines,
15
+ createGroupedRowStyler,
16
+ fitGroupsToBudget,
17
+ groupedLinkTargets,
18
+ groupLineIndicesByBlank,
19
+ groupsByFile,
20
+ walkGroupedOutput,
21
+ } from "./grouped-file-output";
17
22
  import type { OutputMeta } from "./output-meta";
18
23
  import type {
19
24
  NativeToolHead,
@@ -59,34 +64,24 @@ interface AstEditRenderArgs {
59
64
  const COLLAPSED_CHANGE_LIMIT = PREVIEW_LIMITS.COLLAPSED_LINES * 2;
60
65
 
61
66
  /**
62
- * Flatten change groups (line indices, styled on demand) into frame body
63
- * lines. Groups are separated by a blank line and carry no tree guides — the
64
- * frame border is the container, so nested `├─ │` gutters would just be
65
- * noise. Collapsed mode always shows at least the first group, then fills up
66
- * to `budget` lines before summarizing the rest as `… N more changes`.
67
+ * Frame body lines for per-file change groups, styled on demand: files apart by
68
+ * a blank line and without tree guides (the frame border is the container), fit
69
+ * to `budget` with the rest summarized as `… N more files`.
67
70
  */
68
71
  function buildChangeBody(
69
72
  groups: readonly (readonly number[])[],
70
73
  styleLine: (index: number) => string,
71
- expanded: boolean,
74
+ isFileRow: (index: number) => boolean,
72
75
  budget: number,
73
76
  theme: Theme,
74
77
  ): string[] {
78
+ const { shown, summary } = fitGroupsToBudget(groups, budget, { isUnit: isFileRow, unit: "file", gap: 1 });
75
79
  const lines: string[] = [];
76
- let shown = 0;
77
- for (let i = 0; i < groups.length; i++) {
78
- const group = groups[i]!;
79
- const separator = shown > 0 ? 1 : 0;
80
- const remainingAfter = groups.length - (i + 1);
81
- const reserved = !expanded && remainingAfter > 0 ? 1 : 0;
82
- // Always emit the first group; budget only gates subsequent ones.
83
- if (!expanded && shown > 0 && lines.length + separator + group.length + reserved > budget) break;
84
- if (separator) lines.push("");
80
+ for (const group of shown) {
81
+ if (lines.length > 0) lines.push("");
85
82
  for (const index of group) lines.push(styleLine(index));
86
- shown++;
87
83
  }
88
- const remaining = groups.length - shown;
89
- if (!expanded && remaining > 0) lines.push(theme.fg("muted", formatMoreItems(remaining, "change")));
84
+ if (summary) lines.push(theme.fg("muted", summary));
90
85
  return lines;
91
86
  }
92
87
 
@@ -98,9 +93,7 @@ function patternPreview(pat: string | undefined): string | undefined {
98
93
  return collapsed || undefined;
99
94
  }
100
95
 
101
- const AST_EDIT_HEADER_RE = /^(#+)\s+(.*)$/;
102
96
  const AST_EDIT_CHANGE_LINE_RE = /^([+\- ])\s*(\d+)(?:│|[:|])(.*)$/;
103
- const AST_EDIT_HEADER_SUFFIX_RE = /\s+\([^)]*\)\s*$/;
104
97
 
105
98
  /** One file's proposed rewrite: its unified diff text and change counts. */
106
99
  interface AstEditFileDiff {
@@ -117,29 +110,15 @@ interface AstEditFileDiff {
117
110
  */
118
111
  function parseAstEditChanges(lines: readonly string[]): AstEditFileDiff[] {
119
112
  const files: AstEditFileDiff[] = [];
120
- const dirs: string[] = [];
121
113
  let file: AstEditFileDiff | undefined;
122
- const flush = () => {
123
- if (file && file.lines.length > 0) files.push(file);
124
- file = undefined;
125
- };
126
- for (const line of lines) {
127
- const header = AST_EDIT_HEADER_RE.exec(line);
128
- if (header) {
129
- flush();
130
- const depth = header[1]!.length;
131
- const rest = header[2]!.trimEnd().replace(AST_EDIT_HEADER_SUFFIX_RE, "");
132
- dirs.length = depth - 1;
133
- if (rest.endsWith("/")) {
134
- dirs[depth - 1] = rest.slice(0, -1);
135
- continue;
136
- }
137
- const prefix = dirs.filter(Boolean).join("/");
138
- file = { path: prefix ? `${prefix}/${rest}` : rest, lines: [], added: 0, removed: 0 };
114
+ for (const event of walkGroupedOutput(lines)) {
115
+ if (event.kind !== "line") {
116
+ if (file && file.lines.length > 0) files.push(file);
117
+ file = event.kind === "file" ? { path: event.path, lines: [], added: 0, removed: 0 } : undefined;
139
118
  continue;
140
119
  }
141
- if (!file || line.trim().length === 0) continue;
142
- const change = AST_EDIT_CHANGE_LINE_RE.exec(line);
120
+ if (!file) continue;
121
+ const change = AST_EDIT_CHANGE_LINE_RE.exec(event.text);
143
122
  if (!change) continue;
144
123
  const lineNumber = Number.parseInt(change[2]!, 10);
145
124
  if (file.lastOld === undefined || lineNumber > file.lastOld + 1 || lineNumber < file.lastOld) {
@@ -150,7 +129,7 @@ function parseAstEditChanges(lines: readonly string[]): AstEditFileDiff[] {
150
129
  else if (change[1] === "-") file.removed++;
151
130
  file.lines.push(`${change[1]}${change[3]}`);
152
131
  }
153
- flush();
132
+ if (file && file.lines.length > 0) files.push(file);
154
133
  return files;
155
134
  }
156
135
 
@@ -248,53 +227,23 @@ export const astEditToolRenderer = {
248
227
 
249
228
  const textContent = result.details?.displayContent ?? result.content?.find(c => c.type === "text")?.text ?? "";
250
229
  const allLines = textContent.split("\n");
251
- // Resolve hyperlinks over the whole output so nested directory headers
252
- // reconstruct across the blank-line groups the tree list collapses by.
230
+ // Classify the whole output so nested directory headers resolve across blank-line groups.
253
231
  const contexts = classifyGroupedLines(allLines, details?.cwd ?? details?.searchPath, details?.searchPath);
254
- // The display lines are sanitized; reconstruct link targets from the original
255
- // grouped headers only when they still align with those display lines.
256
- const rawDetails = options.renderContext?.rawDetails;
257
- const rawContent =
258
- isRecord(rawDetails) && typeof rawDetails.displayContent === "string" ? rawDetails.displayContent : undefined;
259
- const rawLines = rawContent?.split("\n");
260
- const rawCwd = isRecord(rawDetails) && typeof rawDetails.cwd === "string" ? rawDetails.cwd : undefined;
261
- const rawSearchPath =
262
- isRecord(rawDetails) && typeof rawDetails.searchPath === "string" ? rawDetails.searchPath : undefined;
263
- const rawContexts =
264
- rawContent !== undefined && rawLines?.length === allLines.length && sanitizeText(rawContent) === textContent
265
- ? classifyGroupedLines(rawLines, rawCwd ?? rawSearchPath, rawSearchPath)
266
- : undefined;
267
- // Style lazily: collapsed bodies show only the first groups.
268
- const styledLines: (string | undefined)[] = Array.from({ length: allLines.length }, () => undefined);
269
- const styleLine = (index: number): string => {
270
- const cached = styledLines[index];
271
- if (cached !== undefined) return cached;
272
- const ctx = contexts[index]!;
273
- // Swap the inner code-frame gutter `│` for a space so it does not nest a
274
- // second vertical bar inside the frame border.
275
- const display = replaceTabs(allLines[index]!.replace("│", " "));
276
- let styled: string;
277
- const linkPath =
278
- ctx.headerPath && rawContexts?.[index]?.kind === ctx.kind && rawContexts[index]?.depth === ctx.depth
279
- ? (rawContexts[index]?.headerPath ?? ctx.headerPath)
280
- : ctx.headerPath;
281
- if (ctx.kind === "dir") {
282
- const accent = uiTheme.fg("accent", display);
283
- styled = linkPath ? fileHyperlink(linkPath, accent) : accent;
284
- } else if (ctx.kind === "file") {
285
- const tinted = uiTheme.fg(ctx.depth === 1 ? "accent" : "dim", display);
286
- styled = linkPath ? fileHyperlink(linkPath, tinted) : tinted;
287
- } else if (display.startsWith("+")) {
288
- styled = uiTheme.fg("toolDiffAdded", display);
289
- } else if (display.startsWith("-")) {
290
- styled = uiTheme.fg("toolDiffRemoved", display);
291
- } else {
292
- styled = uiTheme.fg("toolOutput", display);
293
- }
294
- styledLines[index] = styled;
295
- return styled;
296
- };
297
- const changeGroups = groupLineIndicesByBlank(allLines).filter(indices => {
232
+ const styleLine = createGroupedRowStyler(allLines, contexts, uiTheme, {
233
+ linkTarget: groupedLinkTargets(contexts, textContent, details, options.renderContext?.rawDetails),
234
+ styleBody: index => {
235
+ // Swap the code-frame gutter `│` for a space so it does not nest a
236
+ // second vertical bar inside the frame border.
237
+ const line = allLines[index]!.replace("│", " ");
238
+ const color = line.startsWith("+")
239
+ ? "toolDiffAdded"
240
+ : line.startsWith("-")
241
+ ? "toolDiffRemoved"
242
+ : "toolOutput";
243
+ return uiTheme.fg(color, line);
244
+ },
245
+ });
246
+ const changeGroups = groupsByFile(groupLineIndicesByBlank(allLines), contexts).filter(indices => {
298
247
  const first = allLines[indices[0]!]!;
299
248
  return !first.startsWith("Safety cap reached") && !first.startsWith("Parse issues:");
300
249
  });
@@ -321,7 +270,13 @@ export const astEditToolRenderer = {
321
270
  ({ contentWidth }) => {
322
271
  const expanded = Boolean(options.expanded);
323
272
  if (bodyMemo === undefined || bodyMemo.expanded !== expanded || bodyMemo.width !== contentWidth) {
324
- const changeLines = buildChangeBody(changeGroups, styleLine, expanded, COLLAPSED_CHANGE_LIMIT, uiTheme);
273
+ const changeLines = buildChangeBody(
274
+ changeGroups,
275
+ styleLine,
276
+ index => contexts[index]!.kind === "file",
277
+ expanded ? Number.POSITIVE_INFINITY : COLLAPSED_CHANGE_LIMIT,
278
+ uiTheme,
279
+ );
325
280
  const lines = [...changeLines, ...extraLines].map(l => truncateToWidth(l, contentWidth, Ellipsis.Omit));
326
281
  while (lines.length > 0 && lines[0].trim() === "") lines.shift();
327
282
  bodyMemo = { expanded, width: contentWidth, lines };
@@ -34,6 +34,8 @@ interface AstGrepRenderArgs {
34
34
  /** Legacy pre-`path` argument name; kept so historical transcripts still render a scope. */
35
35
  paths?: string[];
36
36
  skip?: number;
37
+ /** Language the search parsed the files as; highlighting follows it over the file extension. */
38
+ lang?: string;
37
39
  }
38
40
  /** Render AST grep calls and results. */
39
41
  export declare const astGrepToolRenderer: {
@@ -1,8 +1,7 @@
1
- import { isRecord, sanitizeText } from "@linxiraos/pi-utils";
2
1
  import type { Component } from "../tui";
3
2
  import { Text } from "../components/text";
4
3
  import type { Theme } from "../theme/theme";
5
- import { fileHyperlink, renderStatusLine, renderTreeList } from "../render";
4
+ import { renderStatusLine, renderTreeList } from "../render";
6
5
  import {
7
6
  appendParseErrorsBulletList,
8
7
  createCachedComponent,
@@ -14,7 +13,17 @@ import {
14
13
  PREVIEW_LIMITS,
15
14
  toPathList,
16
15
  } from "../render/render-utils";
17
- import { classifyGroupedLines, describeGroupedOutput, groupLineIndicesByBlank } from "./grouped-file-output";
16
+ import {
17
+ classifyGroupedLines,
18
+ createCodeFrameStyler,
19
+ createGroupedRowStyler,
20
+ describeGroupedOutput,
21
+ fitGroupsToBudget,
22
+ groupedLinkTargets,
23
+ groupLineIndicesByBlank,
24
+ groupsByFile,
25
+ isMatchRow,
26
+ } from "./grouped-file-output";
18
27
  import { code, compact, node, span } from "../native/describe";
19
28
  import type { NativeChild } from "../native/node";
20
29
  import { errorText, noteText, resultText, toolHead } from "./native-view";
@@ -51,6 +60,8 @@ interface AstGrepRenderArgs {
51
60
  /** Legacy pre-`path` argument name; kept so historical transcripts still render a scope. */
52
61
  paths?: string[];
53
62
  skip?: number;
63
+ /** Language the search parsed the files as; highlighting follows it over the file extension. */
64
+ lang?: string;
54
65
  }
55
66
 
56
67
  const COLLAPSED_MATCH_LIMIT = PREVIEW_LIMITS.COLLAPSED_LINES * 2;
@@ -121,63 +132,21 @@ export const astGrepToolRenderer = {
121
132
 
122
133
  const textContent = result.details?.displayContent ?? result.content?.find(c => c.type === "text")?.text ?? "";
123
134
  const allLines = textContent.split("\n");
124
- // Resolve hyperlinks over the whole output so nested directory headers
125
- // reconstruct across the blank-line groups the tree list collapses by.
135
+ // Classify the whole output so nested directory headers resolve across blank-line groups.
126
136
  const contexts = classifyGroupedLines(allLines, details?.cwd ?? details?.searchPath, details?.searchPath);
127
- // The displayed lines are sanitized, but OSC 8 destinations must retain the
128
- // original path bytes. Only substitute targets for headers already linked
129
- // by the sanitized output; never let raw text create additional links.
130
- const rawDetails = options.renderContext?.rawDetails;
131
- const rawContent =
132
- isRecord(rawDetails) && typeof rawDetails.displayContent === "string" ? rawDetails.displayContent : undefined;
133
- const rawLines = rawContent?.split("\n");
134
- const rawCwd = isRecord(rawDetails) && typeof rawDetails.cwd === "string" ? rawDetails.cwd : undefined;
135
- const rawSearchPath =
136
- isRecord(rawDetails) && typeof rawDetails.searchPath === "string" ? rawDetails.searchPath : undefined;
137
- const rawContexts =
138
- rawContent !== undefined && rawLines?.length === allLines.length && sanitizeText(rawContent) === textContent
139
- ? classifyGroupedLines(rawLines, rawCwd ?? rawSearchPath, rawSearchPath)
140
- : undefined;
141
- // Style lazily: the collapsed tree list only renders the first few groups,
142
- // so a large result never styles/hyperlinks rows nobody sees.
143
- const styledLines: (string | undefined)[] = Array.from({ length: allLines.length }, () => undefined);
144
- const styleLine = (index: number): string => {
145
- const cached = styledLines[index];
146
- if (cached !== undefined) return cached;
147
- const line = allLines[index]!;
148
- const ctx = contexts[index]!;
149
- const rawContext = rawContexts?.[index];
150
- const target =
151
- ctx.headerPath && rawContext?.kind === ctx.kind && rawContext.depth === ctx.depth
152
- ? (rawContext.headerPath ?? ctx.headerPath)
153
- : ctx.headerPath;
154
- let styled: string;
155
- if (ctx.kind === "dir") {
156
- const accent = uiTheme.fg("accent", line);
157
- styled = target ? fileHyperlink(target, accent) : accent;
158
- } else if (ctx.kind === "file") {
159
- const tinted = uiTheme.fg(ctx.depth === 1 ? "accent" : "dim", line);
160
- styled = target ? fileHyperlink(target, tinted) : tinted;
161
- } else {
162
- styled = uiTheme.fg(line.startsWith(" meta:") ? "dim" : "toolOutput", line);
163
- }
164
- styledLines[index] = styled;
165
- return styled;
166
- };
167
- const matchGroups = groupLineIndicesByBlank(allLines).filter(indices => {
137
+ const styleCodeFrame = createCodeFrameStyler(allLines, contexts, "toolOutput", uiTheme, args?.lang);
138
+ const styleLine = createGroupedRowStyler(allLines, contexts, uiTheme, {
139
+ linkTarget: groupedLinkTargets(contexts, textContent, details, options.renderContext?.rawDetails),
140
+ styleBody: index => {
141
+ const line = allLines[index]!;
142
+ return styleCodeFrame(index) ?? uiTheme.fg(line.startsWith(" meta:") ? "dim" : "toolOutput", line);
143
+ },
144
+ linkLines: true,
145
+ });
146
+ const matchGroups = groupsByFile(groupLineIndicesByBlank(allLines), contexts).filter(indices => {
168
147
  const first = allLines[indices[0]!]!;
169
148
  return !first.startsWith("Result limit reached") && !first.startsWith("Parse issues:");
170
149
  });
171
- // Line offset at which each group starts. A collapsed tree list stops at the
172
- // first group that overflows its line budget, so groups starting at or past
173
- // the budget are never shown — hand it same-length placeholders instead of
174
- // styling them (renderTreeList only needs their line counts).
175
- const groupStarts: number[] = [];
176
- let groupStart = 0;
177
- for (const group of matchGroups) {
178
- groupStarts.push(groupStart);
179
- groupStart += group.length;
180
- }
181
150
 
182
151
  const extraLines: string[] = [];
183
152
  if (limitReached) {
@@ -192,18 +161,13 @@ export const astGrepToolRenderer = {
192
161
  return createCachedComponent(
193
162
  () => options.expanded,
194
163
  width => {
164
+ const { shown, summary } = fitGroupsToBudget(
165
+ matchGroups,
166
+ options.expanded ? Number.POSITIVE_INFINITY : COLLAPSED_MATCH_LIMIT,
167
+ { isUnit: index => isMatchRow(allLines[index]!), unit: "match", total: matchCount },
168
+ );
195
169
  const matchLines = renderTreeList(
196
- {
197
- items: matchGroups,
198
- expanded: options.expanded,
199
- maxCollapsed: matchGroups.length,
200
- maxCollapsedLines: COLLAPSED_MATCH_LIMIT,
201
- itemType: "match",
202
- renderItem: (group, context) =>
203
- !options.expanded && groupStarts[context.index]! >= COLLAPSED_MATCH_LIMIT
204
- ? Array.from({ length: group.length }, () => "")
205
- : group.map(styleLine),
206
- },
170
+ { items: shown, trailingSummary: summary, renderItem: group => group.map(styleLine) },
207
171
  uiTheme,
208
172
  );
209
173
  return fitHeaderedRows(header, [...matchLines, ...extraLines], width);
@@ -0,0 +1,49 @@
1
+ import type * as XtermModule from "@linxiraos/pi-utils/vterm";
2
+ import type { Component } from "../tui";
3
+ import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
4
+ import type { Theme } from "../theme/theme";
5
+ /** Resize-only backend exposed by an interactive PTY controller. */
6
+ export interface BashInteractiveTerminalBackend {
7
+ resize(columns: number, rows: number): void;
8
+ }
9
+ /**
10
+ * Translates a TUI key event into the bytes a terminal would send to a PTY
11
+ * child; key releases encode to "". Shared by the agent `pty` console and
12
+ * `!` commands (`BashExecutionComponent.encodePtyInput`).
13
+ */
14
+ export declare function normalizeInputForPty(data: string, applicationCursorKeysMode: boolean): string;
15
+ /** Interactive terminal overlay driven by an external PTY controller. */
16
+ export declare class BashInteractiveOverlayComponent implements Component {
17
+ #private;
18
+ /** Native sheet: a full-pane glass overlay titled Console. */
19
+ readonly nativeOverlay: {
20
+ readonly role: "zeta.overlay.console";
21
+ readonly size: "full";
22
+ readonly head: "Console";
23
+ };
24
+ constructor(command: string, uiTheme: Theme, getTerminalRows: () => number, terminalCtor: typeof XtermModule.Terminal, backend: BashInteractiveTerminalBackend);
25
+ /** Connects normalized keyboard input and overlay lifecycle events to the controller. */
26
+ setHandlers(onInput: (data: string) => void, onDismiss: () => void, onDispose: () => void): void;
27
+ /** Queues a raw terminal output chunk for virtual-terminal rendering. */
28
+ appendOutput(chunk: string): void;
29
+ /** Resolves when the virtual terminal has processed all queued output. */
30
+ flushOutput(): Promise<void>;
31
+ /** Records process completion and stops forwarding keyboard input. */
32
+ setComplete(result: {
33
+ exitCode: number | undefined;
34
+ cancelled: boolean;
35
+ timedOut: boolean;
36
+ }): void;
37
+ handleInput(data: string): void;
38
+ /** The Force kill button runs the Esc path. */
39
+ handleNativeEvent(event: NativeUiEvent): void;
40
+ /**
41
+ * Native view: the command with its state badge, the PTY screen as an
42
+ * `ansi` node (SGR kept, fixed to the PTY grid), and a footer with the
43
+ * Force kill action while running.
44
+ */
45
+ describe(cx: DescribeContext): NativeNode;
46
+ render(width: number): readonly string[];
47
+ invalidate(): void;
48
+ dispose(): void;
49
+ }
@@ -25,7 +25,12 @@ const NATIVE_SHEET_INSET_COLS = 8;
25
25
  // Action id of the native Force kill button (mirrors Esc).
26
26
  const KILL_ACTION = "kill";
27
27
 
28
- function normalizeInputForPty(data: string, applicationCursorKeysMode: boolean): string {
28
+ /**
29
+ * Translates a TUI key event into the bytes a terminal would send to a PTY
30
+ * child; key releases encode to "". Shared by the agent `pty` console and
31
+ * `!` commands (`BashExecutionComponent.encodePtyInput`).
32
+ */
33
+ export function normalizeInputForPty(data: string, applicationCursorKeysMode: boolean): string {
29
34
  const kitty = parseKittySequence(data);
30
35
  if (kitty?.eventType === 3) {
31
36
  return "";
@@ -24,6 +24,8 @@ export interface BashToolDetails {
24
24
  exitCode?: number;
25
25
  /** True when the command was killed by its timeout deadline (not a failure). */
26
26
  timedOut?: boolean;
27
+ /** Text the command wrote to `out://`, oldest first; transcripts draw each as a reply after the call. */
28
+ replies?: string[];
27
29
  /** Live ACP update only; completed results refer to released terminals. */
28
30
  terminalId?: string;
29
31
  service?: {
package/src/tools/bash.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  replaceTabs,
14
14
  } from "../render/render-utils";
15
15
  import {
16
+ formatMinimizedMeta,
16
17
  formatStyledTruncationWarning,
17
18
  type OutputMeta,
18
19
  stripOutputNotice,
@@ -69,6 +70,8 @@ export interface BashToolDetails {
69
70
  exitCode?: number;
70
71
  /** True when the command was killed by its timeout deadline (not a failure). */
71
72
  timedOut?: boolean;
73
+ /** Text the command wrote to `out://`, oldest first; transcripts draw each as a reply after the call. */
74
+ replies?: string[];
72
75
  /** Live ACP update only; completed results refer to released terminals. */
73
76
  terminalId?: string;
74
77
  service?: {
@@ -349,6 +352,10 @@ function bashStatsParts(
349
352
  if (artifactId) {
350
353
  statsParts.push(`Artifact: ${artifactId}`);
351
354
  }
355
+ const minimized = details?.meta?.minimized;
356
+ if (minimized) {
357
+ statsParts.push(`Minimized: ${formatMinimizedMeta(minimized)}`);
358
+ }
352
359
  if (isError && typeof details?.exitCode === "number") {
353
360
  statsParts.push(`Exit: ${details.exitCode}`);
354
361
  }
@@ -398,6 +405,8 @@ function shellFootParts(details: BashToolDetails | undefined, artifactId: string
398
405
  if (service.pid !== undefined) parts.push(`PID ${service.pid}`);
399
406
  }
400
407
  if (artifactId) parts.push(`Artifact ${artifactId}`);
408
+ const minimized = details?.meta?.minimized;
409
+ if (minimized) parts.push(`Minimized ${formatMinimizedMeta(minimized)}`);
401
410
  return parts;
402
411
  }
403
412
 
@@ -22,10 +22,12 @@ export interface DefaultToolRenderInput {
22
22
  export declare function formatDefaultToolExecution(input: DefaultToolRenderInput, contentWidth: number, uiTheme: Theme): string;
23
23
  /**
24
24
  * TSP view of the generic fallback card: the tool label with a one-line args
25
- * summary as the head target; the result as a JSON tree or raw `ansi` output.
26
- * The complete output goes over the wire — the card-level disclosure clamp the
27
- * terminal applies is the only bound, so an expanded card keeps every row. JSON
28
- * the tree's depth, node or scalar caps would cut keeps the raw path instead.
25
+ * summary as the head target; the result as JSON (the host's `json` viewer,
26
+ * else a JSON tree) or raw `ansi` output. The complete output goes over the
27
+ * wire — the card-level disclosure clamp the terminal applies is the only
28
+ * bound, so an expanded card keeps every row. The `json` viewer never cuts;
29
+ * JSON the fallback tree's depth, node or scalar caps would cut keeps the raw
30
+ * path instead.
29
31
  */
30
32
  export declare function describeDefaultToolExecution(input: DefaultToolRenderInput): NativeToolView;
31
33
  /** Render the generic fallback as the state-tinted card used by direct custom tools. */