@linxiraos/pi-tui 1.4.7 → 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 (172) hide show
  1. package/CHANGELOG.md +28 -109
  2. package/README.md +7 -1
  3. package/dist/types/app-keybindings.d.ts +5 -0
  4. package/dist/types/charts/table-data.d.ts +4 -2
  5. package/dist/types/chat/bash-execution.d.ts +4 -1
  6. package/dist/types/chat/eval-execution.d.ts +2 -0
  7. package/dist/types/chat/execution-shared.d.ts +14 -8
  8. package/dist/types/chat/figure-markdown.d.ts +2 -0
  9. package/dist/types/chat/svg-figure.d.ts +5 -0
  10. package/dist/types/chat/table-chart.d.ts +2 -0
  11. package/dist/types/chat/transcript-render-helpers.d.ts +11 -3
  12. package/dist/types/chrome/dynamic-border.d.ts +6 -0
  13. package/dist/types/chrome/transcript-status.d.ts +2 -2
  14. package/dist/types/components/editor.d.ts +15 -6
  15. package/dist/types/components/image.d.ts +6 -0
  16. package/dist/types/components/loader.d.ts +2 -0
  17. package/dist/types/keybinding-matchers.d.ts +7 -0
  18. package/dist/types/native/describe.d.ts +4 -2
  19. package/dist/types/native/node.d.ts +2 -3
  20. package/dist/types/native/overlay.d.ts +42 -2
  21. package/dist/types/native/state.d.ts +4 -0
  22. package/dist/types/overlays/btw-history-panel.d.ts +15 -0
  23. package/dist/types/overlays/btw-history.d.ts +24 -0
  24. package/dist/types/overlays/btw-inject.d.ts +22 -0
  25. package/dist/types/overlays/btw-panel.d.ts +7 -0
  26. package/dist/types/overlays/hook-editor.d.ts +2 -0
  27. package/dist/types/overlays/jobs-panel.d.ts +4 -0
  28. package/dist/types/overlays/model-browser.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +11 -2
  30. package/dist/types/prompt/composer.d.ts +13 -5
  31. package/dist/types/render/render-utils.d.ts +23 -1
  32. package/dist/types/status-line/startup.d.ts +0 -15
  33. package/dist/types/terminal-capabilities.d.ts +1 -1
  34. package/dist/types/theme/symbols.d.ts +3 -1
  35. package/dist/types/theme/theme-class.d.ts +1 -0
  36. package/dist/types/theme/theme.d.ts +1 -1
  37. package/dist/types/theme/tui-adapters.d.ts +2 -0
  38. package/dist/types/thinking.d.ts +8 -6
  39. package/dist/types/tools/ast-grep.d.ts +2 -0
  40. package/dist/types/tools/eval.d.ts +2 -0
  41. package/dist/types/tools/find.d.ts +1 -1
  42. package/dist/types/tools/grouped-file-output.d.ts +100 -19
  43. package/dist/types/tools/hashline-format.d.ts +5 -0
  44. package/dist/types/tools/native-view.d.ts +2 -0
  45. package/dist/types/tools/output-meta.d.ts +27 -0
  46. package/dist/types/tools/read.d.ts +14 -4
  47. package/dist/types/tools/task.d.ts +4 -3
  48. package/dist/types/tools/wait.d.ts +2 -0
  49. package/dist/types/tui.d.ts +12 -0
  50. package/dist/types/utils.d.ts +4 -0
  51. package/package.json +9 -9
  52. package/src/app-keybindings.d.ts +5 -0
  53. package/src/app-keybindings.ts +5 -0
  54. package/src/apps/git/git-tui.ts +10 -17
  55. package/src/apps/git/sidebar.ts +21 -35
  56. package/src/apps/ps-top.ts +4 -12
  57. package/src/charts/chart-plan.ts +0 -29
  58. package/src/charts/table-data.d.ts +4 -2
  59. package/src/charts/table-data.ts +55 -6
  60. package/src/chat/bash-execution.d.ts +4 -1
  61. package/src/chat/bash-execution.ts +20 -9
  62. package/src/chat/chat-transcript-builder.ts +5 -2
  63. package/src/chat/eval-execution.d.ts +2 -0
  64. package/src/chat/eval-execution.ts +14 -7
  65. package/src/chat/execution-shared.d.ts +14 -8
  66. package/src/chat/execution-shared.ts +39 -18
  67. package/src/chat/figure-markdown.d.ts +2 -0
  68. package/src/chat/figure-markdown.ts +6 -4
  69. package/src/chat/read-tool-group.ts +56 -36
  70. package/src/chat/svg-figure.d.ts +5 -0
  71. package/src/chat/svg-figure.ts +55 -16
  72. package/src/chat/table-chart.d.ts +2 -0
  73. package/src/chat/table-chart.ts +19 -2
  74. package/src/chat/transcript-render-helpers.d.ts +11 -3
  75. package/src/chat/transcript-render-helpers.ts +70 -22
  76. package/src/chrome/dynamic-border.d.ts +6 -0
  77. package/src/chrome/dynamic-border.ts +28 -2
  78. package/src/chrome/transcript-status.d.ts +2 -2
  79. package/src/chrome/transcript-status.ts +5 -3
  80. package/src/components/editor.d.ts +15 -6
  81. package/src/components/editor.ts +123 -24
  82. package/src/components/image.d.ts +6 -0
  83. package/src/components/image.ts +13 -0
  84. package/src/components/key-value-list.ts +9 -9
  85. package/src/components/loader.d.ts +2 -0
  86. package/src/components/loader.ts +7 -0
  87. package/src/components/section.ts +1 -9
  88. package/src/components/table.ts +1 -9
  89. package/src/keybinding-matchers.d.ts +7 -0
  90. package/src/keybinding-matchers.ts +13 -0
  91. package/src/native/backend.ts +7 -3
  92. package/src/native/describe.d.ts +4 -2
  93. package/src/native/describe.ts +9 -4
  94. package/src/native/node.d.ts +2 -3
  95. package/src/native/node.ts +2 -3
  96. package/src/native/overlay.d.ts +42 -2
  97. package/src/native/overlay.ts +124 -16
  98. package/src/native/state.d.ts +4 -0
  99. package/src/native/state.ts +25 -5
  100. package/src/overlays/btw-history-panel.ts +106 -14
  101. package/src/overlays/btw-history.ts +65 -0
  102. package/src/overlays/btw-inject.ts +91 -0
  103. package/src/overlays/btw-panel.ts +53 -12
  104. package/src/overlays/extensions/extension-dashboard.ts +7 -8
  105. package/src/overlays/hook-editor.ts +6 -0
  106. package/src/overlays/jobs-panel.ts +82 -22
  107. package/src/overlays/login-dialog.ts +8 -26
  108. package/src/overlays/model-browser.ts +69 -10
  109. package/src/overlays/session-selector.ts +25 -5
  110. package/src/overlays/settings-defs.ts +2 -2
  111. package/src/overlays/tree-selector.ts +83 -27
  112. package/src/overlays/usage-dashboard.ts +4 -6
  113. package/src/prompt/composer.ts +17 -5
  114. package/src/render/code-cell.ts +1 -1
  115. package/src/render/file-list.ts +4 -7
  116. package/src/render/render-utils.d.ts +23 -1
  117. package/src/render/render-utils.ts +38 -6
  118. package/src/setup/scenes/glyph.ts +1 -1
  119. package/src/status-line/startup.ts +36 -70
  120. package/src/terminal-capabilities.d.ts +1 -1
  121. package/src/terminal-capabilities.ts +5 -0
  122. package/src/theme/symbols.d.ts +3 -1
  123. package/src/theme/symbols.ts +16 -9
  124. package/src/theme/theme-class.d.ts +1 -0
  125. package/src/theme/theme-class.ts +15 -3
  126. package/src/theme/theme.d.ts +1 -1
  127. package/src/theme/theme.ts +1 -0
  128. package/src/theme/tui-adapters.d.ts +2 -0
  129. package/src/theme/tui-adapters.ts +8 -3
  130. package/src/thinking.d.ts +8 -6
  131. package/src/thinking.ts +17 -11
  132. package/src/tmux.ts +1 -0
  133. package/src/tools/agent-tree.ts +13 -11
  134. package/src/tools/ask.ts +24 -37
  135. package/src/tools/ast-edit.ts +48 -93
  136. package/src/tools/ast-grep.d.ts +2 -0
  137. package/src/tools/ast-grep.ts +31 -67
  138. package/src/tools/bash.ts +7 -0
  139. package/src/tools/default-renderer.ts +1 -1
  140. package/src/tools/edit.ts +50 -43
  141. package/src/tools/eval.d.ts +2 -0
  142. package/src/tools/eval.ts +2 -0
  143. package/src/tools/fetch.ts +2 -1
  144. package/src/tools/find.d.ts +1 -1
  145. package/src/tools/find.ts +13 -5
  146. package/src/tools/github.ts +14 -46
  147. package/src/tools/glob.ts +2 -1
  148. package/src/tools/grep.ts +47 -277
  149. package/src/tools/grouped-file-output.d.ts +100 -19
  150. package/src/tools/grouped-file-output.ts +414 -103
  151. package/src/tools/hashline-format.d.ts +5 -0
  152. package/src/tools/hashline-format.ts +5 -0
  153. package/src/tools/json-tree.ts +1 -5
  154. package/src/tools/lsp.ts +210 -32
  155. package/src/tools/native-view.d.ts +2 -0
  156. package/src/tools/native-view.ts +11 -5
  157. package/src/tools/output-meta.d.ts +27 -0
  158. package/src/tools/output-meta.ts +68 -4
  159. package/src/tools/proc-render.ts +3 -3
  160. package/src/tools/read.d.ts +14 -4
  161. package/src/tools/read.ts +20 -5
  162. package/src/tools/task.d.ts +4 -3
  163. package/src/tools/task.ts +41 -81
  164. package/src/tools/vibe.ts +4 -4
  165. package/src/tools/wait.d.ts +2 -0
  166. package/src/tools/wait.ts +8 -5
  167. package/src/tools/write.ts +17 -27
  168. package/src/tools/yield.ts +1 -1
  169. package/src/tui.d.ts +12 -0
  170. package/src/tui.ts +91 -9
  171. package/src/utils.d.ts +4 -0
  172. package/src/utils.ts +10 -0
