@linxiraos/pi-tui 1.4.11 → 1.4.13

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 (265) hide show
  1. package/CHANGELOG.md +30 -233
  2. package/README.md +4 -1
  3. package/THIRD-PARTY-NOTICES.txt +4 -5
  4. package/dist/types/apps/shell-visualizer.d.ts +24 -0
  5. package/dist/types/autocomplete.d.ts +20 -0
  6. package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
  7. package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +72 -1
  10. package/dist/types/chat/image-loading.d.ts +2 -2
  11. package/dist/types/chat/messages.d.ts +2 -3
  12. package/dist/types/chat/read-tool-group.d.ts +15 -2
  13. package/dist/types/chat/skill-message.d.ts +1 -0
  14. package/dist/types/chat/spotlight.d.ts +203 -0
  15. package/dist/types/chat/tool-execution.d.ts +26 -5
  16. package/dist/types/chat/transcript-actions.d.ts +11 -0
  17. package/dist/types/chat/transcript-browser.d.ts +9 -0
  18. package/dist/types/chat/transcript-presentation.d.ts +164 -0
  19. package/dist/types/chat/ttsr-notification.d.ts +2 -0
  20. package/dist/types/chrome/message-frame.d.ts +2 -0
  21. package/dist/types/chrome/transcript-container.d.ts +27 -6
  22. package/dist/types/components/loader.d.ts +0 -2
  23. package/dist/types/components/markdown.d.ts +11 -1
  24. package/dist/types/components/settings-list.d.ts +12 -2
  25. package/dist/types/frame-rate.d.ts +18 -0
  26. package/dist/types/hotkeys-markdown.d.ts +2 -0
  27. package/dist/types/index.d.ts +3 -0
  28. package/dist/types/keybinding-matchers.d.ts +4 -1
  29. package/dist/types/kitty-graphics.d.ts +1 -1
  30. package/dist/types/motion-effects.d.ts +10 -0
  31. package/dist/types/native/encode.d.ts +2 -0
  32. package/dist/types/native/measure.d.ts +10 -0
  33. package/dist/types/native/overlay.d.ts +1 -1
  34. package/dist/types/native/quiet.d.ts +5 -0
  35. package/dist/types/native/reconcile.d.ts +6 -1
  36. package/dist/types/native/spans.d.ts +6 -0
  37. package/dist/types/native/state.d.ts +4 -0
  38. package/dist/types/overlays/agent-hub.d.ts +6 -0
  39. package/dist/types/overlays/link-browser.d.ts +55 -0
  40. package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
  41. package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
  42. package/dist/types/prompt/composer-attachments.d.ts +5 -2
  43. package/dist/types/prompt/composer-cache.d.ts +7 -2
  44. package/dist/types/prompt/composer.d.ts +6 -11
  45. package/dist/types/prompt/custom-editor.d.ts +8 -2
  46. package/dist/types/prompt/gradient-highlight.d.ts +2 -2
  47. package/dist/types/prompt/magic-keywords.d.ts +2 -0
  48. package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
  49. package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
  50. package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
  51. package/dist/types/prompt/welcome.d.ts +19 -0
  52. package/dist/types/render/extension-links.d.ts +0 -6
  53. package/dist/types/render/index.d.ts +1 -0
  54. package/dist/types/render/link-hints.d.ts +78 -0
  55. package/dist/types/render/render-utils.d.ts +0 -2
  56. package/dist/types/setup/scenes/types.d.ts +8 -0
  57. package/dist/types/setup/scenes/updates.d.ts +6 -0
  58. package/dist/types/setup/wizard.d.ts +7 -2
  59. package/dist/types/spinner-clock.d.ts +34 -0
  60. package/dist/types/status-line/component.d.ts +8 -4
  61. package/dist/types/status-line/host.d.ts +62 -0
  62. package/dist/types/status-line/index.d.ts +1 -0
  63. package/dist/types/status-line/prompt-cache.d.ts +14 -0
  64. package/dist/types/status-line/schema.d.ts +1 -1
  65. package/dist/types/status-line/startup.d.ts +6 -0
  66. package/dist/types/status-line/types.d.ts +8 -21
  67. package/dist/types/theme/schema.d.ts +28 -1
  68. package/dist/types/theme/symbols.d.ts +1 -1
  69. package/dist/types/theme/theme-class.d.ts +12 -2
  70. package/dist/types/theme/theme.d.ts +1 -1
  71. package/dist/types/theme/tui-adapters.d.ts +7 -0
  72. package/dist/types/thinking.d.ts +12 -0
  73. package/dist/types/tools/ask.d.ts +1 -1
  74. package/dist/types/tools/bash.d.ts +21 -0
  75. package/dist/types/tools/find.d.ts +9 -1
  76. package/dist/types/tools/grep.d.ts +2 -1
  77. package/dist/types/tools/grouped-file-output.d.ts +17 -0
  78. package/dist/types/tools/job-widget.d.ts +2 -2
  79. package/dist/types/tools/lsp.d.ts +4 -2
  80. package/dist/types/tools/native-view.d.ts +4 -0
  81. package/dist/types/tools/renderer.d.ts +9 -1
  82. package/dist/types/tools/shell-trace.d.ts +10 -0
  83. package/dist/types/tools/shell-viz-render.d.ts +6 -0
  84. package/dist/types/tools/shell-viz.d.ts +16 -0
  85. package/dist/types/tools/wait.d.ts +2 -2
  86. package/dist/types/tools/web-search-types.d.ts +1 -0
  87. package/dist/types/tools/write.d.ts +2 -0
  88. package/dist/types/tui.d.ts +15 -1
  89. package/package.json +15 -11
  90. package/src/apps/shell-visualizer.d.ts +24 -0
  91. package/src/apps/shell-visualizer.ts +167 -0
  92. package/src/autocomplete.d.ts +20 -0
  93. package/src/autocomplete.ts +14 -0
  94. package/src/chat/assistant-message.ts +11 -6
  95. package/src/chat/cache-invalidation-marker.d.ts +15 -7
  96. package/src/chat/cache-invalidation-marker.ts +18 -9
  97. package/src/chat/chat-transcript-builder.d.ts +5 -3
  98. package/src/chat/chat-transcript-builder.ts +16 -12
  99. package/src/chat/display-preferences.d.ts +2 -0
  100. package/src/chat/display-preferences.ts +3 -0
  101. package/src/chat/extension-types.d.ts +72 -1
  102. package/src/chat/extension-types.ts +74 -1
  103. package/src/chat/image-loading.d.ts +2 -2
  104. package/src/chat/image-loading.ts +2 -2
  105. package/src/chat/messages.d.ts +2 -3
  106. package/src/chat/messages.ts +3 -8
  107. package/src/chat/read-tool-group.d.ts +15 -2
  108. package/src/chat/read-tool-group.ts +201 -41
  109. package/src/chat/skill-message.d.ts +1 -0
  110. package/src/chat/skill-message.ts +4 -0
  111. package/src/chat/spotlight.d.ts +203 -0
  112. package/src/chat/spotlight.ts +460 -0
  113. package/src/chat/tool-execution.d.ts +26 -5
  114. package/src/chat/tool-execution.ts +360 -38
  115. package/src/chat/transcript-actions.d.ts +11 -0
  116. package/src/chat/transcript-actions.ts +13 -1
  117. package/src/chat/transcript-browser.d.ts +9 -0
  118. package/src/chat/transcript-browser.ts +18 -0
  119. package/src/chat/transcript-presentation.d.ts +164 -0
  120. package/src/chat/transcript-presentation.ts +642 -0
  121. package/src/chat/ttsr-notification.d.ts +25 -0
  122. package/src/chat/ttsr-notification.ts +5 -0
  123. package/src/chrome/message-frame.d.ts +2 -0
  124. package/src/chrome/message-frame.ts +7 -0
  125. package/src/chrome/message-notice.d.ts +58 -0
  126. package/src/chrome/transcript-container.d.ts +27 -6
  127. package/src/chrome/transcript-container.ts +317 -66
  128. package/src/components/editor.ts +25 -1
  129. package/src/components/loader.d.ts +0 -2
  130. package/src/components/loader.ts +30 -18
  131. package/src/components/markdown.d.ts +11 -1
  132. package/src/components/markdown.ts +41 -16
  133. package/src/components/settings-list.d.ts +12 -2
  134. package/src/components/settings-list.ts +29 -13
  135. package/src/frame-rate.d.ts +18 -0
  136. package/src/frame-rate.ts +36 -0
  137. package/src/hotkeys-markdown.ts +9 -2
  138. package/src/index.d.ts +3 -0
  139. package/src/index.ts +3 -0
  140. package/src/keybinding-matchers.d.ts +4 -1
  141. package/src/keybinding-matchers.ts +13 -12
  142. package/src/kitty-graphics.d.ts +1 -1
  143. package/src/kitty-graphics.ts +3 -2
  144. package/src/motion-effects.d.ts +10 -0
  145. package/src/motion-effects.ts +27 -0
  146. package/src/native/backend.ts +66 -7
  147. package/src/native/encode.d.ts +2 -0
  148. package/src/native/encode.ts +2 -0
  149. package/src/native/measure.d.ts +10 -0
  150. package/src/native/measure.ts +185 -0
  151. package/src/native/overlay.d.ts +1 -1
  152. package/src/native/overlay.ts +1 -1
  153. package/src/native/quiet.d.ts +5 -0
  154. package/src/native/quiet.ts +105 -0
  155. package/src/native/reconcile.d.ts +6 -1
  156. package/src/native/reconcile.ts +16 -10
  157. package/src/native/spans.d.ts +6 -0
  158. package/src/native/spans.ts +40 -0
  159. package/src/native/state.d.ts +4 -0
  160. package/src/native/state.ts +18 -0
  161. package/src/overlays/agent-hub.ts +15 -2
  162. package/src/overlays/ask-dialog.ts +1 -0
  163. package/src/overlays/btw-history-panel.ts +73 -6
  164. package/src/overlays/link-browser.ts +295 -0
  165. package/src/overlays/running-subagent-badge.ts +2 -9
  166. package/src/overlays/settings-defs.ts +1 -1
  167. package/src/overlays/settings-selector.ts +17 -3
  168. package/src/overlays/spotlight-sheet.ts +478 -0
  169. package/src/overlays/usage-dashboard.ts +6 -5
  170. package/src/prompt/composer-attachments.d.ts +5 -2
  171. package/src/prompt/composer-attachments.ts +6 -6
  172. package/src/prompt/composer-cache.ts +17 -16
  173. package/src/prompt/composer.ts +30 -123
  174. package/src/prompt/custom-editor.ts +17 -13
  175. package/src/prompt/gradient-highlight.d.ts +2 -2
  176. package/src/prompt/gradient-highlight.ts +5 -4
  177. package/src/prompt/magic-keywords.d.ts +2 -0
  178. package/src/prompt/magic-keywords.ts +4 -1
  179. package/src/prompt/model-mention-autocomplete.ts +73 -20
  180. package/src/prompt/model-mention-syntax.d.ts +6 -0
  181. package/src/prompt/model-mention-syntax.ts +9 -0
  182. package/src/prompt/prompt-action-autocomplete.ts +49 -33
  183. package/src/prompt/tips.txt +1 -0
  184. package/src/prompt/welcome.ts +104 -2
  185. package/src/render/extension-links.d.ts +0 -6
  186. package/src/render/extension-links.ts +0 -20
  187. package/src/render/index.d.ts +1 -0
  188. package/src/render/index.ts +1 -0
  189. package/src/render/link-hints.d.ts +78 -0
  190. package/src/render/link-hints.ts +299 -0
  191. package/src/render/render-utils.d.ts +0 -2
  192. package/src/render/render-utils.ts +0 -5
  193. package/src/setup/scenes/glyph.ts +1 -1
  194. package/src/setup/scenes/types.ts +8 -0
  195. package/src/setup/scenes/updates.ts +116 -0
  196. package/src/setup/wizard.ts +19 -8
  197. package/src/spinner-clock.d.ts +34 -0
  198. package/src/spinner-clock.ts +79 -0
  199. package/src/status-line/component.ts +145 -53
  200. package/src/status-line/host.ts +51 -0
  201. package/src/status-line/index.ts +1 -0
  202. package/src/status-line/presets.ts +3 -1
  203. package/src/status-line/prompt-cache.ts +154 -0
  204. package/src/status-line/schema.ts +1 -1
  205. package/src/status-line/segments.ts +33 -22
  206. package/src/status-line/startup.ts +22 -4
  207. package/src/status-line/types.ts +8 -22
  208. package/src/stdin-buffer.ts +89 -46
  209. package/src/terminal-capabilities.ts +3 -3
  210. package/src/terminal.ts +1 -8
  211. package/src/theme/loader.ts +3 -2
  212. package/src/theme/schema.d.ts +28 -1
  213. package/src/theme/schema.ts +30 -1
  214. package/src/theme/symbols.d.ts +1 -1
  215. package/src/theme/symbols.ts +15 -3
  216. package/src/theme/theme-class.d.ts +12 -2
  217. package/src/theme/theme-class.ts +23 -0
  218. package/src/theme/theme-schema.json +1 -1
  219. package/src/theme/theme.d.ts +1 -1
  220. package/src/theme/theme.ts +3 -7
  221. package/src/theme/tui-adapters.d.ts +7 -0
  222. package/src/theme/tui-adapters.ts +33 -1
  223. package/src/thinking.d.ts +12 -0
  224. package/src/thinking.ts +31 -0
  225. package/src/tools/ask.d.ts +1 -1
  226. package/src/tools/ask.ts +99 -38
  227. package/src/tools/ast-edit.ts +51 -32
  228. package/src/tools/ast-grep.ts +31 -19
  229. package/src/tools/bash.d.ts +21 -0
  230. package/src/tools/bash.ts +166 -24
  231. package/src/tools/find.d.ts +9 -1
  232. package/src/tools/find.ts +23 -2
  233. package/src/tools/grep.d.ts +2 -1
  234. package/src/tools/grep.ts +52 -36
  235. package/src/tools/grouped-file-output.d.ts +17 -0
  236. package/src/tools/grouped-file-output.ts +20 -2
  237. package/src/tools/job-widget.d.ts +2 -2
  238. package/src/tools/job-widget.ts +2 -2
  239. package/src/tools/lsp.d.ts +4 -2
  240. package/src/tools/lsp.ts +537 -642
  241. package/src/tools/native-view.d.ts +4 -0
  242. package/src/tools/native-view.ts +8 -2
  243. package/src/tools/renderer.d.ts +9 -1
  244. package/src/tools/renderer.ts +9 -1
  245. package/src/tools/shell-trace.d.ts +10 -0
  246. package/src/tools/shell-trace.ts +80 -0
  247. package/src/tools/shell-viz-render.d.ts +6 -0
  248. package/src/tools/shell-viz-render.ts +156 -0
  249. package/src/tools/shell-viz.d.ts +16 -0
  250. package/src/tools/shell-viz.ts +181 -0
  251. package/src/tools/streaming-output.ts +18 -8
  252. package/src/tools/wait.d.ts +2 -2
  253. package/src/tools/wait.ts +39 -34
  254. package/src/tools/web-search-types.d.ts +1 -0
  255. package/src/tools/web-search-types.ts +1 -0
  256. package/src/tools/write.d.ts +2 -0
  257. package/src/tools/write.ts +2 -0
  258. package/src/tui.d.ts +15 -1
  259. package/src/tui.ts +63 -6
  260. package/src/windows-input-mode.ts +7 -1
  261. package/dist/types/chat/collab-prompt-message.d.ts +0 -14
  262. package/dist/types/chrome/collab-qrcode.d.ts +0 -35
  263. package/src/chat/collab-prompt-message.d.ts +0 -14
  264. package/src/chat/collab-prompt-message.ts +0 -46
  265. package/src/chrome/collab-qrcode.ts +0 -99
