aegisone 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/aegis.js +28 -3
- package/package.json +1 -1
- package/scripts/predist.mjs +228 -0
- package/src/permissions.js +134 -7
- package/vendor/cli/README.md +4 -3
- package/vendor/cli/bin/aegiscode.js +15 -3
- package/vendor/cli/package.json +1 -1
- package/vendor/cli/src/app.js +93 -36
- package/vendor/cli/src/chatflow.js +145 -39
- package/vendor/cli/src/commands.js +79 -29
- package/vendor/cli/src/config.js +41 -11
- package/vendor/cli/src/engine.js +29 -2
- package/vendor/cli/src/entitlement.js +30 -1
- package/vendor/cli/src/format.js +175 -3
- package/vendor/cli/src/overlays.js +13 -9
- package/vendor/cli/src/panels.js +19 -6
- package/vendor/cli/src/render.js +49 -14
- package/vendor/cli/src/screen.js +12 -1
- package/vendor/cli/src/todos.js +7 -4
- package/vendor/cli/src/tokens.js +31 -1
- package/vendor/cli/vendor/desktop/renderer/usage.js +206 -20
- package/vendor/cli/vendor/mcp/tools.js +1 -1
- package/vendor/desktop/main.js +12 -0
- package/vendor/desktop/package.json +1 -1
- package/vendor/desktop/renderer/app.js +236 -31
- package/vendor/desktop/renderer/index.html +2 -3
- package/vendor/desktop/renderer/stream-policy.js +24 -2
- package/vendor/desktop/renderer/style.css +49 -7
- package/vendor/desktop/renderer/usage.js +206 -20
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AEGISONE
|
|
2
2
|
|
|
3
|
-
Product version: **1.0.
|
|
3
|
+
Product version: **1.0.6**
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
+
"version": "1.0.6",
|
|
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",
|
package/scripts/predist.mjs
CHANGED
|
@@ -284,6 +284,219 @@ function copyTree(from, toDir) {
|
|
|
284
284
|
else walk(from, '');
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
// ---------------------------------------------------------------------------
|
|
288
|
+
// Mutual exclusion — one stager at a time per checkout
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
//
|
|
291
|
+
// Staging is destructive by construction: `stageFiles(entries, CLI_VENDOR)`
|
|
292
|
+
// removes `cli/vendor/` outright and re-copies every module into it, and the
|
|
293
|
+
// bundle step does the same to `one/vendor/<face>/`. Two stagers in the same
|
|
294
|
+
// checkout therefore cannot merely interleave harmlessly — the second one's
|
|
295
|
+
// `rmSync` unlinks the tree the first one is still reading, and the first one's
|
|
296
|
+
// per-file byte comparison (`readFileSync(from).equals(readFileSync(dest))`)
|
|
297
|
+
// then fails, or the second one's copy is read half-written.
|
|
298
|
+
//
|
|
299
|
+
// That is not hypothetical: `test/one-vendor.test.mjs` and
|
|
300
|
+
// `test/one-pack-boot.test.mjs` each shell out to this file, so running the
|
|
301
|
+
// suite with block-level concurrency puts two stagers in the same tree at once.
|
|
302
|
+
// Both pass alone and each can fail when overlapped, which reads as a flaky
|
|
303
|
+
// gate rather than as the data race it is. The lock below is what makes the
|
|
304
|
+
// gate honest under concurrency instead of pretending the race is a test bug.
|
|
305
|
+
//
|
|
306
|
+
// The lock file lives in this checkout's OWN git directory, and that location
|
|
307
|
+
// is load-bearing three ways over:
|
|
308
|
+
//
|
|
309
|
+
// * It cannot be the OS temp dir — resolving that is an OS answer, and `one/`'s
|
|
310
|
+
// seam rule (asserted by test/one-vendor.test.mjs) forbids this file from
|
|
311
|
+
// knowing the platform at all: that answer belongs to `client/platform.js`.
|
|
312
|
+
// * It cannot be `one/`, `cli/` or the repo root: an untracked lock file there
|
|
313
|
+
// is visible to `git status` and one `git add -A` from being committed.
|
|
314
|
+
// * It cannot be under any vendor tree, because `stageFiles(entries, CLI_VENDOR)`
|
|
315
|
+
// deletes those — the lock would be destroyed by the very thing it guards.
|
|
316
|
+
//
|
|
317
|
+
// `.git` is per-checkout (so the `aegiscode-plugin-verify-main` worktree locks
|
|
318
|
+
// independently, correctly), is never packed by `npm pack`, and is reachable
|
|
319
|
+
// from every stager for this tree. In a linked worktree `.git` is a FILE
|
|
320
|
+
// (`gitdir: …`) rather than a directory, so it is followed to its gitdir.
|
|
321
|
+
const LOCK_WAIT_MS = 120000; // how long to wait for a peer before giving up
|
|
322
|
+
const LOCK_STALE_MS = 600000; // a lock older than this is abandoned, not held
|
|
323
|
+
const LOCK_POLL_MS = 50;
|
|
324
|
+
/** The token a holder hands to its own descendants through the environment. */
|
|
325
|
+
const LOCK_ENV = 'AEGISONE_PREDIST_LOCK_TOKEN';
|
|
326
|
+
|
|
327
|
+
/** The lock file this process is inside, or null. */
|
|
328
|
+
let LOCK_HELD = null;
|
|
329
|
+
/** Only the process that CREATED the lock unlinks it. */
|
|
330
|
+
let LOCK_OWNS = false;
|
|
331
|
+
/** In-process nesting: a reader may hold the lock while stage() is called. */
|
|
332
|
+
let LOCK_DEPTH = 0;
|
|
333
|
+
|
|
334
|
+
function lockFile() {
|
|
335
|
+
const dotGit = path.join(REPO_DIR, '.git');
|
|
336
|
+
let dir = dotGit;
|
|
337
|
+
try {
|
|
338
|
+
if (!fs.lstatSync(dotGit).isDirectory()) {
|
|
339
|
+
const m = /^gitdir:\s*(.+)$/m.exec(fs.readFileSync(dotGit, 'utf8'));
|
|
340
|
+
if (m) dir = path.resolve(REPO_DIR, m[1].trim());
|
|
341
|
+
}
|
|
342
|
+
} catch {
|
|
343
|
+
dir = dotGit; // no `.git` at all (an exported tree): the open below reports it
|
|
344
|
+
}
|
|
345
|
+
return path.join(dir, 'aegisone-predist.lock');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Is `pid` a live process? Signal 0 tests existence without signalling. */
|
|
349
|
+
function pidAlive(pid) {
|
|
350
|
+
try {
|
|
351
|
+
process.kill(pid, 0);
|
|
352
|
+
return true;
|
|
353
|
+
} catch (error) {
|
|
354
|
+
// EPERM means it exists and belongs to someone else — still alive.
|
|
355
|
+
return Boolean(error) && error.code === 'EPERM';
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Take the staging lock, or adopt the one an ANCESTOR already holds.
|
|
363
|
+
*
|
|
364
|
+
* Waiting is the right failure mode against a peer, and failing fast would not
|
|
365
|
+
* be: the peer is about to produce exactly the tree this run wants, so the two
|
|
366
|
+
* are not so much competing for a resource as queueing for it. A stale lock is
|
|
367
|
+
* broken (dead pid, or older than LOCK_STALE_MS) so a killed stager cannot wedge
|
|
368
|
+
* every later run — the alternative, a lock no one can clear, trades a rare
|
|
369
|
+
* flake for a permanent one.
|
|
370
|
+
*
|
|
371
|
+
* ADOPTION is what makes the lock usable by a *reader*. `test/one-vendor.test.mjs`
|
|
372
|
+
* asserts on the staged trees, and it also spawns both wrapper scripts with
|
|
373
|
+
* `spawnSync` — which BLOCKS its own process. If those children had to queue for
|
|
374
|
+
* a lock their parent is holding, the parent would block waiting for a child
|
|
375
|
+
* that is waiting for the parent: a guaranteed 120-second deadlock, in the gate
|
|
376
|
+
* that is supposed to prove staging works. So the holder writes a random token
|
|
377
|
+
* into the lock file and exports it; a descendant that sees its OWN token in the
|
|
378
|
+
* file is the same logical stager, runs immediately, and leaves the unlinking to
|
|
379
|
+
* the process that created it.
|
|
380
|
+
*/
|
|
381
|
+
async function takeLock(log) {
|
|
382
|
+
const file = lockFile();
|
|
383
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
384
|
+
const inherited = process.env[LOCK_ENV] || null;
|
|
385
|
+
let token = null;
|
|
386
|
+
let announced = false;
|
|
387
|
+
for (;;) {
|
|
388
|
+
// Adopt before waiting: the lock is held by our own ancestor.
|
|
389
|
+
if (inherited) {
|
|
390
|
+
try {
|
|
391
|
+
const tokenLine = String(fs.readFileSync(file, 'utf8')).split('\n')[1];
|
|
392
|
+
// The token match IS the test: it is a random value that only ever
|
|
393
|
+
// existed inside this process tree, so a foreign holder's file cannot
|
|
394
|
+
// match it and we will queue for that one like anybody else.
|
|
395
|
+
if (tokenLine && tokenLine.trim() === inherited) {
|
|
396
|
+
LOCK_HELD = file;
|
|
397
|
+
LOCK_OWNS = false;
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
} catch {
|
|
401
|
+
/* no lock file: fall through and take it normally */
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
token = `${Date.now().toString(36)}-${process.pid}-${Math.random().toString(36).slice(2, 10)}`;
|
|
406
|
+
const fd = fs.openSync(file, 'wx'); // atomic create-or-fail
|
|
407
|
+
fs.writeSync(fd, `${process.pid}\n${token}\n`);
|
|
408
|
+
fs.closeSync(fd);
|
|
409
|
+
LOCK_HELD = file;
|
|
410
|
+
LOCK_OWNS = true;
|
|
411
|
+
// Handed to every descendant for the duration, so a stager this process
|
|
412
|
+
// spawns (the two wrappers the suite runs) does not deadlock against us.
|
|
413
|
+
process.env[LOCK_ENV] = token;
|
|
414
|
+
return;
|
|
415
|
+
} catch (error) {
|
|
416
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
417
|
+
}
|
|
418
|
+
// Somebody holds it. Decide whether they are still alive.
|
|
419
|
+
let stat = null;
|
|
420
|
+
let holder = 0;
|
|
421
|
+
try {
|
|
422
|
+
stat = fs.statSync(file);
|
|
423
|
+
holder = Number(String(fs.readFileSync(file, 'utf8')).split('\n')[0].trim());
|
|
424
|
+
} catch {
|
|
425
|
+
continue; // released between the open and the stat — retry immediately
|
|
426
|
+
}
|
|
427
|
+
const abandoned =
|
|
428
|
+
Date.now() - stat.mtimeMs > LOCK_STALE_MS ||
|
|
429
|
+
(Number.isFinite(holder) && holder > 0 && !pidAlive(holder));
|
|
430
|
+
if (abandoned) {
|
|
431
|
+
log(`predist: breaking an abandoned staging lock (pid ${holder || 'unknown'})`);
|
|
432
|
+
try {
|
|
433
|
+
fs.unlinkSync(file);
|
|
434
|
+
} catch {
|
|
435
|
+
/* the holder released it first — the next open will succeed */
|
|
436
|
+
}
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (Date.now() > deadline) {
|
|
440
|
+
throw new Error(
|
|
441
|
+
`predist: another stager (pid ${holder || 'unknown'}) has held ${file} for over ` +
|
|
442
|
+
`${Math.round(LOCK_WAIT_MS / 1000)}s. Staging is destructive — it removes and ` +
|
|
443
|
+
'rewrites cli/vendor, desktop/vendor and one/vendor — so it will not run ' +
|
|
444
|
+
'concurrently with a peer. Wait for it, or delete the lock if that process is gone.'
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
if (!announced) {
|
|
448
|
+
announced = true;
|
|
449
|
+
log(
|
|
450
|
+
`predist: another stager (pid ${holder || 'unknown'}) is running — waiting for it ` +
|
|
451
|
+
'(concurrent staging would read a vendor tree the peer is rewriting)'
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
await sleep(LOCK_POLL_MS + Math.floor(Math.random() * LOCK_POLL_MS));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function releaseLock() {
|
|
459
|
+
if (LOCK_DEPTH > 0) {
|
|
460
|
+
LOCK_DEPTH--;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const file = LOCK_HELD;
|
|
464
|
+
const owns = LOCK_OWNS;
|
|
465
|
+
const token = process.env[LOCK_ENV];
|
|
466
|
+
LOCK_HELD = null;
|
|
467
|
+
LOCK_OWNS = false;
|
|
468
|
+
if (!file || !owns) return; // an adopted lock is released by its creator
|
|
469
|
+
if (token) delete process.env[LOCK_ENV];
|
|
470
|
+
try {
|
|
471
|
+
fs.unlinkSync(file);
|
|
472
|
+
} catch {
|
|
473
|
+
/* already gone, or broken as stale by a peer — either way we no longer hold it */
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Hold the staging lock across an arbitrary span — staging AND the reads that
|
|
479
|
+
* check what was staged — releasing when the returned function is called.
|
|
480
|
+
*
|
|
481
|
+
* Exported because a reader is a legitimate participant: whoever asserts on
|
|
482
|
+
* `cli/vendor/` while another process may be re-staging it has the same race as
|
|
483
|
+
* two stagers do, and `stage()`'s own critical section ends too early to cover
|
|
484
|
+
* the assertions that follow it. Re-entrant in-process (a holder may call
|
|
485
|
+
* `stage()`), and adopted by descendants through LOCK_ENV — see `takeLock`.
|
|
486
|
+
*
|
|
487
|
+
* @param {{stdout?: object}} [io] where the "waiting for a peer" line is written
|
|
488
|
+
* @returns {Promise<() => void>} the release function
|
|
489
|
+
*/
|
|
490
|
+
export async function acquireStageLock(io) {
|
|
491
|
+
if (LOCK_HELD) {
|
|
492
|
+
LOCK_DEPTH++;
|
|
493
|
+
return releaseLock;
|
|
494
|
+
}
|
|
495
|
+
const out = (io && io.stdout) || process.stdout;
|
|
496
|
+
await takeLock((line) => out.write(`${line}\n`));
|
|
497
|
+
return releaseLock;
|
|
498
|
+
}
|
|
499
|
+
|
|
287
500
|
// ---------------------------------------------------------------------------
|
|
288
501
|
// Staging primitives
|
|
289
502
|
// ---------------------------------------------------------------------------
|
|
@@ -545,6 +758,21 @@ export async function stage(opts) {
|
|
|
545
758
|
const want = (s) => shapes.includes(s);
|
|
546
759
|
const log = (line) => out.write(`${line}\n`);
|
|
547
760
|
|
|
761
|
+
// The whole body is one critical section: every shape below removes and
|
|
762
|
+
// rewrites a shared tree, and the proofs read those trees back. Held from
|
|
763
|
+
// here to the end, released even when a proof throws — a thrown proof that
|
|
764
|
+
// kept the lock would wedge every later run in this checkout. A caller that
|
|
765
|
+
// already holds it (a test asserting on the staged trees) keeps holding it:
|
|
766
|
+
// `acquireStageLock` nests in-process.
|
|
767
|
+
const release = await acquireStageLock(io);
|
|
768
|
+
try {
|
|
769
|
+
return await stageLocked({ want, log });
|
|
770
|
+
} finally {
|
|
771
|
+
release();
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
async function stageLocked({ want, log }) {
|
|
548
776
|
const report = { mirror: null, flat: null, nested: null, bundle: null };
|
|
549
777
|
|
|
550
778
|
if (want('mirror')) {
|
package/src/permissions.js
CHANGED
|
@@ -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:
|
|
164
|
-
skipSource
|
|
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(
|
|
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:
|
|
176
|
-
flag: !
|
|
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: !
|
|
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:
|
|
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/vendor/cli/README.md
CHANGED
|
@@ -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` `/theme` `/terminal` `/vim` `/permissions` `/hooks` `/credentials` `/install-github-app` `/thinking` `/mcp` `/memory` `/memory-deep` `/confirm` `/automode` *(alias `/yolo`)* `/router` `/class` `/models` |
|
|
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` |
|
|
@@ -637,8 +637,9 @@ What the loop does, in the order a turn happens:
|
|
|
637
637
|
text is still what gets submitted).
|
|
638
638
|
- **The turn starts.** A random verb from the reference set shimmers in coral
|
|
639
639
|
beside the spinner, with elapsed time and a live token estimate.
|
|
640
|
-
- **The answer streams into a row**, markdown-rendered, opening with `●`
|
|
641
|
-
|
|
640
|
+
- **The answer streams into a row**, markdown-rendered, opening with `●` — one
|
|
641
|
+
marker, whatever the answer's length, so the glyph does not multiply when the
|
|
642
|
+
text wraps.
|
|
642
643
|
- **Tool calls become rows.** `● Running 1 shell command… · 3s` resolves to
|
|
643
644
|
`Ran 1 shell command` when the call returns — paired by tool-call id, so
|
|
644
645
|
parallel same-name calls and nested subagent rows stay separate, and the
|
|
@@ -86,8 +86,9 @@ Options:
|
|
|
86
86
|
--max-tokens <n> output ceiling hint
|
|
87
87
|
--light light theme
|
|
88
88
|
--width <cols> force a render width (useful for piping/logs)
|
|
89
|
-
--
|
|
90
|
-
run without asking) — same as the in-session /
|
|
89
|
+
--automode skip tool-approval prompts (exec/writeFile/editFile
|
|
90
|
+
run without asking) — same as the in-session /automode
|
|
91
|
+
--yolo alias of --automode (the pre-rename spelling)
|
|
91
92
|
--ascii draw with the ASCII mark and glyph set (no Unicode).
|
|
92
93
|
Same as AEGIS_ART=ascii; /terminal ascii toggles it
|
|
93
94
|
mid-session.
|
|
@@ -248,6 +249,7 @@ function parseArgs(argv) {
|
|
|
248
249
|
case '--light':
|
|
249
250
|
opts.light = true;
|
|
250
251
|
break;
|
|
252
|
+
case '--automode':
|
|
251
253
|
case '--yolo':
|
|
252
254
|
opts.yolo = true;
|
|
253
255
|
break;
|
|
@@ -663,7 +665,17 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
663
665
|
maxTokens: opts.maxTokens,
|
|
664
666
|
width: opts.width ? () => opts.width : undefined,
|
|
665
667
|
interactive: !prompt && Boolean(process.stdin.isTTY),
|
|
666
|
-
|
|
668
|
+
// ONLY a flag states an answer here. This line used to read `!opts.yolo`,
|
|
669
|
+
// which is a boolean on every launch — and `app.js`'s gate returns a pinned
|
|
670
|
+
// `options.confirmMode` the moment it is not `undefined`, so that one `true`
|
|
671
|
+
// short-circuited the store read the whole ON8 posture is built on: an
|
|
672
|
+
// automode the user had turned on (`/automode`, the window's switch, both of
|
|
673
|
+
// which persist) was overruled by the absence of a launch flag, and the CLI
|
|
674
|
+
// kept asking for exactly as long as the process lived. `undefined` hands
|
|
675
|
+
// the question to the one read — `resolveSkip()`, then `confirmPosture()` —
|
|
676
|
+
// which is where the flag/env and the shared store are resolved, live, on
|
|
677
|
+
// every tool round.
|
|
678
|
+
confirmMode: opts.yolo ? false : undefined,
|
|
667
679
|
continue: opts.continue,
|
|
668
680
|
});
|
|
669
681
|
|
package/vendor/cli/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aegiscode",
|
|
3
3
|
"productName": "AEGIS Code",
|
|
4
|
-
"version": "6.8.
|
|
4
|
+
"version": "6.8.36",
|
|
5
5
|
"description": "aegiscode — the command-line version of AEGIS Desktop. The shared tool surface in your shell, over the same thin transport and tool registry as the MCP plugin and the desktop app. Ships transport + UI only; no brain.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "AEGIS Code",
|