@@ -6,6 +6,7 @@ import { node, span } from "../native/describe";
6
6
  import type { NativeNode } from "../native/node";
7
7
  import type { Theme } from "../theme/theme";
8
8
  import { fileLinkSpan } from "./hyperlink";
9
+ import { formatStyledPath } from "./render-utils";
9
10
  import { renderTreeList } from "./tree-list";
10
11
 
11
12
  /** A file-list item with optional display metadata. */
@@ -69,15 +70,11 @@ export function renderFileList(options: FileListOptions, theme: Theme): string[]
69
70
  const isDirectory = entry.isDirectory ?? entry.path.endsWith("/");
70
71
  const displayPath = entry.path;
71
72
  const lang = isDirectory ? undefined : getLanguageFromPath(displayPath);
72
- const icon = !showIcons
73
- ? ""
74
- : isDirectory
75
- ? theme.fg("accent", theme.icon.folder)
76
- : theme.fg("muted", theme.getLangIcon(lang));
77
- const labelColor = isDirectory ? "accent" : "toolOutput";
73
+ // Type icons stay muted beside the dim directory and colored file name.
74
+ const icon = !showIcons ? "" : theme.fg("muted", isDirectory ? theme.icon.folder : theme.getLangIcon(lang));
78
75
  const meta = entry.meta ? ` ${theme.fg("dim", entry.meta)}` : "";
79
76
  const iconPrefix = icon ? `${icon} ` : "";
80
- const pathStr = theme.fg(labelColor, displayPath);
77
+ const pathStr = formatStyledPath(displayPath, theme);
81
78
  const linkedPath = entry.absPath && hyperlinkFn ? hyperlinkFn(entry.absPath, pathStr) : pathStr;
82
79
  return `${iconPrefix}${linkedPath}${meta}`;
83
80
  },
