dsh-code 1.0.6 → 1.2.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/README.en.md +123 -26
- package/README.md +124 -27
- package/bin/deepseek.mjs +283 -35
- package/cordis.patch.yml +97 -0
- package/lib/index.mjs +5008 -881
- package/lib/session-query.mjs +150 -0
- package/lib/startup.mjs +4 -4
- package/lib/{theme-DCT8Y2xf.mjs → theme-7u5Qo3dF.mjs} +657 -20
- package/lib/types/app.d.ts +106 -62
- package/lib/types/authorization-panel.d.ts +3 -3
- package/lib/types/git-workflow.d.ts +91 -2
- package/lib/types/i18n.d.ts +39 -0
- package/lib/types/index.d.ts +100 -1
- package/lib/types/input-split.d.ts +1 -1
- package/lib/types/kernel-panels.d.ts +107 -29
- package/lib/types/language-panel.d.ts +12 -0
- package/lib/types/locales/en.d.ts +450 -0
- package/lib/types/locales/zh.d.ts +9 -0
- package/lib/types/mentions.d.ts +7 -3
- package/lib/types/models.d.ts +14 -0
- package/lib/types/panel-accent.d.ts +28 -0
- package/lib/types/rainbow.d.ts +69 -0
- package/lib/types/render/animations.d.ts +42 -0
- package/lib/types/render/editor.d.ts +4 -3
- package/lib/types/render/ime-cursor.d.ts +60 -0
- package/lib/types/render/inspector.d.ts +26 -0
- package/lib/types/render/lines.d.ts +21 -1
- package/lib/types/render/markdown.d.ts +1 -1
- package/lib/types/render/projection.d.ts +130 -4
- package/lib/types/render/status.d.ts +9 -9
- package/lib/types/render/text.d.ts +6 -0
- package/lib/types/render/usage.d.ts +113 -0
- package/lib/types/session-directory.d.ts +17 -0
- package/lib/types/session-query.d.ts +92 -0
- package/lib/types/startup.d.ts +1 -1
- package/lib/types/terminal-title.d.ts +66 -0
- package/lib/types/theme-panel.d.ts +2 -2
- package/lib/types/theme.d.ts +271 -52
- package/lib/types/update-panel.d.ts +49 -0
- package/lib/types/update.d.ts +75 -0
- package/lib/types/version.d.ts +4 -3
- package/package.json +246 -90
- package/src/app.ts +1369 -509
- package/src/approval.ts +166 -166
- package/src/authorization-panel.ts +19 -16
- package/src/editor-keys.ts +371 -371
- package/src/git-workflow.ts +229 -3
- package/src/i18n.ts +68 -0
- package/src/index.ts +534 -80
- package/src/input-split.ts +3 -3
- package/src/internals.ts +5 -0
- package/src/kernel-panels.ts +554 -86
- package/src/keyboard.ts +5 -4
- package/src/language-panel.ts +53 -0
- package/src/locales/en.ts +489 -0
- package/src/locales/zh.ts +488 -0
- package/src/mentions.ts +8 -4
- package/src/models.ts +264 -212
- package/src/panel-accent.ts +41 -0
- package/src/presets.ts +1 -1
- package/src/provider-settings.ts +1 -1
- package/src/rainbow.ts +208 -0
- package/src/render/animations.ts +104 -6
- package/src/render/editor.ts +25 -24
- package/src/render/export.ts +116 -95
- package/src/render/ime-cursor.ts +147 -0
- package/src/render/inspector.ts +42 -0
- package/src/render/lines.ts +628 -415
- package/src/render/markdown.ts +15 -3
- package/src/render/projection.ts +572 -21
- package/src/render/status.ts +59 -39
- package/src/render/text.ts +14 -0
- package/src/render/tool-preview.ts +77 -77
- package/src/render/usage.ts +430 -0
- package/src/render/width.ts +2 -2
- package/src/session-directory.ts +8 -6
- package/src/session-query.ts +239 -0
- package/src/startup.ts +3 -3
- package/src/subagents.ts +229 -229
- package/src/terminal-title.ts +190 -0
- package/src/theme-panel.ts +17 -21
- package/src/theme.ts +281 -33
- package/src/update-panel.ts +256 -0
- package/src/update.ts +126 -0
- package/src/version.ts +58 -20
- package/src/whale-glyph.ts +23 -23
package/src/theme-panel.ts
CHANGED
|
@@ -11,14 +11,9 @@ import { createElement, useState, type ReactElement } from 'react'
|
|
|
11
11
|
import { Box, Text, useInput, useStdout } from 'ink'
|
|
12
12
|
import { clampScroll, panelViewport } from './render/inspector.ts'
|
|
13
13
|
import { truncateColumns } from './render/text.ts'
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const THEME_ROWS: readonly { id: ThemeName; label: string; description: string }[] = [
|
|
18
|
-
{ id: 'dark', label: 'dark', description: 'DeepSeek dark palette (default)' },
|
|
19
|
-
{ id: 'light', label: 'light', description: 'light palette for bright terminals' },
|
|
20
|
-
{ id: 'auto', label: 'auto', description: 'follow the terminal; dark until detection lands' },
|
|
21
|
-
]
|
|
14
|
+
import { panelAccent } from './panel-accent.ts'
|
|
15
|
+
import { getPalette, inkColor, THEMES, type ThemeName } from './theme.ts'
|
|
16
|
+
import { t } from './i18n.ts'
|
|
22
17
|
|
|
23
18
|
/**
|
|
24
19
|
* The /theme list: one row per theme, the current one marked with ●, the
|
|
@@ -30,37 +25,38 @@ export function ThemePanel({ current, select, close }: {
|
|
|
30
25
|
/** Theme name in force (the requested name; 'auto' included). */
|
|
31
26
|
current: ThemeName
|
|
32
27
|
/** Accept one theme name: applied immediately and persisted by the runner. */
|
|
33
|
-
select(name: ThemeName)
|
|
28
|
+
select: (name: ThemeName) => void
|
|
34
29
|
/** Close without changing the theme. */
|
|
35
|
-
close()
|
|
30
|
+
close: () => void
|
|
36
31
|
}): ReactElement {
|
|
37
32
|
const [cursor, setCursor] = useState(() => {
|
|
38
|
-
const index =
|
|
33
|
+
const index = THEMES.findIndex(theme => theme.id === current)
|
|
39
34
|
return index < 0 ? 0 : index
|
|
40
35
|
})
|
|
41
36
|
const stdout = useStdout().stdout
|
|
42
37
|
const viewport = panelViewport(stdout?.columns ?? 80, stdout?.rows ?? 30)
|
|
43
38
|
useInput((input, key) => {
|
|
44
39
|
if (key.escape || input === 'q') return close()
|
|
45
|
-
if (key.upArrow) return setCursor(value => (value +
|
|
46
|
-
if (key.downArrow) return setCursor(value => (value + 1) %
|
|
47
|
-
if (key.return) return select(
|
|
40
|
+
if (key.upArrow) return setCursor(value => (value + THEMES.length - 1) % THEMES.length)
|
|
41
|
+
if (key.downArrow) return setCursor(value => (value + 1) % THEMES.length)
|
|
42
|
+
if (key.return) return select(THEMES[cursor].id)
|
|
48
43
|
})
|
|
49
44
|
if (viewport.maxHeight === 0 || viewport.compact) {
|
|
50
|
-
return createElement(Text, { wrap: 'truncate-end' }, truncateColumns('
|
|
45
|
+
return createElement(Text, { wrap: 'truncate-end' }, truncateColumns(t('theme.compact'), viewport.contentColumns))
|
|
51
46
|
}
|
|
52
47
|
// The theme rows share the panel's body budget like every other panel: an
|
|
53
48
|
// unsliced three-row list reached terminal-height equality on short
|
|
54
49
|
// terminals, where Ink rewrites the whole Static region every frame.
|
|
55
50
|
// Reveal-cursor slicing keeps the focused row visible instead.
|
|
56
51
|
const rowBudget = Math.max(1, viewport.bodyRows)
|
|
57
|
-
const first = clampScroll(cursor,
|
|
58
|
-
const visibleThemes =
|
|
59
|
-
const hiddenThemes =
|
|
52
|
+
const first = clampScroll(cursor, THEMES.length, rowBudget)
|
|
53
|
+
const visibleThemes = THEMES.slice(first, first + rowBudget)
|
|
54
|
+
const hiddenThemes = THEMES.length - visibleThemes.length
|
|
55
|
+
const accent = panelAccent('theme', getPalette().dim, getPalette().brandBright)
|
|
60
56
|
return createElement(
|
|
61
57
|
Box,
|
|
62
|
-
{ width: viewport.outerColumns, borderStyle: 'round', borderColor: inkColor(
|
|
63
|
-
createElement(Text, { color: inkColor(
|
|
58
|
+
{ width: viewport.outerColumns, borderStyle: 'round', borderColor: inkColor(accent.border), flexDirection: 'column', paddingX: 1 },
|
|
59
|
+
createElement(Text, { color: inkColor(accent.title), wrap: 'truncate-end' }, truncateColumns(t('theme.title'), viewport.contentColumns)),
|
|
64
60
|
...visibleThemes.map((theme, index) => {
|
|
65
61
|
const selected = first + index === cursor
|
|
66
62
|
const active = theme.id === current
|
|
@@ -71,7 +67,7 @@ export function ThemePanel({ current, select, close }: {
|
|
|
71
67
|
color: selected ? inkColor(getPalette().brandBright) : undefined,
|
|
72
68
|
wrap: 'truncate-end',
|
|
73
69
|
},
|
|
74
|
-
truncateColumns(`${selected ? '› ' : ' '}${active ? '● ' : '○ '}${theme.label}${active ?
|
|
70
|
+
truncateColumns(`${selected ? '› ' : ' '}${active ? '● ' : '○ '}${t(`theme.${theme.id}.label`)}${active ? ` · ${t('theme.current')}` : ''} · ${t(`theme.${theme.id}.description`)}`, viewport.contentColumns),
|
|
75
71
|
)
|
|
76
72
|
}),
|
|
77
73
|
createElement(Text, { dimColor: true, wrap: 'truncate-end' }, truncateColumns(`↑↓ choose · enter apply · esc/q close${hiddenThemes > 0 ? ` · +${hiddenThemes} more` : ''}`, viewport.contentColumns)),
|
package/src/theme.ts
CHANGED
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
* (`packages/client/ui-theme/src/styles/design-platform.css`). Truecolor RGB
|
|
5
5
|
* rides chalk, which degrades automatically on terminals without truecolor.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Three palettes — `dark` (the default), `light`, and `prismatic` (the
|
|
8
|
+
* neon synthwave skin) — share the same token keys with different values.
|
|
9
|
+
* Painters and the palette accessor read the ACTIVE
|
|
9
10
|
* palette selected through {@link setTheme}, so a theme switch recolors every
|
|
10
|
-
* painted surface on the next render without touching call sites
|
|
11
|
-
*
|
|
12
|
-
* theme-aware integration replaces those call sites with
|
|
13
|
-
* `inkColor(getPalette().token)`.
|
|
11
|
+
* painted surface on the next render without touching call sites; consumers
|
|
12
|
+
* read colors through {@link getPalette} or the painters below only.
|
|
14
13
|
*
|
|
15
14
|
* @module @deepseek-ai/dsh-tui/theme
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
17
|
import chalk from 'chalk'
|
|
19
18
|
|
|
19
|
+
import { rainbowRoll } from './rainbow.ts'
|
|
20
|
+
|
|
20
21
|
/** One RGB triple for a palette token. */
|
|
21
22
|
export type RgbTriple = readonly [number, number, number]
|
|
22
23
|
|
|
@@ -33,15 +34,46 @@ export type ThemeToken =
|
|
|
33
34
|
| 'text'
|
|
34
35
|
| 'code'
|
|
35
36
|
| 'composerBand'
|
|
37
|
+
| 'diffAdd'
|
|
38
|
+
| 'diffDel'
|
|
39
|
+
| 'diffAddFg'
|
|
40
|
+
| 'diffDelFg'
|
|
41
|
+
| 'surface'
|
|
42
|
+
| 'prompt'
|
|
43
|
+
| 'queued'
|
|
44
|
+
| 'steered'
|
|
36
45
|
|
|
37
46
|
/** One full color palette: every token key mapped to an RGB triple. */
|
|
38
47
|
export type ThemePalette = Readonly<Record<ThemeToken, RgbTriple>>
|
|
39
48
|
|
|
40
|
-
/** Selectable theme names: dark, light, or auto (terminal-sensed). */
|
|
41
|
-
export type ThemeName = 'dark' | 'light' | 'auto'
|
|
49
|
+
/** Selectable theme names: dark, light, prismatic, rainbow, or auto (terminal-sensed). */
|
|
50
|
+
export type ThemeName = 'dark' | 'light' | 'prismatic' | 'rainbow' | 'auto'
|
|
42
51
|
|
|
43
52
|
/** Valid theme names in canonical picker order. */
|
|
44
|
-
export const THEME_NAMES: readonly ThemeName[] = ['dark', 'light', 'auto']
|
|
53
|
+
export const THEME_NAMES: readonly ThemeName[] = ['dark', 'light', 'prismatic', 'rainbow', 'auto']
|
|
54
|
+
|
|
55
|
+
/** One /theme picker row: the theme id plus its display copy. */
|
|
56
|
+
export interface ThemeDescriptor {
|
|
57
|
+
/** The selectable theme name. */
|
|
58
|
+
readonly id: ThemeName
|
|
59
|
+
/** Short row label shown in the picker. */
|
|
60
|
+
readonly label: string
|
|
61
|
+
/** One-line description shown after the label. */
|
|
62
|
+
readonly description: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every theme's picker metadata in canonical order — the single source the
|
|
67
|
+
* /theme panel rows derive from; {@link THEME_NAMES} stays the validation
|
|
68
|
+
* list. Adding a theme means adding its palette plus one row here.
|
|
69
|
+
*/
|
|
70
|
+
export const THEMES: readonly ThemeDescriptor[] = [
|
|
71
|
+
{ id: 'dark', label: 'dark', description: 'DeepSeek dark palette (default)' },
|
|
72
|
+
{ id: 'light', label: 'light', description: 'light palette for bright terminals' },
|
|
73
|
+
{ id: 'prismatic', label: 'prismatic', description: 'neon synthwave palette (violet/magenta/cyan)' },
|
|
74
|
+
{ id: 'rainbow', label: 'rainbow', description: 'randomized carnival palette (/rainbow to reroll)' },
|
|
75
|
+
{ id: 'auto', label: 'auto', description: 'follow the terminal; dark until detection lands' },
|
|
76
|
+
]
|
|
45
77
|
|
|
46
78
|
/**
|
|
47
79
|
* DeepSeek dark palette: the original TUI colors, one entry per
|
|
@@ -71,16 +103,35 @@ export const DARK_PALETTE = {
|
|
|
71
103
|
code: [125, 211, 252],
|
|
72
104
|
/** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
|
|
73
105
|
composerBand: [46, 48, 52],
|
|
106
|
+
/** Diff added-line background — Codex's muted dark green tint (#213A2B). */
|
|
107
|
+
diffAdd: [33, 58, 43],
|
|
108
|
+
/** Diff removed-line background — Codex's muted dark red tint (#4A221D). */
|
|
109
|
+
diffDel: [74, 34, 29],
|
|
110
|
+
/** Diff added-line foreground — green-500, 5.4:1 on the diffAdd tint. */
|
|
111
|
+
diffAddFg: [34, 197, 94],
|
|
112
|
+
/** Diff removed-line foreground — red-400, 4.9:1 on the diffDel tint (error's red-500 sinks to 3.6:1 on it). */
|
|
113
|
+
diffDelFg: [248, 113, 113],
|
|
114
|
+
/** Terminal background this palette is designed against; row tints blend toward it. */
|
|
115
|
+
surface: [0, 0, 0],
|
|
116
|
+
/**
|
|
117
|
+
* The three prompt-row colors, one per delivery kind. They are the palette's
|
|
118
|
+
* own accents (bright brand, warning amber, violet) rather than fixed RGBs,
|
|
119
|
+
* and every row's bar is these colors laid over {@link surface}.
|
|
120
|
+
*/
|
|
121
|
+
prompt: [103, 158, 254],
|
|
122
|
+
queued: [245, 158, 11],
|
|
123
|
+
steered: [167, 139, 250],
|
|
74
124
|
} as const satisfies ThemePalette
|
|
75
125
|
|
|
76
126
|
/**
|
|
77
127
|
* Light palette tuned for white terminals: the same token keys as dark with
|
|
78
128
|
* contrast-driven values (AA on a white background). Brand keeps its dark
|
|
79
|
-
* value (≈4.
|
|
80
|
-
*
|
|
129
|
+
* value (≈4.2:1 on white — reserved for bold/accent spans; body-size brand
|
|
130
|
+
* text uses brandBright at ≈5.4:1); the bright/mid/deep blues, muted grays,
|
|
131
|
+
* and status colors deepen so they stay legible on bright backgrounds.
|
|
81
132
|
*/
|
|
82
133
|
export const LIGHT_PALETTE = {
|
|
83
|
-
/** Primary brand blue — unchanged
|
|
134
|
+
/** Primary brand blue — unchanged design-platform value; ≈4.2:1 on white, so bold/accent spans only (body-size brand text uses brandBright). */
|
|
84
135
|
brand: [65, 118, 230],
|
|
85
136
|
/** Brighter brand blue deepened for white backgrounds (was 2.7:1). */
|
|
86
137
|
brandBright: [72, 104, 178],
|
|
@@ -102,24 +153,84 @@ export const LIGHT_PALETTE = {
|
|
|
102
153
|
code: [14, 116, 144],
|
|
103
154
|
/** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
|
|
104
155
|
composerBand: [229, 231, 235],
|
|
156
|
+
/** Diff added-line background — GitHub's pastel green (#dafbe1), Codex's light pick. */
|
|
157
|
+
diffAdd: [218, 251, 225],
|
|
158
|
+
/** Diff removed-line background — GitHub's pastel red (#ffebe9), Codex's light pick. */
|
|
159
|
+
diffDel: [255, 235, 233],
|
|
160
|
+
/** Diff added-line foreground — green-800, 6.4:1 on the pastel tint (green-700 clears 4.5:1 by a hair). */
|
|
161
|
+
diffAddFg: [22, 101, 52],
|
|
162
|
+
/** Diff removed-line foreground — red-700, 5.6:1 on the pastel tint (error's red-600 is 3.9:1). */
|
|
163
|
+
diffDelFg: [185, 28, 28],
|
|
164
|
+
/** Terminal background this palette is designed against; row tints blend toward it. */
|
|
165
|
+
surface: [255, 255, 255],
|
|
166
|
+
/**
|
|
167
|
+
* Prompt-row colors deepened for white: the amber and violet the dark theme
|
|
168
|
+
* uses sit at the AA edge on their own pastel bars, so each kind carries a
|
|
169
|
+
* value that clears 4.5:1 both on the bar and on plain white.
|
|
170
|
+
*/
|
|
171
|
+
prompt: [47, 76, 143],
|
|
172
|
+
queued: [124, 53, 10],
|
|
173
|
+
steered: [109, 40, 217],
|
|
105
174
|
} as const satisfies ThemePalette
|
|
106
175
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Prismatic palette — the neon synthwave skin (docs/prismatic-theme-design.md):
|
|
178
|
+
* electric violet replaces the brand blues, neon fuchsia carries live
|
|
179
|
+
* emphasis, neon cyan paints code, and a lavender gray dims captions. Paints
|
|
180
|
+
* on a black terminal; every value meets the same WCAG thresholds as the
|
|
181
|
+
* other palettes (body tokens ≥4.5:1, accents ≥3:1 on pure black). Semantic
|
|
182
|
+
* colors — success/error/warn and the four diff tokens — reuse the dark
|
|
183
|
+
* values verbatim so green still means added and red still means removed.
|
|
184
|
+
*/
|
|
185
|
+
export const PRISMATIC_PALETTE = {
|
|
186
|
+
/** Primary electric purple — violet-500 (#8B5CF6), 5.0:1 on black. */
|
|
187
|
+
brand: [139, 92, 246],
|
|
188
|
+
/** Live/streaming emphasis — neon fuchsia-300 (#F0ABFC), 11.9:1 on black. */
|
|
189
|
+
brandBright: [240, 171, 252],
|
|
190
|
+
/** Intermediate violet — violet-400 (#A78BFA), 7.7:1 on black. */
|
|
191
|
+
brandMid: [167, 139, 250],
|
|
192
|
+
/** Deep secondary chrome — violet-600 (#7C3AED), 3.7:1 on black (violet-700 misses 3:1). */
|
|
193
|
+
brandDeep: [124, 58, 237],
|
|
194
|
+
/** Muted captions — lavender gray (#A6A3B8), 8.6:1 on black. */
|
|
195
|
+
dim: [166, 163, 184],
|
|
196
|
+
/** Success green — unchanged from dark. */
|
|
197
|
+
success: [34, 197, 94],
|
|
198
|
+
/** Error red — unchanged from dark. */
|
|
199
|
+
error: [239, 68, 68],
|
|
200
|
+
/** Warning amber — unchanged from dark. */
|
|
201
|
+
warn: [245, 158, 11],
|
|
202
|
+
/** Default foreground text — white with a lavender cast (#F0EEF9). */
|
|
203
|
+
text: [240, 238, 249],
|
|
204
|
+
/** Inline/fenced code — neon cyan-300 (#67E8F9), 14.5:1 on black. */
|
|
205
|
+
code: [103, 232, 249],
|
|
206
|
+
/** Composer three-row band base — neutral dark gray, hue-free so wave tints read on it. */
|
|
207
|
+
composerBand: [46, 46, 52],
|
|
208
|
+
/** Diff added-line background — unchanged from dark. */
|
|
209
|
+
diffAdd: [33, 58, 43],
|
|
210
|
+
/** Diff removed-line background — unchanged from dark. */
|
|
211
|
+
diffDel: [74, 34, 29],
|
|
212
|
+
/** Diff added-line foreground — unchanged from dark. */
|
|
213
|
+
diffAddFg: [34, 197, 94],
|
|
214
|
+
/** Diff removed-line foreground — unchanged from dark. */
|
|
215
|
+
diffDelFg: [248, 113, 113],
|
|
216
|
+
/** Terminal background this palette is designed against; row tints blend toward it. */
|
|
217
|
+
surface: [0, 0, 0],
|
|
218
|
+
/** Prompt rows in the skin's own neon: fuchsia, amber, cyan. */
|
|
219
|
+
prompt: [240, 171, 252],
|
|
220
|
+
queued: [245, 158, 11],
|
|
221
|
+
steered: [103, 232, 249],
|
|
222
|
+
} as const satisfies ThemePalette
|
|
112
223
|
|
|
113
224
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* {@link getPalette} so a theme switch reaches it.
|
|
118
|
-
*
|
|
119
|
-
* @deprecated Read the active palette through {@link getPalette}; this
|
|
120
|
-
* compatibility alias is removed in the next minor release.
|
|
225
|
+
* Every STATIC palette by theme name; auto resolves through {@link resolveTheme}
|
|
226
|
+
* and rainbow is rolled per launch ({@link rainbowRoll}), so neither lives
|
|
227
|
+
* here — {@link setTheme} resolves both through the same key space.
|
|
121
228
|
*/
|
|
122
|
-
export const
|
|
229
|
+
export const PALETTES = {
|
|
230
|
+
dark: DARK_PALETTE,
|
|
231
|
+
light: LIGHT_PALETTE,
|
|
232
|
+
prismatic: PRISMATIC_PALETTE,
|
|
233
|
+
} as const satisfies Record<Exclude<ThemeName, 'auto' | 'rainbow'>, ThemePalette>
|
|
123
234
|
|
|
124
235
|
/** The theme name in force (the requested name; 'auto' included). */
|
|
125
236
|
let activeName: ThemeName = 'dark'
|
|
@@ -130,12 +241,13 @@ let activePalette: ThemePalette = DARK_PALETTE
|
|
|
130
241
|
/**
|
|
131
242
|
* Resolve a theme name to the palette actually in use. `auto` detection
|
|
132
243
|
* (OSC 11 terminal background query) is a later enhancement; until it lands,
|
|
133
|
-
* auto falls back to the dark palette
|
|
244
|
+
* auto falls back to the dark palette (prismatic and rainbow are always
|
|
245
|
+
* explicit choices, never auto-resolved).
|
|
134
246
|
* @param name - the requested theme name.
|
|
135
|
-
* @returns 'dark' or '
|
|
247
|
+
* @returns 'dark', 'light', 'prismatic', or 'rainbow' — the palette key.
|
|
136
248
|
*/
|
|
137
|
-
export function resolveTheme(name: ThemeName): 'dark' | 'light' {
|
|
138
|
-
return name === 'light' ? 'light' : 'dark'
|
|
249
|
+
export function resolveTheme(name: ThemeName): 'dark' | 'light' | 'prismatic' | 'rainbow' {
|
|
250
|
+
return name === 'light' ? 'light' : name === 'prismatic' ? 'prismatic' : name === 'rainbow' ? 'rainbow' : 'dark'
|
|
139
251
|
}
|
|
140
252
|
|
|
141
253
|
/**
|
|
@@ -146,7 +258,8 @@ export function resolveTheme(name: ThemeName): 'dark' | 'light' {
|
|
|
146
258
|
*/
|
|
147
259
|
export function setTheme(name: ThemeName): void {
|
|
148
260
|
activeName = name
|
|
149
|
-
|
|
261
|
+
const resolved = resolveTheme(name)
|
|
262
|
+
activePalette = resolved === 'rainbow' ? rainbowRoll().palette : PALETTES[resolved]
|
|
150
263
|
}
|
|
151
264
|
|
|
152
265
|
/**
|
|
@@ -164,13 +277,15 @@ export function getPalette(): ThemePalette {
|
|
|
164
277
|
}
|
|
165
278
|
|
|
166
279
|
/**
|
|
167
|
-
* Parse a persisted theme name: only
|
|
168
|
-
* else (missing, corrupt, or unknown) falls back to the dark default.
|
|
280
|
+
* Parse a persisted theme name: only names in {@link THEME_NAMES} survive;
|
|
281
|
+
* anything else (missing, corrupt, or unknown) falls back to the dark default.
|
|
169
282
|
* @param value - the raw parsed JSON value (expected string).
|
|
170
283
|
* @returns a valid theme name.
|
|
171
284
|
*/
|
|
172
285
|
export function parseThemeName(value: unknown): ThemeName {
|
|
173
|
-
return value === '
|
|
286
|
+
return typeof value === 'string' && (THEME_NAMES as readonly string[]).includes(value)
|
|
287
|
+
? (value as ThemeName)
|
|
288
|
+
: 'dark'
|
|
174
289
|
}
|
|
175
290
|
|
|
176
291
|
/** Ink `color` string for one RGB triple. */
|
|
@@ -178,6 +293,139 @@ export function inkColor(triple: RgbTriple): string {
|
|
|
178
293
|
return `rgb(${triple[0]}, ${triple[1]}, ${triple[2]})`
|
|
179
294
|
}
|
|
180
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Diff-line background as an Ink `backgroundColor` string, theme-aware and
|
|
298
|
+
* depth-gated (the Codex diff renderer's rule): 16-color terminals paint
|
|
299
|
+
* backgrounds from the saturated system palette, which drowns the text, so
|
|
300
|
+
* they keep the foreground-only look; 256-color and truecolor terminals get
|
|
301
|
+
* the palette's tint (chalk quantizes the RGB form down automatically).
|
|
302
|
+
* @param token - which diff background, added or removed lines.
|
|
303
|
+
* @returns the Ink background color, or undefined to paint foreground-only.
|
|
304
|
+
*/
|
|
305
|
+
export function diffBackground(token: 'diffAdd' | 'diffDel'): string | undefined {
|
|
306
|
+
if (chalk.level < 2) return undefined
|
|
307
|
+
return inkColor(activePalette[token])
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** One prompt-row color: the palette token whose color paints the row. */
|
|
311
|
+
export interface PromptRowTokens {
|
|
312
|
+
readonly fg: 'prompt' | 'queued' | 'steered'
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** How far one prompt-row tint leans toward its color, over the surface. */
|
|
316
|
+
const PROMPT_ROW_TINT = 0.22
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The color family one prompt row wears, chosen by how it was delivered: the
|
|
320
|
+
* ordinary brand accent, the warning amber for a queued prompt, and the
|
|
321
|
+
* palette's own third accent for a steered one. The bar behind it is derived
|
|
322
|
+
* from that same color, so every theme — including a freshly rolled rainbow —
|
|
323
|
+
* carries its own look instead of a fixed triple.
|
|
324
|
+
* @param delivery - how the prompt was delivered; undefined is an ordinary one.
|
|
325
|
+
* @returns the palette token whose color paints the row.
|
|
326
|
+
*/
|
|
327
|
+
export function promptRowTokens(delivery: 'queued' | 'steered' | undefined): PromptRowTokens {
|
|
328
|
+
if (delivery === 'queued') return { fg: 'queued' }
|
|
329
|
+
if (delivery === 'steered') return { fg: 'steered' }
|
|
330
|
+
return { fg: 'prompt' }
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Blended prompt-row background for one row color: the palette color laid
|
|
335
|
+
* over the surface the palette is designed for (dark themes over black, light
|
|
336
|
+
* over white), depth-gated exactly like {@link diffBackground} — a 16-color
|
|
337
|
+
* terminal keeps the foreground-only look rather than painting a saturated
|
|
338
|
+
* system background behind the text.
|
|
339
|
+
* @param color - the row's palette token.
|
|
340
|
+
* @returns the Ink background color, or undefined to paint foreground-only.
|
|
341
|
+
*/
|
|
342
|
+
export function rowBackground(color: PromptRowTokens['fg']): string | undefined {
|
|
343
|
+
if (chalk.level < 2) return undefined
|
|
344
|
+
const surface = activePalette.surface
|
|
345
|
+
const tint = activePalette[color]
|
|
346
|
+
const blend = (index: number): number =>
|
|
347
|
+
Math.round(surface[index] + (tint[index] - surface[index]) * PROMPT_ROW_TINT)
|
|
348
|
+
return inkColor([blend(0), blend(1), blend(2)] as RgbTriple)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* The prismatic surface ring: four neon accents panels cycle through by
|
|
353
|
+
* mount order (cyan → fuchsia → violet → lime), all ≥3:1 on black. Dark and
|
|
354
|
+
* light ignore the ring — {@link surfaceAccent} falls back to the passed-in
|
|
355
|
+
* base color so those themes stay pixel-identical.
|
|
356
|
+
*/
|
|
357
|
+
export const ACCENT_RING: readonly RgbTriple[] = [
|
|
358
|
+
[34, 211, 238],
|
|
359
|
+
[232, 121, 249],
|
|
360
|
+
[167, 139, 250],
|
|
361
|
+
[163, 230, 53],
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The prismatic flow anchors: brand violet → neon fuchsia → neon cyan. All
|
|
366
|
+
* three clear 4.5:1 on black, so a flowing foreground stays AA throughout
|
|
367
|
+
* the oscillation (render/animations.ts walks the triangle).
|
|
368
|
+
*/
|
|
369
|
+
export const FLOW_ANCHORS: readonly RgbTriple[] = [
|
|
370
|
+
[139, 92, 246],
|
|
371
|
+
[232, 121, 249],
|
|
372
|
+
[34, 211, 238],
|
|
373
|
+
]
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Whether the active theme is prismatic (the neon skin with surface rings
|
|
377
|
+
* and flowing accents).
|
|
378
|
+
*/
|
|
379
|
+
export function isPrismatic(): boolean {
|
|
380
|
+
return activeName === 'prismatic'
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** Whether the active theme is rainbow (the per-launch carnival roll). */
|
|
384
|
+
export function isRainbow(): boolean {
|
|
385
|
+
return activeName === 'rainbow'
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** The active theme's flow walk, if it has one (anchors plus phase offset). */
|
|
389
|
+
export interface ThemeFlow {
|
|
390
|
+
/** Anchor colors walked in order over one 2.4s lap. */
|
|
391
|
+
readonly anchors: readonly RgbTriple[]
|
|
392
|
+
/** Phase offset into the lap, milliseconds (0 for prismatic). */
|
|
393
|
+
readonly phaseMs: number
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* The flowing theme's anchor walk: prismatic rides the fixed violet→fuchsia→
|
|
398
|
+
* cyan triangle; rainbow rides its rolled full-spectrum anchors with a random
|
|
399
|
+
* phase; dark and light have no flow (undefined) and keep static accents.
|
|
400
|
+
*/
|
|
401
|
+
export function themeFlow(): ThemeFlow | undefined {
|
|
402
|
+
if (isPrismatic()) return { anchors: FLOW_ANCHORS, phaseMs: 0 }
|
|
403
|
+
if (isRainbow()) {
|
|
404
|
+
const roll = rainbowRoll()
|
|
405
|
+
return { anchors: roll.flowAnchors, phaseMs: roll.flowPhaseMs }
|
|
406
|
+
}
|
|
407
|
+
return undefined
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* The accent for one surface slot: prismatic rotates the {@link ACCENT_RING}
|
|
412
|
+
* by slot index; every other theme gets the caller's base color back.
|
|
413
|
+
* @param index - the slot's position in the mount-order sequence.
|
|
414
|
+
* @param base - the color to use outside prismatic (the surface's usual one).
|
|
415
|
+
* @returns the accent to paint the surface's border/title with.
|
|
416
|
+
*/
|
|
417
|
+
export function surfaceAccent(index: number, base: RgbTriple): RgbTriple {
|
|
418
|
+
if (isPrismatic()) {
|
|
419
|
+
const ring = ACCENT_RING
|
|
420
|
+
return ring[((index % ring.length) + ring.length) % ring.length]
|
|
421
|
+
}
|
|
422
|
+
if (isRainbow()) {
|
|
423
|
+
const ring = rainbowRoll().ring
|
|
424
|
+
return ring[((index % ring.length) + ring.length) % ring.length]
|
|
425
|
+
}
|
|
426
|
+
return base
|
|
427
|
+
}
|
|
428
|
+
|
|
181
429
|
/** Paint with the primary brand blue: whale, wordmark, tool names, accents. */
|
|
182
430
|
export function brand(text: string): string {
|
|
183
431
|
return chalk.rgb(...activePalette.brand)(text)
|