aegiscode 6.8.7 → 6.8.9
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/package.json +1 -1
- package/scripts/predist.mjs +12 -0
- package/src/app.js +93 -2
- package/src/art.js +26 -19
- package/src/caps.js +106 -158
- package/src/chatflow.js +66 -2
- package/src/commands.js +89 -30
- package/src/models.js +162 -13
- package/src/overlays.js +27 -7
- package/src/panels.js +9 -7
- package/src/theme.js +23 -21
- package/vendor/client/brain-catalog.js +188 -0
- package/vendor/client/byok-catalog.js +144 -0
- package/vendor/client/env-file.js +398 -11
- package/vendor/desktop/lib/local/autonomous.js +2 -2
- package/vendor/desktop/lib/local/engine.js +91 -39
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.9",
|
|
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/scripts/predist.mjs
CHANGED
|
@@ -55,6 +55,18 @@ const FILES = [
|
|
|
55
55
|
// for the same account on the same machine.
|
|
56
56
|
'client/auto-provision.js',
|
|
57
57
|
'client/device-fingerprint.js',
|
|
58
|
+
// The pooled-brain selection rule: which single entry stands for the Aegis
|
|
59
|
+
// class. Required at load time by src/models.js (through src/sharedpaths.js),
|
|
60
|
+
// which the picker, /model and the OpenAI-compatible shim all build their
|
|
61
|
+
// model list from — and by the desktop engine, so the GUI and the terminal
|
|
62
|
+
// offer one account one list. Leaving it out stages a package whose every
|
|
63
|
+
// model listing throws MODULE_NOT_FOUND before it can print a prompt.
|
|
64
|
+
'client/brain-catalog.js',
|
|
65
|
+
// The BYOK model additions: the ids a provider relays but the server catalog
|
|
66
|
+
// does not name (the DeepSeek flash route). Required at load time by
|
|
67
|
+
// src/commands.js, so a package built without it throws MODULE_NOT_FOUND on
|
|
68
|
+
// the first picker or /byok listing instead of showing a short one.
|
|
69
|
+
'client/byok-catalog.js',
|
|
58
70
|
'mcp/tools.js',
|
|
59
71
|
// The stdio MCP server itself — the process every editor config written by
|
|
60
72
|
// `aegiscode mcp install` points at. Staging the registry without it ships a
|
package/src/app.js
CHANGED
|
@@ -220,6 +220,12 @@ function createApp(options = {}) {
|
|
|
220
220
|
// /new genuinely reset context.
|
|
221
221
|
const transcript = [];
|
|
222
222
|
let wantExit = false;
|
|
223
|
+
// When non-null, `emit` appends here instead of writing to `out`. Used by the
|
|
224
|
+
// one-shot path to run a command and report its output as one JSON document
|
|
225
|
+
// (`--json`) rather than as loose human text on stdout. Every command's output
|
|
226
|
+
// funnels through `emit` (pushRow's panel/note/turn branches all call it), so
|
|
227
|
+
// one switch here covers the whole command surface.
|
|
228
|
+
let capture = null;
|
|
223
229
|
|
|
224
230
|
const ctx = () => ({ light: commandCtx.light });
|
|
225
231
|
|
|
@@ -665,7 +671,10 @@ function createApp(options = {}) {
|
|
|
665
671
|
*/
|
|
666
672
|
function emit(lines) {
|
|
667
673
|
const block = typeof lines === 'string' ? [lines] : lines;
|
|
668
|
-
for (const l of block)
|
|
674
|
+
for (const l of block) {
|
|
675
|
+
if (capture) capture.push(l);
|
|
676
|
+
else out.write(l + '\n');
|
|
677
|
+
}
|
|
669
678
|
}
|
|
670
679
|
|
|
671
680
|
// --- the ask path ---------------------------------------------------------
|
|
@@ -1223,6 +1232,19 @@ function createApp(options = {}) {
|
|
|
1223
1232
|
// The one spelling of a provider's settings row, shared with the engine
|
|
1224
1233
|
// that reads it (`byok:<provider>`) — see engine.js byokNamespace.
|
|
1225
1234
|
byokNamespace: (p) => byokNamespace(p),
|
|
1235
|
+
// Whether a provider key is already on this machine — read through the
|
|
1236
|
+
// same `byok:<provider>` rows /byok-key writes, so the model picker's
|
|
1237
|
+
// "does this row need a key?" answer cannot disagree with the store that
|
|
1238
|
+
// would supply it. Never throws: an injected engine may carry no store.
|
|
1239
|
+
hasProviderKey: (p) => {
|
|
1240
|
+
const store = engine.settings || null;
|
|
1241
|
+
if (!store || !p || typeof store.rawKey !== 'function') return false;
|
|
1242
|
+
try { return !!store.rawKey(byokNamespace(p)); } catch { return false; }
|
|
1243
|
+
},
|
|
1244
|
+
// And whether the ACCOUNT key resolves anywhere (env → credentials.json).
|
|
1245
|
+
// A pooled row needs that key, not a provider one, and prompting for a
|
|
1246
|
+
// key the machine demonstrably holds is the bug this prevents.
|
|
1247
|
+
accountConfigured: () => !!credentials.keyStatus().configured,
|
|
1226
1248
|
// The class surface: /class switches, /models lists for whichever class
|
|
1227
1249
|
// is live (the frozen state carries the current one as c.ctx.modelClass).
|
|
1228
1250
|
listModelsFor: (cls) => listModelsFor(cls),
|
|
@@ -1432,9 +1454,20 @@ function createApp(options = {}) {
|
|
|
1432
1454
|
async function runOnce(prompt, { json = false } = {}) {
|
|
1433
1455
|
adoptLegacyKeyOnce();
|
|
1434
1456
|
if (!client.apiKey) {
|
|
1435
|
-
err.write(`aegiscode: no AEGIS account key. ${credentials.HOW_TO_SET}, or set
|
|
1457
|
+
err.write(`aegiscode: no AEGIS account key. ${credentials.HOW_TO_SET}, or set ${credentials.KEY_ENV}.\n`);
|
|
1436
1458
|
return 2;
|
|
1437
1459
|
}
|
|
1460
|
+
// A leading `/` is a LOCAL command at every other entry point (the chatflow
|
|
1461
|
+
// dispatches it, the linear REPL dispatches it), so it must be one here too.
|
|
1462
|
+
// This path used to skip the dispatcher entirely and hand `"/cost"` to the
|
|
1463
|
+
// model as ordinary user text: the request went out as a chat completion, and
|
|
1464
|
+
// the pool — which has no answer for a bare slash command — opened an
|
|
1465
|
+
// event-stream and sent nothing, so the turn died on the client's 60s idle
|
|
1466
|
+
// watchdog with "stream stalled". Every documented non-interactive use of a
|
|
1467
|
+
// command (`aegiscode -p "/cost"`, `--json -p "/models"`) was affected, and
|
|
1468
|
+
// the failure was indistinguishable from a server outage.
|
|
1469
|
+
const parsed = parseLine(prompt);
|
|
1470
|
+
if (parsed.kind !== 'prompt') return runOnceCommand(prompt, parsed, { json });
|
|
1438
1471
|
// Snapshot the account's existing ledger BEFORE the billed call. Without
|
|
1439
1472
|
// this the refresh after the turn would treat every historical row as new,
|
|
1440
1473
|
// and the reported charge would be whatever the account spent last rather
|
|
@@ -1473,6 +1506,64 @@ function createApp(options = {}) {
|
|
|
1473
1506
|
return res.interrupted ? 130 : 0;
|
|
1474
1507
|
}
|
|
1475
1508
|
|
|
1509
|
+
/**
|
|
1510
|
+
* The one-shot variant of `handleLine`: run a local command and print what it
|
|
1511
|
+
* produced. Returns the process exit code.
|
|
1512
|
+
*
|
|
1513
|
+
* The commands are dispatched through the SAME `handleLine` the interactive
|
|
1514
|
+
* loop uses — not a second implementation — so `/cost`, `/models` and friends
|
|
1515
|
+
* cannot answer differently depending on whether a human was watching. What
|
|
1516
|
+
* this adds over the interactive path is only the two things a non-interactive
|
|
1517
|
+
* caller has that the loop does not: an exit code, and, under `--json`, a
|
|
1518
|
+
* machine-readable envelope around the command's own output.
|
|
1519
|
+
*
|
|
1520
|
+
* Preferences are restored first. The interactive entry point calls
|
|
1521
|
+
* `restorePrefs()` on startup and this one never did, so a command run through
|
|
1522
|
+
* `-p` would have read a context that ignored the config on disk — `/model`
|
|
1523
|
+
* with no pin, for instance, would not have seen the model the user pinned.
|
|
1524
|
+
*/
|
|
1525
|
+
async function runOnceCommand(line, parsed, { json }) {
|
|
1526
|
+
if (parsed.kind === 'empty') return 0;
|
|
1527
|
+
if (parsed.kind === 'unknown') {
|
|
1528
|
+
// Straight to stderr, and non-zero: an unknown command is a caller bug, and
|
|
1529
|
+
// `-p` is the entry point scripts use. Going through `emit` would put the
|
|
1530
|
+
// diagnostic on stdout where a `$(...)` capture would swallow it, and
|
|
1531
|
+
// exiting 0 would make a typo look like a success.
|
|
1532
|
+
const alt = nearest(parsed.name);
|
|
1533
|
+
err.write(`aegiscode: unknown command: /${parsed.name}${alt ? ` — did you mean /${alt}?` : ''}\n`);
|
|
1534
|
+
return 2;
|
|
1535
|
+
}
|
|
1536
|
+
restorePrefs();
|
|
1537
|
+
await refreshSpend();
|
|
1538
|
+
const lines = json ? [] : null;
|
|
1539
|
+
if (lines) capture = lines;
|
|
1540
|
+
let keep = true;
|
|
1541
|
+
try {
|
|
1542
|
+
keep = await handleLine(line);
|
|
1543
|
+
} finally {
|
|
1544
|
+
capture = null;
|
|
1545
|
+
}
|
|
1546
|
+
if (json) {
|
|
1547
|
+
out.write(
|
|
1548
|
+
JSON.stringify(
|
|
1549
|
+
{
|
|
1550
|
+
command: parsed.kind === 'command' ? '/' + parsed.command.name : line,
|
|
1551
|
+
arg: parsed.arg || '',
|
|
1552
|
+
// `handleLine` returns false when the command asked to end the
|
|
1553
|
+
// session (`/quit`, `/exit`); in one-shot that simply means the
|
|
1554
|
+
// command ran and there is nothing further to do.
|
|
1555
|
+
ended: keep === false,
|
|
1556
|
+
output: lines,
|
|
1557
|
+
balance_eur: session.balance,
|
|
1558
|
+
},
|
|
1559
|
+
null,
|
|
1560
|
+
2
|
|
1561
|
+
) + '\n'
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
return 0;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1476
1567
|
/** Fold one completed turn's usage into the session tallies.
|
|
1477
1568
|
* @returns {number|null} the total token count for the turn, when known. */
|
|
1478
1569
|
function recordTurn(res) {
|
package/src/art.js
CHANGED
|
@@ -9,7 +9,10 @@ const { caps, detect, cells, padCells } = require('./caps.js');
|
|
|
9
9
|
* A platform *name* is still accepted because it is the shape a test wants when
|
|
10
10
|
* it is asking "what would the mark look like on that host?"; it is resolved
|
|
11
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.
|
|
12
|
+
* convenience alias for a capability probe, never a second decision path. Under
|
|
13
|
+
* the uniform policy `detect()` ignores the platform it is handed, so
|
|
14
|
+
* `capsOf('win32')` and `capsOf('linux')` return the same axes — which is the
|
|
15
|
+
* point, and is asserted by `test/cli-terminal-caps.test.mjs`.
|
|
13
16
|
*/
|
|
14
17
|
function capsOf(target) {
|
|
15
18
|
if (!target) return caps();
|
|
@@ -81,27 +84,31 @@ const TAGLINE = 'Your intent, AI automated.';
|
|
|
81
84
|
const TAGLINE_SHORT = 'Your intent, automated.';
|
|
82
85
|
|
|
83
86
|
// ── Terminal portability ─────────────────────────────────────────────────────
|
|
84
|
-
// The wordmark is drawn with U+2550 box-drawing runes
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
// offending code points 1:1 (same character count per row) so the width maths
|
|
89
|
-
// stays exact and the mark keeps its shape.
|
|
87
|
+
// The wordmark is drawn with U+2550 box-drawing runes, which are single-width on
|
|
88
|
+
// essentially every terminal in use. Each pass swaps offending code points 1:1
|
|
89
|
+
// (same character count per row) so the width maths stays exact and the mark
|
|
90
|
+
// keeps its shape.
|
|
90
91
|
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
92
|
+
// A pass is applied when the user ASKS for one — `AEGIS_ART=ascii` for a font
|
|
93
|
+
// with no box-drawing or block range, `AEGIS_STAR=narrow` for a font that
|
|
94
|
+
// renders ✦ through a two-cell emoji fallback. It is never triggered by the
|
|
95
|
+
// host: `process.platform`, `TERM`, `TERM_PROGRAM`, `WT_SESSION` and the
|
|
96
|
+
// locale's character set are probed and reported by `caps.js` and then
|
|
97
|
+
// deliberately ignored, because a font that lacks the runes is something only
|
|
98
|
+
// the person looking at the screen can settle. Previously PowerShell outside
|
|
99
|
+
// Windows Terminal, Terminal.app and any `LANG=C` shell each silently got a
|
|
100
|
+
// different mark from the same build.
|
|
101
|
+
//
|
|
102
|
+
// The passes still compose rather than being picked one-of-three, because the
|
|
103
|
+
// two overrides are independent: `AEGIS_STAR=narrow` alone gives a native block
|
|
104
|
+
// palette with a single-column star, which no single flat table could express.
|
|
98
105
|
//
|
|
99
106
|
// This table is the ONE stencil source of truth for the product. `theme.js`
|
|
100
107
|
// resolves `GLYPH.star` through `stencilGlyph(STAR, caps)` rather than carrying
|
|
101
108
|
// its own `'✦' → '*'` rule, and `render.js` builds the mark's tint map by
|
|
102
109
|
// stencilling its runes — both had a private copy of the same decision, which
|
|
103
|
-
// is how a stencil edit here could leave the star wide on
|
|
104
|
-
// untinted on
|
|
110
|
+
// is how a stencil edit here could leave the star wide on one host and the mark
|
|
111
|
+
// untinted on another. `test/cli-terminal-caps.test.mjs` pins all of it.
|
|
105
112
|
const STAR = '✦';
|
|
106
113
|
|
|
107
114
|
/** The quartile/quadrant face edges. The wordmark no longer draws them, but the
|
|
@@ -145,9 +152,9 @@ const EDGE_STENCIL = new Map(EDGE_RUNES.map((c) => [c, '#']));
|
|
|
145
152
|
const STAR_STENCIL = new Map([[STAR, '*']]);
|
|
146
153
|
|
|
147
154
|
/**
|
|
148
|
-
* The named passes. They compose rather than being picked one-of-three:
|
|
149
|
-
*
|
|
150
|
-
*
|
|
155
|
+
* The named passes. They compose rather than being picked one-of-three:
|
|
156
|
+
* `AEGIS_STAR=narrow` takes `star` only — a native block palette with a
|
|
157
|
+
* single-column star — and `AEGIS_ART=ascii` takes the full pass.
|
|
151
158
|
*/
|
|
152
159
|
const STENCILS = { ascii: ASCII_STENCIL, edges: EDGE_STENCIL, star: STAR_STENCIL };
|
|
153
160
|
|
package/src/caps.js
CHANGED
|
@@ -3,35 +3,39 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Terminal capabilities — ONE probe, resolved once, consulted by everything.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* POLICY: aegiscode renders ONE way. `process.platform`, `TERM`, `TERM_PROGRAM`,
|
|
7
|
+
* the locale's character set and the Windows terminal markers are all still
|
|
8
|
+
* probed — because the support surface reports them — but not one of them may
|
|
9
|
+
* move a single byte of what is drawn. PowerShell in Windows Terminal,
|
|
10
|
+
* Terminal.app, a legacy Windows console, WSL and zsh over SSH all get the same
|
|
11
|
+
* palette, the same mark, the same colour depth, the same control sequences and
|
|
12
|
+
* the same `\n`. A screenshot of one is a screenshot of all of them.
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
* █▓▒░▐▛▜▌▝▘ and ✦ exactly like zsh does — but `process.platform` is still
|
|
14
|
-
* `win32`, so it was being handed the hyphen-and-hash ASCII mark.
|
|
15
|
-
* · `zsh` over SSH from a Windows box, inside `mintty`/`ConEmu`, is `linux`
|
|
16
|
-
* on the far side and `win32` on the client — the mark must be chosen once,
|
|
17
|
-
* from what the *terminal* can draw.
|
|
14
|
+
* What used to differ by platform or environment, and no longer does:
|
|
18
15
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
16
|
+
* · Windows got the ASCII stencil because `process.platform` was `win32` —
|
|
17
|
+
* even *inside Windows Terminal*, which draws █▓▒░▐▛▜▌▝▘ and ✦ exactly like
|
|
18
|
+
* zsh does.
|
|
19
|
+
* · Terminal.app got a half-stencil (edges stencilled, star narrowed) because
|
|
20
|
+
* its font stack lacks ▐▛▜▌▝▘ and renders ✦ through the wide emoji fallback.
|
|
21
|
+
* · A non-UTF-8 locale, or `TERM=dumb`, dropped the whole UI to ASCII — so the
|
|
22
|
+
* same build looked like a different product in `LANG=C` CI.
|
|
23
|
+
* · `TERM=linux|vt100|ansi` and a legacy console flattened truecolor to the 16
|
|
24
|
+
* ANSI slots.
|
|
25
|
+
* · A redirected run on Windows wrote CRLF; the same run on Linux wrote LF.
|
|
26
|
+
*
|
|
27
|
+
* The probe is not gone, it is just no longer *implicit*. Every axis below is
|
|
28
|
+
* still overridable, and an override is now the ONLY thing that changes the
|
|
29
|
+
* rendering. All of them are environment variables and flags, so they are
|
|
30
|
+
* spelled and behave identically on every platform, and the resulting look is
|
|
31
|
+
* reproducible from a bug report without asking what OS it came from.
|
|
26
32
|
*
|
|
27
33
|
* The axes:
|
|
28
|
-
* glyphs 'unicode' | 'ascii' —
|
|
29
|
-
* face 'native' | 'edges' —
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* depth 24 | 8 | 4 | 0 — truecolor, 256, the 16 ANSI slots, none
|
|
34
|
-
* vt boolean — are cursor/erase escapes honoured?
|
|
34
|
+
* glyphs 'unicode' | 'ascii' — the mark's palette (unicode by default)
|
|
35
|
+
* face 'native' | 'edges' — the quartile edges ▐▛▜▌▝▘
|
|
36
|
+
* star 'native' | 'narrow' — ✦ as a single-cell glyph, or stencilled to `*`
|
|
37
|
+
* depth 24 | 8 | 4 | 0 — truecolor by default
|
|
38
|
+
* vt boolean — cursor/erase escapes (on by default)
|
|
35
39
|
* cols/rows — the frame, with `AEGIS_WIDTH`/`COLUMNS` over
|
|
36
40
|
* the reported size and a stable 80 fallback,
|
|
37
41
|
* wideRunes — runes the terminal draws two cells wide
|
|
@@ -43,6 +47,7 @@
|
|
|
43
47
|
* AEGIS_ART=unicode|ascii AEGIS_ASCII=1 AEGIS_UNICODE=0|1
|
|
44
48
|
* AEGIS_STAR=native|narrow AEGIS_COLOR=0|1|2|3
|
|
45
49
|
* AEGIS_VT=0|1 AEGIS_WIDTH=<cols> AEGIS_WIDE_RUNES=<runes>
|
|
50
|
+
* AEGIS_FORCE_TRUECOLOR=0 NO_COLOR FORCE_COLOR=0|1|2|3
|
|
46
51
|
*
|
|
47
52
|
* `caps()` is cached; `setCaps()` re-resolves and notifies subscribers, which is
|
|
48
53
|
* how `theme.js` re-materialises its palette and glyph table when the user runs
|
|
@@ -63,11 +68,15 @@ const RE_ZERO = /[\u0300-\u036F\u1AB0-\u1AFF\u1DC0-\u1DFF\u20D0-\u20FF\uFE00-\uF
|
|
|
63
68
|
const RE_WIDE = /[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uA960-\uA97F\uAC00-\uD7A3\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6\u{1F1E6}-\u{1F1FF}\u{1F300}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1F9FF}\u{1FA70}-\u{1FAFF}\u{20000}-\u{3FFFD}]/u;
|
|
64
69
|
|
|
65
70
|
/**
|
|
66
|
-
* Windows terminals that draw the full mark. `WT_SESSION` is set by Windows
|
|
71
|
+
* Windows terminals that can draw the full mark. `WT_SESSION` is set by Windows
|
|
67
72
|
* Terminal for every shell it hosts (pwsh, cmd, wsl, git-bash); `TERM_PROGRAM`
|
|
68
73
|
* by VS Code and the other Electron/ConPTY hosts; the rest are the classic
|
|
69
|
-
* ConPTY-era consoles.
|
|
70
|
-
*
|
|
74
|
+
* ConPTY-era consoles.
|
|
75
|
+
*
|
|
76
|
+
* Reported, never consulted: the rendering is uniform whether one of these is
|
|
77
|
+
* set or not (see the policy at the top of this file). The list survives so
|
|
78
|
+
* `--terminal` can say "Windows VT host (WT_SESSION)" in a bug report, which is
|
|
79
|
+
* how a support thread knows the user's console can draw what we draw.
|
|
71
80
|
*/
|
|
72
81
|
const MODERN_WINDOWS = [
|
|
73
82
|
'WT_SESSION',
|
|
@@ -80,27 +89,6 @@ const MODERN_WINDOWS = [
|
|
|
80
89
|
'KITTY_WINDOW_ID',
|
|
81
90
|
];
|
|
82
91
|
|
|
83
|
-
/**
|
|
84
|
-
* `TERM_PROGRAM` values whose font renders the whole palette natively, `✦`
|
|
85
|
-
* included. `Apple_Terminal` is deliberately NOT here — see `resolveGlyphs`.
|
|
86
|
-
*/
|
|
87
|
-
const NATIVE_TERM_PROGRAMS = new Set([
|
|
88
|
-
'vscode',
|
|
89
|
-
'vscode-insiders',
|
|
90
|
-
'iTerm.app',
|
|
91
|
-
'WezTerm',
|
|
92
|
-
'kitty',
|
|
93
|
-
'ghostty',
|
|
94
|
-
'Alacritty',
|
|
95
|
-
'Hyper',
|
|
96
|
-
'Tabby',
|
|
97
|
-
'WarpTerminal',
|
|
98
|
-
'Warp',
|
|
99
|
-
'rio',
|
|
100
|
-
'mintty',
|
|
101
|
-
'JetBrains-JediTerm',
|
|
102
|
-
]);
|
|
103
|
-
|
|
104
92
|
const TRUTHY_RE = /^(1|true|yes|on)$/i;
|
|
105
93
|
|
|
106
94
|
/** Is an env value "on"? (`WT_SESSION=` with no value still counts.) */
|
|
@@ -124,20 +112,16 @@ function modernWindows(env) {
|
|
|
124
112
|
|
|
125
113
|
/**
|
|
126
114
|
* The locale's character set. POSIX terminals signal UTF-8 support here and
|
|
127
|
-
* nowhere else
|
|
128
|
-
*
|
|
115
|
+
* nowhere else. Recorded for the support surface only: a `LANG=C` shell renders
|
|
116
|
+
* the same Unicode mark as a UTF-8 one, so that the same build cannot look like
|
|
117
|
+
* a different product on a differently-configured host. A terminal whose font
|
|
118
|
+
* genuinely lacks the palette is a deliberate `AEGIS_ART=ascii`.
|
|
129
119
|
*/
|
|
130
120
|
function localeOf(env) {
|
|
131
121
|
const hit = firstEnv(env, ['LC_ALL', 'LC_CTYPE', 'LANG']);
|
|
132
122
|
return hit ? hit.value : '';
|
|
133
123
|
}
|
|
134
124
|
|
|
135
|
-
function utf8Locale(env) {
|
|
136
|
-
const loc = localeOf(env);
|
|
137
|
-
if (!loc) return true; // unset: every shell we ship to defaults to UTF-8
|
|
138
|
-
return /utf-?8/i.test(loc);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
125
|
/** The explicit art mode, or 'auto'. */
|
|
142
126
|
function artMode(env) {
|
|
143
127
|
const raw = String(env.AEGIS_ART || '').trim().toLowerCase();
|
|
@@ -149,10 +133,24 @@ function artMode(env) {
|
|
|
149
133
|
}
|
|
150
134
|
|
|
151
135
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
136
|
+
* What the mark is drawn with — the same answer on every platform.
|
|
137
|
+
*
|
|
138
|
+
* Only an explicit request moves this: `AEGIS_ART` (the valued switch),
|
|
139
|
+
* `AEGIS_ASCII`/`AEGIS_UNICODE` (the booleans it supersedes), or `AEGIS_STAR`
|
|
140
|
+
* for a font that renders ✦ through a wide emoji fallback. Everything else —
|
|
141
|
+
* `process.platform`, `TERM`, `TERM_PROGRAM`, `WT_SESSION`, the locale's
|
|
142
|
+
* character set — is recorded in the resolved `reasons` for the support surface
|
|
143
|
+
* and then deliberately ignored.
|
|
144
|
+
*
|
|
145
|
+
* The old behaviour read those signals and silently downgraded: a `win32`
|
|
146
|
+
* process outside a ConPTY host, an Apple Terminal, `TERM=dumb` and any
|
|
147
|
+
* non-UTF-8 locale each got a different product. That made the same build look
|
|
148
|
+
* unlike itself from one machine to the next, and it made the *reason* for the
|
|
149
|
+
* difference invisible to the person looking at the screen. A terminal that
|
|
150
|
+
* genuinely cannot draw the palette now says so with the documented override,
|
|
151
|
+
* which is a decision the user makes once and the support surface can report.
|
|
152
|
+
*
|
|
153
|
+
* `platform` is accepted (and reported) but never branched on.
|
|
156
154
|
*/
|
|
157
155
|
function resolveGlyphs(env, platform) {
|
|
158
156
|
const starPref = String(env.AEGIS_STAR || '').trim().toLowerCase();
|
|
@@ -170,56 +168,11 @@ function resolveGlyphs(env, platform) {
|
|
|
170
168
|
return { glyphs: 'unicode', face: 'native', star: star || 'native', reason: 'AEGIS_ART=unicode' };
|
|
171
169
|
}
|
|
172
170
|
|
|
173
|
-
if (String(env.TERM || '').toLowerCase() === 'dumb') {
|
|
174
|
-
return { glyphs: 'ascii', face: 'edges', star: 'narrow', reason: 'TERM=dumb' };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (platform === 'win32') {
|
|
178
|
-
const modern = modernWindows(env);
|
|
179
|
-
if (!modern) {
|
|
180
|
-
return {
|
|
181
|
-
glyphs: 'ascii',
|
|
182
|
-
face: 'edges',
|
|
183
|
-
star: 'narrow',
|
|
184
|
-
reason: 'legacy Windows console (no WT_SESSION/ConEmu/TERM_PROGRAM) — Consolas has no block glyphs',
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
// A ConPTY host (Windows Terminal, VS Code, ConEmu) renders the block
|
|
188
|
-
// palette, and ConPTY does font fallback — Cascadia Mono lacks ✦ but the
|
|
189
|
-
// system symbol fonts carry it single-width, so the star is drawn natively
|
|
190
|
-
// and the welcome mark is byte-identical to the one zsh prints. That parity
|
|
191
|
-
// is the point: `star: 'narrow'` here would swap all eleven ✦ in the mark
|
|
192
|
-
// for '*', which is the difference a PowerShell user sees.
|
|
193
|
-
//
|
|
194
|
-
// The escape hatches are for the font that does *not* fall back cleanly:
|
|
195
|
-
// AEGIS_STAR=narrow swaps ✦ for '*', AEGIS_WIDE_RUNES=✦ tells the width
|
|
196
|
-
// maths the glyph is two cells wide (which is what a bad fallback actually
|
|
197
|
-
// breaks — the row alignment, not the rune).
|
|
198
|
-
return {
|
|
199
|
-
glyphs: 'unicode',
|
|
200
|
-
face: 'native',
|
|
201
|
-
star: star || 'native',
|
|
202
|
-
reason: `Windows VT host (${modern.name})`,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (!utf8Locale(env)) {
|
|
207
|
-
return { glyphs: 'ascii', face: 'edges', star: 'narrow', reason: `locale is not UTF-8 (${localeOf(env)})` };
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const program = String(env.TERM_PROGRAM || '');
|
|
211
|
-
if (platform === 'darwin' && program === 'Apple_Terminal') {
|
|
212
|
-
// Terminal.app's font stack has no ▐▛▜▌▝▘ and renders ✦ with the emoji
|
|
213
|
-
// fallback (two cells), so it gets the edge pass and a narrow star — the
|
|
214
|
-
// shipped behaviour on macOS, now expressed as a capability, not a platform.
|
|
215
|
-
return { glyphs: 'unicode', face: 'edges', star: 'narrow', reason: 'Apple_Terminal font stack' };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
171
|
return {
|
|
219
172
|
glyphs: 'unicode',
|
|
220
173
|
face: 'native',
|
|
221
174
|
star: star || 'native',
|
|
222
|
-
reason:
|
|
175
|
+
reason: `uniform default on every platform${star ? ` (AEGIS_STAR=${starPref})` : ''}`,
|
|
223
176
|
};
|
|
224
177
|
}
|
|
225
178
|
|
|
@@ -227,15 +180,19 @@ function resolveGlyphs(env, platform) {
|
|
|
227
180
|
* Colour depth in bits per channel: 24 truecolor, 8 the 256-colour cube, 4 the
|
|
228
181
|
* 16 ANSI slots, 0 no colour at all.
|
|
229
182
|
*
|
|
230
|
-
*
|
|
231
|
-
* terminal
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* shown it.
|
|
183
|
+
* Truecolor, always, unless the user says otherwise. That is the honest default
|
|
184
|
+
* for every terminal in use: the 256-colour terminals all pass 24-bit SGR
|
|
185
|
+
* through, and a terminal that cannot simply downsamples it itself — which is
|
|
186
|
+
* the correct authority for the decision. The old probe tried to guess the
|
|
187
|
+
* terminal's ceiling from `TERM`, from the platform and from the Windows console
|
|
188
|
+
* markers, and every wrong guess flattened the palette on a machine that could
|
|
189
|
+
* have shown it *and* made Windows differ from Linux on identical hardware.
|
|
190
|
+
*
|
|
191
|
+
* `NO_COLOR` (non-empty), `FORCE_COLOR=0` and `AEGIS_COLOR=0` are the only ways
|
|
192
|
+
* to get depth 0; `FORCE_COLOR`/`AEGIS_COLOR` pick 4, 8 or 24; the older
|
|
193
|
+
* `AEGIS_FORCE_TRUECOLOR=0` still selects the 256-colour cube.
|
|
237
194
|
*/
|
|
238
|
-
function resolveDepth(env
|
|
195
|
+
function resolveDepth(env) {
|
|
239
196
|
if (env.NO_COLOR != null && env.NO_COLOR !== '') return { depth: 0, reason: 'NO_COLOR' };
|
|
240
197
|
const forced = String(env.FORCE_COLOR || '').trim();
|
|
241
198
|
if (forced === '0') return { depth: 0, reason: 'FORCE_COLOR=0' };
|
|
@@ -246,47 +203,23 @@ function resolveDepth(env, platform, isTTY) {
|
|
|
246
203
|
if (/^[0-3]$/.test(aegis)) {
|
|
247
204
|
return { depth: aegis === '0' ? 0 : aegis === '1' ? 4 : aegis === '2' ? 8 : 24, reason: `AEGIS_COLOR=${aegis}` };
|
|
248
205
|
}
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
const term = String(env.TERM || '').toLowerCase();
|
|
253
|
-
if (term === 'dumb') return { depth: 0, reason: 'TERM=dumb' };
|
|
254
|
-
if (platform === 'win32') {
|
|
255
|
-
const modern = modernWindows(env);
|
|
256
|
-
if (modern) return { depth: 24, reason: `Windows VT host (${modern.name})` };
|
|
257
|
-
// The classic console: 16 slots, and only when it is actually a console.
|
|
258
|
-
if (isTTY) return { depth: 4, reason: 'legacy Windows console' };
|
|
259
|
-
return { depth: 24, reason: 'redirected output' };
|
|
260
|
-
}
|
|
261
|
-
if (/^(linux|vt100|vt220|ansi|cons25|sun|dumb)$/.test(term) || /^xterm-color$/.test(term)) {
|
|
262
|
-
return { depth: 4, reason: `TERM=${term}` };
|
|
263
|
-
}
|
|
264
|
-
if (env.AEGIS_FORCE_TRUECOLOR === '0' || env.TERM_PROGRAM === 'Apple_Terminal') {
|
|
265
|
-
// Terminal.app advertises truecolor and honours 24-bit SGR on every release
|
|
266
|
-
// that still runs, so it keeps its depth; the check exists for the older
|
|
267
|
-
// builds that dithered. AEGIS_FORCE_TRUECOLOR=0 is the user's override.
|
|
268
|
-
if (env.AEGIS_FORCE_TRUECOLOR === '0') return { depth: 8, reason: 'AEGIS_FORCE_TRUECOLOR=0' };
|
|
269
|
-
}
|
|
270
|
-
return { depth: 24, reason: term ? `TERM=${term}` : 'default' };
|
|
206
|
+
if (env.AEGIS_FORCE_TRUECOLOR === '0') return { depth: 8, reason: 'AEGIS_FORCE_TRUECOLOR=0' };
|
|
207
|
+
return { depth: 24, reason: 'uniform default: truecolor on every platform' };
|
|
271
208
|
}
|
|
272
209
|
|
|
273
210
|
/**
|
|
274
|
-
* Cursor and erase control
|
|
275
|
-
*
|
|
276
|
-
*
|
|
211
|
+
* Cursor and erase control — on everywhere, since every terminal we ship to
|
|
212
|
+
* honours it, and off only for an explicit `AEGIS_VT=0`. The old probe guessed
|
|
213
|
+
* from the platform and the console markers, which meant the live spinner line
|
|
214
|
+
* behaved differently in a Windows console than in a Linux one; a redirected
|
|
215
|
+
* Windows run is no longer treated as a terminal that would print `\x1b[2K` as
|
|
216
|
+
* text, because that is the same run everywhere and should render the same.
|
|
277
217
|
*/
|
|
278
|
-
function resolveVt(env
|
|
218
|
+
function resolveVt(env) {
|
|
279
219
|
const pref = String(env.AEGIS_VT == null ? '' : env.AEGIS_VT).trim();
|
|
280
220
|
if (pref === '0') return { vt: false, reason: 'AEGIS_VT=0' };
|
|
281
221
|
if (pref === '1' || /^(true|yes|on)$/i.test(pref)) return { vt: true, reason: 'AEGIS_VT=1' };
|
|
282
|
-
|
|
283
|
-
if (platform === 'win32') {
|
|
284
|
-
const modern = modernWindows(env);
|
|
285
|
-
if (modern) return { vt: true, reason: `Windows VT host (${modern.name})` };
|
|
286
|
-
if (isTTY) return { vt: true, reason: 'console host (Node enables VT processing)' };
|
|
287
|
-
return { vt: false, reason: 'redirected output' };
|
|
288
|
-
}
|
|
289
|
-
return { vt: true, reason: 'POSIX terminal' };
|
|
222
|
+
return { vt: true, reason: 'uniform default: ansi on every platform' };
|
|
290
223
|
}
|
|
291
224
|
|
|
292
225
|
/**
|
|
@@ -323,24 +256,33 @@ function resolveWideRunes(env) {
|
|
|
323
256
|
|
|
324
257
|
/**
|
|
325
258
|
* Resolve every axis, purely, from an environment and a stream. Exported so the
|
|
326
|
-
*
|
|
259
|
+
* uniformity invariant is a plain function call in a test — no subprocess, no
|
|
260
|
+
* TTY.
|
|
261
|
+
*
|
|
262
|
+
* `platform` is recorded in the result and threaded into the *reasons*, so a
|
|
263
|
+
* support paste still says which host it came from; nothing else reads it. The
|
|
264
|
+
* line ending is `\n` on every platform, including a redirected run on Windows:
|
|
265
|
+
* the one divergence the previous probe allowed is exactly the kind of thing
|
|
266
|
+
* that makes two identical invocations produce different bytes.
|
|
327
267
|
*
|
|
328
268
|
* @param {object} [env] defaults to `process.env`
|
|
329
269
|
* @param {object} [stdout] defaults to `process.stdout`
|
|
330
|
-
* @param {string} [platform] defaults to `process.platform`
|
|
270
|
+
* @param {string} [platform] defaults to `process.platform` (reported, not consulted)
|
|
331
271
|
*/
|
|
332
272
|
function detect(env = process.env, stdout = process.stdout, platform = process.platform) {
|
|
333
273
|
const isTTY = !!(stdout && stdout.isTTY);
|
|
334
274
|
const glyph = resolveGlyphs(env, platform);
|
|
335
|
-
const color = resolveDepth(env
|
|
336
|
-
const vt = resolveVt(env
|
|
275
|
+
const color = resolveDepth(env);
|
|
276
|
+
const vt = resolveVt(env);
|
|
337
277
|
const size = resolveSize(env, stdout);
|
|
278
|
+
const host = platform === 'win32' ? modernWindows(env) : null;
|
|
338
279
|
return {
|
|
339
280
|
platform,
|
|
340
281
|
isTTY,
|
|
341
282
|
term: String(env.TERM || ''),
|
|
342
283
|
termProgram: String(env.TERM_PROGRAM || ''),
|
|
343
284
|
locale: localeOf(env),
|
|
285
|
+
windowsHost: host ? host.name : '',
|
|
344
286
|
glyphs: glyph.glyphs,
|
|
345
287
|
face: glyph.face,
|
|
346
288
|
star: glyph.star,
|
|
@@ -349,7 +291,7 @@ function detect(env = process.env, stdout = process.stdout, platform = process.p
|
|
|
349
291
|
vt: vt.vt,
|
|
350
292
|
cols: size.cols,
|
|
351
293
|
rows: size.rows,
|
|
352
|
-
eol:
|
|
294
|
+
eol: '\n',
|
|
353
295
|
wideRunes: resolveWideRunes(env),
|
|
354
296
|
reasons: {
|
|
355
297
|
glyphs: glyph.reason,
|
|
@@ -556,11 +498,18 @@ function bg(r, g, b) {
|
|
|
556
498
|
/**
|
|
557
499
|
* The resolved capabilities as `[label, value]` rows — one shape, same on every
|
|
558
500
|
* platform, so a support paste from PowerShell reads like one from zsh.
|
|
501
|
+
*
|
|
502
|
+
* The first three rows are the host as *reported*: they are the only place the
|
|
503
|
+
* platform, the terminal brand and the locale appear, and they cannot influence
|
|
504
|
+
* any row below them. That is the point of the layout — a reader can see at a
|
|
505
|
+
* glance that the mark, the colour, the control sequences and the line ending
|
|
506
|
+
* are the same on every machine, while still knowing which machine produced the
|
|
507
|
+
* paste.
|
|
559
508
|
*/
|
|
560
509
|
function describe(c = caps()) {
|
|
561
|
-
const
|
|
510
|
+
const host = [c.platform, c.isTTY ? '' : '(no tty)'].filter(Boolean).join(' ');
|
|
562
511
|
return [
|
|
563
|
-
['platform', `${
|
|
512
|
+
['platform', c.windowsHost ? `${host} — ${c.windowsHost}` : host],
|
|
564
513
|
['terminal', c.termProgram || c.term || 'unknown'],
|
|
565
514
|
['locale', c.locale || 'unset'],
|
|
566
515
|
['mark', c.glyphs === 'ascii' ? 'ascii' : c.face === 'edges' ? 'unicode (edges stencilled)' : 'unicode'],
|
|
@@ -568,7 +517,7 @@ function describe(c = caps()) {
|
|
|
568
517
|
['color', c.depth === 0 ? 'none' : c.depth >= 24 ? 'truecolor' : c.depth >= 8 ? '256' : '16'],
|
|
569
518
|
['control', c.vt ? 'ansi' : 'plain'],
|
|
570
519
|
['size', `${c.cols}x${c.rows} (${c.reasons.size})`],
|
|
571
|
-
['eol',
|
|
520
|
+
['eol', '\\n'],
|
|
572
521
|
['why', `${c.reasons.glyphs}; ${c.reasons.depth}`],
|
|
573
522
|
];
|
|
574
523
|
}
|
|
@@ -593,5 +542,4 @@ module.exports = {
|
|
|
593
542
|
resolveVt,
|
|
594
543
|
resolveSize,
|
|
595
544
|
MODERN_WINDOWS,
|
|
596
|
-
NATIVE_TERM_PROGRAMS,
|
|
597
545
|
};
|