aegiscode 6.8.31 → 6.8.34

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 CHANGED
@@ -249,18 +249,22 @@ launch, and an explicit flag (`-m`, `--light`) always outranks the stored value.
249
249
 
250
250
  In a session, plain text is a prompt. `/help` lists commands, grouped by
251
251
  category, the way the reference does. The registry is that client's, ported
252
- command for command — 75 entries across nine categories:
252
+ command for command — 87 entries across nine categories:
253
253
 
254
254
  | Category | Commands |
255
255
  |---|---|
256
- | Session & context | `/clear` `/compact` `/cost` `/exit` `/new` `/recap` `/resume` `/rewind` `/agents` `/status` `/teleport` `/version` `/clone` `/schedule` |
257
- | Workspace | `/run` `/build` `/cd` `/copy` `/init` `/review` `/prs` |
258
- | Model & behavior | `/model` `/models` `/class` `/effort` `/thinking` `/theme` `/vim` `/router` `/confirm` `/yolo` `/permissions` `/hooks` `/skills` `/mcp` |
259
- | Data | `/context` `/export` `/tokens` `/sync` |
260
- | Auth | `/key` `/login` `/logout` `/credentials` `/byok` `/byok-set` `/byok-rm` `/byok-key` `/byok-rm-key` |
261
- | Support | `/help` `/doctor` `/troubleshooting` `/feedback` `/bug` `/issue` `/onboarding` `/benchmark` `/release-notes` `/billing` `/cloud` |
262
- | Aegis plugin | `/aegis-ask` `/aegis-status` `/aegis-recall` `/aegis-remember` `/memory` `/aegis-council` `/aegis-multi` `/aegis-print` `/aegis-import` `/tool` |
256
+ | Session & context | `/schedule` `/clear` `/compact` `/context` `/todos` `/config` `/exit` `/recap` `/resume` `/rewind` `/agents` `/status` `/teleport` `/version` `/new` `/skills` `/multiyolo` `/multi` `/research` `/debate` |
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` |
259
+ | Data | `/copy` `/cost` `/export` `/tokens` `/sync` |
260
+ | Auth | `/login` `/logout` `/key` `/byok` `/byok-set` `/byok-rm` `/byok-key` `/byok-rm-key` |
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` |
263
262
  | Fun | `/radio` `/waifu` |
263
+ | Aegis plugin | `/aegis-status` `/aegis-ask` `/aegis-recall` `/aegis-remember` `/aegis-council` `/aegis-print` `/aegis-multi` `/tool` `/aegis-import` |
264
+
265
+ The table above is generated from `cli/src/commands.js` (`COMMANDS` +
266
+ `CATEGORIES`), which is the only authority on what exists — a hand-kept copy is
267
+ how it came to claim 75 entries while the code held 84 before this port.
264
268
 
265
269
  `/help` shows the live list with hints; aliases are searchable in the `/`
