@bismawy/pi-arnative 0.16.1 → 0.18.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.md +25 -16
- package/extensions/index.ts +41 -0
- package/lib/active-clock.ts +91 -0
- package/lib/ansi.ts +40 -78
- package/lib/box.ts +49 -68
- package/lib/chatbox.ts +371 -0
- package/lib/color.ts +3 -31
- package/lib/compat.ts +0 -60
- package/lib/edit-diff.ts +199 -0
- package/{extensions → lib/features}/arnative.ts +96 -423
- package/{extensions/autocompact.ts → lib/features/auto-compact.ts} +30 -327
- package/{extensions → lib/features}/budget.ts +17 -242
- package/lib/features/footer.ts +2232 -0
- package/{extensions/section-headers.ts → lib/features/headers.ts} +38 -49
- package/{extensions → lib/features}/model-heal.ts +5 -28
- package/lib/features/progress-group.ts +1557 -0
- package/{extensions → lib/features}/render-cache.ts +113 -161
- package/{extensions → lib/features}/timestamps.ts +18 -94
- package/{extensions → lib/features}/todos.ts +44 -158
- package/lib/features/tools.ts +1202 -0
- package/lib/features/ui-render-tweaks.ts +606 -0
- package/lib/features/usage.ts +786 -0
- package/lib/format.ts +22 -4
- package/lib/git-status.ts +164 -0
- package/lib/list-picker.ts +1 -127
- package/lib/model-heal.ts +70 -162
- package/lib/patch.ts +0 -63
- package/lib/preset-store.ts +17 -133
- package/lib/provider-store.ts +573 -0
- package/lib/provider.ts +52 -851
- package/lib/runtime.ts +209 -0
- package/lib/shortcuts.ts +8 -58
- package/lib/spinner.ts +88 -162
- package/lib/status-widget.ts +4 -30
- package/lib/todos.ts +20 -143
- package/lib/usage-pricing.ts +143 -0
- package/lib/usage-store.ts +44 -378
- package/package.json +5 -6
- package/themes/arnative-blossom.json +0 -0
- package/themes/arnative-crimson.json +0 -0
- package/themes/arnative-cyberpunk.json +0 -0
- package/themes/arnative-dracula.json +0 -0
- package/themes/arnative-earthy.json +0 -0
- package/themes/arnative-garden.json +0 -0
- package/themes/arnative-gruvbox.json +0 -0
- package/themes/arnative-lemonade.json +0 -0
- package/themes/arnative-magical.json +0 -0
- package/themes/arnative-matrix.json +0 -0
- package/themes/arnative-neutral.json +0 -0
- package/themes/arnative-nord.json +0 -0
- package/themes/arnative-zinc.json +0 -0
- package/themes/arnative.json +0 -0
- package/CHANGELOG.md +0 -683
- package/extensions/animations.ts +0 -242
- package/extensions/footer.ts +0 -2617
- package/extensions/tools.ts +0 -2231
- package/extensions/ui-render-tweaks.ts +0 -1005
- package/extensions/usage-export.ts +0 -283
- package/extensions/usage.ts +0 -1406
- package/lib/check.ts +0 -21
- package/themes/gen-themes.mjs +0 -715
package/themes/gen-themes.mjs
DELETED
|
@@ -1,715 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Theme generator — the single source of truth for every `themes/*.json`.
|
|
4
|
-
*
|
|
5
|
-
* Each theme is a handful of parameters (accent hue, chroma, canvas lightness,
|
|
6
|
-
* neutral tint) plus optional hue overrides for the strong palettes. The
|
|
7
|
-
* renderer derives every color from a shared OKLCH ramp, so lightness and
|
|
8
|
-
* saturation stay consistent across themes and no two roles collapse to the
|
|
9
|
-
* same value by accident.
|
|
10
|
-
*
|
|
11
|
-
* Usage: node themes/gen-themes.mjs [--check]
|
|
12
|
-
*/
|
|
13
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
14
|
-
import { dirname, join } from "node:path";
|
|
15
|
-
import { fileURLToPath } from "node:url";
|
|
16
|
-
import { contrast, hexToOklch, parseOklch, oklchToRgb, toHex } from "../lib/color.ts";
|
|
17
|
-
import { assert } from "../lib/check.ts";
|
|
18
|
-
|
|
19
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
// Pi 1.2.0 moved the published schema to pi.dev; older releases validated this
|
|
21
|
-
// reference only as a string, so the new URL is safe on both.
|
|
22
|
-
const SCHEMA = "https://pi.dev/schemas/theme.schema.json";
|
|
23
|
-
|
|
24
|
-
// --- color helpers ---------------------------------------------------------
|
|
25
|
-
|
|
26
|
-
const hue = (x) => ((x % 360) + 360) % 360;
|
|
27
|
-
const round3 = (x) => +x.toFixed(3);
|
|
28
|
-
|
|
29
|
-
/** Format OKLCH after gamut-reducing chroma, so the written value renders as-is. */
|
|
30
|
-
function oklch(L, C, H) {
|
|
31
|
-
const { chroma } = oklchToRgb(L, C, H);
|
|
32
|
-
return `oklch(${+(L * 100).toFixed(1)}% ${round3(chroma)} ${Math.round(hue(H))})`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Soft tier of a color: clone at lightness `l` (default 0.82) with `scale`
|
|
37
|
-
* (default 0.5, matching `SOFT_CHROMA_SCALE` in lib/ansi.ts; the accent tier
|
|
38
|
-
* uses 0.15 at 0.94 lightness — a near-white tint — matching
|
|
39
|
-
* `SOFT_CHROMA_SCALE_ACCENT` and `SOFT_L_ACCENT`) of the GAMUT-CLAMPED
|
|
40
|
-
* chroma, hue kept. `lib/ansi.ts` softens the resolved token with these same
|
|
41
|
-
* recipes at runtime, so `*Soft` vars declared here and the extension's derived
|
|
42
|
-
* values agree. Grey-collapse is avoided because the hue is carried, not dropped.
|
|
43
|
-
*
|
|
44
|
-
* The chroma keeps five decimals (not the usual three): the soft tier multiplies
|
|
45
|
-
* it by the scale, so a coarser round-trip shifts the last hex digit and the
|
|
46
|
-
* `declare == derive` guard in ui-render-tweaks.ts fails.
|
|
47
|
-
*/
|
|
48
|
-
function soften(value, scale = 0.35, l = 0.90) {
|
|
49
|
-
const o = parseOklch(value);
|
|
50
|
-
assert(o !== null, `cannot soften a non-oklch color: ${value}`);
|
|
51
|
-
const { chroma } = oklchToRgb(l, o.C * scale, o.H);
|
|
52
|
-
return `oklch(${+(l * 100).toFixed(1)}% ${+chroma.toFixed(5)} ${Math.round(hue(o.H))})`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Chroma a box background may keep. A panel tint needs to survive the 256-color
|
|
57
|
-
* quantizer, which drops any color whose channels are within 10 levels of each other
|
|
58
|
-
* onto the grey ramp. Enforcing a floor keeps the theme's hue in both color modes.
|
|
59
|
-
*/
|
|
60
|
-
function boxChroma(chroma) {
|
|
61
|
-
return Math.min(Math.max(chroma, 0.031), 0.06);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Normalize a spec color to an oklch literal: hex is converted, oklch passes through. */
|
|
65
|
-
function colorLiteral(value) {
|
|
66
|
-
const s = String(value).trim();
|
|
67
|
-
if (s.startsWith("#")) {
|
|
68
|
-
const o = hexToOklch(s);
|
|
69
|
-
return oklch(o.L, o.C, o.H);
|
|
70
|
-
}
|
|
71
|
-
return s;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// --- shared ramps ----------------------------------------------------------
|
|
75
|
-
|
|
76
|
-
const NEUTRAL = { fg: 0.88, fgMuted: 0.72, fgDim: 0.61, fgFaint: 0.49 };
|
|
77
|
-
/**
|
|
78
|
-
* Lightness of every box background (message panel, tool cards, selection).
|
|
79
|
-
*
|
|
80
|
-
* Two hard floors decide these numbers, both measured, not chosen:
|
|
81
|
-
*
|
|
82
|
-
* 1. A pure-black terminal (`#000000`) hides anything below L≈0.22: the panel at the
|
|
83
|
-
* old L 0.19 rendered `#001817`, contrast 1.14 against black — a box nobody sees.
|
|
84
|
-
* pi's own dark theme keeps its panel at L 0.338, which is the weight below.
|
|
85
|
-
* 2. 256-color terminals (any `TERM=*-256color` without `COLORTERM`) quantize every
|
|
86
|
-
* background through `rgbToAnsi256`. Below L≈0.23 the nearest entry is the 6x6x6
|
|
87
|
-
* cube black (index 16), so the box is drawn pure black on every theme.
|
|
88
|
-
*/
|
|
89
|
-
const CANVAS = { userMessage: 0.32, customMessage: 0.30, toolPending: 0.30, toolSuccess: 0.30, toolError: 0.30, selected: 0.36, searchMatch: 0.40 };
|
|
90
|
-
// Thinking ramp. `off` must still read as a visible step above CANVAS.userMessage
|
|
91
|
-
// (floor 1.3 contrast); at the old 0.40 the brightest canvas themes dropped it to
|
|
92
|
-
// 1.24, so the ramp starts at 0.45 and keeps its monotonic spacing to `minimal`.
|
|
93
|
-
const THINKING = { off: 0.45, minimal: 0.50, low: 0.55, medium: 0.63, high: 0.71, xhigh: 0.79 };
|
|
94
|
-
const SEMANTIC = { success: 145, error: 25, warning: 85 };
|
|
95
|
-
const SYNTAX_OFFSET = { keyword: 0, func: 45, variable: -45, string: 120, number: 180, type: 90 };
|
|
96
|
-
|
|
97
|
-
/** Default hue for a role used outside `syntax*` (heading/link/label/code/bullet/border). */
|
|
98
|
-
const ACCENT_OFFSET = {
|
|
99
|
-
heading: 0,
|
|
100
|
-
link: 0,
|
|
101
|
-
label: 60,
|
|
102
|
-
code: 0,
|
|
103
|
-
bullet: 0,
|
|
104
|
-
border: 0,
|
|
105
|
-
selected: 0,
|
|
106
|
-
searchMatch: 0,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// --- theme parameters ------------------------------------------------------
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* `accent` is the seed/focus color (OKLCH, hue + reference lightness/chroma);
|
|
113
|
-
* `primary` and `secondary` define the theme's core signature and dual-tone balance;
|
|
114
|
-
* `chroma` is the normalized accent chroma.
|
|
115
|
-
* `hues` overrides the derived hue per role (keyword/func/… /heading/link/label/code/…)
|
|
116
|
-
* to keep rich multi-colored palettes (cyberpunk, synthwave, dracula, etc.) authentic.
|
|
117
|
-
*/
|
|
118
|
-
const THEMES = {
|
|
119
|
-
arnative: {
|
|
120
|
-
// Cyan & gold: strong-cyan focus, bright-gold signature (primary), school-bus
|
|
121
|
-
// yellow labels, icy-aqua links/code (tone), deep teal message panels.
|
|
122
|
-
accent: "oklch(77% 0.13 193)",
|
|
123
|
-
chroma: 0.13,
|
|
124
|
-
canvasL: 0.27,
|
|
125
|
-
neutralHue: 205,
|
|
126
|
-
neutralChroma: 0.012,
|
|
127
|
-
primary: "oklch(88.8% 0.181 96)",
|
|
128
|
-
secondary: "oklch(84.2% 0.172 86)",
|
|
129
|
-
tone: "oklch(95.1% 0.073 196)",
|
|
130
|
-
// Teal panel; CANVAS.userMessage sets its lightness so the box stays visible.
|
|
131
|
-
surfaceMsg: "oklch(19% 0.04 191)",
|
|
132
|
-
// The label tier follows the accent (soft cyan); the gold signature lives on
|
|
133
|
-
// headings and links instead, so the theme keeps two tones without the label gap.
|
|
134
|
-
borderAccent: "accentSoft",
|
|
135
|
-
headingColor: "primary",
|
|
136
|
-
linkColor: "primary",
|
|
137
|
-
codeColor: "tone",
|
|
138
|
-
bulletColor: "accent",
|
|
139
|
-
hues: { heading: 96, label: 96, link: 196, code: 196, bullet: 193, border: 86, selected: 86 },
|
|
140
|
-
},
|
|
141
|
-
"arnative-cyberpunk": {
|
|
142
|
-
// Neon fuchsia focus (#ea00d9, accent), electric cyan headings & model (#0abdc6, primary),
|
|
143
|
-
// deep purple secondary (#711c91, secondary), and deep violet panels.
|
|
144
|
-
accent: "oklch(76% 0.22 332)",
|
|
145
|
-
chroma: 0.22,
|
|
146
|
-
canvasL: 0.24,
|
|
147
|
-
neutralHue: 275,
|
|
148
|
-
neutralChroma: 0.02,
|
|
149
|
-
primary: "oklch(72.7% 0.123 201)",
|
|
150
|
-
secondary: "oklch(42.4% 0.183 314)",
|
|
151
|
-
surfaceMsg: "primary",
|
|
152
|
-
borderAccent: "accentSoft",
|
|
153
|
-
headingColor: "primary",
|
|
154
|
-
linkColor: "primary",
|
|
155
|
-
codeColor: "accent",
|
|
156
|
-
bulletColor: "accent",
|
|
157
|
-
hues: {
|
|
158
|
-
heading: 201, label: 201, link: 201, code: 332, bullet: 332, border: 201, selected: 201, searchMatch: 332,
|
|
159
|
-
keyword: 332, func: 201, variable: 332, string: 140, number: 45, type: 201,
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
"arnative-crimson": {
|
|
163
|
-
// Garnet red focus (#941b0c, accent), fiery burnt orange headings (#bc3908 adjusted to L:58%, primary),
|
|
164
|
-
// golden amber secondary (#f6aa1c, secondary), and deep red-brown panels (#361715, surfaceMsg).
|
|
165
|
-
accent: "oklch(74% 0.16 31)",
|
|
166
|
-
chroma: 0.16,
|
|
167
|
-
canvasL: 0.24,
|
|
168
|
-
neutralHue: 31,
|
|
169
|
-
neutralChroma: 0.015,
|
|
170
|
-
primary: "oklch(60.5% 0.175 37)",
|
|
171
|
-
secondary: "oklch(79.2% 0.161 75)",
|
|
172
|
-
tone: "oklch(82% 0.14 70)",
|
|
173
|
-
surfaceMsg: "primary",
|
|
174
|
-
borderAccent: "accentSoft",
|
|
175
|
-
headingColor: "primary",
|
|
176
|
-
linkColor: "tone",
|
|
177
|
-
codeColor: "tone",
|
|
178
|
-
bulletColor: "accent",
|
|
179
|
-
hues: {
|
|
180
|
-
heading: 37, label: 37, link: 70, code: 70, bullet: 31, border: 75, selected: 75, searchMatch: 31,
|
|
181
|
-
keyword: 31, func: 75, variable: 31, string: 145, number: 75, type: 70,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
"arnative-matrix": {
|
|
185
|
-
// Medium-jungle green focus (#009a22, accent), bright phosphor-green headings & model (#00ff2b, primary),
|
|
186
|
-
// lime green secondary (#36ba01, secondary), and jet-black teal panels (#0a2e36, surfaceMsg).
|
|
187
|
-
// AccentSoft provides the bright, soft matrix pastel green for footer labels.
|
|
188
|
-
accent: "oklch(74% 0.191 144)",
|
|
189
|
-
chroma: 0.19,
|
|
190
|
-
canvasL: 0.24,
|
|
191
|
-
neutralHue: 215,
|
|
192
|
-
neutralChroma: 0.015,
|
|
193
|
-
primary: "oklch(86.7% 0.287 143)",
|
|
194
|
-
secondary: "oklch(69% 0.223 140)",
|
|
195
|
-
tone: "oklch(82% 0.12 175)",
|
|
196
|
-
surfaceMsg: "primary",
|
|
197
|
-
borderAccent: "accentSoft",
|
|
198
|
-
headingColor: "primary",
|
|
199
|
-
linkColor: "tone",
|
|
200
|
-
codeColor: "tone",
|
|
201
|
-
bulletColor: "primary",
|
|
202
|
-
hues: {
|
|
203
|
-
heading: 143, label: 143, link: 175, code: 175, bullet: 143, border: 140, selected: 140, searchMatch: 144,
|
|
204
|
-
keyword: 144, func: 143, variable: 175, string: 144, number: 85, type: 175,
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
"arnative-neutral": {
|
|
208
|
-
// Grey-olive focus (#8a817c, accent), powder-blush warm headings (#e0afa0, primary),
|
|
209
|
-
// silver grey links/code & secondary (#bcb8b1, secondary), and deep warm-taupe panels.
|
|
210
|
-
accent: "oklch(76% 0.035 51)",
|
|
211
|
-
chroma: 0.035,
|
|
212
|
-
canvasL: 0.24,
|
|
213
|
-
neutralHue: 58,
|
|
214
|
-
neutralChroma: 0.008,
|
|
215
|
-
primary: "oklch(79.5% 0.061 38)",
|
|
216
|
-
secondary: "oklch(78.4% 0.011 82)",
|
|
217
|
-
tone: "oklch(82% 0.015 82)",
|
|
218
|
-
surfaceMsg: "primary",
|
|
219
|
-
borderAccent: "accentSoft",
|
|
220
|
-
headingColor: "primary",
|
|
221
|
-
linkColor: "tone",
|
|
222
|
-
codeColor: "tone",
|
|
223
|
-
bulletColor: "accent",
|
|
224
|
-
hues: {
|
|
225
|
-
heading: 38, label: 38, link: 82, code: 82, bullet: 51, border: 82, selected: 82, searchMatch: 51,
|
|
226
|
-
keyword: 51, func: 38, variable: 82, string: 97, number: 51, type: 82,
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
"arnative-zinc": {
|
|
230
|
-
// Zinc: ash grey focus (#b8bdb5, accent), cool steel headings & model (#889696, primary),
|
|
231
|
-
// dust grey footer labels & secondary (#d2d4c8, secondary), and deep slate-zinc panels.
|
|
232
|
-
accent: "oklch(79.2% 0.035 133)",
|
|
233
|
-
chroma: 0.035,
|
|
234
|
-
canvasL: 0.25,
|
|
235
|
-
neutralHue: 120,
|
|
236
|
-
neutralChroma: 0.008,
|
|
237
|
-
primary: "oklch(66.2% 0.016 197)",
|
|
238
|
-
secondary: "oklch(86.5% 0.016 114)",
|
|
239
|
-
tone: "oklch(80% 0.03 197)",
|
|
240
|
-
surfaceMsg: "primary",
|
|
241
|
-
borderAccent: "accentSoft",
|
|
242
|
-
headingColor: "primary",
|
|
243
|
-
linkColor: "tone",
|
|
244
|
-
codeColor: "tone",
|
|
245
|
-
bulletColor: "accent",
|
|
246
|
-
hues: {
|
|
247
|
-
heading: 197, label: 197, link: 197, code: 197, bullet: 133, border: 114, selected: 114, searchMatch: 133,
|
|
248
|
-
keyword: 133, func: 197, variable: 114, string: 114, number: 114, type: 197,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
"arnative-nord": {
|
|
252
|
-
// Nord polar night: dark slate canvas, polar navy focus (#3c455c adapted to L:76%, accent),
|
|
253
|
-
// frosted blue-grey headings & model (#697d97, primary), slate-purple footer labels (#777696, secondary),
|
|
254
|
-
// and deep slate-blue panels.
|
|
255
|
-
accent: "oklch(76% 0.06 268)",
|
|
256
|
-
chroma: 0.06,
|
|
257
|
-
canvasL: 0.26,
|
|
258
|
-
neutralHue: 255,
|
|
259
|
-
neutralChroma: 0.012,
|
|
260
|
-
primary: "oklch(58.3% 0.047 255)",
|
|
261
|
-
secondary: "oklch(57.8% 0.049 286)",
|
|
262
|
-
tone: "oklch(80% 0.05 194)",
|
|
263
|
-
surfaceMsg: "primary",
|
|
264
|
-
borderAccent: "accentSoft",
|
|
265
|
-
headingColor: "primary",
|
|
266
|
-
linkColor: "tone",
|
|
267
|
-
codeColor: "tone",
|
|
268
|
-
bulletColor: "accent",
|
|
269
|
-
hues: {
|
|
270
|
-
heading: 255, label: 255, link: 194, code: 194, bullet: 268, border: 286, selected: 286, searchMatch: 268,
|
|
271
|
-
keyword: 268, func: 255, variable: 286, string: 131, number: 286, type: 194,
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
"arnative-dracula": {
|
|
275
|
-
// Dracula: night canvas #282a36 with #44475a panels, pink focus #ff80bf (accent),
|
|
276
|
-
// purple headings & model name #9580ff (primary), bright yellow footer labels #ffff80 (secondary),
|
|
277
|
-
// cyan links and code #8be9fd (tone).
|
|
278
|
-
accent: "oklch(76.2% 0.168 351)",
|
|
279
|
-
chroma: 0.17,
|
|
280
|
-
canvasL: 0.28,
|
|
281
|
-
neutralHue: 278,
|
|
282
|
-
neutralChroma: 0.012,
|
|
283
|
-
primary: "oklch(67.8% 0.181 288)",
|
|
284
|
-
secondary: "oklch(97.5% 0.149 109)",
|
|
285
|
-
tone: "oklch(86% 0.09 213)",
|
|
286
|
-
surfaceMsg: "primary",
|
|
287
|
-
borderAccent: "secondary",
|
|
288
|
-
headingColor: "primary",
|
|
289
|
-
linkColor: "tone",
|
|
290
|
-
codeColor: "tone",
|
|
291
|
-
bulletColor: "accent",
|
|
292
|
-
hues: {
|
|
293
|
-
heading: 288, label: 288, link: 213, code: 213, bullet: 351, border: 109, selected: 109, searchMatch: 351,
|
|
294
|
-
keyword: 351, func: 142, variable: 288, string: 109, number: 109, type: 213,
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
"arnative-gruvbox": {
|
|
298
|
-
// Gruvbox dark: warm canvas #282828 with #3c3836 panels, yellow focus #eebd35 (accent),
|
|
299
|
-
// red headings & model #d83328 (derived from #cc241d, primary), blue-grey footer labels #458588 (secondary),
|
|
300
|
-
// aqua links and code #83a598 (tone).
|
|
301
|
-
accent: "oklch(82% 0.153 88)",
|
|
302
|
-
chroma: 0.15,
|
|
303
|
-
canvasL: 0.25,
|
|
304
|
-
neutralHue: 60,
|
|
305
|
-
neutralChroma: 0.008,
|
|
306
|
-
primary: "oklch(61% 0.203 29)",
|
|
307
|
-
secondary: "oklch(57.6% 0.066 199)",
|
|
308
|
-
tone: "oklch(78% 0.045 170)",
|
|
309
|
-
surfaceMsg: "primary",
|
|
310
|
-
borderAccent: "accentSoft",
|
|
311
|
-
headingColor: "primary",
|
|
312
|
-
linkColor: "tone",
|
|
313
|
-
codeColor: "tone",
|
|
314
|
-
bulletColor: "accent",
|
|
315
|
-
hues: {
|
|
316
|
-
heading: 29, label: 29, link: 170, code: 170, bullet: 88, border: 199, selected: 199, searchMatch: 88,
|
|
317
|
-
keyword: 29, func: 111, variable: 88, string: 83, number: 29, type: 199,
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
"arnative-magical": {
|
|
321
|
-
// Magical: vivid lavender focus (#b892ff, accent), pastel rose/pink headings & model (#ff90b3, primary),
|
|
322
|
-
// deep vivid purple secondary (#6e44ff, secondary), and deep rose-wine panels.
|
|
323
|
-
accent: "oklch(73.9% 0.157 299)",
|
|
324
|
-
chroma: 0.16,
|
|
325
|
-
canvasL: 0.24,
|
|
326
|
-
neutralHue: 300,
|
|
327
|
-
neutralChroma: 0.015,
|
|
328
|
-
primary: "oklch(78.1% 0.139 1)",
|
|
329
|
-
secondary: "oklch(55.5% 0.257 285)",
|
|
330
|
-
tone: "oklch(84% 0.10 320)",
|
|
331
|
-
surfaceMsg: "primary",
|
|
332
|
-
borderAccent: "accentSoft",
|
|
333
|
-
headingColor: "primary",
|
|
334
|
-
linkColor: "tone",
|
|
335
|
-
codeColor: "tone",
|
|
336
|
-
bulletColor: "accent",
|
|
337
|
-
hues: {
|
|
338
|
-
heading: 1, label: 1, link: 320, code: 320, bullet: 299, border: 285, selected: 285, searchMatch: 299,
|
|
339
|
-
keyword: 285, func: 1, variable: 299, string: 140, number: 285, type: 320,
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
"arnative-lemonade": {
|
|
343
|
-
// Lemonade: soft sage focus (#aac0aa, accent), warm peach-orange headings & model (#f4b886, primary),
|
|
344
|
-
// bright lime-lemon secondary (#cbe896, secondary), and deep peach-wood panels.
|
|
345
|
-
accent: "oklch(79% 0.06 148)",
|
|
346
|
-
chroma: 0.06,
|
|
347
|
-
canvasL: 0.24,
|
|
348
|
-
neutralHue: 61,
|
|
349
|
-
neutralChroma: 0.012,
|
|
350
|
-
primary: "oklch(82.6% 0.095 61)",
|
|
351
|
-
secondary: "oklch(89.1% 0.11 124)",
|
|
352
|
-
tone: "oklch(85% 0.08 124)",
|
|
353
|
-
surfaceMsg: "primary",
|
|
354
|
-
borderAccent: "accentSoft",
|
|
355
|
-
headingColor: "primary",
|
|
356
|
-
linkColor: "tone",
|
|
357
|
-
codeColor: "tone",
|
|
358
|
-
bulletColor: "accent",
|
|
359
|
-
hues: {
|
|
360
|
-
heading: 61, label: 61, link: 124, code: 124, bullet: 148, border: 124, selected: 124, searchMatch: 148,
|
|
361
|
-
keyword: 148, func: 61, variable: 124, string: 124, number: 61, type: 124,
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
"arnative-blossom": {
|
|
365
|
-
// Blossom: crimson rose focus (#dd2d4a, accent), blossom pink headings & model (#f26a8d, primary),
|
|
366
|
-
// soft petal pink secondary (#ffc2d1, secondary), and deep rose-wine panels.
|
|
367
|
-
accent: "oklch(74% 0.18 18)",
|
|
368
|
-
chroma: 0.18,
|
|
369
|
-
canvasL: 0.24,
|
|
370
|
-
neutralHue: 6,
|
|
371
|
-
neutralChroma: 0.015,
|
|
372
|
-
primary: "oklch(69.9% 0.17 6)",
|
|
373
|
-
secondary: "oklch(87.3% 0.072 2)",
|
|
374
|
-
tone: "oklch(84% 0.10 350)",
|
|
375
|
-
surfaceMsg: "primary",
|
|
376
|
-
borderAccent: "accentSoft",
|
|
377
|
-
headingColor: "primary",
|
|
378
|
-
linkColor: "tone",
|
|
379
|
-
codeColor: "tone",
|
|
380
|
-
bulletColor: "accent",
|
|
381
|
-
hues: {
|
|
382
|
-
heading: 6, label: 6, link: 350, code: 350, bullet: 18, border: 2, selected: 2, searchMatch: 18,
|
|
383
|
-
keyword: 18, func: 6, variable: 18, string: 140, number: 2, type: 350,
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
"arnative-garden": {
|
|
387
|
-
// Garden: warm earth-gold focus (#dda15e, accent), olive-moss headings & model (#6c7844 adapted from #606c38, primary),
|
|
388
|
-
// terracotta secondary (#bc6c25, secondary), and deep forest-earth panels.
|
|
389
|
-
accent: "oklch(75.3% 0.11 68)",
|
|
390
|
-
chroma: 0.11,
|
|
391
|
-
canvasL: 0.24,
|
|
392
|
-
neutralHue: 68,
|
|
393
|
-
neutralChroma: 0.012,
|
|
394
|
-
primary: "oklch(58.5% 0.076 120)",
|
|
395
|
-
secondary: "oklch(60.9% 0.13 57)",
|
|
396
|
-
tone: "oklch(80% 0.06 120)",
|
|
397
|
-
surfaceMsg: "primary",
|
|
398
|
-
borderAccent: "accentSoft",
|
|
399
|
-
headingColor: "primary",
|
|
400
|
-
linkColor: "tone",
|
|
401
|
-
codeColor: "tone",
|
|
402
|
-
bulletColor: "accent",
|
|
403
|
-
hues: {
|
|
404
|
-
heading: 120, label: 120, link: 120, code: 120, bullet: 68, border: 57, selected: 57, searchMatch: 68,
|
|
405
|
-
keyword: 68, func: 120, variable: 57, string: 140, number: 57, type: 120,
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
"arnative-earthy": {
|
|
409
|
-
// Earthy: warm tan focus (#a68a64, accent), sage-moss headings & model (#6e7653 adapted from #656d4a, primary),
|
|
410
|
-
// clay brown secondary (#7f5539, secondary), and deep forest-earth panels.
|
|
411
|
-
accent: "oklch(76% 0.063 75)",
|
|
412
|
-
chroma: 0.065,
|
|
413
|
-
canvasL: 0.24,
|
|
414
|
-
neutralHue: 75,
|
|
415
|
-
neutralChroma: 0.012,
|
|
416
|
-
primary: "oklch(58.5% 0.053 119)",
|
|
417
|
-
secondary: "oklch(48.9% 0.07 54)",
|
|
418
|
-
tone: "oklch(78% 0.04 119)",
|
|
419
|
-
surfaceMsg: "primary",
|
|
420
|
-
borderAccent: "accentSoft",
|
|
421
|
-
headingColor: "primary",
|
|
422
|
-
linkColor: "tone",
|
|
423
|
-
codeColor: "tone",
|
|
424
|
-
bulletColor: "accent",
|
|
425
|
-
hues: {
|
|
426
|
-
heading: 119, label: 119, link: 119, code: 119, bullet: 75, border: 54, selected: 54, searchMatch: 75,
|
|
427
|
-
keyword: 75, func: 119, variable: 54, string: 140, number: 54, type: 119,
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
// --- role order (matches the pi theme schema) ------------------------------
|
|
433
|
-
//
|
|
434
|
-
// Only tokens pi's schema declares may appear as keys here: since 1.2.0 the
|
|
435
|
-
// `colors` object is validated with `additionalProperties: false`, and an extra
|
|
436
|
-
// key rejects the whole theme at startup. Arnative's own colors (`accentSoft`,
|
|
437
|
-
// `primary`, `secondary`, …) live in `vars` and are referenced from these roles.
|
|
438
|
-
const ROLE_ORDER = [
|
|
439
|
-
"accent", "border", "borderAccent", "borderMuted", "success", "error", "warning",
|
|
440
|
-
"muted", "dim", "text", "thinkingText",
|
|
441
|
-
"selectedBg", "scrollbarTrack", "scrollbarThumb", "searchMatchBg", "searchMatchText",
|
|
442
|
-
"userMessageBg", "userMessageText", "customMessageBg", "customMessageText", "customMessageLabel",
|
|
443
|
-
"toolPendingBg", "toolSuccessBg", "toolErrorBg", "toolTitle", "toolOutput",
|
|
444
|
-
"mdHeading", "mdLink", "mdLinkUrl", "mdCode", "mdCodeBlock", "mdCodeBlockBorder", "mdQuote",
|
|
445
|
-
"mdQuoteBorder", "mdHr", "mdListBullet",
|
|
446
|
-
"toolDiffAdded", "toolDiffRemoved", "toolDiffContext",
|
|
447
|
-
"syntaxComment", "syntaxKeyword", "syntaxFunction", "syntaxVariable", "syntaxString",
|
|
448
|
-
"syntaxNumber", "syntaxType", "syntaxOperator", "syntaxPunctuation",
|
|
449
|
-
"thinkingOff", "thinkingMinimal", "thinkingLow", "thinkingMedium", "thinkingHigh",
|
|
450
|
-
"thinkingXhigh", "thinkingMax", "bashMode",
|
|
451
|
-
];
|
|
452
|
-
|
|
453
|
-
// --- derivation ------------------------------------------------------------
|
|
454
|
-
|
|
455
|
-
function derive(spec) {
|
|
456
|
-
const seed = parseOklch(spec.accent);
|
|
457
|
-
assert(seed !== null, `theme accent must be an oklch color: ${spec.accent}`);
|
|
458
|
-
const h = seed.H;
|
|
459
|
-
const c = spec.chroma;
|
|
460
|
-
const nh = spec.neutralHue;
|
|
461
|
-
const nc = spec.neutralChroma;
|
|
462
|
-
const base = spec.canvasL;
|
|
463
|
-
const H = { ...SYNTAX_OFFSET, ...ACCENT_OFFSET, ...(spec.hues ?? {}) };
|
|
464
|
-
const roleHue = (role) => hue(H[role]);
|
|
465
|
-
const sem = (role) => hue(SEMANTIC[role]);
|
|
466
|
-
|
|
467
|
-
const primarySeed = spec.primary ? parseOklch(spec.primary) : null;
|
|
468
|
-
const secondarySeed = spec.secondary ? parseOklch(spec.secondary) : null;
|
|
469
|
-
const primaryVal = primarySeed ? oklch(primarySeed.L, primarySeed.C, primarySeed.H) : oklch(0.82, c, h);
|
|
470
|
-
const secondaryVal = secondarySeed ? oklch(secondarySeed.L, secondarySeed.C, secondarySeed.H) : oklch(0.78, Math.min(c * 0.8, 0.12), roleHue("label"));
|
|
471
|
-
|
|
472
|
-
// Soft counterpart of the border-accent tier — the footer's label, clock and status
|
|
473
|
-
// colour. Softened from the SAME value the `borderAccent` token resolves to, because
|
|
474
|
-
// that token is what extensions read back at runtime (`softSecondaryOf` in
|
|
475
|
-
// lib/ansi.ts). One source keeps the declared value and the runtime one identical.
|
|
476
|
-
const accentBorderVal = oklch(0.82, c * 0.6, h);
|
|
477
|
-
const accentVal = oklch(0.78, c, h);
|
|
478
|
-
const accentSoftVal = soften(accentVal);
|
|
479
|
-
const borderAccentRole = spec.borderAccent ?? "accentSoft";
|
|
480
|
-
const borderAccentVal = { accentBorder: accentBorderVal, accentSoft: accentSoftVal, secondary: secondaryVal }[borderAccentRole] ?? borderAccentRole;
|
|
481
|
-
|
|
482
|
-
const vars = {
|
|
483
|
-
fg: oklch(NEUTRAL.fg, nc, nh),
|
|
484
|
-
fgMuted: oklch(NEUTRAL.fgMuted, nc, nh),
|
|
485
|
-
fgDim: oklch(NEUTRAL.fgDim, nc, nh),
|
|
486
|
-
fgFaint: oklch(NEUTRAL.fgFaint, nc, nh),
|
|
487
|
-
primary: primaryVal,
|
|
488
|
-
secondary: secondaryVal,
|
|
489
|
-
secondarySoft: soften(secondaryVal),
|
|
490
|
-
accent: accentVal,
|
|
491
|
-
accentSoft: accentSoftVal,
|
|
492
|
-
accentBorder: accentBorderVal,
|
|
493
|
-
success: oklch(0.78, Math.min(c, 0.15), sem("success")),
|
|
494
|
-
error: oklch(0.76, Math.min(c, 0.15), sem("error")),
|
|
495
|
-
warning: oklch(0.86, Math.min(c, 0.14), sem("warning")),
|
|
496
|
-
};
|
|
497
|
-
// Optional third signature tone (a color of its own, reused by roles via its var).
|
|
498
|
-
if (spec.tone) vars.tone = colorLiteral(spec.tone);
|
|
499
|
-
// Optional heading/model signature tone (e.g. cyberpunk's purple), also a var.
|
|
500
|
-
if (spec.headingTone) vars.headingTone = colorLiteral(spec.headingTone);
|
|
501
|
-
|
|
502
|
-
// The message panel: a literal/hex override, or the name of a var whose hue is
|
|
503
|
-
// reused at the box lightness — so a theme keeps its signature tint on the panel
|
|
504
|
-
// instead of hand-picking a color. Defaults to the neutral canvas tint.
|
|
505
|
-
if (typeof spec.surfaceMsg === "string" && spec.surfaceMsg in vars) {
|
|
506
|
-
const src = parseOklch(vars[spec.surfaceMsg]);
|
|
507
|
-
assert(src !== null, `surfaceMsg var must be an oklch color: ${spec.surfaceMsg}`);
|
|
508
|
-
vars.surfaceMsg = oklch(CANVAS.userMessage, boxChroma(src.C), src.H);
|
|
509
|
-
} else {
|
|
510
|
-
const src = spec.surfaceMsg ? parseOklch(spec.surfaceMsg) : null;
|
|
511
|
-
vars.surfaceMsg = src
|
|
512
|
-
? oklch(CANVAS.userMessage, boxChroma(src.C), src.H)
|
|
513
|
-
: oklch(CANVAS.userMessage, boxChroma(nc * 0.5), nh);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const accentLiteral = oklch(0.8, Math.min(c * 0.7, 0.14), h);
|
|
517
|
-
const roles = {
|
|
518
|
-
accent: "accent",
|
|
519
|
-
border: oklch(0.55, Math.min(c * 0.35, 0.08), roleHue("border")),
|
|
520
|
-
borderAccent: spec.borderAccent ?? "accentBorder",
|
|
521
|
-
borderMuted: "fgFaint",
|
|
522
|
-
success: "success",
|
|
523
|
-
error: "error",
|
|
524
|
-
warning: "warning",
|
|
525
|
-
muted: "fgMuted",
|
|
526
|
-
dim: "fgDim",
|
|
527
|
-
text: "fg",
|
|
528
|
-
thinkingText: "fgMuted",
|
|
529
|
-
|
|
530
|
-
selectedBg: oklch(CANVAS.selected, Math.min(c * 0.25, 0.06), roleHue("selected")),
|
|
531
|
-
scrollbarTrack: "fgFaint",
|
|
532
|
-
scrollbarThumb: "accentSoft",
|
|
533
|
-
searchMatchBg: oklch(CANVAS.searchMatch, Math.min(c * 0.45, 0.10), roleHue("searchMatch")),
|
|
534
|
-
searchMatchText: "fg",
|
|
535
|
-
userMessageBg: "surfaceMsg",
|
|
536
|
-
userMessageText: "fg",
|
|
537
|
-
customMessageBg: oklch(CANVAS.customMessage, boxChroma(c * 0.4), roleHue("label")),
|
|
538
|
-
customMessageText: "fg",
|
|
539
|
-
customMessageLabel: spec.labelColor ?? oklch(0.78, Math.min(c * 0.7, 0.14), roleHue("label")),
|
|
540
|
-
|
|
541
|
-
toolPendingBg: oklch(CANVAS.toolPending, boxChroma(c * 0.3), h),
|
|
542
|
-
toolSuccessBg: oklch(CANVAS.toolSuccess, boxChroma(c * 0.4), sem("success")),
|
|
543
|
-
toolErrorBg: oklch(CANVAS.toolError, boxChroma(c * 0.4), sem("error")),
|
|
544
|
-
toolTitle: "fg",
|
|
545
|
-
toolOutput: "fgMuted",
|
|
546
|
-
|
|
547
|
-
mdHeading: spec.headingColor ?? oklch(0.88, Math.min(c * 0.6, 0.14), roleHue("heading")),
|
|
548
|
-
mdLink: spec.linkColor ?? oklch(0.8, Math.min(c * 0.7, 0.14), roleHue("link")),
|
|
549
|
-
mdLinkUrl: "fgDim",
|
|
550
|
-
mdCode: spec.codeColor ?? accentLiteral,
|
|
551
|
-
mdCodeBlock: "success",
|
|
552
|
-
mdCodeBlockBorder: "fgMuted",
|
|
553
|
-
mdQuote: "fgMuted",
|
|
554
|
-
mdQuoteBorder: "fgMuted",
|
|
555
|
-
mdHr: spec.hrColor ?? "fgFaint",
|
|
556
|
-
mdListBullet: spec.bulletColor ?? accentLiteral,
|
|
557
|
-
|
|
558
|
-
toolDiffAdded: "success",
|
|
559
|
-
toolDiffRemoved: "error",
|
|
560
|
-
toolDiffContext: "fgMuted",
|
|
561
|
-
|
|
562
|
-
syntaxComment: "fgDim",
|
|
563
|
-
syntaxKeyword: spec.keywordColor ?? accentLiteral,
|
|
564
|
-
syntaxFunction: oklch(0.86, Math.min(c * 0.8, 0.16), roleHue("func")),
|
|
565
|
-
syntaxVariable: oklch(0.84, Math.min(c * 0.55, 0.14), roleHue("variable")),
|
|
566
|
-
syntaxString: oklch(0.82, Math.min(c * 0.7, 0.16), roleHue("string")),
|
|
567
|
-
syntaxNumber: oklch(0.8, Math.min(c * 0.7, 0.15), roleHue("number")),
|
|
568
|
-
syntaxType: oklch(0.8, Math.min(c * 0.8, 0.16), roleHue("type")),
|
|
569
|
-
syntaxOperator: "fg",
|
|
570
|
-
syntaxPunctuation: "fgMuted",
|
|
571
|
-
|
|
572
|
-
thinkingOff: oklch(spec.thinkingOff ?? THINKING.off, nc, nh),
|
|
573
|
-
thinkingMinimal: oklch(THINKING.minimal, c * 0.25, h),
|
|
574
|
-
thinkingLow: oklch(THINKING.low, c * 0.4, h),
|
|
575
|
-
thinkingMedium: oklch(THINKING.medium, c * 0.6, h),
|
|
576
|
-
thinkingHigh: oklch(THINKING.high, c * 0.8, h),
|
|
577
|
-
thinkingXhigh: oklch(THINKING.xhigh, c, h),
|
|
578
|
-
thinkingMax: "accent",
|
|
579
|
-
|
|
580
|
-
bashMode: "success",
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
const exp = {
|
|
584
|
-
pageBg: oklch(base - 0.06, nc, nh),
|
|
585
|
-
cardBg: oklch(base - 0.03, nc, nh),
|
|
586
|
-
infoBg: oklch(base + 0.05, Math.min(c * 0.25, 0.06), h),
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
// Roles must match ROLE_ORDER exactly and each value must be a var name or a literal.
|
|
590
|
-
const missing = ROLE_ORDER.filter((n) => !(n in roles));
|
|
591
|
-
const extra = Object.keys(roles).filter((n) => !ROLE_ORDER.includes(n));
|
|
592
|
-
assert(missing.length === 0 && extra.length === 0, `roles vs ROLE_ORDER: missing [${missing}] extra [${extra}]`);
|
|
593
|
-
for (const [name, value] of Object.entries(roles)) {
|
|
594
|
-
assert(/^oklch\(/.test(value) || value in vars, `role ${name} is neither a var nor an oklch literal: ${value}`);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// Distinct vars must stay visually distinct (roles may alias on purpose).
|
|
598
|
-
const seen = new Map();
|
|
599
|
-
for (const [name, value] of Object.entries(vars)) {
|
|
600
|
-
const v = parseOklch(value);
|
|
601
|
-
assert(v !== null, `var ${name} is not an oklch color: ${value}`);
|
|
602
|
-
const { r, g, b } = oklchToRgb(v.L, v.C, v.H);
|
|
603
|
-
const rgb = `${r},${g},${b}`;
|
|
604
|
-
if (seen.has(rgb)) throw new Error(`vars ${seen.get(rgb)} and ${name} resolve to the same color`);
|
|
605
|
-
seen.set(rgb, name);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
return { vars, roles, exp };
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// --- dual-tone guard -------------------------------------------------------
|
|
612
|
-
|
|
613
|
-
/** Hues between two colours, 0..180. */
|
|
614
|
-
const hueGap = (a, b) => {
|
|
615
|
-
const d = Math.abs(hue(a) - hue(b)) % 360;
|
|
616
|
-
return d > 180 ? 360 - d : d;
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
/** How far the label tier must sit from the accent. Every theme draws the footer, the
|
|
620
|
-
* selected row and the detail line on `borderAccent`; when that shares the accent's hue
|
|
621
|
-
* the whole UI reads as one colour, which is how six themes ended up mono-tone. */
|
|
622
|
-
const MIN_HUE_GAP = { default: 25, "arnative": 0, "arnative-cyberpunk": 0, "arnative-crimson": 0, "arnative-matrix": 0, "arnative-neutral": 0, "arnative-gruvbox": 0, "arnative-nord": 0, "arnative-zinc": 0, "arnative-magical": 0, "arnative-lemonade": 0, "arnative-blossom": 0, "arnative-garden": 0, "arnative-earthy": 0 };
|
|
623
|
-
|
|
624
|
-
function assertDualTone(name, { vars, roles, exp }) {
|
|
625
|
-
const accent = parseOklch(vars.accent);
|
|
626
|
-
const labelValue = roles.borderAccent in vars ? vars[roles.borderAccent] : roles.borderAccent;
|
|
627
|
-
const label = parseOklch(String(labelValue));
|
|
628
|
-
assert(accent !== null && label !== null, `${name}: accent and borderAccent must both be oklch`);
|
|
629
|
-
const min = MIN_HUE_GAP[name] ?? MIN_HUE_GAP.default;
|
|
630
|
-
const gap = hueGap(accent.H, label.H);
|
|
631
|
-
assert(
|
|
632
|
-
gap >= min,
|
|
633
|
-
`${name}: accent ${Math.round(accent.H)} and borderAccent ${Math.round(label.H)} are ${gap.toFixed(0)}° apart, need ${min}°`,
|
|
634
|
-
);
|
|
635
|
-
// A label tier without chroma is grey text, not a second tone.
|
|
636
|
-
const minChroma = name === "arnative-neutral" || name === "arnative-zinc" ? 0.01 : 0.02;
|
|
637
|
-
assert(label.C >= minChroma, `${name}: borderAccent chroma ${label.C} is too low to read as a tone`);
|
|
638
|
-
// And it has to stand off the canvas it is drawn on.
|
|
639
|
-
const ratio = contrast(toHex(labelValue), toHex(exp.pageBg));
|
|
640
|
-
assert(ratio >= 3, `${name}: borderAccent contrast ${ratio.toFixed(2)} on pageBg is too low`);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// --- cross-theme distinctness ----------------------------------------------
|
|
644
|
-
|
|
645
|
-
/** Two themes may not share a signature colour: the picker previews one at a time, so a
|
|
646
|
-
* repeated accent or footer tier makes two palettes look like the same theme. */
|
|
647
|
-
function assertDistinctThemes(themes) {
|
|
648
|
-
const seen = new Map();
|
|
649
|
-
for (const [name, { vars, roles }] of themes) {
|
|
650
|
-
const label = roles.borderAccent in vars ? vars[roles.borderAccent] : roles.borderAccent;
|
|
651
|
-
for (const [tier, value] of [
|
|
652
|
-
["accent", vars.accent],
|
|
653
|
-
["borderAccent", label],
|
|
654
|
-
]) {
|
|
655
|
-
const hex = toHex(value);
|
|
656
|
-
const other = seen.get(hex);
|
|
657
|
-
assert(other === undefined, `${name}.${tier} ${hex} repeats ${other}`);
|
|
658
|
-
seen.set(hex, `${name}.${tier}`);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// --- rendering -------------------------------------------------------------
|
|
664
|
-
|
|
665
|
-
function render(name, { vars, roles, exp }) {
|
|
666
|
-
const lines = [
|
|
667
|
-
"{",
|
|
668
|
-
`\t"$schema": ${JSON.stringify(SCHEMA)},`,
|
|
669
|
-
`\t"name": ${JSON.stringify(name)},`,
|
|
670
|
-
`\t"appearance": "dark",`,
|
|
671
|
-
`\t"vars": {`,
|
|
672
|
-
];
|
|
673
|
-
const entries = Object.entries(vars);
|
|
674
|
-
entries.forEach(([k, v], i) => lines.push(`\t\t${JSON.stringify(k)}: ${JSON.stringify(v)}${i < entries.length - 1 ? "," : ""}`));
|
|
675
|
-
lines.push("\t},", `\t"colors": {`);
|
|
676
|
-
const roleEntries = ROLE_ORDER.map((r) => [r, roles[r]]);
|
|
677
|
-
const blank = new Set(["thinkingText", "toolOutput", "mdListBullet", "syntaxPunctuation"]);
|
|
678
|
-
roleEntries.forEach(([k, v], i) => {
|
|
679
|
-
if (blank.has(k) && i > 0) lines.push("");
|
|
680
|
-
lines.push(`\t\t${JSON.stringify(k)}: ${JSON.stringify(v)}${i < roleEntries.length - 1 ? "," : ""}`);
|
|
681
|
-
});
|
|
682
|
-
lines.push("\t},", `\t"export": {`);
|
|
683
|
-
const expEntries = Object.entries(exp);
|
|
684
|
-
expEntries.forEach(([k, v], i) => lines.push(`\t\t${JSON.stringify(k)}: ${JSON.stringify(v)}${i < expEntries.length - 1 ? "," : ""}`));
|
|
685
|
-
lines.push("\t}", "}");
|
|
686
|
-
return lines.join("\n") + "\n";
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// --- main ------------------------------------------------------------------
|
|
690
|
-
|
|
691
|
-
const check = process.argv.includes("--check");
|
|
692
|
-
let drifted = 0;
|
|
693
|
-
const built = new Map();
|
|
694
|
-
for (const [name, spec] of Object.entries(THEMES)) {
|
|
695
|
-
const derived = derive({ ...spec, name });
|
|
696
|
-
assertDualTone(name, derived);
|
|
697
|
-
built.set(name, derived);
|
|
698
|
-
const content = render(name, derived);
|
|
699
|
-
const file = join(HERE, `${name}.json`);
|
|
700
|
-
if (check) {
|
|
701
|
-
const current = await readFile(file, "utf8").catch(() => "");
|
|
702
|
-
if (current !== content) {
|
|
703
|
-
console.error(`✗ ${name}.json is stale — run: node themes/gen-themes.mjs`);
|
|
704
|
-
drifted++;
|
|
705
|
-
}
|
|
706
|
-
} else {
|
|
707
|
-
await writeFile(file, content);
|
|
708
|
-
console.log(`✓ ${name}.json`);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
assertDistinctThemes(built);
|
|
712
|
-
if (check) {
|
|
713
|
-
if (drifted) process.exit(1);
|
|
714
|
-
console.log(`✓ ${Object.keys(THEMES).length} themes in sync with gen-themes.mjs`);
|
|
715
|
-
}
|