aegiscode 7.0.14 → 7.0.16
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/SOURCE-OFFER.txt +9 -0
- package/package.json +4 -7
- package/scripts/check.mjs +1 -52
- package/scripts/demo.mjs +1 -94
- package/scripts/predist.mjs +1 -75
- package/scripts/runtests.mjs +1 -56
- package/scripts/seal-gate.mjs +1 -74
- package/src/agents.js +1 -139
- package/src/app.js +1 -2932
- package/src/art.js +1 -289
- package/src/chatflow.js +1 -3020
- package/src/checkpoint.js +1 -90
- package/src/clipboard.js +1 -424
- package/src/cloudsync.js +1 -528
- package/src/commands.js +1 -4003
- package/src/config.js +1 -581
- package/src/connect.js +1 -349
- package/src/credentials.js +1 -33
- package/src/deps.js +1 -232
- package/src/devrun.js +1 -187
- package/src/diff.js +1 -333
- package/src/diffview.js +1 -296
- package/src/engine.js +1 -297
- package/src/entitlement.js +1 -355
- package/src/events.js +1 -707
- package/src/export.js +1 -67
- package/src/fingerprint.js +1 -592
- package/src/format.js +1 -259
- package/src/fuzzy.js +1 -119
- package/src/history.js +1 -401
- package/src/init.js +1 -175
- package/src/input.js +1 -139
- package/src/keys.js +1 -183
- package/src/markdown.js +1 -306
- package/src/models.js +1 -487
- package/src/naming.js +1 -229
- package/src/overlays.js +1 -461
- package/src/panels.js +1 -1418
- package/src/ping.js +1 -226
- package/src/presence.js +1 -238
- package/src/render.js +1 -515
- package/src/screen.js +1 -518
- package/src/screens.js +1 -896
- package/src/secret.js +1 -59
- package/src/securefs.js +1 -359
- package/src/settings.js +1 -155
- package/src/shared.js +1 -52
- package/src/sharedpaths.js +1 -53
- package/src/signup.js +1 -156
- package/src/summarize.js +1 -95
- package/src/sysdiag.js +1 -585
- package/src/system.js +1 -40
- package/src/theme.js +1 -570
- package/src/title.js +1 -220
- package/src/todos.js +1 -115
- package/src/tokens.js +1 -263
- package/src/topup.js +1 -210
- package/src/update.js +1 -181
- package/vendor/client/aegis.js +1 -2179
- package/vendor/client/attest.js +1 -442
- package/vendor/client/authorship-key.js +1 -410
- package/vendor/client/auto-provision.js +1 -134
- package/vendor/client/brain-catalog.js +1 -268
- package/vendor/client/byok-catalog.js +1 -230
- package/vendor/client/credentials.js +1 -494
- package/vendor/client/device-fingerprint.js +1 -141
- package/vendor/client/drive-connect.js +1 -110
- package/vendor/client/drive-upload.js +1 -174
- package/vendor/client/env-file.js +1 -1273
- package/vendor/client/fingerprint.js +1 -1064
- package/vendor/client/foreign-memory.js +1 -669
- package/vendor/client/google-signin.js +1 -133
- package/vendor/client/hooks.js +1 -430
- package/vendor/client/model-discovery.js +1 -373
- package/vendor/client/platform.js +1 -937
- package/vendor/client/prefs.js +1 -351
- package/vendor/client/presence-constants.js +1 -107
- package/vendor/client/presence.js +1 -438
- package/vendor/client/record-vault.js +3 -1055
- package/vendor/client/session-store.js +1 -548
- package/vendor/client/topup.js +1 -297
- package/vendor/client/touch.js +1 -458
- package/vendor/client/update.js +1 -704
- package/vendor/client/user-models.js +1 -381
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/desktop/lib/settings.js +1 -890
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/hosts/install.js +1 -638
- package/vendor/hosts/openai-shim.js +1 -515
- package/vendor/hosts/spec.js +1 -164
- package/vendor/hosts/targets.js +1 -346
- package/vendor/mcp/server.js +1 -221
- package/vendor/mcp/tools.js +1 -408
- package/vendor/one/src/child.js +1 -285
- package/vendor/one/src/permissions.js +1 -369
package/src/panels.js
CHANGED
|
@@ -1,1420 +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
|
-
* Panel builders — the bodies that slash-commands print.
|
|
10
|
-
*
|
|
11
|
-
* Ported from the upstream engine reference (868 lines), keeping its layouts
|
|
12
|
-
* and copy wherever the capability exists in this client. Everything here is
|
|
13
|
-
* PURE: a builder receives all of its data as arguments and returns an array of
|
|
14
|
-
* span lines (each line an array of `{ t, s, w }`, see `screen.js`). No stdout
|
|
15
|
-
* writes, no `process.exit`, no network, no filesystem reads — which is exactly
|
|
16
|
-
* what makes them assertable from a plain Node test with no TTY.
|
|
17
|
-
*
|
|
18
|
-
* Style objects come from `themeOf(ctx)` (`ctx = { light }`), never a
|
|
19
|
-
* module-scoped palette. Money is euro: `fmtEur` renders 4dp below a cent (a
|
|
20
|
-
* pooled call settles near €0.0007) and 2dp at or above it, so a real charge
|
|
21
|
-
* never reads as "€0.00". The reference printed USD; every `$` became `€`.
|
|
22
|
-
* Claude/Anthropic names became AEGIS (`aegiscode`, `aegiscloud.org`)
|
|
23
|
-
* and `~/.aegiscodex` became
|
|
24
|
-
* `~/.aegiscode`.
|
|
25
|
-
*
|
|
26
|
-
* Every builder is defensive: a missing field is omitted, never rendered as
|
|
27
|
-
* `undefined`, `NaN` or `[object Object]`.
|
|
28
|
-
*
|
|
29
|
-
* ── Ported for real ──────────────────────────────────────────────────────────
|
|
30
|
-
* buildHelp buildStatus buildCost buildContext buildTokens buildAgents
|
|
31
|
-
* renderSessionsOverlay buildPermissions buildModelList buildRewindList
|
|
32
|
-
* buildOnboarding buildShellCompletion buildTerminalSetup buildPRs
|
|
33
|
-
* buildBenchmark buildWaifu buildAegisStatus buildAegisRecall buildAegisMulti
|
|
34
|
-
* buildBilling buildMemory buildMemoryTiers buildRouter buildAutomode buildSkills
|
|
35
|
-
* buildMcp buildHooksStatus buildHooksList buildTroubleshooting
|
|
36
|
-
* buildReleaseNotes
|
|
37
|
-
* (plus the pure reference helpers with no missing capability)
|
|
38
|
-
* buildAegisPrint buildSkillDetail buildMemoryEmbeddings
|
|
39
|
-
*
|
|
40
|
-
* ── Honest stubs (capability absent in this client) ──────────────────────────
|
|
41
|
-
* buildDoctor — needs the local environment diagnostic suite (runDoctor),
|
|
42
|
-
* which belongs to the upstream engine; /doctor is unavailable.
|
|
43
|
-
* buildBuildPanel — needs a local multi-model agent build loop this client
|
|
44
|
-
* does not host.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const { span, getSize, lineWidth } = require('./screen.js');
|
|
48
|
-
const { themeOf, BOLD, BOLD_OFF, GLYPH } = require('./theme.js');
|
|
49
|
-
// Pure, like this module (signup.js requires nothing and does no I/O), so the
|
|
50
|
-
// "everything here is assertable from a plain Node test" contract still holds.
|
|
51
|
-
const { goUrl } = require('./signup.js');
|
|
52
|
-
// Path NAMES for the session overlay — the shared rule, not a second `split('/')`
|
|
53
|
-
// (which reported the whole path on win32). See format.js's path section.
|
|
54
|
-
const { cwdName, pathName } = require('./format.js');
|
|
55
|
-
|
|
56
|
-
const VERSION = require('../package.json').version;
|
|
57
|
-
|
|
58
|
-
// ── local helpers (this file stays self-contained apart from theme/screen) ────
|
|
59
|
-
|
|
60
|
-
/** Finite number or 0 — never NaN (which would print as "NaN"). */
|
|
61
|
-
function num(v) {
|
|
62
|
-
const n = Number(v);
|
|
63
|
-
return Number.isFinite(n) ? n : 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** A safe display string: null/undefined become '', everything else String()s. */
|
|
67
|
-
function str(v) {
|
|
68
|
-
return v == null ? '' : String(v);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Word-wrap one sentence into span rows, indented, so a long claim survives
|
|
73
|
-
* `padLine()`.
|
|
74
|
-
*
|
|
75
|
-
* Local rather than imported on purpose (see the header: this file stays
|
|
76
|
-
* self-contained apart from theme/screen). `screens.js` has a `wrapped()` that
|
|
77
|
-
* does the same job, but it lives behind the screen-drawing module, which
|
|
78
|
-
* requires this one — importing it here would close a require cycle to reuse
|
|
79
|
-
* fifteen lines.
|
|
80
|
-
*
|
|
81
|
-
* Anything one word longer than the terminal is emitted on its own row rather
|
|
82
|
-
* than dropped: `padLine()` clips it, which is what already happens today, and
|
|
83
|
-
* losing a word is better than losing the sentence.
|
|
84
|
-
*/
|
|
85
|
-
function wrapRows(text, indent, style, cols) {
|
|
86
|
-
const width = Math.max(20, (Number(cols) || 80) - 2 - indent);
|
|
87
|
-
const pad = ' '.repeat(indent);
|
|
88
|
-
const words = str(text).split(/\s+/).filter(Boolean);
|
|
89
|
-
const out = [];
|
|
90
|
-
let line = '';
|
|
91
|
-
for (const word of words) {
|
|
92
|
-
const next = line ? `${line} ${word}` : word;
|
|
93
|
-
if (line && next.length > width) {
|
|
94
|
-
out.push([span('', pad), span(style, line)]);
|
|
95
|
-
line = word;
|
|
96
|
-
} else {
|
|
97
|
-
line = next;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (line) out.push([span('', pad), span(style, line)]);
|
|
101
|
-
return out.length ? out : [[span('', pad), span(style, '')]];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* The four token buckets these panels render, in the shared shape.
|
|
106
|
-
*
|
|
107
|
-
* `input` is the MISS half only — that is what `usageBuckets` normalises it to
|
|
108
|
-
* for every provider, and what the ledger rows and the desktop roll store — so
|
|
109
|
-
* the prompt a context window actually holds is `input + cacheRead +
|
|
110
|
-
* cacheWrite`, NOT `input` alone. Totalling `input + output` (what this file
|
|
111
|
-
* did before) therefore silently dropped the entire cached prompt: the exact
|
|
112
|
-
* turns where the cache was working and the context was largest were the turns
|
|
113
|
-
* the meter under-reported.
|
|
114
|
-
*
|
|
115
|
-
* `tok.total` wins when a caller supplies one (the live session tally does), so
|
|
116
|
-
* this fallback can only ever add information, never overwrite it. One formula,
|
|
117
|
-
* one place: /cost, /context and /tokens must not disagree about the same turn.
|
|
118
|
-
*/
|
|
119
|
-
function tokenBuckets(tok) {
|
|
120
|
-
const input = num(tok.input);
|
|
121
|
-
const output = num(tok.output);
|
|
122
|
-
const cacheRead = num(tok.cacheRead);
|
|
123
|
-
const cacheWrite = num(tok.cacheWrite);
|
|
124
|
-
const prompt = input + cacheRead + cacheWrite;
|
|
125
|
-
return { input, output, cacheRead, cacheWrite, prompt, total: num(tok.total) || prompt + output };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Group digits: 1562 -> "1,562". Matches the CLI's format.js rule. */
|
|
129
|
-
function fmtTokens(n) {
|
|
130
|
-
const v = Number(n);
|
|
131
|
-
if (!Number.isFinite(v) || v <= 0) return '0';
|
|
132
|
-
return Math.round(v)
|
|
133
|
-
.toString()
|
|
134
|
-
.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** € amount, 4dp below a cent (per-call spend) and 2dp at or above it. */
|
|
138
|
-
function fmtEur(n) {
|
|
139
|
-
const v = Number(n);
|
|
140
|
-
if (!Number.isFinite(v)) return '€?';
|
|
141
|
-
const abs = Math.abs(v);
|
|
142
|
-
return `€${abs < 0.01 ? abs.toFixed(4) : abs.toFixed(2)}`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** Relative-time stamp, ported verbatim from the reference's `ago()`. */
|
|
146
|
-
function ago(ts) {
|
|
147
|
-
if (!ts) return '';
|
|
148
|
-
const ms = Date.now() - new Date(String(ts)).getTime();
|
|
149
|
-
if (!(ms >= 0) || Number.isNaN(ms)) return '';
|
|
150
|
-
if (ms < 60_000) return `${Math.max(1, Math.round(ms / 1000))}s ago`;
|
|
151
|
-
if (ms < 3_600_000) return `${Math.round(ms / 60_000)}m ago`;
|
|
152
|
-
if (ms < 86_400_000) return `${Math.round(ms / 3_600_000)}h ago`;
|
|
153
|
-
return `${Math.round(ms / 86_400_000)}d ago`;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** A `█`-filled progress bar as a span line (the reference's contextBar). */
|
|
157
|
-
function contextBar(used, window, t, width = 50) {
|
|
158
|
-
const pct = Math.max(0, Math.min(1, window > 0 ? num(used) / window : 0));
|
|
159
|
-
const filled = Math.round(pct * width);
|
|
160
|
-
return [
|
|
161
|
-
span('', ' '),
|
|
162
|
-
span(t.green, '█'.repeat(filled)),
|
|
163
|
-
span(t.dim, '█'.repeat(Math.max(0, width - filled))),
|
|
164
|
-
span(t.gray, ` ${Math.round(pct * 100)}% used`),
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** Aligned key/value rows, the reference's `k + ' '.repeat(maxK-len) + ' : '`. */
|
|
169
|
-
function kv(t, rows, { indent = ' ', keyStyle = null, valStyle = null } = {}) {
|
|
170
|
-
const maxK = rows.reduce((m, r) => Math.max(m, [...r[0]].length), 0);
|
|
171
|
-
return rows.map(([k, v]) => [
|
|
172
|
-
span(keyStyle != null ? keyStyle : t.gray, indent + k + ' '.repeat(maxK - [...k].length) + ' : '),
|
|
173
|
-
span(valStyle != null ? valStyle : t.white, str(v)),
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/** The `state` argument, guaranteed to be an object. */
|
|
178
|
-
function obj(state) {
|
|
179
|
-
return state && typeof state === 'object' ? state : {};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** An object that looks like ÆGIS memory stats, from either `state.memory` or
|
|
183
|
-
* `state` itself (the reference passed the stats object directly). */
|
|
184
|
-
function statsFrom(state) {
|
|
185
|
-
const s = obj(state);
|
|
186
|
-
if (s.stats && typeof s.stats === 'object') return s.stats;
|
|
187
|
-
if (s.memory && typeof s.memory === 'object' && (s.memory.total != null || s.memory.tiers || s.memory.sessions != null || s.memory.roles)) {
|
|
188
|
-
return s.memory;
|
|
189
|
-
}
|
|
190
|
-
if (s.total != null || s.tiers || s.roles) return s;
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** Category labels, copied from the reference registry's CATEGORIES table. */
|
|
195
|
-
const CATEGORY_LABELS = {
|
|
196
|
-
session: 'Session & context',
|
|
197
|
-
workspace: 'Workspace',
|
|
198
|
-
model: 'Model & behavior',
|
|
199
|
-
data: 'Data',
|
|
200
|
-
auth: 'Auth',
|
|
201
|
-
support: 'Support',
|
|
202
|
-
fun: 'Fun',
|
|
203
|
-
aegis: 'Aegis plugin',
|
|
204
|
-
custom: 'Custom',
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
function categoryLabel(cmd) {
|
|
208
|
-
if (cmd && cmd.categoryLabel) return String(cmd.categoryLabel);
|
|
209
|
-
const id = str(cmd && cmd.category);
|
|
210
|
-
if (CATEGORY_LABELS[id]) return CATEGORY_LABELS[id];
|
|
211
|
-
return id ? id.charAt(0).toUpperCase() + id.slice(1) : 'Commands';
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// ── /help ────────────────────────────────────────────────────────────────────
|
|
215
|
-
|
|
216
|
-
/** @param {Array} commands [{name,aliases,desc,hint,args,category,unavailable}] */
|
|
217
|
-
function buildHelp(commands, ctx = {}) {
|
|
218
|
-
const t = themeOf(ctx);
|
|
219
|
-
const list = Array.isArray(commands)
|
|
220
|
-
? commands
|
|
221
|
-
: Array.isArray(obj(commands).commands)
|
|
222
|
-
? commands.commands
|
|
223
|
-
: [];
|
|
224
|
-
const out = [];
|
|
225
|
-
out.push([span(t.gold + BOLD, 'Commands'), span(BOLD_OFF, '')]);
|
|
226
|
-
out.push([span(t.gray, '─'.repeat(30))]);
|
|
227
|
-
let lastCat = null;
|
|
228
|
-
for (const cmd of list) {
|
|
229
|
-
if (!cmd || !cmd.name) continue;
|
|
230
|
-
const cat = str(cmd.category);
|
|
231
|
-
if (cat !== lastCat) {
|
|
232
|
-
out.push([span('', '')]);
|
|
233
|
-
out.push([span(t.gray + BOLD, categoryLabel(cmd)), span(BOLD_OFF, '')]);
|
|
234
|
-
lastCat = cat;
|
|
235
|
-
}
|
|
236
|
-
const name = String(cmd.name);
|
|
237
|
-
const pad = ' '.repeat(Math.max(1, 16 - [...name].length));
|
|
238
|
-
const desc = str(cmd.desc != null ? cmd.desc : cmd.help);
|
|
239
|
-
const nameStyle = cmd.unavailable ? t.gray : t.white;
|
|
240
|
-
const descStyle = cmd.unavailable ? t.dim : t.gray;
|
|
241
|
-
const tail = cmd.unavailable ? ' (unavailable)' : '';
|
|
242
|
-
out.push([span(nameStyle, '/' + name), span(descStyle, pad + desc + tail)]);
|
|
243
|
-
}
|
|
244
|
-
if (!list.length) {
|
|
245
|
-
out.push([span('', '')]);
|
|
246
|
-
out.push([span(t.gray, 'No commands registered.')]);
|
|
247
|
-
}
|
|
248
|
-
out.push([span('', '')]);
|
|
249
|
-
// 71 cells, and it has to stay under 80. This row was 81: the label already
|
|
250
|
-
// reads "Shortcuts:", so `? shortcuts` repeated the word — which cost the 10
|
|
251
|
-
// cells that pushed it one over, and `padLine()` truncates to `cols` rather
|
|
252
|
-
// than wrapping, so on every 80-column terminal the row rendered as
|
|
253
|
-
// "Ctrl-D exi". Measured by test/cli-panels.test.mjs, which asserts every
|
|
254
|
-
// buildHelp row fits the terminal.
|
|
255
|
-
out.push([
|
|
256
|
-
span(t.gray, 'Shortcuts: '), span(t.white, '?'), span(t.gray, ' · '),
|
|
257
|
-
span(t.white, '/help'), span(t.gray, ' commands · '), span(t.white, '↑↓'), span(t.gray, ' history · '),
|
|
258
|
-
span(t.white, 'Ctrl-L'), span(t.gray, ' clear · '), span(t.white, 'Ctrl-D'), span(t.gray, ' exit'),
|
|
259
|
-
]);
|
|
260
|
-
return out;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// ── /status ──────────────────────────────────────────────────────────────────
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* @param {object} state session state (see the module header in the task)
|
|
267
|
-
* @param {{light?: boolean, caps?: Array<[string,string]>}} [ctx] `caps` is the
|
|
268
|
-
* `caps.describe()` row list, rendered as the terminal-capability rows.
|
|
269
|
-
*/
|
|
270
|
-
function buildStatus(state, ctx = {}) {
|
|
271
|
-
const t = themeOf(ctx);
|
|
272
|
-
const s = obj(state);
|
|
273
|
-
const lines = [];
|
|
274
|
-
lines.push([span(t.gold + BOLD, 'Status'), span(BOLD_OFF, '')]);
|
|
275
|
-
|
|
276
|
-
const rows = [];
|
|
277
|
-
const add = (k, v) => {
|
|
278
|
-
const value = str(v);
|
|
279
|
-
if (value !== '') rows.push([k, value]);
|
|
280
|
-
};
|
|
281
|
-
add('Session ID', s.sessionId);
|
|
282
|
-
add('Working directory', s.cwd);
|
|
283
|
-
add('Home', s.home);
|
|
284
|
-
add('Model', s.model);
|
|
285
|
-
// `null` = auto: the pool sizes each turn from the ask, so the row says so
|
|
286
|
-
// rather than vanishing (add() skips empty values).
|
|
287
|
-
add('Effort', s.effort || 'high');
|
|
288
|
-
if (s.thinking != null) add('Thinking', s.thinking ? 'on' : 'off');
|
|
289
|
-
if (s.stream != null) add('Streaming', s.stream === false ? 'off' : 'on');
|
|
290
|
-
if (s.vim != null) add('Vim keymap', s.vim ? 'on' : 'off');
|
|
291
|
-
add('Theme', s.theme ? str(s.theme) : (ctx && ctx.light ? 'Light mode' : 'Dark mode'));
|
|
292
|
-
add('Backend', s.backend);
|
|
293
|
-
add('Base', s.base);
|
|
294
|
-
add('Plan', s.plan);
|
|
295
|
-
add('Account', s.account);
|
|
296
|
-
if (s.online != null) add('Online', s.online ? 'yes' : 'no');
|
|
297
|
-
if (s.turns != null) add('Turns', str(num(s.turns)));
|
|
298
|
-
if (s.calls != null) add('Tool calls', str(num(s.calls)));
|
|
299
|
-
if (s.version != null) add('Version', 'v' + str(s.version));
|
|
300
|
-
add('Node', process.version);
|
|
301
|
-
add('Platform', `${process.platform} ${process.arch}`);
|
|
302
|
-
// Terminal capabilities, read off the same `caps.describe()` rows `/terminal`
|
|
303
|
-
// renders — passed in on `ctx` so this builder stays pure (no caps.js require)
|
|
304
|
-
// and the two reports cannot drift. Absent in tests and headless runs; `add()`
|
|
305
|
-
// skips empty values, so the rows simply do not appear.
|
|
306
|
-
const capsRows = Array.isArray(ctx.caps) ? ctx.caps : [];
|
|
307
|
-
const cap = (k) => {
|
|
308
|
-
const hit = capsRows.find((r) => Array.isArray(r) && String(r[0]) === k);
|
|
309
|
-
return hit ? str(hit[1]) : '';
|
|
310
|
-
};
|
|
311
|
-
add('Terminal', cap('terminal'));
|
|
312
|
-
add('Mark', cap('mark'));
|
|
313
|
-
add('Star', cap('star'));
|
|
314
|
-
add('Color', cap('color'));
|
|
315
|
-
add('Control', cap('control'));
|
|
316
|
-
add('Frame', cap('size'));
|
|
317
|
-
|
|
318
|
-
for (const l of kv(t, rows, { keyStyle: t.gray, valStyle: t.white })) lines.push(l);
|
|
319
|
-
|
|
320
|
-
lines.push([span('', '')]);
|
|
321
|
-
const mode = s.permissions && s.permissions.mode ? str(s.permissions.mode) : 'default';
|
|
322
|
-
lines.push([span(t.gray, `Permissions: ${mode} — tool use follows your AEGIS settings.`)]);
|
|
323
|
-
return lines;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// ── /cost — the session's euro tally ─────────────────────────────────────────
|
|
327
|
-
|
|
328
|
-
/** @param {object} state {tokens, costEur, balance, model, turns, calls} */
|
|
329
|
-
function buildCost(state, ctx = {}) {
|
|
330
|
-
const t = themeOf(ctx);
|
|
331
|
-
const s = obj(state);
|
|
332
|
-
const { cols } = getSize();
|
|
333
|
-
const W = Math.max(30, cols - 2);
|
|
334
|
-
const tok = s.tokens && typeof s.tokens === 'object' ? s.tokens : {};
|
|
335
|
-
const { input, output, cacheRead, cacheWrite, prompt, total } = tokenBuckets(tok);
|
|
336
|
-
const cost = num(s.costEur);
|
|
337
|
-
const model = str(s.model) || 'the pinned model';
|
|
338
|
-
const window = num(s.contextWindow) || 200000;
|
|
339
|
-
const pct = window > 0 ? Math.min(100, Math.round((total / window) * 100)) : 0;
|
|
340
|
-
|
|
341
|
-
const lines = [];
|
|
342
|
-
lines.push([span(t.gray, '─'.repeat(W))]);
|
|
343
|
-
lines.push([
|
|
344
|
-
span('', ' '), span(t.white + BOLD, 'Session'), span(BOLD_OFF, ''),
|
|
345
|
-
span(t.gray, ' Status Config Usage Stats'),
|
|
346
|
-
]);
|
|
347
|
-
lines.push([span('', ' '), span(t.gray, 'Session')]);
|
|
348
|
-
lines.push([span('', ' '), span(t.white, 'Total cost:'), span(t.gray, ' ' + ' '.repeat(Math.max(0, 14 - fmtEur(cost).length)) + fmtEur(cost))]);
|
|
349
|
-
if (s.balance != null) {
|
|
350
|
-
lines.push([span('', ' '), span(t.white, 'Balance:'), span(t.gray, ' ' + ' '.repeat(Math.max(0, 14 - fmtEur(s.balance).length)) + fmtEur(s.balance))]);
|
|
351
|
-
}
|
|
352
|
-
if (s.turns != null || s.calls != null) {
|
|
353
|
-
lines.push([span('', ' '), span(t.white, 'Turns:'), span(t.gray, ` ${num(s.turns)} turns · ${num(s.calls)} calls`)]);
|
|
354
|
-
}
|
|
355
|
-
lines.push([span('', ' '), span(t.white, ' Usage by model:')]);
|
|
356
|
-
// The prompt, not the miss. `input` is the miss half only (see tokenBuckets),
|
|
357
|
-
// so printing it as "input" reported 1.2k for a turn that had sent 31.2k —
|
|
358
|
-
// the same under-report /context was fixed for, in the panel that sits right
|
|
359
|
-
// next to it. With a cache in play the row is a sum, so show the split too.
|
|
360
|
-
lines.push([span('', ' '), span(t.gray, ` ${model}: ${fmtTokens(prompt)} input, ${fmtTokens(output)} output (${fmtEur(cost)})`)]);
|
|
361
|
-
if (cacheRead || cacheWrite) {
|
|
362
|
-
lines.push([span('', ' '), span(t.dim, ` ↳ miss ${fmtTokens(input)} · cache read ${fmtTokens(cacheRead)} · cache write ${fmtTokens(cacheWrite)}`)]);
|
|
363
|
-
}
|
|
364
|
-
lines.push([span('', ' ')]);
|
|
365
|
-
lines.push([span('', ' '), span(t.white + BOLD, 'Current session'), span(BOLD_OFF, '')]);
|
|
366
|
-
lines.push(contextBar(total, window, t));
|
|
367
|
-
lines.push([span('', ' ')]);
|
|
368
|
-
lines.push([span('', ' '), span(t.gray, `Session context: ${pct}% of ${fmtTokens(window)} used.`)]);
|
|
369
|
-
lines.push([span('', ' '), span(t.dim, 'Cost is metered from the AEGIS token bank; tokens are counted this session.')]);
|
|
370
|
-
return lines;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// ── /context — token usage by bucket ─────────────────────────────────────────
|
|
374
|
-
|
|
375
|
-
/** @param {object} state {tokens} */
|
|
376
|
-
function buildContext(state, ctx = {}) {
|
|
377
|
-
const t = themeOf(ctx);
|
|
378
|
-
const s = obj(state);
|
|
379
|
-
const { cols } = getSize();
|
|
380
|
-
const W = Math.max(30, cols - 2);
|
|
381
|
-
const tok = s.tokens && typeof s.tokens === 'object' ? s.tokens : {};
|
|
382
|
-
const { input, output, cacheRead, cacheWrite, prompt, total } = tokenBuckets(tok);
|
|
383
|
-
const window = num(s.contextWindow) || 200000;
|
|
384
|
-
|
|
385
|
-
const lines = [];
|
|
386
|
-
lines.push([span(t.gold + BOLD, 'Context usage'), span(BOLD_OFF, '')]);
|
|
387
|
-
lines.push([span('', ' '), span(t.gray, '─'.repeat(Math.max(1, W - 2)))]);
|
|
388
|
-
const row = (label, tokens) => [
|
|
389
|
-
span('', ' '), span(t.white, label),
|
|
390
|
-
span('', ' '.repeat(Math.max(1, 16 - [...label].length))),
|
|
391
|
-
span(t.gray, fmtTokens(tokens)),
|
|
392
|
-
span('', ' '.repeat(Math.max(1, 10 - fmtTokens(tokens).length))),
|
|
393
|
-
...contextBar(tokens, window, t),
|
|
394
|
-
];
|
|
395
|
-
lines.push(row('Prompt tokens', prompt));
|
|
396
|
-
// With a cache in play the prompt row is a SUM, and a sum hides the one thing
|
|
397
|
-
// the operator is looking for: how much of the prompt was re-sent at full
|
|
398
|
-
// price. Show the split, so "280.0k" cannot be misread as 280k of fresh
|
|
399
|
-
// input. Absent a cache the row is byte-identical to before.
|
|
400
|
-
if (cacheRead || cacheWrite) {
|
|
401
|
-
lines.push([
|
|
402
|
-
span('', ' '),
|
|
403
|
-
span(t.dim, ` ↳ miss ${fmtTokens(input)} · cache read ${fmtTokens(cacheRead)} · cache write ${fmtTokens(cacheWrite)}`),
|
|
404
|
-
]);
|
|
405
|
-
}
|
|
406
|
-
lines.push(row('Output tokens', output));
|
|
407
|
-
lines.push([span('', ' ')]);
|
|
408
|
-
lines.push([span('', ' '), span(t.gray, '─'.repeat(Math.max(1, W - 2)))]);
|
|
409
|
-
lines.push([
|
|
410
|
-
span('', ' '), span(t.white + BOLD, 'Total'), span('', ' '.repeat(9)),
|
|
411
|
-
span(t.gray, fmtTokens(total)),
|
|
412
|
-
span('', ' '.repeat(Math.max(1, 10 - fmtTokens(total).length))),
|
|
413
|
-
...contextBar(total, window, t),
|
|
414
|
-
]);
|
|
415
|
-
lines.push([span('', ' ')]);
|
|
416
|
-
lines.push([span('', ' '), span(t.gray, `Context window: ${fmtTokens(window)} tokens`)]);
|
|
417
|
-
return lines;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// ── agents / sessions overlay ────────────────────────────────────────────────
|
|
421
|
-
|
|
422
|
-
/** @param {object} state {version, model, cwd, sessions} */
|
|
423
|
-
function renderSessionsOverlay(state, width, height, ctx = {}) {
|
|
424
|
-
const t = themeOf(ctx);
|
|
425
|
-
const s = obj(state);
|
|
426
|
-
const W = Math.max(30, num(width) ? num(width) - 4 : 76);
|
|
427
|
-
const ver = str(s.version);
|
|
428
|
-
const model = str(s.model) || 'default model';
|
|
429
|
-
const cwd = cwdName(s.cwd);
|
|
430
|
-
const sessions = Array.isArray(s.sessions) ? s.sessions.filter(Boolean) : [];
|
|
431
|
-
const awaiting = sessions.filter((x) => x.awaiting || x.needsInput).length;
|
|
432
|
-
const working = sessions.filter((x) => x.working).length;
|
|
433
|
-
const completed = sessions.filter((x) => x.completed).length;
|
|
434
|
-
|
|
435
|
-
const line = (spans) => [
|
|
436
|
-
span(t.gray, '│'), span('', ' '), ...spans,
|
|
437
|
-
span('', ' '.repeat(Math.max(0, W - 1 - lineWidth(spans)))),
|
|
438
|
-
span(t.gray, '│'),
|
|
439
|
-
];
|
|
440
|
-
const box = [];
|
|
441
|
-
box.push([span(t.coral, '╭─── Aegiscode v' + ver + ' ' + '─'.repeat(Math.max(0, W - 24)) + '╮')]);
|
|
442
|
-
box.push(line([span(t.white, model), span(t.gray, ' · '), span(t.white, cwd)]));
|
|
443
|
-
box.push(line([span(t.gray, `${awaiting} awaiting input · ${working} working · ${completed} completed`)]));
|
|
444
|
-
box.push([span(t.gray, '├' + '─'.repeat(W) + '┤')]);
|
|
445
|
-
box.push(line([span(t.white + BOLD, 'Needs input'), span(BOLD_OFF, '')]));
|
|
446
|
-
box.push(line([span(t.gray, 'Sessions that have a question or need your decision land here')]));
|
|
447
|
-
box.push(line([span(t.coral, GLYPH.bloom), span(t.gray, ' current session send a prompt to start '), span(t.gray, '—')]));
|
|
448
|
-
box.push(line([span(t.white + BOLD, 'Working'), span(BOLD_OFF, '')]));
|
|
449
|
-
box.push(line([span(t.gray, 'Sessions AEGIS is actively working on — they keep running even if you close the terminal')]));
|
|
450
|
-
box.push(line([span(t.white + BOLD, 'Completed'), span(BOLD_OFF, '')]));
|
|
451
|
-
box.push(line([span(t.gray, 'Finished sessions wait here for you to review')]));
|
|
452
|
-
box.push([span(t.gray, '╰' + '─'.repeat(W) + '╯')]);
|
|
453
|
-
box.push([span('', ' '), span(t.gray, 'Sub-agents that keep working in the background need a local agent loop;')]);
|
|
454
|
-
box.push([span('', ' '), span(t.gray, 'this build hands a bigger task to the pooled brain instead.')]);
|
|
455
|
-
return box;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/** @param {object} state /agents — the sessions overlay at the terminal size. */
|
|
459
|
-
function buildAgents(state, ctx = {}) {
|
|
460
|
-
const { cols, rows } = getSize();
|
|
461
|
-
return renderSessionsOverlay(state, cols, rows, ctx);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// ── /permissions ─────────────────────────────────────────────────────────────
|
|
465
|
-
|
|
466
|
-
/** @param {object} rules {allow,deny,ask,defaultMode,_path} @param {string} [mode] */
|
|
467
|
-
function buildPermissions(rules, mode, ctx = {}) {
|
|
468
|
-
const t = themeOf(ctx);
|
|
469
|
-
const r = obj(rules);
|
|
470
|
-
const list = (v) => (Array.isArray(v) ? v : []);
|
|
471
|
-
const def = mode != null && mode !== '' ? String(mode) : (r.defaultMode != null ? String(r.defaultMode) : 'default');
|
|
472
|
-
|
|
473
|
-
const lines = [];
|
|
474
|
-
lines.push([span(t.gold + BOLD, 'Permissions'), span(BOLD_OFF, '')]);
|
|
475
|
-
lines.push([span('', ' '), span(t.gray, 'Default mode: '), span(t.white, def)]);
|
|
476
|
-
lines.push([span('', ' ')]);
|
|
477
|
-
const section = (name, patterns) => {
|
|
478
|
-
const out = [[span('', ' '), span(t.white + BOLD, name), span(BOLD_OFF, '')]];
|
|
479
|
-
if (!patterns.length) out.push([span('', ' '), span(t.gray, '(none)')]);
|
|
480
|
-
for (const p of patterns) out.push([span('', ' '), span(t.gray, str(p))]);
|
|
481
|
-
return out;
|
|
482
|
-
};
|
|
483
|
-
for (const l of section('Allow', list(r.allow))) lines.push(l);
|
|
484
|
-
for (const l of section('Deny', list(r.deny))) lines.push(l);
|
|
485
|
-
for (const l of section('Ask', list(r.ask))) lines.push(l);
|
|
486
|
-
lines.push([span('', '')]);
|
|
487
|
-
lines.push([span(t.gray, 'Usage:')]);
|
|
488
|
-
lines.push([span(t.gray, ' /permissions allow "Bash(npm run *)"')]);
|
|
489
|
-
lines.push([span(t.gray, ' /permissions deny "Edit(src/**)"')]);
|
|
490
|
-
lines.push([span(t.gray, ' /permissions ask "Read(**/*.env)"')]);
|
|
491
|
-
lines.push([span(t.gray, ' /permissions default ask · /permissions clear')]);
|
|
492
|
-
lines.push([span('', '')]);
|
|
493
|
-
lines.push([span(t.dim, `Stored in ${str(r._path) || '~/.aegiscode/permissions.json'}`)]);
|
|
494
|
-
return lines;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
// ── /model list ──────────────────────────────────────────────────────────────
|
|
498
|
-
|
|
499
|
-
/** @param {string} currentId @param {Array} models [{id,name,model}] */
|
|
500
|
-
function buildModelList(currentId, models, ctx = {}) {
|
|
501
|
-
const t = themeOf(ctx);
|
|
502
|
-
const list = Array.isArray(models) ? models : [];
|
|
503
|
-
const cur0 = str(currentId);
|
|
504
|
-
// Which class each row belongs to. On byok a row is `provider:model` (the
|
|
505
|
-
// engine's listModels('byok') shape) and `model` is unset, so the third
|
|
506
|
-
// column would otherwise print "(default)" down the whole panel; the row's
|
|
507
|
-
// `note` is what actually tells the user whether this machine holds the key.
|
|
508
|
-
// A merged list (both classes at once, e.g. the /model picker's full list)
|
|
509
|
-
// tags each row with its own `cls`, checked first so an aegis row and a byok
|
|
510
|
-
// row in the same panel each render with the format that fits its shape;
|
|
511
|
-
// `ctx.modelClass` is the fallback for a single-class list with no per-row tag.
|
|
512
|
-
const byokRow = (m) => (m.cls ? m.cls === 'byok' : ctx.modelClass === 'byok');
|
|
513
|
-
const anyByok = list.some(byokRow);
|
|
514
|
-
const lines = [];
|
|
515
|
-
lines.push([span(t.gold + BOLD, 'Models'), span(BOLD_OFF, '')]);
|
|
516
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
517
|
-
for (const m of list) {
|
|
518
|
-
if (!m) continue;
|
|
519
|
-
const idv = str(m.id) || str(m.model);
|
|
520
|
-
const cur = idv !== '' && idv === cur0;
|
|
521
|
-
const id = (cur ? '▶ ' : ' ') + idv;
|
|
522
|
-
const name = str(m.name || m.label || m.model);
|
|
523
|
-
const model = byokRow(m) ? str(m.note) || str(m.model) : str(m.model) || '(default)';
|
|
524
|
-
lines.push([
|
|
525
|
-
span(t.white, id), span('', ' '.repeat(Math.max(1, 26 - [...id].length))),
|
|
526
|
-
span(t.gray, name), span('', ' '.repeat(Math.max(1, 22 - [...name].length))),
|
|
527
|
-
span(t.gray, model),
|
|
528
|
-
]);
|
|
529
|
-
}
|
|
530
|
-
if (!list.length) lines.push([span('', ' '), span(t.gray, '(no models configured)')]);
|
|
531
|
-
lines.push([span('', '')]);
|
|
532
|
-
lines.push([
|
|
533
|
-
span(t.gray, anyByok
|
|
534
|
-
? 'Switch: /model <id> · Add a provider key: /byok-key <provider> · Run on it: /class byok'
|
|
535
|
-
: 'Switch: /model <id> · Add: /model add <id> <name> <model> <baseURL> [apiKey] · Remove: /model remove <id>'),
|
|
536
|
-
]);
|
|
537
|
-
return lines;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
// ── /rewind ──────────────────────────────────────────────────────────────────
|
|
541
|
-
|
|
542
|
-
/** @param {Array} items [{idx,depth,words,ts}] */
|
|
543
|
-
function buildRewindList(items, ctx = {}) {
|
|
544
|
-
const t = themeOf(ctx);
|
|
545
|
-
const list = Array.isArray(items) ? items : [];
|
|
546
|
-
const lines = [];
|
|
547
|
-
lines.push([span(t.gold + BOLD, 'Rewind'), span(BOLD_OFF, '')]);
|
|
548
|
-
lines.push([span('', ' '), span(t.gray, 'Snapshots are taken after every exchange.')]);
|
|
549
|
-
lines.push([span('', ' ')]);
|
|
550
|
-
for (const it of list) {
|
|
551
|
-
if (!it) continue;
|
|
552
|
-
const idx = str(num(it.idx));
|
|
553
|
-
lines.push([
|
|
554
|
-
span('', ' '), span(t.green, idx),
|
|
555
|
-
span('', ' '.repeat(Math.max(1, 4 - [...idx].length))),
|
|
556
|
-
span(t.white, `${num(it.depth)} messages`),
|
|
557
|
-
span(t.gray, ` · ${num(it.words)} words · ${ago(it.ts)}`),
|
|
558
|
-
]);
|
|
559
|
-
}
|
|
560
|
-
if (!list.length) lines.push([span('', ' '), span(t.gray, '(no checkpoints)')]);
|
|
561
|
-
lines.push([span('', '')]);
|
|
562
|
-
lines.push([span(t.gray, 'Usage: /rewind N to restore that checkpoint (0 = session start)')]);
|
|
563
|
-
return lines;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// ── /hooks ───────────────────────────────────────────────────────────────────
|
|
567
|
-
|
|
568
|
-
/** @param {object} stats {enabled,hooks,events,byEvent,fromPaths} */
|
|
569
|
-
function buildHooksStatus(stats, ctx = {}) {
|
|
570
|
-
const t = themeOf(ctx);
|
|
571
|
-
const st = obj(stats);
|
|
572
|
-
const events = Array.isArray(st.events) ? st.events : [];
|
|
573
|
-
const byEvent = st.byEvent && typeof st.byEvent === 'object' ? st.byEvent : {};
|
|
574
|
-
const fromPaths = Array.isArray(st.fromPaths) ? st.fromPaths : Array.isArray(st.sources) ? st.sources : [];
|
|
575
|
-
|
|
576
|
-
const lines = [];
|
|
577
|
-
lines.push([span(t.gold + BOLD, 'Hooks status'), span(BOLD_OFF, '')]);
|
|
578
|
-
const rows = [
|
|
579
|
-
['status', st.enabled ? 'enabled' : 'disabled'],
|
|
580
|
-
['hooks', str(num(st.hooks))],
|
|
581
|
-
['events', str(events.length)],
|
|
582
|
-
];
|
|
583
|
-
for (const l of kv(t, rows, { keyStyle: t.gray, valStyle: t.white })) lines.push(l);
|
|
584
|
-
if (num(st.hooks) > 0) {
|
|
585
|
-
lines.push([span('', '')]);
|
|
586
|
-
lines.push([span('', ' '), span(t.white + BOLD, 'by event'), span(BOLD_OFF, '')]);
|
|
587
|
-
for (const [event, count] of Object.entries(byEvent)) {
|
|
588
|
-
lines.push([span('', ' '), span(t.green, GLYPH.bullet), span(t.white, ` ${event}`), span(t.gray, ` ${num(count)}`)]);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
lines.push([span('', '')]);
|
|
592
|
-
lines.push([span(t.gray, '/hooks list for full config')]);
|
|
593
|
-
lines.push([span('', '')]);
|
|
594
|
-
lines.push([span(t.dim, fromPaths.length
|
|
595
|
-
? `Settings: ${fromPaths.join(', ')}`
|
|
596
|
-
: 'Settings: no settings.json with hooks found (checked ~/.aegis, .aegis, ~/.aegiscode, .aegiscode, ~/.claude)')]);
|
|
597
|
-
lines.push([span(t.gray, 'Config hooks are read, not managed — edit the files above.')]);
|
|
598
|
-
lines.push([span(t.gray, 'The repo guard hooks (.githooks/) are installed by /hooks install.')]);
|
|
599
|
-
return lines;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/** @param {object} config {hooks:{event:[{name,matcher,hooks}]}} */
|
|
603
|
-
function buildHooksList(config, ctx = {}) {
|
|
604
|
-
const t = themeOf(ctx);
|
|
605
|
-
const cfg = obj(config);
|
|
606
|
-
const hooks = cfg.hooks && typeof cfg.hooks === 'object' ? cfg.hooks : {};
|
|
607
|
-
const lines = [];
|
|
608
|
-
lines.push([span(t.gold + BOLD, 'Hooks config'), span(BOLD_OFF, '')]);
|
|
609
|
-
let hasAny = false;
|
|
610
|
-
for (const [event, matchers] of Object.entries(hooks)) {
|
|
611
|
-
if (!Array.isArray(matchers) || matchers.length === 0) continue;
|
|
612
|
-
hasAny = true;
|
|
613
|
-
lines.push([span('', '')]);
|
|
614
|
-
lines.push([span('', ' '), span(t.white + BOLD, event), span(BOLD_OFF, '')]);
|
|
615
|
-
for (const matcher of matchers) {
|
|
616
|
-
if (!matcher) continue;
|
|
617
|
-
lines.push([span('', ' '), span(t.lavender, str(matcher.name) || '(unnamed)')]);
|
|
618
|
-
if (matcher.matcher) {
|
|
619
|
-
if (matcher.matcher.tools) lines.push([span('', ' - tools: '), span(t.gray, str(matcher.matcher.tools))]);
|
|
620
|
-
if (matcher.matcher.paths) lines.push([span('', ' - paths: '), span(t.gray, str(matcher.matcher.paths))]);
|
|
621
|
-
if (matcher.matcher.commands) lines.push([span('', ' - commands: '), span(t.gray, str(matcher.matcher.commands))]);
|
|
622
|
-
}
|
|
623
|
-
lines.push([span('', ` - hooks: ${Array.isArray(matcher.hooks) ? matcher.hooks.length : 0}`)]);
|
|
624
|
-
lines.push([span('', '')]);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
if (!hasAny) {
|
|
628
|
-
lines.push([span('', ' '), span(t.gray, 'no hooks configured.')]);
|
|
629
|
-
lines.push([span('', '')]);
|
|
630
|
-
lines.push([span('', ' '), span(t.gray, 'add hooks to settings.json:')]);
|
|
631
|
-
lines.push([span('', ' '), span(t.gray, '- ~/.aegis/settings.json (user)')]);
|
|
632
|
-
lines.push([span('', ' '), span(t.gray, '- .aegis/settings.json (project)')]);
|
|
633
|
-
} else {
|
|
634
|
-
lines.push([span('', '')]);
|
|
635
|
-
lines.push([span(t.gray, '/hooks status for the summary')]);
|
|
636
|
-
}
|
|
637
|
-
return lines;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
// ── support panels ───────────────────────────────────────────────────────────
|
|
641
|
-
|
|
642
|
-
function buildTroubleshooting(state, ctx = {}) {
|
|
643
|
-
const t = themeOf(ctx);
|
|
644
|
-
const lines = [];
|
|
645
|
-
lines.push([span(t.gold + BOLD, 'Troubleshooting'), span(BOLD_OFF, '')]);
|
|
646
|
-
const tips = [
|
|
647
|
-
['No output / blank screen', 'Run with TERM=xterm-256color, or switch to a lighter theme (/theme light).'],
|
|
648
|
-
['Keys not responding', 'This client needs a real TTY — run it from a terminal, not a CI job.'],
|
|
649
|
-
['401 / unauthorized', 'Check the account line with /status, or set a provider key with /byok-set.'],
|
|
650
|
-
['No answers from the brain', 'Confirm the token-bank balance with /billing.'],
|
|
651
|
-
['Memory looks empty', 'Recall is per-topic — try /aegis-recall <topic> or save one with /aegis-remember <note>.'],
|
|
652
|
-
];
|
|
653
|
-
for (const [issue, fix] of tips) {
|
|
654
|
-
lines.push([span(t.green, GLYPH.bullet), span(t.white, ' ' + issue)]);
|
|
655
|
-
lines.push([span('', ' '), span(t.gray, fix)]);
|
|
656
|
-
}
|
|
657
|
-
lines.push([span('', '')]);
|
|
658
|
-
lines.push([span(t.gray, 'Run /status for account state. Help: https://aegiscloud.org')]);
|
|
659
|
-
return lines;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
function buildOnboarding(state, ctx = {}) {
|
|
663
|
-
const t = themeOf(ctx);
|
|
664
|
-
const lines = [];
|
|
665
|
-
lines.push([span(t.gold + BOLD, 'Getting started'), span(BOLD_OFF, '')]);
|
|
666
|
-
const tips = [
|
|
667
|
-
['/help', 'list every command'],
|
|
668
|
-
['/', 'open the command palette'],
|
|
669
|
-
['?', 'shortcuts'],
|
|
670
|
-
['/model <id>', 'pin a model'],
|
|
671
|
-
['/theme light|dark', 'switch the colour theme'],
|
|
672
|
-
['/aegis-ask', 'ask the pooled brain a question'],
|
|
673
|
-
['/memory', 'show your AEGIS cloud memory'],
|
|
674
|
-
['Ctrl-D', 'exit'],
|
|
675
|
-
];
|
|
676
|
-
for (const [key, what] of tips) {
|
|
677
|
-
lines.push([span('', ' '), span(t.lavender, key), span('', ' '.repeat(Math.max(1, 20 - [...key].length))), span(t.gray, what)]);
|
|
678
|
-
}
|
|
679
|
-
lines.push([span('', '')]);
|
|
680
|
-
lines.push([span(t.gray, 'Try "summarize this file for me" to see the full flow.')]);
|
|
681
|
-
return lines;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function buildShellCompletion(state, ctx = {}) {
|
|
685
|
-
const t = themeOf(ctx);
|
|
686
|
-
const lines = [];
|
|
687
|
-
lines.push([span(t.gold + BOLD, 'Shell completion'), span(BOLD_OFF, '')]);
|
|
688
|
-
lines.push([span('', ' '), span(t.gray, 'Aegiscode completes /commands with Tab inside the app.')]);
|
|
689
|
-
lines.push([span('', ' '), span(t.gray, 'For shell-level completion of the aegiscode CLI itself:')]);
|
|
690
|
-
lines.push([span('', ' ')]);
|
|
691
|
-
const rows = [
|
|
692
|
-
['bash', 'eval "$(aegiscode shell-completion bash)"'],
|
|
693
|
-
['zsh', 'eval "$(aegiscode shell-completion zsh)"'],
|
|
694
|
-
['fish', 'aegiscode shell-completion fish | source'],
|
|
695
|
-
];
|
|
696
|
-
for (const [shell, cmd] of rows) {
|
|
697
|
-
lines.push([span('', ' '), span(t.white + BOLD, shell), span('', ' '.repeat(Math.max(1, 6 - shell.length))), span(t.gray, cmd)]);
|
|
698
|
-
}
|
|
699
|
-
lines.push([span('', '')]);
|
|
700
|
-
lines.push([span(t.dim, 'Add the eval line to your ~/.bashrc or ~/.zshrc to make it persist.')]);
|
|
701
|
-
return lines;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
function buildTerminalSetup(state, ctx = {}) {
|
|
705
|
-
const t = themeOf(ctx);
|
|
706
|
-
const s = obj(state);
|
|
707
|
-
const env = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
708
|
-
const { cols, rows } = getSize();
|
|
709
|
-
const shell = str(s.shell) || pathName(str(env.SHELL));
|
|
710
|
-
const table = [
|
|
711
|
-
['TERM', str(s.term) || str(env.TERM) || '(unset)'],
|
|
712
|
-
['LANG', str(s.lang) || str(env.LANG) || '(unset)'],
|
|
713
|
-
['Shell', shell || 'unknown'],
|
|
714
|
-
['Size', `${cols}x${rows}`],
|
|
715
|
-
];
|
|
716
|
-
const lines = [];
|
|
717
|
-
lines.push([span(t.gold + BOLD, 'Terminal setup'), span(BOLD_OFF, '')]);
|
|
718
|
-
for (const l of kv(t, table, { keyStyle: t.white, valStyle: t.gray })) lines.push(l);
|
|
719
|
-
lines.push([span('', '')]);
|
|
720
|
-
lines.push([span(t.gray, 'Tips:')]);
|
|
721
|
-
lines.push([span(t.gray, ' • TERM=xterm-256color enables full color + resize handling')]);
|
|
722
|
-
lines.push([span(t.gray, ' • Set LANG (e.g. en_US.UTF-8) for correct glyphs and word wrap')]);
|
|
723
|
-
lines.push([span(t.gray, ' • Resize mid-session is handled (SIGWINCH); overlays adapt')]);
|
|
724
|
-
return lines;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// ── /terminal ────────────────────────────────────────────────────────────────
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* The capability report — the same rows `aegiscode --terminal` prints, because
|
|
731
|
-
* both render `caps.describe()`. Taking the rows as an argument keeps this
|
|
732
|
-
* builder pure (see the module header): no `require('./caps.js')` here, so
|
|
733
|
-
* `/terminal` and the launcher flag cannot drift into two different reports.
|
|
734
|
-
*
|
|
735
|
-
* This is the panel the CLI help promised at `aegiscode.js:63` ("`/terminal
|
|
736
|
-
* ascii` toggles it mid-session") long before the command existed.
|
|
737
|
-
*
|
|
738
|
-
* @param {Array<[string,string]>} report rows from `caps.describe()`
|
|
739
|
-
* @param {{pinned?: boolean, light?: boolean}} [ctx] `pinned` adds the warning
|
|
740
|
-
* shown after `/terminal width`, which turns off resize re-reads.
|
|
741
|
-
*/
|
|
742
|
-
function buildTerminalCaps(report, ctx = {}) {
|
|
743
|
-
const t = themeOf(ctx);
|
|
744
|
-
const rows = (Array.isArray(report) ? report : [])
|
|
745
|
-
.filter((r) => Array.isArray(r) && r.length >= 2)
|
|
746
|
-
.map(([k, v]) => [str(k), str(v)]);
|
|
747
|
-
const lines = [];
|
|
748
|
-
lines.push([span(t.gold + BOLD, 'Terminal capabilities'), span(BOLD_OFF, '')]);
|
|
749
|
-
if (!rows.length) {
|
|
750
|
-
lines.push([span('', ' '), span(t.gray, 'No capability report available.')]);
|
|
751
|
-
return lines;
|
|
752
|
-
}
|
|
753
|
-
for (const l of kv(t, rows, { keyStyle: t.white, valStyle: t.gray })) lines.push(l);
|
|
754
|
-
lines.push([span('', '')]);
|
|
755
|
-
if (ctx && ctx.pinned) {
|
|
756
|
-
lines.push([span(t.coral, GLYPH.warn), span(t.gold, ' width is pinned — resizes are ignored until /terminal auto')]);
|
|
757
|
-
lines.push([span('', '')]);
|
|
758
|
-
}
|
|
759
|
-
lines.push([span(t.gray, 'Override: /terminal ascii | unicode | color | no-color | background <dark|light> | star <native|narrow>')]);
|
|
760
|
-
lines.push([span(t.gray, ' /terminal width <cols> | auto | status')]);
|
|
761
|
-
lines.push([span(t.gray, 'At launch: --ascii --unicode --no-color --width <cols> --terminal')]);
|
|
762
|
-
return lines;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
function buildPRs(ghOutput, ctx = {}) {
|
|
766
|
-
const t = themeOf(ctx);
|
|
767
|
-
const lines = [];
|
|
768
|
-
lines.push([span(t.gold + BOLD, 'Open pull requests'), span(BOLD_OFF, '')]);
|
|
769
|
-
const trimmed = str(ghOutput).trim();
|
|
770
|
-
if (!trimmed) {
|
|
771
|
-
lines.push([span('', ' '), span(t.gray, 'No open PRs in this repository.')]);
|
|
772
|
-
return lines;
|
|
773
|
-
}
|
|
774
|
-
for (const l of trimmed.split('\n').slice(0, 10)) {
|
|
775
|
-
lines.push([span('', ' '), span(t.white, l)]);
|
|
776
|
-
}
|
|
777
|
-
lines.push([span('', '')]);
|
|
778
|
-
lines.push([span(t.gray, 'Review with /review · comments via /pr-comments')]);
|
|
779
|
-
return lines;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// ── /benchmark ───────────────────────────────────────────────────────────────
|
|
783
|
-
|
|
784
|
-
/** @param {Array} results [[label, ms], ...] */
|
|
785
|
-
function buildBenchmark(results, ctx = {}) {
|
|
786
|
-
const t = themeOf(ctx);
|
|
787
|
-
const list = Array.isArray(results) ? results : [];
|
|
788
|
-
const lines = [];
|
|
789
|
-
lines.push([span(t.gold + BOLD, 'Benchmark'), span(BOLD_OFF, '')]);
|
|
790
|
-
lines.push([span('', ' '), span(t.gray, 'In-app micro-benchmarks (this process, this machine):')]);
|
|
791
|
-
lines.push([span('', ' ')]);
|
|
792
|
-
for (const item of list) {
|
|
793
|
-
if (!Array.isArray(item) || item.length < 2) continue;
|
|
794
|
-
const label = str(item[0]);
|
|
795
|
-
lines.push([span('', ' '), span(t.white, label), span('', ' '.repeat(Math.max(1, 30 - [...label].length))), span(t.gray, `${num(item[1])} ms`)]);
|
|
796
|
-
}
|
|
797
|
-
if (!list.length) lines.push([span('', ' '), span(t.gray, '(no benchmarks run)')]);
|
|
798
|
-
lines.push([span('', '')]);
|
|
799
|
-
lines.push([span(t.dim, 'Spoiler: the terminal renders faster than you type.')]);
|
|
800
|
-
return lines;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// ── /waifu ───────────────────────────────────────────────────────────────────
|
|
804
|
-
|
|
805
|
-
const WAIFU_ART = [
|
|
806
|
-
' ▄▄▄▄▄▄▄▄▄▄▄▄',
|
|
807
|
-
' ▄█▓▓▓▓▓▓▓▓▓▓▓▓█▄',
|
|
808
|
-
' █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█',
|
|
809
|
-
' █▓▓▓█▓▓▓▓▓▓▓█▓▓▓█',
|
|
810
|
-
' █▓▓█▓▓█▓▓▓█▓▓█▓▓█',
|
|
811
|
-
' █▓▓█▓█▓▓▓█▓█▓▓█',
|
|
812
|
-
' █▓▓▓█▓▓▓█▓▓▓█',
|
|
813
|
-
' ██▓▓▓▓▓▓▓▓▓▓▓▓▓██',
|
|
814
|
-
' █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█',
|
|
815
|
-
' █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█',
|
|
816
|
-
' █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█',
|
|
817
|
-
' ▀█▓▓▓▓▓▓▓▓▓▓▓▓▓█▀',
|
|
818
|
-
' ▀▀▀███████▀▀▀',
|
|
819
|
-
];
|
|
820
|
-
|
|
821
|
-
function buildWaifu(ctx = {}) {
|
|
822
|
-
const t = themeOf(ctx);
|
|
823
|
-
const lines = [];
|
|
824
|
-
lines.push([span(t.gold + BOLD, 'Waifu'), span(BOLD_OFF, '')]);
|
|
825
|
-
for (const row of WAIFU_ART) lines.push([span(t.lavender, row)]);
|
|
826
|
-
lines.push([span('', '')]);
|
|
827
|
-
lines.push([span(t.gray, 'A distinguished gentleman, rendered in block characters.')]);
|
|
828
|
-
return lines;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
// ── /aegis-* panels ──────────────────────────────────────────────────────────
|
|
832
|
-
|
|
833
|
-
/** @param {object} state {stats|memory, cloud, cloudNote, version, backend} */
|
|
834
|
-
function buildAegisStatus(state, ctx = {}) {
|
|
835
|
-
const t = themeOf(ctx);
|
|
836
|
-
const s = obj(state);
|
|
837
|
-
const stats = statsFrom(s);
|
|
838
|
-
const cloud = s.cloud && typeof s.cloud === 'object' ? s.cloud : null;
|
|
839
|
-
const cloudNote = str(s.cloudNote);
|
|
840
|
-
const version = str(s.version);
|
|
841
|
-
const backend = str(s.backend || s.store);
|
|
842
|
-
|
|
843
|
-
const lines = [];
|
|
844
|
-
lines.push([span(t.gold + BOLD, 'ÆGIS Status'), span(BOLD_OFF, '')]);
|
|
845
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
846
|
-
const total = stats ? num(stats.total) : 0;
|
|
847
|
-
const sessions = stats ? num(stats.sessions) : 0;
|
|
848
|
-
lines.push([span(t.white, `Memory: ${total.toLocaleString()} entries across ${sessions} sessions`)]);
|
|
849
|
-
if (stats && stats.roles && (stats.roles.user != null || stats.roles.assistant != null)) {
|
|
850
|
-
const roles = stats.roles;
|
|
851
|
-
const parts = [];
|
|
852
|
-
if (roles.user != null) parts.push(`${num(roles.user)} user`);
|
|
853
|
-
if (roles.assistant != null) parts.push(`${num(roles.assistant)} assistant`);
|
|
854
|
-
if (roles.other) parts.push(`${num(roles.other)} other`);
|
|
855
|
-
if (parts.length) lines.push([span(t.gray, ` roles: ${parts.join(' · ')}`)]);
|
|
856
|
-
}
|
|
857
|
-
if (stats && stats.tiers) lines.push([span(t.gray, ` tiers: ${JSON.stringify(stats.tiers)}`)]);
|
|
858
|
-
if (backend) lines.push([span(t.gray, ` store: ${backend}`)]);
|
|
859
|
-
if (stats && stats.total != null) {
|
|
860
|
-
const withEmb = num(stats.withEmbeddings);
|
|
861
|
-
const pct = total ? Math.round((withEmb / total) * 100) : 0;
|
|
862
|
-
if (stats.embeddingsEnabled === true) {
|
|
863
|
-
const eng = (stats.embeddingModels && Object.keys(stats.embeddingModels)[0]) || 'embedding';
|
|
864
|
-
lines.push([span(t.gray, ` embed: ${eng} · ${pct}% coverage`)]);
|
|
865
|
-
} else if (stats.embeddingsEnabled === false && total) {
|
|
866
|
-
lines.push([span(t.gray, ' embed: keyword-only')]);
|
|
867
|
-
}
|
|
868
|
-
if (stats.stale) lines.push([span(t.gray, ` stale: ${num(stats.stale)} entries >90d`)]);
|
|
869
|
-
}
|
|
870
|
-
if (cloud) {
|
|
871
|
-
const key = cloud.key ? '✓ connected' : '✗ no API key';
|
|
872
|
-
const sync = cloud.sync ? 'sync on' : 'sync off';
|
|
873
|
-
lines.push([span(t.white, `Cloud: ${key}, ${sync}`)]);
|
|
874
|
-
} else if (cloudNote) {
|
|
875
|
-
lines.push([span(t.gray, `Cloud: ${cloudNote}`)]);
|
|
876
|
-
} else {
|
|
877
|
-
lines.push([span(t.gray, 'Cloud: not checked (aegis /cloud status unavailable)')]);
|
|
878
|
-
}
|
|
879
|
-
if (version) lines.push([span(t.gray, `CLI: aegis ${version}`)]);
|
|
880
|
-
return lines;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/** @param {Array} results [{content,timestamp,source,tags}] */
|
|
884
|
-
function buildAegisRecall(results, ctx = {}) {
|
|
885
|
-
const t = themeOf(ctx);
|
|
886
|
-
const list = Array.isArray(results) ? results.filter(Boolean) : [];
|
|
887
|
-
const lines = [];
|
|
888
|
-
lines.push([span(t.gold + BOLD, 'ÆGIS Memory'), span(BOLD_OFF, '')]);
|
|
889
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
890
|
-
if (!list.length) {
|
|
891
|
-
lines.push([span(t.gray, 'No memory found for this topic.')]);
|
|
892
|
-
lines.push([span(t.gray, 'Nothing relevant is stored yet — /aegis-remember <note> saves one.')]);
|
|
893
|
-
return lines;
|
|
894
|
-
}
|
|
895
|
-
for (const r of list.slice(0, 10)) {
|
|
896
|
-
const first = str(r.content).split('\n')[0].slice(0, 90);
|
|
897
|
-
lines.push([span(t.white + BOLD, `• ${first}`), span(BOLD_OFF, '')]);
|
|
898
|
-
const when = r.timestamp ? str(r.timestamp).slice(0, 10) : '';
|
|
899
|
-
const src = r.source ? ` (${str(r.source)})` : '';
|
|
900
|
-
const tags = Array.isArray(r.tags) && r.tags.length ? ' · tags: ' + r.tags.join(', ') : '';
|
|
901
|
-
lines.push([span(t.gray, ` ${when}${src}${tags}`)]);
|
|
902
|
-
}
|
|
903
|
-
if (list.length > 10) lines.push([span(t.gray, `…and ${list.length - 10} more`)]);
|
|
904
|
-
return lines;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/** @param {string} task */
|
|
908
|
-
function buildAegisMulti(task, ctx = {}) {
|
|
909
|
-
const t = themeOf(ctx);
|
|
910
|
-
const subject = str(task);
|
|
911
|
-
const lines = [];
|
|
912
|
-
lines.push([span(t.gold + BOLD, 'ÆGIS Multi — compose'), span(BOLD_OFF, '')]);
|
|
913
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
914
|
-
lines.push([span(t.gray, 'Paste into your aegis-cli session (the confirmation prompt works there):')]);
|
|
915
|
-
lines.push([span(t.white, ` /multi ${subject}`)]);
|
|
916
|
-
lines.push([span(t.gray, ' /multiyolo ' + subject + ' — auto-approved variant')]);
|
|
917
|
-
lines.push([span('', '')]);
|
|
918
|
-
lines.push([span(t.gray, 'Optional flags: --save-as <name> · --template <id>')]);
|
|
919
|
-
lines.push([span(t.gray, 'Add "run" to execute headless here instead: /aegis-multi <task> run')]);
|
|
920
|
-
return lines;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
/** Shared renderer for --print slash results (/council, /ask, /multi run). */
|
|
924
|
-
function buildAegisPrint(title, opts = {}, ctx = {}) {
|
|
925
|
-
const t = themeOf(ctx);
|
|
926
|
-
const o = obj(opts);
|
|
927
|
-
const lines = [];
|
|
928
|
-
lines.push([span(t.gold + BOLD, str(title)), span(BOLD_OFF, '')]);
|
|
929
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
930
|
-
for (const l of str(o.result).split('\n')) lines.push([span(t.white, l)]);
|
|
931
|
-
if (o.model || o.provider) {
|
|
932
|
-
lines.push([span(t.gray, ` via ${str(o.provider) || 'aegis'}${o.model ? ' · ' + str(o.model) : ''}`)]);
|
|
933
|
-
}
|
|
934
|
-
return lines;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
// ── /billing ─────────────────────────────────────────────────────────────────
|
|
938
|
-
|
|
939
|
-
/** @param {object} state {balance,plan,account,costEur} */
|
|
940
|
-
function buildBilling(state, ctx = {}) {
|
|
941
|
-
const t = themeOf(ctx);
|
|
942
|
-
const s = obj(state);
|
|
943
|
-
const lines = [];
|
|
944
|
-
lines.push([span(t.gold + BOLD, 'Billing'), span(BOLD_OFF, '')]);
|
|
945
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
946
|
-
const rows = [];
|
|
947
|
-
if (s.balance != null) rows.push(['Balance', fmtEur(s.balance)]);
|
|
948
|
-
if (s.plan != null) rows.push(['Plan', str(s.plan)]);
|
|
949
|
-
if (s.account != null) rows.push(['Account', str(s.account)]);
|
|
950
|
-
if (s.costEur != null) rows.push(['This session', fmtEur(s.costEur)]);
|
|
951
|
-
if (rows.length) {
|
|
952
|
-
for (const l of kv(t, rows, { indent: ' ', keyStyle: t.gray, valStyle: t.white })) lines.push(l);
|
|
953
|
-
} else {
|
|
954
|
-
lines.push([span('', ' '), span(t.gray, 'No billing data available.')]);
|
|
955
|
-
}
|
|
956
|
-
lines.push([span('', '')]);
|
|
957
|
-
lines.push([span(t.white, 'AEGIS pooled inference'), span(t.gray, ' metered against your token bank')]);
|
|
958
|
-
// ── the paid prompt ───────────────────────────────────────────────────────
|
|
959
|
-
// `/billing` is the one screen a free user reaches when they are already
|
|
960
|
-
// thinking about money, and it used to spend that moment saying "AEGIS has no
|
|
961
|
-
// subscription of its own" — a claim that contradicted the plan Pro is sold
|
|
962
|
-
// as, on the only surface where the contradiction could cost a sale. It is
|
|
963
|
-
// now the place the ONE reason to pay is stated, in the words the desktop's
|
|
964
|
-
// welcome panel and the drain's refusal both use (`state.payment`, built by
|
|
965
|
-
// `cli/src/entitlement.js` from the shared module, so a terminal and a GUI
|
|
966
|
-
// cannot pitch two different products).
|
|
967
|
-
//
|
|
968
|
-
// The panel stays pure: it renders the view it is handed and never probes,
|
|
969
|
-
// never decides entitlement, and never invents a link. A caller that passes
|
|
970
|
-
// no view gets the top-up row it always printed, minus the false claim.
|
|
971
|
-
const pay = s.payment && typeof s.payment === 'object' ? s.payment : null;
|
|
972
|
-
if (pay) {
|
|
973
|
-
const { cols } = getSize();
|
|
974
|
-
const mark = pay.paid ? '✔' : '✦';
|
|
975
|
-
lines.push(...wrapRows(`${mark} ${str(pay.label) || 'Unlimited'}: ${str(pay.reason)}`, 2, pay.paid ? t.green : t.gold, cols));
|
|
976
|
-
// The honesty line rides every paid prompt, wrapped rather than clipped —
|
|
977
|
-
// `padLine()` truncates, and a truncated honesty line would read as the
|
|
978
|
-
// promise alone.
|
|
979
|
-
lines.push(...wrapRows(str(pay.honesty), 2, t.gray, cols));
|
|
980
|
-
if (!pay.paid && pay.unlock) lines.push(...wrapRows(str(pay.unlock), 2, t.gray, cols));
|
|
981
|
-
// The relay's price, on the lane a BYOK user is actually billed on. Printed
|
|
982
|
-
// only when the server published a rate (`pay.byok` is '' otherwise) —
|
|
983
|
-
// a hardcoded fee here would be a client disagreeing with the ledger, and
|
|
984
|
-
// saying nothing is the only honest alternative to inventing one. Wrapped,
|
|
985
|
-
// never clipped: `padLine()` truncates, and a truncated fee line would read
|
|
986
|
-
// as a cheaper lane than the one that bills.
|
|
987
|
-
if (pay.byok) lines.push(...wrapRows(str(pay.byok), 2, t.gray, cols));
|
|
988
|
-
// `verified === false` is the module's "we did not get a real answer"
|
|
989
|
-
// (timeout, unreadable body, no key). The offer still renders — this panel
|
|
990
|
-
// is allowed to sell — but a timeout is not presented as a fact about the
|
|
991
|
-
// account, which is the difference between a prompt and a lie.
|
|
992
|
-
if (pay.verified === false) lines.push(...wrapRows('(account not confirmed this session — verdict may be stale)', 2, t.gray, cols));
|
|
993
|
-
if (pay.url) lines.push([span('', ' '), span(t.gray, str(pay.url))]);
|
|
994
|
-
} else {
|
|
995
|
-
// Was a literal `https://aegiscloud.org/billing`, which has never been a
|
|
996
|
-
// route on aegis1 — only `/billing/success` is real; the page is `/topup`.
|
|
997
|
-
// So the one row on the one screen that exists to convert a free user sent
|
|
998
|
-
// every user who reached it to a 404, and correcting a wrong path needed an
|
|
999
|
-
// npm release because it was compiled into the client. Now it points at
|
|
1000
|
-
// `/go/topup`, a server-side indirection: the destination can change without
|
|
1001
|
-
// a client release, and the click arrives tagged with the channel. 75 cells
|
|
1002
|
-
// of 80 — measured, because `padLine()` truncates rather than wraps.
|
|
1003
|
-
lines.push([span(t.gray, ` Top-ups and invoices: ${goUrl('topup', 'cost_screen')}`)]);
|
|
1004
|
-
}
|
|
1005
|
-
return lines;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
// ── /tokens ──────────────────────────────────────────────────────────────────
|
|
1009
|
-
|
|
1010
|
-
/** @param {object} state {tokens, costEur} */
|
|
1011
|
-
function buildTokens(state, ctx = {}) {
|
|
1012
|
-
const t = themeOf(ctx);
|
|
1013
|
-
const s = obj(state);
|
|
1014
|
-
const { cols } = getSize();
|
|
1015
|
-
const W = Math.max(24, cols - 2);
|
|
1016
|
-
const tok = s.tokens && typeof s.tokens === 'object' ? s.tokens : {};
|
|
1017
|
-
const { input, output, cacheRead, cacheWrite, total } = tokenBuckets(tok);
|
|
1018
|
-
const cost = num(s.costEur);
|
|
1019
|
-
const window = num(s.contextWindow) || 200000;
|
|
1020
|
-
const pct = window > 0 ? Math.min(100, Math.round((total / window) * 100)) : 0;
|
|
1021
|
-
|
|
1022
|
-
const lines = [];
|
|
1023
|
-
lines.push([span(t.gold + BOLD, 'Token usage'), span(BOLD_OFF, '')]);
|
|
1024
|
-
lines.push([span(t.gray, '─'.repeat(Math.min(30, W)))]);
|
|
1025
|
-
const max = Math.max(input, output, cacheRead, cacheWrite, 1);
|
|
1026
|
-
const bar = (label, tokens) => {
|
|
1027
|
-
const frac = Math.min(1, tokens / max);
|
|
1028
|
-
const filled = Math.max(0, Math.round(frac * 24));
|
|
1029
|
-
return [
|
|
1030
|
-
span('', ' '), span(t.white, label),
|
|
1031
|
-
span('', ' '.repeat(Math.max(1, 11 - [...label].length))),
|
|
1032
|
-
span(t.green, '█'.repeat(filled)),
|
|
1033
|
-
span(t.dim, '█'.repeat(Math.max(0, 24 - filled))),
|
|
1034
|
-
span(t.gray, ` ${fmtTokens(tokens)}`),
|
|
1035
|
-
];
|
|
1036
|
-
};
|
|
1037
|
-
lines.push(bar('input', input));
|
|
1038
|
-
lines.push(bar('output', output));
|
|
1039
|
-
lines.push(bar('cache read', cacheRead));
|
|
1040
|
-
lines.push(bar('cache write', cacheWrite));
|
|
1041
|
-
lines.push([span('', ' ')]);
|
|
1042
|
-
lines.push([
|
|
1043
|
-
span('', ' '), span(t.white, 'Total:'), span(t.gray, ` ${fmtTokens(total)}`),
|
|
1044
|
-
span('', ' '.repeat(8)), span(t.white, 'Est. cost:'), span(t.gray, ` ${fmtEur(cost)}`),
|
|
1045
|
-
]);
|
|
1046
|
-
lines.push([span('', ' '), span(t.gray, `Context: ${pct}% of ${fmtTokens(window)} window`)]);
|
|
1047
|
-
lines.push([span('', ' '), span(t.gray, 'Tokens are counted from this session; cost is metered in euro.')]);
|
|
1048
|
-
return lines;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
// ── /skills ──────────────────────────────────────────────────────────────────
|
|
1052
|
-
|
|
1053
|
-
/** @param {Array} skills [{source,name,namespace,description}] @param {Array} scannedDirs */
|
|
1054
|
-
function buildSkills(skills, scannedDirs, ctx = {}) {
|
|
1055
|
-
const t = themeOf(ctx);
|
|
1056
|
-
const list = Array.isArray(skills) ? skills.filter(Boolean) : [];
|
|
1057
|
-
const dirs = Array.isArray(scannedDirs) ? scannedDirs : [];
|
|
1058
|
-
const lines = [];
|
|
1059
|
-
lines.push([span(t.gold + BOLD, 'Skills'), span(BOLD_OFF, '')]);
|
|
1060
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1061
|
-
if (!list.length) {
|
|
1062
|
-
lines.push([span(t.gray, 'No skills found.')]);
|
|
1063
|
-
lines.push([span(t.gray, 'Skill dirs scanned:')]);
|
|
1064
|
-
for (const d of dirs) lines.push([span(t.dim, ` ${str(d)}`)]);
|
|
1065
|
-
lines.push([span('', '')]);
|
|
1066
|
-
lines.push([span(t.gray, 'Add one: mkdir -p .aegis/skills/<name> and drop a SKILL.md inside.')]);
|
|
1067
|
-
return lines;
|
|
1068
|
-
}
|
|
1069
|
-
let lastSource = null;
|
|
1070
|
-
for (const s of list) {
|
|
1071
|
-
if (s.source !== lastSource) {
|
|
1072
|
-
lines.push([span(t.gray + BOLD, s.source === 'user' ? 'User' : 'Project'), span(BOLD_OFF, '')]);
|
|
1073
|
-
lastSource = s.source;
|
|
1074
|
-
}
|
|
1075
|
-
const name = s.namespace ? `${str(s.namespace)}/${str(s.name)}` : str(s.name);
|
|
1076
|
-
const desc = str(s.description) || '(no description)';
|
|
1077
|
-
lines.push([span(t.white, ` ${name}`), span(t.gray, ' '.repeat(Math.max(1, 18 - [...name].length)) + desc)]);
|
|
1078
|
-
}
|
|
1079
|
-
lines.push([span('', '')]);
|
|
1080
|
-
lines.push([span(t.gray, '/skills <name> for details · /skills refresh to rescan')]);
|
|
1081
|
-
return lines;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
/** /skills <name> — one skill's frontmatter + body excerpt. */
|
|
1085
|
-
function buildSkillDetail(skill, ctx = {}) {
|
|
1086
|
-
const t = themeOf(ctx);
|
|
1087
|
-
const s = obj(skill);
|
|
1088
|
-
const name = s.namespace ? `${str(s.namespace)}/${str(s.name)}` : str(s.name);
|
|
1089
|
-
const lines = [];
|
|
1090
|
-
lines.push([span(t.gold + BOLD, `Skill: ${name}`), span(BOLD_OFF, '')]);
|
|
1091
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1092
|
-
if (s.description) lines.push([span(t.gray, str(s.description))]);
|
|
1093
|
-
lines.push([span(t.dim, str(s.path))]);
|
|
1094
|
-
lines.push([span('', '')]);
|
|
1095
|
-
const body = str(s.content);
|
|
1096
|
-
const bodyLines = body.split('\n');
|
|
1097
|
-
const excerpt = bodyLines.slice(0, 8).join('\n');
|
|
1098
|
-
for (const l of excerpt.split('\n')) lines.push([span(t.white, l)]);
|
|
1099
|
-
if (bodyLines.length > 8) lines.push([span(t.gray, `… (${bodyLines.length} lines)`)]);
|
|
1100
|
-
return lines;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
// ── /mcp ─────────────────────────────────────────────────────────────────────
|
|
1104
|
-
|
|
1105
|
-
/** @param {Array|object} servers @param {Array} fromPaths */
|
|
1106
|
-
function buildMcp(servers, fromPaths, ctx = {}) {
|
|
1107
|
-
const t = themeOf(ctx);
|
|
1108
|
-
const entries = Array.isArray(servers)
|
|
1109
|
-
? servers.map((srv, i) => [str(srv && srv.name) || String(i), srv])
|
|
1110
|
-
: servers && typeof servers === 'object'
|
|
1111
|
-
? Object.entries(servers)
|
|
1112
|
-
: [];
|
|
1113
|
-
const paths = Array.isArray(fromPaths) ? fromPaths : [];
|
|
1114
|
-
const lines = [];
|
|
1115
|
-
lines.push([span(t.gold + BOLD, 'MCP servers'), span(BOLD_OFF, '')]);
|
|
1116
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1117
|
-
if (!entries.length) {
|
|
1118
|
-
lines.push([span(t.gray, 'No MCP servers configured.')]);
|
|
1119
|
-
} else {
|
|
1120
|
-
for (const [name, srv] of entries) {
|
|
1121
|
-
const cmd = typeof srv === 'string'
|
|
1122
|
-
? srv
|
|
1123
|
-
: (str(srv && srv.command) + ' ' + (Array.isArray(srv && srv.args) ? srv.args.join(' ') : '')).trim();
|
|
1124
|
-
lines.push([span(t.white, ` ${str(name)}`), span(t.gray, ' '.repeat(Math.max(1, 14 - [...str(name)].length)) + cmd)]);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
lines.push([span('', '')]);
|
|
1128
|
-
lines.push([span(t.gray, 'This build has no MCP runtime — servers are configuration only.')]);
|
|
1129
|
-
lines.push([span(t.gray, '/mcp add <name> <command> [args…] · /mcp remove <name>')]);
|
|
1130
|
-
if (paths.length) lines.push([span(t.dim, 'Sources: ' + paths.join(', '))]);
|
|
1131
|
-
return lines;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
// ── /router ──────────────────────────────────────────────────────────────────
|
|
1135
|
-
|
|
1136
|
-
/** @param {object} state {autoRouter|router:{enabled,tiers}} */
|
|
1137
|
-
function buildRouter(state, ctx = {}) {
|
|
1138
|
-
const t = themeOf(ctx);
|
|
1139
|
-
const s = obj(state);
|
|
1140
|
-
const router = s.autoRouter && typeof s.autoRouter === 'object'
|
|
1141
|
-
? s.autoRouter
|
|
1142
|
-
: s.router && typeof s.router === 'object'
|
|
1143
|
-
? s.router
|
|
1144
|
-
: { enabled: false, tiers: {} };
|
|
1145
|
-
const tiers = router.tiers && typeof router.tiers === 'object' ? router.tiers : {};
|
|
1146
|
-
const lines = [];
|
|
1147
|
-
lines.push([span(t.gold + BOLD, 'Model router'), span(BOLD_OFF, '')]);
|
|
1148
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1149
|
-
lines.push([span(t.white, `auto-router: ${router.enabled ? 'on' : 'off'}`)]);
|
|
1150
|
-
lines.push([span(t.gray, ` simple ${str(tiers.simple) || '(auto)'}`)]);
|
|
1151
|
-
lines.push([span(t.gray, ` medium ${str(tiers.medium) || '(auto)'}`)]);
|
|
1152
|
-
lines.push([span(t.gray, ` complex ${str(tiers.complex) || '(auto)'}`)]);
|
|
1153
|
-
lines.push([span('', '')]);
|
|
1154
|
-
lines.push([span(t.gray, '/router on|off · /router set <simple|medium|complex> <modelId>')]);
|
|
1155
|
-
lines.push([span(t.dim, 'Routing config is persisted for the real CLI; this build serves the model chosen by /model.')]);
|
|
1156
|
-
return lines;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
// ── /billing (provider list) + /memory ───────────────────────────────────────
|
|
1160
|
-
|
|
1161
|
-
/** @param {object} state {memory|stats, embedStatus, compactState, compactCfg} */
|
|
1162
|
-
function buildMemory(state, ctx = {}) {
|
|
1163
|
-
const t = themeOf(ctx);
|
|
1164
|
-
const s = obj(state);
|
|
1165
|
-
const stats = statsFrom(s);
|
|
1166
|
-
const embedStatus = s.embedStatus && typeof s.embedStatus === 'object' ? s.embedStatus : null;
|
|
1167
|
-
const compact = s.compactState && typeof s.compactState === 'object' ? s.compactState : (s.at ? s : null);
|
|
1168
|
-
const cfg = s.compactCfg && typeof s.compactCfg === 'object' ? s.compactCfg : null;
|
|
1169
|
-
|
|
1170
|
-
const lines = [];
|
|
1171
|
-
lines.push([span(t.gold + BOLD, 'ÆGIS Memory'), span(BOLD_OFF, '')]);
|
|
1172
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1173
|
-
const total = stats ? num(stats.total) : 0;
|
|
1174
|
-
const sessions = stats ? num(stats.sessions) : 0;
|
|
1175
|
-
lines.push([span(t.white, `${total.toLocaleString()} memories across ${sessions} sessions`)]);
|
|
1176
|
-
if (stats && stats.roles && typeof stats.roles === 'object') {
|
|
1177
|
-
const parts = [];
|
|
1178
|
-
if (stats.roles.user != null) parts.push(`${num(stats.roles.user)} user`);
|
|
1179
|
-
if (stats.roles.assistant != null) parts.push(`${num(stats.roles.assistant)} assistant`);
|
|
1180
|
-
if (stats.roles.other) parts.push(`${num(stats.roles.other)} other`);
|
|
1181
|
-
if (parts.length) lines.push([span(t.gray, ` roles: ${parts.join(' · ')}`)]);
|
|
1182
|
-
}
|
|
1183
|
-
if (stats && stats.tiers) lines.push([span(t.gray, ` tiers: ${JSON.stringify(stats.tiers)}`)]);
|
|
1184
|
-
if (stats && stats.total != null) {
|
|
1185
|
-
const pct = total ? Math.round((num(stats.withEmbeddings) / total) * 100) : 0;
|
|
1186
|
-
if (embedStatus && embedStatus.engine) {
|
|
1187
|
-
lines.push([span(t.gray, ` embed: ${str(embedStatus.engine)} · ${pct}% coverage`)]);
|
|
1188
|
-
} else if (embedStatus) {
|
|
1189
|
-
lines.push([span(t.gray, ' embed: keyword-only')]);
|
|
1190
|
-
}
|
|
1191
|
-
if (stats.stale) lines.push([span(t.gray, ` stale: ${num(stats.stale)} entries >90d`)]);
|
|
1192
|
-
}
|
|
1193
|
-
if (compact) {
|
|
1194
|
-
lines.push([span(t.gray, compact.at ? ` last compact: ${str(compact.at).slice(0, 10)}` : ' auto-compact: never run')]);
|
|
1195
|
-
}
|
|
1196
|
-
if (cfg) {
|
|
1197
|
-
lines.push([span(t.gray, ` auto-compact: ${cfg.enabled ? 'on' : 'off'} (min ${num(cfg.minL1)} L1 · ${num(cfg.cooldownMin)}m cooldown)`)]);
|
|
1198
|
-
}
|
|
1199
|
-
lines.push([span('', '')]);
|
|
1200
|
-
lines.push([span(t.gray, '/memory tiers · /memory embeddings · /memory recall <q>')]);
|
|
1201
|
-
lines.push([span(t.gray, '/memory compact · /memory profile · /aegis-remember <note> to save')]);
|
|
1202
|
-
return lines;
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
/** @param {object} state {memory|stats, pending, compactState, compactCfg} */
|
|
1206
|
-
function buildMemoryTiers(state, ctx = {}) {
|
|
1207
|
-
const t = themeOf(ctx);
|
|
1208
|
-
const s = obj(state);
|
|
1209
|
-
const stats = statsFrom(s);
|
|
1210
|
-
const pending = Array.isArray(s.pending) ? s.pending : [];
|
|
1211
|
-
const compact = s.compactState && typeof s.compactState === 'object' ? s.compactState : null;
|
|
1212
|
-
const cfg = s.compactCfg && typeof s.compactCfg === 'object' ? s.compactCfg : null;
|
|
1213
|
-
|
|
1214
|
-
const lines = [];
|
|
1215
|
-
lines.push([span(t.gold + BOLD, 'Memory Tiers'), span(BOLD_OFF, '')]);
|
|
1216
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1217
|
-
if (stats && stats.tiers) {
|
|
1218
|
-
lines.push([span(t.white, `L0 turns ${num(stats.tiers.L0)} raw session turns, volatile`)]);
|
|
1219
|
-
lines.push([span(t.white, `L1 atomic ${num(stats.tiers.L1)} facts · decisions · breakthroughs`)]);
|
|
1220
|
-
lines.push([span(t.white, `L2 scenario ${num(stats.tiers.L2)} distilled reusable context`)]);
|
|
1221
|
-
lines.push([span(t.white, `L3 profile ${num(stats.tiers.L3)} single distilled identity row`)]);
|
|
1222
|
-
}
|
|
1223
|
-
lines.push([span('', '')]);
|
|
1224
|
-
lines.push([span(t.gray, `pending L1 (auto-compact trigger): ${pending.length}`)]);
|
|
1225
|
-
if (compact && compact.at) {
|
|
1226
|
-
const sc = Array.isArray(compact.scenarios) ? compact.scenarios.length : 0;
|
|
1227
|
-
lines.push([span(t.gray, `last auto-compact: ${str(compact.at).slice(0, 16)} · ${sc} scenario${sc === 1 ? '' : 's'}`)]);
|
|
1228
|
-
} else {
|
|
1229
|
-
lines.push([span(t.gray, 'last auto-compact: never')]);
|
|
1230
|
-
}
|
|
1231
|
-
lines.push([span(t.gray, cfg
|
|
1232
|
-
? `auto-compact: ${cfg.enabled ? 'on' : 'off'} · min ${num(cfg.minL1)} L1 · ${num(cfg.cooldownMin)}m cooldown`
|
|
1233
|
-
: 'auto-compact: on · min 5 L1 · 15m cooldown')]);
|
|
1234
|
-
lines.push([span('', '')]);
|
|
1235
|
-
lines.push([span(t.gray, '/memory compact runs maintenance manually')]);
|
|
1236
|
-
return lines;
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
/** /memory embeddings [status] — engine chain + vector coverage panel. */
|
|
1240
|
-
function buildMemoryEmbeddings(status, stats, ctx = {}) {
|
|
1241
|
-
const t = themeOf(ctx);
|
|
1242
|
-
const st = status && typeof status === 'object' ? status : null;
|
|
1243
|
-
const s = stats && typeof stats === 'object' ? stats : null;
|
|
1244
|
-
const lines = [];
|
|
1245
|
-
lines.push([span(t.gold + BOLD, 'Memory Embeddings'), span(BOLD_OFF, '')]);
|
|
1246
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1247
|
-
if (st && st.engine) {
|
|
1248
|
-
lines.push([span(t.white, `engine: ${str(st.engine)} · ${str(st.model)}`)]);
|
|
1249
|
-
if (st.dim) lines.push([span(t.gray, ` dim: ${num(st.dim)}`)]);
|
|
1250
|
-
} else {
|
|
1251
|
-
lines.push([span(t.white, 'engine: keyword-only (no embedder resolved)')]);
|
|
1252
|
-
if (st && st.reason) lines.push([span(t.gray, ` reason: ${str(st.reason)}`)]);
|
|
1253
|
-
}
|
|
1254
|
-
lines.push([span(t.gray, `mode: ${st ? str(st.mode) || 'auto' : 'auto'} (env AEGIS_MEMORY_EMBED or memoryConfig.embedMode)`)]);
|
|
1255
|
-
if (s && s.total != null) {
|
|
1256
|
-
const total = num(s.total);
|
|
1257
|
-
const withEmb = num(s.withEmbeddings);
|
|
1258
|
-
const pct = total ? Math.round((withEmb / total) * 100) : 0;
|
|
1259
|
-
lines.push([span(t.gray, `coverage: ${withEmb}/${total} rows (${pct}%)`)]);
|
|
1260
|
-
if (s.embeddingModels && Object.keys(s.embeddingModels).length) {
|
|
1261
|
-
const parts = Object.entries(s.embeddingModels).map(([m, n]) => `${m}: ${num(n)}`);
|
|
1262
|
-
lines.push([span(t.gray, ` models: ${parts.join(' · ')}`)]);
|
|
1263
|
-
}
|
|
1264
|
-
if (s.stale) lines.push([span(t.gray, ` stale (>90d): ${num(s.stale)}`)]);
|
|
1265
|
-
}
|
|
1266
|
-
lines.push([span('', '')]);
|
|
1267
|
-
lines.push([span(t.gray, '/memory embeddings on|off toggles the engine chain')]);
|
|
1268
|
-
return lines;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
// ── /automode ────────────────────────────────────────────────────────────────
|
|
1272
|
-
//
|
|
1273
|
-
// This mode is called "automode" here, the same word the engine repo
|
|
1274
|
-
// (aegiscodex-dev) uses for its ← -on-an-empty-input mode: one name for one
|
|
1275
|
-
// idea across the two faces. `/yolo` remains a working ALIAS — it is what the
|
|
1276
|
-
// desktop switch, the persisted posture and every existing install's muscle
|
|
1277
|
-
// memory say, so dropping it would break the command for people who typed it
|
|
1278
|
-
// yesterday — but nothing user-facing is *labelled* YOLO any more.
|
|
1279
|
-
|
|
1280
|
-
function buildAutomode(state, ctx = {}) {
|
|
1281
|
-
const t = themeOf(ctx);
|
|
1282
|
-
const lines = [];
|
|
1283
|
-
lines.push([span(t.gold + BOLD, '⚠ automode enabled'), span(BOLD_OFF, '')]);
|
|
1284
|
-
lines.push([span(t.gray, '─'.repeat(30))]);
|
|
1285
|
-
lines.push([span(t.white, 'All tool executions are auto-approved: file writes,')]);
|
|
1286
|
-
lines.push([span(t.white, 'bash commands, and network requests run without asking.')]);
|
|
1287
|
-
lines.push([span('', '')]);
|
|
1288
|
-
lines.push([span(t.gray, 'Run /automode off to restore confirmations.')]);
|
|
1289
|
-
lines.push([span(t.gray, '(/yolo is accepted as an alias.)')]);
|
|
1290
|
-
return lines;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
// The pre-rename name, kept as an export so vendored copies and the panels
|
|
1294
|
-
// test's export list cannot break on the rename. Same function object.
|
|
1295
|
-
const buildYolo = buildAutomode;
|
|
1296
|
-
|
|
1297
|
-
// ── /release-notes ───────────────────────────────────────────────────────────
|
|
1298
|
-
|
|
1299
|
-
/**
|
|
1300
|
-
* `/release-notes` — the long form of the welcome box's `What's new`.
|
|
1301
|
-
*
|
|
1302
|
-
* This panel was stale in a way the welcome box was not. It opened at v0.1.0
|
|
1303
|
-
* and closed with three bullets declaring /login /doctor /permissions /mcp
|
|
1304
|
-
* /skills /hooks /agents /resume /rewind /compact /init /export /vim /yolo
|
|
1305
|
-
* "unavailable here — each says why". Every one of those is implemented now
|
|
1306
|
-
* (no command reports `unavailable`, and `stubPanel` has zero callers), so the
|
|
1307
|
-
* panel was telling anyone who ran it that a third of the command surface did
|
|
1308
|
-
* not exist. The list below is the real one.
|
|
1309
|
-
*
|
|
1310
|
-
* The command count is read from the registry at call time rather than frozen
|
|
1311
|
-
* as a literal, because a frozen count is precisely what nobody re-derived.
|
|
1312
|
-
*/
|
|
1313
|
-
function buildReleaseNotes(state, ctx = {}) {
|
|
1314
|
-
const t = themeOf(ctx);
|
|
1315
|
-
const out = [];
|
|
1316
|
-
out.push([span(t.gold + BOLD, `What's new in v${VERSION}`), span(BOLD_OFF, '')]);
|
|
1317
|
-
out.push([span(t.gray, '─'.repeat(30))]);
|
|
1318
|
-
|
|
1319
|
-
const bullets = [
|
|
1320
|
-
'v6.7.3 — the shared renderer is re-staged into cli/vendor.',
|
|
1321
|
-
'v6.7.1 — terminal capabilities are read from the terminal, not the platform.',
|
|
1322
|
-
'v6.7.0 — a file edit renders as a coloured diff block.',
|
|
1323
|
-
'v6.6.0 — autonomous mode: a persistent work queue with a detached worker.',
|
|
1324
|
-
'v6.5.x — the live tool row, /cost billed from the ledger the server settled at.',
|
|
1325
|
-
'v6.4.0 — `aegiscode login`/`logout`/`key`, a 0600 credential store, /cloud and /sync.',
|
|
1326
|
-
];
|
|
1327
|
-
for (const text of bullets) {
|
|
1328
|
-
const i = text.indexOf(' — ');
|
|
1329
|
-
const head = i === -1 ? text : text.slice(0, i);
|
|
1330
|
-
const body = i === -1 ? '' : text.slice(i + 3);
|
|
1331
|
-
out.push([span(t.green, '•'), span(t.gold, ` ${head}`), span(t.white, body ? ` — ${body}` : '')]);
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
let counts = null;
|
|
1335
|
-
try {
|
|
1336
|
-
// Call-time require: commands.js requires this module, so a top-level
|
|
1337
|
-
// require would close a cycle at load for no benefit.
|
|
1338
|
-
const commands = require('./commands.js');
|
|
1339
|
-
counts = { n: commands.visibleCommands().length, cats: commands.CATEGORIES.length };
|
|
1340
|
-
} catch {
|
|
1341
|
-
// A release-notes panel is never worth failing a render over — the bullets
|
|
1342
|
-
// above stand on their own without the count.
|
|
1343
|
-
}
|
|
1344
|
-
if (counts) {
|
|
1345
|
-
out.push([span('', '')]);
|
|
1346
|
-
out.push([span(t.gray, ` ${counts.n} commands across ${counts.cats} categories — /help lists them.`)]);
|
|
1347
|
-
}
|
|
1348
|
-
out.push([span(t.gray, ' The version above is read from the package; the prose is not.')]);
|
|
1349
|
-
out.push([span(t.gray, ' Repo: https://aegiscloud.org')]);
|
|
1350
|
-
return out;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
// ── honest stubs (capability absent in this client) ──────────────────────────
|
|
1354
|
-
|
|
1355
|
-
/** Two-line honest panel: a heading and the reason it is absent. */
|
|
1356
|
-
function stubPanel(ctx, name, reason) {
|
|
1357
|
-
const t = themeOf(ctx);
|
|
1358
|
-
return [
|
|
1359
|
-
[span(t.gold + BOLD, name), span(BOLD_OFF, '')],
|
|
1360
|
-
[span(t.gray, ` ${name} is not available in aegiscode — ${reason}`)],
|
|
1361
|
-
];
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
function buildDoctor(state, ctx = {}) {
|
|
1365
|
-
return stubPanel(ctx, 'Doctor', 'it needs the local environment diagnostic suite.');
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
function buildBuildPanel(args, ctx = {}) {
|
|
1369
|
-
const o = obj(args);
|
|
1370
|
-
const t = themeOf(ctx);
|
|
1371
|
-
return [
|
|
1372
|
-
[span(t.gold + BOLD, `⬡ Build: ${str(o.plan && o.plan.appName) || 'build'}`), span(BOLD_OFF, '')],
|
|
1373
|
-
[span(t.gray, ' Build is not available in aegiscode — it needs a local multi-model agent build loop.')],
|
|
1374
|
-
];
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
module.exports = {
|
|
1378
|
-
buildHelp,
|
|
1379
|
-
buildStatus,
|
|
1380
|
-
buildCost,
|
|
1381
|
-
buildContext,
|
|
1382
|
-
buildTokens,
|
|
1383
|
-
buildAgents,
|
|
1384
|
-
buildPermissions,
|
|
1385
|
-
buildModelList,
|
|
1386
|
-
buildRewindList,
|
|
1387
|
-
buildOnboarding,
|
|
1388
|
-
buildShellCompletion,
|
|
1389
|
-
buildTerminalSetup,
|
|
1390
|
-
buildTerminalCaps,
|
|
1391
|
-
buildPRs,
|
|
1392
|
-
buildBenchmark,
|
|
1393
|
-
buildWaifu,
|
|
1394
|
-
buildAegisStatus,
|
|
1395
|
-
buildAegisRecall,
|
|
1396
|
-
buildAegisMulti,
|
|
1397
|
-
buildBilling,
|
|
1398
|
-
buildMemory,
|
|
1399
|
-
buildMemoryTiers,
|
|
1400
|
-
buildRouter,
|
|
1401
|
-
buildAutomode,
|
|
1402
|
-
buildYolo,
|
|
1403
|
-
buildSkills,
|
|
1404
|
-
buildMcp,
|
|
1405
|
-
buildHooksStatus,
|
|
1406
|
-
buildHooksList,
|
|
1407
|
-
buildTroubleshooting,
|
|
1408
|
-
buildReleaseNotes,
|
|
1409
|
-
renderSessionsOverlay,
|
|
1410
|
-
// pure reference helpers with no missing capability
|
|
1411
|
-
buildAegisPrint,
|
|
1412
|
-
buildSkillDetail,
|
|
1413
|
-
buildMemoryEmbeddings,
|
|
1414
|
-
// honest stubs
|
|
1415
|
-
buildDoctor,
|
|
1416
|
-
buildBuildPanel,
|
|
1417
|
-
// local formatting helpers (exported for the panel tests)
|
|
1418
|
-
fmtEur,
|
|
1419
|
-
fmtTokens,
|
|
1420
|
-
};
|
|
3
|
+
const{span:e,getSize:t,lineWidth:s}=require("./screen.js"),{themeOf:o,BOLD:r,BOLD_OFF:n,GLYPH:a}=require("./theme.js"),{goUrl:i}=require("./signup.js"),{cwdName:u,pathName:l}=require("./format.js"),h=require("../package.json").version;function p(e){const t=Number(e);return Number.isFinite(t)?t:0}function c(e){return null==e?"":String(e)}function d(t,s,o,r){const n=Math.max(20,(Number(r)||80)-2-s),a=" ".repeat(s),i=c(t).split(/\s+/).filter(Boolean),u=[];let l="";for(const t of i){const s=l?`${l} ${t}`:t;l&&s.length>n?(u.push([e("",a),e(o,l)]),l=t):l=s}return l&&u.push([e("",a),e(o,l)]),u.length?u:[[e("",a),e(o,"")]]}function g(e){const t=p(e.input),s=p(e.output),o=p(e.cacheRead),r=p(e.cacheWrite),n=t+o+r;return{input:t,output:s,cacheRead:o,cacheWrite:r,prompt:n,total:p(e.total)||n+s}}function m(e){const t=Number(e);return!Number.isFinite(t)||t<=0?"0":Math.round(t).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function y(e){const t=Number(e);if(!Number.isFinite(t))return"€?";const s=Math.abs(t);return`€${s<.01?s.toFixed(4):s.toFixed(2)}`}function f(e){if(!e)return"";const t=Date.now()-new Date(String(e)).getTime();return t>=0&&!Number.isNaN(t)?t<6e4?`${Math.max(1,Math.round(t/1e3))}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`:""}function b(t,s,o,r=50){const n=Math.max(0,Math.min(1,s>0?p(t)/s:0)),a=Math.round(n*r);return[e(""," "),e(o.green,"█".repeat(a)),e(o.dim,"█".repeat(Math.max(0,r-a))),e(o.gray,` ${Math.round(100*n)}% used`)]}function w(t,s,{indent:o=" ",keyStyle:r=null,valStyle:n=null}={}){const a=s.reduce(((e,t)=>Math.max(e,[...t[0]].length)),0);return s.map((([s,i])=>[e(null!=r?r:t.gray,o+s+" ".repeat(a-[...s].length)+" : "),e(null!=n?n:t.white,c(i))]))}function k(e){return e&&"object"==typeof e?e:{}}function $(e){const t=k(e);return t.stats&&"object"==typeof t.stats?t.stats:t.memory&&"object"==typeof t.memory&&(null!=t.memory.total||t.memory.tiers||null!=t.memory.sessions||t.memory.roles)?t.memory:null!=t.total||t.tiers||t.roles?t:null}const v={session:"Session & context",workspace:"Workspace",model:"Model & behavior",data:"Data",auth:"Auth",support:"Support",fun:"Fun",aegis:"Aegis plugin",custom:"Custom"};function S(e){if(e&&e.categoryLabel)return String(e.categoryLabel);const t=c(e&&e.category);return v[t]?v[t]:t?t.charAt(0).toUpperCase()+t.slice(1):"Commands"}function M(t,i,l,h={}){const d=o(h),g=k(t),m=Math.max(30,p(i)?p(i)-4:76),y=c(g.version),f=c(g.model)||"default model",b=u(g.cwd),w=Array.isArray(g.sessions)?g.sessions.filter(Boolean):[],$=w.filter((e=>e.awaiting||e.needsInput)).length,v=w.filter((e=>e.working)).length,S=w.filter((e=>e.completed)).length,M=t=>[e(d.gray,"│"),e(""," "),...t,e(""," ".repeat(Math.max(0,m-1-s(t)))),e(d.gray,"│")],A=[];return A.push([e(d.coral,"╭─── Aegiscode v"+y+" "+"─".repeat(Math.max(0,m-24))+"╮")]),A.push(M([e(d.white,f),e(d.gray," · "),e(d.white,b)])),A.push(M([e(d.gray,`${$} awaiting input · ${v} working · ${S} completed`)])),A.push([e(d.gray,"├"+"─".repeat(m)+"┤")]),A.push(M([e(d.white+r,"Needs input"),e(n,"")])),A.push(M([e(d.gray,"Sessions that have a question or need your decision land here")])),A.push(M([e(d.coral,a.bloom),e(d.gray," current session send a prompt to start "),e(d.gray,"—")])),A.push(M([e(d.white+r,"Working"),e(n,"")])),A.push(M([e(d.gray,"Sessions AEGIS is actively working on — they keep running even if you close the terminal")])),A.push(M([e(d.white+r,"Completed"),e(n,"")])),A.push(M([e(d.gray,"Finished sessions wait here for you to review")])),A.push([e(d.gray,"╰"+"─".repeat(m)+"╯")]),A.push([e(""," "),e(d.gray,"Sub-agents that keep working in the background need a local agent loop;")]),A.push([e(""," "),e(d.gray,"this build hands a bigger task to the pooled brain instead.")]),A}const A=[" ▄▄▄▄▄▄▄▄▄▄▄▄"," ▄█▓▓▓▓▓▓▓▓▓▓▓▓█▄"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓█▓▓▓▓▓▓▓█▓▓▓█"," █▓▓█▓▓█▓▓▓█▓▓█▓▓█"," █▓▓█▓█▓▓▓█▓█▓▓█"," █▓▓▓█▓▓▓█▓▓▓█"," ██▓▓▓▓▓▓▓▓▓▓▓▓▓██"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," ▀█▓▓▓▓▓▓▓▓▓▓▓▓▓█▀"," ▀▀▀███████▀▀▀"];function x(t,s={}){const a=o(s),i=[];return i.push([e(a.gold+r,"⚠ automode enabled"),e(n,"")]),i.push([e(a.gray,"─".repeat(30))]),i.push([e(a.white,"All tool executions are auto-approved: file writes,")]),i.push([e(a.white,"bash commands, and network requests run without asking.")]),i.push([e("","")]),i.push([e(a.gray,"Run /automode off to restore confirmations.")]),i.push([e(a.gray,"(/yolo is accepted as an alias.)")]),i}const j=x;module.exports={buildHelp:function(t,s={}){const a=o(s),i=Array.isArray(t)?t:Array.isArray(k(t).commands)?t.commands:[],u=[];u.push([e(a.gold+r,"Commands"),e(n,"")]),u.push([e(a.gray,"─".repeat(30))]);let l=null;for(const t of i){if(!t||!t.name)continue;const s=c(t.category);s!==l&&(u.push([e("","")]),u.push([e(a.gray+r,S(t)),e(n,"")]),l=s);const o=String(t.name),i=" ".repeat(Math.max(1,16-[...o].length)),h=c(null!=t.desc?t.desc:t.help),p=t.unavailable?a.gray:a.white,d=t.unavailable?a.dim:a.gray,g=t.unavailable?" (unavailable)":"";u.push([e(p,"/"+o),e(d,i+h+g)])}return i.length||(u.push([e("","")]),u.push([e(a.gray,"No commands registered.")])),u.push([e("","")]),u.push([e(a.gray,"Shortcuts: "),e(a.white,"?"),e(a.gray," · "),e(a.white,"/help"),e(a.gray," commands · "),e(a.white,"↑↓"),e(a.gray," history · "),e(a.white,"Ctrl-L"),e(a.gray," clear · "),e(a.white,"Ctrl-D"),e(a.gray," exit")]),u},buildStatus:function(t,s={}){const a=o(s),i=k(t),u=[];u.push([e(a.gold+r,"Status"),e(n,"")]);const l=[],h=(e,t)=>{const s=c(t);""!==s&&l.push([e,s])};h("Session ID",i.sessionId),h("Working directory",i.cwd),h("Home",i.home),h("Model",i.model),h("Effort",i.effort||"high"),null!=i.thinking&&h("Thinking",i.thinking?"on":"off"),null!=i.stream&&h("Streaming",!1===i.stream?"off":"on"),null!=i.vim&&h("Vim keymap",i.vim?"on":"off"),h("Theme",i.theme?c(i.theme):s&&s.light?"Light mode":"Dark mode"),h("Backend",i.backend),h("Base",i.base),h("Plan",i.plan),h("Account",i.account),null!=i.online&&h("Online",i.online?"yes":"no"),null!=i.turns&&h("Turns",c(p(i.turns))),null!=i.calls&&h("Tool calls",c(p(i.calls))),null!=i.version&&h("Version","v"+c(i.version)),h("Node",process.version),h("Platform",`${process.platform} ${process.arch}`);const d=Array.isArray(s.caps)?s.caps:[],g=e=>{const t=d.find((t=>Array.isArray(t)&&String(t[0])===e));return t?c(t[1]):""};h("Terminal",g("terminal")),h("Mark",g("mark")),h("Star",g("star")),h("Color",g("color")),h("Control",g("control")),h("Frame",g("size"));for(const e of w(a,l,{keyStyle:a.gray,valStyle:a.white}))u.push(e);u.push([e("","")]);const m=i.permissions&&i.permissions.mode?c(i.permissions.mode):"default";return u.push([e(a.gray,`Permissions: ${m} — tool use follows your AEGIS settings.`)]),u},buildCost:function(s,a={}){const i=o(a),u=k(s),{cols:l}=t(),h=Math.max(30,l-2),d=u.tokens&&"object"==typeof u.tokens?u.tokens:{},{input:f,output:w,cacheRead:$,cacheWrite:v,prompt:S,total:M}=g(d),A=p(u.costEur),x=c(u.model)||"the pinned model",j=p(u.contextWindow)||2e5,C=j>0?Math.min(100,Math.round(M/j*100)):0,T=[];return T.push([e(i.gray,"─".repeat(h))]),T.push([e(""," "),e(i.white+r,"Session"),e(n,""),e(i.gray," Status Config Usage Stats")]),T.push([e(""," "),e(i.gray,"Session")]),T.push([e(""," "),e(i.white,"Total cost:"),e(i.gray," "+" ".repeat(Math.max(0,14-y(A).length))+y(A))]),null!=u.balance&&T.push([e(""," "),e(i.white,"Balance:"),e(i.gray," "+" ".repeat(Math.max(0,14-y(u.balance).length))+y(u.balance))]),null==u.turns&&null==u.calls||T.push([e(""," "),e(i.white,"Turns:"),e(i.gray,` ${p(u.turns)} turns · ${p(u.calls)} calls`)]),T.push([e(""," "),e(i.white," Usage by model:")]),T.push([e(""," "),e(i.gray,` ${x}: ${m(S)} input, ${m(w)} output (${y(A)})`)]),($||v)&&T.push([e(""," "),e(i.dim,` ↳ miss ${m(f)} · cache read ${m($)} · cache write ${m(v)}`)]),T.push([e(""," ")]),T.push([e(""," "),e(i.white+r,"Current session"),e(n,"")]),T.push(b(M,j,i)),T.push([e(""," ")]),T.push([e(""," "),e(i.gray,`Session context: ${C}% of ${m(j)} used.`)]),T.push([e(""," "),e(i.dim,"Cost is metered from the AEGIS token bank; tokens are counted this session.")]),T},buildContext:function(s,a={}){const i=o(a),u=k(s),{cols:l}=t(),h=Math.max(30,l-2),c=u.tokens&&"object"==typeof u.tokens?u.tokens:{},{input:d,output:y,cacheRead:f,cacheWrite:w,prompt:$,total:v}=g(c),S=p(u.contextWindow)||2e5,M=[];M.push([e(i.gold+r,"Context usage"),e(n,"")]),M.push([e(""," "),e(i.gray,"─".repeat(Math.max(1,h-2)))]);const A=(t,s)=>[e(""," "),e(i.white,t),e(""," ".repeat(Math.max(1,16-[...t].length))),e(i.gray,m(s)),e(""," ".repeat(Math.max(1,10-m(s).length))),...b(s,S,i)];return M.push(A("Prompt tokens",$)),(f||w)&&M.push([e(""," "),e(i.dim,` ↳ miss ${m(d)} · cache read ${m(f)} · cache write ${m(w)}`)]),M.push(A("Output tokens",y)),M.push([e(""," ")]),M.push([e(""," "),e(i.gray,"─".repeat(Math.max(1,h-2)))]),M.push([e(""," "),e(i.white+r,"Total"),e(""," ".repeat(9)),e(i.gray,m(v)),e(""," ".repeat(Math.max(1,10-m(v).length))),...b(v,S,i)]),M.push([e(""," ")]),M.push([e(""," "),e(i.gray,`Context window: ${m(S)} tokens`)]),M},buildTokens:function(s,a={}){const i=o(a),u=k(s),{cols:l}=t(),h=Math.max(24,l-2),c=u.tokens&&"object"==typeof u.tokens?u.tokens:{},{input:d,output:f,cacheRead:b,cacheWrite:w,total:$}=g(c),v=p(u.costEur),S=p(u.contextWindow)||2e5,M=S>0?Math.min(100,Math.round($/S*100)):0,A=[];A.push([e(i.gold+r,"Token usage"),e(n,"")]),A.push([e(i.gray,"─".repeat(Math.min(30,h)))]);const x=Math.max(d,f,b,w,1),j=(t,s)=>{const o=Math.min(1,s/x),r=Math.max(0,Math.round(24*o));return[e(""," "),e(i.white,t),e(""," ".repeat(Math.max(1,11-[...t].length))),e(i.green,"█".repeat(r)),e(i.dim,"█".repeat(Math.max(0,24-r))),e(i.gray,` ${m(s)}`)]};return A.push(j("input",d)),A.push(j("output",f)),A.push(j("cache read",b)),A.push(j("cache write",w)),A.push([e(""," ")]),A.push([e(""," "),e(i.white,"Total:"),e(i.gray,` ${m($)}`),e(""," ".repeat(8)),e(i.white,"Est. cost:"),e(i.gray,` ${y(v)}`)]),A.push([e(""," "),e(i.gray,`Context: ${M}% of ${m(S)} window`)]),A.push([e(""," "),e(i.gray,"Tokens are counted from this session; cost is metered in euro.")]),A},buildAgents:function(e,s={}){const{cols:o,rows:r}=t();return M(e,o,0,s)},buildPermissions:function(t,s,a={}){const i=o(a),u=k(t),l=e=>Array.isArray(e)?e:[],h=null!=s&&""!==s?String(s):null!=u.defaultMode?String(u.defaultMode):"default",p=[];p.push([e(i.gold+r,"Permissions"),e(n,"")]),p.push([e(""," "),e(i.gray,"Default mode: "),e(i.white,h)]),p.push([e(""," ")]);const d=(t,s)=>{const o=[[e(""," "),e(i.white+r,t),e(n,"")]];s.length||o.push([e(""," "),e(i.gray,"(none)")]);for(const t of s)o.push([e(""," "),e(i.gray,c(t))]);return o};for(const e of d("Allow",l(u.allow)))p.push(e);for(const e of d("Deny",l(u.deny)))p.push(e);for(const e of d("Ask",l(u.ask)))p.push(e);return p.push([e("","")]),p.push([e(i.gray,"Usage:")]),p.push([e(i.gray,' /permissions allow "Bash(npm run *)"')]),p.push([e(i.gray,' /permissions deny "Edit(src/**)"')]),p.push([e(i.gray,' /permissions ask "Read(**/*.env)"')]),p.push([e(i.gray," /permissions default ask · /permissions clear")]),p.push([e("","")]),p.push([e(i.dim,`Stored in ${c(u._path)||"~/.aegiscode/permissions.json"}`)]),p},buildModelList:function(t,s,a={}){const i=o(a),u=Array.isArray(s)?s:[],l=c(t),h=e=>e.cls?"byok"===e.cls:"byok"===a.modelClass,p=u.some(h),d=[];d.push([e(i.gold+r,"Models"),e(n,"")]),d.push([e(i.gray,"─".repeat(30))]);for(const t of u){if(!t)continue;const s=c(t.id)||c(t.model),o=(""!==s&&s===l?"▶ ":" ")+s,r=c(t.name||t.label||t.model),n=h(t)?c(t.note)||c(t.model):c(t.model)||"(default)";d.push([e(i.white,o),e(""," ".repeat(Math.max(1,26-[...o].length))),e(i.gray,r),e(""," ".repeat(Math.max(1,22-[...r].length))),e(i.gray,n)])}return u.length||d.push([e(""," "),e(i.gray,"(no models configured)")]),d.push([e("","")]),d.push([e(i.gray,p?"Switch: /model <id> · Add a provider key: /byok-key <provider> · Run on it: /class byok":"Switch: /model <id> · Add: /model add <id> <name> <model> <baseURL> [apiKey] · Remove: /model remove <id>")]),d},buildRewindList:function(t,s={}){const a=o(s),i=Array.isArray(t)?t:[],u=[];u.push([e(a.gold+r,"Rewind"),e(n,"")]),u.push([e(""," "),e(a.gray,"Snapshots are taken after every exchange.")]),u.push([e(""," ")]);for(const t of i){if(!t)continue;const s=c(p(t.idx));u.push([e(""," "),e(a.green,s),e(""," ".repeat(Math.max(1,4-[...s].length))),e(a.white,`${p(t.depth)} messages`),e(a.gray,` · ${p(t.words)} words · ${f(t.ts)}`)])}return i.length||u.push([e(""," "),e(a.gray,"(no checkpoints)")]),u.push([e("","")]),u.push([e(a.gray,"Usage: /rewind N to restore that checkpoint (0 = session start)")]),u},buildOnboarding:function(t,s={}){const a=o(s),i=[];i.push([e(a.gold+r,"Getting started"),e(n,"")]);const u=[["/help","list every command"],["/","open the command palette"],["?","shortcuts"],["/model <id>","pin a model"],["/theme light|dark","switch the colour theme"],["/aegis-ask","ask the pooled brain a question"],["/memory","show your AEGIS cloud memory"],["Ctrl-D","exit"]];for(const[t,s]of u)i.push([e(""," "),e(a.lavender,t),e(""," ".repeat(Math.max(1,20-[...t].length))),e(a.gray,s)]);return i.push([e("","")]),i.push([e(a.gray,'Try "summarize this file for me" to see the full flow.')]),i},buildShellCompletion:function(t,s={}){const a=o(s),i=[];i.push([e(a.gold+r,"Shell completion"),e(n,"")]),i.push([e(""," "),e(a.gray,"Aegiscode completes /commands with Tab inside the app.")]),i.push([e(""," "),e(a.gray,"For shell-level completion of the aegiscode CLI itself:")]),i.push([e(""," ")]);const u=[["bash",'eval "$(aegiscode shell-completion bash)"'],["zsh",'eval "$(aegiscode shell-completion zsh)"'],["fish","aegiscode shell-completion fish | source"]];for(const[t,s]of u)i.push([e(""," "),e(a.white+r,t),e(""," ".repeat(Math.max(1,6-t.length))),e(a.gray,s)]);return i.push([e("","")]),i.push([e(a.dim,"Add the eval line to your ~/.bashrc or ~/.zshrc to make it persist.")]),i},buildTerminalSetup:function(s,a={}){const i=o(a),u=k(s),h="undefined"!=typeof process&&process.env?process.env:{},{cols:p,rows:d}=t(),g=c(u.shell)||l(c(h.SHELL)),m=[["TERM",c(u.term)||c(h.TERM)||"(unset)"],["LANG",c(u.lang)||c(h.LANG)||"(unset)"],["Shell",g||"unknown"],["Size",`${p}x${d}`]],y=[];y.push([e(i.gold+r,"Terminal setup"),e(n,"")]);for(const e of w(i,m,{keyStyle:i.white,valStyle:i.gray}))y.push(e);return y.push([e("","")]),y.push([e(i.gray,"Tips:")]),y.push([e(i.gray," • TERM=xterm-256color enables full color + resize handling")]),y.push([e(i.gray," • Set LANG (e.g. en_US.UTF-8) for correct glyphs and word wrap")]),y.push([e(i.gray," • Resize mid-session is handled (SIGWINCH); overlays adapt")]),y},buildTerminalCaps:function(t,s={}){const i=o(s),u=(Array.isArray(t)?t:[]).filter((e=>Array.isArray(e)&&e.length>=2)).map((([e,t])=>[c(e),c(t)])),l=[];if(l.push([e(i.gold+r,"Terminal capabilities"),e(n,"")]),!u.length)return l.push([e(""," "),e(i.gray,"No capability report available.")]),l;for(const e of w(i,u,{keyStyle:i.white,valStyle:i.gray}))l.push(e);return l.push([e("","")]),s&&s.pinned&&(l.push([e(i.coral,a.warn),e(i.gold," width is pinned — resizes are ignored until /terminal auto")]),l.push([e("","")])),l.push([e(i.gray,"Override: /terminal ascii | unicode | color | no-color | background <dark|light> | star <native|narrow>")]),l.push([e(i.gray," /terminal width <cols> | auto | status")]),l.push([e(i.gray,"At launch: --ascii --unicode --no-color --width <cols> --terminal")]),l},buildPRs:function(t,s={}){const a=o(s),i=[];i.push([e(a.gold+r,"Open pull requests"),e(n,"")]);const u=c(t).trim();if(!u)return i.push([e(""," "),e(a.gray,"No open PRs in this repository.")]),i;for(const t of u.split("\n").slice(0,10))i.push([e(""," "),e(a.white,t)]);return i.push([e("","")]),i.push([e(a.gray,"Review with /review · comments via /pr-comments")]),i},buildBenchmark:function(t,s={}){const a=o(s),i=Array.isArray(t)?t:[],u=[];u.push([e(a.gold+r,"Benchmark"),e(n,"")]),u.push([e(""," "),e(a.gray,"In-app micro-benchmarks (this process, this machine):")]),u.push([e(""," ")]);for(const t of i){if(!Array.isArray(t)||t.length<2)continue;const s=c(t[0]);u.push([e(""," "),e(a.white,s),e(""," ".repeat(Math.max(1,30-[...s].length))),e(a.gray,`${p(t[1])} ms`)])}return i.length||u.push([e(""," "),e(a.gray,"(no benchmarks run)")]),u.push([e("","")]),u.push([e(a.dim,"Spoiler: the terminal renders faster than you type.")]),u},buildWaifu:function(t={}){const s=o(t),a=[];a.push([e(s.gold+r,"Waifu"),e(n,"")]);for(const t of A)a.push([e(s.lavender,t)]);return a.push([e("","")]),a.push([e(s.gray,"A distinguished gentleman, rendered in block characters.")]),a},buildAegisStatus:function(t,s={}){const a=o(s),i=k(t),u=$(i),l=i.cloud&&"object"==typeof i.cloud?i.cloud:null,h=c(i.cloudNote),d=c(i.version),g=c(i.backend||i.store),m=[];m.push([e(a.gold+r,"ÆGIS Status"),e(n,"")]),m.push([e(a.gray,"─".repeat(30))]);const y=u?p(u.total):0,f=u?p(u.sessions):0;if(m.push([e(a.white,`Memory: ${y.toLocaleString()} entries across ${f} sessions`)]),u&&u.roles&&(null!=u.roles.user||null!=u.roles.assistant)){const t=u.roles,s=[];null!=t.user&&s.push(`${p(t.user)} user`),null!=t.assistant&&s.push(`${p(t.assistant)} assistant`),t.other&&s.push(`${p(t.other)} other`),s.length&&m.push([e(a.gray,` roles: ${s.join(" · ")}`)])}if(u&&u.tiers&&m.push([e(a.gray,` tiers: ${JSON.stringify(u.tiers)}`)]),g&&m.push([e(a.gray,` store: ${g}`)]),u&&null!=u.total){const t=p(u.withEmbeddings),s=y?Math.round(t/y*100):0;if(!0===u.embeddingsEnabled){const t=u.embeddingModels&&Object.keys(u.embeddingModels)[0]||"embedding";m.push([e(a.gray,` embed: ${t} · ${s}% coverage`)])}else!1===u.embeddingsEnabled&&y&&m.push([e(a.gray," embed: keyword-only")]);u.stale&&m.push([e(a.gray,` stale: ${p(u.stale)} entries >90d`)])}if(l){const t=l.key?"✓ connected":"✗ no API key",s=l.sync?"sync on":"sync off";m.push([e(a.white,`Cloud: ${t}, ${s}`)])}else h?m.push([e(a.gray,`Cloud: ${h}`)]):m.push([e(a.gray,"Cloud: not checked (aegis /cloud status unavailable)")]);return d&&m.push([e(a.gray,`CLI: aegis ${d}`)]),m},buildAegisRecall:function(t,s={}){const a=o(s),i=Array.isArray(t)?t.filter(Boolean):[],u=[];if(u.push([e(a.gold+r,"ÆGIS Memory"),e(n,"")]),u.push([e(a.gray,"─".repeat(30))]),!i.length)return u.push([e(a.gray,"No memory found for this topic.")]),u.push([e(a.gray,"Nothing relevant is stored yet — /aegis-remember <note> saves one.")]),u;for(const t of i.slice(0,10)){const s=c(t.content).split("\n")[0].slice(0,90);u.push([e(a.white+r,`• ${s}`),e(n,"")]);const o=t.timestamp?c(t.timestamp).slice(0,10):"",i=t.source?` (${c(t.source)})`:"",l=Array.isArray(t.tags)&&t.tags.length?" · tags: "+t.tags.join(", "):"";u.push([e(a.gray,` ${o}${i}${l}`)])}return i.length>10&&u.push([e(a.gray,`…and ${i.length-10} more`)]),u},buildAegisMulti:function(t,s={}){const a=o(s),i=c(t),u=[];return u.push([e(a.gold+r,"ÆGIS Multi — compose"),e(n,"")]),u.push([e(a.gray,"─".repeat(30))]),u.push([e(a.gray,"Paste into your aegis-cli session (the confirmation prompt works there):")]),u.push([e(a.white,` /multi ${i}`)]),u.push([e(a.gray," /multiyolo "+i+" — auto-approved variant")]),u.push([e("","")]),u.push([e(a.gray,"Optional flags: --save-as <name> · --template <id>")]),u.push([e(a.gray,'Add "run" to execute headless here instead: /aegis-multi <task> run')]),u},buildBilling:function(s,a={}){const u=o(a),l=k(s),h=[];h.push([e(u.gold+r,"Billing"),e(n,"")]),h.push([e(u.gray,"─".repeat(30))]);const p=[];if(null!=l.balance&&p.push(["Balance",y(l.balance)]),null!=l.plan&&p.push(["Plan",c(l.plan)]),null!=l.account&&p.push(["Account",c(l.account)]),null!=l.costEur&&p.push(["This session",y(l.costEur)]),p.length)for(const e of w(u,p,{indent:" ",keyStyle:u.gray,valStyle:u.white}))h.push(e);else h.push([e(""," "),e(u.gray,"No billing data available.")]);h.push([e("","")]),h.push([e(u.white,"AEGIS pooled inference"),e(u.gray," metered against your token bank")]);const g=l.payment&&"object"==typeof l.payment?l.payment:null;if(g){const{cols:s}=t(),o=g.paid?"✔":"✦";h.push(...d(`${o} ${c(g.label)||"Unlimited"}: ${c(g.reason)}`,2,g.paid?u.green:u.gold,s)),h.push(...d(c(g.honesty),2,u.gray,s)),!g.paid&&g.unlock&&h.push(...d(c(g.unlock),2,u.gray,s)),g.byok&&h.push(...d(c(g.byok),2,u.gray,s)),!1===g.verified&&h.push(...d("(account not confirmed this session — verdict may be stale)",2,u.gray,s)),g.url&&h.push([e(""," "),e(u.gray,c(g.url))])}else h.push([e(u.gray,` Top-ups and invoices: ${i("topup","cost_screen")}`)]);return h},buildMemory:function(t,s={}){const a=o(s),i=k(t),u=$(i),l=i.embedStatus&&"object"==typeof i.embedStatus?i.embedStatus:null,h=i.compactState&&"object"==typeof i.compactState?i.compactState:i.at?i:null,d=i.compactCfg&&"object"==typeof i.compactCfg?i.compactCfg:null,g=[];g.push([e(a.gold+r,"ÆGIS Memory"),e(n,"")]),g.push([e(a.gray,"─".repeat(30))]);const m=u?p(u.total):0,y=u?p(u.sessions):0;if(g.push([e(a.white,`${m.toLocaleString()} memories across ${y} sessions`)]),u&&u.roles&&"object"==typeof u.roles){const t=[];null!=u.roles.user&&t.push(`${p(u.roles.user)} user`),null!=u.roles.assistant&&t.push(`${p(u.roles.assistant)} assistant`),u.roles.other&&t.push(`${p(u.roles.other)} other`),t.length&&g.push([e(a.gray,` roles: ${t.join(" · ")}`)])}if(u&&u.tiers&&g.push([e(a.gray,` tiers: ${JSON.stringify(u.tiers)}`)]),u&&null!=u.total){const t=m?Math.round(p(u.withEmbeddings)/m*100):0;l&&l.engine?g.push([e(a.gray,` embed: ${c(l.engine)} · ${t}% coverage`)]):l&&g.push([e(a.gray," embed: keyword-only")]),u.stale&&g.push([e(a.gray,` stale: ${p(u.stale)} entries >90d`)])}return h&&g.push([e(a.gray,h.at?` last compact: ${c(h.at).slice(0,10)}`:" auto-compact: never run")]),d&&g.push([e(a.gray,` auto-compact: ${d.enabled?"on":"off"} (min ${p(d.minL1)} L1 · ${p(d.cooldownMin)}m cooldown)`)]),g.push([e("","")]),g.push([e(a.gray,"/memory tiers · /memory embeddings · /memory recall <q>")]),g.push([e(a.gray,"/memory compact · /memory profile · /aegis-remember <note> to save")]),g},buildMemoryTiers:function(t,s={}){const a=o(s),i=k(t),u=$(i),l=Array.isArray(i.pending)?i.pending:[],h=i.compactState&&"object"==typeof i.compactState?i.compactState:null,d=i.compactCfg&&"object"==typeof i.compactCfg?i.compactCfg:null,g=[];if(g.push([e(a.gold+r,"Memory Tiers"),e(n,"")]),g.push([e(a.gray,"─".repeat(30))]),u&&u.tiers&&(g.push([e(a.white,`L0 turns ${p(u.tiers.L0)} raw session turns, volatile`)]),g.push([e(a.white,`L1 atomic ${p(u.tiers.L1)} facts · decisions · breakthroughs`)]),g.push([e(a.white,`L2 scenario ${p(u.tiers.L2)} distilled reusable context`)]),g.push([e(a.white,`L3 profile ${p(u.tiers.L3)} single distilled identity row`)])),g.push([e("","")]),g.push([e(a.gray,`pending L1 (auto-compact trigger): ${l.length}`)]),h&&h.at){const t=Array.isArray(h.scenarios)?h.scenarios.length:0;g.push([e(a.gray,`last auto-compact: ${c(h.at).slice(0,16)} · ${t} scenario${1===t?"":"s"}`)])}else g.push([e(a.gray,"last auto-compact: never")]);return g.push([e(a.gray,d?`auto-compact: ${d.enabled?"on":"off"} · min ${p(d.minL1)} L1 · ${p(d.cooldownMin)}m cooldown`:"auto-compact: on · min 5 L1 · 15m cooldown")]),g.push([e("","")]),g.push([e(a.gray,"/memory compact runs maintenance manually")]),g},buildRouter:function(t,s={}){const a=o(s),i=k(t),u=i.autoRouter&&"object"==typeof i.autoRouter?i.autoRouter:i.router&&"object"==typeof i.router?i.router:{enabled:!1,tiers:{}},l=u.tiers&&"object"==typeof u.tiers?u.tiers:{},h=[];return h.push([e(a.gold+r,"Model router"),e(n,"")]),h.push([e(a.gray,"─".repeat(30))]),h.push([e(a.white,"auto-router: "+(u.enabled?"on":"off"))]),h.push([e(a.gray,` simple ${c(l.simple)||"(auto)"}`)]),h.push([e(a.gray,` medium ${c(l.medium)||"(auto)"}`)]),h.push([e(a.gray,` complex ${c(l.complex)||"(auto)"}`)]),h.push([e("","")]),h.push([e(a.gray,"/router on|off · /router set <simple|medium|complex> <modelId>")]),h.push([e(a.dim,"Routing config is persisted for the real CLI; this build serves the model chosen by /model.")]),h},buildAutomode:x,buildYolo:j,buildSkills:function(t,s,a={}){const i=o(a),u=Array.isArray(t)?t.filter(Boolean):[],l=Array.isArray(s)?s:[],h=[];if(h.push([e(i.gold+r,"Skills"),e(n,"")]),h.push([e(i.gray,"─".repeat(30))]),!u.length){h.push([e(i.gray,"No skills found.")]),h.push([e(i.gray,"Skill dirs scanned:")]);for(const t of l)h.push([e(i.dim,` ${c(t)}`)]);return h.push([e("","")]),h.push([e(i.gray,"Add one: mkdir -p .aegis/skills/<name> and drop a SKILL.md inside.")]),h}let p=null;for(const t of u){t.source!==p&&(h.push([e(i.gray+r,"user"===t.source?"User":"Project"),e(n,"")]),p=t.source);const s=t.namespace?`${c(t.namespace)}/${c(t.name)}`:c(t.name),o=c(t.description)||"(no description)";h.push([e(i.white,` ${s}`),e(i.gray," ".repeat(Math.max(1,18-[...s].length))+o)])}return h.push([e("","")]),h.push([e(i.gray,"/skills <name> for details · /skills refresh to rescan")]),h},buildMcp:function(t,s,a={}){const i=o(a),u=Array.isArray(t)?t.map(((e,t)=>[c(e&&e.name)||String(t),e])):t&&"object"==typeof t?Object.entries(t):[],l=Array.isArray(s)?s:[],h=[];if(h.push([e(i.gold+r,"MCP servers"),e(n,"")]),h.push([e(i.gray,"─".repeat(30))]),u.length)for(const[t,s]of u){const o="string"==typeof s?s:(c(s&&s.command)+" "+(Array.isArray(s&&s.args)?s.args.join(" "):"")).trim();h.push([e(i.white,` ${c(t)}`),e(i.gray," ".repeat(Math.max(1,14-[...c(t)].length))+o)])}else h.push([e(i.gray,"No MCP servers configured.")]);return h.push([e("","")]),h.push([e(i.gray,"This build has no MCP runtime — servers are configuration only.")]),h.push([e(i.gray,"/mcp add <name> <command> [args…] · /mcp remove <name>")]),l.length&&h.push([e(i.dim,"Sources: "+l.join(", "))]),h},buildHooksStatus:function(t,s={}){const i=o(s),u=k(t),l=Array.isArray(u.events)?u.events:[],h=u.byEvent&&"object"==typeof u.byEvent?u.byEvent:{},d=Array.isArray(u.fromPaths)?u.fromPaths:Array.isArray(u.sources)?u.sources:[],g=[];g.push([e(i.gold+r,"Hooks status"),e(n,"")]);const m=[["status",u.enabled?"enabled":"disabled"],["hooks",c(p(u.hooks))],["events",c(l.length)]];for(const e of w(i,m,{keyStyle:i.gray,valStyle:i.white}))g.push(e);if(p(u.hooks)>0){g.push([e("","")]),g.push([e(""," "),e(i.white+r,"by event"),e(n,"")]);for(const[t,s]of Object.entries(h))g.push([e(""," "),e(i.green,a.bullet),e(i.white,` ${t}`),e(i.gray,` ${p(s)}`)])}return g.push([e("","")]),g.push([e(i.gray,"/hooks list for full config")]),g.push([e("","")]),g.push([e(i.dim,d.length?`Settings: ${d.join(", ")}`:"Settings: no settings.json with hooks found (checked ~/.aegis, .aegis, ~/.aegiscode, .aegiscode, ~/.claude)")]),g.push([e(i.gray,"Config hooks are read, not managed — edit the files above.")]),g.push([e(i.gray,"The repo guard hooks (.githooks/) are installed by /hooks install.")]),g},buildHooksList:function(t,s={}){const a=o(s),i=k(t),u=i.hooks&&"object"==typeof i.hooks?i.hooks:{},l=[];l.push([e(a.gold+r,"Hooks config"),e(n,"")]);let h=!1;for(const[t,s]of Object.entries(u))if(Array.isArray(s)&&0!==s.length){h=!0,l.push([e("","")]),l.push([e(""," "),e(a.white+r,t),e(n,"")]);for(const t of s)t&&(l.push([e(""," "),e(a.lavender,c(t.name)||"(unnamed)")]),t.matcher&&(t.matcher.tools&&l.push([e(""," - tools: "),e(a.gray,c(t.matcher.tools))]),t.matcher.paths&&l.push([e(""," - paths: "),e(a.gray,c(t.matcher.paths))]),t.matcher.commands&&l.push([e(""," - commands: "),e(a.gray,c(t.matcher.commands))])),l.push([e("",` - hooks: ${Array.isArray(t.hooks)?t.hooks.length:0}`)]),l.push([e("","")]))}return h?(l.push([e("","")]),l.push([e(a.gray,"/hooks status for the summary")])):(l.push([e(""," "),e(a.gray,"no hooks configured.")]),l.push([e("","")]),l.push([e(""," "),e(a.gray,"add hooks to settings.json:")]),l.push([e(""," "),e(a.gray,"- ~/.aegis/settings.json (user)")]),l.push([e(""," "),e(a.gray,"- .aegis/settings.json (project)")])),l},buildTroubleshooting:function(t,s={}){const i=o(s),u=[];u.push([e(i.gold+r,"Troubleshooting"),e(n,"")]);const l=[["No output / blank screen","Run with TERM=xterm-256color, or switch to a lighter theme (/theme light)."],["Keys not responding","This client needs a real TTY — run it from a terminal, not a CI job."],["401 / unauthorized","Check the account line with /status, or set a provider key with /byok-set."],["No answers from the brain","Confirm the token-bank balance with /billing."],["Memory looks empty","Recall is per-topic — try /aegis-recall <topic> or save one with /aegis-remember <note>."]];for(const[t,s]of l)u.push([e(i.green,a.bullet),e(i.white," "+t)]),u.push([e(""," "),e(i.gray,s)]);return u.push([e("","")]),u.push([e(i.gray,"Run /status for account state. Help: https://aegiscloud.org")]),u},buildReleaseNotes:function(t,s={}){const a=o(s),i=[];i.push([e(a.gold+r,`What's new in v${h}`),e(n,"")]),i.push([e(a.gray,"─".repeat(30))]);const u=["v6.7.3 — the shared renderer is re-staged into cli/vendor.","v6.7.1 — terminal capabilities are read from the terminal, not the platform.","v6.7.0 — a file edit renders as a coloured diff block.","v6.6.0 — autonomous mode: a persistent work queue with a detached worker.","v6.5.x — the live tool row, /cost billed from the ledger the server settled at.","v6.4.0 — `aegiscode login`/`logout`/`key`, a 0600 credential store, /cloud and /sync."];for(const t of u){const s=t.indexOf(" — "),o=-1===s?t:t.slice(0,s),r=-1===s?"":t.slice(s+3);i.push([e(a.green,"•"),e(a.gold,` ${o}`),e(a.white,r?` — ${r}`:"")])}let l=null;try{const e=require("./commands.js");l={n:e.visibleCommands().length,cats:e.CATEGORIES.length}}catch{}return l&&(i.push([e("","")]),i.push([e(a.gray,` ${l.n} commands across ${l.cats} categories — /help lists them.`)])),i.push([e(a.gray," The version above is read from the package; the prose is not.")]),i.push([e(a.gray," Repo: https://aegiscloud.org")]),i},renderSessionsOverlay:M,buildAegisPrint:function(t,s={},a={}){const i=o(a),u=k(s),l=[];l.push([e(i.gold+r,c(t)),e(n,"")]),l.push([e(i.gray,"─".repeat(30))]);for(const t of c(u.result).split("\n"))l.push([e(i.white,t)]);return(u.model||u.provider)&&l.push([e(i.gray,` via ${c(u.provider)||"aegis"}${u.model?" · "+c(u.model):""}`)]),l},buildSkillDetail:function(t,s={}){const a=o(s),i=k(t),u=i.namespace?`${c(i.namespace)}/${c(i.name)}`:c(i.name),l=[];l.push([e(a.gold+r,`Skill: ${u}`),e(n,"")]),l.push([e(a.gray,"─".repeat(30))]),i.description&&l.push([e(a.gray,c(i.description))]),l.push([e(a.dim,c(i.path))]),l.push([e("","")]);const h=c(i.content).split("\n"),p=h.slice(0,8).join("\n");for(const t of p.split("\n"))l.push([e(a.white,t)]);return h.length>8&&l.push([e(a.gray,`… (${h.length} lines)`)]),l},buildMemoryEmbeddings:function(t,s,a={}){const i=o(a),u=t&&"object"==typeof t?t:null,l=s&&"object"==typeof s?s:null,h=[];if(h.push([e(i.gold+r,"Memory Embeddings"),e(n,"")]),h.push([e(i.gray,"─".repeat(30))]),u&&u.engine?(h.push([e(i.white,`engine: ${c(u.engine)} · ${c(u.model)}`)]),u.dim&&h.push([e(i.gray,` dim: ${p(u.dim)}`)])):(h.push([e(i.white,"engine: keyword-only (no embedder resolved)")]),u&&u.reason&&h.push([e(i.gray,` reason: ${c(u.reason)}`)])),h.push([e(i.gray,`mode: ${u&&c(u.mode)||"auto"} (env AEGIS_MEMORY_EMBED or memoryConfig.embedMode)`)]),l&&null!=l.total){const t=p(l.total),s=p(l.withEmbeddings),o=t?Math.round(s/t*100):0;if(h.push([e(i.gray,`coverage: ${s}/${t} rows (${o}%)`)]),l.embeddingModels&&Object.keys(l.embeddingModels).length){const t=Object.entries(l.embeddingModels).map((([e,t])=>`${e}: ${p(t)}`));h.push([e(i.gray,` models: ${t.join(" · ")}`)])}l.stale&&h.push([e(i.gray,` stale (>90d): ${p(l.stale)}`)])}return h.push([e("","")]),h.push([e(i.gray,"/memory embeddings on|off toggles the engine chain")]),h},buildDoctor:function(t,s={}){return function(t,s,a){const i=o(t);return[[e(i.gold+r,s),e(n,"")],[e(i.gray,` ${s} is not available in aegiscode — it needs the local environment diagnostic suite.`)]]}(s,"Doctor")},buildBuildPanel:function(t,s={}){const a=k(t),i=o(s);return[[e(i.gold+r,`⬡ Build: ${c(a.plan&&a.plan.appName)||"build"}`),e(n,"")],[e(i.gray," Build is not available in aegiscode — it needs a local multi-model agent build loop.")]]},fmtEur:y,fmtTokens:m};
|