aegisone 1.0.5 → 1.0.8

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.
Files changed (45) hide show
  1. package/README.md +2 -2
  2. package/bin/aegis.js +28 -3
  3. package/package.json +1 -1
  4. package/scripts/predist.mjs +230 -0
  5. package/src/permissions.js +134 -7
  6. package/src/release.js +14 -5
  7. package/vendor/cli/README.md +42 -3
  8. package/vendor/cli/bin/aegiscode.js +15 -3
  9. package/vendor/cli/package.json +1 -1
  10. package/vendor/cli/src/app.js +167 -37
  11. package/vendor/cli/src/chatflow.js +285 -39
  12. package/vendor/cli/src/commands.js +251 -30
  13. package/vendor/cli/src/config.js +41 -11
  14. package/vendor/cli/src/engine.js +33 -4
  15. package/vendor/cli/src/entitlement.js +30 -1
  16. package/vendor/cli/src/format.js +175 -3
  17. package/vendor/cli/src/overlays.js +13 -9
  18. package/vendor/cli/src/panels.js +19 -6
  19. package/vendor/cli/src/render.js +49 -14
  20. package/vendor/cli/src/screen.js +12 -1
  21. package/vendor/cli/src/screens.js +118 -25
  22. package/vendor/cli/src/todos.js +7 -4
  23. package/vendor/cli/src/tokens.js +31 -1
  24. package/vendor/cli/vendor/client/aegis.js +22 -0
  25. package/vendor/cli/vendor/client/byok-catalog.js +43 -8
  26. package/vendor/cli/vendor/client/user-models.js +378 -0
  27. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +81 -0
  28. package/vendor/cli/vendor/desktop/lib/local/engine.js +447 -14
  29. package/vendor/cli/vendor/desktop/renderer/usage.js +274 -21
  30. package/vendor/cli/vendor/mcp/tools.js +1 -1
  31. package/vendor/desktop/README.md +11 -0
  32. package/vendor/desktop/lib/deep-link.js +35 -1
  33. package/vendor/desktop/lib/local/autonomous.js +81 -0
  34. package/vendor/desktop/lib/local/engine.js +447 -14
  35. package/vendor/desktop/main.js +271 -6
  36. package/vendor/desktop/package.json +1 -1
  37. package/vendor/desktop/preload.js +18 -0
  38. package/vendor/desktop/renderer/app.js +631 -43
  39. package/vendor/desktop/renderer/index.html +4 -5
  40. package/vendor/desktop/renderer/stream-policy.js +24 -2
  41. package/vendor/desktop/renderer/style.css +81 -7
  42. package/vendor/desktop/renderer/usage.js +274 -21
  43. package/vendor/desktop/vendor/aegis.js +22 -0
  44. package/vendor/desktop/vendor/byok-catalog.js +43 -8
  45. package/vendor/desktop/vendor/user-models.js +378 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AEGISONE
2
2
 
3
- Product version: **1.0.5**
3
+ Product version: **1.0.8**
4
4
 
5
5
  One product, two faces: the terminal (`aegiscode`) and the window (`aegis-desktop`),
6
6
  reached through one command — `aegis` — and released as one version.
@@ -60,7 +60,7 @@ fails, and it never leaves you with "nothing happened". Afterwards: `aegis`
60
60
 
61
61
  ## Size, measured not claimed
62
62
 
63
- Measured size: **2.00 MB** (2,101,414 bytes) with Electron absent — both faces inside.
63
+ Measured size: **2.08 MB** (2,178,611 bytes) with Electron absent — both faces inside.
64
64
 
65
65
  The plan's "~2 MB" was a target, so it is measured here rather than published:
66
66
  `npm pack one/` on this tree, with Electron absent, produces that tarball, and it