266
270
  palette exactly as they are there (`/ask` → `/aegis-ask`, `?` → `/help`,
@@ -491,6 +495,46 @@ echo "why is the sky blue" | aegiscode -p -
491
495
  /troubleshooting
492
496
  ```
493
497
 
498
+ ### Settings and the reply-ready alert
499
+
500
+ ```bash
501
+ /config # every setting, and which store holds it
502
+ /config effort high # set one, typed (true/false/null, numbers, JSON, text)
503
+ /config reset themeIndex # back to the shipped value
504
+ ```
505
+
506
+ `/config` writes through the same split every other surface uses: the keys in
507
+ `SHARED_PREF_KEYS` go to `preferences.json`, the file AEGIS Desktop's settings
508
+ window reads and writes too, and this shell's own keys (`lastCwd`,
509
+ `updateCheck`) stay in `config.json`. It never writes a file directly, so it
510
+ cannot leave the window and the shell holding two answers to one question.
511
+
512
+ ```bash
513
+ /ping # show the state and the vocabulary
514
+ /ping bell # channel: off | bell | notify | both
515
+ /ping notify 120 # only turns longer than two minutes
516
+ /ping test # fire one now, to check this terminal
517
+ ```
518
+
519
+ `/ping` is the terminal's half of the desktop's "reply ready" notification: a
520
+ turn that outlasted `pingMinSeconds` raises an OSC 9 / OSC 777 notification and
521
+ rings the bell, so you can stop watching a long turn. A turn you pressed Escape
522
+ on never pings — you were demonstrably looking at the screen — and neither does
523
+ a piped or headless run, which has no one to notify. `notify` needs a terminal
524
+ that implements those sequences (iTerm2, WezTerm, kitty, GNOME Terminal, Windows
525
+ Terminal); `/ping test` tells you whether yours does, and `/ping bell` is the
526
+ fallback every terminal has.
527
+
528
+ ```bash
529
+ /todos # list
530
+ /todos add ship the retry fix # add one
531
+ /todos done 1 # by number, or by a unique text prefix
532
+ /todos clear
533
+ ```
534
+
535
+ The list lives in `$AEGISCODE_HOME/todos.json` and survives compaction, so a
536
+ plan you wrote out mid-session is still there after the context is shrunk.
537
+
494
538
  ### Unattended work
495
539
 
496
540
  ```bash
@@ -681,6 +725,7 @@ node ../test/cli-terminal-caps.test.mjs # capability resolution: PowerShell and
681
725
  node ../test/cli-render.test.mjs # width safety, accounting, live region
682
726
  node ../test/cli-overlays.test.mjs # the / palette, model + effort pickers, resume list
683
727
  node ../test/cli-fuzzy.test.mjs # palette ranking and match positions
728
+ node ../test/cli-ping-todos.test.mjs # /ping's four properties, /todos, /config's store routing
684
729
  node ../test/cli-markdown.test.mjs # span-line markdown, cell widths
685
730
  node ../test/cli-tools.test.mjs # registry parity with the MCP host + dispatch
686
731
  node ../test/cli-run.test.mjs # the real binary against a real backend
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "6.8.31",
4
+ "version": "6.8.34",
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",
package/src/app.js CHANGED
@@ -37,6 +37,7 @@ const {
37
37
  memoryPersistState,
38
38
  memoryPersistEnabled,
39
39
  setMemoryPersist,
40
+ confirmPosture,
40
41
  } = require('./config.js');
41
42
  const credentials = require('./credentials.js');
42
43
  // The key pump, so the startup background query can hand back a keystroke that
@@ -127,10 +128,12 @@ function createApp(options = {}) {
127
128
  // on the same machine. One attempt per `createApp()` instance, not one per
128
129
  // call: register-device is rate-limited server-side, and a session that
129
130
  // fires several turns before noticing a failure must not retry the same
130
- // failing call each time. The provisioned account starts at zero
131
- // token-bank balance and still needs an upgraded plan for pooled
132
- // aegiscloud models (aegis1's is_pro() gate) — this only unblocks BYOK and
133
- // account status/settings, never silently free inference.
131
+ // failing call each time. A brand-new fingerprint comes back with aegis1's
132
+ // one-time 30-day welcome-trial `unlimited` entitlement (token-bank credit
133
+ // plus a `subscriptions` row) granted in the same request — aegis1 commit
134
+ // 4372830 — so the account is usable pooled right away rather than starting
135
+ // at zero. The credit is finite: once it is spent or the trial lapses, the
136
+ // usual plan/balance gate applies.
134
137
  let provisionAttempted = false;
135
138
  async function ensureApiKey() {
136
139
  if (client.apiKey || provisionAttempted) return;
@@ -197,7 +200,14 @@ function createApp(options = {}) {
197
200
  /* fall through to the store: a broken skip resolver must not skip */
198
201
  }
199
202
  try {
200
- return loadPermissions().defaultMode !== 'allow';
203
+ // ON8 / D8 rule 1: the posture is read from the SHARED store first
204
+ // (config.js confirmPosture), which is the same store the desktop's
205
+ // "confirm before running tools" switch writes. Before this, the shell
206
+ // read only its own rule file, so the switch and `/yolo` were two
207
+ // postures for one question — the drift D8 names. The rule file is
208
+ // still the answer for an install that never touched the switch, so
209
+ // nothing changes for it.
210
+ return confirmPosture().enabled;
201
211
  } catch {
202
212
  return confirmMode;
203
213
  }
@@ -1162,6 +1172,9 @@ function createApp(options = {}) {
1162
1172
  /** A fresh snapshot for panels.js (the frozen `c.state()` shape). */
1163
1173
  function buildState() {
1164
1174
  const rules = loadPermissions();
1175
+ // ON8: `/status` reports the POSTURE, so a gate turned off in the window
1176
+ // shows here as `allow` rather than as a rule file that no longer decides.
1177
+ const posture = confirmPosture();
1165
1178
  return {
1166
1179
  version: VERSION,
1167
1180
  model: commandCtx.model || 'server default',
@@ -1196,7 +1209,7 @@ function createApp(options = {}) {
1196
1209
  balance: session.balance,
1197
1210
  plan: session.plan || null,
1198
1211
  account: session.account || null,
1199
- permissions: { mode: rules.defaultMode, rules },
1212
+ permissions: { mode: posture.enabled ? rules.defaultMode : 'allow', confirm: posture.enabled, source: posture.source, rules },
1200
1213
  // The selectable (pickable) catalog, not the raw payload: alias tiers are
1201
1214
  // dropped, live ids only (see models.js pickerEntries).
1202
1215
  // Whichever class is live decides what is pinnable — the pooled ids the
@@ -1866,7 +1879,9 @@ function createApp(options = {}) {
1866
1879
  wantsExit: () => wantExit,
1867
1880
  isYolo: () => {
1868
1881
  try {
1869
- return loadPermissions().defaultMode === 'allow';
1882
+ // The posture, not the rule file: since ON8 the window's switch is the
1883
+ // same fact, so a switch turned off there lights this chip too.
1884
+ return confirmPosture().enabled === false;
1870
1885
  } catch {
1871
1886
  return false;
1872
1887
  }
package/src/autonomous.js CHANGED
@@ -363,8 +363,8 @@ async function runQueueCommand(command, argv, io = {}) {
363
363
  // instead of guessing.
364
364
  stderr.write(
365
365
  snap.wall === 'balance'
366
- ? ' ↳ unlock: top up the Token Bank, or upgrade to Pro\n'
367
- : ' ↳ unlock: Pro, or any Token Bank balance\n'
366
+ ? ' ↳ unlock: top up the Token Bank, or upgrade to Unlimited\n'
367
+ : ' ↳ unlock: Unlimited, or any Token Bank balance\n'
368
368
  );
369
369
  if (snap.upgradeUrl) stderr.write(` ${snap.upgradeUrl}\n`);
370
370
  }
package/src/chatflow.js CHANGED
@@ -57,7 +57,10 @@ const { copyToClipboard, describeCopy, readClipboardText, readClipboardImage } =
57
57
  const { transcriptToMarkdown } = require('./export.js');
58
58
  const fs = require('node:fs');
59
59
  const path = require('node:path');
60
- const { aegisDir } = require('./config.js');
60
+ const { aegisDir, loadConfig } = require('./config.js');
61
+ // /ping — the terminal's half of the desktop's "reply ready" alert. Pure, so
62
+ // the loop only has to supply the stream and the elapsed time.
63
+ const { pingTurn } = require('./ping.js');
61
64
 
62
65
  /** The rotating placeholder shown on an empty input line. */
63
66
  const SUGGESTIONS = [
@@ -1268,6 +1271,30 @@ async function runSession(host) {
1268
1271
  turnCount++;
1269
1272
  abort = null;
1270
1273
 
1274
+ // /ping — the same notice the desktop raises from
1275
+ // `notifyReplyIfUnfocused()`, re-derived for a terminal that has no
1276
+ // `isFocused()`: the proxy is TIME (a turn the user walked away from is
1277
+ // one that took longer than `pingMinSeconds`), and the gate is
1278
+ // `process.stdout.isTTY` (a piped or headless run has no one to notify).
1279
+ // Written to `process.stdout` rather than through the renderer on
1280
+ // purpose: a notification escape goes past the screen buffer, so it works
1281
+ // while the renderer still owns the terminal. Guarded, and last, so a
1282
+ // notice can never break the turn it is reporting on.
1283
+ try {
1284
+ const pingCfg = loadConfig();
1285
+ const notice = pingTurn({
1286
+ stream: process.stdout,
1287
+ mode: pingCfg.ping,
1288
+ minSeconds: pingCfg.pingMinSeconds,
1289
+ elapsedMs: Date.now() - startedAt,
1290
+ isTTY: !!process.stdout.isTTY,
1291
+ aborted: abortedFlag,
1292
+ });
1293
+ if (notice) push({ role: 'note', text: notice }, { follow: false });
1294
+ } catch {
1295
+ /* a notice must never break a turn */
1296
+ }
1297
+
1271
1298
  // Accounting: fold the turn's usage into the session tallies, ask the
1272
1299
  // ledger what it settled at, and show both — tokens beside €.
1273
1300
  host.recordTurn(result);
package/src/commands.js CHANGED
@@ -53,6 +53,10 @@ const overlays = require('./overlays.js');
53
53
  const {
54
54
  updateConfig, loadConfig, loadPermissions, savePermissions, addPermissionRule,
55
55
  DEFAULT_PERMISSIONS, permissionsPath, configPath, aegisDir,
56
+ // ON8 / D8 rule 1: the posture writers. Every "confirmations on/off" command
57
+ // below goes through these rather than writing `defaultMode` itself, so the
58
+ // window's switch and this face's gate cannot end up holding two answers.
59
+ setConfirmPosture, setPermissionDefaultMode,
56
60
  memoryPersistState, setMemoryPersist,
57
61
  } = require('./config.js');
58
62
  const { auditExposure, repairExposure } = require('./securefs.js');
@@ -64,6 +68,20 @@ const { summarizeTranscript, recapLine } = require('./summarize.js');
64
68
  const { sessionAccounting, accountingFromUsage, estimateTokens } = require('./tokens.js');
65
69
  const { transcriptToMarkdown, transcriptToJSON, writeExportFile, lastAssistantText } = require('./export.js');
66
70
  const { detectDevCommand, runDevServer } = require('./devrun.js');
71
+ // /ping — the terminal half of the desktop's "reply ready" alert. Pure and
72
+ // dependency-free (no config, no TTY), so it is unit-testable on its own.
73
+ const {
74
+ PING_MODES, DEFAULT_PING_MODE, normalizePingMode, normalizePingSeconds,
75
+ buildPing, writePing,
76
+ } = require('./ping.js');
77
+ // /todos — the session list. Owns its own file; shares only `aegisDir`.
78
+ const { addTodo, completeTodo, clearTodos, formatTodos, todosFile } = require('./todos.js');
79
+ // /config — the settings surface. Store-aware, so it cannot write a preference
80
+ // to the host file (or the reverse) and re-open the drift ON8/D8 closed.
81
+ const {
82
+ configRows, formatConfigRows, setConfigValue, resetConfigValue,
83
+ fullValue, summarizeValue, configStore,
84
+ } = require('./settings.js');
67
85
  const credentials = require('./credentials.js');
68
86
  const cloudsync = require('./cloudsync.js');
69
87
  const { maskKey, fmtTokens, shortCwd } = require('./format.js');
@@ -195,8 +213,10 @@ async function multiData(c, task) {
195
213
  */
196
214
  async function runMultiCommand(c, task, { yolo = false, title = 'ÆGIS Multi' } = {}) {
197
215
  if (yolo) {
198
- const rules = loadPermissions();
199
- savePermissions({ ...rules, defaultMode: 'allow' });
216
+ // ON8: through the posture writer, not a bare `defaultMode` write — /multiyolo
217
+ // means "stop confirming", and that is now ONE fact in two stores rather than
218
+ // a rule-file edit the window would never see.
219
+ setConfirmPosture(false);
200
220
  panel(c, panels.buildYolo(c.state(), c.ctx));
201
221
  }
202
222
  note(c, 'Running the multi-agent fan-out — the engine delegates to specialist subagents (headless: this skips aegis-cli\'s own confirmation step).');
@@ -876,6 +896,172 @@ const COMMANDS = [
876
896
  return true;
877
897
  },
878
898
  },
899
+ {
900
+ name: 'ping', args: ['mode', 'seconds'], hint: '[off|bell|notify|both] [seconds] | test', category: 'model',
901
+ desc: 'Alert me when a long turn finishes, if I am looking elsewhere',
902
+ handler: async (c, args) => {
903
+ const cfg = loadConfig();
904
+ const raw = ((args._rest || '').trim()).split(/\s+/).filter(Boolean);
905
+ const first = (raw[0] || '').toLowerCase();
906
+ const mode = normalizePingMode(cfg.ping);
907
+ const seconds = normalizePingSeconds(cfg.pingMinSeconds);
908
+
909
+ // No argument: report the state AND the vocabulary, so the command is its
910
+ // own help. Silence here would be indistinguishable from a broken config.
911
+ if (!first) {
912
+ note(c, `[ping] ${mode} — a turn longer than ${seconds}s raises a terminal notification.`);
913
+ note(c, ` /ping ${PING_MODES.filter((m) => m !== mode).join('|')} ${mode === 'off' ? 'turn it back on' : 'change the channel'}`);
914
+ note(c, ` /ping <mode> <seconds> move the threshold (0 pings every turn)`);
915
+ note(c, ' /ping test fire one now, to check this terminal supports it');
916
+ c.render();
917
+ return true;
918
+ }
919
+
920
+ if (first === 'test') {
921
+ const text = buildPing({ mode: mode === 'off' ? DEFAULT_PING_MODE : mode });
922
+ // The test deliberately ignores the threshold and the abort rule — it is
923
+ // the user asking "does this terminal show anything?", and the only
924
+ // condition worth keeping is the one that makes the answer meaningful.
925
+ const wrote = process.stdout.isTTY ? writePing(process.stdout, text) : false;
926
+ note(c, wrote
927
+ ? '[ping] sent one just now. If nothing appeared or sounded, this terminal implements neither OSC 9 nor OSC 777 — /ping bell is the fallback.'
928
+ : '[ping] nothing sent: stdout is not a TTY (a piped or headless run has no one to notify).');
929
+ c.render();
930
+ return true;
931
+ }
932
+
933
+ if (!PING_MODES.includes(first)) {
934
+ note(c, `Unknown ping mode "${raw[0]}". Use ${PING_MODES.join(', ')}.`);
935
+ c.render();
936
+ return true;
937
+ }
938
+
939
+ const patch = { ping: first };
940
+ if (raw[1] != null) {
941
+ const n = Number(raw[1]);
942
+ if (!Number.isFinite(n) || n < 0) {
943
+ note(c, `"${raw[1]}" is not a number of seconds. Use /ping ${first} 30.`);
944
+ c.render();
945
+ return true;
946
+ }
947
+ patch.pingMinSeconds = normalizePingSeconds(n);
948
+ }
949
+ updateConfig(patch);
950
+
951
+ if (first === 'off') {
952
+ note(c, '[ping] off — no notice will be raised, and nothing is reported as sent.');
953
+ } else {
954
+ note(c, `[ping] ${first} — turns longer than ${normalizePingSeconds(patch.pingMinSeconds ?? cfg.pingMinSeconds)}s will notify you.`);
955
+ note(c, ' Escape never pings (you were watching), and neither does a piped or headless run.');
956
+ }
957
+ c.render();
958
+ return true;
959
+ },
960
+ },
961
+ {
962
+ name: 'todos', aliases: ['todo'], args: ['sub', 'text'], hint: '[add <text> | done <n|text> | clear]', category: 'session',
963
+ desc: 'A session todo list that survives compaction',
964
+ handler: async (c, args) => {
965
+ const sub = (args.sub || '').toLowerCase();
966
+ const rest = (args._rest || '').trim();
967
+ // Everything after the subcommand. `_rest` is the whole line, so
968
+ // `/todos add buy milk` would otherwise store the literal string
969
+ // "add buy milk" — the subcommand has to come off first.
970
+ const tail = rest.replace(/^\S+\s*/, '');
971
+
972
+ if (!sub) {
973
+ panel(c, formatTodos());
974
+ note(c, ` ${todosFile()}`);
975
+ note(c, ' /todos add <text> · /todos done <n|text> · /todos clear');
976
+ c.render();
977
+ return true;
978
+ }
979
+
980
+ if (sub === 'add') {
981
+ const res = addTodo(tail);
982
+ if (res.error) { note(c, res.error); c.render(); return true; }
983
+ panel(c, formatTodos(res.list));
984
+ c.render();
985
+ return true;
986
+ }
987
+
988
+ if (sub === 'done' || sub === 'do') {
989
+ const res = completeTodo(tail);
990
+ if (res.error) { note(c, res.error); c.render(); return true; }
991
+ note(c, `[todos] "${res.item.text}" is now ${res.item.done ? 'done' : 'open'}.`);
992
+ panel(c, formatTodos(res.list));
993
+ c.render();
994
+ return true;
995
+ }
996
+
997
+ if (sub === 'clear') {
998
+ clearTodos();
999
+ note(c, '[todos] cleared.');
1000
+ c.render();
1001
+ return true;
1002
+ }
1003
+
1004
+ note(c, `Unknown /todos subcommand "${args.sub}". Use add, done or clear.`);
1005
+ c.render();
1006
+ return true;
1007
+ },
1008
+ },
1009
+ {
1010
+ name: 'config', args: ['key', 'value'], hint: '[<key> | <key> <value> | reset <key>]', category: 'session',
1011
+ desc: 'Show or change any setting, and say which store holds it',
1012
+ handler: async (c, args) => {
1013
+ const rest = (args._rest || '').trim();
1014
+ const key = (args.key || '').trim();
1015
+ // The value is everything after the key, not the next token: a string
1016
+ // setting may contain spaces, and `_rest` is the whole line.
1017
+ const value = rest.replace(/^\S+\s*/, '');
1018
+
1019
+ if (!key) {
1020
+ // The list summarizes structured values rather than dumping them —
1021
+ // `models` is a model table and `updateCheck` is an object, and printing
1022
+ // them whole is how this command becomes unreadable.
1023
+ panel(c, formatConfigRows(configRows()));
1024
+ note(c, ' /config <key> show one value in full');
1025
+ note(c, ' /config <key> <value> set it (true/false/null, numbers, JSON, or text)');
1026
+ note(c, ' /config reset <key> back to the shipped value');
1027
+ note(c, ' "shared" keys live in the store AEGIS Desktop writes too; "host" keys are this shell\'s own.');
1028
+ c.render();
1029
+ return true;
1030
+ }
1031
+
1032
+ if (key === 'reset') {
1033
+ const res = resetConfigValue(value);
1034
+ if (res.error) { note(c, res.error); c.render(); return true; }
1035
+ note(c, `[config] ${res.key} reset to ${summarizeValue(res.value)} (${res.store}).`);
1036
+ c.render();
1037
+ return true;
1038
+ }
1039
+
1040
+ if (!value) {
1041
+ const cfg = loadConfig();
1042
+ if (!Object.prototype.hasOwnProperty.call(cfg, key)) {
1043
+ note(c, `unknown config key "${key}" — run /config to list the keys`);
1044
+ c.render();
1045
+ return true;
1046
+ }
1047
+ note(c, `${key} (${configStore(key)}):`);
1048
+ c.push({ role: 'panel', lines: fullValue(cfg[key]).split('\n').map((l) => ` ${l}`) });
1049
+ c.render();
1050
+ return true;
1051
+ }
1052
+
1053
+ const res = setConfigValue(key, value);
1054
+ if (res.error) { note(c, res.error); c.render(); return true; }
1055
+ note(c, `[config] ${res.key} = ${summarizeValue(res.value)} (${res.store}).`);
1056
+ // A model/class/effort change is a live session decision, not just a file
1057
+ // write; say so rather than leaving the user to wonder when it applies.
1058
+ if (['model', 'currentModelId', 'modelClass', 'effort', 'themeIndex', 'vim'].includes(res.key)) {
1059
+ note(c, ` This takes effect on the next turn; /${res.key === 'currentModelId' ? 'model' : res.key} shows the live session value.`);
1060
+ }
1061
+ c.render();
1062
+ return true;
1063
+ },
1064
+ },
879
1065
  {
880
1066
  name: 'effort', args: ['level'], hint: '[auto|low|medium|high]', category: 'model',
881
1067
  desc: 'Set the token budget the pool sizes each turn from',
@@ -1528,13 +1714,21 @@ const COMMANDS = [
1528
1714
  return true;
1529
1715
  }
1530
1716
  if (mode === 'clear') {
1717
+ // A reset is a posture change too: DEFAULT_PERMISSIONS' residual is
1718
+ // `ask`, i.e. confirmations ON, and leaving the shared key where it was
1719
+ // would keep the gate off in the window while this face asks.
1720
+ setPermissionDefaultMode(DEFAULT_PERMISSIONS.defaultMode);
1531
1721
  savePermissions({ ...DEFAULT_PERMISSIONS, allow: [], deny: [], ask: [] });
1532
1722
  note(c, 'Permissions reset to defaults (no rules).');
1533
1723
  c.render();
1534
1724
  return true;
1535
1725
  }
1536
1726
  if (mode === 'default' && ['ask', 'allow', 'deny'].includes(pattern)) {
1537
- savePermissions({ ...rules, defaultMode: pattern });
1727
+ // ON8: `ask`/`allow` are the posture, so this moves the shared gate too
1728
+ // (a `/permissions default ask` in the shell must close the window's
1729
+ // switch, which is the whole point of rule 1). `deny` is not a posture:
1730
+ // it writes the rule residual and leaves the gate UP.
1731
+ setPermissionDefaultMode(pattern);
1538
1732
  note(c, `Default permission mode: ${pattern}`);
1539
1733
  c.render();
1540
1734
  return true;
@@ -1896,7 +2090,9 @@ const COMMANDS = [
1896
2090
  const mode = (args.mode || '').toLowerCase();
1897
2091
  if (mode && !['on', 'off'].includes(mode)) { note(c, 'Usage: /confirm [on|off]'); c.render(); return true; }
1898
2092
  const want = mode === 'on' ? true : mode === 'off' ? false : rules.defaultMode !== 'allow';
1899
- savePermissions({ ...rules, defaultMode: want ? 'ask' : 'allow' });
2093
+ // ON8: one writer for the posture — the shared key the window's switch
2094
+ // reads, plus the rule residual this face's gate reads.
2095
+ setConfirmPosture(want);
1900
2096
  note(c, `Confirmation prompts: ${want ? 'on' : 'off'} (default permission mode: ${want ? 'ask' : 'allow'})`);
1901
2097
  c.render();
1902
2098
  return true;
@@ -1910,7 +2106,9 @@ const COMMANDS = [
1910
2106
  const mode = (args.mode || '').toLowerCase();
1911
2107
  if (mode && !['on', 'off'].includes(mode)) { note(c, 'Usage: /yolo [on|off]'); c.render(); return true; }
1912
2108
  const want = mode === 'on' ? true : mode === 'off' ? false : rules.defaultMode !== 'allow';
1913
- savePermissions({ ...rules, defaultMode: want ? 'allow' : 'ask' });
2109
+ // ON8: `/yolo` is the posture's OFF state, written through the one writer,
2110
+ // so the window's switch shows it and the two faces cannot disagree.
2111
+ setConfirmPosture(!want);
1914
2112
  if (want) panel(c, panels.buildYolo(c.state(), c.ctx));
1915
2113
  else note(c, 'YOLO mode off — confirmations restored.');
1916
2114
  c.render();
package/src/config.js CHANGED
@@ -273,11 +273,25 @@ function loadConfig() {
273
273
  * opted back in. So it is written only when it is actually known — set by this
274
274
  * patch, already in the shared store, already in config.json, or stated by the
275
275
  * legacy `cloudSync` key.
276
+ *
277
+ * `confirmMode` (ON8) is the second, for the same reason and one more: it is a
278
+ * posture, and `DEFAULT_CONFIG` has no entry for it, so the default-fill would
279
+ * have written `undefined` — which `prefs.set()` drops. Every unrelated config
280
+ * save (`/theme`, onboarding, an update-check cache write) would then DELETE the
281
+ * gate's one shared copy, silently reverting the window's switch and the shell's
282
+ * `/yolo` to the rule file on the next launch. And filling it with `true` instead
283
+ * would be worse, not better: an install whose desktop still holds a legacy
284
+ * `__confirmMode: { enabled: false }` would be flipped ON by the first CLI save,
285
+ * which is exactly the migration `client/prefs.js`'s `adopt()` exists to get
286
+ * right. So: written when this patch states it, or when the store already has
287
+ * one, and otherwise left alone for the rule file to answer.
276
288
  */
289
+ const WRITE_WHEN_KNOWN = new Set(['memoryPersist', 'confirmMode']);
290
+
277
291
  function sharedView(patch, host, shared) {
278
292
  const view = {};
279
293
  for (const k of SHARED_KEYS) {
280
- if (k === 'memoryPersist') continue;
294
+ if (WRITE_WHEN_KNOWN.has(k)) continue;
281
295
  if (patch[k] !== undefined) view[k] = patch[k];
282
296
  else if (shared[k] !== undefined) view[k] = shared[k];
283
297
  else if (host[k] !== undefined) view[k] = host[k];
@@ -289,6 +303,8 @@ function sharedView(patch, host, shared) {
289
303
  else if (typeof host[LEGACY_MEMORY_PERSIST_KEY] === 'boolean') {
290
304
  view.memoryPersist = host[LEGACY_MEMORY_PERSIST_KEY];
291
305
  }
306
+ if (patch.confirmMode !== undefined) view.confirmMode = patch.confirmMode;
307
+ else if (shared.confirmMode !== undefined) view.confirmMode = shared.confirmMode;
292
308
  return view;
293
309
  }
294
310
 
@@ -392,6 +408,99 @@ function removePermissionRule(list, pattern, rules) {
392
408
  return { removed: patterns.length !== rules[key].length, rules: { ...rules, [key]: patterns } };
393
409
  }
394
410
 
411
+ // ── The confirmation posture (AEGISONE ON8, decision D8 rule 1) ─────────────
412
+ //
413
+ // "One posture, two faces": the window's *Confirm before running tools* switch
414
+ // and this face's gate (app.js's `getConfirmMode`, which the engine reads on
415
+ // every tool round) answer the same question — may a mutating call run
416
+ // unattended? — so they are one value, stored once, in the shared preference
417
+ // store both hosts read (`confirmMode`).
418
+ //
419
+ // Why the writer lives HERE and not in permissions.js: this module owns BOTH
420
+ // files, so it is the only place that can keep them consistent in one step.
421
+ // permissions.json's `defaultMode` is NOT a second copy of the posture to be
422
+ // retired — it is a field of the rule schema `evalPermission` reads (an
423
+ // explicit `ask` is what makes the rule engine prompt on an unmatched call), so
424
+ // it stays, and it is written in lockstep with the shared key. Then the read
425
+ // order below is consistent by construction: the shared key answers, and it
426
+ // cannot disagree with the file because nothing writes one without the other.
427
+ //
428
+ // Rule 2 is untouched and unreachable from here: the ÆGIS covenant's
429
+ // `preActionAssert` and the avatar's `write|shell|network|offDevice` approvals
430
+ // are asserted above this gate, in the engine, on purpose (see
431
+ // desktop/lib/local/engine.js's "DO NOT MOVE THIS BELOW A SHORT-CIRCUIT"). A
432
+ // posture is the *configurable* half and can only ever move that half.
433
+
434
+ /**
435
+ * The posture, resolved from the two stores, shared store first.
436
+ *
437
+ * @returns {{enabled: boolean, source: 'shared'|'rules'|'default'}}
438
+ * `enabled` true means the gate is UP (confirmations on), which is the
439
+ * polarity the window's switch and `getConfirmMode()` both use.
440
+ *
441
+ * `rules` is the un-migrated fallback rather than a competitor: an install that
442
+ * never touched the switch has no `confirmMode` key and is answered by its rule
443
+ * file exactly as it was before this phase. Nothing here throws — a store that
444
+ * cannot be read keeps the gate UP, never off.
445
+ */
446
+ function confirmPosture() {
447
+ try {
448
+ const shared = readSharedPrefs().confirmMode;
449
+ if (typeof shared === 'boolean') return { enabled: shared, source: 'shared' };
450
+ } catch {
451
+ /* fall through to the rule file, then the safe default */
452
+ }
453
+ try {
454
+ const parsed = JSON.parse(fs.readFileSync(permissionsPath(), 'utf8'));
455
+ if (parsed && typeof parsed === 'object' && typeof parsed.defaultMode === 'string') {
456
+ // The pre-ON8 reading, verbatim: anything that is not an explicit `allow`
457
+ // leaves the gate up.
458
+ return { enabled: parsed.defaultMode !== 'allow', source: 'rules' };
459
+ }
460
+ } catch {
461
+ /* absent or corrupt: the default below is ON */
462
+ }
463
+ return { enabled: true, source: 'default' };
464
+ }
465
+
466
+ /**
467
+ * Set the posture: the shared key (both faces) + the rule file's residual.
468
+ *
469
+ * Called by every command that means "confirmations on/off" — /confirm, /yolo,
470
+ * /multiyolo and the flag the desktop's switch mirrors — so there is exactly one
471
+ * writer per fact and no command can leave the two stores disagreeing.
472
+ */
473
+ function setConfirmPosture(enabled) {
474
+ const want = Boolean(enabled);
475
+ try {
476
+ prefs.set({ confirmMode: want }, { dir: aegisDir() });
477
+ } catch (e) {
478
+ if (process.env.AEGIS_HIST_DEBUG) console.error('[prefs] write failed:', e);
479
+ }
480
+ savePermissions({ ...loadPermissions(), defaultMode: want ? 'ask' : 'allow' });
481
+ return want;
482
+ }
483
+
484
+ /**
485
+ * `/permissions default <ask|allow|deny>` — the residual mode, and the posture
486
+ * that follows from it.
487
+ *
488
+ * `ask`/`allow` ARE the posture (`setConfirmPosture`). `deny` is not: there is
489
+ * no "confirmations: deny" switch, so the residual is written to the file while
490
+ * the posture stays UP — a default of `deny` must not be implemented as a gate
491
+ * that stopped asking.
492
+ */
493
+ function setPermissionDefaultMode(mode) {
494
+ const want = mode === 'allow' ? 'allow' : mode === 'deny' ? 'deny' : 'ask';
495
+ try {
496
+ prefs.set({ confirmMode: want !== 'allow' }, { dir: aegisDir() });
497
+ } catch (e) {
498
+ if (process.env.AEGIS_HIST_DEBUG) console.error('[prefs] write failed:', e);
499
+ }
500
+ savePermissions({ ...loadPermissions(), defaultMode: want });
501
+ return want;
502
+ }
503
+
395
504
  module.exports = {
396
505
  aegisDir,
397
506
  configPath,
@@ -412,4 +521,7 @@ module.exports = {
412
521
  savePermissions,
413
522
  addPermissionRule,
414
523
  removePermissionRule,
524
+ confirmPosture,
525
+ setConfirmPosture,
526
+ setPermissionDefaultMode,
415
527
  };
@@ -263,6 +263,15 @@ function paymentView(snapshot, { host = 'cli', fee = null } = {}) {
263
263
  const entitled = snap.entitled === true;
264
264
  const feeLine = feeView(fee).line;
265
265
  const wall = entitled ? 'owned' : snap.wall === 'balance' ? 'balance' : 'plan';
266
+ // The paid tier's NAME, resolved from the server's plan string. `unlimited`
267
+ // is the tier currently sold (€9/mo); `pro` is the grandfathered €2 line —
268
+ // still paid, still named Pro, but no longer offered to anyone. The shared
269
+ // module's own `tierName` (TIER_NAMES) wins when the snapshot carries one, so
270
+ // this host cannot disagree with the gate about which tier was granted.
271
+ const tierName =
272
+ snap.tierName ||
273
+ { unlimited: 'Unlimited', pro: 'Pro' }[String(snap.plan || '').toLowerCase()] ||
274
+ 'Unlimited';
266
275
  const which = wall === 'balance' ? BALANCE_WALL : BILLING_WALL;
267
276
  return {
268
277
  host,
@@ -291,11 +300,11 @@ function paymentView(snapshot, { host = 'cli', fee = null } = {}) {
291
300
  // bill and the pitch disagreed: a user was told BYOK costs "your provider's
292
301
  // cost" while aegis1 charged a handling fee on top of it.
293
302
  byok: feeLine,
294
- label: entitled ? 'Pro' : wall === 'balance' ? 'Top up' : 'Upgrade',
303
+ label: entitled ? tierName : wall === 'balance' ? 'Top up' : 'Upgrade',
295
304
  unlock:
296
305
  wall === 'balance'
297
- ? 'Unlock: top up the Token Bank, or upgrade to Pro'
298
- : 'Unlock: Pro, or any Token Bank balance',
306
+ ? 'Unlock: top up the Token Bank, or upgrade to Unlimited'
307
+ : 'Unlock: Unlimited, or any Token Bank balance',
299
308
  };
300
309
  }
301
310