aegiscode 6.6.1 → 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/app.js +156 -11
- package/src/art.js +114 -60
- package/src/autonomous.js +8 -2
- package/src/caps.js +597 -0
- package/src/chatflow.js +59 -6
- package/src/cloudsync.js +86 -6
- package/src/commands.js +243 -23
- package/src/config.js +87 -0
- package/src/diff.js +330 -0
- package/src/diffview.js +286 -0
- package/src/events.js +21 -10
- package/src/panels.js +59 -1
- package/src/render.js +39 -17
- package/src/screen.js +20 -20
- package/src/theme.js +334 -125
- package/vendor/desktop/lib/local/autonomous.js +45 -4
- package/vendor/desktop/lib/local/engine.js +38 -0
- package/vendor/desktop/lib/local/queue.js +4 -0
- package/vendor/desktop/lib/local/session-rounds.js +19 -2
package/src/theme.js
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Design tokens — the aegiscodex-dev design system, adopted wholesale
|
|
4
|
+
* Design tokens — the aegiscodex-dev design system, adopted wholesale, and
|
|
5
|
+
* resolved through the terminal's capabilities (`caps.js`) rather than the
|
|
6
|
+
* platform the process happens to run on.
|
|
5
7
|
*
|
|
6
|
-
* Every value below is copied verbatim from `aegiscodex-dev/src/theme.js`,
|
|
7
|
-
* extracted them from the live ANSI stream of Claude Code: gold 255,193,7
|
|
8
|
-
* coral 215,119,87 · lavender 177,185,249 · blue 120,160,250 · green 78,186,101
|
|
9
|
-
* · red 220,90,90 · gray 153,153,153 · dim 80,80,80.
|
|
8
|
+
* Every colour value below is copied verbatim from `aegiscodex-dev/src/theme.js`,
|
|
9
|
+
* which extracted them from the live ANSI stream of Claude Code: gold 255,193,7
|
|
10
|
+
* · coral 215,119,87 · lavender 177,185,249 · blue 120,160,250 · green 78,186,101
|
|
11
|
+
* · red 220,90,90 · gray 153,153,153 · dim 80,80,80. `test/cli-conformance.test.mjs`
|
|
12
|
+
* pins them to aegiscodex-dev's source and reads them back out of a truecolor
|
|
13
|
+
* SGR prefix, so the design cannot drift.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* What DOES change per terminal is how those triples reach the screen:
|
|
16
|
+
*
|
|
17
|
+
* · `RGB()`/`BG()` go through `caps.rgb()/caps.bg()`, which emit 24-bit SGR,
|
|
18
|
+
* the 256-colour cube, the 16 ANSI slots, or nothing at all — decided by the
|
|
19
|
+
* terminal, not by us. On a legacy Windows console or `TERM=linux` the UI
|
|
20
|
+
* now paints in colours that console can actually show, instead of emitting
|
|
21
|
+
* truecolor escapes it renders as literal text or dithers unpredictably.
|
|
22
|
+
* · `glyphsFor()` is a function of the resolved capabilities, so PowerShell in
|
|
23
|
+
* Windows Terminal gets the same ❯ ⎿ ✻ ✦ set as zsh, and only a terminal
|
|
24
|
+
* that genuinely cannot draw them (legacy console, `TERM=dumb`, a non-UTF-8
|
|
25
|
+
* locale, `AEGIS_ART=ascii`) gets the ASCII stand-ins.
|
|
26
|
+
*
|
|
27
|
+
* Both are re-materialised when the capabilities change (`onCapsChange`), so
|
|
28
|
+
* `aegiscode --ascii`, `--no-color` and the `/terminal` command take effect on
|
|
29
|
+
* the palette and glyph table of a *running* session — the exported objects are
|
|
30
|
+
* mutated in place rather than replaced, because renderers hold references to
|
|
31
|
+
* them (`const { C } = require('./theme.js')`).
|
|
15
32
|
*
|
|
16
33
|
* Zero dependencies: SGR escapes are hand-built, like the rest of this repo.
|
|
17
34
|
*/
|
|
18
35
|
|
|
36
|
+
const { caps, detect, onCapsChange, rgb, bg } = require('./caps.js');
|
|
37
|
+
|
|
19
38
|
// The stencil is the mark's single source of truth for its own runes — this
|
|
20
39
|
// file resolves `star` through it rather than restating the platform rule.
|
|
21
|
-
// `art.js` requires
|
|
40
|
+
// `art.js` requires only `caps.js`, so this import cannot cycle.
|
|
22
41
|
const { STAR, stencilGlyph } = require('./art.js');
|
|
23
42
|
|
|
24
43
|
const RESET = '\x1b[0m';
|
|
@@ -32,140 +51,171 @@ const UNDER_OFF = '\x1b[24m';
|
|
|
32
51
|
const RESET_FG = '\x1b[39m';
|
|
33
52
|
const RESET_BG = '\x1b[49m';
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
const
|
|
54
|
+
/** Truecolour foreground SGR (or the best the terminal can do — see caps.js). */
|
|
55
|
+
const RGB = (r, g, b) => rgb(r, g, b);
|
|
56
|
+
/** Truecolour background SGR (or the best the terminal can do). */
|
|
57
|
+
const BG = (r, g, b) => bg(r, g, b);
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
lavender: RGB(177, 185, 249), // selection cursor ❯, links, focused option
|
|
43
|
-
blue: RGB(120, 160, 250), // selected palette row
|
|
44
|
-
green: RGB(78, 186, 101), // checkmarks, success, diff additions
|
|
45
|
-
red: RGB(220, 90, 90), // diff removals, errors
|
|
46
|
-
gray: RGB(153, 153, 153), // secondary text, menu numbers, hints
|
|
47
|
-
dim: RGB(80, 80, 80), // ╌ divider lines
|
|
48
|
-
white: RGB(255, 255, 255), // primary text, spinner glyphs
|
|
49
|
-
black: RGB(30, 30, 30), // code-block background
|
|
50
|
-
darkBg: RGB(20, 20, 20), // theme card background
|
|
51
|
-
};
|
|
59
|
+
// ── the palettes ─────────────────────────────────────────────────────────────
|
|
60
|
+
// Built by functions and written into stable objects: `Object.assign` on every
|
|
61
|
+
// capability change keeps the key set identical (the conformance guard pins
|
|
62
|
+
// `Object.keys(C)`) while the escapes follow the new depth.
|
|
52
63
|
|
|
64
|
+
/** The dark palette. Role names match aegiscodex-dev exactly. */
|
|
65
|
+
const C = {};
|
|
53
66
|
/** Light-theme approximations, true to the dark palette's hue mapping. */
|
|
54
|
-
const LIGHT = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
const LIGHT = {};
|
|
68
|
+
/** The colourblind-friendly dark/light variants. */
|
|
69
|
+
const CB_DARK = {};
|
|
70
|
+
const CB_LIGHT = {};
|
|
71
|
+
/** The 16-colour ANSI-only variants. */
|
|
72
|
+
const ANSI_DARK = {};
|
|
73
|
+
const ANSI_LIGHT = {};
|
|
74
|
+
|
|
75
|
+
function buildDark() {
|
|
76
|
+
return {
|
|
77
|
+
gold: RGB(255, 193, 7), // header line, accents, welcome frame
|
|
78
|
+
coral: RGB(215, 119, 87), // "Welcome to ..." title
|
|
79
|
+
lavender: RGB(177, 185, 249), // selection cursor ❯, links, focused option
|
|
80
|
+
blue: RGB(120, 160, 250), // selected palette row
|
|
81
|
+
green: RGB(78, 186, 101), // checkmarks, success, diff additions
|
|
82
|
+
red: RGB(220, 90, 90), // diff removals, errors
|
|
83
|
+
gray: RGB(153, 153, 153), // secondary text, menu numbers, hints
|
|
84
|
+
dim: RGB(80, 80, 80), // ╌ divider lines
|
|
85
|
+
white: RGB(255, 255, 255), // primary text, spinner glyphs
|
|
86
|
+
black: RGB(30, 30, 30), // code-block background
|
|
87
|
+
darkBg: RGB(20, 20, 20), // theme card background
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function buildLight() {
|
|
92
|
+
return {
|
|
93
|
+
gold: RGB(180, 130, 0),
|
|
94
|
+
coral: RGB(190, 100, 70),
|
|
95
|
+
lavender: RGB(120, 130, 220),
|
|
96
|
+
blue: RGB(70, 110, 220),
|
|
97
|
+
green: RGB(60, 150, 80),
|
|
98
|
+
red: RGB(200, 60, 60),
|
|
99
|
+
gray: RGB(110, 110, 110),
|
|
100
|
+
dim: RGB(170, 170, 170),
|
|
101
|
+
white: RGB(40, 40, 40),
|
|
102
|
+
black: RGB(245, 245, 245),
|
|
103
|
+
darkBg: RGB(255, 255, 255),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function buildCbDark() {
|
|
108
|
+
return {
|
|
109
|
+
...buildDark(),
|
|
110
|
+
// The red/green pair — the one that carries meaning in diffs and errors —
|
|
111
|
+
// is remapped to the blue/orange axis, which stays distinguishable under
|
|
112
|
+
// deuteranopia and protanopia.
|
|
113
|
+
green: RGB(86, 182, 194),
|
|
114
|
+
red: RGB(255, 146, 43),
|
|
115
|
+
gold: RGB(255, 203, 71),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function buildCbLight() {
|
|
120
|
+
return {
|
|
121
|
+
...buildLight(),
|
|
122
|
+
green: RGB(30, 130, 145),
|
|
123
|
+
red: RGB(200, 100, 20),
|
|
124
|
+
gold: RGB(150, 110, 0),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 16-colour SGR foregrounds. Written as escape strings rather than RGB triples
|
|
129
|
+
// because the variant exists precisely to hand the decision to the terminal.
|
|
130
|
+
const A = (n) => (caps().color ? `\x1b[${n}m` : '');
|
|
131
|
+
|
|
132
|
+
function buildAnsiDark() {
|
|
133
|
+
return {
|
|
134
|
+
gold: A(93), coral: A(91), lavender: A(94), blue: A(94), green: A(92),
|
|
135
|
+
red: A(91), gray: A(90), dim: A(90), white: A(97), black: A(40),
|
|
136
|
+
darkBg: caps().color ? '\x1b[48;5;236m' : '',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function buildAnsiLight() {
|
|
141
|
+
return {
|
|
142
|
+
gold: A(33), coral: A(31), lavender: A(34), blue: A(34), green: A(32),
|
|
143
|
+
red: A(31), gray: A(90), dim: A(37), white: A(30), black: A(47),
|
|
144
|
+
darkBg: caps().color ? '\x1b[48;5;254m' : '',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
67
147
|
|
|
68
148
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
149
|
+
* Diff palette for edit blocks in the transcript — Monokai Extended, taken
|
|
150
|
+
* verbatim from the theme picker's preview (also `renderDiffPreview` in
|
|
151
|
+
* `aegiscodex-dev/src/markdown.js`) so the two can never drift apart: dim
|
|
152
|
+
* red/green backgrounds per row, the bright variant for the token that
|
|
153
|
+
* actually changed inside the row, and the monokai syntax colors for the code
|
|
154
|
+
* itself.
|
|
74
155
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* the glyph table would then disagree about the same character. Every other
|
|
80
|
-
* entry below is a *text* glyph (cursor, hook, spinner frames) that no art row
|
|
81
|
-
* contains, so it keeps its own definition.
|
|
156
|
+
* A SEPARATE export, not keys added to `C`/`LIGHT`: `test/cli-conformance.test.mjs`
|
|
157
|
+
* pins `Object.keys(C)` to exactly the eleven DEV_DARK role names, so a diff
|
|
158
|
+
* entry folded into the palette would fail the conformance guard. This is the
|
|
159
|
+
* same reason `DIFF` is its own object in the engine.
|
|
82
160
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
161
|
+
const DIFF = {};
|
|
162
|
+
const DIFF_LIGHT = {};
|
|
163
|
+
|
|
164
|
+
function buildDiff() {
|
|
165
|
+
return {
|
|
166
|
+
delFg: RGB(220, 90, 90),
|
|
167
|
+
delBg: BG(61, 1, 0),
|
|
168
|
+
delHiFg: RGB(248, 248, 242),
|
|
169
|
+
delHiBg: BG(92, 2, 0),
|
|
170
|
+
addFg: RGB(80, 200, 80),
|
|
171
|
+
addBg: BG(2, 40, 0),
|
|
172
|
+
addHiFg: RGB(255, 255, 255),
|
|
173
|
+
addHiBg: BG(4, 71, 0),
|
|
174
|
+
codeFg: RGB(248, 248, 242),
|
|
175
|
+
gutter: RGB(120, 120, 120),
|
|
176
|
+
kw: RGB(102, 217, 239),
|
|
177
|
+
fn: RGB(166, 226, 46),
|
|
178
|
+
str: RGB(230, 219, 116),
|
|
179
|
+
num: RGB(174, 129, 255),
|
|
180
|
+
comment: RGB(117, 113, 94),
|
|
99
181
|
};
|
|
100
|
-
if (platform === 'win32') {
|
|
101
|
-
return {
|
|
102
|
-
...base,
|
|
103
|
-
pause: '❚❚', // ⏸ U+23F8 missing from many Windows fonts
|
|
104
|
-
hook: '_|', // ⎿ U+23BF almost never present in Windows fonts
|
|
105
|
-
bloom: '*', // ✻ U+273B
|
|
106
|
-
spin: ['|', '/', '-', '\\', '*', '-'],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (platform === 'darwin') {
|
|
110
|
-
return {
|
|
111
|
-
...base,
|
|
112
|
-
pause: '❚❚', // ⏸ has an emoji presentation on Apple fonts
|
|
113
|
-
hook: '_|', // ⎿ U+23BF not in Apple monospace fonts
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return base;
|
|
117
182
|
}
|
|
118
183
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
184
|
+
/**
|
|
185
|
+
* The light-theme diff palette. Monokai's dark backgrounds on a light terminal
|
|
186
|
+
* are unreadable, so the row backgrounds invert to a pale tint and the code
|
|
187
|
+
* keeps its hue mapping from the dark set — the same relationship `LIGHT`
|
|
188
|
+
* already has to `C`.
|
|
189
|
+
*/
|
|
190
|
+
function buildDiffLight() {
|
|
191
|
+
return {
|
|
192
|
+
delFg: RGB(160, 40, 40),
|
|
193
|
+
delBg: BG(255, 235, 233),
|
|
194
|
+
delHiFg: RGB(90, 0, 0),
|
|
195
|
+
delHiBg: BG(255, 205, 200),
|
|
196
|
+
addFg: RGB(30, 130, 40),
|
|
197
|
+
addBg: BG(232, 250, 232),
|
|
198
|
+
addHiFg: RGB(0, 80, 0),
|
|
199
|
+
addHiBg: BG(195, 240, 195),
|
|
200
|
+
codeFg: RGB(40, 40, 40),
|
|
201
|
+
gutter: RGB(150, 150, 150),
|
|
202
|
+
kw: RGB(0, 120, 160),
|
|
203
|
+
fn: RGB(80, 140, 0),
|
|
204
|
+
str: RGB(150, 110, 0),
|
|
205
|
+
num: RGB(120, 60, 200),
|
|
206
|
+
comment: RGB(140, 140, 130),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
140
209
|
|
|
141
210
|
const THEMES = { dark: C, light: LIGHT };
|
|
142
211
|
|
|
143
212
|
/**
|
|
144
213
|
* The two extra palette families the reference's theme picker offers.
|
|
145
214
|
*
|
|
146
|
-
* `cb` is the colourblind-friendly variant
|
|
147
|
-
* carries meaning in diffs and errors) is remapped to the blue/orange axis so
|
|
148
|
-
* the two remain distinguishable under deuteranopia and protanopia. `ansi` uses
|
|
215
|
+
* `cb` is the colourblind-friendly variant (see `buildCbDark`). `ansi` uses
|
|
149
216
|
* the terminal's own 16-colour table, for terminals whose truecolour output is
|
|
150
217
|
* remapped anyway — the whole point being that the *terminal* decides, not us.
|
|
151
218
|
*/
|
|
152
|
-
const CB_DARK = { ...C, green: RGB(86, 182, 194), red: RGB(255, 146, 43), gold: RGB(255, 203, 71) };
|
|
153
|
-
const CB_LIGHT = { ...LIGHT, green: RGB(30, 130, 145), red: RGB(200, 100, 20), gold: RGB(150, 110, 0) };
|
|
154
|
-
|
|
155
|
-
// 16-colour SGR foregrounds. Written as escape strings rather than RGB triples
|
|
156
|
-
// because the variant exists precisely to hand the decision to the terminal.
|
|
157
|
-
const A = (n) => `\x1b[${n}m`;
|
|
158
|
-
const ANSI_DARK = {
|
|
159
|
-
gold: A(93), coral: A(91), lavender: A(94), blue: A(94), green: A(92),
|
|
160
|
-
red: A(91), gray: A(90), dim: A(90), white: A(97), black: A(40),
|
|
161
|
-
darkBg: '\x1b[48;5;236m',
|
|
162
|
-
};
|
|
163
|
-
const ANSI_LIGHT = {
|
|
164
|
-
gold: A(33), coral: A(31), lavender: A(34), blue: A(34), green: A(32),
|
|
165
|
-
red: A(31), gray: A(90), dim: A(37), white: A(30), black: A(47),
|
|
166
|
-
darkBg: '\x1b[48;5;254m',
|
|
167
|
-
};
|
|
168
|
-
|
|
169
219
|
/**
|
|
170
220
|
* The theme picker's table, copied from `aegiscodex-dev/src/screens.js` THEMES
|
|
171
221
|
* (names and notes verbatim). `light` is the flag the reference sets on commit
|
|
@@ -198,6 +248,12 @@ function themeForIndex(i) {
|
|
|
198
248
|
* exactly as before. The colourblind and ANSI families are only consulted when
|
|
199
249
|
* `themeIndex` actually names one of them (3–6), so an app that seeds
|
|
200
250
|
* `themeIndex` to 0/1 for light/dark is unaffected.
|
|
251
|
+
*
|
|
252
|
+
* The *depth* is deliberately not consulted here: `C` is already built from
|
|
253
|
+
* `RGB()`, which is depth-aware, so a 16-colour console gets a 16-colour dark
|
|
254
|
+
* palette rather than being silently switched to the ANSI picker row — the
|
|
255
|
+
* picker row must keep meaning "use the terminal's own table", not
|
|
256
|
+
* "your terminal is too old".
|
|
201
257
|
*/
|
|
202
258
|
function themeOf(ctx) {
|
|
203
259
|
if (ctx && typeof ctx.themeIndex === 'number' && ctx.themeIndex >= 3 && ctx.themeIndex <= 6) {
|
|
@@ -206,6 +262,155 @@ function themeOf(ctx) {
|
|
|
206
262
|
return ctx && ctx.light ? LIGHT : C;
|
|
207
263
|
}
|
|
208
264
|
|
|
265
|
+
/**
|
|
266
|
+
* The diff palette for a context — the exact companion of `themeOf`, so a
|
|
267
|
+
* caller never has to ask "which palette did the rows use?" separately from
|
|
268
|
+
* "which diff colors go with it?". `themeIndex` 3–6 are the four picker rows
|
|
269
|
+
* whose brightness is named by their own `light` flag; anything else falls
|
|
270
|
+
* back to the ctx's `light` flag, exactly as `themeOf` does.
|
|
271
|
+
*/
|
|
272
|
+
function diffOf(ctx) {
|
|
273
|
+
const light = ctx && typeof ctx.themeIndex === 'number' && ctx.themeIndex >= 3 && ctx.themeIndex <= 6
|
|
274
|
+
? !!THEME_TABLE[ctx.themeIndex].light
|
|
275
|
+
: !!(ctx && ctx.light);
|
|
276
|
+
return light ? DIFF_LIGHT : DIFF;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ── glyphs ───────────────────────────────────────────────────────────────────
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The glyph table for a terminal, resolved from its capabilities.
|
|
283
|
+
*
|
|
284
|
+
* A few of the reference's glyphs are missing from some terminal fonts
|
|
285
|
+
* (⎿ U+23BF, ⏸ U+23F8, ✔ U+2714, ▸ U+25B8) or render as double-width emoji
|
|
286
|
+
* (✦ U+2726, ✻/✢/✽/✶), which breaks row alignment exactly like the welcome art.
|
|
287
|
+
* The three capability classes in `caps.js` decide the set:
|
|
288
|
+
*
|
|
289
|
+
* · `glyphs: 'ascii'` — no Unicode claim at all: legacy Windows console,
|
|
290
|
+
* `TERM=dumb`, a non-UTF-8 locale, `AEGIS_ART=ascii`. Every mark becomes a
|
|
291
|
+
* single-column ASCII stand-in, so the layout is identical but nothing is
|
|
292
|
+
* mis-rendered by a font that lacks the glyph.
|
|
293
|
+
* · `face: 'edges'` — the block palette survives but the quartile edges
|
|
294
|
+
* and the typographic marks (⎿, ⏸, ✔) do not (Apple fonts, older Windows
|
|
295
|
+
* fonts). Only those are swapped.
|
|
296
|
+
* · native — the reference's own set, on any terminal that can
|
|
297
|
+
* draw it: Windows Terminal, VS Code, iTerm2, WezTerm, kitty, Ghostty,
|
|
298
|
+
* Alacritty, GNOME Terminal, xterm, zsh on Linux/macOS.
|
|
299
|
+
*
|
|
300
|
+
* `star` is NOT restated here: it is resolved through `art.js`'s stencil, the
|
|
301
|
+
* single source of truth for the mark's runes, so the glyph table and the art
|
|
302
|
+
* can never disagree about the same character.
|
|
303
|
+
*
|
|
304
|
+
* @param {string|object} [target] a `process.platform` name, or a caps object,
|
|
305
|
+
* or nothing at all for the live process's resolved capabilities.
|
|
306
|
+
*/
|
|
307
|
+
function glyphsFor(target = null) {
|
|
308
|
+
const c = !target
|
|
309
|
+
? caps()
|
|
310
|
+
: typeof target === 'string'
|
|
311
|
+
? detect(process.env, process.stdout, target)
|
|
312
|
+
: target;
|
|
313
|
+
const ascii = c.glyphs === 'ascii';
|
|
314
|
+
const edges = ascii || c.face === 'edges';
|
|
315
|
+
|
|
316
|
+
if (ascii) {
|
|
317
|
+
return {
|
|
318
|
+
cursor: '>', // menu selection marker, prompt prefix
|
|
319
|
+
check: '+', // selected / completed
|
|
320
|
+
divider: '-', // menu separators
|
|
321
|
+
bullet: '.', // inline separators
|
|
322
|
+
hint: '>', // "Try ..." suggestion marker
|
|
323
|
+
pause: '||', // bottom status line (manual mode)
|
|
324
|
+
star: stencilGlyph(STAR, c), // own-session marker, decorations
|
|
325
|
+
rightarrow: '->', // the manual ⇄ auto mode switch
|
|
326
|
+
pointer: '>', // tips list bullets
|
|
327
|
+
hook: '_|', // inline command / tip rows
|
|
328
|
+
block: '*', // streaming cursor / assistant answer marker
|
|
329
|
+
bloom: '*', // "done" spinner glyph (✻ Brewed for 2s)
|
|
330
|
+
spin: ['|', '/', '-', '\\', '*', '-'], // working spinner
|
|
331
|
+
ellipse: '...',
|
|
332
|
+
err: 'x', // failed check
|
|
333
|
+
warn: '!', // warning mark
|
|
334
|
+
rule: '-', // ruled section headers
|
|
335
|
+
ruleHeavy: '=', // the welcome banner's frame rule
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const base = {
|
|
340
|
+
cursor: '❯', // menu selection marker, prompt prefix
|
|
341
|
+
check: '✔', // selected / completed
|
|
342
|
+
divider: '╌', // menu separators
|
|
343
|
+
bullet: '·', // inline separators
|
|
344
|
+
hint: '❯', // "Try ..." suggestion marker
|
|
345
|
+
pause: edges ? '❚❚' : '⏸', // bottom status line (manual mode)
|
|
346
|
+
star: stencilGlyph(STAR, c), // own-session marker, decorations
|
|
347
|
+
rightarrow: '→', // the manual ⇄ auto mode switch, advertised on the status line
|
|
348
|
+
pointer: '▸', // tips list bullets
|
|
349
|
+
hook: edges ? '_|' : '⎿', // inline command / tip rows (tool commands, usage hints)
|
|
350
|
+
block: '●', // streaming cursor / assistant answer marker
|
|
351
|
+
bloom: '✻', // "done" spinner glyph (✻ Brewed for 2s)
|
|
352
|
+
spin: ['✢', '·', '✻', '*', '✽', '✶'], // working spinner
|
|
353
|
+
ellipse: '…',
|
|
354
|
+
err: '✗', // failed check (render.js's notice marks live here too)
|
|
355
|
+
warn: '⚠', // warning mark
|
|
356
|
+
rule: '─', // ruled section headers
|
|
357
|
+
ruleHeavy: '━', // the welcome banner's frame rule
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
if (edges) {
|
|
361
|
+
// ⏸ U+23F8 and ⎿ U+23BF are the two the font stacks in this class lack;
|
|
362
|
+
// ✻ U+273B has an emoji presentation on them as well.
|
|
363
|
+
return { ...base, bloom: '*', spin: ['|', '/', '-', '\\', '*', '-'] };
|
|
364
|
+
}
|
|
365
|
+
return base;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** The live glyph table — re-materialised whenever the capabilities change. */
|
|
369
|
+
const GLYPH = glyphsFor();
|
|
370
|
+
|
|
371
|
+
/** Working-line verbs, verbatim from the capture-backed table. */
|
|
372
|
+
const VERBS = [
|
|
373
|
+
'Incubating',
|
|
374
|
+
'Tempering',
|
|
375
|
+
'Determining',
|
|
376
|
+
'Beboppin\'',
|
|
377
|
+
'Julienning',
|
|
378
|
+
'Inferring',
|
|
379
|
+
'Simmering',
|
|
380
|
+
'Twisting',
|
|
381
|
+
'Fermenting',
|
|
382
|
+
'Fiddle-faddling',
|
|
383
|
+
'Orbiting',
|
|
384
|
+
'Prestidigitating',
|
|
385
|
+
];
|
|
386
|
+
|
|
387
|
+
/** Completion verbs: "✻ Churned for 3s" after a chat turn, "✻ Worked for 3s"
|
|
388
|
+
* after one that used tools. */
|
|
389
|
+
const DONE_VERBS = ['Churned', 'Worked'];
|
|
390
|
+
|
|
391
|
+
// ── materialisation ──────────────────────────────────────────────────────────
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Rebuild every palette and the glyph table for the current capabilities.
|
|
395
|
+
* Mutates in place: renderers, screens and panels capture these objects at
|
|
396
|
+
* require time, and swapping the object would leave them drawing the previous
|
|
397
|
+
* terminal's colours after `--ascii` or `/terminal`.
|
|
398
|
+
*/
|
|
399
|
+
function rematerialize() {
|
|
400
|
+
Object.assign(C, buildDark());
|
|
401
|
+
Object.assign(LIGHT, buildLight());
|
|
402
|
+
Object.assign(CB_DARK, buildCbDark());
|
|
403
|
+
Object.assign(CB_LIGHT, buildCbLight());
|
|
404
|
+
Object.assign(ANSI_DARK, buildAnsiDark());
|
|
405
|
+
Object.assign(ANSI_LIGHT, buildAnsiLight());
|
|
406
|
+
Object.assign(DIFF, buildDiff());
|
|
407
|
+
Object.assign(DIFF_LIGHT, buildDiffLight());
|
|
408
|
+
Object.assign(GLYPH, glyphsFor());
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
rematerialize();
|
|
412
|
+
onCapsChange(rematerialize);
|
|
413
|
+
|
|
209
414
|
module.exports = {
|
|
210
415
|
RGB,
|
|
211
416
|
BG,
|
|
@@ -221,6 +426,9 @@ module.exports = {
|
|
|
221
426
|
RESET_BG,
|
|
222
427
|
C,
|
|
223
428
|
LIGHT,
|
|
429
|
+
DIFF,
|
|
430
|
+
DIFF_LIGHT,
|
|
431
|
+
diffOf,
|
|
224
432
|
CB_DARK,
|
|
225
433
|
CB_LIGHT,
|
|
226
434
|
ANSI_DARK,
|
|
@@ -233,4 +441,5 @@ module.exports = {
|
|
|
233
441
|
VERBS,
|
|
234
442
|
DONE_VERBS,
|
|
235
443
|
themeOf,
|
|
444
|
+
rematerialize,
|
|
236
445
|
};
|
|
@@ -55,6 +55,15 @@ const gitScope = require('./git-scope.js');
|
|
|
55
55
|
/** Default tool-round horizon for an unattended turn (matches the engine's). */
|
|
56
56
|
const DEFAULT_ROUNDS = 40;
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Consecutive tool-round-horizon stops a queued task gets before runOne gives
|
|
60
|
+
* up on it as unable to converge and settles it 'error' instead of 'pending'.
|
|
61
|
+
* Without this bound a task that never finishes would keep proceed()'s drain
|
|
62
|
+
* loop picking it back up forever — proceed() defaults to no --max at all, so
|
|
63
|
+
* nothing else would ever stop it.
|
|
64
|
+
*/
|
|
65
|
+
const MAX_ROUND_STOPS = 3;
|
|
66
|
+
|
|
58
67
|
/**
|
|
59
68
|
* The engine tools that report the file they write, and the argument holding
|
|
60
69
|
* it. This set is the attribution record for a task's commit: `exec` is absent
|
|
@@ -326,7 +335,8 @@ function autonomousDirective(rounds = DEFAULT_ROUNDS) {
|
|
|
326
335
|
*/
|
|
327
336
|
function digestLine(item, result) {
|
|
328
337
|
const task = String(item.task || '').replace(/\s+/g, ' ').trim().slice(0, 120);
|
|
329
|
-
const
|
|
338
|
+
const paused = Boolean(result && result.ok && result.stoppedOnRounds);
|
|
339
|
+
const mark = paused ? '⏸' : result && result.ok ? '✓' : '✗';
|
|
330
340
|
const files = (result && Array.isArray(result.files) && result.files.slice(0, 6)) || [];
|
|
331
341
|
const where = files.length ? ` — touched: ${files.join(', ')}${result.files.length > files.length ? ', …' : ''}` : '';
|
|
332
342
|
const why = !result || result.ok ? '' : ` — ${String((result && result.error) || 'failed').slice(0, 120)}`;
|
|
@@ -616,13 +626,41 @@ function createQueueWorker({ engine, env = process.env, log = () => {}, git = gi
|
|
|
616
626
|
const items = queue.loadQueue(env);
|
|
617
627
|
const claimed = queue.markRunning(items, item.id, { now: now() });
|
|
618
628
|
if (!claimed) return { ok: false, error: `unknown task #${item.id}`, carry };
|
|
629
|
+
const priorRoundStops = Number(claimed.roundStops) || 0;
|
|
619
630
|
queue.saveQueue(env, items);
|
|
620
631
|
|
|
621
|
-
const
|
|
632
|
+
const raw = await runTask(claimed, { carry, commit });
|
|
633
|
+
|
|
634
|
+
// A task that hit its tool-round horizon has NOT finished — engine.js's
|
|
635
|
+
// session ledger (session-rounds.js) is holding the rest of the work
|
|
636
|
+
// under this task's stable session id (sessionIdFor(item.id)), ready to
|
|
637
|
+
// inject a continuation preamble the moment this item is dispatched
|
|
638
|
+
// again. Settling it 'done' here (the old behavior) threw that away: the
|
|
639
|
+
// queue believed the task was finished, so nothing ever sent the next
|
|
640
|
+
// turn that would have consumed the resume, and a human had to notice
|
|
641
|
+
// the output was incomplete and re-queue the whole task from scratch.
|
|
642
|
+
//
|
|
643
|
+
// Left 'pending' instead, so proceed()'s own drain loop picks it straight
|
|
644
|
+
// back up — unless it has now failed to converge MAX_ROUND_STOPS times in
|
|
645
|
+
// a row, at which point looping on it forever (an unattended proceed()
|
|
646
|
+
// with no --max has no other cap at all) is worse than a visible error.
|
|
647
|
+
const hitRoundCap = Boolean(raw.ok && raw.stoppedOnRounds);
|
|
648
|
+
const roundStops = hitRoundCap ? priorRoundStops + 1 : 0;
|
|
649
|
+
const exhausted = hitRoundCap && roundStops > MAX_ROUND_STOPS;
|
|
650
|
+
const result = exhausted
|
|
651
|
+
? {
|
|
652
|
+
...raw,
|
|
653
|
+
ok: false,
|
|
654
|
+
error:
|
|
655
|
+
`stopped at its tool-round horizon ${roundStops} times in a row without finishing — ` +
|
|
656
|
+
'raise AEGIS_AUTONOMOUS_MAX_ROUNDS or split the task into smaller ones',
|
|
657
|
+
}
|
|
658
|
+
: raw;
|
|
659
|
+
const status = exhausted ? 'error' : hitRoundCap ? 'pending' : result.ok ? 'done' : 'error';
|
|
622
660
|
|
|
623
661
|
const after = queue.loadQueue(env);
|
|
624
662
|
queue.settle(after, claimed.id, {
|
|
625
|
-
status
|
|
663
|
+
status,
|
|
626
664
|
result: {
|
|
627
665
|
ok: result.ok,
|
|
628
666
|
output: result.output || '',
|
|
@@ -634,13 +672,15 @@ function createQueueWorker({ engine, env = process.env, log = () => {}, git = gi
|
|
|
634
672
|
error: result.ok ? null : result.error,
|
|
635
673
|
now: now(),
|
|
636
674
|
});
|
|
675
|
+
const settled = queue.findTask(after, claimed.id);
|
|
676
|
+
if (settled) settled.roundStops = roundStops;
|
|
637
677
|
queue.saveQueue(env, after);
|
|
638
678
|
queue.appendRun(env, {
|
|
639
679
|
id: claimed.id,
|
|
640
680
|
task: claimed.task,
|
|
641
681
|
cwd: claimed.cwd,
|
|
642
682
|
model: resolveModel({ model: claimed.model, env }),
|
|
643
|
-
status:
|
|
683
|
+
status: status === 'pending' ? 'stopped' : status,
|
|
644
684
|
at: new Date(now()).toISOString(),
|
|
645
685
|
ms: result.ms,
|
|
646
686
|
usage: result.usage || null,
|
|
@@ -722,6 +762,7 @@ function commitMessage(item) {
|
|
|
722
762
|
module.exports = {
|
|
723
763
|
DEFAULT_MODEL,
|
|
724
764
|
DEFAULT_ROUNDS,
|
|
765
|
+
MAX_ROUND_STOPS,
|
|
725
766
|
AEGIS_MODEL_IDS,
|
|
726
767
|
isAegisModel,
|
|
727
768
|
modelRefusal,
|