@agi-fans/dsh-tui 0.21.0 → 0.23.0
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.
- package/LICENSE +26 -0
- package/lib/CHANGELOG.md +356 -1
- package/lib/chrome/box.d.ts +32 -18
- package/lib/chrome/box.js +131 -132
- package/lib/chrome/box.js.map +1 -1
- package/lib/chrome/code-highlight.d.ts +15 -0
- package/lib/chrome/code-highlight.js +61 -5
- package/lib/chrome/code-highlight.js.map +1 -1
- package/lib/chrome/command-output.d.ts +28 -2
- package/lib/chrome/command-output.js +106 -4
- package/lib/chrome/command-output.js.map +1 -1
- package/lib/chrome/goal-bar.js +1 -1
- package/lib/chrome/goal-bar.js.map +1 -1
- package/lib/chrome/main-screen-renderer.d.ts +16 -0
- package/lib/chrome/main-screen-renderer.js +57 -8
- package/lib/chrome/main-screen-renderer.js.map +1 -1
- package/lib/chrome/markdown.d.ts +3 -3
- package/lib/chrome/markdown.js +101 -32
- package/lib/chrome/markdown.js.map +1 -1
- package/lib/chrome/md-style.d.ts +5 -2
- package/lib/chrome/md-style.js +13 -4
- package/lib/chrome/md-style.js.map +1 -1
- package/lib/chrome/relative-time.d.ts +17 -0
- package/lib/chrome/relative-time.js +36 -0
- package/lib/chrome/relative-time.js.map +1 -1
- package/lib/chrome/renderer.d.ts +37 -1
- package/lib/chrome/renderer.js.map +1 -1
- package/lib/chrome/secret-mask.d.ts +35 -0
- package/lib/chrome/secret-mask.js +180 -0
- package/lib/chrome/secret-mask.js.map +1 -0
- package/lib/chrome/status-config.d.ts +161 -51
- package/lib/chrome/status-config.js +237 -126
- package/lib/chrome/status-config.js.map +1 -1
- package/lib/chrome/status-line.d.ts +6 -5
- package/lib/chrome/status-line.js +110 -68
- package/lib/chrome/status-line.js.map +1 -1
- package/lib/chrome/terminal-colors.d.ts +85 -0
- package/lib/chrome/terminal-colors.js +230 -0
- package/lib/chrome/terminal-colors.js.map +1 -0
- package/lib/chrome/terminal-images.d.ts +9 -1
- package/lib/chrome/terminal-images.js +27 -4
- package/lib/chrome/terminal-images.js.map +1 -1
- package/lib/chrome/theme.d.ts +38 -10
- package/lib/chrome/theme.js +537 -542
- package/lib/chrome/theme.js.map +1 -1
- package/lib/chrome/tool-renderers.js +69 -13
- package/lib/chrome/tool-renderers.js.map +1 -1
- package/lib/chrome/tools-list.d.ts +1 -4
- package/lib/chrome/tools-list.js +1 -41
- package/lib/chrome/tools-list.js.map +1 -1
- package/lib/commands/auth-account.d.ts +9 -0
- package/lib/commands/auth-account.js +202 -0
- package/lib/commands/auth-account.js.map +1 -0
- package/lib/commands/auth-ids.d.ts +25 -0
- package/lib/commands/auth-ids.js +27 -0
- package/lib/commands/auth-ids.js.map +1 -0
- package/lib/commands/auth-input.d.ts +34 -0
- package/lib/commands/auth-input.js +96 -0
- package/lib/commands/auth-input.js.map +1 -0
- package/lib/commands/auth-providers.d.ts +39 -0
- package/lib/commands/auth-providers.js +125 -0
- package/lib/commands/auth-providers.js.map +1 -0
- package/lib/commands/auth.d.ts +12 -20
- package/lib/commands/auth.js +264 -627
- package/lib/commands/auth.js.map +1 -1
- package/lib/commands/btw.d.ts +13 -1
- package/lib/commands/btw.js +37 -104
- package/lib/commands/btw.js.map +1 -1
- package/lib/commands/diff.js +23 -112
- package/lib/commands/diff.js.map +1 -1
- package/lib/commands/export.d.ts +0 -1
- package/lib/commands/export.js +98 -57
- package/lib/commands/export.js.map +1 -1
- package/lib/commands/files.d.ts +17 -1
- package/lib/commands/files.js +68 -114
- package/lib/commands/files.js.map +1 -1
- package/lib/commands/integrations.d.ts +12 -1
- package/lib/commands/integrations.js +120 -23
- package/lib/commands/integrations.js.map +1 -1
- package/lib/commands/jobs-browser.d.ts +3 -0
- package/lib/commands/jobs-browser.js +152 -0
- package/lib/commands/jobs-browser.js.map +1 -0
- package/lib/commands/jobs.d.ts +12 -8
- package/lib/commands/jobs.js +65 -14
- package/lib/commands/jobs.js.map +1 -1
- package/lib/commands/model.d.ts +3 -0
- package/lib/commands/model.js +223 -114
- package/lib/commands/model.js.map +1 -1
- package/lib/commands/open-external.d.ts +2 -0
- package/lib/commands/open-external.js +19 -0
- package/lib/commands/open-external.js.map +1 -0
- package/lib/commands/permission.js +70 -60
- package/lib/commands/permission.js.map +1 -1
- package/lib/commands/plugins.js +427 -68
- package/lib/commands/plugins.js.map +1 -1
- package/lib/commands/schedule-catalog.d.ts +12 -0
- package/lib/commands/schedule-catalog.js +41 -0
- package/lib/commands/schedule-catalog.js.map +1 -0
- package/lib/commands/schedule-history.d.ts +4 -0
- package/lib/commands/schedule-history.js +62 -0
- package/lib/commands/schedule-history.js.map +1 -0
- package/lib/commands/schedule.d.ts +16 -9
- package/lib/commands/schedule.js +226 -162
- package/lib/commands/schedule.js.map +1 -1
- package/lib/commands/session-configuration.d.ts +3 -0
- package/lib/commands/session-configuration.js +58 -32
- package/lib/commands/session-configuration.js.map +1 -1
- package/lib/commands/session.js +118 -97
- package/lib/commands/session.js.map +1 -1
- package/lib/commands/terminal.d.ts +14 -8
- package/lib/commands/terminal.js +32 -185
- package/lib/commands/terminal.js.map +1 -1
- package/lib/commands/trajectory.js +4 -1
- package/lib/commands/trajectory.js.map +1 -1
- package/lib/definition.d.ts +226 -29
- package/lib/definition.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/input/actions.d.ts +51 -0
- package/lib/input/actions.js +123 -0
- package/lib/input/actions.js.map +1 -0
- package/lib/input/composer-files.d.ts +2 -0
- package/lib/input/composer-files.js +13 -3
- package/lib/input/composer-files.js.map +1 -1
- package/lib/input/editor.d.ts +0 -10
- package/lib/input/editor.js +11 -9
- package/lib/input/editor.js.map +1 -1
- package/lib/input/image-paste.d.ts +12 -1
- package/lib/input/image-paste.js +86 -1
- package/lib/input/image-paste.js.map +1 -1
- package/lib/input/key-test.d.ts +5 -0
- package/lib/input/key-test.js +19 -0
- package/lib/input/key-test.js.map +1 -0
- package/lib/input/keybindings-config.d.ts +12 -5
- package/lib/input/keybindings-config.js +30 -57
- package/lib/input/keybindings-config.js.map +1 -1
- package/lib/input/keys.d.ts +18 -0
- package/lib/input/keys.js +42 -4
- package/lib/input/keys.js.map +1 -1
- package/lib/input/wheel-scroll.d.ts +46 -0
- package/lib/input/wheel-scroll.js +69 -0
- package/lib/input/wheel-scroll.js.map +1 -0
- package/lib/locale/index.d.ts +6 -0
- package/lib/locale/index.js +32 -0
- package/lib/locale/index.js.map +1 -0
- package/lib/locale/prompt.d.ts +4 -0
- package/lib/locale/prompt.js +24 -0
- package/lib/locale/prompt.js.map +1 -0
- package/lib/locale/zh.d.ts +1114 -0
- package/lib/locale/zh.js +1115 -0
- package/lib/locale/zh.js.map +1 -0
- package/lib/prompt-intents.d.ts +186 -0
- package/lib/prompt-intents.js +131 -0
- package/lib/prompt-intents.js.map +1 -0
- package/lib/runtime/account-settings.d.ts +18 -0
- package/lib/runtime/account-settings.js +241 -0
- package/lib/runtime/account-settings.js.map +1 -0
- package/lib/runtime/agent-profile.d.ts +3 -3
- package/lib/runtime/agent-profile.js +4 -4
- package/lib/runtime/agent-profile.js.map +1 -1
- package/lib/runtime/btw-policy.js +2 -1
- package/lib/runtime/btw-policy.js.map +1 -1
- package/lib/runtime/btw.js +1 -2
- package/lib/runtime/btw.js.map +1 -1
- package/lib/runtime/cancellable.d.ts +75 -0
- package/lib/runtime/cancellable.js +76 -0
- package/lib/runtime/cancellable.js.map +1 -0
- package/lib/runtime/composer-images.d.ts +2 -2
- package/lib/runtime/composer-images.js +7 -6
- package/lib/runtime/composer-images.js.map +1 -1
- package/lib/runtime/composer-shell.d.ts +17 -2
- package/lib/runtime/composer-shell.js +133 -41
- package/lib/runtime/composer-shell.js.map +1 -1
- package/lib/runtime/file-browser.d.ts +19 -0
- package/lib/runtime/file-browser.js +291 -0
- package/lib/runtime/file-browser.js.map +1 -0
- package/lib/runtime/file-recovery-review.d.ts +0 -1
- package/lib/runtime/file-recovery-review.js +29 -30
- package/lib/runtime/file-recovery-review.js.map +1 -1
- package/lib/runtime/file-recovery-store.js +5 -1
- package/lib/runtime/file-recovery-store.js.map +1 -1
- package/lib/runtime/file-review.d.ts +6 -9
- package/lib/runtime/file-review.js +92 -8
- package/lib/runtime/file-review.js.map +1 -1
- package/lib/runtime/help-reader.d.ts +12 -0
- package/lib/runtime/help-reader.js +50 -0
- package/lib/runtime/help-reader.js.map +1 -0
- package/lib/runtime/hook-settings.d.ts +2 -2
- package/lib/runtime/human-interaction.js +1 -1
- package/lib/runtime/human-interaction.js.map +1 -1
- package/lib/runtime/model-catalog-editor.d.ts +12 -0
- package/lib/runtime/model-catalog-editor.js +215 -0
- package/lib/runtime/model-catalog-editor.js.map +1 -0
- package/lib/runtime/model-settings.d.ts +11 -0
- package/lib/runtime/model-settings.js +404 -0
- package/lib/runtime/model-settings.js.map +1 -0
- package/lib/runtime/plain-tui.d.ts +2 -0
- package/lib/runtime/plain-tui.js +7 -1
- package/lib/runtime/plain-tui.js.map +1 -1
- package/lib/runtime/plugin-settings.d.ts +4 -1
- package/lib/runtime/plugin-settings.js +170 -92
- package/lib/runtime/plugin-settings.js.map +1 -1
- package/lib/runtime/prompt-browser.d.ts +9 -0
- package/lib/runtime/prompt-browser.js +19 -0
- package/lib/runtime/prompt-browser.js.map +1 -0
- package/lib/runtime/provider-local.d.ts +80 -38
- package/lib/runtime/provider-local.js +2280 -683
- package/lib/runtime/provider-local.js.map +1 -1
- package/lib/runtime/reference-reader.d.ts +15 -0
- package/lib/runtime/reference-reader.js +78 -0
- package/lib/runtime/reference-reader.js.map +1 -0
- package/lib/runtime/runner.js +42 -39
- package/lib/runtime/runner.js.map +1 -1
- package/lib/runtime/session-runtime.js +1 -1
- package/lib/runtime/session-runtime.js.map +1 -1
- package/lib/runtime/settings-draft.d.ts +21 -0
- package/lib/runtime/settings-draft.js +166 -0
- package/lib/runtime/settings-draft.js.map +1 -0
- package/lib/runtime/settings-preferences.js +1 -1
- package/lib/runtime/settings-preferences.js.map +1 -1
- package/lib/runtime/startup-notices.d.ts +0 -1
- package/lib/runtime/startup-notices.js +35 -4
- package/lib/runtime/startup-notices.js.map +1 -1
- package/lib/runtime/subagent-model-selection.js +2 -1
- package/lib/runtime/subagent-model-selection.js.map +1 -1
- package/lib/runtime/subagent-settings.d.ts +14 -0
- package/lib/runtime/subagent-settings.js +288 -0
- package/lib/runtime/subagent-settings.js.map +1 -0
- package/lib/runtime/terminal-modes.d.ts +47 -0
- package/lib/runtime/terminal-modes.js +86 -0
- package/lib/runtime/terminal-modes.js.map +1 -0
- package/lib/runtime/terminal-notifications.d.ts +6 -5
- package/lib/runtime/terminal-notifications.js +17 -16
- package/lib/runtime/terminal-notifications.js.map +1 -1
- package/lib/runtime/terminal-probe.d.ts +38 -0
- package/lib/runtime/terminal-probe.js +46 -0
- package/lib/runtime/terminal-probe.js.map +1 -0
- package/lib/runtime/terminal-session.d.ts +57 -0
- package/lib/runtime/terminal-session.js +164 -0
- package/lib/runtime/terminal-session.js.map +1 -0
- package/lib/runtime/tool-presentation.js.map +1 -1
- package/lib/runtime/tool-reader.d.ts +5 -0
- package/lib/runtime/tool-reader.js +27 -0
- package/lib/runtime/tool-reader.js.map +1 -0
- package/lib/runtime/web-settings.d.ts +14 -0
- package/lib/runtime/web-settings.js +339 -0
- package/lib/runtime/web-settings.js.map +1 -0
- package/lib/session/command-attachments.d.ts +17 -0
- package/lib/session/command-attachments.js +50 -0
- package/lib/session/command-attachments.js.map +1 -0
- package/lib/session/context-diagnostics.d.ts +16 -0
- package/lib/session/context-diagnostics.js +15 -0
- package/lib/session/context-diagnostics.js.map +1 -1
- package/lib/session/external-agents.d.ts +3 -1
- package/lib/session/external-agents.js +35 -10
- package/lib/session/external-agents.js.map +1 -1
- package/lib/session/generation-continuation.d.ts +11 -0
- package/lib/session/generation-continuation.js +34 -0
- package/lib/session/generation-continuation.js.map +1 -0
- package/lib/session/goal-controls.d.ts +5 -0
- package/lib/session/goal-controls.js +81 -0
- package/lib/session/goal-controls.js.map +1 -0
- package/lib/session/interaction-adapter.d.ts +7 -3
- package/lib/session/interaction-adapter.js +125 -54
- package/lib/session/interaction-adapter.js.map +1 -1
- package/lib/session/message-queue.d.ts +2 -0
- package/lib/session/message-queue.js +102 -17
- package/lib/session/message-queue.js.map +1 -1
- package/lib/session/package-metadata.d.ts +8 -0
- package/lib/session/package-metadata.js +8 -0
- package/lib/session/package-metadata.js.map +1 -1
- package/lib/session/pending-inputs.d.ts +30 -0
- package/lib/session/pending-inputs.js +183 -0
- package/lib/session/pending-inputs.js.map +1 -0
- package/lib/session/session-configuration.js +1 -1
- package/lib/session/session-configuration.js.map +1 -1
- package/lib/session/session-controller.d.ts +42 -24
- package/lib/session/session-controller.js +534 -106
- package/lib/session/session-controller.js.map +1 -1
- package/lib/session/session-tree.d.ts +2 -0
- package/lib/session/session-tree.js +2 -0
- package/lib/session/session-tree.js.map +1 -1
- package/lib/session/subagent-roster.d.ts +1 -0
- package/lib/session/subagent-roster.js +16 -5
- package/lib/session/subagent-roster.js.map +1 -1
- package/lib/session/subagent-tracker.d.ts +2 -0
- package/lib/session/subagent-tracker.js +18 -0
- package/lib/session/subagent-tracker.js.map +1 -1
- package/lib/session/tui-settings.d.ts +48 -15
- package/lib/session/tui-settings.js +75 -34
- package/lib/session/tui-settings.js.map +1 -1
- package/lib/session/workflow-projection.d.ts +2 -1
- package/lib/session/workflow-projection.js +34 -4
- package/lib/session/workflow-projection.js.map +1 -1
- package/lib/views/autocomplete.d.ts +28 -9
- package/lib/views/autocomplete.js +90 -70
- package/lib/views/autocomplete.js.map +1 -1
- package/lib/views/context-overview.d.ts +4 -0
- package/lib/views/context-overview.js +43 -0
- package/lib/views/context-overview.js.map +1 -0
- package/lib/views/copy-targets.d.ts +18 -15
- package/lib/views/copy-targets.js +35 -60
- package/lib/views/copy-targets.js.map +1 -1
- package/lib/views/document-reader.d.ts +10 -1
- package/lib/views/document-reader.js +76 -9
- package/lib/views/document-reader.js.map +1 -1
- package/lib/views/event-views.js +71 -17
- package/lib/views/event-views.js.map +1 -1
- package/lib/views/file-actions.js +21 -0
- package/lib/views/file-actions.js.map +1 -1
- package/lib/views/file-browser.d.ts +98 -0
- package/lib/views/file-browser.js +120 -0
- package/lib/views/file-browser.js.map +1 -0
- package/lib/views/history-search.js +19 -25
- package/lib/views/history-search.js.map +1 -1
- package/lib/views/hotkey-format.d.ts +3 -2
- package/lib/views/hotkey-format.js +4 -3
- package/lib/views/hotkey-format.js.map +1 -1
- package/lib/views/hotkeys.d.ts +7 -1
- package/lib/views/hotkeys.js +59 -37
- package/lib/views/hotkeys.js.map +1 -1
- package/lib/views/list-navigation.d.ts +62 -0
- package/lib/views/list-navigation.js +73 -0
- package/lib/views/list-navigation.js.map +1 -0
- package/lib/views/list-view.d.ts +99 -0
- package/lib/views/list-view.js +170 -0
- package/lib/views/list-view.js.map +1 -0
- package/lib/views/prompt-selector.d.ts +54 -4
- package/lib/views/prompt-selector.js +349 -162
- package/lib/views/prompt-selector.js.map +1 -1
- package/lib/views/session-files.d.ts +1 -2
- package/lib/views/session-files.js +1 -11
- package/lib/views/session-files.js.map +1 -1
- package/lib/views/settings-list.d.ts +16 -9
- package/lib/views/settings-list.js +171 -315
- package/lib/views/settings-list.js.map +1 -1
- package/lib/views/tool-actions.d.ts +16 -0
- package/lib/views/tool-actions.js +29 -0
- package/lib/views/tool-actions.js.map +1 -0
- package/lib/views/trajectory-timeline.d.ts +71 -0
- package/lib/views/trajectory-timeline.js +143 -0
- package/lib/views/trajectory-timeline.js.map +1 -0
- package/lib/views/trajectory.d.ts +36 -4
- package/lib/views/trajectory.js +842 -190
- package/lib/views/trajectory.js.map +1 -1
- package/lib/views/transcript-render.d.ts +132 -38
- package/lib/views/transcript-render.js +792 -260
- package/lib/views/transcript-render.js.map +1 -1
- package/lib/views/transcript-search.d.ts +39 -6
- package/lib/views/transcript-search.js +46 -11
- package/lib/views/transcript-search.js.map +1 -1
- package/lib/views/transcript-types.d.ts +64 -5
- package/lib/views/transcript-types.js +23 -11
- package/lib/views/transcript-types.js.map +1 -1
- package/lib/views/workflow.d.ts +16 -0
- package/lib/views/workflow.js +42 -0
- package/lib/views/workflow.js.map +1 -0
- package/package.json +74 -90
- package/lib/chrome/welcome-tips.d.ts +0 -11
- package/lib/chrome/welcome-tips.js +0 -44
- package/lib/chrome/welcome-tips.js.map +0 -1
- package/lib/commands/advisor.d.ts +0 -15
- package/lib/commands/advisor.js +0 -200
- package/lib/commands/advisor.js.map +0 -1
- package/lib/commands/loop.d.ts +0 -52
- package/lib/commands/loop.js +0 -307
- package/lib/commands/loop.js.map +0 -1
- package/lib/commands/rate.d.ts +0 -33
- package/lib/commands/rate.js +0 -212
- package/lib/commands/rate.js.map +0 -1
- package/lib/commands/steer.d.ts +0 -5
- package/lib/commands/steer.js +0 -24
- package/lib/commands/steer.js.map +0 -1
- package/lib/commands/worktree.d.ts +0 -5
- package/lib/commands/worktree.js +0 -103
- package/lib/commands/worktree.js.map +0 -1
- package/lib/runtime/terminal-reader.d.ts +0 -11
- package/lib/runtime/terminal-reader.js +0 -87
- package/lib/runtime/terminal-reader.js.map +0 -1
- package/lib/session/steering.d.ts +0 -3
- package/lib/session/steering.js +0 -9
- package/lib/session/steering.js.map +0 -1
- package/lib/views/agent-hub.d.ts +0 -32
- package/lib/views/agent-hub.js +0 -209
- package/lib/views/agent-hub.js.map +0 -1
- package/lib/views/copy-selector.d.ts +0 -54
- package/lib/views/copy-selector.js +0 -170
- package/lib/views/copy-selector.js.map +0 -1
package/lib/chrome/theme.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* glyphs used by terminal views.
|
|
4
4
|
* @module @agi-fans/dsh-tui
|
|
5
5
|
*/
|
|
6
|
+
import { uiText } from "../locale/index.js";
|
|
7
|
+
import { contrastRatio, labDistance, nearestPaletteIndex, nearestXterm256, nearestXterm256Grey, relativeLuminance, toOklab, terminalColorsKey, } from "./terminal-colors.js";
|
|
6
8
|
/** Rounded-box drawing characters (OMP unicode preset). */
|
|
7
9
|
export const BOX = {
|
|
8
10
|
topLeft: '╭',
|
|
@@ -49,396 +51,48 @@ export const SYMBOL = {
|
|
|
49
51
|
};
|
|
50
52
|
/** Braille activity spinner (OMP unicode activity frames). */
|
|
51
53
|
export const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
52
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Adapted from Catppuccin Mocha/Latte (MIT; see the package LICENSE).
|
|
56
|
+
* Blue identifies interaction. Neutral headings and readable secondary ink keep
|
|
57
|
+
* prose calm; syntax colors are reserved for code. The terminal owns body ink.
|
|
58
|
+
*/
|
|
53
59
|
const DARK_PALETTE = {
|
|
54
|
-
accent: '#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
toolSuccessBg: '#141b26',
|
|
68
|
-
toolErrorBg: '#291d1d',
|
|
69
|
-
toolTitle: '#e0e0e0',
|
|
70
|
-
toolOutput: '#858a94',
|
|
71
|
-
toolDiffAdded: '#89d281',
|
|
72
|
-
toolDiffRemoved: '#fc4353',
|
|
73
|
-
toolDiffContext: '#838a98',
|
|
74
|
-
mdHeading: '#7c93ff',
|
|
75
|
-
mdLink: '#7c93ff',
|
|
76
|
-
mdLinkUrl: '#7186bd',
|
|
77
|
-
mdCode: '#8a9099',
|
|
78
|
-
mdCodeBlock: '#9cdcfe',
|
|
79
|
-
mdCodeBlockBorder: '#3d424a',
|
|
80
|
-
mdKeyword: '#569cd6',
|
|
81
|
-
syntaxString: '#ce9178',
|
|
82
|
-
syntaxNumber: '#b5cea8',
|
|
83
|
-
syntaxFunction: '#dcdcaa',
|
|
84
|
-
syntaxType: '#4ec9b0',
|
|
85
|
-
mdQuote: '#777d88',
|
|
86
|
-
mdListBullet: '#7c93ff',
|
|
87
|
-
thinkingText: '#6b7280',
|
|
88
|
-
customMessageLabel: '#b281d6',
|
|
60
|
+
accent: '#89b4fa', border: '#454e70', borderAccent: '#4d6bfe', borderMuted: '#45475a',
|
|
61
|
+
success: '#a6e3a1', error: '#f38ba8', warning: '#f9e2af',
|
|
62
|
+
muted: '#bac2de', dim: '#9399b2', text: '',
|
|
63
|
+
userMessageText: '#cdd6f4', userMessageBg: '#20283f',
|
|
64
|
+
toolPendingBg: '#313244', toolSuccessBg: '#293b35', toolAltBg: '#272938', toolErrorBg: '#462d39',
|
|
65
|
+
toolTitle: '#cdd6f4', toolOutput: '#bac2de',
|
|
66
|
+
toolDiffAdded: '#a6e3a1', toolDiffRemoved: '#f38ba8', toolDiffContext: '#bac2de',
|
|
67
|
+
mdHeading: '#cdd6f4', mdLink: '#89b4fa', mdLinkUrl: '#9399b2', mdCode: '#cba6f7',
|
|
68
|
+
mdCodeBlock: '#cdd6f4', mdCodeBlockBorder: '#585b70', mdKeyword: '#cba6f7',
|
|
69
|
+
syntaxString: '#a6e3a1', syntaxNumber: '#fab387', syntaxFunction: '#89dceb', syntaxType: '#f9e2af',
|
|
70
|
+
syntaxComment: '#a6adc8', syntaxPunctuation: '#bac2de',
|
|
71
|
+
mdQuote: '#bac2de', mdQuoteBorder: '#585b70', mdHr: '#45475a', mdListBullet: '#9399b2',
|
|
72
|
+
shellMode: '#a6e3a1', thinkingText: '#a6adc8', customMessageLabel: '#cba6f7',
|
|
89
73
|
};
|
|
90
|
-
/**
|
|
74
|
+
/** Latte neutrals with darker semantic inks for small terminal text. */
|
|
91
75
|
const LIGHT_PALETTE = {
|
|
92
|
-
accent: '#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
toolSuccessBg: '#e8f0e8',
|
|
106
|
-
toolErrorBg: '#f0e8e8',
|
|
107
|
-
toolTitle: '#242424',
|
|
108
|
-
toolOutput: '#666666',
|
|
109
|
-
toolDiffAdded: '#4a6f4a',
|
|
110
|
-
toolDiffRemoved: '#9f4f4f',
|
|
111
|
-
toolDiffContext: '#666666',
|
|
112
|
-
mdHeading: '#3b57e0',
|
|
113
|
-
mdLink: '#3b57e0',
|
|
114
|
-
mdLinkUrl: '#5b6f9e',
|
|
115
|
-
mdCode: '#567b7b',
|
|
116
|
-
mdCodeBlock: '#567b7b',
|
|
117
|
-
mdCodeBlockBorder: '#6c6c6c',
|
|
118
|
-
mdKeyword: '#0451a5',
|
|
119
|
-
syntaxString: '#a31515',
|
|
120
|
-
syntaxNumber: '#098558',
|
|
121
|
-
syntaxFunction: '#795e26',
|
|
122
|
-
syntaxType: '#267e97',
|
|
123
|
-
mdQuote: '#6c6c6c',
|
|
124
|
-
mdListBullet: '#3b57e0',
|
|
125
|
-
thinkingText: '#6c6c6c',
|
|
126
|
-
customMessageLabel: '#7e57c2',
|
|
127
|
-
};
|
|
128
|
-
const MIDNIGHT_PALETTE = {
|
|
129
|
-
...DARK_PALETTE,
|
|
130
|
-
accent: '#7aa2f7',
|
|
131
|
-
border: '#3d59a1',
|
|
132
|
-
borderAccent: '#7dcfff',
|
|
133
|
-
borderMuted: '#3d424a',
|
|
134
|
-
success: '#9ece6a',
|
|
135
|
-
error: '#f7768e',
|
|
136
|
-
warning: '#e0af68',
|
|
137
|
-
muted: '#878d96',
|
|
138
|
-
dim: '#686f7e',
|
|
139
|
-
text: '',
|
|
140
|
-
userMessageBg: '#1a1b26',
|
|
141
|
-
toolPendingBg: '#16161e',
|
|
142
|
-
toolSuccessBg: '#1b2430',
|
|
143
|
-
toolErrorBg: '#2a1b26',
|
|
144
|
-
toolOutput: '#878d96',
|
|
145
|
-
toolDiffAdded: '#9ece6a',
|
|
146
|
-
toolDiffRemoved: '#f7768e',
|
|
147
|
-
toolDiffContext: '#858d9a',
|
|
148
|
-
mdHeading: '#bb9af7',
|
|
149
|
-
mdLink: '#7dcfff',
|
|
150
|
-
mdLinkUrl: '#626a77',
|
|
151
|
-
mdCode: '#7f8799',
|
|
152
|
-
mdCodeBlock: '#9aa5ce',
|
|
153
|
-
mdCodeBlockBorder: '#3d424a',
|
|
154
|
-
mdKeyword: '#bb9af7',
|
|
155
|
-
syntaxString: '#9ece6a',
|
|
156
|
-
syntaxNumber: '#ff9e64',
|
|
157
|
-
syntaxFunction: '#7aa2f7',
|
|
158
|
-
syntaxType: '#2ac3de',
|
|
159
|
-
mdQuote: '#777d88',
|
|
160
|
-
mdListBullet: '#7aa2f7',
|
|
161
|
-
thinkingText: '#6a7394',
|
|
162
|
-
customMessageLabel: '#bb9af7',
|
|
163
|
-
userMessageText: '#c0caf5',
|
|
164
|
-
toolTitle: '#c0caf5',
|
|
165
|
-
};
|
|
166
|
-
const SOLARIZED_PALETTE = {
|
|
167
|
-
...DARK_PALETTE,
|
|
168
|
-
accent: '#c39400',
|
|
169
|
-
border: '#268bd2',
|
|
170
|
-
borderAccent: '#2aa198',
|
|
171
|
-
borderMuted: '#586e75',
|
|
172
|
-
success: '#859900',
|
|
173
|
-
error: '#e87b79',
|
|
174
|
-
warning: '#cb4b16',
|
|
175
|
-
muted: '#8e9e9f',
|
|
176
|
-
dim: '#668088',
|
|
177
|
-
text: '',
|
|
178
|
-
userMessageBg: '#073642',
|
|
179
|
-
toolPendingBg: '#002b36',
|
|
180
|
-
toolSuccessBg: '#073642',
|
|
181
|
-
toolErrorBg: '#3b2020',
|
|
182
|
-
toolOutput: '#8e9e9f',
|
|
183
|
-
toolDiffAdded: '#8fa500',
|
|
184
|
-
toolDiffRemoved: '#e87b79',
|
|
185
|
-
toolDiffContext: '#889fa6',
|
|
186
|
-
mdHeading: '#b58900',
|
|
187
|
-
mdLink: '#3496da',
|
|
188
|
-
mdLinkUrl: '#5e767d',
|
|
189
|
-
mdCode: '#93a1a1',
|
|
190
|
-
mdCodeBlock: '#2aa198',
|
|
191
|
-
mdCodeBlockBorder: '#073642',
|
|
192
|
-
mdKeyword: '#859900',
|
|
193
|
-
syntaxString: '#2aa198',
|
|
194
|
-
syntaxNumber: '#de66a0',
|
|
195
|
-
syntaxFunction: '#3496da',
|
|
196
|
-
syntaxType: '#b58900',
|
|
197
|
-
mdQuote: '#839496',
|
|
198
|
-
mdListBullet: '#b58900',
|
|
199
|
-
thinkingText: '#5e767d',
|
|
200
|
-
customMessageLabel: '#6c71c4',
|
|
201
|
-
userMessageText: '#93a1a1',
|
|
202
|
-
toolTitle: '#93a1a1',
|
|
203
|
-
};
|
|
204
|
-
const CATPPUCCIN_PALETTE = {
|
|
205
|
-
...DARK_PALETTE,
|
|
206
|
-
accent: '#fab387',
|
|
207
|
-
border: '#89b4fa',
|
|
208
|
-
borderAccent: '#b4befe',
|
|
209
|
-
borderMuted: '#313244',
|
|
210
|
-
success: '#a6e3a1',
|
|
211
|
-
error: '#f38ba8',
|
|
212
|
-
warning: '#f9e2af',
|
|
213
|
-
muted: '#989db0',
|
|
214
|
-
dim: '#7a7d93',
|
|
215
|
-
text: '',
|
|
216
|
-
userMessageBg: '#181825',
|
|
217
|
-
toolPendingBg: '#313244',
|
|
218
|
-
toolSuccessBg: '#181825',
|
|
219
|
-
toolErrorBg: '#11111b',
|
|
220
|
-
toolTitle: '#b4befe',
|
|
221
|
-
toolOutput: '#989db0',
|
|
222
|
-
toolDiffAdded: '#a6e3a1',
|
|
223
|
-
toolDiffRemoved: '#f38ba8',
|
|
224
|
-
toolDiffContext: '#989db0',
|
|
225
|
-
mdHeading: '#fab387',
|
|
226
|
-
mdLink: '#89b4fa',
|
|
227
|
-
mdLinkUrl: '#6c7086',
|
|
228
|
-
mdCode: '#a6adc8',
|
|
229
|
-
mdCodeBlock: '#cdd6f4',
|
|
230
|
-
mdCodeBlockBorder: '#313244',
|
|
231
|
-
mdKeyword: '#cba6f7',
|
|
232
|
-
syntaxString: '#a6e3a1',
|
|
233
|
-
syntaxNumber: '#fab387',
|
|
234
|
-
syntaxFunction: '#89b4fa',
|
|
235
|
-
syntaxType: '#f9e2af',
|
|
236
|
-
mdQuote: '#7f849c',
|
|
237
|
-
mdListBullet: '#fab387',
|
|
238
|
-
thinkingText: '#6c7086',
|
|
239
|
-
customMessageLabel: '#cba6f7',
|
|
240
|
-
userMessageText: '#cdd6f4',
|
|
241
|
-
};
|
|
242
|
-
const DRACULA_PALETTE = {
|
|
243
|
-
...DARK_PALETTE,
|
|
244
|
-
accent: '#bd93f9',
|
|
245
|
-
border: '#bd93f9',
|
|
246
|
-
borderAccent: '#ff79c6',
|
|
247
|
-
borderMuted: '#44475a',
|
|
248
|
-
success: '#50fa7b',
|
|
249
|
-
error: '#ff5a5a',
|
|
250
|
-
warning: '#f1fa8c',
|
|
251
|
-
muted: '#8693b9',
|
|
252
|
-
dim: '#6f7492',
|
|
253
|
-
text: '',
|
|
254
|
-
userMessageBg: '#1f2029',
|
|
255
|
-
toolPendingBg: '#21222c',
|
|
256
|
-
toolSuccessBg: '#1a1f1e',
|
|
257
|
-
toolErrorBg: '#2a2028',
|
|
258
|
-
toolTitle: '#8be9fd',
|
|
259
|
-
toolOutput: '#8693b9',
|
|
260
|
-
toolDiffAdded: '#50fa7b',
|
|
261
|
-
toolDiffRemoved: '#ff5a5a',
|
|
262
|
-
toolDiffContext: '#8693b9',
|
|
263
|
-
mdHeading: '#bd93f9',
|
|
264
|
-
mdLink: '#8be9fd',
|
|
265
|
-
mdLinkUrl: '#6474a5',
|
|
266
|
-
mdCode: '#9aa3c7',
|
|
267
|
-
mdCodeBlock: '#f8f8f2',
|
|
268
|
-
mdCodeBlockBorder: '#44475a',
|
|
269
|
-
mdKeyword: '#ff79c6',
|
|
270
|
-
syntaxString: '#f1fa8c',
|
|
271
|
-
syntaxNumber: '#bd93f9',
|
|
272
|
-
syntaxFunction: '#50fa7b',
|
|
273
|
-
syntaxType: '#8be9fd',
|
|
274
|
-
mdQuote: '#6474a5',
|
|
275
|
-
mdListBullet: '#ff79c6',
|
|
276
|
-
thinkingText: '#6474a5',
|
|
277
|
-
customMessageLabel: '#bd93f9',
|
|
278
|
-
userMessageText: '#f8f8f2',
|
|
279
|
-
};
|
|
280
|
-
const NORD_PALETTE = {
|
|
281
|
-
...DARK_PALETTE,
|
|
282
|
-
accent: '#88c0d0',
|
|
283
|
-
border: '#5e81ac',
|
|
284
|
-
borderAccent: '#88c0d0',
|
|
285
|
-
borderMuted: '#434c5e',
|
|
286
|
-
success: '#a3be8c',
|
|
287
|
-
error: '#daa2a8',
|
|
288
|
-
warning: '#ebcb8b',
|
|
289
|
-
muted: '#a8b1c1',
|
|
290
|
-
dim: '#8490a7',
|
|
291
|
-
text: '',
|
|
292
|
-
userMessageBg: '#3b4252',
|
|
293
|
-
toolPendingBg: '#3b4252',
|
|
294
|
-
toolSuccessBg: '#2e3440',
|
|
295
|
-
toolErrorBg: '#3b2f31',
|
|
296
|
-
toolTitle: '#88c0d0',
|
|
297
|
-
toolOutput: '#a8b1c1',
|
|
298
|
-
toolDiffAdded: '#a3be8c',
|
|
299
|
-
toolDiffRemoved: '#daa2a8',
|
|
300
|
-
toolDiffContext: '#a8b1c1',
|
|
301
|
-
mdHeading: '#88c0d0',
|
|
302
|
-
mdLink: '#88c0d0',
|
|
303
|
-
mdLinkUrl: '#727f9a',
|
|
304
|
-
mdCode: '#82a2c1',
|
|
305
|
-
mdCodeBlock: '#d8dee9',
|
|
306
|
-
mdCodeBlockBorder: '#434c5e',
|
|
307
|
-
mdKeyword: '#82a2c1',
|
|
308
|
-
syntaxString: '#a3be8c',
|
|
309
|
-
syntaxNumber: '#b793b1',
|
|
310
|
-
syntaxFunction: '#88c0d0',
|
|
311
|
-
syntaxType: '#8fbcbb',
|
|
312
|
-
mdQuote: '#7b88a1',
|
|
313
|
-
mdListBullet: '#81a1c1',
|
|
314
|
-
thinkingText: '#747f95',
|
|
315
|
-
customMessageLabel: '#b48ead',
|
|
316
|
-
userMessageText: '#d8dee9',
|
|
317
|
-
};
|
|
318
|
-
const GRUVBOX_PALETTE = {
|
|
319
|
-
...DARK_PALETTE,
|
|
320
|
-
accent: '#fe8019',
|
|
321
|
-
border: '#458588',
|
|
322
|
-
borderAccent: '#8ec07c',
|
|
323
|
-
borderMuted: '#504945',
|
|
324
|
-
success: '#b8bb26',
|
|
325
|
-
error: '#fc6c5c',
|
|
326
|
-
warning: '#fabd2f',
|
|
327
|
-
muted: '#a4988b',
|
|
328
|
-
dim: '#87796d',
|
|
329
|
-
text: '',
|
|
330
|
-
userMessageBg: '#1d2021',
|
|
331
|
-
toolPendingBg: '#32302f',
|
|
332
|
-
toolSuccessBg: '#1d2021',
|
|
333
|
-
toolErrorBg: '#3c2021',
|
|
334
|
-
toolTitle: '#ebdbb2',
|
|
335
|
-
toolOutput: '#a4988b',
|
|
336
|
-
toolDiffAdded: '#b8bb26',
|
|
337
|
-
toolDiffRemoved: '#fc6c5c',
|
|
338
|
-
toolDiffContext: '#a4988b',
|
|
339
|
-
mdHeading: '#fabd2f',
|
|
340
|
-
mdLink: '#8ec07c',
|
|
341
|
-
mdLinkUrl: '#7e7165',
|
|
342
|
-
mdCode: '#bdae93',
|
|
343
|
-
mdCodeBlock: '#ebdbb2',
|
|
344
|
-
mdCodeBlockBorder: '#504945',
|
|
345
|
-
mdKeyword: '#d3869b',
|
|
346
|
-
syntaxString: '#b8bb26',
|
|
347
|
-
syntaxNumber: '#d3869b',
|
|
348
|
-
syntaxFunction: '#fabd2f',
|
|
349
|
-
syntaxType: '#8ec07c',
|
|
350
|
-
mdQuote: '#928374',
|
|
351
|
-
mdListBullet: '#fe8019',
|
|
352
|
-
thinkingText: '#7e7165',
|
|
353
|
-
customMessageLabel: '#d3869b',
|
|
354
|
-
userMessageText: '#ebdbb2',
|
|
355
|
-
};
|
|
356
|
-
const ROSE_PINE_PALETTE = {
|
|
357
|
-
...DARK_PALETTE,
|
|
358
|
-
accent: '#c4a7e7',
|
|
359
|
-
border: '#31748f',
|
|
360
|
-
borderAccent: '#9ccfd8',
|
|
361
|
-
borderMuted: '#403d52',
|
|
362
|
-
success: '#9ccfd8',
|
|
363
|
-
error: '#eb6f92',
|
|
364
|
-
warning: '#f6c177',
|
|
365
|
-
muted: '#8c89a2',
|
|
366
|
-
dim: '#6f6b8b',
|
|
367
|
-
text: '',
|
|
368
|
-
userMessageBg: '#21202e',
|
|
369
|
-
toolPendingBg: '#1f1d2e',
|
|
370
|
-
toolSuccessBg: '#21202e',
|
|
371
|
-
toolErrorBg: '#2d1f26',
|
|
372
|
-
toolTitle: '#9ccfd8',
|
|
373
|
-
toolOutput: '#8c89a2',
|
|
374
|
-
toolDiffAdded: '#9ccfd8',
|
|
375
|
-
toolDiffRemoved: '#eb6f92',
|
|
376
|
-
toolDiffContext: '#8c89a2',
|
|
377
|
-
mdHeading: '#c4a7e7',
|
|
378
|
-
mdLink: '#9ccfd8',
|
|
379
|
-
mdLinkUrl: '#908caa',
|
|
380
|
-
mdCode: '#a8a4c4',
|
|
381
|
-
mdCodeBlock: '#e0def4',
|
|
382
|
-
mdCodeBlockBorder: '#403d52',
|
|
383
|
-
mdKeyword: '#3b8cac',
|
|
384
|
-
syntaxString: '#f6c177',
|
|
385
|
-
syntaxNumber: '#ebbcba',
|
|
386
|
-
syntaxFunction: '#9ccfd8',
|
|
387
|
-
syntaxType: '#c4a7e7',
|
|
388
|
-
mdQuote: '#6e6a86',
|
|
389
|
-
mdListBullet: '#c4a7e7',
|
|
390
|
-
thinkingText: '#6e6a86',
|
|
391
|
-
customMessageLabel: '#c4a7e7',
|
|
392
|
-
userMessageText: '#e0def4',
|
|
393
|
-
};
|
|
394
|
-
const MONO_PALETTE = {
|
|
395
|
-
accent: '#e8e8e8',
|
|
396
|
-
border: '#888888',
|
|
397
|
-
borderAccent: '#b8b8b8',
|
|
398
|
-
borderMuted: '#444444',
|
|
399
|
-
success: '#c0c0c0',
|
|
400
|
-
error: '#f0f0f0',
|
|
401
|
-
warning: '#a8a8a8',
|
|
402
|
-
muted: '#939393',
|
|
403
|
-
dim: '#757575',
|
|
404
|
-
text: '',
|
|
405
|
-
userMessageText: '#e8e8e8',
|
|
406
|
-
userMessageBg: '#202020',
|
|
407
|
-
toolPendingBg: '#242424',
|
|
408
|
-
toolSuccessBg: '#1c1c1c',
|
|
409
|
-
toolErrorBg: '#2a2a2a',
|
|
410
|
-
toolTitle: '#e8e8e8',
|
|
411
|
-
toolOutput: '#939393',
|
|
412
|
-
toolDiffAdded: '#c0c0c0',
|
|
413
|
-
toolDiffRemoved: '#f0f0f0',
|
|
414
|
-
toolDiffContext: '#939393',
|
|
415
|
-
mdHeading: '#e8e8e8',
|
|
416
|
-
mdLink: '#b8b8b8',
|
|
417
|
-
mdLinkUrl: '#666666',
|
|
418
|
-
mdCode: '#a0a0a0',
|
|
419
|
-
mdCodeBlock: '#c0c0c0',
|
|
420
|
-
mdCodeBlockBorder: '#444444',
|
|
421
|
-
mdKeyword: '#b8b8b8',
|
|
422
|
-
syntaxString: '#c0c0c0',
|
|
423
|
-
syntaxNumber: '#a0a0a0',
|
|
424
|
-
syntaxFunction: '#e8e8e8',
|
|
425
|
-
syntaxType: '#b8b8b8',
|
|
426
|
-
mdQuote: '#888888',
|
|
427
|
-
mdListBullet: '#b8b8b8',
|
|
428
|
-
thinkingText: '#767676',
|
|
429
|
-
customMessageLabel: '#a8a8a8',
|
|
76
|
+
accent: '#245ac7', border: '#a0adca', borderAccent: '#4d6bfe', borderMuted: '#9ca0b0',
|
|
77
|
+
success: '#386b35', error: '#b52e4d', warning: '#805d16',
|
|
78
|
+
muted: '#5c5f77', dim: '#6c6f85', text: '',
|
|
79
|
+
userMessageText: '#4c4f69', userMessageBg: '#e6ecfb',
|
|
80
|
+
toolPendingBg: '#e6e9ef', toolSuccessBg: '#e0eadf', toolAltBg: '#eff1f5', toolErrorBg: '#f2e2e7',
|
|
81
|
+
toolTitle: '#4c4f69', toolOutput: '#5c5f77',
|
|
82
|
+
toolDiffAdded: '#386b35', toolDiffRemoved: '#b52e4d', toolDiffContext: '#5c5f77',
|
|
83
|
+
mdHeading: '#4c4f69', mdLink: '#245ac7', mdLinkUrl: '#6c6f85', mdCode: '#783ab0',
|
|
84
|
+
mdCodeBlock: '#4c4f69', mdCodeBlockBorder: '#9ca0b0', mdKeyword: '#783ab0',
|
|
85
|
+
syntaxString: '#386b35', syntaxNumber: '#975020', syntaxFunction: '#216778', syntaxType: '#805d16',
|
|
86
|
+
syntaxComment: '#63677c', syntaxPunctuation: '#5c5f77',
|
|
87
|
+
mdQuote: '#5c5f77', mdQuoteBorder: '#9ca0b0', mdHr: '#9ca0b0', mdListBullet: '#6c6f85',
|
|
88
|
+
shellMode: '#386b35', thinkingText: '#63677c', customMessageLabel: '#783ab0',
|
|
430
89
|
};
|
|
431
90
|
const PALETTES = {
|
|
432
91
|
dark: DARK_PALETTE,
|
|
433
92
|
light: LIGHT_PALETTE,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
dracula: DRACULA_PALETTE,
|
|
438
|
-
nord: NORD_PALETTE,
|
|
439
|
-
gruvbox: GRUVBOX_PALETTE,
|
|
440
|
-
'rose-pine': ROSE_PINE_PALETTE,
|
|
441
|
-
mono: MONO_PALETTE,
|
|
93
|
+
// `system` starts from the neutral palette and is rebuilt from the reported
|
|
94
|
+
// terminal colors when a launch can probe them.
|
|
95
|
+
system: DARK_PALETTE,
|
|
442
96
|
};
|
|
443
97
|
/**
|
|
444
98
|
* 16-color foreground fallbacks when the terminal is not truecolor. Entries
|
|
@@ -446,6 +100,7 @@ const PALETTES = {
|
|
|
446
100
|
* shift in {@link ANSI16_BG} yields the intended background SGR.
|
|
447
101
|
*/
|
|
448
102
|
const DARK_ANSI16 = {
|
|
103
|
+
syntaxComment: '37', syntaxPunctuation: '37',
|
|
449
104
|
syntaxString: '32',
|
|
450
105
|
syntaxNumber: '35',
|
|
451
106
|
syntaxFunction: '33',
|
|
@@ -465,25 +120,30 @@ const DARK_ANSI16 = {
|
|
|
465
120
|
// Neutral fills avoid same-index collisions with error and diff ink.
|
|
466
121
|
toolPendingBg: '30',
|
|
467
122
|
toolSuccessBg: '30',
|
|
123
|
+
toolAltBg: '30',
|
|
468
124
|
toolErrorBg: '30',
|
|
469
125
|
toolTitle: '37',
|
|
470
126
|
toolOutput: '37',
|
|
471
127
|
toolDiffAdded: '32',
|
|
472
128
|
toolDiffRemoved: '31',
|
|
473
129
|
toolDiffContext: '90',
|
|
474
|
-
mdHeading: '
|
|
130
|
+
mdHeading: '37',
|
|
475
131
|
mdLink: '94',
|
|
476
132
|
mdLinkUrl: '90',
|
|
477
133
|
mdCode: '90',
|
|
478
|
-
mdCodeBlock: '
|
|
134
|
+
mdCodeBlock: '37',
|
|
479
135
|
mdCodeBlockBorder: '90',
|
|
480
136
|
mdKeyword: '36',
|
|
481
137
|
mdQuote: '37',
|
|
482
|
-
|
|
483
|
-
|
|
138
|
+
mdQuoteBorder: '90',
|
|
139
|
+
mdHr: '90',
|
|
140
|
+
mdListBullet: '90',
|
|
141
|
+
shellMode: '92',
|
|
142
|
+
thinkingText: '37',
|
|
484
143
|
customMessageLabel: '35',
|
|
485
144
|
};
|
|
486
145
|
const LIGHT_ANSI16 = {
|
|
146
|
+
syntaxComment: '30', syntaxPunctuation: '30',
|
|
487
147
|
syntaxString: '31',
|
|
488
148
|
syntaxNumber: '30',
|
|
489
149
|
syntaxFunction: '30',
|
|
@@ -500,135 +160,37 @@ const LIGHT_ANSI16 = {
|
|
|
500
160
|
text: '39',
|
|
501
161
|
userMessageText: '30',
|
|
502
162
|
userMessageBg: '37',
|
|
163
|
+
// This table holds *foreground* codes; `toBackgrounds` adds the 10 that turns
|
|
164
|
+
// them into fills, so `37` here is the white `\x1b[47m` card a light terminal
|
|
165
|
+
// needs under its dark ink.
|
|
503
166
|
toolPendingBg: '37',
|
|
504
167
|
toolSuccessBg: '37',
|
|
168
|
+
toolAltBg: '37',
|
|
505
169
|
toolErrorBg: '37',
|
|
506
170
|
toolTitle: '30',
|
|
507
171
|
toolOutput: '30',
|
|
508
172
|
toolDiffAdded: '30',
|
|
509
173
|
toolDiffRemoved: '31',
|
|
510
174
|
toolDiffContext: '90',
|
|
511
|
-
mdHeading: '
|
|
175
|
+
mdHeading: '30',
|
|
512
176
|
mdLink: '34',
|
|
513
177
|
mdLinkUrl: '90',
|
|
514
178
|
mdCode: '30',
|
|
515
|
-
mdCodeBlock: '
|
|
179
|
+
mdCodeBlock: '30',
|
|
516
180
|
mdCodeBlockBorder: '90',
|
|
517
181
|
mdKeyword: '34',
|
|
518
182
|
mdQuote: '30',
|
|
519
|
-
|
|
183
|
+
mdQuoteBorder: '90',
|
|
184
|
+
mdHr: '90',
|
|
185
|
+
mdListBullet: '90',
|
|
186
|
+
shellMode: '32',
|
|
520
187
|
thinkingText: '90',
|
|
521
188
|
customMessageLabel: '35',
|
|
522
189
|
};
|
|
523
|
-
const MIDNIGHT_ANSI16 = {
|
|
524
|
-
...DARK_ANSI16,
|
|
525
|
-
accent: '34',
|
|
526
|
-
border: '34',
|
|
527
|
-
borderAccent: '36',
|
|
528
|
-
mdHeading: '35',
|
|
529
|
-
mdLink: '36',
|
|
530
|
-
mdKeyword: '35',
|
|
531
|
-
mdListBullet: '34',
|
|
532
|
-
customMessageLabel: '35',
|
|
533
|
-
};
|
|
534
|
-
const SOLARIZED_ANSI16 = {
|
|
535
|
-
...DARK_ANSI16,
|
|
536
|
-
accent: '33',
|
|
537
|
-
border: '34',
|
|
538
|
-
borderAccent: '36',
|
|
539
|
-
mdHeading: '33',
|
|
540
|
-
mdLink: '34',
|
|
541
|
-
mdKeyword: '32',
|
|
542
|
-
mdCodeBlock: '36',
|
|
543
|
-
mdListBullet: '33',
|
|
544
|
-
customMessageLabel: '35',
|
|
545
|
-
};
|
|
546
|
-
const CATPPUCCIN_ANSI16 = {
|
|
547
|
-
...DARK_ANSI16,
|
|
548
|
-
accent: '33',
|
|
549
|
-
border: '34',
|
|
550
|
-
borderAccent: '35',
|
|
551
|
-
mdHeading: '33',
|
|
552
|
-
mdLink: '34',
|
|
553
|
-
mdKeyword: '35',
|
|
554
|
-
mdListBullet: '33',
|
|
555
|
-
customMessageLabel: '35',
|
|
556
|
-
};
|
|
557
|
-
const DRACULA_ANSI16 = {
|
|
558
|
-
...DARK_ANSI16,
|
|
559
|
-
accent: '35',
|
|
560
|
-
border: '35',
|
|
561
|
-
borderAccent: '35',
|
|
562
|
-
mdHeading: '35',
|
|
563
|
-
mdLink: '36',
|
|
564
|
-
mdKeyword: '35',
|
|
565
|
-
mdListBullet: '35',
|
|
566
|
-
customMessageLabel: '35',
|
|
567
|
-
};
|
|
568
|
-
const NORD_ANSI16 = {
|
|
569
|
-
...DARK_ANSI16,
|
|
570
|
-
accent: '36',
|
|
571
|
-
border: '34',
|
|
572
|
-
borderAccent: '36',
|
|
573
|
-
mdHeading: '36',
|
|
574
|
-
mdLink: '36',
|
|
575
|
-
mdKeyword: '34',
|
|
576
|
-
mdListBullet: '34',
|
|
577
|
-
customMessageLabel: '35',
|
|
578
|
-
};
|
|
579
|
-
const GRUVBOX_ANSI16 = {
|
|
580
|
-
...DARK_ANSI16,
|
|
581
|
-
accent: '33',
|
|
582
|
-
border: '36',
|
|
583
|
-
borderAccent: '32',
|
|
584
|
-
mdHeading: '33',
|
|
585
|
-
mdLink: '32',
|
|
586
|
-
mdKeyword: '35',
|
|
587
|
-
mdListBullet: '33',
|
|
588
|
-
customMessageLabel: '35',
|
|
589
|
-
};
|
|
590
|
-
const ROSE_PINE_ANSI16 = {
|
|
591
|
-
...DARK_ANSI16,
|
|
592
|
-
accent: '35',
|
|
593
|
-
border: '36',
|
|
594
|
-
borderAccent: '36',
|
|
595
|
-
mdHeading: '35',
|
|
596
|
-
mdLink: '36',
|
|
597
|
-
mdKeyword: '36',
|
|
598
|
-
mdListBullet: '35',
|
|
599
|
-
customMessageLabel: '35',
|
|
600
|
-
};
|
|
601
|
-
const MONO_ANSI16 = {
|
|
602
|
-
...DARK_ANSI16,
|
|
603
|
-
syntaxString: '37',
|
|
604
|
-
syntaxNumber: '37',
|
|
605
|
-
syntaxFunction: '97',
|
|
606
|
-
syntaxType: '37',
|
|
607
|
-
accent: '97',
|
|
608
|
-
border: '37',
|
|
609
|
-
borderAccent: '97',
|
|
610
|
-
success: '37',
|
|
611
|
-
error: '97',
|
|
612
|
-
warning: '37',
|
|
613
|
-
muted: '37',
|
|
614
|
-
mdHeading: '97',
|
|
615
|
-
mdLink: '37',
|
|
616
|
-
mdCodeBlock: '37',
|
|
617
|
-
mdKeyword: '37',
|
|
618
|
-
mdListBullet: '37',
|
|
619
|
-
customMessageLabel: '37',
|
|
620
|
-
};
|
|
621
190
|
const ANSI16 = {
|
|
622
191
|
dark: DARK_ANSI16,
|
|
623
192
|
light: LIGHT_ANSI16,
|
|
624
|
-
|
|
625
|
-
solarized: SOLARIZED_ANSI16,
|
|
626
|
-
catppuccin: CATPPUCCIN_ANSI16,
|
|
627
|
-
dracula: DRACULA_ANSI16,
|
|
628
|
-
nord: NORD_ANSI16,
|
|
629
|
-
gruvbox: GRUVBOX_ANSI16,
|
|
630
|
-
'rose-pine': ROSE_PINE_ANSI16,
|
|
631
|
-
mono: MONO_ANSI16,
|
|
193
|
+
system: DARK_ANSI16,
|
|
632
194
|
};
|
|
633
195
|
/** Distance from a foreground SGR code to its background twin: 31 → 41, 39 → 49. */
|
|
634
196
|
const BG_CODE_OFFSET = 10;
|
|
@@ -645,18 +207,164 @@ function toBackgrounds(foreground) {
|
|
|
645
207
|
}
|
|
646
208
|
return result;
|
|
647
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Backgrounds for the three tool states, chosen so they stay distinct.
|
|
212
|
+
*
|
|
213
|
+
* This is the group form of the problem {@link nearestXterm256} solves for one
|
|
214
|
+
* colour: the states differ mostly in hue and only slightly in lightness, so
|
|
215
|
+
* quantising each swatch on its own collapses them. The assignment below picks a
|
|
216
|
+
* distinct entry per state and then orders the three by lightness, so pending,
|
|
217
|
+
* success, and error remain recognizable even on a terminal that offers only
|
|
218
|
+
* eight backgrounds.
|
|
219
|
+
*
|
|
220
|
+
* A 16-colour terminal simply has fewer backgrounds than the states that need
|
|
221
|
+
* one. Rather than paint three states the same black, the ones it cannot tint
|
|
222
|
+
* fall back to `toolSuccessBg` and the error state — the only one a reader must
|
|
223
|
+
* act on — is given the red it already has in `ansiBg` when the palette has a
|
|
224
|
+
* usable red background.
|
|
225
|
+
*/
|
|
226
|
+
function resolveToolFills(name, depth, terminal) {
|
|
227
|
+
const palette = name === 'system' ? systemPalette(terminal) : PALETTES[name];
|
|
228
|
+
const reported = depth === 'ansi16' && terminal?.palette !== undefined && terminal.palette.length === 16
|
|
229
|
+
? terminal.palette
|
|
230
|
+
: undefined;
|
|
231
|
+
const states = ['toolPendingBg', 'toolSuccessBg', 'toolErrorBg'];
|
|
232
|
+
const swatches = states.map(state => {
|
|
233
|
+
const swatch = palette[state];
|
|
234
|
+
if (typeof swatch !== 'string' || swatch === '')
|
|
235
|
+
return undefined;
|
|
236
|
+
const [r, g, b] = hexToRgb(swatch);
|
|
237
|
+
return { r, g, b };
|
|
238
|
+
});
|
|
239
|
+
const filled = swatches.every((swatch) => swatch !== undefined);
|
|
240
|
+
if (!filled)
|
|
241
|
+
return undefined;
|
|
242
|
+
if (depth === 'ansi256') {
|
|
243
|
+
// The neutral ramp is where the three near-black surfaces actually live; the
|
|
244
|
+
// colour cube would round them all to the same corner.
|
|
245
|
+
const indices = swatches.map(swatch => nearestXterm256Grey(swatch));
|
|
246
|
+
return assignDistinct(states, indices, index => `\x1b[48;5;${index}m`);
|
|
247
|
+
}
|
|
248
|
+
if (reported !== undefined) {
|
|
249
|
+
// Sixteen colours are not enough for three surfaces, so each state claims a
|
|
250
|
+
// *different* entry from the ones its own hue actually reaches, rather than
|
|
251
|
+
// nudging a number that has no meaning in this palette.
|
|
252
|
+
return pickDistinctPaletteEntries(name, states, swatches, reported, index => ansiIndexSgr(index, true));
|
|
253
|
+
}
|
|
254
|
+
// The terminal never answered our colour query, so the standard xterm ANSI
|
|
255
|
+
// meanings are assumed: three different backgrounds that carry text. Guessing
|
|
256
|
+
// per swatch here is exactly what collapsed the three states into one. Red is
|
|
257
|
+
// deliberately not one of them — a red fill would share its palette slot with
|
|
258
|
+
// the red `error` and `toolDiffRemoved` ink drawn on top of it.
|
|
259
|
+
// A light card is white paper under dark ink, and the eight backgrounds an
|
|
260
|
+
// ANSI-16 terminal offers contain exactly one that carries it. Pending and
|
|
261
|
+
// success therefore share it, and the failing card — the state a reader has to
|
|
262
|
+
// act on — is the one that gets a fill of its own.
|
|
263
|
+
return name === 'light'
|
|
264
|
+
? { toolPendingBg: '\x1b[47m', toolSuccessBg: '\x1b[47m', toolErrorBg: '\x1b[45m' }
|
|
265
|
+
: { toolPendingBg: '\x1b[44m', toolSuccessBg: '\x1b[40m', toolErrorBg: '\x1b[45m' };
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Give each state the nearest palette entry no other state has taken.
|
|
269
|
+
*
|
|
270
|
+
* A 16-colour terminal cannot express a subtle tint, so the question stops being
|
|
271
|
+
* "which entry is nearest" and becomes "which entry can this state have". Each
|
|
272
|
+
* state is served in turn, by increasing distance, and only entries whose
|
|
273
|
+
* luminance is low enough to hold card text are considered — a bright palette
|
|
274
|
+
* entry would turn a tool card into a block of white.
|
|
275
|
+
*/
|
|
276
|
+
function pickDistinctPaletteEntries(name, states, swatches, palette, encode) {
|
|
277
|
+
// A palette slot already used as ink on a card is not available as a fill: a
|
|
278
|
+
// red background under red diff lines erases them. The check runs against the
|
|
279
|
+
// same fallback table the foreground codes come from, so the two can never
|
|
280
|
+
// disagree about which slot a colour occupies.
|
|
281
|
+
const takenByInk = new Set(CARD_INK_COLORS
|
|
282
|
+
.map(color => Number.parseInt(ANSI16[name][color], 10))
|
|
283
|
+
.filter(code => Number.isInteger(code) && code < 8));
|
|
284
|
+
const ceiling = SURFACE_MAX_LUMINANCE[name];
|
|
285
|
+
// A light card's ink is a black that owns slot 0, so its fills come from the
|
|
286
|
+
// bright end instead; the test is "far enough from the ink", not "dark".
|
|
287
|
+
const eligible = (entry, index) => entry !== undefined
|
|
288
|
+
&& !takenByInk.has(index)
|
|
289
|
+
&& (name === 'light' ? relativeLuminance(entry) >= ceiling : relativeLuminance(entry) < ceiling);
|
|
290
|
+
if (palette.filter(eligible).length < states.length)
|
|
291
|
+
return undefined;
|
|
292
|
+
const ranked = palette
|
|
293
|
+
.flatMap((entry, index) => entry === undefined ? [] : [{ index, entry: entry }])
|
|
294
|
+
.filter(({ entry, index }) => eligible(entry, index))
|
|
295
|
+
.map(({ index, entry }) => ({ index, lab: toOklab(entry) }));
|
|
296
|
+
if (ranked.length < states.length)
|
|
297
|
+
return undefined;
|
|
298
|
+
const used = new Set();
|
|
299
|
+
const result = {};
|
|
300
|
+
for (let at = 0; at < states.length; at += 1) {
|
|
301
|
+
const target = toOklab(swatches[at]);
|
|
302
|
+
let best;
|
|
303
|
+
for (const candidate of ranked) {
|
|
304
|
+
if (used.has(candidate.index))
|
|
305
|
+
continue;
|
|
306
|
+
const distance = labDistance(target, candidate.lab);
|
|
307
|
+
if (best === undefined || distance < best.distance)
|
|
308
|
+
best = { index: candidate.index, distance };
|
|
309
|
+
}
|
|
310
|
+
if (best === undefined)
|
|
311
|
+
return undefined;
|
|
312
|
+
used.add(best.index);
|
|
313
|
+
result[states[at]] = encode(best.index);
|
|
314
|
+
}
|
|
315
|
+
return result;
|
|
316
|
+
}
|
|
317
|
+
/** Ink drawn on a tool card, by theme token and ANSI-16 fallback code. */
|
|
318
|
+
const CARD_INK_COLORS = [
|
|
319
|
+
'toolTitle', 'toolOutput', 'toolDiffAdded', 'toolDiffRemoved', 'toolDiffContext',
|
|
320
|
+
'mdKeyword', 'syntaxString', 'syntaxNumber', 'syntaxFunction', 'syntaxType', 'syntaxComment', 'syntaxPunctuation',
|
|
321
|
+
'mdCodeBlock', 'mdLink', 'mdHeading', 'mdQuote', 'dim', 'muted', 'accent',
|
|
322
|
+
'success', 'error', 'warning', 'thinkingText', 'mdListBullet', 'mdHr',
|
|
323
|
+
'mdQuoteBorder', 'mdCodeBlockBorder', 'mdCode', 'mdLinkUrl',
|
|
324
|
+
];
|
|
325
|
+
/**
|
|
326
|
+
* How light a card fill may be, per palette.
|
|
327
|
+
*
|
|
328
|
+
* The constraint is not "dark" — it is "far from the ink". A dark theme draws
|
|
329
|
+
* light text on a dark fill and a light theme draws dark text on a light fill, so
|
|
330
|
+
* each palette states its own ceiling instead of sharing a dark one that would
|
|
331
|
+
* make every card on a light terminal a black block.
|
|
332
|
+
*/
|
|
333
|
+
const SURFACE_MAX_LUMINANCE = {
|
|
334
|
+
dark: 0.5, system: 0.5,
|
|
335
|
+
// A light card's fill comes from the bright end; the ceiling is its floor.
|
|
336
|
+
light: 0.98,
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Give every state its own encoding, nudging the ones that collided.
|
|
340
|
+
*
|
|
341
|
+
* `preferred` is the honest per-state choice; when two states land on it, the
|
|
342
|
+
* one further from the light end is pushed to a neighbouring entry. A terminal
|
|
343
|
+
* whose palette has no room left keeps the collision rather than inventing a
|
|
344
|
+
* colour it cannot draw, which is why this returns `undefined` in that case.
|
|
345
|
+
*/
|
|
346
|
+
function assignDistinct(states, preferred, encode) {
|
|
347
|
+
const used = new Set();
|
|
348
|
+
const result = {};
|
|
349
|
+
for (let at = 0; at < states.length; at += 1) {
|
|
350
|
+
const state = states[at];
|
|
351
|
+
let index = preferred[at] ?? 0;
|
|
352
|
+
for (let step = 1; used.has(index) && step < 8; step += 1) {
|
|
353
|
+
// Alternate lighter and darker so a nudge stays close to the intent.
|
|
354
|
+
index = preferred[at] + (step % 2 === 1 ? -step : step);
|
|
355
|
+
}
|
|
356
|
+
if (used.has(index))
|
|
357
|
+
return undefined;
|
|
358
|
+
used.add(index);
|
|
359
|
+
result[state] = encode(index);
|
|
360
|
+
}
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
648
363
|
/** 16-color background fallbacks when the terminal is not truecolor. */
|
|
649
364
|
const ANSI16_BG = {
|
|
650
365
|
dark: toBackgrounds(DARK_ANSI16),
|
|
651
366
|
light: toBackgrounds(LIGHT_ANSI16),
|
|
652
|
-
|
|
653
|
-
solarized: toBackgrounds(SOLARIZED_ANSI16),
|
|
654
|
-
catppuccin: toBackgrounds(CATPPUCCIN_ANSI16),
|
|
655
|
-
dracula: toBackgrounds(DRACULA_ANSI16),
|
|
656
|
-
nord: toBackgrounds(NORD_ANSI16),
|
|
657
|
-
gruvbox: toBackgrounds(GRUVBOX_ANSI16),
|
|
658
|
-
'rose-pine': toBackgrounds(ROSE_PINE_ANSI16),
|
|
659
|
-
mono: toBackgrounds(MONO_ANSI16),
|
|
367
|
+
system: toBackgrounds(DARK_ANSI16),
|
|
660
368
|
};
|
|
661
369
|
const FG_RESET = '\x1b[39m';
|
|
662
370
|
const BG_RESET = '\x1b[49m';
|
|
@@ -665,12 +373,15 @@ const ITALIC_RESET = '\x1b[23m';
|
|
|
665
373
|
const UNDERLINE_RESET = '\x1b[24m';
|
|
666
374
|
const STRIKE_RESET = '\x1b[29m';
|
|
667
375
|
const INVERSE_RESET = '\x1b[27m';
|
|
668
|
-
/**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Shipped palettes: one dark, one light, and the one that follows the terminal.
|
|
378
|
+
*
|
|
379
|
+
* A theme is a contract the whole TUI is read through — every card, diff, and
|
|
380
|
+
* syntax token has to stay legible on it — so the set stays small enough to hold
|
|
381
|
+
* to that standard. `system` is not a third design: it derives its surfaces from
|
|
382
|
+
* the colours the terminal reports and then follows the same rules.
|
|
383
|
+
*/
|
|
384
|
+
export const THEME_NAMES = ['dark', 'light', 'system'];
|
|
674
385
|
/** True when `value` is a shipped palette name. */
|
|
675
386
|
export function isThemeName(value) {
|
|
676
387
|
return THEME_NAMES.includes(value);
|
|
@@ -726,27 +437,250 @@ function hexToRgb(hex) {
|
|
|
726
437
|
Number.parseInt(body.slice(4, 6), 16),
|
|
727
438
|
];
|
|
728
439
|
}
|
|
729
|
-
/**
|
|
730
|
-
|
|
440
|
+
/**
|
|
441
|
+
* SGR for one swatch at a color depth; `fallback` is a code from
|
|
442
|
+
* {@link ANSI16} or {@link ANSI16_BG}. `layer` is 38 for ink and 48 for fill.
|
|
443
|
+
*/
|
|
444
|
+
function swatchCode(swatch, depth, fallback, layer) {
|
|
731
445
|
if (swatch === '')
|
|
732
|
-
return '\x1b[39m';
|
|
446
|
+
return layer === 38 ? '\x1b[39m' : '\x1b[49m';
|
|
733
447
|
if (typeof swatch === 'number')
|
|
734
|
-
return `\x1b[
|
|
735
|
-
if (
|
|
448
|
+
return `\x1b[${layer};5;${swatch}m`;
|
|
449
|
+
if (depth === 'ansi16')
|
|
736
450
|
return `\x1b[${fallback}m`;
|
|
737
451
|
const [r, g, b] = hexToRgb(swatch);
|
|
738
|
-
|
|
452
|
+
if (depth === 'ansi256')
|
|
453
|
+
return `\x1b[${layer};5;${nearestXterm256({ r, g, b })}m`;
|
|
454
|
+
return `\x1b[${layer};2;${r};${g};${b}m`;
|
|
739
455
|
}
|
|
740
|
-
/**
|
|
741
|
-
function
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
456
|
+
/** Mix two colors in linear light; `weight` is the share of `to`. */
|
|
457
|
+
function mixRgb(from, to, weight) {
|
|
458
|
+
const linear = (value) => {
|
|
459
|
+
const channelValue = value / 255;
|
|
460
|
+
return channelValue <= 0.04045 ? channelValue / 12.92 : ((channelValue + 0.055) / 1.055) ** 2.4;
|
|
461
|
+
};
|
|
462
|
+
const encode = (value) => {
|
|
463
|
+
const clamped = Math.max(0, Math.min(1, value));
|
|
464
|
+
return Math.round(255 * (clamped <= 0.003_130_8 ? clamped * 12.92 : 1.055 * clamped ** (1 / 2.4) - 0.055));
|
|
465
|
+
};
|
|
466
|
+
const mix = (left, right) => linear(left) * (1 - weight) + linear(right) * weight;
|
|
467
|
+
return { r: encode(mix(from.r, to.r)), g: encode(mix(from.g, to.g)), b: encode(mix(from.b, to.b)) };
|
|
468
|
+
}
|
|
469
|
+
function toHex(color) {
|
|
470
|
+
const part = (value) => Math.round(value).toString(16).padStart(2, '0');
|
|
471
|
+
return `#${part(color.r)}${part(color.g)}${part(color.b)}`;
|
|
472
|
+
}
|
|
473
|
+
/** The fixed red a `system` error surface mixes toward when the palette has none. */
|
|
474
|
+
const SYSTEM_ERROR_RED = { r: 0xff, g: 0x5f, b: 0x5f };
|
|
475
|
+
/** The fixed green a `system` success surface mixes toward when the palette has none. */
|
|
476
|
+
const SYSTEM_SUCCESS_GREEN = { r: 0x4a, g: 0xc8, b: 0x7a };
|
|
477
|
+
/** The fixed blue a `system` notice surface mixes toward when the palette has none. */
|
|
478
|
+
const SYSTEM_NOTICE_BLUE = { r: 0x6f, g: 0xa8, b: 0xff };
|
|
479
|
+
/**
|
|
480
|
+
* How far a card may move from the terminal background toward a state hue.
|
|
481
|
+
*
|
|
482
|
+
* A card is a step off the reader's own background, not a swatch of the terminal
|
|
483
|
+
* palette. Scaling a tint to the target luminance directly keeps the hue but not
|
|
484
|
+
* the calm: a saturated green has to be dimmed so far to reach 4.4% that the
|
|
485
|
+
* scaled channels clip, and a light terminal turns it neon. Interpolating from the
|
|
486
|
+
* background toward the hue instead bounds how much of the hue a card can ever
|
|
487
|
+
* contain, so the fill stays a surface whatever the terminal reports.
|
|
488
|
+
*/
|
|
489
|
+
const SYSTEM_CARD_TINT = 0.34;
|
|
490
|
+
/**
|
|
491
|
+
* The background-to-hue step that lands closest to a target relative luminance.
|
|
492
|
+
*
|
|
493
|
+
* A fixed weight cannot hold a card at one lightness — the same weight applied to
|
|
494
|
+
* a bright terminal green and to a dim one lands almost three stops apart — so the
|
|
495
|
+
* weight is solved for instead, by bisection. Hue still comes from the terminal,
|
|
496
|
+
* which is what makes the fill say "success"; how *much* of it a card spends is
|
|
497
|
+
* the theme's decision, and the tint cap is what keeps the result a surface.
|
|
498
|
+
*/
|
|
499
|
+
function tintAtLuminance(background, tint, target) {
|
|
500
|
+
const at = (weight) => mixRgb(background, tint, weight);
|
|
501
|
+
const luminanceAt = (weight) => relativeLuminance(at(weight));
|
|
502
|
+
// Interpolating between two luminance endpoints is monotonic only while one
|
|
503
|
+
// side sits below the target; a background already brighter than the target
|
|
504
|
+
// reverses which direction helps, so solve outward from the background.
|
|
505
|
+
const towardsBrighter = relativeLuminance(background) < target;
|
|
506
|
+
let low = 0;
|
|
507
|
+
let high = SYSTEM_CARD_TINT;
|
|
508
|
+
if (towardsBrighter ? luminanceAt(high) < target : luminanceAt(high) > target) {
|
|
509
|
+
// The capped step already overshoots or undershoots the target: the cap is
|
|
510
|
+
// the answer, and the card keeps the calm it was given.
|
|
511
|
+
return at(high);
|
|
512
|
+
}
|
|
513
|
+
for (let step = 0; step < 40; step += 1) {
|
|
514
|
+
const middle = (low + high) / 2;
|
|
515
|
+
if (towardsBrighter ? luminanceAt(middle) < target : luminanceAt(middle) > target)
|
|
516
|
+
low = middle;
|
|
517
|
+
else
|
|
518
|
+
high = middle;
|
|
519
|
+
}
|
|
520
|
+
return at((low + high) / 2);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* The background lifted toward white until it reaches a target luminance.
|
|
524
|
+
*
|
|
525
|
+
* Neutral surfaces need a lightness step, not a hue: interpolating toward the
|
|
526
|
+
* foreground flattens whatever faint tint the terminal's background carries, so
|
|
527
|
+
* the step is taken toward white and the background's own channel ratios survive.
|
|
528
|
+
*/
|
|
529
|
+
function liftedToLuminance(background, target) {
|
|
530
|
+
// On paper the background is already brighter than a card wants to be, so the
|
|
531
|
+
// step goes toward black instead; either way it keeps the background's ratios.
|
|
532
|
+
const pole = relativeLuminance(background) < target ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };
|
|
533
|
+
const towardsBrighter = pole.r === 255;
|
|
534
|
+
const at = (weight) => mixRgb(background, pole, weight);
|
|
535
|
+
const luminanceAt = (weight) => relativeLuminance(at(weight));
|
|
536
|
+
let low = 0;
|
|
537
|
+
let high = 1;
|
|
538
|
+
for (let step = 0; step < 40; step += 1) {
|
|
539
|
+
const middle = (low + high) / 2;
|
|
540
|
+
if (towardsBrighter ? luminanceAt(middle) < target : luminanceAt(middle) > target)
|
|
541
|
+
low = middle;
|
|
542
|
+
else
|
|
543
|
+
high = middle;
|
|
544
|
+
}
|
|
545
|
+
return at((low + high) / 2);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The contrast a swatch keeps against the surfaces it is drawn on.
|
|
549
|
+
*
|
|
550
|
+
* Taken against the *weakest* card rather than against the page, because a
|
|
551
|
+
* secondary ink is spent on card fills — a hint on a successful card is the case
|
|
552
|
+
* that has to stay readable, not the same hint on bare background.
|
|
553
|
+
*/
|
|
554
|
+
function worstContrast(ink, cards) {
|
|
555
|
+
return Math.min(...cards.map(card => contrastRatio(ink, card)));
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* A secondary ink held at the contrast the shipped palette achieved.
|
|
559
|
+
*
|
|
560
|
+
* A fixed mix weight made the result depend on which side was bright: on a dark
|
|
561
|
+
* background the step lightened the ink and stayed safe, but against paper it
|
|
562
|
+
* moved it toward the page, so a light terminal's `dim` ended at 1.75:1 — nearly
|
|
563
|
+
* invisible. The weight is solved from the contrast actually achieved instead, so
|
|
564
|
+
* the live cards keep the hierarchy the palette was drawn with: this ink is as
|
|
565
|
+
* far from the text as the shipped one was from its own cards, no further.
|
|
566
|
+
*/
|
|
567
|
+
function quietInk(foreground, background, cards, target) {
|
|
568
|
+
const at = (weight) => mixRgb(foreground, background, weight);
|
|
569
|
+
/**
|
|
570
|
+
* Which way the weight moves contrast is the host's answer, not a constant.
|
|
571
|
+
*
|
|
572
|
+
* Toward a dark background the ink lightens as it is mixed, so weight raises
|
|
573
|
+
* contrast; toward paper it fades toward the page, so weight lowers it. Solving
|
|
574
|
+
* one direction silently returned the palette's cap on every light host, which
|
|
575
|
+
* is how `dim` came to sit at 1.75:1 while looking correct in the code.
|
|
576
|
+
*/
|
|
577
|
+
const towardsBrighter = relativeLuminance(background) < relativeLuminance(foreground);
|
|
578
|
+
let low = 0;
|
|
579
|
+
let high = 1;
|
|
580
|
+
// A background that is itself close to the cards cannot reach the target at any
|
|
581
|
+
// weight; full foreground is the readable answer and the palette's floor.
|
|
582
|
+
if (worstContrast(at(0), cards) <= target)
|
|
583
|
+
return at(0);
|
|
584
|
+
for (let step = 0; step < 40; step += 1) {
|
|
585
|
+
const middle = (low + high) / 2;
|
|
586
|
+
const contrast = worstContrast(at(middle), cards);
|
|
587
|
+
if (towardsBrighter ? contrast > target : contrast >= target)
|
|
588
|
+
low = middle;
|
|
589
|
+
else
|
|
590
|
+
high = middle;
|
|
591
|
+
}
|
|
592
|
+
return at((low + high) / 2);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Rebuild the surface and ink swatches from what the terminal reported, so the
|
|
596
|
+
* cards sit on the user's own background instead of a guessed one. The two
|
|
597
|
+
* successful-call surfaces are separated by design: alternation only reads if
|
|
598
|
+
* the pair is perceptibly different.
|
|
599
|
+
*/
|
|
600
|
+
function systemPalette(terminal) {
|
|
601
|
+
const background = terminal?.background;
|
|
602
|
+
const light = terminal?.scheme === 'light';
|
|
603
|
+
const base = light ? LIGHT_PALETTE : DARK_PALETTE;
|
|
604
|
+
if (background === undefined)
|
|
605
|
+
return base;
|
|
606
|
+
const foreground = terminal?.foreground ?? (light ? { r: 0x24, g: 0x24, b: 0x24 } : { r: 0xe0, g: 0xe0, b: 0xe0 });
|
|
607
|
+
const accent = terminal?.palette?.[4] ?? SYSTEM_NOTICE_BLUE;
|
|
608
|
+
const error = terminal?.palette?.[1] ?? SYSTEM_ERROR_RED;
|
|
609
|
+
const successInk = terminal?.palette?.[2] ?? SYSTEM_SUCCESS_GREEN;
|
|
610
|
+
/**
|
|
611
|
+
* A state fill carries its own hue, the way the shipped palettes do.
|
|
612
|
+
*
|
|
613
|
+
* Mixing toward the terminal's *foreground* produced three greys: the states
|
|
614
|
+
* were separated only by lightness, which on a dark background is the one axis
|
|
615
|
+
* a reader cannot see. Mixing toward the state colour keeps the card on the
|
|
616
|
+
* user's own background and gives it the meaning at the same time — but the
|
|
617
|
+
* *amount* of that colour is fixed by the target luminance, not by a weight.
|
|
618
|
+
* A weight made the fill follow the terminal's swatch, and a bright terminal
|
|
619
|
+
* green turned every successful card into a pale one.
|
|
620
|
+
*/
|
|
621
|
+
const stateCard = (tint, target) => toHex(tintAtLuminance(background, tint, target));
|
|
622
|
+
/** Relative luminance of a shipped swatch, keeping the light palette's own paper tone. */
|
|
623
|
+
const swatchLuminance = (color) => {
|
|
624
|
+
const [r, g, b] = hexToRgb(base[color]);
|
|
625
|
+
return relativeLuminance({ r, g, b });
|
|
626
|
+
};
|
|
627
|
+
// A light terminal wants the same three states as tinted paper, so its cards
|
|
628
|
+
// are held at the light palette's own lightness rather than inverted.
|
|
629
|
+
const target = (state) => swatchLuminance(`tool${state[0].toUpperCase()}${state.slice(1)}Bg`);
|
|
630
|
+
// Pending is neutral, so it keeps the background's own hue and is only lifted in
|
|
631
|
+
// lightness: it must stay quieter than a settled card, and it must still read as
|
|
632
|
+
// belonging to this terminal rather than as a generic grey. Lifting the
|
|
633
|
+
// background keeps whatever faint tint it has; mixing toward the foreground
|
|
634
|
+
// instead traded that tint for the foreground's flat grey.
|
|
635
|
+
const pending = toHex(liftedToLuminance(background, target('pending')));
|
|
636
|
+
const successRgb = tintAtLuminance(background, successInk, target('success'));
|
|
637
|
+
const success = toHex(successRgb);
|
|
638
|
+
// Expanded detail uses a neutral surface with the terminal's own hue.
|
|
639
|
+
const alt = toHex(liftedToLuminance(background, swatchLuminance('toolAltBg')));
|
|
640
|
+
const errorCard = stateCard(error, target('error'));
|
|
641
|
+
const cardFills = [pending, success, alt, errorCard].map(hexToRgb).map(([r, g, b]) => ({ r, g, b }));
|
|
642
|
+
/**
|
|
643
|
+
* The contrast the shipped `dim` reached against the shipped cards.
|
|
644
|
+
*
|
|
645
|
+
* That is the hierarchy to reproduce: the live cards are derived here, so a
|
|
646
|
+
* fixed weight cannot know how far it may weaken the ink before it disappears.
|
|
647
|
+
* `dim` is the only secondary ink that needs solving — it sits closest to the
|
|
648
|
+
* surface, so it is the first to become unreadable there.
|
|
649
|
+
*/
|
|
650
|
+
const shippedDimContrast = () => {
|
|
651
|
+
const [r, g, b] = hexToRgb(base.dim);
|
|
652
|
+
const shippedCards = ['toolPendingBg', 'toolSuccessBg', 'toolAltBg', 'toolErrorBg']
|
|
653
|
+
.map(color => {
|
|
654
|
+
const [cr, cg, cb] = hexToRgb(base[color]);
|
|
655
|
+
return { r: cr, g: cg, b: cb };
|
|
656
|
+
});
|
|
657
|
+
return worstContrast({ r, g, b }, shippedCards);
|
|
658
|
+
};
|
|
659
|
+
return {
|
|
660
|
+
...base,
|
|
661
|
+
text: toHex(foreground),
|
|
662
|
+
/**
|
|
663
|
+
* `muted` is not derived. Both shipped palettes set it to the same swatch as
|
|
664
|
+
* `toolOutput`, and that swatch already clears its cards on either host;
|
|
665
|
+
* deriving it separately only produced a second, near-identical grey that
|
|
666
|
+
* sometimes landed on the wrong side of the ink it was meant to match.
|
|
667
|
+
*/
|
|
668
|
+
muted: base.muted,
|
|
669
|
+
dim: toHex(quietInk(foreground, background, cardFills, shippedDimContrast())),
|
|
670
|
+
userMessageBg: toHex(mixRgb(background, accent, 0.14)),
|
|
671
|
+
toolPendingBg: pending,
|
|
672
|
+
toolSuccessBg: success,
|
|
673
|
+
toolAltBg: alt,
|
|
674
|
+
toolErrorBg: errorCard,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
/** 16-color SGR for one ANSI palette index, as ink or as a fill. */
|
|
678
|
+
function ansiIndexSgr(index, asBackground) {
|
|
679
|
+
const base = asBackground ? 4 : 3;
|
|
680
|
+
if (index < 8)
|
|
681
|
+
return `\x1b[${base}${index}m`;
|
|
682
|
+
const bright = asBackground ? 10 : 9;
|
|
683
|
+
return `\x1b[${bright}${index - 8}m`;
|
|
750
684
|
}
|
|
751
685
|
/**
|
|
752
686
|
* True when the environment asks for no color at all: a non-empty `NO_COLOR`
|
|
@@ -757,41 +691,102 @@ export function colorDisabledByEnv(env = process.env) {
|
|
|
757
691
|
return (env.NO_COLOR !== undefined && env.NO_COLOR !== '') || env.FORCE_COLOR === '0';
|
|
758
692
|
}
|
|
759
693
|
/**
|
|
760
|
-
* Detect
|
|
761
|
-
*
|
|
762
|
-
*
|
|
694
|
+
* Detect the color depth. `NO_COLOR` (any non-empty value) and `FORCE_COLOR=0`
|
|
695
|
+
* outrank every capability hint and leave 16 colors; `COLORTERM` and Windows
|
|
696
|
+
* Terminal prove 24-bit color. Apple Terminal advertises `xterm-256color` but
|
|
697
|
+
* misdraws 24-bit sequences on the releases still in use, so it gets the
|
|
698
|
+
* 256-color cube. Known 16-color hosts stay at 16, and every other terminal is
|
|
699
|
+
* assumed to be a modern 24-bit one.
|
|
763
700
|
*/
|
|
764
|
-
export function
|
|
701
|
+
export function detectColorDepth(env = process.env) {
|
|
765
702
|
if (colorDisabledByEnv(env))
|
|
766
|
-
return
|
|
767
|
-
const colorterm = env.COLORTERM ?? '';
|
|
703
|
+
return 'ansi16';
|
|
704
|
+
const colorterm = (env.COLORTERM ?? '').toLowerCase();
|
|
768
705
|
if (colorterm === 'truecolor' || colorterm === '24bit')
|
|
769
|
-
return
|
|
706
|
+
return 'truecolor';
|
|
770
707
|
if (env.WT_SESSION)
|
|
771
|
-
return
|
|
708
|
+
return 'truecolor';
|
|
772
709
|
const term = env.TERM ?? '';
|
|
773
710
|
if (term === 'dumb' || term === '' || term === 'linux')
|
|
774
|
-
return
|
|
775
|
-
|
|
711
|
+
return 'ansi16';
|
|
712
|
+
if (env.TERM_PROGRAM === 'Apple_Terminal') {
|
|
713
|
+
const build = Number.parseInt((env.TERM_PROGRAM_VERSION ?? '').split('.')[0] ?? '', 10);
|
|
714
|
+
return Number.isInteger(build) && build >= FIRST_TRUECOLOR_APPLE_TERMINAL_BUILD ? 'truecolor' : 'ansi256';
|
|
715
|
+
}
|
|
716
|
+
return 'truecolor';
|
|
776
717
|
}
|
|
718
|
+
/** Terminal 2.15, macOS 26 Tahoe, is the first Apple Terminal with real 24-bit color. */
|
|
719
|
+
const FIRST_TRUECOLOR_APPLE_TERMINAL_BUILD = 464;
|
|
777
720
|
/**
|
|
778
721
|
* Build a theme.
|
|
779
722
|
* @param colors - emit SGR when true.
|
|
780
|
-
* @param
|
|
723
|
+
* @param depth - color depth, or a boolean for 24-bit versus 16 colors; ignored when colors is false.
|
|
781
724
|
* @param name - shipped palette (`dark` default).
|
|
725
|
+
* @param terminal - what the terminal reported about itself, when a probe answered.
|
|
782
726
|
*/
|
|
783
|
-
export function createTheme(colors,
|
|
784
|
-
const
|
|
785
|
-
const
|
|
727
|
+
export function createTheme(colors, depth = detectColorDepth(), name = 'dark', terminal, language = 'en', compactLinks = false) {
|
|
728
|
+
const resolvedDepth = depth === true ? 'truecolor' : depth === false ? 'ansi16' : depth;
|
|
729
|
+
const tc = colors && resolvedDepth === 'truecolor';
|
|
730
|
+
const palette = name === 'system' ? systemPalette(terminal) : PALETTES[name];
|
|
786
731
|
const ansi = ANSI16[name];
|
|
787
732
|
const ansiBg = ANSI16_BG[name];
|
|
788
|
-
|
|
789
|
-
|
|
733
|
+
// The reported sixteen colors decide the encoding only on a 16-color
|
|
734
|
+
// terminal; 256- and 24-bit terminals encode the exact swatch themselves.
|
|
735
|
+
const reported = resolvedDepth === 'ansi16' && terminal?.palette !== undefined && terminal.palette.length === 16 ? terminal.palette : undefined;
|
|
736
|
+
/**
|
|
737
|
+
* Without 24-bit color a hex swatch is quantized to the entry the terminal
|
|
738
|
+
* actually has, which is perceptual nearest rather than a fixed code shift.
|
|
739
|
+
*/
|
|
740
|
+
const quantized = (swatch, asBackground) => {
|
|
741
|
+
if (reported === undefined || typeof swatch !== 'string' || swatch === '')
|
|
742
|
+
return undefined;
|
|
743
|
+
const [r, g, b] = hexToRgb(swatch);
|
|
744
|
+
const index = nearestPaletteIndex({ r, g, b }, reported);
|
|
745
|
+
return index === undefined ? undefined : ansiIndexSgr(index, asBackground);
|
|
746
|
+
};
|
|
747
|
+
const getFgAnsi = (color) => {
|
|
748
|
+
if (!colors)
|
|
749
|
+
return '';
|
|
750
|
+
return quantized(palette[color], false) ?? swatchCode(palette[color], resolvedDepth, ansi[color], 38);
|
|
751
|
+
};
|
|
752
|
+
const rawBgAnsi = (color) => {
|
|
753
|
+
if (!colors)
|
|
754
|
+
return '';
|
|
755
|
+
return quantized(palette[color], true) ?? swatchCode(palette[color], resolvedDepth, ansiBg[color], 48);
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* A tool card must keep telling pending from done from failed on every
|
|
759
|
+
* terminal, so the three fills are resolved together rather than one at a
|
|
760
|
+
* time.
|
|
761
|
+
*
|
|
762
|
+
* A palette with only sixteen backgrounds, or a 256-color cube with six
|
|
763
|
+
* levels per channel, has no entries that differ by the handful of units the
|
|
764
|
+
* truecolor swatches do: nearest-neighbour quantisation sent pending,
|
|
765
|
+
* success, and error to one and the same black. Every icon that says which
|
|
766
|
+
* state a card is in was therefore invisible on any terminal that was not
|
|
767
|
+
* truecolor.
|
|
768
|
+
*/
|
|
769
|
+
const toolFills = colors && !tc ? resolveToolFills(name, resolvedDepth, terminal) : undefined;
|
|
770
|
+
const fillsFor = (color) => toolFills !== undefined && Object.hasOwn(toolFills, color)
|
|
771
|
+
? toolFills[color]
|
|
772
|
+
: rawBgAnsi(color);
|
|
773
|
+
/**
|
|
774
|
+
* A 16- or 256-color terminal can still collapse the two *alternating* card
|
|
775
|
+
* surfaces onto one entry. The alternating card then gives up its fill instead
|
|
776
|
+
* of pretending to have a second one, which keeps consecutive calls readable.
|
|
777
|
+
*/
|
|
778
|
+
const altBg = colors && !tc && fillsFor('toolSuccessBg') === fillsFor('toolAltBg') ? BG_RESET : undefined;
|
|
779
|
+
const getBgAnsi = (color) => color === 'toolAltBg' && altBg !== undefined ? altBg : fillsFor(color);
|
|
790
780
|
const paint = (open, text, close) => colors && open !== '' ? open + text + close : text;
|
|
791
781
|
return {
|
|
782
|
+
language,
|
|
783
|
+
text: (source, values) => uiText(language, source, values),
|
|
792
784
|
name,
|
|
793
785
|
colors,
|
|
786
|
+
compactLinks: colors && compactLinks,
|
|
794
787
|
trueColor: tc,
|
|
788
|
+
depth: resolvedDepth,
|
|
789
|
+
key: [name, colors ? 1 : 0, resolvedDepth, terminalColorsKey(terminal), language, compactLinks && colors ? 1 : 0].join('|'),
|
|
795
790
|
getFgAnsi,
|
|
796
791
|
getBgAnsi,
|
|
797
792
|
fg: (color, text) => paint(getFgAnsi(color), text, FG_RESET),
|