aegiscode 6.7.0 → 6.7.1
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 +46 -0
- package/bin/aegiscode.js +87 -0
- package/package.json +1 -1
- package/src/art.js +114 -60
- package/src/caps.js +597 -0
- package/src/commands.js +85 -1
- package/src/panels.js +59 -1
- package/src/render.js +27 -16
- package/src/screen.js +20 -20
- package/src/theme.js +297 -160
package/README.md
CHANGED
|
@@ -67,8 +67,53 @@ aegiscode "why is the sky blue" # one-shot, prints the answer and the tokens
|
|
|
67
67
|
aegiscode -p "..." --json # machine-readable
|
|
68
68
|
echo "q" | aegiscode -p - # prompt on stdin
|
|
69
69
|
aegiscode -m deepseek/deepseek-v4-flash -p "..." # pin a model
|
|
70
|
+
aegiscode --terminal # print the resolved terminal capabilities
|
|
71
|
+
aegiscode --ascii # force the ASCII mark (legacy consoles)
|
|
72
|
+
aegiscode --width 100 # pin the frame width
|
|
70
73
|
```
|
|
71
74
|
|
|
75
|
+
## One look on every terminal
|
|
76
|
+
|
|
77
|
+
The welcome screen, the palette and the glyph set are resolved from what the
|
|
78
|
+
terminal *can actually draw*, not from `process.platform`. PowerShell inside
|
|
79
|
+
Windows Terminal sets `WT_SESSION`/`TERM_PROGRAM`, so it renders the **same
|
|
80
|
+
byte-identical frame** as zsh: `unicode` mark, `native` star, 24-bit colour. The
|
|
81
|
+
host OS is only a fallback hint; the environment wins.
|
|
82
|
+
|
|
83
|
+
`cli/src/caps.js` resolves one capability object — mark (`unicode`/`ascii`), face
|
|
84
|
+
(`native`/`edges`), star (`native`/`narrow`), colour depth (24/8/4/0), control
|
|
85
|
+
(`ansi`/`plain`), size and EOL — and everything that draws goes through it.
|
|
86
|
+
`theme.js` builds its palettes and glyph table via `caps.rgb()`/`caps.bg()`, so a
|
|
87
|
+
16-colour console is painted in colours it has instead of literal escape text,
|
|
88
|
+
and `art.js` applies composable stencils (`ascii`, `edges`, `star`) rather than a
|
|
89
|
+
per-platform art table.
|
|
90
|
+
|
|
91
|
+
Only a **legacy** Windows console degrades — and it says why:
|
|
92
|
+
|
|
93
|
+
| host | mark | star | colour | reason |
|
|
94
|
+
| --- | --- | --- | --- | --- |
|
|
95
|
+
| win32 legacy conhost | `ascii` | `narrow` | 16 | Consolas has no block glyphs |
|
|
96
|
+
| win32 Windows Terminal | `unicode` | `native` | truecolor | Windows VT host (`WT_SESSION`) |
|
|
97
|
+
| Linux/macOS, zsh | `unicode` | `native` | truecolor | — |
|
|
98
|
+
| `TERM=dumb` | `ascii` | `narrow` | none | no control sequences |
|
|
99
|
+
|
|
100
|
+
The **star defaults to native on Windows VT.** `✦` appears eleven times in the
|
|
101
|
+
welcome art, so forcing it narrow there would *create* the divergence this is
|
|
102
|
+
meant to remove; ConPTY does font fallback single-width. `AEGIS_STAR=narrow`
|
|
103
|
+
is the escape hatch if a host proves otherwise.
|
|
104
|
+
|
|
105
|
+
Overrides, at launch — `--ascii`, `--unicode`, `--no-color`, `--color`,
|
|
106
|
+
`--width <cols>`, `--terminal` (print the report) — and in-session via
|
|
107
|
+
`/terminal ascii|unicode|color|no-color|star <native|narrow>|width <cols>|auto|status`.
|
|
108
|
+
`/terminal auto` re-probes rather than restoring launch flags. `/terminal width`
|
|
109
|
+
pins the frame, so resizes are ignored until `/terminal auto`; every other
|
|
110
|
+
`/terminal` switch leaves resize handling intact.
|
|
111
|
+
|
|
112
|
+
The same axes are settable by environment for scripts and CI: `AEGIS_ART`,
|
|
113
|
+
`AEGIS_ASCII`, `AEGIS_UNICODE`, `AEGIS_STAR`, `AEGIS_COLOR`, `AEGIS_VT`,
|
|
114
|
+
`AEGIS_WIDTH`, `AEGIS_WIDE_RUNES`. `NO_COLOR` is honoured to the letter —
|
|
115
|
+
"present and not an empty string, regardless of its value".
|
|
116
|
+
|
|
72
117
|
## First run
|
|
73
118
|
|
|
74
119
|
A genuine first run walks the reference's onboarding before the session starts —
|
|
@@ -307,6 +352,7 @@ node ../test/cli-commands.test.mjs # the full command table, aliases, dispatc
|
|
|
307
352
|
node ../test/cli-panels.test.mjs # every panel builder, defensive against missing data
|
|
308
353
|
node ../test/cli-support.test.mjs # config/history/tokens/agents/export/checkpoints
|
|
309
354
|
node ../test/cli-conformance.test.mjs # the design guard: palette, glyphs, art, verbs
|
|
355
|
+
node ../test/cli-terminal-caps.test.mjs # capability resolution: PowerShell and zsh agree
|
|
310
356
|
node ../test/cli-render.test.mjs # width safety, accounting, live region
|
|
311
357
|
node ../test/cli-overlays.test.mjs # the / palette, model + effort pickers, resume list
|
|
312
358
|
node ../test/cli-fuzzy.test.mjs # palette ranking and match positions
|
package/bin/aegiscode.js
CHANGED
|
@@ -16,6 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
const path = require('node:path');
|
|
18
18
|
|
|
19
|
+
// A closed pipe is not a failure. `aegiscode --terminal | head`, PowerShell's
|
|
20
|
+
// `| Select-Object -First 5`, and a pager the user quits all close the read end
|
|
21
|
+
// while we still have lines to write, and the default unhandled `error` event
|
|
22
|
+
// on stdout turns that into a stack trace over the answer. Every line of output
|
|
23
|
+
// this host produces is disposable, so the first EPIPE ends the process cleanly.
|
|
24
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
25
|
+
stream.on('error', (e) => {
|
|
26
|
+
if (e && (e.code === 'EPIPE' || e.code === 'ERR_STREAM_DESTROYED')) process.exit(0);
|
|
27
|
+
throw e;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
const HELP = `aegiscode — AEGIS in your shell.
|
|
20
32
|
|
|
21
33
|
Usage:
|
|
@@ -47,6 +59,14 @@ Options:
|
|
|
47
59
|
--width <cols> force a render width (useful for piping/logs)
|
|
48
60
|
--yolo skip tool-approval prompts (exec/writeFile/editFile
|
|
49
61
|
run without asking) — same as the in-session /yolo
|
|
62
|
+
--ascii draw with the ASCII mark and glyph set (no Unicode).
|
|
63
|
+
Same as AEGIS_ART=ascii; /terminal ascii toggles it
|
|
64
|
+
mid-session.
|
|
65
|
+
--no-color no colour at all (same as NO_COLOR=1)
|
|
66
|
+
--terminal print the resolved terminal capabilities and exit —
|
|
67
|
+
one report shape on every platform, so pasting it
|
|
68
|
+
from PowerShell (or into a bug report) reads the same
|
|
69
|
+
as pasting it from zsh
|
|
50
70
|
-c, --continue skip onboarding and resume the most recent session
|
|
51
71
|
-h, --help this text
|
|
52
72
|
-v, --version print the version
|
|
@@ -67,6 +87,15 @@ function parseArgs(argv) {
|
|
|
67
87
|
light: false,
|
|
68
88
|
width: null,
|
|
69
89
|
yolo: false,
|
|
90
|
+
// Three-state, like `color`: `null` means "no art flag was given, let the
|
|
91
|
+
// capability probe decide". It must NOT default to `false`, because `false`
|
|
92
|
+
// is how `--unicode` is spelled — a default of `false` sets
|
|
93
|
+
// `AEGIS_ART=unicode` on every run and silently out-ranks the legacy-console
|
|
94
|
+
// ASCII downgrade, so a plain `aegiscode` on an old Windows console would
|
|
95
|
+
// draw Unicode blocks it cannot render.
|
|
96
|
+
ascii: null,
|
|
97
|
+
color: null,
|
|
98
|
+
terminal: false,
|
|
70
99
|
continue: false,
|
|
71
100
|
prompt: null,
|
|
72
101
|
help: false,
|
|
@@ -157,6 +186,28 @@ function parseArgs(argv) {
|
|
|
157
186
|
case '--width':
|
|
158
187
|
opts.width = Number(next());
|
|
159
188
|
break;
|
|
189
|
+
case '--ascii':
|
|
190
|
+
// The same switch as AEGIS_ART=ascii, spelled as a flag because it is
|
|
191
|
+
// the one thing a user has to do to fix a mangled welcome mark, and
|
|
192
|
+
// asking them to export a variable and restart the shell first is how
|
|
193
|
+
// the mark stayed broken.
|
|
194
|
+
opts.ascii = true;
|
|
195
|
+
break;
|
|
196
|
+
case '--unicode':
|
|
197
|
+
opts.ascii = false;
|
|
198
|
+
break;
|
|
199
|
+
case '--no-color':
|
|
200
|
+
case '--no-colour':
|
|
201
|
+
opts.color = false;
|
|
202
|
+
break;
|
|
203
|
+
case '--color':
|
|
204
|
+
case '--colour':
|
|
205
|
+
opts.color = true;
|
|
206
|
+
break;
|
|
207
|
+
case '--terminal':
|
|
208
|
+
case '--caps':
|
|
209
|
+
opts.terminal = true;
|
|
210
|
+
break;
|
|
160
211
|
default:
|
|
161
212
|
if (a.startsWith('-') && a !== '-') throw new Error(`unknown option: ${a}`);
|
|
162
213
|
rest.push(a);
|
|
@@ -325,6 +376,42 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
325
376
|
return 0;
|
|
326
377
|
}
|
|
327
378
|
|
|
379
|
+
// ── terminal capabilities, resolved before anything else is loaded ────────
|
|
380
|
+
//
|
|
381
|
+
// Ordering is the whole point. `theme.js` materialises its palettes and its
|
|
382
|
+
// glyph table at load time and `art.js` picks its stencil at load time, and
|
|
383
|
+
// `app.js` pulls in both. Resolving caps first means the welcome screen is
|
|
384
|
+
// drawn for the terminal actually in use — PowerShell with VT enabled gets
|
|
385
|
+
// the same mark as zsh, a legacy console gets the ASCII pass — instead of
|
|
386
|
+
// whatever the first probe guessed being frozen into a module that is never
|
|
387
|
+
// re-evaluated.
|
|
388
|
+
const { setCaps, describe } = require('../src/caps.js');
|
|
389
|
+
const capEnv = { ...process.env };
|
|
390
|
+
if (opts.ascii === true) capEnv.AEGIS_ART = 'ascii';
|
|
391
|
+
if (opts.ascii === false) capEnv.AEGIS_ART = 'unicode';
|
|
392
|
+
if (opts.color === false) capEnv.NO_COLOR = '1';
|
|
393
|
+
if (opts.color === true) {
|
|
394
|
+
// An explicit --color has to beat an inherited NO_COLOR, and NO_COLOR is
|
|
395
|
+
// checked first, so it is removed rather than out-ranked.
|
|
396
|
+
delete capEnv.NO_COLOR;
|
|
397
|
+
capEnv.FORCE_COLOR = '3';
|
|
398
|
+
}
|
|
399
|
+
if (opts.width) capEnv.AEGIS_WIDTH = String(opts.width);
|
|
400
|
+
setCaps(null, capEnv);
|
|
401
|
+
|
|
402
|
+
// `--terminal` answers "why does it look like that here?" in one shape on
|
|
403
|
+
// every platform, so a paste from PowerShell reads like one from zsh. It
|
|
404
|
+
// prints the resolved values and exits before a session, a config read or a
|
|
405
|
+
// network call can colour the answer.
|
|
406
|
+
if (opts.terminal) {
|
|
407
|
+
const rows = describe();
|
|
408
|
+
const key = rows.reduce((m, [k]) => Math.max(m, k.length), 0);
|
|
409
|
+
process.stdout.write(`aegiscode ${pkg.version} — terminal capabilities\n\n`);
|
|
410
|
+
for (const [k, v] of rows) process.stdout.write(` ${k.padEnd(key)} ${v}\n`);
|
|
411
|
+
process.stdout.write('\nOverride with --ascii / --color / --width, or AEGIS_ART,\nAEGIS_STAR, AEGIS_COLOR, AEGIS_VT, AEGIS_WIDTH (see README).\n');
|
|
412
|
+
return 0;
|
|
413
|
+
}
|
|
414
|
+
|
|
328
415
|
// Apply the flags that the shared client reads from the environment, before
|
|
329
416
|
// anything constructs it.
|
|
330
417
|
if (opts.base) process.env.AEGIS_API_BASE = opts.base;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.7.
|
|
4
|
+
"version": "6.7.1",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|
package/src/art.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { caps, detect, cells, padCells } = require('./caps.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a stencil target — nothing at all, a `process.platform` name, or a
|
|
7
|
+
* whole caps object — to the capabilities that decide the pass.
|
|
8
|
+
*
|
|
9
|
+
* A platform *name* is still accepted because it is the shape a test wants when
|
|
10
|
+
* it is asking "what would the mark look like on that host?"; it is resolved
|
|
11
|
+
* through the same `detect()` the live process uses, so a platform string is a
|
|
12
|
+
* convenience alias for a capability probe, never a second decision path.
|
|
13
|
+
*/
|
|
14
|
+
function capsOf(target) {
|
|
15
|
+
if (!target) return caps();
|
|
16
|
+
if (typeof target === 'string') return detect(process.env, process.stdout, target);
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* Welcome art — the aegiscodex-dev mark, adopted wholesale.
|
|
5
22
|
*
|
|
@@ -13,6 +30,9 @@
|
|
|
13
30
|
* `joinSideBySide()` stay exact. `test/cli-conformance.test.mjs` asserts both
|
|
14
31
|
* that property and that these rows still match aegiscodex-dev's source, so the
|
|
15
32
|
* mark can't drift.
|
|
33
|
+
*
|
|
34
|
+
* Which pass is applied is decided by the terminal's capabilities, not by
|
|
35
|
+
* `process.platform` — see the portability section below and `caps.js`.
|
|
16
36
|
*/
|
|
17
37
|
|
|
18
38
|
// The mascot face — exact glyphs from the binary (msS template).
|
|
@@ -84,100 +104,137 @@ const WELCOME_BACK = 'Welcome back!';
|
|
|
84
104
|
const TAGLINE = 'Cloud brain in your shell.';
|
|
85
105
|
|
|
86
106
|
// ── Terminal portability ─────────────────────────────────────────────────────
|
|
87
|
-
// The block-glyph palette and ✦ stars are single-width on
|
|
88
|
-
// not everywhere: Windows
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
107
|
+
// The block-glyph palette and ✦ stars are single-width on most terminals, but
|
|
108
|
+
// not everywhere: a legacy Windows console font lacks the U+259B..U+259F face
|
|
109
|
+
// edges and mangles █▓▒░ entirely; Terminal.app has no quartile edges and
|
|
110
|
+
// renders ✦ through the two-cell emoji fallback. Each pass swaps offending code
|
|
111
|
+
// points 1:1 (same character count per row) so the width maths stays exact and
|
|
112
|
+
// the mark keeps its shape.
|
|
113
|
+
//
|
|
114
|
+
// The pass is keyed on the terminal's CAPABILITIES (`caps.js`), never on
|
|
115
|
+
// `process.platform`. That distinction is the whole point: PowerShell inside
|
|
116
|
+
// Windows Terminal draws this mark exactly as zsh does, and it used to be
|
|
117
|
+
// handed the hyphen-and-hash ASCII version purely because the *process* was
|
|
118
|
+
// win32. The three passes below compose — a Windows VT host needs the star
|
|
119
|
+
// narrow but keeps the native block palette, which no single platform-keyed
|
|
120
|
+
// table could express.
|
|
92
121
|
//
|
|
93
122
|
// This table is the ONE stencil source of truth for the product. `theme.js`
|
|
94
|
-
// resolves `GLYPH.star` through `stencilGlyph(STAR,
|
|
95
|
-
//
|
|
96
|
-
//
|
|
123
|
+
// resolves `GLYPH.star` through `stencilGlyph(STAR, caps)` rather than carrying
|
|
124
|
+
// its own `'✦' → '*'` rule, and `render.js` builds the mark's tint map by
|
|
125
|
+
// stencilling its runes — both had a private copy of the same decision, which
|
|
97
126
|
// is how a stencil edit here could leave the star wide on macOS or the whale
|
|
98
|
-
// untinted on Windows. `test/cli-
|
|
127
|
+
// untinted on Windows. `test/cli-terminal-caps.test.mjs` pins all of it.
|
|
99
128
|
const STAR = '✦';
|
|
100
129
|
|
|
130
|
+
/** The quartile/quadrant face edges — the runes Apple and older Windows fonts lack. */
|
|
131
|
+
const EDGE_RUNES = ['▐', '▛', '▜', '▌', '▝', '▘'];
|
|
132
|
+
|
|
133
|
+
/** Full ASCII pass: the block palette, the face edges, the star, the mid-dot. */
|
|
101
134
|
const ASCII_STENCIL = new Map([
|
|
102
135
|
['█', '#'],
|
|
103
136
|
['▓', '@'],
|
|
104
137
|
['▒', '='],
|
|
105
138
|
['░', '.'],
|
|
106
|
-
[
|
|
107
|
-
['▛', '#'],
|
|
108
|
-
['▜', '#'],
|
|
109
|
-
['▌', '#'],
|
|
110
|
-
['▝', '#'],
|
|
111
|
-
['▘', '#'],
|
|
139
|
+
...EDGE_RUNES.map((c) => [c, '#']),
|
|
112
140
|
[STAR, '*'],
|
|
113
141
|
['·', '.'],
|
|
114
142
|
]);
|
|
115
143
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
['▛', '#'],
|
|
119
|
-
['▜', '#'],
|
|
120
|
-
['▌', '#'],
|
|
121
|
-
['▝', '#'],
|
|
122
|
-
['▘', '#'],
|
|
123
|
-
[STAR, '*'],
|
|
124
|
-
]);
|
|
144
|
+
/** Unicode pass for fonts that carry █▓▒░ but not the face edges (Apple, old Consolas). */
|
|
145
|
+
const EDGE_STENCIL = new Map(EDGE_RUNES.map((c) => [c, '#']));
|
|
125
146
|
|
|
126
|
-
/**
|
|
127
|
-
const
|
|
147
|
+
/** ✦ alone: a font that falls back to a *two-cell* emoji glyph for it. */
|
|
148
|
+
const STAR_STENCIL = new Map([[STAR, '*']]);
|
|
128
149
|
|
|
129
|
-
/**
|
|
130
|
-
|
|
150
|
+
/**
|
|
151
|
+
* The named passes. They compose rather than being picked one-of-three: a
|
|
152
|
+
* Windows VT host takes `star` only (native palette, narrow star) and
|
|
153
|
+
* Terminal.app takes `edges` + `star`.
|
|
154
|
+
*/
|
|
155
|
+
const STENCILS = { ascii: ASCII_STENCIL, edges: EDGE_STENCIL, star: STAR_STENCIL };
|
|
131
156
|
|
|
132
157
|
/**
|
|
133
|
-
* The
|
|
134
|
-
*
|
|
158
|
+
* The capability classes this mark has a pass for, and the one that needs none.
|
|
159
|
+
* Kept as a name list so a caller (and the test) can enumerate the matrix
|
|
160
|
+
* without restating the pass table.
|
|
135
161
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
162
|
+
const PASSES = ['native', 'star', 'edges', 'ascii'];
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The stencil for a terminal, or `null` when its runes need no pass.
|
|
167
|
+
*
|
|
168
|
+
* `glyphs: 'ascii'` is the full pass and subsumes the others — a terminal with
|
|
169
|
+
* no block glyphs certainly has no quartile edges and no ✦ either, so it must
|
|
170
|
+
* not be handed a partial map that leaves ░▒▓◧ on screen.
|
|
171
|
+
*
|
|
172
|
+
* @param {string|object|null} [target] a caps object, a `process.platform` name,
|
|
173
|
+
* or nothing for the live process's resolved capabilities.
|
|
174
|
+
* @returns {Map<string,string>|null}
|
|
175
|
+
*/
|
|
176
|
+
function stencilFor(target = null) {
|
|
177
|
+
const c = capsOf(target);
|
|
178
|
+
if (c.glyphs === 'ascii') return ASCII_STENCIL;
|
|
179
|
+
const pass = new Map();
|
|
180
|
+
if (c.face === 'edges') for (const [k, v] of EDGE_STENCIL) pass.set(k, v);
|
|
181
|
+
if (c.star === 'narrow') for (const [k, v] of STAR_STENCIL) pass.set(k, v);
|
|
182
|
+
return pass.size ? pass : null;
|
|
138
183
|
}
|
|
139
184
|
|
|
140
185
|
/**
|
|
141
|
-
* One rune as
|
|
186
|
+
* One rune as the terminal renders it — the identity when it is native.
|
|
142
187
|
* Exported so `theme.js`'s glyph table and `render.js`'s tint map are derived
|
|
143
188
|
* from the stencil instead of restating it.
|
|
144
189
|
* @param {string} ch
|
|
145
|
-
* @param {string} [platform
|
|
190
|
+
* @param {string|object} [target] a caps object, a platform name, or nothing
|
|
146
191
|
*/
|
|
147
|
-
function stencilGlyph(ch,
|
|
148
|
-
const s = stencilFor(
|
|
192
|
+
function stencilGlyph(ch, target = null) {
|
|
193
|
+
const s = stencilFor(target);
|
|
149
194
|
return (s && s.get(ch)) || ch;
|
|
150
195
|
}
|
|
151
196
|
|
|
152
|
-
/** One
|
|
153
|
-
function portabilityFor(rows,
|
|
154
|
-
const s = stencilFor(
|
|
197
|
+
/** One pass over an art block, for an explicit target (caps object or platform). */
|
|
198
|
+
function portabilityFor(rows, target = null) {
|
|
199
|
+
const s = stencilFor(target);
|
|
155
200
|
if (!s) return rows;
|
|
156
201
|
return rows.map((r) => [...r].map((ch) => s.get(ch) ?? ch).join(''));
|
|
157
202
|
}
|
|
158
203
|
|
|
159
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* The mark as the terminal running this process will render it.
|
|
206
|
+
*
|
|
207
|
+
* Deliberately NOT memoised: `aegiscode --ascii` and `/terminal ascii` re-resolve
|
|
208
|
+
* the capabilities mid-session, and a cached mark would keep drawing the
|
|
209
|
+
* previous terminal's runes until the process restarted.
|
|
210
|
+
*/
|
|
160
211
|
function portability(rows) {
|
|
161
|
-
return portabilityFor(rows,
|
|
212
|
+
return portabilityFor(rows, null);
|
|
162
213
|
}
|
|
163
214
|
|
|
164
215
|
/** The mark that fits the current terminal: side-by-side when there's room. */
|
|
165
216
|
function welcomeArtFor(cols) {
|
|
166
217
|
const wide = portability(WELCOME_ART);
|
|
167
218
|
const stacked = portability(WELCOME_ART_STACKED);
|
|
168
|
-
const W = Math.max(...wide.map(
|
|
219
|
+
const W = Math.max(...wide.map(cells));
|
|
169
220
|
return cols >= W + 4 ? wide : stacked;
|
|
170
221
|
}
|
|
171
222
|
|
|
172
223
|
/**
|
|
173
224
|
* Split the mark into its two halves so each can carry its own theme ink.
|
|
225
|
+
*
|
|
226
|
+
* Rows are padded to a whole-cell width with `padCells()`, not `padEnd()`: a
|
|
227
|
+
* terminal that draws a rune two cells wide (`AEGIS_WIDE_RUNES=✦`, or a font
|
|
228
|
+
* that falls back to an emoji glyph) would otherwise be padded by *code point*
|
|
229
|
+
* and every row after it would drift one cell to the right of the one above.
|
|
230
|
+
*
|
|
174
231
|
* @returns {{rows: Array<[string,string]>, width: number, gutter: number}}
|
|
175
232
|
*/
|
|
176
233
|
function welcomeArtParts(cols) {
|
|
177
234
|
const mascot = portability(MASCOT_ART);
|
|
178
235
|
const moonWhale = portability(MOON_WHALE);
|
|
179
|
-
const L = Math.max(...mascot.map(
|
|
180
|
-
const R = Math.max(...moonWhale.map(
|
|
236
|
+
const L = Math.max(...mascot.map(cells));
|
|
237
|
+
const R = Math.max(...moonWhale.map(cells));
|
|
181
238
|
const wide = cols >= L + R + 2 + 4;
|
|
182
239
|
const gutter = wide ? 2 : 1;
|
|
183
240
|
if (wide) {
|
|
@@ -190,13 +247,12 @@ function welcomeArtParts(cols) {
|
|
|
190
247
|
// Same bottom-align rule as joinSideBySide — subtract the offset.
|
|
191
248
|
const li = i - (n - mascot.length);
|
|
192
249
|
const ri = i - (n - moonWhale.length);
|
|
193
|
-
rows.push([(mascot[li] ?? ''
|
|
250
|
+
rows.push([padCells(mascot[li] ?? '', L), padCells(moonWhale[ri] ?? '', R)]);
|
|
194
251
|
}
|
|
195
252
|
return { rows, width: L + gutter + R, gutter };
|
|
196
253
|
}
|
|
197
254
|
const w = Math.max(L, R);
|
|
198
|
-
const centerBlock = (rows) =>
|
|
199
|
-
rows.map((r) => ' '.repeat(Math.max(0, Math.floor((w - [...r].length) / 2))) + r);
|
|
255
|
+
const centerBlock = (rows) => rows.map((r) => ' '.repeat(Math.max(0, Math.floor((w - cells(r)) / 2))) + r);
|
|
200
256
|
return {
|
|
201
257
|
rows: [
|
|
202
258
|
...centerBlock(mascot).map((c) => [c, '']),
|
|
@@ -210,19 +266,16 @@ function welcomeArtParts(cols) {
|
|
|
210
266
|
|
|
211
267
|
/** Stack two art blocks vertically, each centred, separated by `gap` rows. */
|
|
212
268
|
function stackVertical(top, bottom, gap = 1) {
|
|
213
|
-
const w = Math.max(...[...top, ...bottom].map(
|
|
269
|
+
const w = Math.max(...[...top, ...bottom].map(cells));
|
|
214
270
|
const centerBlock = (rows) =>
|
|
215
|
-
rows.map((r) =>
|
|
216
|
-
const pad = Math.max(0, Math.floor((w - [...r].length) / 2));
|
|
217
|
-
return ' '.repeat(pad) + r;
|
|
218
|
-
});
|
|
271
|
+
rows.map((r) => ' '.repeat(Math.max(0, Math.floor((w - cells(r)) / 2))) + r);
|
|
219
272
|
return [...centerBlock(top), ...Array(gap).fill(''), ...centerBlock(bottom)];
|
|
220
273
|
}
|
|
221
274
|
|
|
222
275
|
/** Join two art stacks row-aligned (bottom-aligned by default). */
|
|
223
276
|
function joinSideBySide(left, right, gutter = 2, align = 'bottom') {
|
|
224
|
-
const L = Math.max(...left.map(
|
|
225
|
-
const R = Math.max(...right.map(
|
|
277
|
+
const L = Math.max(...left.map(cells));
|
|
278
|
+
const R = Math.max(...right.map(cells));
|
|
226
279
|
const n = Math.max(left.length, right.length);
|
|
227
280
|
return Array.from({ length: n }, (_, i) => {
|
|
228
281
|
// Bottom-align puts each block's LAST row on the output's last row, so a
|
|
@@ -233,8 +286,8 @@ function joinSideBySide(left, right, gutter = 2, align = 'bottom') {
|
|
|
233
286
|
// hung two rows below the baseline.
|
|
234
287
|
const li = align === 'bottom' ? i - (n - left.length) : i;
|
|
235
288
|
const ri = align === 'bottom' ? i - (n - right.length) : i;
|
|
236
|
-
const l = (left[li] ?? ''
|
|
237
|
-
const r = (right[ri] ?? ''
|
|
289
|
+
const l = padCells(left[li] ?? '', L);
|
|
290
|
+
const r = padCells(right[ri] ?? '', R);
|
|
238
291
|
return l + ' '.repeat(gutter) + r;
|
|
239
292
|
});
|
|
240
293
|
}
|
|
@@ -242,14 +295,14 @@ function joinSideBySide(left, right, gutter = 2, align = 'bottom') {
|
|
|
242
295
|
/** Centre every row of an art block inside `width` (left pad + right fill). */
|
|
243
296
|
function center(rows, width) {
|
|
244
297
|
return rows.map((r) => {
|
|
245
|
-
const pad = Math.max(0, Math.floor((width -
|
|
246
|
-
return ' '.repeat(pad) + r
|
|
298
|
+
const pad = Math.max(0, Math.floor((width - cells(r)) / 2));
|
|
299
|
+
return ' '.repeat(pad) + padCells(r, width - pad);
|
|
247
300
|
});
|
|
248
301
|
}
|
|
249
302
|
|
|
250
303
|
/** Centre each row against the block's own max width (no trailing fill). */
|
|
251
304
|
function padBoth(rows, width) {
|
|
252
|
-
const w = Math.max(...rows.map(
|
|
305
|
+
const w = Math.max(...rows.map(cells));
|
|
253
306
|
return rows.map((r) => {
|
|
254
307
|
const pad = Math.floor((width - w) / 2);
|
|
255
308
|
return ' '.repeat(Math.max(0, pad)) + r;
|
|
@@ -269,7 +322,8 @@ module.exports = {
|
|
|
269
322
|
WELCOME_BACK,
|
|
270
323
|
TAGLINE,
|
|
271
324
|
STAR,
|
|
272
|
-
|
|
325
|
+
EDGE_RUNES,
|
|
326
|
+
PASSES,
|
|
273
327
|
STENCILS,
|
|
274
328
|
stencilFor,
|
|
275
329
|
stencilGlyph,
|