aegiscode 7.0.14 → 7.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +3 -2
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2932
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3020
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -4003
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/fingerprint.js +1 -592
  28. package/src/format.js +1 -259
  29. package/src/fuzzy.js +1 -119
  30. package/src/history.js +1 -401
  31. package/src/init.js +1 -175
  32. package/src/input.js +1 -139
  33. package/src/keys.js +1 -183
  34. package/src/markdown.js +1 -306
  35. package/src/models.js +1 -487
  36. package/src/naming.js +1 -229
  37. package/src/overlays.js +1 -461
  38. package/src/panels.js +1 -1418
  39. package/src/ping.js +1 -226
  40. package/src/presence.js +1 -238
  41. package/src/render.js +1 -515
  42. package/src/screen.js +1 -518
  43. package/src/screens.js +1 -896
  44. package/src/secret.js +1 -59
  45. package/src/securefs.js +1 -359
  46. package/src/settings.js +1 -155
  47. package/src/shared.js +1 -52
  48. package/src/sharedpaths.js +1 -53
  49. package/src/signup.js +1 -156
  50. package/src/summarize.js +1 -95
  51. package/src/sysdiag.js +1 -585
  52. package/src/system.js +1 -40
  53. package/src/theme.js +1 -570
  54. package/src/title.js +1 -220
  55. package/src/todos.js +1 -115
  56. package/src/tokens.js +1 -263
  57. package/src/topup.js +1 -210
  58. package/src/update.js +1 -181
  59. package/vendor/client/aegis.js +1 -2179
  60. package/vendor/client/attest.js +1 -442
  61. package/vendor/client/authorship-key.js +1 -410
  62. package/vendor/client/auto-provision.js +1 -134
  63. package/vendor/client/brain-catalog.js +1 -268
  64. package/vendor/client/byok-catalog.js +1 -230
  65. package/vendor/client/credentials.js +1 -494
  66. package/vendor/client/device-fingerprint.js +1 -141
  67. package/vendor/client/drive-connect.js +1 -110
  68. package/vendor/client/drive-upload.js +1 -174
  69. package/vendor/client/env-file.js +1 -1273
  70. package/vendor/client/fingerprint.js +1 -1064
  71. package/vendor/client/foreign-memory.js +1 -669
  72. package/vendor/client/google-signin.js +1 -133
  73. package/vendor/client/hooks.js +1 -430
  74. package/vendor/client/model-discovery.js +1 -373
  75. package/vendor/client/platform.js +1 -937
  76. package/vendor/client/prefs.js +1 -351
  77. package/vendor/client/presence-constants.js +1 -107
  78. package/vendor/client/presence.js +1 -438
  79. package/vendor/client/record-vault.js +3 -1055
  80. package/vendor/client/session-store.js +1 -548
  81. package/vendor/client/topup.js +1 -297
  82. package/vendor/client/touch.js +1 -458
  83. package/vendor/client/update.js +1 -704
  84. package/vendor/client/user-models.js +1 -381
  85. package/vendor/desktop/lib/local/agents.js +1 -105
  86. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  87. package/vendor/desktop/lib/local/claude-pro.js +1 -993
  88. package/vendor/desktop/lib/local/context.js +1 -95
  89. package/vendor/desktop/lib/local/engine.js +1 -3301
  90. package/vendor/desktop/lib/local/entitlement.js +1 -660
  91. package/vendor/desktop/lib/local/git-scope.js +1 -228
  92. package/vendor/desktop/lib/local/local.js +1 -2135
  93. package/vendor/desktop/lib/local/prompt.js +1 -275
  94. package/vendor/desktop/lib/local/queue.js +1 -560
  95. package/vendor/desktop/lib/local/session-rounds.js +1 -208
  96. package/vendor/desktop/lib/local/shell.js +1 -680
  97. package/vendor/desktop/lib/local/tools.js +1 -1238
  98. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  99. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  100. package/vendor/desktop/lib/settings.js +1 -890
  101. package/vendor/desktop/renderer/usage.js +1 -1239
  102. package/vendor/hosts/install.js +1 -638
  103. package/vendor/hosts/openai-shim.js +1 -515
  104. package/vendor/hosts/spec.js +1 -164
  105. package/vendor/hosts/targets.js +1 -346
  106. package/vendor/mcp/server.js +1 -221
  107. package/vendor/mcp/tools.js +1 -408
  108. package/vendor/one/src/child.js +1 -285
  109. package/vendor/one/src/permissions.js +1 -369