package/bin/aegis.js CHANGED
@@ -164,8 +164,23 @@ function run(argv, deps) {
164
164
  const skipFlagAt = (input.argv || []).indexOf(perms.SKIP_FLAG || '--dangerously-skip-permissions');
165
165
  const ttyInteractive = Boolean(input.tty && input.tty.stdin && input.tty.stdout);
166
166
  const childKind = ttyInteractive ? 'interactive' : 'headless';
167
+ // The store's answer, read through the faces' OWN module (cli/src/config.js
168
+ // `confirmPosture()`, resolved by layout exactly like the evaluator), never by
169
+ // cracking `preferences.json` open here: that key has one reader per face and
170
+ // a third would be the split brain ON8 removed. `d.stored` is injectable for
171
+ // tests; a store that cannot be read answers `undefined`, which leaves the
172
+ // gate exactly as it was.
173
+ const stored = d.stored || perms.storedPermissionFacts(d.storedOpts || {});
167
174
  const posture = perms.resolvePosture({
168
- rules: d.rules,
175
+ // `d.rules` still wins when a caller set it (tests, embedding); otherwise
176
+ // the rule set the user actually wrote. It was never filled in before, so
177
+ // rule 4's `--allowedTools`/`--disallowedTools` — "the child's policy
178
+ // tracks ours" — were built from an empty set.
179
+ rules: d.rules !== undefined ? d.rules : stored.rules,
180
+ // The stored posture: a user who already ran `/automode` (or flipped the
181
+ // window's switch) is NOT asked again one process down. This is the half
182
+ // that was missing — the flag resolved here, the setting did not.
183
+ gate: d.gate !== undefined ? d.gate : stored.confirmationsOn,
169
184
  flag: skipFlagAt !== -1,
170
185
  env: input.env,
171
186
  interactive: ttyInteractive,
@@ -173,12 +188,22 @@ function run(argv, deps) {
173
188
  });
174
189
 
175
190
  if (posture.warning) write(stderr, `aegis: ${posture.warning}`);
176
- if (posture.skip) write(stderr, perms.skipReport(posture));
191
+ // Rule 3's report is for a FLAG typed for one run. A stored posture is a
192
+ // setting the user can see and undo in both faces' own UI, so it is not
193
+ // announced on every launch (see resolvePosture's `skipFromFlag`).
194
+ if (posture.skip && posture.skipFromFlag) write(stderr, perms.skipReport(posture));
177
195
 
178
196
  const faceArgs = skipFlagAt === -1
179
197
  ? decision.args
180
198
  : decision.args.filter((a) => a !== (perms.SKIP_FLAG || '--dangerously-skip-permissions'));
181
- const postureEnv = posture.skip ? { AEGISONE_SKIP_PERMISSIONS: '1' } : {};
199
+ // Forwarded only for a skip that was ASKED for (the flag, or the product's own
200
+ // env spelling). Deliberately NOT for the stored posture: `AEGISONE_SKIP_
201
+ // PERMISSIONS` short-circuits the face's own read on every tool round, so
202
+ // forwarding a setting through it would freeze a live, toggleable posture for
203
+ // the whole process — `/automode on` inside the session could then never
204
+ // restore confirmations. The face reads the same store the window writes and
205
+ // gets the same answer on its own; the child's argv is what needed the fix.
206
+ const postureEnv = posture.skipFromFlag ? { AEGISONE_SKIP_PERMISSIONS: '1' } : {};
182
207
 
183
208
  if ((input.env || {}).AEGISONE_PRINT_DECISION === '1') { write(
184
209
  stderr,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegisone",
3
3
  "productName": "AEGISONE",
4
- "version": "1.0.5",
4
+ "version": "1.0.8",
5
5
  "description": "AEGISONE — one product, two faces. `aegis` opens the window when there is nothing else to do and runs the terminal otherwise; `aegiscode` keeps behaving exactly as it always has.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",
@@ -123,6 +123,8 @@ export const MANIFEST = [
123
123
  note: 'the pooled-brain rule, required at load time by the engine and src/models.js' },
124
124
  { src: 'client/byok-catalog.js', shapes: ['mirror', 'flat'],
125
125
  note: 'the BYOK model additions the server catalog does not name' },
126
+ { src: 'client/user-models.js', shapes: ['mirror', 'flat'],
127
+ note: 'the models the USER declares, in one file both hosts read (requires ./credentials.js)' },
126
128
  { src: 'client/hooks.js', shapes: ['mirror', 'flat'],
127
129
  note: 'the shared hook layer behind /hooks and the repo guard installer' },
128
130
  { src: 'client/platform.js', shapes: ['mirror', 'flat'],
@@ -284,6 +286,219 @@ function copyTree(from, toDir) {
284
286
  else walk(from, '');
285
287
  }
286
288
 
289
+ // ---------------------------------------------------------------------------
290
+ // Mutual exclusion — one stager at a time per checkout
291
+ // ---------------------------------------------------------------------------
292
+ //
293
+ // Staging is destructive by construction: `stageFiles(entries, CLI_VENDOR)`
294
+ // removes `cli/vendor/` outright and re-copies every module into it, and the
295
+ // bundle step does the same to `one/vendor/<face>/`. Two stagers in the same
296
+ // checkout therefore cannot merely interleave harmlessly — the second one's
297
+ // `rmSync` unlinks the tree the first one is still reading, and the first one's
298
+ // per-file byte comparison (`readFileSync(from).equals(readFileSync(dest))`)
299
+ // then fails, or the second one's copy is read half-written.
300
+ //
301
+ // That is not hypothetical: `test/one-vendor.test.mjs` and
302
+ // `test/one-pack-boot.test.mjs` each shell out to this file, so running the
303
+ // suite with block-level concurrency puts two stagers in the same tree at once.
304
+ // Both pass alone and each can fail when overlapped, which reads as a flaky
305
+ // gate rather than as the data race it is. The lock below is what makes the
306
+ // gate honest under concurrency instead of pretending the race is a test bug.
307
+ //
308
+ // The lock file lives in this checkout's OWN git directory, and that location
309
+ // is load-bearing three ways over:
310
+ //
311
+ // * It cannot be the OS temp dir — resolving that is an OS answer, and `one/`'s
312
+ // seam rule (asserted by test/one-vendor.test.mjs) forbids this file from
313
+ // knowing the platform at all: that answer belongs to `client/platform.js`.
314
+ // * It cannot be `one/`, `cli/` or the repo root: an untracked lock file there
315
+ // is visible to `git status` and one `git add -A` from being committed.
316
+ // * It cannot be under any vendor tree, because `stageFiles(entries, CLI_VENDOR)`
317
+ // deletes those — the lock would be destroyed by the very thing it guards.
318
+ //
319
+ // `.git` is per-checkout (so the `aegiscode-plugin-verify-main` worktree locks
320
+ // independently, correctly), is never packed by `npm pack`, and is reachable
321
+ // from every stager for this tree. In a linked worktree `.git` is a FILE
322
+ // (`gitdir: …`) rather than a directory, so it is followed to its gitdir.
323
+ const LOCK_WAIT_MS = 120000; // how long to wait for a peer before giving up
324
+ const LOCK_STALE_MS = 600000; // a lock older than this is abandoned, not held
325
+ const LOCK_POLL_MS = 50;
326
+ /** The token a holder hands to its own descendants through the environment. */
327
+ const LOCK_ENV = 'AEGISONE_PREDIST_LOCK_TOKEN';
328
+
329
+ /** The lock file this process is inside, or null. */
330
+ let LOCK_HELD = null;
331
+ /** Only the process that CREATED the lock unlinks it. */
332
+ let LOCK_OWNS = false;
333
+ /** In-process nesting: a reader may hold the lock while stage() is called. */
334
+ let LOCK_DEPTH = 0;
335
+
336
+ function lockFile() {
337
+ const dotGit = path.join(REPO_DIR, '.git');
338
+ let dir = dotGit;
339
+ try {
340
+ if (!fs.lstatSync(dotGit).isDirectory()) {
341
+ const m = /^gitdir:\s*(.+)$/m.exec(fs.readFileSync(dotGit, 'utf8'));
342
+ if (m) dir = path.resolve(REPO_DIR, m[1].trim());
343
+ }
344
+ } catch {
345
+ dir = dotGit; // no `.git` at all (an exported tree): the open below reports it
346
+ }
347
+ return path.join(dir, 'aegisone-predist.lock');
348
+ }
349
+
350
+ /** Is `pid` a live process? Signal 0 tests existence without signalling. */
351
+ function pidAlive(pid) {
352
+ try {
353
+ process.kill(pid, 0);
354
+ return true;
355
+ } catch (error) {
356
+ // EPERM means it exists and belongs to someone else — still alive.
357
+ return Boolean(error) && error.code === 'EPERM';
358
+ }
359
+ }
360
+
361
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
362
+
363
+ /**
364
+ * Take the staging lock, or adopt the one an ANCESTOR already holds.
365
+ *
366
+ * Waiting is the right failure mode against a peer, and failing fast would not
367
+ * be: the peer is about to produce exactly the tree this run wants, so the two
368
+ * are not so much competing for a resource as queueing for it. A stale lock is
369
+ * broken (dead pid, or older than LOCK_STALE_MS) so a killed stager cannot wedge
370
+ * every later run — the alternative, a lock no one can clear, trades a rare
371
+ * flake for a permanent one.
372
+ *
373
+ * ADOPTION is what makes the lock usable by a *reader*. `test/one-vendor.test.mjs`
374
+ * asserts on the staged trees, and it also spawns both wrapper scripts with
375
+ * `spawnSync` — which BLOCKS its own process. If those children had to queue for
376
+ * a lock their parent is holding, the parent would block waiting for a child
377
+ * that is waiting for the parent: a guaranteed 120-second deadlock, in the gate
378
+ * that is supposed to prove staging works. So the holder writes a random token
379
+ * into the lock file and exports it; a descendant that sees its OWN token in the
380
+ * file is the same logical stager, runs immediately, and leaves the unlinking to
381
+ * the process that created it.
382
+ */
383
+ async function takeLock(log) {
384
+ const file = lockFile();
385
+ const deadline = Date.now() + LOCK_WAIT_MS;
386
+ const inherited = process.env[LOCK_ENV] || null;
387
+ let token = null;
388
+ let announced = false;
389
+ for (;;) {
390
+ // Adopt before waiting: the lock is held by our own ancestor.
391
+ if (inherited) {
392
+ try {
393
+ const tokenLine = String(fs.readFileSync(file, 'utf8')).split('\n')[1];
394
+ // The token match IS the test: it is a random value that only ever
395
+ // existed inside this process tree, so a foreign holder's file cannot
396
+ // match it and we will queue for that one like anybody else.
397
+ if (tokenLine && tokenLine.trim() === inherited) {
398
+ LOCK_HELD = file;
399
+ LOCK_OWNS = false;
400
+ return;
401
+ }
402
+ } catch {
403
+ /* no lock file: fall through and take it normally */
404
+ }
405
+ }
406
+ try {
407
+ token = `${Date.now().toString(36)}-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
408
+ const fd = fs.openSync(file, 'wx'); // atomic create-or-fail
409
+ fs.writeSync(fd, `${process.pid}\n${token}\n`);
410
+ fs.closeSync(fd);
411
+ LOCK_HELD = file;
412
+ LOCK_OWNS = true;
413
+ // Handed to every descendant for the duration, so a stager this process
414
+ // spawns (the two wrappers the suite runs) does not deadlock against us.
415
+ process.env[LOCK_ENV] = token;
416
+ return;
417
+ } catch (error) {
418
+ if (!error || error.code !== 'EEXIST') throw error;
419
+ }
420
+ // Somebody holds it. Decide whether they are still alive.
421
+ let stat = null;
422
+ let holder = 0;
423
+ try {
424
+ stat = fs.statSync(file);
425
+ holder = Number(String(fs.readFileSync(file, 'utf8')).split('\n')[0].trim());
426
+ } catch {
427
+ continue; // released between the open and the stat — retry immediately
428
+ }
429
+ const abandoned =
430
+ Date.now() - stat.mtimeMs > LOCK_STALE_MS ||
431
+ (Number.isFinite(holder) && holder > 0 && !pidAlive(holder));
432
+ if (abandoned) {
433
+ log(`predist: breaking an abandoned staging lock (pid ${holder || 'unknown'})`);
434
+ try {
435
+ fs.unlinkSync(file);
436
+ } catch {
437
+ /* the holder released it first — the next open will succeed */
438
+ }
439
+ continue;
440
+ }
441
+ if (Date.now() > deadline) {
442
+ throw new Error(
443
+ `predist: another stager (pid ${holder || 'unknown'}) has held ${file} for over ` +
444
+ `${Math.round(LOCK_WAIT_MS / 1000)}s. Staging is destructive — it removes and ` +
445
+ 'rewrites cli/vendor, desktop/vendor and one/vendor — so it will not run ' +
446
+ 'concurrently with a peer. Wait for it, or delete the lock if that process is gone.'
447
+ );
448
+ }
449
+ if (!announced) {
450
+ announced = true;
451
+ log(
452
+ `predist: another stager (pid ${holder || 'unknown'}) is running — waiting for it ` +
453
+ '(concurrent staging would read a vendor tree the peer is rewriting)'
454
+ );
455
+ }
456
+ await sleep(LOCK_POLL_MS + Math.floor(Math.random() * LOCK_POLL_MS));
457
+ }
458
+ }
459
+
460
+ function releaseLock() {
461
+ if (LOCK_DEPTH > 0) {
462
+ LOCK_DEPTH--;
463
+ return;
464
+ }
465
+ const file = LOCK_HELD;
466
+ const owns = LOCK_OWNS;
467
+ const token = process.env[LOCK_ENV];
468
+ LOCK_HELD = null;
469
+ LOCK_OWNS = false;
470
+ if (!file || !owns) return; // an adopted lock is released by its creator
471
+ if (token) delete process.env[LOCK_ENV];
472
+ try {
473
+ fs.unlinkSync(file);
474
+ } catch {
475
+ /* already gone, or broken as stale by a peer — either way we no longer hold it */
476
+ }
477
+ }
478
+
479
+ /**
480
+ * Hold the staging lock across an arbitrary span — staging AND the reads that
481
+ * check what was staged — releasing when the returned function is called.
482
+ *
483
+ * Exported because a reader is a legitimate participant: whoever asserts on
484
+ * `cli/vendor/` while another process may be re-staging it has the same race as
485
+ * two stagers do, and `stage()`'s own critical section ends too early to cover
486
+ * the assertions that follow it. Re-entrant in-process (a holder may call
487
+ * `stage()`), and adopted by descendants through LOCK_ENV — see `takeLock`.
488
+ *
489
+ * @param {{stdout?: object}} [io] where the "waiting for a peer" line is written
490
+ * @returns {Promise<() => void>} the release function
491
+ */
492
+ export async function acquireStageLock(io) {
493
+ if (LOCK_HELD) {
494
+ LOCK_DEPTH++;
495
+ return releaseLock;
496
+ }
497
+ const out = (io && io.stdout) || process.stdout;
498
+ await takeLock((line) => out.write(`${line}\n`));
499
+ return releaseLock;
500
+ }
501
+
287
502
  // ---------------------------------------------------------------------------
288
503
  // Staging primitives
289
504
  // ---------------------------------------------------------------------------
@@ -545,6 +760,21 @@ export async function stage(opts) {
545
760
  const want = (s) => shapes.includes(s);
546
761
  const log = (line) => out.write(`${line}\n`);
547
762
 
763
+ // The whole body is one critical section: every shape below removes and
764
+ // rewrites a shared tree, and the proofs read those trees back. Held from
765
+ // here to the end, released even when a proof throws — a thrown proof that
766
+ // kept the lock would wedge every later run in this checkout. A caller that
767
+ // already holds it (a test asserting on the staged trees) keeps holding it:
768
+ // `acquireStageLock` nests in-process.
769
+ const release = await acquireStageLock(io);
770
+ try {
771
+ return await stageLocked({ want, log });
772
+ } finally {
773
+ release();
774
+ }
775
+ }
776
+
777
+ async function stageLocked({ want, log }) {
548
778
  const report = { mirror: null, flat: null, nested: null, bundle: null };
549
779
 
550
780
  if (want('mirror')) {
@@ -85,6 +85,7 @@ const PERMISSION_MODES = Object.freeze([
85
85
  ]);
86
86
 
87
87
  let cachedEvaluator = null;
88
+ let cachedConfig = null;
88
89
 
89
90
  /**
90
91
  * The ONE rule engine, resolved in both layouts:
@@ -118,6 +119,80 @@ function loadEvaluator(injected) {
118
119
  );
119
120
  }
120
121
 
122
+ /**
123
+ * The faces' OWN posture module, resolved in both layouts, exactly as the
124
+ * evaluator above is:
125
+ *
126
+ * 1. `one/src/…` in a checkout → `../../cli/src/config.js`
127
+ * 2. `one/vendor/cli/src/…` in the published product → `../vendor/cli/src/…`
128
+ *
129
+ * This is deliberately the CLI's module and not a new reader. `confirmPosture()`
130
+ * in there is the ONE read of the shared `confirmMode` key both faces write —
131
+ * the desktop's *Confirm before running tools* switch and the shell's
132
+ * `/automode` (alias `/yolo`) — and reading the store here a second way would
133
+ * be the split brain ON8 removed. NotFound is `null`, never a throw: a store
134
+ * that cannot be read must leave the gate UP, not blow up a launch.
135
+ *
136
+ * @returns {object|null}
137
+ */
138
+ function loadConfigStore(injected) {
139
+ if (injected) return injected;
140
+ if (cachedConfig) return cachedConfig;
141
+ const candidates = [
142
+ path.join(__dirname, '..', '..', 'cli', 'src', 'config.js'),
143
+ path.join(__dirname, '..', 'vendor', 'cli', 'src', 'config.js'),
144
+ ];
145
+ for (const candidate of candidates) {
146
+ try {
147
+ const mod = require(candidate);
148
+ if (mod && typeof mod.confirmPosture === 'function') {
149
+ cachedConfig = mod;
150
+ return mod;
151
+ }
152
+ } catch {
153
+ /* try the next layout */
154
+ }
155
+ }
156
+ return null;
157
+ }
158
+
159
+ /**
160
+ * What the SHARED stores say — the same two facts `one/bin/aegis.js` used to
161
+ * pass as `undefined`.
162
+ *
163
+ * `confirmationsOn` is `confirmPosture().enabled`, i.e. the store's own answer
164
+ * with its polarity already resolved (true = the gate is UP, the user is asked
165
+ * before mutating tools). `rules` is the CLI's rule set verbatim, which is what
166
+ * rule 4's `--allowedTools`/`--disallowedTools` were always meant to be built
167
+ * from — the seam shipped with `rules: d.rules`, and nothing ever set `d.rules`
168
+ * in production, so the child was handed our rules by nobody.
169
+ *
170
+ * An unreadable store answers `undefined` for both, never a guess: "no stored
171
+ * posture" must mean "exactly as before", not "confirmations off".
172
+ *
173
+ * @returns {{confirmationsOn: boolean|undefined, rules: object|undefined, source: string}}
174
+ */
175
+ function storedPermissionFacts(opts = {}) {
176
+ const config = loadConfigStore(opts.config);
177
+ if (!config) return { confirmationsOn: undefined, rules: undefined, source: 'unavailable' };
178
+ try {
179
+ const gate = config.confirmPosture();
180
+ let rules;
181
+ try {
182
+ rules = config.loadPermissions();
183
+ } catch {
184
+ rules = undefined;
185
+ }
186
+ return {
187
+ confirmationsOn: gate && typeof gate.enabled === 'boolean' ? gate.enabled : undefined,
188
+ rules,
189
+ source: (gate && gate.source) || 'unavailable',
190
+ };
191
+ } catch {
192
+ return { confirmationsOn: undefined, rules: undefined, source: 'unavailable' };
193
+ }
194
+ }
195
+
121
196
  /** The CLI's rule shape, verbatim (D8 rule 1: not a new schema). */
122
197
  function normalizeRules(rules) {
123
198
  const r = rules && typeof rules === 'object' ? rules : {};
@@ -142,6 +217,13 @@ function normalizeRules(rules) {
142
217
  * @param {object} [input.env] environment (read, never mutated)
143
218
  * @param {boolean} [input.interactive] both stdio ends are a terminal
144
219
  * @param {string} [input.childKind] 'headless' | 'interactive'
220
+ * @param {boolean} [input.gate] the STORE's confirmation posture:
221
+ * `false` means the user already turned
222
+ * the gates off (`/automode`, or the
223
+ * desktop switch). Resolved by the caller
224
+ * (`storedPermissionFacts()`), never read
225
+ * from `process.*` here — the standing
226
+ * seam rule for `one/`.
145
227
  * @param {object} [opts]
146
228
  * @param {object} [opts.evaluator] injectable, for tests only
147
229
  * @returns frozen decision record
@@ -152,6 +234,29 @@ function resolvePosture(input = {}, opts = {}) {
152
234
  const interactive = input.interactive === true;
153
235
  const childKind = input.childKind === CHILD_KINDS.INTERACTIVE ? CHILD_KINDS.INTERACTIVE : CHILD_KINDS.HEADLESS;
154
236
  const skip = evaluator.resolveSkip({ flag: input.flag === true, env: input.env, interactive });
237
+ // ── the second, already-resolved answer ──────────────────────────────────
238
+ //
239
+ // `--dangerously-skip-permissions` is not the only way this product can be
240
+ // running with the gates down. Since ON8 there is a stored posture, written
241
+ // by `/automode` (alias `/yolo`), by `/confirm`, by `/multiyolo` and by the
242
+ // desktop's switch, that the faces read on every tool round. This resolver
243
+ // read the flag and the environment and nothing else, so a session whose user
244
+ // had already said "stop asking" handed the Claude child NO permission flag:
245
+ // headless, the child then asked a question nobody could answer — the hang
246
+ // rule 4 exists to prevent — while the terminal face beside it ran ungated.
247
+ // Two faces, one posture, one of them still asking is precisely the drift D8
248
+ // names, so the stored answer is folded in HERE, at the one place that
249
+ // produces the record, and never re-derived downstream.
250
+ //
251
+ // It cannot reach either floor. `skip` only ever downgrades an `'ask'`
252
+ // verdict in `gateFor()`, an explicit `deny` still wins, and the covenant's
253
+ // `preActionAssert` plus the avatar's `LEVEL_INDEPENDENT_APPROVALS`
254
+ // (`write`/`shell`/`network`/`offDevice`) are the same frozen four as before:
255
+ // the store is the *configurable* half of rule 2 by definition — it is what
256
+ // the confirmation gate itself reads — so honoring it here widens nothing.
257
+ const storedOff = input.gate === false;
258
+ const effectiveSkip = skip.skip || storedOff;
259
+ const skipSource = skip.skip ? skip.source : storedOff ? 'posture' : skip.source;
155
260
 
156
261
  const isInteractiveChild = childKind === CHILD_KINDS.INTERACTIVE;
157
262
  return Object.freeze({
@@ -160,25 +265,37 @@ function resolvePosture(input = {}, opts = {}) {
160
265
  interactive,
161
266
  childKind,
162
267
  // Rule 5 already applied: `skip` is the product's answer, not the raw env.
163
- skip: skip.skip,
164
- skipSource: skip.source,
268
+ skip: effectiveSkip,
269
+ skipSource,
270
+ // Which of the two produced it. The run-log line and the rule-3 report are
271
+ // silent for a stored posture on purpose: the report exists because "a flag
272
+ // whose blast radius is invisible is how a footgun ships", and a flag typed
273
+ // for one run is that. A posture is a setting the user can see in both
274
+ // faces' own UI and turn back, and printing a skip banner on every launch
275
+ // of a deliberately-ungated install is noise that teaches scrolling — but
276
+ // the child's argv is still recorded by `childRecordLine`, so the decision
277
+ // remains accountable.
278
+ skipFromFlag: skip.skip,
165
279
  envVarSet: skip.envSet,
280
+ // The store's answer, recorded rather than inferred (three states: true,
281
+ // false, and `null` for "there was no stored posture to read").
282
+ storedGate: input.gate === undefined || input.gate === null ? null : Boolean(input.gate),
166
283
  warned: skip.warned,
167
284
  warning: skip.warning || null,
168
285
  // What a skip covers, and what it cannot touch. Both are frozen lists so a
169
286
  // caller cannot widen either one in place.
170
- skipped: Object.freeze(skip.skip ? CONFIGURABLE_CLASSES : []),
287
+ skipped: Object.freeze(effectiveSkip ? CONFIGURABLE_CLASSES : []),
171
288
  frozen: FROZEN_CLASSES,
172
289
  // The child's variant, derived here so no spawn site re-derives it (rule 4).
173
290
  child: Object.freeze({
174
291
  kind: childKind,
175
- skip: skip.skip,
176
- flag: !skip.skip
292
+ skip: effectiveSkip,
293
+ flag: !effectiveSkip
177
294
  ? null
178
295
  : isInteractiveChild
179
296
  ? '--allow-dangerously-skip-permissions'
180
297
  : '--dangerously-skip-permissions',
181
- why: !skip.skip
298
+ why: !effectiveSkip
182
299
  ? 'no skip was asked for, so no permission flag is passed to the child'
183
300
  : isInteractiveChild
184
301
  ? 'the interactive variant offers the bypass as an option (the child still asks; a human is there)'
@@ -217,8 +334,16 @@ function skipReport(posture) {
217
334
  const childClause = posture.child.flag
218
335
  ? `; the ${posture.child.kind} Claude child is passed ${posture.child.flag}`
219
336
  : '';
337
+ // Named by its actual source, never as a flag the user did not type: a stored
338
+ // posture (`/automode`, the desktop switch) is reported for what it is, since
339
+ // printing `--dangerously-skip-permissions` for a setting would be the same
340
+ // kind of small lie as eating the flag.
341
+ const what =
342
+ posture.skipSource === 'posture'
343
+ ? 'automode (the stored confirmation posture both faces share)'
344
+ : '--dangerously-skip-permissions';
220
345
  return (
221
- `aegis: --dangerously-skip-permissions (via ${posture.skipSource}) — skipping the configurable ` +
346
+ `aegis: ${what} (via ${posture.skipSource}) — skipping the configurable ` +
222
347
  `confirmation gates (${CONFIGURABLE_CLASSES.join(', ')})${childClause}. NOT skipped, and not ` +
223
348
  `reachable by any setting, flag or env var: the ÆGIS covenant pre-action assert and the ` +
224
349
  `${FROZEN_CLASSES.join('|')} approvals (always 'ask'), plus any explicit deny rule.`
@@ -232,6 +357,8 @@ module.exports = {
232
357
  PERMISSION_MODES,
233
358
  SKIP_FLAG,
234
359
  loadEvaluator,
360
+ loadConfigStore,
361
+ storedPermissionFacts,
235
362
  normalizeRules,
236
363
  resolvePosture,
237
364
  gateFor,
package/src/release.js CHANGED
@@ -41,16 +41,25 @@
41
41
  *
42
42
  * `line` is the `major.minor` that must not move (D4 rule 1). `anchor` is the
43
43
  * patch each face had published at `ANCHOR_PRODUCT` — the calibration point for
44
- * the whole derivation, and the reason product `1.0.0` maps to the versions the
45
- * registry actually serves today instead of to `6.8.0`.
44
+ * the whole derivation.
45
+ *
46
+ * Re-anchored at product `1.0.8`: `aegiscode` graduates from the `6.8.x` line
47
+ * to `7.0.x` and `aegis-desktop` from `0.8.x` to `1.0.x`, both starting at
48
+ * patch 0 — a deliberate one-time line move, not a normal release. Nothing
49
+ * before this point is derivable under the new anchor (an older product
50
+ * version would compute a negative patch and `deriveFaceVersion` refuses it as
51
+ * "backwards"), which is correct: the old `6.8.x`/`0.8.x` history stays real,
52
+ * it is just not reachable through this formula anymore. A product version
53
+ * `>= 1.0.8` is unaffected either way, because the derivation only ever looks
54
+ * at the DELTA from the anchor, never at history before it.
46
55
  */
47
56
  const FACE_LINES = Object.freeze([
48
- Object.freeze({ dir: 'cli', package: 'aegiscode', line: Object.freeze([6, 8]), anchor: 30 }),
49
- Object.freeze({ dir: 'desktop', package: 'aegis-desktop', line: Object.freeze([0, 8]), anchor: 28 })
57
+ Object.freeze({ dir: 'cli', package: 'aegiscode', line: Object.freeze([7, 0]), anchor: 0 }),
58
+ Object.freeze({ dir: 'desktop', package: 'aegis-desktop', line: Object.freeze([1, 0]), anchor: 0 })
50
59
  ]);
51
60
 
52
61
  /** The product version the two anchors above were measured at. */
53
- const ANCHOR_PRODUCT = '1.0.0';
62
+ const ANCHOR_PRODUCT = '1.0.8';
54
63
 
55
64
  /** One product minor reserves 100 face patches; one major reserves 10000. */
56
65
  const MINOR_STRIDE = 100;
@@ -255,7 +255,7 @@ command for command — 87 entries across nine categories:
255
255
  |---|---|
256
256
  | Session & context | `/schedule` `/clear` `/compact` `/context` `/todos` `/config` `/exit` `/recap` `/resume` `/rewind` `/agents` `/status` `/teleport` `/version` `/new` `/skills` `/multiyolo` `/multi` `/research` `/debate` |
257
257
  | Workspace | `/run` `/build` `/cd` `/init` `/clone` |
258
- | Model & behavior | `/ping` `/effort` `/model` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/yolo` `/router` `/class` `/models` |
258
+ | Model & behavior | `/ping` `/effort` `/model` `/models` `/model-add` `/model-rm` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class` |
259
259
  | Data | `/copy` `/cost` `/export` `/tokens` `/sync` |
260
260
  | Auth | `/login` `/logout` `/key` `/byok` `/byok-set` `/byok-rm` `/byok-key` `/byok-rm-key` |
261
261
  | Support | `/help` `/doctor` `/upgrade` `/troubleshooting` `/feedback` `/bug` `/issue` `/onboarding` `/shell-completion` `/terminal-setup` `/pr-comments` `/prs` `/review` `/benchmark` `/billing` `/topup` `/cloud` `/gmail` `/release-notes` |
@@ -338,6 +338,44 @@ Selecting it switches the class to `aegis` first (this is the one row that is
338
338
  not a `provider:model` id); pinning it *without* switching is not offered,
339
339
  because the relay would read `nexus-brain` as a provider name.
340
340
 
341
+ **3. Adding a model nobody has released yet.**
342
+
343
+ Vendors ship models faster than any client can be updated, and the BYOK relay is
344
+ a pass-through: your own vendor key authenticates upstream and AEGIS forwards the
345
+ model string it is handed. So an id your provider serves is callable the moment
346
+ your machine offers it as a row — which is what these do:
347
+
348
+ ```bash
349
+ /model-add deepseek deepseek-v4.2-preview # offer it on this machine
350
+ /model-rm deepseek deepseek-v4.2-preview # forget it
351
+ /model-add deepseek # prompt for the id instead
352
+ ```
353
+
354
+ `/model-add` resolves the provider against the relay's catalogue first, so a
355
+ provider the relay takes no key for is **refused** rather than stored — a
356
+ declaration for a slug the relay does not accept would appear in no picker at
357
+ all, and the failure would land on your first turn. The id itself is shape
358
+ checked (no spaces, no colon — `provider:model` is the id a pin uses) but never
359
+ checked against a vendor list: reaching a model the catalogue has not caught up
360
+ with is the entire point.
361
+
362
+ The declaration lives in **`~/.aegiscode/models.json`** (`$AEGISCODE_HOME` if you
363
+ set it), which is also the file the desktop's Settings pane writes and reads. Add
364
+ a model in the terminal and it is in the window's picker on its next refresh,
365
+ with no restart; add one in the window and `/models` shows it immediately. The
366
+ file is plain JSON and 0600, so a bulk edit is an editor away:
367
+
368
+ ```json
369
+ {
370
+ "deepseek": ["deepseek-v4.2-preview"],
371
+ "anthropic": ["claude-opus-9-1"]
372
+ }
373
+ ```
374
+
375
+ Nothing here is validated against a vendor on read, so a hand-typed row that the
376
+ vendor does not serve will 404 on your first turn — that is the one cost of the
377
+ escape hatch, and it is why the commands validate what they store.
378
+
341
379
  ```bash
342
380
  aegiscode -m nexus-brain -p "…" # pin at launch
343
381
  aegiscode -m anthropic:claude-sonnet-4-5 -p "…" # a BYOK id at launch
@@ -637,8 +675,9 @@ What the loop does, in the order a turn happens:
637
675
  text is still what gets submitted).
638
676
  - **The turn starts.** A random verb from the reference set shimmers in coral
639
677
  beside the spinner, with elapsed time and a live token estimate.
640
- - **The answer streams into a row**, markdown-rendered, opening with `●` and
641
- trailing a live cursor while it grows.
678
+ - **The answer streams into a row**, markdown-rendered, opening with `●` — one
679
+ marker, whatever the answer's length, so the glyph does not multiply when the
680
+ text wraps.
642
681
  - **Tool calls become rows.** `● Running 1 shell command… · 3s` resolves to
643
682
  `Ran 1 shell command` when the call returns — paired by tool-call id, so
644
683
  parallel same-name calls and nested subagent rows stay separate, and the