aegiscode 6.8.11 → 6.8.12

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.
@@ -0,0 +1,559 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * `aegiscode fingerprint` — the key and the record, from the terminal.
5
+ *
6
+ * aegiscode fingerprint status which key is in use, and where
7
+ * aegiscode fingerprint keygen mint a private authorship key
8
+ * aegiscode fingerprint mint seal a session as a φ(α) record
9
+ * aegiscode fingerprint verify <file> recompute a record's attestation
10
+ * aegiscode fingerprint backup --to DIR copy the key somewhere safe
11
+ * aegiscode fingerprint publish [<file>] put a record in the vault, link it
12
+ * aegiscode fingerprint anchor <file> is the published copy still ours?
13
+ * aegiscode fingerprint vault [--audit] what is in the vault (and is a key)
14
+ *
15
+ * This file is argv plumbing, output and exit codes: the cryptography and the
16
+ * key-handling rules are in `client/{fingerprint,authorship-key,attest}.js`,
17
+ * shared byte-for-byte with the desktop app so the two hosts cannot mint
18
+ * incompatible records. It is deliberately thin for the same reason `src/
19
+ * presence.js` is: the part worth testing is the shared part.
20
+ *
21
+ * ## Exit codes, because this is a script surface
22
+ *
23
+ * 0 the question was answered ("is it configured?" yes; "does it verify?" yes)
24
+ * 1 the answer is no — not configured, or the record does not verify
25
+ * 2 the command could not be carried out at all (usage, missing file, no key)
26
+ *
27
+ * 1 vs 2 is the difference a caller needs: `mint` failing because no key exists
28
+ * is not the same event as `verify` reporting a tampered record, and a monitoring
29
+ * script has to be able to tell them apart without parsing prose.
30
+ *
31
+ * ## The key is never printed
32
+ *
33
+ * Every subcommand that touches the key prints a *derived* 12-hex fingerprint
34
+ * (`keyFingerprint(secret)` = `sha256('aegiscode-agent-v1\n' + secret)[0:12]`,
35
+ * the same value the avatar registry indexes by), and
36
+ * `test/cli-fingerprint.test.mjs` asserts the key's text appears nowhere in
37
+ * stdout or stderr. That is the only way "which key is this?" can be answered
38
+ * across two machines without either machine revealing one.
39
+ */
40
+
41
+ const fs = require('node:fs');
42
+ const path = require('node:path');
43
+
44
+ const { resolveClientModule } = require('./shared.js');
45
+
46
+ /**
47
+ * The shared modules are resolved by existence (repo checkout first, staged
48
+ * vendor tree second) — see `src/shared.js`. `fingerprint.js` requires
49
+ * `./touch.js` and `authorship-key.js` requires `./fingerprint.js` by plain
50
+ * same-directory paths, so all five must be staged together; a package missing
51
+ * one would be a MODULE_NOT_FOUND at load, which is loud and correct.
52
+ */
53
+ function load() {
54
+ return {
55
+ fp: require(resolveClientModule('fingerprint.js')),
56
+ authorship: require(resolveClientModule('authorship-key.js')),
57
+ attest: require(resolveClientModule('attest.js')),
58
+ vault: require(resolveClientModule('record-vault.js')),
59
+ };
60
+ }
61
+
62
+ /** `--flag value`, repeatable flags returned in order. */
63
+ function flag(argv, name, fallback = null) {
64
+ const i = argv.indexOf(name);
65
+ return i !== -1 && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--')
66
+ ? argv[i + 1]
67
+ : fallback;
68
+ }
69
+
70
+ function everyFlag(argv, name) {
71
+ const out = [];
72
+ for (let i = 0; i < argv.length - 1; i += 1) {
73
+ if (argv[i] === name && !argv[i + 1].startsWith('--')) out.push(argv[i + 1]);
74
+ }
75
+ return out;
76
+ }
77
+
78
+ function has(argv, name) {
79
+ return argv.includes(name);
80
+ }
81
+
82
+ /** A session id goes into a filename, so it may not be a path. */
83
+ function slug(value, max = 80) {
84
+ return String(value || 'session')
85
+ .replace(/[^A-Za-z0-9._-]+/g, '_')
86
+ .replace(/^[._-]+/, '')
87
+ .slice(0, max) || 'session';
88
+ }
89
+
90
+ /**
91
+ * Where a minted record lands with no `--out`. `last` is the honest name for
92
+ * "the last session in the log" — this module does not know the id because
93
+ * `attest` chose it, and inventing one would put a wrong name in the filename.
94
+ */
95
+ function defaultRecordPath(record, session, dataDir) {
96
+ const stamp = String(record.createdAt).replace(/[:.]/g, '-');
97
+ return path.join(dataDir, 'fingerprints', `${slug(session)}.${stamp}.json`);
98
+ }
99
+
100
+ const HELP = `aegiscode fingerprint — φ(α): a sealed record of what a session was.
101
+
102
+ Usage:
103
+ aegiscode fingerprint status [--json]
104
+ aegiscode fingerprint keygen [--out F] [--force]
105
+ aegiscode fingerprint mint [--history F] [--session ID] [--turns N]
106
+ [--label L] [--account A] [--model M] [--tools a,b]
107
+ [--code-root DIR]... [--code-file F]...
108
+ [--code-clean | --code-dirty] [--out F] [--json]
109
+ [--ai-secret FILE] [--ai-model M]
110
+ aegiscode fingerprint verify <record.json> [--secret FILE] [--json]
111
+ aegiscode fingerprint backup [--secret FILE] --to DIR [--name N]
112
+ aegiscode fingerprint publish [<record.json>] [--remote R] [--root D]
113
+ [--dry-run] [--no-index] [--out F] [--json]
114
+ aegiscode fingerprint anchor <record.json> [--json]
115
+ aegiscode fingerprint vault [--audit] [--max N] [--json]
116
+
117
+ Key:
118
+ --secret FILE also --secret-file (the engine's spelling). A private
119
+ key, which MUST NOT be group/other readable.
120
+ --ai-secret FILE the credential the session RAN ON — a model-provider key,
121
+ not the authorship key. Only its 12-hex fingerprint is
122
+ recorded as 'aiKey'; the key itself never is. Also read
123
+ from $AEGIS_AI_SECRET. With neither, the record says
124
+ aiKey: null rather than borrowing the sealing key.
125
+ --ai-model M the model that answered. Defaults to whatever the session
126
+ log recorded, else null.
127
+ --out F where keygen writes, or where mint writes the record
128
+ --force keygen: replace an existing key. Orphans every record
129
+ minted under the old one, so it is never implicit.
130
+ --public --covenant F
131
+ key to the published covenant hash instead of a private
132
+ key. Such a record verifies for ANY covenant holder —
133
+ integrity, not authorship — and is labelled as such.
134
+
135
+ Vault:
136
+ publish copies the SEALED BYTES to the vault, byte-identical, and
137
+ writes the link (<record>.anchor.json) beside the local
138
+ copy. Default target gdrive:AEGIS-AGPL (override with
139
+ --remote/--root, or AEGIS_VAULT_REMOTE/ROOT).
140
+ anchor re-downloads the published copy and checks three separate
141
+ things: present, unchanged (sha256), still attested.
142
+ vault --audit inspects every object already in the vault for key
143
+ material and names it. The key is never published: a
144
+ secret in cloud storage can mint records that
145
+ impersonate yours.
146
+
147
+ The key is read from --secret, then $AEGIS_FINGERPRINT_SECRET, then
148
+ $AEGIS_HOME/keys/authorship.key (default ~/.aegiscode/keys/authorship.key).
149
+ With none of those, mint and verify refuse: a key nobody chose is a key whose
150
+ records prove nothing.`;
151
+
152
+ // ---------------------------------------------------------------------------
153
+ // subcommands
154
+ // ---------------------------------------------------------------------------
155
+
156
+ function status(argv, io) {
157
+ const { authorship } = load();
158
+ const env = io.env || process.env;
159
+ const key = authorship.resolveKey({ argv, env });
160
+ const history = path.join(authorship.dataDir(env), 'history.jsonl');
161
+ const report = {
162
+ configured: Boolean(key.secret),
163
+ key_source: key.source,
164
+ key_path: key.path,
165
+ key_file_mode: key.path && !/^win/.test(process.platform) ? authorship.modeString(fs.statSync(key.path).mode & 0o777) : null,
166
+ key_fingerprint: key.secret ? load().fp.keyFingerprint(key.secret) : null,
167
+ public_key: key.public,
168
+ default_key_path: authorship.defaultKeyPath(env),
169
+ history_path: history,
170
+ history_present: fs.existsSync(history),
171
+ };
172
+
173
+ if (io.json) {
174
+ io.stdout.write(JSON.stringify(report, null, 2) + '\n');
175
+ return report.configured ? 0 : 1;
176
+ }
177
+
178
+ const lines = [
179
+ `key: ${report.configured ? report.key_fingerprint : 'not set'}`,
180
+ `source: ${report.key_source || 'none'}`,
181
+ `file: ${report.key_path || report.default_key_path}`,
182
+ `mode: ${report.key_file_mode || 'n/a'}`,
183
+ `public key: ${report.public_key ? 'YES — anyone holding the covenant can forge these records' : 'no'}`,
184
+ `history: ${report.history_path}${report.history_present ? '' : ' (not created yet)'}`,
185
+ ];
186
+ if (!report.configured) {
187
+ lines.push('', 'No key yet. Mint one: aegiscode fingerprint keygen');
188
+ }
189
+ io.stdout.write(lines.join('\n') + '\n');
190
+ return report.configured ? 0 : 1;
191
+ }
192
+
193
+ function keygen(argv, io) {
194
+ const { authorship } = load();
195
+ const r = authorship.keygen({ argv, env: io.env || process.env });
196
+ if (io.json) {
197
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
198
+ return 0;
199
+ }
200
+ io.stdout.write(
201
+ [
202
+ `${r.replaced ? 'replaced' : 'created'} ${r.out} (mode ${r.mode})`,
203
+ `key: ${r.keyFingerprint} (derived — the key itself was not printed)`,
204
+ `bytes: ${r.bytes} random (256-bit)`,
205
+ '',
206
+ 'Next: aegiscode fingerprint mint seal the last session',
207
+ ` aegiscode fingerprint backup --to ~/safe keep a copy of the key`,
208
+ ].join('\n') + '\n',
209
+ );
210
+ return 0;
211
+ }
212
+
213
+ function mint(argv, io) {
214
+ const { attest, authorship } = load();
215
+ const env = io.env || process.env;
216
+ const roots = everyFlag(argv, '--code-root');
217
+ const files = everyFlag(argv, '--code-file');
218
+ const codeClean = has(argv, '--code-clean');
219
+ const codeDirty = has(argv, '--code-dirty');
220
+ if (codeClean && codeDirty) throw new Error('fingerprint: --code-clean and --code-dirty are exclusive');
221
+
222
+ const code = roots.length || files.length
223
+ ? attest.collectCode({ roots, files, skip: everyFlag(argv, '--code-skip') })
224
+ : [];
225
+
226
+ // The AI half. `attestedFields` carries the field list, so the AI flags are
227
+ // read by the shared adapter (`--ai-secret`, `$AEGIS_AI_SECRET`) exactly as the
228
+ // module documents; this host only forwards the one flag it must shape.
229
+ const r = attest.mintSession({
230
+ argv,
231
+ env,
232
+ aiModel: flag(argv, '--ai-model') || undefined,
233
+ history: flag(argv, '--history') || undefined,
234
+ session: flag(argv, '--session') || undefined,
235
+ turns: flag(argv, '--turns') || undefined,
236
+ label: flag(argv, '--label') || undefined,
237
+ account: flag(argv, '--account') || undefined,
238
+ model: flag(argv, '--model') || undefined,
239
+ tools: flag(argv, '--tools') ? flag(argv, '--tools').split(',').map((s) => s.trim()).filter(Boolean) : undefined,
240
+ code,
241
+ codeDirty: codeClean ? false : codeDirty ? true : null,
242
+ });
243
+
244
+ const out =
245
+ flag(argv, '--out') ||
246
+ defaultRecordPath(r.record, flag(argv, '--session') || 'last', authorship.dataDir(env));
247
+ fs.mkdirSync(path.dirname(path.resolve(out)), { recursive: true });
248
+ fs.writeFileSync(path.resolve(out), JSON.stringify(r.record, null, 2) + '\n');
249
+
250
+ if (io.json) {
251
+ io.stdout.write(JSON.stringify({ ...r.record, keySource: r.keySource, out: path.resolve(out) }, null, 2) + '\n');
252
+ return 0;
253
+ }
254
+ io.stdout.write(
255
+ [
256
+ `record ${path.resolve(out)}`,
257
+ `identity φ_${r.record.keyFingerprint} (key: ${r.keySource}${r.public ? ' — PUBLIC, forgeable by any covenant holder' : ''})`,
258
+ `behaviour ${r.record.behaviour || 'none'} from ${r.record.behaviourSamples} turn(s)`,
259
+ `code ${r.record.code || 'none'} ${r.record.codeFiles} file(s)${
260
+ r.record.codeDirty === null ? ' (clean/dirty unknown)' : r.record.codeDirty ? ' (dirty tree)' : ' (clean tree)'
261
+ }`,
262
+ `ai ${r.record.aiKey || 'none'}${r.record.aiKey ? ` (${r.aiKeySource})` : ' — no AI credential nominated (--ai-secret | $AEGIS_AI_SECRET)'}`,
263
+ `ai habit ${r.record.ai || 'unobserved'} from ${r.record.aiSamples} reply/replies${
264
+ r.record.aiModel ? ` on ${r.record.aiModel}` : ''
265
+ }`,
266
+ `sealed ${r.record.attestation} (v${r.record.v}, ${r.record.algo})`,
267
+ r.samples === 0 ? 'note: no turns matched — the record says so rather than signing nothing' : '',
268
+ ]
269
+ .filter(Boolean)
270
+ .join('\n') + '\n',
271
+ );
272
+ return 0;
273
+ }
274
+
275
+ function verify(argv, io) {
276
+ const { fp, authorship } = load();
277
+ const file = argv.find((a) => !a.startsWith('-'));
278
+ if (!file) throw new Error('fingerprint: verify needs a record file');
279
+
280
+ let record;
281
+ try {
282
+ record = JSON.parse(fs.readFileSync(file, 'utf8'));
283
+ } catch (e) {
284
+ throw new Error(`fingerprint: cannot read ${file} as JSON — ${e.message}`);
285
+ }
286
+
287
+ const key = authorship.resolveKey({ argv, env: io.env || process.env });
288
+ if (!key.secret) {
289
+ throw new Error(
290
+ 'fingerprint: no key to verify with — pass --secret <file>, set ' +
291
+ 'AEGIS_FINGERPRINT_SECRET, or run `aegiscode fingerprint keygen`',
292
+ );
293
+ }
294
+
295
+ const v = fp.verify(record, key.secret);
296
+ const body = {
297
+ ok: v.ok,
298
+ reason: v.reason,
299
+ id: v.id,
300
+ credential_match: v.credentialMatch,
301
+ key_source: key.source,
302
+ key_fingerprint_recorded: record.keyFingerprint || null,
303
+ file: path.resolve(file),
304
+ };
305
+
306
+ if (io.json) {
307
+ io.stdout.write(JSON.stringify(body, null, 2) + '\n');
308
+ return v.ok ? 0 : 1;
309
+ }
310
+ io.stdout.write(
311
+ v.ok
312
+ ? `verified ${record.keyFingerprint} — intact, and minted by ${key.source}\n` +
313
+ `record ${v.id}\n`
314
+ : `FAILED ${v.reason}\n` +
315
+ `key used ${key.source}\n` +
316
+ `fingerprint recorded ${record.keyFingerprint || '(none)'}\n`,
317
+ );
318
+ return v.ok ? 0 : 1;
319
+ }
320
+
321
+ function backup(argv, io) {
322
+ const { authorship } = load();
323
+ const r = authorship.backup({ argv, env: io.env || process.env });
324
+ if (io.json) {
325
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
326
+ return 0;
327
+ }
328
+ io.stdout.write(
329
+ [
330
+ `key copied ${r.from} -> ${r.to}`,
331
+ `fingerprint ${r.keyFingerprint} (same key, confirmed by re-reading the copy)`,
332
+ 'restore: point --secret at the copy (or copy it back to the key path). ' +
333
+ 'Nothing else changes.',
334
+ ].join('\n') + '\n',
335
+ );
336
+ return 0;
337
+ }
338
+
339
+ /**
340
+ * The key, when there is one, for the vault's leak check.
341
+ *
342
+ * `null` rather than a throw: publishing is a thing you do *after* sealing, and
343
+ * a host whose key resolution fails should still be told what is wrong by the
344
+ * vault check rather than by an unrelated resolve error. When a key does
345
+ * resolve, the vault compares every published byte against it.
346
+ */
347
+ function secretOrNull(authorship, argv, env) {
348
+ try {
349
+ return authorship.resolveKey({ argv, env }).secret || null;
350
+ } catch {
351
+ return null;
352
+ }
353
+ }
354
+
355
+ /** The newest local record, for `publish` with no path. */
356
+ function newestRecord(dataDir) {
357
+ const dir = path.join(dataDir, 'fingerprints');
358
+ if (!fs.existsSync(dir)) return null;
359
+ const files = fs
360
+ .readdirSync(dir)
361
+ .filter((f) => f.endsWith('.json') && !f.endsWith('.anchor.json'))
362
+ .map((f) => path.join(dir, f))
363
+ .map((f) => ({ f, mtime: fs.statSync(f).mtimeMs }))
364
+ .sort((a, b) => b.mtime - a.mtime);
365
+ return files.length ? files[0].f : null;
366
+ }
367
+
368
+ function publish(argv, io) {
369
+ const { authorship, vault } = load();
370
+ const env = io.env || process.env;
371
+ const positional = argv.find((a) => !a.startsWith('-'));
372
+ const file = positional ? path.resolve(positional) : newestRecord(authorship.dataDir(env));
373
+
374
+ if (!file) {
375
+ throw new Error(
376
+ 'fingerprint: no record to publish — seal one first ' +
377
+ '(`aegiscode fingerprint mint`), or name the file: ' +
378
+ '`aegiscode fingerprint publish <record.json>`',
379
+ );
380
+ }
381
+ if (!fs.existsSync(file)) throw new Error(`fingerprint: no record at ${file}`);
382
+
383
+ const r = vault.publish({
384
+ file,
385
+ argv,
386
+ env,
387
+ dryRun: has(argv, '--dry-run'),
388
+ secret: secretOrNull(authorship, argv, env),
389
+ });
390
+
391
+ if (io.json) {
392
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
393
+ return 0;
394
+ }
395
+ if (r.dryRun) {
396
+ io.stdout.write(
397
+ [
398
+ `dry run nothing uploaded`,
399
+ `record ${file}`,
400
+ `would go ${r.remotePath}`,
401
+ ...r.commands.map((c) => ` ${c}`),
402
+ ].join('\n') + '\n',
403
+ );
404
+ return 0;
405
+ }
406
+ io.stdout.write(
407
+ [
408
+ `published ${r.remotePath}`,
409
+ `identity φ_${r.anchor.keyFingerprint}-${r.anchor.behaviour || 'unobserved'}`,
410
+ `digest sha256 ${r.sha256.slice(0, 16)}… (${r.bytes} bytes, byte-identical to ${file})`,
411
+ `link ${r.url || '(no Drive id returned — the copy is at the path above)'}`,
412
+ `anchored ${r.localAnchor}${r.indexLines === null ? '' : ` · ledger lines ${r.indexLines}`}`,
413
+ '',
414
+ 'The key was NOT published. Only the sealed record travels; verify the copy',
415
+ `any time with: aegiscode fingerprint anchor ${path.basename(file)}`,
416
+ ].join('\n') + '\n',
417
+ );
418
+ return 0;
419
+ }
420
+
421
+ function anchorCmd(argv, io) {
422
+ const { vault } = load();
423
+ const file = argv.find((a) => !a.startsWith('-'));
424
+ if (!file) throw new Error('fingerprint: anchor needs a record file (the one you published)');
425
+
426
+ const r = vault.checkAnchor({ file: path.resolve(file), argv, env: io.env || process.env });
427
+ if (io.json) {
428
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
429
+ return r.ok ? 0 : 1;
430
+ }
431
+ if (!r.anchor) {
432
+ io.stdout.write(`not linked ${path.resolve(file)}\n ${r.reason}\n`);
433
+ return 1;
434
+ }
435
+ io.stdout.write(
436
+ [
437
+ `record ${path.resolve(file)}`,
438
+ `published ${r.anchor.path}${r.anchor.url ? `\n ${r.anchor.url}` : ''}`,
439
+ `emitted ${r.anchor.emittedAt}`,
440
+ `present ${r.present ? 'yes' : 'NO'}`,
441
+ `unchanged ${r.unchanged ? 'yes — the copy is the bytes that were sealed' : 'NO — sha256 differs'}`,
442
+ `attested ${r.attested === null ? `unknown (${r.attestationReason})` : r.attested ? 'yes — this key still recomputes it' : `NO — ${r.attestationReason}`}`,
443
+ '',
444
+ r.ok ? 'ok — the vault copy is the sealed record, unchanged.' : `FAILED — ${r.reason}`,
445
+ ].join('\n') + '\n',
446
+ );
447
+ return r.ok ? 0 : 1;
448
+ }
449
+
450
+ function vaultCmd(argv, io) {
451
+ const { authorship, vault } = load();
452
+ const env = io.env || process.env;
453
+ const audit = has(argv, '--audit');
454
+
455
+ if (audit) {
456
+ const r = vault.audit({ argv, env, secret: secretOrNull(authorship, argv, env) });
457
+ if (io.json) {
458
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
459
+ return r.ok ? 0 : 1;
460
+ }
461
+ if (r.error) {
462
+ io.stdout.write(`vault unreachable — ${r.error}\n`);
463
+ return 2;
464
+ }
465
+ io.stdout.write(
466
+ [
467
+ `vault ${r.remote}:${r.root}`,
468
+ `inspected ${r.checked} of ${r.files} object(s)`,
469
+ r.uninspected.length ? `skipped ${r.uninspected.length} (see --json)` : '',
470
+ '',
471
+ r.findings.length === 0
472
+ ? 'clean — no key material in the vault.'
473
+ : [
474
+ `KEY MATERIAL IN THE VAULT — ${r.findings.length} finding(s):`,
475
+ ...r.findings.map((f) => ` ${f.path}\n ${f.reason}`),
476
+ '',
477
+ 'Anyone who can read that folder can mint records that look like yours.',
478
+ 'Move it out, then rotate: aegiscode fingerprint keygen --force',
479
+ '(rotation orphans every record minted under the old key — publish new ones.)',
480
+ ].join('\n'),
481
+ ]
482
+ .filter(Boolean)
483
+ .join('\n') + '\n',
484
+ );
485
+ return r.ok ? 0 : 1;
486
+ }
487
+
488
+ const r = vault.list({ argv, env });
489
+ if (io.json) {
490
+ io.stdout.write(JSON.stringify(r, null, 2) + '\n');
491
+ return 0;
492
+ }
493
+ const lines = [`vault ${r.remote}:${r.root} (${r.records.length} record(s))`];
494
+ for (const rec of r.records) {
495
+ lines.push(
496
+ ` ${rec.name}`,
497
+ ` id ${rec.id || '(no anchor)'} · sha256 ${rec.sha256 ? rec.sha256.slice(0, 16) + '…' : '(none)'}`,
498
+ rec.url ? ` ${rec.url}` : '',
499
+ );
500
+ }
501
+ if (!r.records.length) lines.push(' (no records published yet — `aegiscode fingerprint publish`)');
502
+ io.stdout.write(lines.filter(Boolean).join('\n') + '\n');
503
+ return 0;
504
+ }
505
+
506
+ /**
507
+ * Run a subcommand. Returns the process exit code; never throws (a throw here
508
+ * would be a stack trace over a usage message, which is what a user reads when
509
+ * the command is spelled wrong).
510
+ */
511
+ function runFingerprint(sub, argv = [], io = {}) {
512
+ const out = {
513
+ json: false,
514
+ stdout: process.stdout,
515
+ stderr: process.stderr,
516
+ env: process.env,
517
+ ...io,
518
+ // `--json` is the SUBCOMMAND's flag. bin/aegiscode.js hands the tail of the
519
+ // line over verbatim (like `mcp`/`autonomous`, and for the same reason:
520
+ // `--secret-file` is not a session flag), so the session parser never sees
521
+ // it and `io.json` is always false here. Honouring both keeps
522
+ // `aegiscode fingerprint status --json` meaning what it reads as.
523
+ json: Boolean(io.json) || argv.includes('--json'),
524
+ };
525
+ const name = String(sub || 'status').toLowerCase();
526
+
527
+ try {
528
+ if (name === 'help' || name === '--help' || name === '-h') {
529
+ out.stdout.write(HELP + '\n');
530
+ return 0;
531
+ }
532
+ switch (name) {
533
+ case 'status':
534
+ return status(argv, out);
535
+ case 'keygen':
536
+ return keygen(argv, out);
537
+ case 'mint':
538
+ return mint(argv, out);
539
+ case 'verify':
540
+ return verify(argv, out);
541
+ case 'backup':
542
+ return backup(argv, out);
543
+ case 'publish':
544
+ return publish(argv, out);
545
+ case 'anchor':
546
+ return anchorCmd(argv, out);
547
+ case 'vault':
548
+ return vaultCmd(argv, out);
549
+ default:
550
+ out.stderr.write(`aegiscode: unknown fingerprint subcommand "${sub}"\n\n${HELP}\n`);
551
+ return 2;
552
+ }
553
+ } catch (e) {
554
+ out.stderr.write(`aegiscode: ${(e && e.message) || e}\n`);
555
+ return 2;
556
+ }
557
+ }
558
+
559
+ module.exports = { runFingerprint, HELP, slug, defaultRecordPath, flag, everyFlag };
package/src/panels.js CHANGED
@@ -714,7 +714,7 @@ function buildTerminalCaps(report, ctx = {}) {
714
714
  lines.push([span(t.coral, GLYPH.warn), span(t.gold, ' width is pinned — resizes are ignored until /terminal auto')]);
715
715
  lines.push([span('', '')]);
716
716
  }
717
- lines.push([span(t.gray, 'Override: /terminal ascii | unicode | color | no-color | star <native|narrow>')]);
717
+ lines.push([span(t.gray, 'Override: /terminal ascii | unicode | color | no-color | background <dark|light> | star <native|narrow>')]);
718
718
  lines.push([span(t.gray, ' /terminal width <cols> | auto | status')]);
719
719
  lines.push([span(t.gray, 'At launch: --ascii --unicode --no-color --width <cols> --terminal')]);
720
720
  return lines;