@@ -49,6 +49,8 @@ export declare const PREVIEW_LIMITS: {
49
49
  readonly EXPANDED_LINES: 12;
50
50
  /** Items (files, results) shown in collapsed view */
51
51
  readonly COLLAPSED_ITEMS: 8;
52
+ /** Definition, type-definition and implementation locations shown in collapsed view */
53
+ readonly LOCATIONS_COLLAPSED: 2;
52
54
  /** Output preview lines in collapsed view */
53
55
  readonly OUTPUT_COLLAPSED: 3;
54
56
  /** Output preview lines in expanded view */
@@ -188,11 +190,31 @@ export declare function formatErrorMessage(message: string | undefined, theme: T
188
190
  export declare function formatErrorDetail(message: string | undefined, theme: Theme): string;
189
191
  /** Render a muted empty-state message with a warning icon. */
190
192
  export declare function formatEmptyMessage(message: string, theme: Theme): string;
193
+ /**
194
+ * Color of a file's name, or a whole URL, in tool bodies: it keeps paths apart
195
+ * from the tool titles above them (bronze in titanium).
196
+ */
197
+ export declare const FILE_NAME_COLOR = "customMessageLabel";
198
+ /**
199
+ * Where a display path's final segment (file or folder name) starts, past its
200
+ * last `/` or `\` separator; a trailing-slash directory keeps its slash on the
201
+ * name. Shared by the terminal ({@link formatStyledPath}) and Tern file rows.
202
+ */
203
+ export declare function pathNameStart(filePath: string): number;
204
+ /**
205
+ * A file path in a tool body: the directory (with its trailing separator) dim,
206
+ * the final segment in {@link FILE_NAME_COLOR}. Tool headers keep paths in
207
+ * their plain subject color instead.
208
+ */
209
+ export declare function formatStyledPath(filePath: string, theme: Theme): string;
191
210
  /** Marker displayed in the gutter of a code frame. */
192
211
  export type CodeFrameMarker = "" | " " | "*" | "+" | "-" | ">";
193
212
  /** Format a code-frame row with a padded line-number gutter. */
194
213
  export declare function formatCodeFrameLine(marker: CodeFrameMarker, lineNumber: string | number, content: string, lineNumberWidth: number): string;
195
- /** Status states supported by shared tool renderer icons. */
214
+ /**
215
+ * Status states supported by shared tool renderer icons. `done` is a deprecated
216
+ * alias of `success`, kept for extension renderers.
217
+ */
196
218
  export type ToolUIStatus = "success" | "done" | "error" | "warning" | "info" | "pending" | "running" | "aborted";
197
219
  /** Semantic foreground colors used by tool renderer labels. */
198
220
  export type ToolUIColor = "success" | "error" | "warning" | "accent" | "muted";
@@ -13,7 +13,7 @@ import { expandWindowsLongPath, getWindowsShortPath } from "@linxiraos/pi-native
13
13
  import { pluralize, sanitizeText } from "@linxiraos/pi-utils";
14
14
  import { formatKeyHint, type KeyId } from "../app-keybindings";
15
15
  import { getKeybindings } from "../keybindings";
16
- import type { Theme } from "../theme/theme";
16
+ import type { Theme, ThemeColor } from "../theme/theme";
17
17
  import type { Component } from "../tui";
18
18
  import { replaceTabs, sliceByColumn, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "../utils";
19
19
  import { Hasher } from "./utils";
@@ -103,6 +103,8 @@ export const PREVIEW_LIMITS = {
103
103
  EXPANDED_LINES: 12,
104
104
  /** Items (files, results) shown in collapsed view */
105
105
  COLLAPSED_ITEMS: 8,
106
+ /** Definition, type-definition and implementation locations shown in collapsed view */
107
+ LOCATIONS_COLLAPSED: 2,
106
108
  /** Output preview lines in collapsed view */
107
109
  OUTPUT_COLLAPSED: 3,
108
110
  /** Output preview lines in expanded view */
@@ -291,9 +293,8 @@ export { formatAge, formatBytes, formatCount, formatDuration, formatNumber, plur
291
293
  export function formatStatusIcon(status: ToolUIStatus, theme: Theme, spinnerFrame?: number): string {
292
294
  switch (status) {
293
295
  case "success":
294
- return theme.styledSymbol("status.success", "success");
295
296
  case "done":
296
- return theme.styledSymbol("status.done", "success");
297
+ return theme.styledSymbol("status.success", "success");
297
298
  case "error":
298
299
  return theme.styledSymbol("status.error", "error");
299
300
  case "warning":
@@ -433,6 +434,34 @@ export function formatEmptyMessage(message: string, theme: Theme): string {
433
434
  return `${theme.styledSymbol("status.warning", "warning")} ${theme.fg("muted", message)}`;
434
435
  }
435
436
 
437
+ /**
438
+ * Color of a file's name, or a whole URL, in tool bodies: it keeps paths apart
439
+ * from the tool titles above them (bronze in titanium).
440
+ */
441
+ export const FILE_NAME_COLOR = "customMessageLabel" satisfies ThemeColor;
442
+
443
+ /**
444
+ * Where a display path's final segment (file or folder name) starts, past its
445
+ * last `/` or `\` separator; a trailing-slash directory keeps its slash on the
446
+ * name. Shared by the terminal ({@link formatStyledPath}) and Tern file rows.
447
+ */
448
+ export function pathNameStart(filePath: string): number {
449
+ let end = filePath.length;
450
+ while (end > 0 && (filePath[end - 1] === "/" || filePath[end - 1] === "\\")) end--;
451
+ return end === 0 ? 0 : Math.max(filePath.lastIndexOf("/", end - 1), filePath.lastIndexOf("\\", end - 1)) + 1;
452
+ }
453
+
454
+ /**
455
+ * A file path in a tool body: the directory (with its trailing separator) dim,
456
+ * the final segment in {@link FILE_NAME_COLOR}. Tool headers keep paths in
457
+ * their plain subject color instead.
458
+ */
459
+ export function formatStyledPath(filePath: string, theme: Theme): string {
460
+ const cut = pathNameStart(filePath);
461
+ const name = theme.fg(FILE_NAME_COLOR, filePath.slice(cut));
462
+ return cut > 0 ? `${theme.fg("dim", filePath.slice(0, cut))}${name}` : name;
463
+ }
464
+
436
465
  // =============================================================================
437
466
  // Code Frame Formatting
438
467
  // =============================================================================
@@ -457,7 +486,10 @@ export function formatCodeFrameLine(
457
486
  // Tool UI Helpers
458
487
  // =============================================================================
459
488
 
460
- /** Status states supported by shared tool renderer icons. */
489
+ /**
490
+ * Status states supported by shared tool renderer icons. `done` is a deprecated
491
+ * alias of `success`, kept for extension renderers.
492
+ */
461
493
  export type ToolUIStatus = "success" | "done" | "error" | "warning" | "info" | "pending" | "running" | "aborted";
462
494
  /** Semantic foreground colors used by tool renderer labels. */
463
495
  export type ToolUIColor = "success" | "error" | "warning" | "accent" | "muted";
@@ -598,7 +630,7 @@ export function formatDiagnostics(
598
630
  const fileBranch = isLastFileNode ? theme.tree.last : theme.tree.branch;
599
631
 
600
632
  const fileIcon = theme.fg("muted", getLangIcon(filePath));
601
- output += `\n ${theme.fg("dim", fileBranch)} ${fileIcon} ${theme.fg("accent", filePath)}`;
633
+ output += `\n ${theme.fg("dim", fileBranch)} ${fileIcon} ${formatStyledPath(filePath, theme)}`;
602
634
 
603
635
  for (let di = 0; di < diagnostics.length && diagsShown < maxDiags; di++) {
604
636
  const d = diagnostics[di];
@@ -622,7 +654,7 @@ export function formatDiagnostics(
622
654
  : d.severity === "warning"
623
655
  ? theme.styledSymbol("status.warning", "warning")
624
656
  : theme.styledSymbol("status.info", "muted");
625
- const location = theme.fg("dim", `:${d.line}:${d.col}`);
657
+ const location = theme.fg("muted", `:${d.line}:${d.col}`);
626
658
  const codeTag = d.code ? theme.fg("dim", ` (${d.code})`) : "";
627
659
  const msgColor = d.severity === "error" ? "error" : d.severity === "warning" ? "warning" : "toolOutput";
628
660
 
@@ -21,7 +21,7 @@ const GLYPH_LABELS: Readonly<Record<SymbolPreset, string>> = {
21
21
  const GLYPH_SAMPLES: Readonly<Record<SymbolPreset, string>> = {
22
22
  nerd: "   󰉋 ",
23
23
  unicode: "✔ ✖ 📁 ⬢ ╭─╮ ├─ • ⠋ →",
24
- ascii: "[ok] [x] > + [D] +-+ |-- * ->",
24
+ ascii: "[+] [-] > + [D] +-+ |-- * ->",
25
25
  };
26
26
 
27
27
  /** One picker row per preset; the description column shows live sample glyphs instead of prose. */
@@ -13,9 +13,9 @@
13
13
  * statusLine.attachToEditor(editor, getComposerStyle(shape));
14
14
  * ```
15
15
  */
16
+ import { type } from "@linxiraos/pi-omptype";
16
17
  import type { ThinkingLevel } from "@linxiraos/pi-agent-core";
17
18
  import type { Model } from "@linxiraos/pi-catalog/types";
18
- import { isRecord } from "@linxiraos/pi-utils/type-guards";
19
19
  import { parseThinkingLevel } from "../thinking";
20
20
  import { StatusLineComponent } from "./component";
21
21
  import type { CompactionBoundaries } from "./context-usage";
@@ -100,82 +100,48 @@ export function createStartupStatusLine(data: StatusLineStartupData): StatusLine
100
100
  return statusLine;
101
101
  }
102
102
 
103
- function isOneOf<T extends string>(values: readonly T[], value: unknown): value is T {
104
- return typeof value === "string" && values.some(candidate => candidate === value);
105
- }
106
-
107
- function isOptionalBoolean(value: unknown): boolean {
108
- return value === undefined || typeof value === "boolean";
109
- }
110
-
111
- function isSegmentList(value: unknown): boolean {
112
- return value === undefined || (Array.isArray(value) && value.every(id => isOneOf(STATUS_LINE_SEGMENT_IDS, id)));
113
- }
103
+ const SegmentIds = type.enumerated(...STATUS_LINE_SEGMENT_IDS).array();
114
104
 
115
105
  /** Shallow check of persisted settings; nested segment options are trusted as written by this version. */
116
- function isStatusLineSettings(value: unknown): value is StatusLineSettings {
117
- return (
118
- isRecord(value) &&
119
- (value.preset === undefined || isOneOf(STATUS_LINE_PRESET_VALUES, value.preset)) &&
120
- isSegmentList(value.leftSegments) &&
121
- isSegmentList(value.rightSegments) &&
122
- (value.separator === undefined || isOneOf(STATUS_LINE_SEPARATOR_VALUES, value.separator)) &&
123
- (value.segmentOptions === undefined || isRecord(value.segmentOptions)) &&
124
- (value.contextLine === undefined || isOneOf(CONTEXT_LINE_MODE_VALUES, value.contextLine)) &&
125
- isOptionalBoolean(value.showHookStatus) &&
126
- isOptionalBoolean(value.sessionAccent) &&
127
- isOptionalBoolean(value.transparent) &&
128
- isOptionalBoolean(value.compactThinkingLevel)
129
- );
130
- }
131
-
132
- /** Check the model fields the status line reads; the rest is trusted as serialized by this version. */
133
- function isPersistedModel(value: unknown): value is Model {
134
- return (
135
- isRecord(value) &&
136
- typeof value.id === "string" &&
137
- typeof value.name === "string" &&
138
- typeof value.provider === "string" &&
139
- typeof value.api === "string" &&
140
- typeof value.contextWindow === "number"
141
- );
142
- }
106
+ const StatusLineSettingsShape = type({
107
+ "preset?": type.enumerated(...STATUS_LINE_PRESET_VALUES),
108
+ "leftSegments?": SegmentIds,
109
+ "rightSegments?": SegmentIds,
110
+ "separator?": type.enumerated(...STATUS_LINE_SEPARATOR_VALUES),
111
+ "segmentOptions?": "Record<string, unknown>",
112
+ "contextLine?": type.enumerated(...CONTEXT_LINE_MODE_VALUES),
113
+ "showHookStatus?": "boolean",
114
+ "sessionAccent?": "boolean",
115
+ "transparent?": "boolean",
116
+ "compactThinkingLevel?": "boolean",
117
+ });
143
118
 
144
- function readCompactionBoundaries(value: unknown): CompactionBoundaries | null | undefined {
145
- if (value === null) return null;
146
- if (!isRecord(value) || typeof value.thresholdPercent !== "number") return undefined;
147
- const speculationPercent = value.speculationPercent;
148
- if (speculationPercent !== null && typeof speculationPercent !== "number") return undefined;
149
- return { thresholdPercent: value.thresholdPercent, speculationPercent };
150
- }
119
+ const StartupDataShape = type({
120
+ "+": "delete",
121
+ settings: StatusLineSettingsShape,
122
+ gitEnabled: "boolean",
123
+ // Only the fields the status line reads; the rest is trusted as serialized by this version.
124
+ "model?": { id: "string", name: "string", provider: "string", api: "string", contextWindow: "number" },
125
+ "thinkingLevel?": "string",
126
+ autoThinking: "boolean",
127
+ fastMode: "boolean",
128
+ usingSubscription: "boolean",
129
+ autoCompactEnabled: "boolean",
130
+ compactionBoundaries: type({ "+": "delete", thresholdPercent: "number", speculationPercent: "number | null" }).or(
131
+ "null",
132
+ ),
133
+ });
151
134
 
152
135
  /** Validate persisted {@link StatusLineStartupData}; `undefined` for anything malformed. */
153
136
  export function readStatusLineStartupData(value: unknown): StatusLineStartupData | undefined {
154
- if (!isRecord(value) || !isStatusLineSettings(value.settings)) return undefined;
155
- const model = value.model;
156
- if (model !== undefined && !isPersistedModel(model)) return undefined;
157
- const thinkingLevel = typeof value.thinkingLevel === "string" ? parseThinkingLevel(value.thinkingLevel) : undefined;
158
- if (value.thinkingLevel !== undefined && thinkingLevel === undefined) return undefined;
159
- const compactionBoundaries = readCompactionBoundaries(value.compactionBoundaries);
160
- if (
161
- typeof value.gitEnabled !== "boolean" ||
162
- typeof value.autoThinking !== "boolean" ||
163
- typeof value.fastMode !== "boolean" ||
164
- typeof value.usingSubscription !== "boolean" ||
165
- typeof value.autoCompactEnabled !== "boolean" ||
166
- compactionBoundaries === undefined
167
- ) {
168
- return undefined;
169
- }
137
+ const data = StartupDataShape(value);
138
+ if (data instanceof type.errors) return undefined;
139
+ const thinkingLevel = data.thinkingLevel === undefined ? undefined : parseThinkingLevel(data.thinkingLevel);
140
+ if (data.thinkingLevel !== undefined && thinkingLevel === undefined) return undefined;
170
141
  return {
171
- settings: value.settings,
172
- gitEnabled: value.gitEnabled,
173
- model,
142
+ ...data,
143
+ settings: data.settings as StatusLineSettings,
144
+ model: data.model as Model | undefined,
174
145
  thinkingLevel,
175
- autoThinking: value.autoThinking,
176
- fastMode: value.fastMode,
177
- usingSubscription: value.usingSubscription,
178
- autoCompactEnabled: value.autoCompactEnabled,
179
- compactionBoundaries,
180
146
  };
181
147
  }
@@ -18,7 +18,7 @@ export declare enum NotifyProtocol {
18
18
  Osc99 = "\u001B]99;;",
19
19
  Osc9 = "\u001B]9;"
20
20
  }
21
- export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "zetawork" | "base" | "trueColor";
21
+ export type TerminalId = "kitty" | "ghostty" | "wezterm" | "iterm2" | "vscode" | "alacritty" | "warp" | "orca" | "otty" | "rio" | "tern" | "monstar" | "rex" | "zetawork" | "base" | "trueColor";
22
22
  /** Terminal capability details used for rendering and protocol selection. */
23
23
  export declare class TerminalInfo {
24
24
  readonly id: TerminalId;
@@ -67,6 +67,7 @@ export type TerminalId =
67
67
  | "rio"
68
68
  | "tern"
69
69
  | "monstar"
70
+ | "rex"
70
71
  | "zetawork"
71
72
  | "base"
72
73
  | "trueColor";
@@ -644,6 +645,8 @@ const KNOWN_TERMINALS = Object.freeze({
644
645
  // OSC 99, and OSC 66 text sizing are outside rio's supported set and keep
645
646
  // the conservative defaults.
646
647
  rio: new TerminalInfo("rio", ImageProtocol.Kitty, true, true),
648
+ // Rex (TERM_PROGRAM=rex / TERM=xterm-rex): only Kitty graphics is confirmed.
649
+ rex: new TerminalInfo("rex", ImageProtocol.Kitty, true, false),
647
650
  // Tern (Stencil's terminal, `stencil-term`) sets TERM_PROGRAM=tern and
648
651
  // implements Kitty graphics, OSC 8 and OSC 9/99 notifications. Whether zeta
649
652
  // renders natively (Tern Surface Protocol) is decided by the `hello`
@@ -693,6 +696,7 @@ export function detectTerminalId(env: NodeJS.ProcessEnv = Bun.env): TerminalId {
693
696
  if (caseEq(program, "rio")) return "rio";
694
697
  if (caseEq(program, "tern")) return "tern";
695
698
  if (caseEq(program, "monstar")) return "monstar";
699
+ if (caseEq(program, "rex")) return "rex";
696
700
  if (caseEq(program, "zetawork")) return "zetawork";
697
701
  return null;
698
702
  }
@@ -745,6 +749,7 @@ export function detectTerminalId(env: NodeJS.ProcessEnv = Bun.env): TerminalId {
745
749
 
746
750
  if (TERM?.toLowerCase().includes("ghostty")) return "ghostty";
747
751
  if (TERM && caseEq(TERM, "monstar")) return "monstar";
752
+ if (TERM && caseEq(TERM, "xterm-rex")) return "rex";
748
753
 
749
754
  if (COLORTERM) {
750
755
  if (caseEq(COLORTERM, "truecolor") || caseEq(COLORTERM, "24bit")) return "trueColor";
@@ -2,7 +2,9 @@ export type SymbolPreset = "unicode" | "nerd" | "ascii";
2
2
  /**
3
3
  * All available symbol keys organized by category.
4
4
  */
5
- export type SymbolKey = "status.success" | "status.error" | "status.warning" | "status.info" | "status.pending" | "status.disabled" | "status.enabled" | "status.running" | "status.shadowed" | "status.aborted" | "status.done" | "nav.cursor" | "nav.selected" | "nav.expand" | "nav.collapse" | "nav.back" | "tree.branch" | "tree.last" | "tree.vertical" | "tree.horizontal" | "tree.hook" | "progress.filled" | "progress.empty" | "context.speculation" | "context.compaction" | "context.content" | "context.messages" | "context.buffer" | "context.free" | "boxRound.topLeft" | "boxRound.topRight" | "boxRound.bottomLeft" | "boxRound.bottomRight" | "boxRound.horizontal" | "boxRound.vertical" | "boxDotted.horizontal" | "boxDotted.vertical" | "boxSharp.topLeft" | "boxSharp.topRight" | "boxSharp.bottomLeft" | "boxSharp.bottomRight" | "boxSharp.horizontal" | "boxSharp.vertical" | "boxSharp.cross" | "boxSharp.teeDown" | "boxSharp.teeUp" | "boxSharp.teeRight" | "boxSharp.teeLeft" | "sep.powerline" | "sep.powerlineThin" | "sep.powerlineLeft" | "sep.powerlineRight" | "sep.powerlineThinLeft" | "sep.powerlineThinRight" | "sep.powerlineCapLeft" | "sep.block" | "sep.space" | "sep.asciiLeft" | "sep.asciiRight" | "sep.dot" | "sep.slash" | "sep.pipe" | "icon.model" | "icon.plan" | "icon.prewalk" | "icon.goal" | "icon.pause" | "icon.loop" | "icon.folder" | "icon.worktree" | "icon.search" | "icon.scratchFolder" | "icon.file" | "icon.git" | "icon.branch" | "icon.pr" | "icon.pin" | "icon.tokens" | "icon.context" | "icon.cost" | "icon.subscription" | "icon.advisor" | "icon.advisorClosed" | "icon.time" | "icon.omp" | "icon.ghost" | "icon.agents" | "icon.job" | "icon.cache" | "icon.cacheMiss" | "icon.input" | "icon.output" | "icon.throughput" | "icon.intelligence" | "icon.host" | "icon.session" | "icon.package" | "icon.warning" | "icon.rewind" | "icon.auto" | "icon.fast" | "icon.extensionSkill" | "icon.extensionTool" | "icon.extensionSlashCommand" | "icon.extensionMcp" | "icon.extensionRule" | "icon.extensionHook" | "icon.extensionPrompt" | "icon.extensionContextFile" | "icon.extensionInstruction" | "icon.vimNormal" | "icon.vimInsert" | "icon.vimVisual" | "icon.vimVisualLine" | "icon.vimReplace" | "cmd.action" | "cmd.prompt" | "cmd.extension" | "cmd.settings" | "cmd.gear" | "cmd.shield" | "cmd.wave" | "cmd.compass" | "cmd.inbox" | "cmd.swap" | "cmd.expand" | "cmd.computer" | "cmd.eye" | "cmd.todo" | "cmd.stats" | "cmd.news" | "cmd.keyboard" | "cmd.export" | "cmd.clipboard" | "cmd.share" | "cmd.broadcast" | "cmd.globe" | "cmd.copy" | "cmd.plus" | "cmd.restart" | "cmd.eraser" | "cmd.trash" | "cmd.compress" | "cmd.vibrate" | "cmd.handoff" | "cmd.history" | "cmd.question" | "cmd.rocket" | "cmd.stethoscope" | "cmd.redo" | "cmd.bug" | "cmd.memory" | "cmd.pencil" | "cmd.folderMove" | "cmd.folderPlus" | "cmd.folderMinus" | "cmd.hammer" | "cmd.power" | "cmd.cart" | "icon.mic" | "icon.camera" | "thinking.minimal" | "thinking.low" | "thinking.medium" | "thinking.high" | "thinking.xhigh" | "thinking.max" | "thinking.autoPending" | "checkbox.checked" | "checkbox.unchecked" | "radio.selected" | "radio.unselected" | "format.bullet" | "format.dash" | "format.bracketLeft" | "format.bracketRight" | "md.quoteBorder" | "md.hrChar" | "md.bullet" | "md.colorSwatch" | "advisor.rail" | "skill.rail" | "lang.default" | "lang.typescript" | "lang.javascript" | "lang.python" | "lang.rust" | "lang.go" | "lang.java" | "lang.c" | "lang.cpp" | "lang.csharp" | "lang.ruby" | "lang.julia" | "lang.php" | "lang.swift" | "lang.kotlin" | "lang.shell" | "lang.html" | "lang.css" | "lang.json" | "lang.yaml" | "lang.markdown" | "lang.sql" | "lang.docker" | "lang.lua" | "lang.text" | "lang.env" | "lang.toml" | "lang.xml" | "lang.ini" | "lang.conf" | "lang.log" | "lang.csv" | "lang.tsv" | "lang.image" | "lang.pdf" | "lang.archive" | "lang.binary" | "chip.image" | "chip.video" | "chip.paste" | "tab.appearance" | "tab.model" | "tab.interaction" | "tab.context" | "tab.files" | "tab.shell" | "tab.tools" | "tab.memory" | "tab.tasks" | "tab.providers" | "tool.write" | "tool.edit" | "tool.bash" | "tool.ssh" | "tool.lsp" | "tool.gh" | "tool.webSearch" | "tool.exa" | "tool.browser" | "tool.eval" | "tool.debug" | "tool.mcp" | "tool.job" | "tool.launch" | "tool.task" | "tool.todo" | "tool.memory" | "tool.ask" | "tool.resolve" | "tool.review" | "tool.goal" | "tool.irc" | "tool.delete" | "tool.move" | "key.ctrl" | "key.ctrlMac" | "key.shift" | "key.alt" | "key.altMac" | "key.super" | "key.superMac" | "key.joiner" | "key.enter" | "key.esc" | "key.tab" | "key.backspace" | "key.delete" | "key.space" | "key.up" | "key.down" | "key.left" | "key.right";
5
+ export type SymbolKey = "status.success" | "status.error" | "status.warning" | "status.info" | "status.pending" | "status.disabled" | "status.enabled" | "status.running" | "status.shadowed" | "status.aborted"
6
+ /** @deprecated Alias of `status.success`; kept so extensions and theme overrides that name it keep working. */
7
+ | "status.done" | "nav.cursor" | "nav.selected" | "nav.expand" | "nav.collapse" | "nav.back" | "tree.branch" | "tree.last" | "tree.vertical" | "tree.horizontal" | "tree.hook" | "progress.filled" | "progress.empty" | "context.speculation" | "context.compaction" | "context.content" | "context.messages" | "context.buffer" | "context.free" | "boxRound.topLeft" | "boxRound.topRight" | "boxRound.bottomLeft" | "boxRound.bottomRight" | "boxRound.horizontal" | "boxRound.vertical" | "boxDotted.horizontal" | "boxDotted.vertical" | "boxSharp.topLeft" | "boxSharp.topRight" | "boxSharp.bottomLeft" | "boxSharp.bottomRight" | "boxSharp.horizontal" | "boxSharp.vertical" | "boxSharp.cross" | "boxSharp.teeDown" | "boxSharp.teeUp" | "boxSharp.teeRight" | "boxSharp.teeLeft" | "sep.powerline" | "sep.powerlineThin" | "sep.powerlineLeft" | "sep.powerlineRight" | "sep.powerlineThinLeft" | "sep.powerlineThinRight" | "sep.powerlineCapLeft" | "sep.block" | "sep.space" | "sep.asciiLeft" | "sep.asciiRight" | "sep.dot" | "sep.slash" | "sep.pipe" | "icon.model" | "icon.plan" | "icon.prewalk" | "icon.goal" | "icon.pause" | "icon.loop" | "icon.folder" | "icon.worktree" | "icon.search" | "icon.scratchFolder" | "icon.file" | "icon.git" | "icon.branch" | "icon.pr" | "icon.pin" | "icon.tokens" | "icon.context" | "icon.cost" | "icon.subscription" | "icon.advisor" | "icon.advisorClosed" | "icon.time" | "icon.omp" | "icon.ghost" | "icon.agents" | "icon.job" | "icon.cache" | "icon.cacheMiss" | "icon.input" | "icon.output" | "icon.throughput" | "icon.intelligence" | "icon.host" | "icon.session" | "icon.package" | "icon.warning" | "icon.rewind" | "icon.auto" | "icon.fast" | "icon.extensionSkill" | "icon.extensionTool" | "icon.extensionSlashCommand" | "icon.extensionMcp" | "icon.extensionRule" | "icon.extensionHook" | "icon.extensionPrompt" | "icon.extensionContextFile" | "icon.extensionInstruction" | "icon.vimNormal" | "icon.vimInsert" | "icon.vimVisual" | "icon.vimVisualLine" | "icon.vimReplace" | "cmd.action" | "cmd.prompt" | "cmd.extension" | "cmd.settings" | "cmd.gear" | "cmd.shield" | "cmd.wave" | "cmd.compass" | "cmd.inbox" | "cmd.swap" | "cmd.expand" | "cmd.computer" | "cmd.eye" | "cmd.todo" | "cmd.stats" | "cmd.news" | "cmd.keyboard" | "cmd.export" | "cmd.clipboard" | "cmd.share" | "cmd.broadcast" | "cmd.globe" | "cmd.copy" | "cmd.plus" | "cmd.restart" | "cmd.eraser" | "cmd.trash" | "cmd.compress" | "cmd.vibrate" | "cmd.handoff" | "cmd.history" | "cmd.question" | "cmd.rocket" | "cmd.stethoscope" | "cmd.redo" | "cmd.bug" | "cmd.memory" | "cmd.pencil" | "cmd.folderMove" | "cmd.folderPlus" | "cmd.folderMinus" | "cmd.hammer" | "cmd.power" | "cmd.cart" | "icon.mic" | "icon.camera" | "thinking.minimal" | "thinking.low" | "thinking.medium" | "thinking.high" | "thinking.xhigh" | "thinking.max" | "thinking.autoPending" | "checkbox.checked" | "checkbox.unchecked" | "radio.selected" | "radio.unselected" | "format.bullet" | "format.dash" | "format.bracketLeft" | "format.bracketRight" | "md.quoteBorder" | "md.hrChar" | "md.bullet" | "md.colorSwatch" | "advisor.rail" | "skill.rail" | "btw.rail" | "lang.default" | "lang.typescript" | "lang.javascript" | "lang.python" | "lang.rust" | "lang.go" | "lang.java" | "lang.c" | "lang.cpp" | "lang.csharp" | "lang.ruby" | "lang.julia" | "lang.php" | "lang.swift" | "lang.kotlin" | "lang.shell" | "lang.html" | "lang.css" | "lang.json" | "lang.yaml" | "lang.markdown" | "lang.sql" | "lang.docker" | "lang.lua" | "lang.text" | "lang.env" | "lang.toml" | "lang.xml" | "lang.ini" | "lang.conf" | "lang.log" | "lang.csv" | "lang.tsv" | "lang.image" | "lang.pdf" | "lang.archive" | "lang.binary" | "chip.image" | "chip.video" | "chip.paste" | "tab.appearance" | "tab.model" | "tab.interaction" | "tab.context" | "tab.files" | "tab.shell" | "tab.tools" | "tab.memory" | "tab.tasks" | "tab.providers" | "tool.write" | "tool.edit" | "tool.bash" | "tool.ssh" | "tool.lsp" | "tool.gh" | "tool.webSearch" | "tool.exa" | "tool.browser" | "tool.eval" | "tool.debug" | "tool.mcp" | "tool.job" | "tool.launch" | "tool.task" | "tool.todo" | "tool.memory" | "tool.ask" | "tool.resolve" | "tool.review" | "tool.goal" | "tool.irc" | "tool.delete" | "tool.move" | "key.ctrl" | "key.ctrlMac" | "key.shift" | "key.alt" | "key.altMac" | "key.super" | "key.superMac" | "key.joiner" | "key.enter" | "key.esc" | "key.tab" | "key.backspace" | "key.delete" | "key.space" | "key.up" | "key.down" | "key.left" | "key.right";
6
8
  export type SymbolMap = Record<SymbolKey, string>;
7
9
  /**
8
10
  * Icon vocabulary for slash-command autocomplete type indicators. Each name
@@ -19,6 +19,7 @@ export type SymbolKey =
19
19
  | "status.running"
20
20
  | "status.shadowed"
21
21
  | "status.aborted"
22
+ /** @deprecated Alias of `status.success`; kept so extensions and theme overrides that name it keep working. */
22
23
  | "status.done"
23
24
  // Navigation
24
25
  | "nav.cursor"
@@ -212,6 +213,8 @@ export type SymbolKey =
212
213
  | "advisor.rail"
213
214
  // Skill callout rail (user turn that opened with a skill chip)
214
215
  | "skill.rail"
216
+ // /btw steering-prompt rail (the <inject> block a side answer drafted)
217
+ | "btw.rail"
215
218
  // Language/file type icons
216
219
  | "lang.default"
217
220
  | "lang.typescript"
@@ -404,7 +407,7 @@ const UNICODE_SYMBOLS: SymbolMap = {
404
407
  "status.running": "⟳",
405
408
  "status.shadowed": "○",
406
409
  "status.aborted": "⏹",
407
- "status.done": "•",
410
+ "status.done": "✔",
408
411
  // Navigation
409
412
  "nav.cursor": "❯",
410
413
  "nav.selected": "➤",
@@ -598,6 +601,7 @@ const UNICODE_SYMBOLS: SymbolMap = {
598
601
  // Advisor note rail (heavier than md.quoteBorder so notes read as a distinct voice)
599
602
  "advisor.rail": "▎",
600
603
  "skill.rail": "▎",
604
+ "btw.rail": "▎",
601
605
  // Language/file icons (emoji-centric, no Nerd Font required)
602
606
  "lang.default": "⌘",
603
607
  "lang.typescript": "🟦",
@@ -721,8 +725,8 @@ const NERD_SYMBOLS: SymbolMap = {
721
725
  "status.shadowed": "\uf10c",
722
726
  // pick:  | alt:  
723
727
  "status.aborted": "\uf04d",
724
- // pick: • | alt: ● ·
725
- "status.done": "•",
728
+ // alias of status.success
729
+ "status.done": "\uf00c",
726
730
  // Navigation
727
731
  // pick:  | alt:  
728
732
  "nav.cursor": "\uf054",
@@ -1072,6 +1076,7 @@ const NERD_SYMBOLS: SymbolMap = {
1072
1076
  // pick: ▎ | alt: ┃ │
1073
1077
  "advisor.rail": "▎",
1074
1078
  "skill.rail": "▎",
1079
+ "btw.rail": "▎",
1075
1080
  // Language icons (nerd font devicons)
1076
1081
  "lang.default": "",
1077
1082
  "lang.typescript": "\u{E628}",
@@ -1186,17 +1191,17 @@ const NERD_SYMBOLS: SymbolMap = {
1186
1191
 
1187
1192
  const ASCII_SYMBOLS: SymbolMap = {
1188
1193
  // Status Indicators
1189
- "status.success": "[ok]",
1190
- "status.error": "[!!]",
1194
+ "status.success": "[+]",
1195
+ "status.error": "[-]",
1191
1196
  "status.warning": "[!]",
1192
1197
  "status.info": "[i]",
1193
- "status.pending": "[*]",
1198
+ "status.pending": "[ ]",
1194
1199
  "status.disabled": "[ ]",
1195
1200
  "status.enabled": "[x]",
1196
1201
  "status.running": "[~]",
1197
1202
  "status.shadowed": "[/]",
1198
- "status.aborted": "[-]",
1199
- "status.done": "*",
1203
+ "status.aborted": "[#]",
1204
+ "status.done": "[+]",
1200
1205
  // Navigation
1201
1206
  "nav.cursor": ">",
1202
1207
  "nav.selected": "->",
@@ -1386,6 +1391,7 @@ const ASCII_SYMBOLS: SymbolMap = {
1386
1391
  "md.colorSwatch": "[]",
1387
1392
  "advisor.rail": "|",
1388
1393
  "skill.rail": "|",
1394
+ "btw.rail": "|",
1389
1395
  // Language icons (ASCII uses abbreviations)
1390
1396
  "lang.default": "code",
1391
1397
  "lang.typescript": "ts",
@@ -1502,7 +1508,8 @@ export const SPINNER_FRAMES: Record<SymbolPreset, Record<SpinnerType, string[]>>
1502
1508
  activity: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
1503
1509
  },
1504
1510
  ascii: {
1505
- status: ["|", "/", "-", "\\"],
1511
+ // Bracketed like the `status.*` glyphs, so a settling call keeps its column width.
1512
+ status: ["[|]", "[/]", "[-]", "[\\]"],
1506
1513
  activity: ["-", "\\", "|", "/"],
1507
1514
  },
1508
1515
  };
@@ -129,6 +129,7 @@ export declare class Theme {
129
129
  running: string;
130
130
  shadowed: string;
131
131
  aborted: string;
132
+ /** @deprecated Alias of `success`. */
132
133
  done: string;
133
134
  };
134
135
  get nav(): {
@@ -138,6 +138,15 @@ const LANG_BRAND_COLORS: Partial<Record<SymbolKey, string>> = {
138
138
  const BACKGROUND_RESET_PATTERN = /\x1b\[(?:0|49)m/g;
139
139
  const FOREGROUND_RESET_PATTERN = /\x1b\[(?:0|39)m/g;
140
140
 
141
+ /**
142
+ * Color `text` with the foreground `ansi`, restoring it after every nested reset so the rest of `text`
143
+ * keeps it (`fg("dim", `${fg("success", "+2")} more`)`); only the foreground is reset at the end.
144
+ */
145
+ function wrapForeground(ansi: string, text: string): string {
146
+ const body = text.includes("\x1b[") ? text.replace(FOREGROUND_RESET_PATTERN, `$&${ansi}`) : text;
147
+ return `${ansi}${body}\x1b[39m`;
148
+ }
149
+
141
150
  // Prebuilt stylers: each `chalk.<style>` access builds a fresh builder. Builders share the
142
151
  // root chalk context, so later `chalk.level` changes still apply.
143
152
  const boldStyler = chalk.bold;
@@ -234,6 +243,8 @@ export class Theme {
234
243
  logger.debug("Invalid symbol key in override", { key, availableKeys: Object.keys(this.#symbols) });
235
244
  }
236
245
  }
246
+ // `status.done` aliases `status.success` unless a theme overrides it explicitly.
247
+ if (!("status.done" in symbolOverrides)) this.#symbols["status.done"] = this.#symbols["status.success"];
237
248
  this.#spinnerFramesOverrides = spinnerFramesOverrides;
238
249
  }
239
250
 
@@ -350,7 +361,7 @@ export class Theme {
350
361
  fg(color: ThemeColor, text: string): string {
351
362
  const ansi = this.#fgColors[color];
352
363
  if (!ansi) throw new Error(`Unknown theme color: ${color}`);
353
- return `${ansi}${text}\x1b[39m`; // Reset only foreground color
364
+ return wrapForeground(ansi, text);
354
365
  }
355
366
 
356
367
  /** Apply a foreground, replacing terminal-default tokens with the theme's contrast-safe fallback. */
@@ -362,7 +373,7 @@ export class Theme {
362
373
  resolved = ansi === "\x1b[39m" ? colorToAnsi(this.getColorHex(color), this.mode) : ansi;
363
374
  this.#resolvedFgColors.set(color, resolved);
364
375
  }
365
- return `${resolved}${text.replace(FOREGROUND_RESET_PATTERN, `$&${resolved}`)}\x1b[39m`;
376
+ return wrapForeground(resolved, text);
366
377
  }
367
378
 
368
379
  bg(color: ThemeBg, text: string): string {
@@ -390,7 +401,7 @@ export class Theme {
390
401
  */
391
402
  fgOnBg(color: ThemeColor, background: ThemeBg, text: string): string {
392
403
  const ansi = this.getFgOnBgAnsi(color, background);
393
- return `${ansi}${text.replace(FOREGROUND_RESET_PATTERN, `$&${ansi}`)}\x1b[39m`;
404
+ return wrapForeground(ansi, text);
394
405
  }
395
406
 
396
407
  bold(text: string): string {
@@ -519,6 +530,7 @@ export class Theme {
519
530
  running: this.#symbols["status.running"],
520
531
  shadowed: this.#symbols["status.shadowed"],
521
532
  aborted: this.#symbols["status.aborted"],
533
+ /** @deprecated Alias of `success`. */
522
534
  done: this.#symbols["status.done"],
523
535
  };
524
536
  }
@@ -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, setMarkdownMermaidRendering, warmHighlighter, } from "./tui-adapters";
9
+ export { createHighlightStream, getEditorTheme, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getSelectListTheme, getSettingsListTheme, getSymbolTheme, highlightCode, isHighlightLanguage, 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.
@@ -32,6 +32,7 @@ export {
32
32
  getSettingsListTheme,
33
33
  getSymbolTheme,
34
34
  highlightCode,
35
+ isHighlightLanguage,
35
36
  setMarkdownMermaidRendering,
36
37
  warmHighlighter,
37
38
  } from "./tui-adapters";
@@ -6,6 +6,8 @@ import type { SettingsListTheme } from "../components/settings-list";
6
6
  import type { SymbolTheme } from "../symbols";
7
7
  import type { SlashCommandIconName } from "./symbols";
8
8
  import type { Theme } from "./theme-class";
9
+ /** Whether {@link highlightCode} colors `lang`; text in any other language comes back unstyled. */
10
+ export declare function isHighlightLanguage(lang: string | undefined): lang is string;
9
11
  /**
10
12
  * Highlight code with syntax coloring based on file extension or language.
11
13
  * Returns array of highlighted lines.
@@ -96,12 +96,17 @@ function highlightCached(code: string, validLang: string | undefined, highlightT
96
96
  return highlighted;
97
97
  }
98
98
 
99
+ /** Whether {@link highlightCode} colors `lang`; text in any other language comes back unstyled. */
100
+ export function isHighlightLanguage(lang: string | undefined): lang is string {
101
+ return lang !== undefined && nativeSupportsLanguage(lang);
102
+ }
103
+
99
104
  /**
100
105
  * Highlight code with syntax coloring based on file extension or language.
101
106
  * Returns array of highlighted lines.
102
107
  */
103
108
  export function highlightCode(code: string, lang?: string, highlightTheme: Theme = theme): string[] {
104
- const validLang = lang && nativeSupportsLanguage(lang) ? lang : undefined;
109
+ const validLang = isHighlightLanguage(lang) ? lang : undefined;
105
110
  const highlighted = highlightCached(code, validLang, highlightTheme);
106
111
  // Always return a fresh array: callers (e.g. renderCodeCell) push extra lines
107
112
  // onto the result, which would corrupt the cached string otherwise.
@@ -110,7 +115,7 @@ export function highlightCode(code: string, lang?: string, highlightTheme: Theme
110
115
 
111
116
  /** Create a stateful highlighter for progressive terminal rendering. */
112
117
  export function createHighlightStream(lang?: string, highlightTheme: Theme = theme): NativeHighlightStream | null {
113
- const validLang = lang && nativeSupportsLanguage(lang) ? lang : undefined;
118
+ const validLang = isHighlightLanguage(lang) ? lang : undefined;
114
119
  if (!validLang) return null;
115
120
  // Workspace loads skip the natives version sentinel, so a stale local
116
121
  // `.node` can omit `HighlightStream` after a pull. Napi constructors can
@@ -305,7 +310,7 @@ export function getMarkdownTheme(): MarkdownTheme {
305
310
  })
306
311
  : undefined,
307
312
  highlightCode: (code: string, lang?: string): string[] => {
308
- const validLang = lang && nativeSupportsLanguage(lang) ? lang : undefined;
313
+ const validLang = isHighlightLanguage(lang) ? lang : undefined;
309
314
  const highlighted = highlightCached(code, validLang, theme);
310
315
  if (highlighted !== null) return highlighted.split("\n");
311
316
  return code.split("\n").map(line => theme.fg("mdCodeBlock", line));