@@ -109,6 +109,8 @@ export type SymbolKey =
109
109
  | "icon.job"
110
110
  | "icon.cache"
111
111
  | "icon.cacheMiss"
112
+ | "icon.cacheWarm"
113
+ | "icon.cacheCold"
112
114
  | "icon.input"
113
115
  | "icon.output"
114
116
  | "icon.throughput"
@@ -497,6 +499,8 @@ const UNICODE_SYMBOLS: SymbolMap = {
497
499
  "icon.job": "⚙",
498
500
  "icon.cache": "💾",
499
501
  "icon.cacheMiss": "⊘",
502
+ "icon.cacheWarm": "●",
503
+ "icon.cacheCold": "⊘",
500
504
  "icon.input": "⤵",
501
505
  "icon.output": "⤴",
502
506
  "icon.throughput": "⚡",
@@ -891,6 +895,10 @@ const NERD_SYMBOLS: SymbolMap = {
891
895
  "icon.cache": "\uf1c0",
892
896
  // pick: (fa-ban) | alt: ⊘
893
897
  "icon.cacheMiss": "\uf05e",
898
+ // pick: 󱘲 (nf-md-database_outline) | alt: 
899
+ "icon.cacheWarm": "\u{f1632}",
900
+ // pick: 󱘱 (nf-md-database_off_outline): the warm glyph struck through | alt: 
901
+ "icon.cacheCold": "\u{f1631}",
894
902
  // pick:  | alt:  →
895
903
  "icon.input": "\uf090",
896
904
  // pick:  | alt:  →
@@ -1208,9 +1216,11 @@ const ASCII_SYMBOLS: SymbolMap = {
1208
1216
  "nav.expand": "+",
1209
1217
  "nav.collapse": "-",
1210
1218
  "nav.back": "<-",
1211
- // Tree Connectors
1212
- "tree.branch": "|--",
1213
- "tree.last": "'--",
1219
+ // Tree Connectors: branches are two columns, like the Unicode `├─`, so a
1220
+ // branch and its space match the three-column continuation (`| `) that
1221
+ // child rows hang under.
1222
+ "tree.branch": "|-",
1223
+ "tree.last": "'-",
1214
1224
  "tree.vertical": "|",
1215
1225
  "tree.horizontal": "-",
1216
1226
  "tree.hook": "`-",
@@ -1295,6 +1305,8 @@ const ASCII_SYMBOLS: SymbolMap = {
1295
1305
  "icon.intelligence": "IQ",
1296
1306
  "icon.cache": "cache",
1297
1307
  "icon.cacheMiss": "!",
1308
+ "icon.cacheWarm": "cache",
1309
+ "icon.cacheCold": "!cache",
1298
1310
  "icon.input": "in:",
1299
1311
  "icon.host": "host",
1300
1312
  "icon.session": "id",
@@ -1,4 +1,4 @@
1
- import { type ColorMode, type ThemeBg, type ThemeColor } from "./schema";
1
+ import { type AnsiColor, type ColorMode, type ThemeBg, type ThemeColor } from "./schema";
2
2
  import type { SessionAccentTheme } from "./session-color";
3
3
  import { type SlashCommandIconName, type SpinnerType, type SymbolKey, type SymbolPreset } from "./symbols";
4
4
  /** Theme token of a thinking/effort level name (`off`…`max`); unknown levels (`auto`) map to `thinkingOff`. */
@@ -15,7 +15,7 @@ export declare class Theme {
15
15
  * otherwise-light theme.
16
16
  */
17
17
  readonly statusLineLuminance: number | undefined;
18
- constructor(fgColors: Record<ThemeColor, string | number>, bgColors: Record<ThemeBg, string | number>, mode: ColorMode, symbolPreset: SymbolPreset, symbolOverrides: Partial<Record<SymbolKey, string>>, spinnerFramesOverrides?: Partial<Record<SpinnerType, string[]>>);
18
+ constructor(fgColors: Record<ThemeColor, string | number>, bgColors: Record<ThemeBg, string | number>, mode: ColorMode, symbolPreset: SymbolPreset, symbolOverrides: Partial<Record<SymbolKey, string>>, spinnerFramesOverrides?: Partial<Record<SpinnerType, string[]>>, ansiPalette?: ReadonlyArray<string | number>);
19
19
  /** True when the active theme has a light status-line background. */
20
20
  get isLight(): boolean;
21
21
  /**
@@ -62,6 +62,12 @@ export declare class Theme {
62
62
  */
63
63
  hasColor(color: ThemeColor): boolean;
64
64
  fg(color: ThemeColor, text: string): string;
65
+ /**
66
+ * Color `text` with slot `color` of the theme's `terminal.ansi` palette, or
67
+ * the terminal's own palette when the theme ships none. Like {@link fg}, the
68
+ * color resumes after nested foreground resets.
69
+ */
70
+ ansiFg(color: AnsiColor, text: string): string;
65
71
  /** Apply a foreground, replacing terminal-default tokens with the theme's contrast-safe fallback. */
66
72
  fgResolved(color: ThemeColor, text: string): string;
67
73
  bg(color: ThemeBg, text: string): string;
@@ -79,6 +85,8 @@ export declare class Theme {
79
85
  */
80
86
  fgOnBg(color: ThemeColor, background: ThemeBg, text: string): string;
81
87
  bold(text: string): string;
88
+ /** Reduce terminal intensity without replacing the text's foreground colors. */
89
+ faint(text: string): string;
82
90
  italic(text: string): string;
83
91
  underline(text: string): string;
84
92
  strikethrough(text: string): string;
@@ -228,6 +236,8 @@ export declare class Theme {
228
236
  job: string;
229
237
  cache: string;
230
238
  cacheMiss: string;
239
+ cacheWarm: string;
240
+ cacheCold: string;
231
241
  input: string;
232
242
  output: string;
233
243
  throughput: string;
@@ -3,6 +3,8 @@ import * as logger from "@linxiraos/pi-utils/logger";
3
3
  import chalk from "@linxiraos/pi-utils/chalk";
4
4
  import { bgAnsi, colorToAnsi, fgAnsi, resolveToHex } from "./color";
5
5
  import {
6
+ ANSI_COLOR_INDEX,
7
+ type AnsiColor,
6
8
  type ColorMode,
7
9
  isValidThemeColor,
8
10
  OPTIONAL_THEME_COLOR_RECORD,
@@ -150,6 +152,7 @@ function wrapForeground(ansi: string, text: string): string {
150
152
  // Prebuilt stylers: each `chalk.<style>` access builds a fresh builder. Builders share the
151
153
  // root chalk context, so later `chalk.level` changes still apply.
152
154
  const boldStyler = chalk.bold;
155
+ const faintStyler = chalk.dim;
153
156
  const italicStyler = chalk.italic;
154
157
  const underlineStyler = chalk.underline;
155
158
  const strikethroughStyler = chalk.strikethrough;
@@ -182,6 +185,8 @@ export class Theme {
182
185
  readonly #hexFgColors: Record<ThemeColor, string>;
183
186
  /** Resolved hex strings for background colors — populated at construction. */
184
187
  readonly #hexBgColors: Record<ThemeBg, string>;
188
+ /** Foreground SGR per `terminal.ansi` index; slots the theme omits use the terminal's palette. */
189
+ readonly #ansiFgColors: readonly string[];
185
190
  /** Lazily resolved `fgResolved` ANSI per color; colors and mode are fixed per instance. */
186
191
  readonly #resolvedFgColors = new Map<ThemeColor, string>();
187
192
  /** Lazily built, frozen `sessionAccentInputs`; every input it reads is fixed per instance. */
@@ -205,6 +210,7 @@ export class Theme {
205
210
  private readonly symbolPreset: SymbolPreset,
206
211
  symbolOverrides: Partial<Record<SymbolKey, string>>,
207
212
  spinnerFramesOverrides: Partial<Record<SpinnerType, string[]>> = {},
213
+ ansiPalette: ReadonlyArray<string | number> = [],
208
214
  ) {
209
215
  this.statusLineLuminance = colorLuma(bgColors.statusLineBg);
210
216
  this.#statusLineContrastLuminance = relativeLuminance(bgColors.statusLineBg);
@@ -227,6 +233,7 @@ export class Theme {
227
233
  this.#fgColors[key] ??= "\x1b[39m";
228
234
  this.#hexFgColors[key] ??= "";
229
235
  }
236
+ this.#ansiFgColors = Array.from({ length: 16 }, (_, index) => fgAnsi(ansiPalette[index] ?? index, mode));
230
237
  this.#bgColors = {} as Record<ThemeBg, string>;
231
238
  this.#hexBgColors = {} as Record<ThemeBg, string>;
232
239
  for (const [key, value] of Object.entries(bgColors) as [ThemeBg, string | number][]) {
@@ -364,6 +371,15 @@ export class Theme {
364
371
  return wrapForeground(ansi, text);
365
372
  }
366
373
 
374
+ /**
375
+ * Color `text` with slot `color` of the theme's `terminal.ansi` palette, or
376
+ * the terminal's own palette when the theme ships none. Like {@link fg}, the
377
+ * color resumes after nested foreground resets.
378
+ */
379
+ ansiFg(color: AnsiColor, text: string): string {
380
+ return wrapForeground(this.#ansiFgColors[ANSI_COLOR_INDEX[color]], text);
381
+ }
382
+
367
383
  /** Apply a foreground, replacing terminal-default tokens with the theme's contrast-safe fallback. */
368
384
  fgResolved(color: ThemeColor, text: string): string {
369
385
  let resolved = this.#resolvedFgColors.get(color);
@@ -408,6 +424,11 @@ export class Theme {
408
424
  return boldStyler(text);
409
425
  }
410
426
 
427
+ /** Reduce terminal intensity without replacing the text's foreground colors. */
428
+ faint(text: string): string {
429
+ return faintStyler(text);
430
+ }
431
+
411
432
  italic(text: string): string {
412
433
  return italicStyler(text);
413
434
  }
@@ -656,6 +677,8 @@ export class Theme {
656
677
  job: this.#symbols["icon.job"],
657
678
  cache: this.#symbols["icon.cache"],
658
679
  cacheMiss: this.#symbols["icon.cacheMiss"],
680
+ cacheWarm: this.#symbols["icon.cacheWarm"],
681
+ cacheCold: this.#symbols["icon.cacheCold"],
659
682
  input: this.#symbols["icon.input"],
660
683
  output: this.#symbols["icon.output"],
661
684
  throughput: this.#symbols["icon.throughput"],
@@ -419,7 +419,7 @@
419
419
  },
420
420
  "ansi": {
421
421
  "type": "array",
422
- "description": "ANSI colors 0-15",
422
+ "description": "ANSI colors 0-15; also the palette colorful Markdown (tui.colorfulMarkdown) paints headings, emphasis, inline code and table headers from",
423
423
  "items": { "$ref": "#/$defs/colorValue" },
424
424
  "minItems": 16,
425
425
  "maxItems": 16
@@ -6,7 +6,7 @@ export { getAvailableThemes, getAvailableThemesWithPaths, getThemeByName, type T
6
6
  export { isValidThemeColor, type ThemeBg, type ThemeColor } from "./schema";
7
7
  export { getAvailableSymbolPresets, isValidSymbolPreset, type SpinnerType, type SymbolKey, type SymbolPreset, } from "./symbols";
8
8
  export { Theme } from "./theme-class";
9
- export { createHighlightStream, getEditorTheme, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getSelectListTheme, getSettingsListTheme, getSymbolTheme, highlightCode, isHighlightLanguage, setMarkdownMermaidRendering, warmHighlighter, } from "./tui-adapters";
9
+ export { createHighlightStream, getEditorTheme, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getSelectListTheme, getSettingsListTheme, getSymbolTheme, highlightCode, isHighlightLanguage, setMarkdownColorful, setMarkdownMermaidRendering, warmHighlighter, } from "./tui-adapters";
10
10
  /**
11
11
  * Subscribe to native fallback appearance changes independently of theme changes.
12
12
  * Consumers must re-check the effective background: COLORFGBG can override it.
@@ -33,6 +33,7 @@ export {
33
33
  getSymbolTheme,
34
34
  highlightCode,
35
35
  isHighlightLanguage,
36
+ setMarkdownColorful,
36
37
  setMarkdownMermaidRendering,
37
38
  warmHighlighter,
38
39
  } from "./tui-adapters";
@@ -99,8 +100,6 @@ function getDefaultTheme(): string {
99
100
  /** Active theme; imports remain live across initialization, previews, and theme switches. */
100
101
  export var theme: Theme;
101
102
  var currentThemeName: string | undefined;
102
- /** Theme shown by `previewTheme` until the next non-preview assignment. */
103
- var previewThemeName: string | undefined;
104
103
 
105
104
  type ThemeBinding = (value: Theme) => void;
106
105
  var themeBindings: Set<ThemeBinding> | undefined;
@@ -115,10 +114,8 @@ export function bindTheme(binding: ThemeBinding): () => void {
115
114
  };
116
115
  }
117
116
 
118
- /** `previewName` marks a theme-selector preview; any other assignment ends it. */
119
- function assignTheme(value: Theme, previewName?: string): void {
117
+ function assignTheme(value: Theme): void {
120
118
  theme = value;
121
- previewThemeName = previewName;
122
119
  setActiveSymbolTheme(value);
123
120
  if (themeBindings) {
124
121
  for (const binding of themeBindings) binding(value);
@@ -282,8 +279,7 @@ export async function previewTheme(
282
279
  if (requestId !== themeLoadRequestId) {
283
280
  return { success: false, error: "Theme preview superseded by a newer request" };
284
281
  }
285
- // Previewing the active theme again (selector cancel) ends the preview.
286
- assignTheme(loadedTheme, name === currentThemeName ? undefined : name);
282
+ assignTheme(loadedTheme);
287
283
  notifyThemeChange(event);
288
284
  return { success: true };
289
285
  } catch (error) {
@@ -22,6 +22,13 @@ export declare function getSymbolTheme(): SymbolTheme;
22
22
  export declare function canCacheMarkdownListItems(candidate: MarkdownTheme): boolean;
23
23
  export declare function getMarkdownThemeWithLinkTargets(targets: ReadonlyMap<string, string>): MarkdownTheme;
24
24
  export declare function setMarkdownMermaidRendering(enabled: boolean): void;
25
+ /**
26
+ * Toggle colorful Markdown (`tui.colorfulMarkdown`): headings, emphasis, inline
27
+ * code and table headers take distinct hues from the theme's `terminal.ansi`
28
+ * palette instead of one heading color and plain bold/italic. Components built
29
+ * afterwards pick it up; callers rebuild existing transcript rows.
30
+ */
31
+ export declare function setMarkdownColorful(enabled: boolean): void;
25
32
  export declare function getMarkdownTheme(): MarkdownTheme;
26
33
  export declare function getSelectListTheme(): SelectListTheme;
27
34
  /**
@@ -10,6 +10,7 @@ import type { MarkdownTheme } from "../components/markdown";
10
10
  import type { SelectListTheme } from "../components/select-list";
11
11
  import type { SettingsListTheme } from "../components/settings-list";
12
12
  import type { SymbolTheme } from "../symbols";
13
+ import type { AnsiColor } from "./schema";
13
14
  import chalk from "@linxiraos/pi-utils/chalk";
14
15
  import { LRUCache } from "@linxiraos/pi-utils/lru";
15
16
  import { resolveMermaidAscii } from "./mermaid-cache";
@@ -199,6 +200,7 @@ const cacheableMarkdownThemes = new WeakMap<
199
200
  >();
200
201
  const linkTargetSnapshots = new WeakMap<ReadonlyMap<string, string>, ReadonlyMap<string, string>>();
201
202
  let markdownMermaidRendering = true;
203
+ let markdownColorful = true;
202
204
 
203
205
  function ownFields(object: object): ReadonlyArray<readonly [PropertyKey, unknown]> {
204
206
  return Reflect.ownKeys(object).map(key => [key, Object.getOwnPropertyDescriptor(object, key)?.value]);
@@ -263,6 +265,35 @@ export function setMarkdownMermaidRendering(enabled: boolean): void {
263
265
  cachedMarkdownTheme = undefined;
264
266
  }
265
267
 
268
+ /**
269
+ * Toggle colorful Markdown (`tui.colorfulMarkdown`): headings, emphasis, inline
270
+ * code and table headers take distinct hues from the theme's `terminal.ansi`
271
+ * palette instead of one heading color and plain bold/italic. Components built
272
+ * afterwards pick it up; callers rebuild existing transcript rows.
273
+ */
274
+ export function setMarkdownColorful(enabled: boolean): void {
275
+ if (markdownColorful === enabled) return;
276
+ markdownColorful = enabled;
277
+ cachedMarkdownTheme = undefined;
278
+ }
279
+
280
+ /** Palette slot per heading depth under colorful Markdown; index 0 is H1, deeper levels reuse the last. */
281
+ const COLORFUL_HEADING_COLORS: readonly AnsiColor[] = ["magenta", "yellow", "blue"];
282
+
283
+ /**
284
+ * Roles colorful Markdown overrides. Every hue comes from one palette so the
285
+ * roles stay distinct; mixing in `md*` tokens collides in themes that alias
286
+ * those tokens to the same palette entries (Dracula's `mdCode` is its magenta).
287
+ */
288
+ const colorfulMarkdownRoles = {
289
+ heading: (text: string, depth: number) =>
290
+ theme.ansiFg(COLORFUL_HEADING_COLORS[Math.min(depth, COLORFUL_HEADING_COLORS.length) - 1], text),
291
+ code: (text: string) => theme.ansiFg("green", text),
292
+ strong: (text: string) => theme.ansiFg("magenta", theme.bold(text)),
293
+ emphasis: (text: string) => theme.ansiFg("magenta", theme.italic(text)),
294
+ tableHeader: (text: string) => theme.ansiFg("yellow", theme.bold(text)),
295
+ } satisfies Partial<MarkdownTheme>;
296
+
266
297
  export function getMarkdownTheme(): MarkdownTheme {
267
298
  ensureThemeSync();
268
299
  if (cachedMarkdownTheme !== undefined && cachedMarkdownThemeRef === theme) {
@@ -287,9 +318,10 @@ export function getMarkdownTheme(): MarkdownTheme {
287
318
  : undefined;
288
319
  const markdownTheme: MarkdownTheme = {
289
320
  heading: (text: string) => theme.fg("mdHeading", text),
321
+ code: (text: string) => theme.fg("mdCode", text),
322
+ ...(markdownColorful ? colorfulMarkdownRoles : {}),
290
323
  link: (text: string) => theme.fg("mdLink", text),
291
324
  linkUrl: (text: string) => theme.fg("mdLinkUrl", text),
292
- code: (text: string) => theme.fg("mdCode", text),
293
325
  codeBlock: (text: string) => theme.fg("mdCodeBlock", text),
294
326
  codeBlockBorder: (text: string) => theme.fg("mdCodeBlockBorder", text),
295
327
  quote: (text: string) => theme.fg("mdQuote", text),
package/src/thinking.d.ts CHANGED
@@ -53,6 +53,18 @@ export declare const AUTO_THINKING: "auto";
53
53
  export type { ConfiguredThinkingLevel } from "./render/render-utils";
54
54
  /** Maps the session-level `auto` sentinel to `undefined`; concrete levels pass through. */
55
55
  export declare function concreteThinkingLevel(level: ConfiguredThinkingLevel | undefined): ThinkingLevel | undefined;
56
+ /**
57
+ * Selector a new session on `model` starts with when neither the launch nor a
58
+ * restored session pins one: the default role's explicit selector, then the
59
+ * model's own default level (unless the configured default is `auto`), then the
60
+ * configured default. Shared by session startup and the next launch's prepaint.
61
+ */
62
+ export declare function newSessionThinkingLevel(model: Model | undefined, roleLevel: ConfiguredThinkingLevel | undefined, configuredDefault: ConfiguredThinkingLevel | undefined): ConfiguredThinkingLevel | undefined;
63
+ /**
64
+ * Concrete level `selector` runs at on `model`: clamped to its ladder, or the
65
+ * provisional effort while `auto` awaits its first per-turn classification.
66
+ */
67
+ export declare function resolveConfiguredThinkingLevel(model: Model | undefined, selector: ConfiguredThinkingLevel | undefined): ResolvedThinkingLevel | undefined;
56
68
  /**
57
69
  * True when a prewalk hand-off from `current`/`currentLevel` to
58
70
  * `target`/`targetLevel` would change nothing observable: same model id, same
package/src/thinking.ts CHANGED
@@ -156,6 +156,37 @@ export function concreteThinkingLevel(level: ConfiguredThinkingLevel | undefined
156
156
  return level === AUTO_THINKING ? undefined : level;
157
157
  }
158
158
 
159
+ /**
160
+ * Selector a new session on `model` starts with when neither the launch nor a
161
+ * restored session pins one: the default role's explicit selector, then the
162
+ * model's own default level (unless the configured default is `auto`), then the
163
+ * configured default. Shared by session startup and the next launch's prepaint.
164
+ */
165
+ export function newSessionThinkingLevel(
166
+ model: Model | undefined,
167
+ roleLevel: ConfiguredThinkingLevel | undefined,
168
+ configuredDefault: ConfiguredThinkingLevel | undefined,
169
+ ): ConfiguredThinkingLevel | undefined {
170
+ if (roleLevel !== undefined) return roleLevel;
171
+ if (configuredDefault !== AUTO_THINKING && model?.thinking?.defaultLevel !== undefined) {
172
+ return model.thinking.defaultLevel;
173
+ }
174
+ return automaticThinkingLevel(model, configuredDefault);
175
+ }
176
+
177
+ /**
178
+ * Concrete level `selector` runs at on `model`: clamped to its ladder, or the
179
+ * provisional effort while `auto` awaits its first per-turn classification.
180
+ */
181
+ export function resolveConfiguredThinkingLevel(
182
+ model: Model | undefined,
183
+ selector: ConfiguredThinkingLevel | undefined,
184
+ ): ResolvedThinkingLevel | undefined {
185
+ return selector === AUTO_THINKING
186
+ ? resolveProvisionalAutoLevel(model)
187
+ : resolveThinkingLevelForModel(model, selector);
188
+ }
189
+
159
190
  /**
160
191
  * True when a prewalk hand-off from `current`/`currentLevel` to
161
192
  * `target`/`targetLevel` would change nothing observable: same model id, same
@@ -69,6 +69,6 @@ export declare const askToolRenderer: {
69
69
  text?: string;
70
70
  }>;
71
71
  details?: AskToolDetails;
72
- }, _options: RenderResultOptions, uiTheme: Theme): Component;
72
+ }, _options: RenderResultOptions, uiTheme: Theme, args?: AskRenderArgs): Component;
73
73
  };
74
74
  export {};
package/src/tools/ask.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { NativeToolHead, NativeToolView, ToolRenderer, ToolRenderResult } from "./renderer";
2
+ import { formatCount } from "@linxiraos/pi-utils";
2
3
  import type { TspSpan } from "@linxiraos/pi-wire";
3
4
  import { compact, md, node, row, span, text } from "../native/describe";
4
5
  import type { NativeChild, NativeNode } from "../native/node";
@@ -8,6 +9,7 @@ import { noteText, resultText } from "./native-view";
8
9
 
9
10
  import {
10
11
  type Component,
12
+ lexDocument,
11
13
  Markdown,
12
14
  type MarkdownTheme,
13
15
  renderInlineMarkdown,
@@ -25,13 +27,7 @@ import { outputBlockContentWidth, renderStatusLine } from "../render";
25
27
  import { framedToolCard } from "../render/tool-card";
26
28
  import { wrapPrefixedLine } from "../render/hanging-wrap";
27
29
 
28
- import {
29
- formatErrorMessage,
30
- formatMeta,
31
- formatStatusIcon,
32
- formatTitle,
33
- sanitizeCarriageReturns,
34
- } from "../render/render-utils";
30
+ import { formatErrorMessage, formatStatusIcon, formatTitle, sanitizeCarriageReturns } from "../render/render-utils";
35
31
 
36
32
  /** Result for a single question */
37
33
  export interface QuestionResult {
@@ -240,6 +236,58 @@ function renderQuestionOptionLines(
240
236
  return out;
241
237
  }
242
238
 
239
+ /** Flags of a question form: `multi` and its option count. */
240
+ function questionFlags(multi: boolean | undefined, optionCount: number): string[] {
241
+ const flags: string[] = [];
242
+ if (multi) flags.push("multi");
243
+ if (optionCount > 0) flags.push(formatCount("option", optionCount));
244
+ return flags;
245
+ }
246
+
247
+ /** Dim `multi · 3 options` footer flags, or undefined when there are none. */
248
+ function formatQuestionFlags(uiTheme: Theme, multi: boolean | undefined, optionCount: number): string | undefined {
249
+ const flags = questionFlags(multi, optionCount);
250
+ return flags.length > 0 ? uiTheme.fg("dim", flags.join(uiTheme.sep.dot)) : undefined;
251
+ }
252
+
253
+ /** A question's dim `(id · multi · 3 options)` tag in a multi-question card. */
254
+ interface QuestionTag {
255
+ text: string;
256
+ /** The question ends in a plain paragraph, so the tag may continue its last row. */
257
+ afterText: boolean;
258
+ }
259
+
260
+ function questionTag(uiTheme: Theme, question: string, id: string, flags: readonly string[]): QuestionTag {
261
+ const lastBlock = lexDocument(question).findLast(token => token.type !== "space");
262
+ // Ids are model-supplied: a newline or tab would split or hole the row.
263
+ const label = replaceTabs(id.replace(/\n+/g, " "));
264
+ return {
265
+ text: uiTheme.fg("dim", `(${[label, ...flags].join(uiTheme.sep.dot)})`),
266
+ afterText: lastBlock?.type === "paragraph",
267
+ };
268
+ }
269
+
270
+ /**
271
+ * Append a `tag` after the last row of a rendered question, or give it a row of
272
+ * its own when it does not fit there or would trail a list item, code fence or
273
+ * table instead of the question's text.
274
+ */
275
+ function appendQuestionTag(lines: readonly string[], tag: QuestionTag, contentWidth: number): string[] {
276
+ // Markdown pads each row to the full width; the tag follows the text, not the padding.
277
+ const last = lines.at(-1)?.trimEnd() ?? "";
278
+ const fits = last.trim() !== "" && visibleWidth(last) + 1 + visibleWidth(tag.text) <= contentWidth;
279
+ // A tag wider than the row wraps under its own one-column indent.
280
+ if (!tag.afterText || !fits) return [...lines, ...wrapPrefixedLine(" ", " ", tag.text, contentWidth)];
281
+ return [...lines.slice(0, -1), `${last} ${tag.text}`];
282
+ }
283
+
284
+ /** Header subject: the lone question's id on one row, or the question count. */
285
+ function askSubject(questions: readonly { id: string }[]): string {
286
+ return questions.length === 1
287
+ ? replaceTabs(questions[0].id.replace(/\n+/g, " "))
288
+ : formatCount("question", questions.length);
289
+ }
290
+
243
291
  /**
244
292
  * Resolve selected labels to option indices against the RAW persisted labels.
245
293
  * Sanitizing can merge distinct options (`Retry\rnow`/`Retry now`) into one
@@ -467,26 +515,29 @@ export const askToolRenderer = {
467
515
  const md = (text: string, width: number) =>
468
516
  new Markdown(text, 1, 0, mdTheme, accentStyle).render(Math.max(1, outputBlockContentWidth(width) + 1));
469
517
 
470
- // Multi-part questions: one divider-labelled section per question.
471
518
  // Call args are untrusted (partially streamed or model-mangled) and a
472
519
  // throw here takes down the whole TUI render loop — normalize first.
473
520
  const questions = normalizeRenderQuestions(args.questions);
474
521
  if (questions && questions.length > 0) {
475
- const header = `${label} ${uiTheme.fg("muted", `${questions.length} questions`)}`;
522
+ const header = `${label}: ${uiTheme.fg("muted", askSubject(questions))}`;
523
+ // One question: its id is the header subject and its flags the footer.
524
+ // Several: each question is tagged with its id and flags, divided by plain separators.
525
+ const lone = questions.length === 1 ? questions[0] : undefined;
526
+ const footerMeta = lone ? formatQuestionFlags(uiTheme, lone.multi, lone.options.length) : undefined;
527
+ const tags = lone
528
+ ? undefined
529
+ : questions.map(q => questionTag(uiTheme, q.question, q.id, questionFlags(q.multi, q.options.length)));
476
530
  return framedToolCard(uiTheme, ({ width, contentWidth }) => {
477
- const sections = questions.map(q => {
478
- const meta: string[] = [];
479
- if (q.multi) meta.push("multi");
480
- if (q.options?.length) meta.push(`options:${q.options.length}`);
481
- const metaStr = meta.length > 0 ? uiTheme.fg("dim", ` · ${meta.join(" · ")}`) : "";
482
- // md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
531
+ const sections = questions.map((q, index) => {
483
532
  const mdLines = md(q.question, width);
484
- const lines = q.options?.length
485
- ? [...mdLines, ...renderQuestionOptionLines(uiTheme, mdTheme, q.options, q.multi, contentWidth)]
486
- : mdLines;
487
- return { label: `${uiTheme.fg("dim", `[${q.id}]`)}${metaStr}`, content: lines };
533
+ // md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
534
+ const content = [
535
+ ...(tags ? appendQuestionTag(mdLines, tags[index]!, contentWidth) : mdLines),
536
+ ...renderQuestionOptionLines(uiTheme, mdTheme, q.options, q.multi, contentWidth),
537
+ ];
538
+ return { content, separator: index > 0 };
488
539
  });
489
- return { header, sections, phase: "pending", borderColor: "borderMuted" };
540
+ return { header, sections, footerMeta, phase: "pending", borderColor: "borderMuted" };
490
541
  });
491
542
  }
492
543
 
@@ -502,21 +553,19 @@ export const askToolRenderer = {
502
553
  }
503
554
 
504
555
  const question = sanitizeCarriageReturns(args.question);
505
- const meta: string[] = [];
506
- if (args.multi) meta.push("multi");
507
- const questionOptions = normalizeRenderOptions(args.options);
508
- if (questionOptions?.length) meta.push(`options:${questionOptions.length}`);
509
- const header = `${label}${formatMeta(meta, uiTheme)}`;
556
+ const questionOptions = normalizeRenderOptions(args.options) ?? [];
510
557
  const multi = args.multi;
558
+ const footerMeta = formatQuestionFlags(uiTheme, multi, questionOptions.length);
511
559
  return framedToolCard(uiTheme, ({ width, contentWidth }) => {
512
560
  // md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
513
- const mdLines = md(question, width);
514
- const bodyLines = questionOptions?.length
515
- ? [...mdLines, ...renderQuestionOptionLines(uiTheme, mdTheme, questionOptions, multi, contentWidth)]
516
- : mdLines;
561
+ const bodyLines = [
562
+ ...md(question, width),
563
+ ...renderQuestionOptionLines(uiTheme, mdTheme, questionOptions, multi, contentWidth),
564
+ ];
517
565
  return {
518
- header,
566
+ header: label,
519
567
  sections: bodyLines.length > 0 ? [{ content: bodyLines }] : [],
568
+ footerMeta,
520
569
  phase: "pending",
521
570
  borderColor: "borderMuted",
522
571
  };
@@ -527,6 +576,7 @@ export const askToolRenderer = {
527
576
  result: { content: Array<{ type: string; text?: string }>; details?: AskToolDetails },
528
577
  _options: RenderResultOptions,
529
578
  uiTheme: Theme,
579
+ args?: AskRenderArgs,
530
580
  ): Component {
531
581
  const rawDetails = result.details;
532
582
  const mdTheme = getMarkdownTheme();
@@ -534,10 +584,13 @@ export const askToolRenderer = {
534
584
  const md = (text: string, width: number) =>
535
585
  new Markdown(text, 1, 0, mdTheme, accentStyle).render(Math.max(1, outputBlockContentWidth(width) + 1));
536
586
 
587
+ const argQuestions = normalizeRenderQuestions(args?.questions);
588
+ const argSubject = argQuestions?.length ? askSubject(argQuestions) : undefined;
589
+
537
590
  if (!rawDetails) {
538
591
  const txt = result.content[0];
539
592
  const fallback = txt?.type === "text" && txt.text ? sanitizeCarriageReturns(txt.text) : "";
540
- const header = renderStatusLine({ icon: "warning", title: "Ask" }, uiTheme);
593
+ const header = renderStatusLine({ icon: "warning", title: "Ask", description: argSubject }, uiTheme);
541
594
  const body = fallback ? `\n${uiTheme.fg("dim", fallback)}` : "";
542
595
  return new Text(`${header}${body}`, 0, 0);
543
596
  }
@@ -545,7 +598,10 @@ export const askToolRenderer = {
545
598
 
546
599
  // Chat redirect: user chose "Chat about this" instead of answering.
547
600
  if (details.chatRedirect) {
548
- const header = renderStatusLine({ icon: "info", title: "Ask", meta: ["chat redirect"] }, uiTheme);
601
+ const header = renderStatusLine(
602
+ { icon: "info", title: "Ask", description: argSubject, meta: ["chat redirect"] },
603
+ uiTheme,
604
+ );
549
605
  const questions = details.questions ?? [];
550
606
  return framedToolCard(uiTheme, ({ width }) => ({
551
607
  header,
@@ -555,7 +611,7 @@ export const askToolRenderer = {
555
611
  }));
556
612
  }
557
613
 
558
- // Multi-part results: one divider-labelled section per question.
614
+ // Multi-part results: one separator-divided section per question, each tagged with its id.
559
615
  if (details.results && details.results.length > 0) {
560
616
  const results = details.results;
561
617
  const hasAnySelection = results.some(
@@ -564,11 +620,15 @@ export const askToolRenderer = {
564
620
  r.note !== undefined ||
565
621
  (r.selectedOptions && r.selectedOptions.length > 0),
566
622
  );
623
+ const tags =
624
+ results.length === 1
625
+ ? undefined
626
+ : results.map(r => questionTag(uiTheme, r.question, r.id, r.multi ? ["multi"] : []));
567
627
  const header = renderStatusLine(
568
628
  {
569
629
  icon: hasAnySelection ? "success" : "warning",
570
630
  title: "Ask",
571
- meta: [`${results.length} questions`],
631
+ description: askSubject(results),
572
632
  },
573
633
  uiTheme,
574
634
  );
@@ -577,9 +637,10 @@ export const askToolRenderer = {
577
637
  const sections = results.map((r, index) => {
578
638
  // Sanitizing preserves order and length, so raw indices align with `r`.
579
639
  const raw = rawResults[index];
640
+ const mdLines = md(r.question, width);
580
641
  // md() returns a shared cached array (module-level Markdown LRU) — copy before appending.
581
642
  const lines = [
582
- ...md(r.question, width),
643
+ ...(tags ? appendQuestionTag(mdLines, tags[index]!, contentWidth) : mdLines),
583
644
  ...renderAnswerOptionLines(
584
645
  uiTheme,
585
646
  mdTheme,
@@ -593,7 +654,7 @@ export const askToolRenderer = {
593
654
  selectedIndicesFor(raw?.options, raw?.selectedOptions),
594
655
  ),
595
656
  ];
596
- return { label: uiTheme.fg("dim", `[${r.id}]`), content: lines };
657
+ return { content: lines, separator: index > 0 };
597
658
  });
598
659
  return {
599
660
  header,
@@ -618,8 +679,8 @@ export const askToolRenderer = {
618
679
  (details.selectedOptions && details.selectedOptions.length > 0);
619
680
  const header = renderStatusLine(
620
681
  hasSelection
621
- ? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title: "Ask" }
622
- : { icon: "warning", title: "Ask" },
682
+ ? { iconOverride: uiTheme.styledSymbol("tool.ask", "accent"), title: "Ask", description: argSubject }
683
+ : { icon: "warning", title: "Ask", description: argSubject },
623
684
  uiTheme,
624
685
  );
625
686
  const dOptions = details.options;