package/src/theme.js CHANGED
@@ -1,572 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Design tokens — the upstream engine design system, adopted wholesale, and
10
- * resolved through the terminal's capabilities (`caps.js`) rather than the
11
- * platform the process happens to run on.
12
- *
13
- * Every colour value below is copied verbatim from the upstream engine's theme,
14
- * which extracted them from the live ANSI stream of Claude Code: gold 255,193,7
15
- * · coral 215,119,87 · lavender 177,185,249 · blue 120,160,250 · green 78,186,101
16
- * · red 220,90,90 · gray 153,153,153 · dim 80,80,80. `test/cli-conformance.test.mjs`
17
- * pins them to the upstream engine's source and reads them back out of a truecolor
18
- * SGR prefix, so the design cannot drift.
19
- *
20
- * What DOES change per terminal is how those triples reach the screen:
21
- *
22
- * · `RGB()`/`BG()` go through `caps.rgb()/caps.bg()`, which emit 24-bit SGR,
23
- * the 256-colour cube, the 16 ANSI slots, or nothing at all. Truecolor is
24
- * the default on every platform, because the terminals we ship to all pass
25
- * 24-bit SGR through and a terminal that cannot downsamples it itself —
26
- * which is the correct authority for the decision. Narrowing the palette is
27
- * an explicit request (`AEGIS_COLOR=1|2`, `FORCE_COLOR`, `NO_COLOR`,
28
- * `AEGIS_FORCE_TRUECOLOR=0`), never an inference from `TERM` or the OS.
29
- * · `glyphsFor()` is a function of the resolved capabilities, so every host
30
- * gets the same ❯ ⎿ ✻ ✦ set; the ASCII stand-ins appear only when the user
31
- * asks for them (`AEGIS_ART=ascii`, `--ascii`).
32
- *
33
- * Both are re-materialised when the capabilities change (`onCapsChange`), so
34
- * `aegiscode --ascii`, `--no-color` and the `/terminal` command take effect on
35
- * the palette and glyph table of a *running* session — the exported objects are
36
- * mutated in place rather than replaced, because renderers hold references to
37
- * them (`const { C } = require('./theme.js')`).
38
- *
39
- * Zero dependencies: SGR escapes are hand-built, like the rest of this repo.
40
- */
41
-
42
- const { caps, detect, onCapsChange, rgb, bg } = require('./caps.js');
43
-
44
- // The stencil is the mark's single source of truth for its own runes — this
45
- // file resolves `star` through it rather than restating the platform rule.
46
- // `art.js` requires only `caps.js`, so this import cannot cycle.
47
- const { STAR, stencilGlyph } = require('./art.js');
48
-
49
- const RESET = '\x1b[0m';
50
- const BOLD = '\x1b[1m';
51
- const DIM = '\x1b[2m';
52
- const ITALIC = '\x1b[3m';
53
- const UNDER = '\x1b[4m';
54
- const BOLD_OFF = '\x1b[22m';
55
- const ITALIC_OFF = '\x1b[23m';
56
- const UNDER_OFF = '\x1b[24m';
57
- const RESET_FG = '\x1b[39m';
58
- const RESET_BG = '\x1b[49m';
59
-
60
- /** Truecolour foreground SGR (or the best the terminal can do — see caps.js). */
61
- const RGB = (r, g, b) => rgb(r, g, b);
62
- /** Truecolour background SGR (or the best the terminal can do). */
63
- const BG = (r, g, b) => bg(r, g, b);
64
-
65
- // ── the palettes ─────────────────────────────────────────────────────────────
66
- // Built by functions and written into stable objects: `Object.assign` on every
67
- // capability change keeps the key set identical (the conformance guard pins
68
- // `Object.keys(C)`) while the escapes follow the new depth.
69
-
70
- /** The dark palette. Role names match the upstream engine exactly. */
71
- const C = {};
72
- /** Light-theme approximations, true to the dark palette's hue mapping. */
73
- const LIGHT = {};
74
- /** The colourblind-friendly dark/light variants. */
75
- const CB_DARK = {};
76
- const CB_LIGHT = {};
77
- /** The 16-colour ANSI-only variants. */
78
- const ANSI_DARK = {};
79
- const ANSI_LIGHT = {};
80
-
81
- function buildDark() {
82
- return {
83
- gold: RGB(255, 193, 7), // header line, accents, welcome frame
84
- coral: RGB(215, 119, 87), // "Welcome to ..." title
85
- lavender: RGB(177, 185, 249), // selection cursor ❯, links, focused option
86
- blue: RGB(120, 160, 250), // selected palette row
87
- green: RGB(78, 186, 101), // checkmarks, success, diff additions
88
- red: RGB(220, 90, 90), // diff removals, errors
89
- gray: RGB(153, 153, 153), // secondary text, menu numbers, hints
90
- dim: RGB(80, 80, 80), // ╌ divider lines
91
- white: RGB(255, 255, 255), // primary text, spinner glyphs
92
- black: RGB(30, 30, 30), // code-block background
93
- darkBg: RGB(20, 20, 20), // theme card background
94
- };
95
- }
96
-
97
- function buildLight() {
98
- return {
99
- gold: RGB(180, 130, 0),
100
- coral: RGB(190, 100, 70),
101
- lavender: RGB(120, 130, 220),
102
- blue: RGB(70, 110, 220),
103
- green: RGB(60, 150, 80),
104
- red: RGB(200, 60, 60),
105
- gray: RGB(110, 110, 110),
106
- dim: RGB(170, 170, 170),
107
- white: RGB(40, 40, 40),
108
- black: RGB(245, 245, 245),
109
- darkBg: RGB(255, 255, 255),
110
- };
111
- }
112
-
113
- function buildCbDark() {
114
- return {
115
- ...buildDark(),
116
- // The red/green pair — the one that carries meaning in diffs and errors —
117
- // is remapped to the blue/orange axis, which stays distinguishable under
118
- // deuteranopia and protanopia.
119
- green: RGB(86, 182, 194),
120
- red: RGB(255, 146, 43),
121
- gold: RGB(255, 203, 71),
122
- };
123
- }
124
-
125
- function buildCbLight() {
126
- return {
127
- ...buildLight(),
128
- green: RGB(30, 130, 145),
129
- red: RGB(200, 100, 20),
130
- gold: RGB(150, 110, 0),
131
- };
132
- }
133
-
134
- // 16-colour SGR foregrounds. Written as escape strings rather than RGB triples
135
- // because the variant exists precisely to hand the decision to the terminal.
136
- const A = (n) => (caps().color ? `\x1b[${n}m` : '');
137
-
138
- function buildAnsiDark() {
139
- return {
140
- gold: A(93), coral: A(91), lavender: A(94), blue: A(94), green: A(92),
141
- red: A(91), gray: A(90), dim: A(90), white: A(97), black: A(40),
142
- darkBg: caps().color ? '\x1b[48;5;236m' : '',
143
- };
144
- }
145
-
146
- function buildAnsiLight() {
147
- return {
148
- gold: A(33), coral: A(31), lavender: A(34), blue: A(34), green: A(32),
149
- red: A(31), gray: A(90), dim: A(37), white: A(30), black: A(47),
150
- darkBg: caps().color ? '\x1b[48;5;254m' : '',
151
- };
152
- }
153
-
154
- /**
155
- * Diff palette for edit blocks in the transcript — Monokai Extended, taken
156
- * verbatim from the theme picker's preview (also `renderDiffPreview` in
157
- * the upstream engine's markdown renderer) so the two can never drift apart: dim
158
- * red/green backgrounds per row, the bright variant for the token that
159
- * actually changed inside the row, and the monokai syntax colors for the code
160
- * itself.
161
- *
162
- * A SEPARATE export, not keys added to `C`/`LIGHT`: `test/cli-conformance.test.mjs`
163
- * pins `Object.keys(C)` to exactly the eleven DEV_DARK role names, so a diff
164
- * entry folded into the palette would fail the conformance guard. This is the
165
- * same reason `DIFF` is its own object in the engine.
166
- */
167
- const DIFF = {};
168
- const DIFF_LIGHT = {};
169
-
170
- function buildDiff() {
171
- return {
172
- delFg: RGB(220, 90, 90),
173
- delBg: BG(61, 1, 0),
174
- delHiFg: RGB(248, 248, 242),
175
- delHiBg: BG(92, 2, 0),
176
- addFg: RGB(80, 200, 80),
177
- addBg: BG(2, 40, 0),
178
- addHiFg: RGB(255, 255, 255),
179
- addHiBg: BG(4, 71, 0),
180
- codeFg: RGB(248, 248, 242),
181
- gutter: RGB(120, 120, 120),
182
- kw: RGB(102, 217, 239),
183
- fn: RGB(166, 226, 46),
184
- str: RGB(230, 219, 116),
185
- num: RGB(174, 129, 255),
186
- comment: RGB(117, 113, 94),
187
- };
188
- }
189
-
190
- /**
191
- * The light-theme diff palette. Monokai's dark backgrounds on a light terminal
192
- * are unreadable, so the row backgrounds invert to a pale tint and the code
193
- * keeps its hue mapping from the dark set — the same relationship `LIGHT`
194
- * already has to `C`.
195
- */
196
- function buildDiffLight() {
197
- return {
198
- delFg: RGB(160, 40, 40),
199
- delBg: BG(255, 235, 233),
200
- delHiFg: RGB(90, 0, 0),
201
- delHiBg: BG(255, 205, 200),
202
- addFg: RGB(30, 130, 40),
203
- addBg: BG(232, 250, 232),
204
- addHiFg: RGB(0, 80, 0),
205
- addHiBg: BG(195, 240, 195),
206
- codeFg: RGB(40, 40, 40),
207
- gutter: RGB(150, 150, 150),
208
- kw: RGB(0, 120, 160),
209
- fn: RGB(80, 140, 0),
210
- str: RGB(150, 110, 0),
211
- num: RGB(120, 60, 200),
212
- comment: RGB(140, 140, 130),
213
- };
214
- }
215
-
216
- const THEMES = { dark: C, light: LIGHT };
217
-
218
- /**
219
- * The two extra palette families the reference's theme picker offers.
220
- *
221
- * `cb` is the colourblind-friendly variant (see `buildCbDark`). `ansi` uses
222
- * the terminal's own 16-colour table, for terminals whose truecolour output is
223
- * remapped anyway — the whole point being that the *terminal* decides, not us.
224
- */
225
- /**
226
- * The theme picker's table, copied from the upstream engine's screens THEMES
227
- * (names and notes verbatim). `light` is the flag the reference sets on commit
228
- * (`ctx.light = sel === 2 || sel === 4 || sel === 6`); `palette` is what this
229
- * client resolves the row to.
230
- *
231
- * Row 0 carries the reference's own note — "(match terminal)" — and now does
232
- * what it says: `terminalIsLight()` reads the background the terminal reports
233
- * about itself (`caps().background`, from `COLORFGBG`/`TERM_BACKGROUND`, see
234
- * `caps.js`) and resolves the row to `LIGHT` or `C` accordingly. Its `light`
235
- * field is therefore the *fallback* used when nothing is reported, not the
236
- * answer; `themeIsLight()` is the function that decides.
237
- */
238
- const THEME_TABLE = [
239
- { name: 'Auto', note: '(match terminal)', light: false, palette: C },
240
- { name: 'Dark mode', note: '', light: false, palette: C },
241
- { name: 'Light mode', note: '', light: true, palette: LIGHT },
242
- { name: 'Dark mode', note: '(colorblind-friendly)', light: false, palette: CB_DARK },
243
- { name: 'Light mode', note: '(colorblind-friendly)', light: true, palette: CB_LIGHT },
244
- { name: 'Dark mode', note: '(ANSI colors only)', light: false, palette: ANSI_DARK },
245
- { name: 'Light mode', note: '(ANSI colors only)', light: true, palette: ANSI_LIGHT },
246
- ];
247
-
248
- /** The picker row that means "match terminal" rather than "be dark/light". */
249
- const AUTO_THEME_INDEX = 0;
250
-
251
- /**
252
- * True when the terminal's own background is light.
253
- *
254
- * The dark palette's primary text is `RGB(255,255,255)`: drawn over a light
255
- * terminal it is white-on-white, which is a blank screen rather than a
256
- * mis-styled one. So this is the one probe that decides between two *legible*
257
- * palettes — it never changes the mark, the glyph set, the colour depth or the
258
- * control sequences, and it is never inferred from `process.platform`.
259
- *
260
- * @param {object} [c] a caps object; defaults to the live process's
261
- */
262
- function terminalIsLight(c = caps()) {
263
- return c.background === 'light';
264
- }
265
-
266
- /**
267
- * Resolve a picker row to the palette family it should draw with — the single
268
- * place "is this row light?" is answered, so a ctx whose `light` flag was
269
- * seeded from the row index can never disagree with the palette `themeOf` picks.
270
- *
271
- * Explicit rows answer from their own flag; row 0 (Auto) asks the terminal; an
272
- * index outside the table falls back to dark, which is what `themeOf` did with
273
- * an unknown index before this existed.
274
- *
275
- * @param {number} themeIndex a row index from THEME_TABLE
276
- * @param {object} [c] a caps object; defaults to the live process's
277
- */
278
- function themeIsLight(themeIndex, c = caps()) {
279
- const row = THEME_TABLE[themeIndex];
280
- if (!row) return false;
281
- if (themeIndex === AUTO_THEME_INDEX) return terminalIsLight(c);
282
- return !!row.light;
283
- }
284
-
285
- /**
286
- * The sibling row: the same palette family at the other brightness.
287
- *
288
- * Row 0 (Auto) has no sibling — it is not a brightness, it is a question. The
289
- * pairs are the picker's own (`Dark mode`/`Light mode`, and the colorblind and
290
- * ANSI families likewise), so a blind choice of "colorblind-friendly" survives
291
- * a correction and only its brightness changes.
292
- */
293
- const SIBLING_THEME_INDEX = [0, 2, 1, 4, 3, 6, 5];
294
-
295
- /** True when a picker row's brightness is the opposite of the terminal's. */
296
- function themeContradicts(themeIndex, c = caps()) {
297
- const row = THEME_TABLE[themeIndex];
298
- if (!row || themeIndex === AUTO_THEME_INDEX) return false;
299
- // Without a report there is nothing to contradict. `background` is then the
300
- // dark default and the stored row stands: overriding a preference on the
301
- // strength of a *default* would be the same class of bug as reading a
302
- // guessed background as if it were evidence.
303
- if (!c || !c.backgroundKnown) return false;
304
- return !!row.light !== (c.background === 'light');
305
- }
306
-
307
- /**
308
- * A stored (or just-picked) theme row, corrected when the terminal it will be
309
- * drawn on cannot show it.
310
- *
311
- * This is the other half of `themeIsLight`. That function answers "is row 0
312
- * light?" — but rows 2, 4 and 6 are *explicitly* light, and an explicit row
313
- * whose text cannot be read is not a preference. The recorded bug: a terminal
314
- * background of `#1e1e2e` with `themeIndex: 2` in the config drew the light
315
- * palette's primary text `RGB(40,40,40)` over it — a 1.11:1 contrast ratio,
316
- * i.e. a body of text that is present and unreadable. The stored row had been
317
- * chosen on a light terminal and outlived it, and nothing ever checked it
318
- * against the terminal that was actually on screen.
319
- *
320
- * The correction keeps the user's family and flips only the brightness, so
321
- * "colorblind-friendly" or "ANSI colors only" survives: the answer is the same
322
- * palette at the brightness this terminal can display. `changed` is reported
323
- * rather than acted on silently — a preference that was overridden is something
324
- * the user is told about, and the stored value is left alone, so moving back to
325
- * a light terminal restores the original choice by itself.
326
- *
327
- * @param {number} themeIndex the stored/selected row
328
- * @param {object} [c] a caps object; defaults to the live process's
329
- * @returns {{index: number, changed: boolean, reason: string, from: object|null}}
330
- */
331
- function reconcileThemeIndex(themeIndex, c = caps()) {
332
- const row = THEME_TABLE[themeIndex];
333
- if (!themeContradicts(themeIndex, c)) return { index: themeIndex, changed: false, reason: '', from: row || null };
334
- const index = SIBLING_THEME_INDEX[themeIndex];
335
- const to = THEME_TABLE[index];
336
- const label = (r) => `${r.name}${r.note ? ' ' + r.note : ''}`;
337
- return {
338
- index,
339
- changed: true,
340
- from: row,
341
- reason:
342
- `saved theme "${label(row)}" is unreadable on this ${c.background} terminal ` +
343
- `(${c.reasons.background}) — using "${label(to)}" instead`,
344
- };
345
- }
346
-
347
- /** The palette object for a theme-picker row index (out-of-range → dark). */
348
- function themeForIndex(i) {
349
- const row = THEME_TABLE[i];
350
- return row ? row.palette : C;
351
- }
352
-
353
- /**
354
- * The palette object for a context. Colours are always derived from one of the
355
- * theme objects — never typed inline.
356
- *
357
- * The light flag alone decides for the three default-brightness rows (indices
358
- * 0–2), which keeps `themeOf({light:true}) === LIGHT` and `themeOf({}) === C`
359
- * exactly as before — except for row 0, which is "Auto (match terminal)" and so
360
- * asks the terminal instead of assuming dark. The colourblind and ANSI families
361
- * are only consulted when `themeIndex` actually names one of them (3–6), so an
362
- * app that seeds `themeIndex` to 0/1 for light/dark is unaffected (it is not
363
- * seeding 0 unless it means Auto).
364
- *
365
- * The *depth* is deliberately not consulted here: `C` is already built from
366
- * `RGB()`, which is depth-aware, so a 16-colour console gets a 16-colour dark
367
- * palette rather than being silently switched to the ANSI picker row — the
368
- * picker row must keep meaning "use the terminal's own table", not
369
- * "your terminal is too old".
370
- */
371
- function themeOf(ctx) {
372
- if (ctx && typeof ctx.themeIndex === 'number' && ctx.themeIndex >= 3 && ctx.themeIndex <= 6) {
373
- return themeForIndex(ctx.themeIndex);
374
- }
375
- // Row 0 is "Auto (match terminal)": the terminal's own background decides,
376
- // not a hardcoded dark. Without this branch the one row whose job is to match
377
- // the terminal was the one row that could not, and a light terminal drew the
378
- // dark palette's `RGB(255,255,255)` body text over its own white background.
379
- if (ctx && ctx.themeIndex === AUTO_THEME_INDEX) return terminalIsLight() ? LIGHT : C;
380
- return ctx && ctx.light ? LIGHT : C;
381
- }
382
-
383
- /**
384
- * The diff palette for a context — the exact companion of `themeOf`, so a
385
- * caller never has to ask "which palette did the rows use?" separately from
386
- * "which diff colors go with it?". `themeIndex` 3–6 are the four picker rows
387
- * whose brightness is named by their own `light` flag; anything else falls
388
- * back to the ctx's `light` flag, exactly as `themeOf` does.
389
- */
390
- function diffOf(ctx) {
391
- const light = ctx && typeof ctx.themeIndex === 'number' && ctx.themeIndex >= 3 && ctx.themeIndex <= 6
392
- ? !!THEME_TABLE[ctx.themeIndex].light
393
- : ctx && ctx.themeIndex === AUTO_THEME_INDEX
394
- ? terminalIsLight()
395
- : !!(ctx && ctx.light);
396
- return light ? DIFF_LIGHT : DIFF;
397
- }
398
-
399
- // ── glyphs ───────────────────────────────────────────────────────────────────
400
-
401
- /**
402
- * The glyph table for a terminal, resolved from its capabilities.
403
- *
404
- * A few of the reference's glyphs are missing from some terminal fonts
405
- * (⎿ U+23BF, ⏸ U+23F8, ✔ U+2714, ▸ U+25B8) or render as double-width emoji
406
- * (✦ U+2726, ✻/✢/✽/✶), which breaks row alignment exactly like the welcome art.
407
- * The capability classes in `caps.js` decide the set, and the host is not one of
408
- * them — see the policy at the top of that file:
409
- *
410
- * · `glyphs: 'ascii'` — no Unicode claim at all, requested with
411
- * `AEGIS_ART=ascii` / `--ascii`. Every mark becomes a single-column ASCII
412
- * stand-in, so the layout is identical but nothing is mis-rendered by a font
413
- * that lacks the glyph.
414
- * · `face: 'edges'` — the quartile edges and the typographic marks (⎿, ⏸,
415
- * ✔) are swapped; reachable today only through the ASCII pass, and kept
416
- * because `AEGIS_ART=unicode` on a font without the edges must be
417
- * expressible.
418
- * · native — the default everywhere: the reference's own set.
419
- *
420
- * `star` is NOT restated here: it is resolved through `art.js`'s stencil, the
421
- * single source of truth for the mark's runes, so the glyph table and the art
422
- * can never disagree about the same character.
423
- *
424
- * @param {string|object} [target] a `process.platform` name (accepted for
425
- * tests, ignored by the policy), or a caps object, or nothing at all for the
426
- * live process's resolved capabilities.
427
- */
428
- function glyphsFor(target = null) {
429
- const c = !target
430
- ? caps()
431
- : typeof target === 'string'
432
- ? detect(process.env, process.stdout, target)
433
- : target;
434
- const ascii = c.glyphs === 'ascii';
435
- const edges = ascii || c.face === 'edges';
436
-
437
- if (ascii) {
438
- return {
439
- cursor: '>', // menu selection marker, prompt prefix
440
- check: '+', // selected / completed
441
- divider: '-', // menu separators
442
- bullet: '.', // inline separators
443
- hint: '>', // "Try ..." suggestion marker
444
- pause: '||', // bottom status line (manual mode)
445
- star: stencilGlyph(STAR, c), // own-session marker, decorations
446
- rightarrow: '->', // the manual ⇄ auto mode switch
447
- pointer: '>', // tips list bullets
448
- hook: '_|', // inline command / tip rows
449
- block: '*', // streaming cursor / assistant answer marker
450
- bloom: '*', // "done" spinner glyph (✻ Brewed for 2s)
451
- spin: ['|', '/', '-', '\\', '*', '-'], // working spinner
452
- ellipse: '...',
453
- err: 'x', // failed check
454
- warn: '!', // warning mark
455
- rule: '-', // ruled section headers
456
- ruleHeavy: '=', // the welcome banner's frame rule
457
- };
458
- }
459
-
460
- const base = {
461
- cursor: '❯', // menu selection marker, prompt prefix
462
- check: '✔', // selected / completed
463
- divider: '╌', // menu separators
464
- bullet: '·', // inline separators
465
- hint: '❯', // "Try ..." suggestion marker
466
- pause: edges ? '❚❚' : '⏸', // bottom status line (manual mode)
467
- star: stencilGlyph(STAR, c), // own-session marker, decorations
468
- rightarrow: '→', // the manual ⇄ auto mode switch, advertised on the status line
469
- pointer: '▸', // tips list bullets
470
- hook: edges ? '_|' : '⎿', // inline command / tip rows (tool commands, usage hints)
471
- block: '●', // streaming cursor / assistant answer marker
472
- bloom: '✻', // "done" spinner glyph (✻ Brewed for 2s)
473
- spin: ['✢', '·', '✻', '*', '✽', '✶'], // working spinner
474
- ellipse: '…',
475
- err: '✗', // failed check (render.js's notice marks live here too)
476
- warn: '⚠', // warning mark
477
- rule: '─', // ruled section headers
478
- ruleHeavy: '━', // the welcome banner's frame rule
479
- };
480
-
481
- if (edges) {
482
- // ⏸ U+23F8 and ⎿ U+23BF are the two the font stacks in this class lack;
483
- // ✻ U+273B has an emoji presentation on them as well.
484
- return { ...base, bloom: '*', spin: ['|', '/', '-', '\\', '*', '-'] };
485
- }
486
- return base;
487
- }
488
-
489
- /** The live glyph table — re-materialised whenever the capabilities change. */
490
- const GLYPH = glyphsFor();
491
-
492
- /** Working-line verbs, verbatim from the capture-backed table. */
493
- const VERBS = [
494
- 'Incubating',
495
- 'Tempering',
496
- 'Determining',
497
- 'Beboppin\'',
498
- 'Julienning',
499
- 'Inferring',
500
- 'Simmering',
501
- 'Twisting',
502
- 'Fermenting',
503
- 'Fiddle-faddling',
504
- 'Orbiting',
505
- 'Prestidigitating',
506
- ];
507
-
508
- /** Completion verbs: "✻ Churned for 3s" after a chat turn, "✻ Worked for 3s"
509
- * after one that used tools. */
510
- const DONE_VERBS = ['Churned', 'Worked'];
511
-
512
- // ── materialisation ──────────────────────────────────────────────────────────
513
-
514
- /**
515
- * Rebuild every palette and the glyph table for the current capabilities.
516
- * Mutates in place: renderers, screens and panels capture these objects at
517
- * require time, and swapping the object would leave them drawing the previous
518
- * terminal's colours after `--ascii` or `/terminal`.
519
- */
520
- function rematerialize() {
521
- Object.assign(C, buildDark());
522
- Object.assign(LIGHT, buildLight());
523
- Object.assign(CB_DARK, buildCbDark());
524
- Object.assign(CB_LIGHT, buildCbLight());
525
- Object.assign(ANSI_DARK, buildAnsiDark());
526
- Object.assign(ANSI_LIGHT, buildAnsiLight());
527
- Object.assign(DIFF, buildDiff());
528
- Object.assign(DIFF_LIGHT, buildDiffLight());
529
- Object.assign(GLYPH, glyphsFor());
530
- }
531
-
532
- rematerialize();
533
- onCapsChange(rematerialize);
534
-
535
- module.exports = {
536
- RGB,
537
- BG,
538
- RESET,
539
- BOLD,
540
- DIM,
541
- ITALIC,
542
- UNDER,
543
- BOLD_OFF,
544
- ITALIC_OFF,
545
- UNDER_OFF,
546
- RESET_FG,
547
- RESET_BG,
548
- C,
549
- LIGHT,
550
- DIFF,
551
- DIFF_LIGHT,
552
- diffOf,
553
- CB_DARK,
554
- CB_LIGHT,
555
- ANSI_DARK,
556
- ANSI_LIGHT,
557
- THEMES,
558
- THEME_TABLE,
559
- AUTO_THEME_INDEX,
560
- themeIsLight,
561
- terminalIsLight,
562
- themeForIndex,
563
- themeContradicts,
564
- reconcileThemeIndex,
565
- SIBLING_THEME_INDEX,
566
- GLYPH,
567
- glyphsFor,
568
- VERBS,
569
- DONE_VERBS,
570
- themeOf,
571
- rematerialize,
572
- };
3
+ const{caps:e,detect:n,onCapsChange:t,rgb:r,bg:i}=require("./caps.js"),{STAR:o,stencilGlyph:d}=require("./art.js"),l=(e,n,t)=>r(e,n,t),a=(e,n,t)=>i(e,n,t),g={},c={},s={},m={},u={},h={};function b(){return{gold:l(255,193,7),coral:l(215,119,87),lavender:l(177,185,249),blue:l(120,160,250),green:l(78,186,101),red:l(220,90,90),gray:l(153,153,153),dim:l(80,80,80),white:l(255,255,255),black:l(30,30,30),darkBg:l(20,20,20)}}function I(){return{gold:l(180,130,0),coral:l(190,100,70),lavender:l(120,130,220),blue:l(70,110,220),green:l(60,150,80),red:l(200,60,60),gray:l(110,110,110),dim:l(170,170,170),white:l(40,40,40),black:l(245,245,245),darkBg:l(255,255,255)}}const p=n=>e().color?`[${n}m`:"",f={},k={},F={dark:g,light:c},B=[{name:"Auto",note:"(match terminal)",light:!1,palette:g},{name:"Dark mode",note:"",light:!1,palette:g},{name:"Light mode",note:"",light:!0,palette:c},{name:"Dark mode",note:"(colorblind-friendly)",light:!1,palette:s},{name:"Light mode",note:"(colorblind-friendly)",light:!0,palette:m},{name:"Dark mode",note:"(ANSI colors only)",light:!1,palette:u},{name:"Light mode",note:"(ANSI colors only)",light:!0,palette:h}];function E(n=e()){return"light"===n.background}const H=[0,2,1,4,3,6,5];function O(n,t=e()){const r=B[n];return!(!r||0===n||!t||!t.backgroundKnown||!!r.light==("light"===t.background))}function T(e){const n=B[e];return n?n.palette:g}function _(t=null){const r=t?"string"==typeof t?n(process.env,process.stdout,t):t:e(),i="ascii"===r.glyphs,l=i||"edges"===r.face;if(i)return{cursor:">",check:"+",divider:"-",bullet:".",hint:">",pause:"||",star:d(o,r),rightarrow:"->",pointer:">",hook:"_|",block:"*",bloom:"*",spin:["|","/","-","\\","*","-"],ellipse:"...",err:"x",warn:"!",rule:"-",ruleHeavy:"="};const a={cursor:"❯",check:"✔",divider:"╌",bullet:"·",hint:"❯",pause:l?"❚❚":"⏸",star:d(o,r),rightarrow:"→",pointer:"▸",hook:l?"_|":"⎿",block:"●",bloom:"✻",spin:["✢","·","✻","*","✽","✶"],ellipse:"…",err:"✗",warn:"⚠",rule:"─",ruleHeavy:"━"};return l?{...a,bloom:"*",spin:["|","/","-","\\","*","-"]}:a}const x=_();function y(){Object.assign(g,b()),Object.assign(c,I()),Object.assign(s,{...b(),green:l(86,182,194),red:l(255,146,43),gold:l(255,203,71)}),Object.assign(m,{...I(),green:l(30,130,145),red:l(200,100,20),gold:l(150,110,0)}),Object.assign(u,{gold:p(93),coral:p(91),lavender:p(94),blue:p(94),green:p(92),red:p(91),gray:p(90),dim:p(90),white:p(97),black:p(40),darkBg:e().color?"":""}),Object.assign(h,{gold:p(33),coral:p(31),lavender:p(34),blue:p(34),green:p(32),red:p(31),gray:p(90),dim:p(37),white:p(30),black:p(47),darkBg:e().color?"":""}),Object.assign(f,{delFg:l(220,90,90),delBg:a(61,1,0),delHiFg:l(248,248,242),delHiBg:a(92,2,0),addFg:l(80,200,80),addBg:a(2,40,0),addHiFg:l(255,255,255),addHiBg:a(4,71,0),codeFg:l(248,248,242),gutter:l(120,120,120),kw:l(102,217,239),fn:l(166,226,46),str:l(230,219,116),num:l(174,129,255),comment:l(117,113,94)}),Object.assign(k,{delFg:l(160,40,40),delBg:a(255,235,233),delHiFg:l(90,0,0),delHiBg:a(255,205,200),addFg:l(30,130,40),addBg:a(232,250,232),addHiFg:l(0,80,0),addHiBg:a(195,240,195),codeFg:l(40,40,40),gutter:l(150,150,150),kw:l(0,120,160),fn:l(80,140,0),str:l(150,110,0),num:l(120,60,200),comment:l(140,140,130)}),Object.assign(x,_())}y(),t(y),module.exports={RGB:l,BG:a,RESET:"",BOLD:"",DIM:"",ITALIC:"",UNDER:"",BOLD_OFF:"",ITALIC_OFF:"",UNDER_OFF:"",RESET_FG:"",RESET_BG:"",C:g,LIGHT:c,DIFF:f,DIFF_LIGHT:k,diffOf:function(e){return(e&&"number"==typeof e.themeIndex&&e.themeIndex>=3&&e.themeIndex<=6?B[e.themeIndex].light:e&&0===e.themeIndex?E():e&&e.light)?k:f},CB_DARK:s,CB_LIGHT:m,ANSI_DARK:u,ANSI_LIGHT:h,THEMES:F,THEME_TABLE:B,AUTO_THEME_INDEX:0,themeIsLight:function(n,t=e()){const r=B[n];return!!r&&(0===n?E(t):!!r.light)},terminalIsLight:E,themeForIndex:T,themeContradicts:O,reconcileThemeIndex:function(n,t=e()){const r=B[n];if(!O(n,t))return{index:n,changed:!1,reason:"",from:r||null};const i=H[n],o=B[i],d=e=>`${e.name}${e.note?" "+e.note:""}`;return{index:i,changed:!0,from:r,reason:`saved theme "${d(r)}" is unreadable on this ${t.background} terminal (${t.reasons.background}) — using "${d(o)}" instead`}},SIBLING_THEME_INDEX:H,GLYPH:x,glyphsFor:_,VERBS:["Incubating","Tempering","Determining","Beboppin'","Julienning","Inferring","Simmering","Twisting","Fermenting","Fiddle-faddling","Orbiting","Prestidigitating"],DONE_VERBS:["Churned","Worked"],themeOf:function(e){return e&&"number"==typeof e.themeIndex&&e.themeIndex>=3&&e.themeIndex<=6?T(e.themeIndex):e&&0===e.themeIndex?E()?c:g:e&&e.light?c:g},rematerialize:y};