aegiscode 7.0.0 → 7.0.1

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 (109) hide show
  1. package/bin/aegiscode.js +137 -0
  2. package/package.json +1 -1
  3. package/scripts/check.mjs +5 -0
  4. package/scripts/demo.mjs +5 -0
  5. package/scripts/predist.mjs +29 -2
  6. package/scripts/runtests.mjs +5 -0
  7. package/scripts/seal-gate.mjs +76 -0
  8. package/src/agents.js +5 -0
  9. package/src/app.js +5 -0
  10. package/src/art.js +5 -0
  11. package/src/autonomous.js +23 -0
  12. package/src/caps.js +5 -0
  13. package/src/chatflow.js +104 -31
  14. package/src/checkpoint.js +5 -0
  15. package/src/clipboard.js +5 -0
  16. package/src/cloudsync.js +5 -0
  17. package/src/commands.js +326 -14
  18. package/src/config.js +5 -0
  19. package/src/credentials.js +5 -0
  20. package/src/deps.js +5 -0
  21. package/src/devrun.js +5 -0
  22. package/src/diff.js +5 -0
  23. package/src/diffview.js +5 -0
  24. package/src/engine.js +5 -0
  25. package/src/entitlement.js +5 -0
  26. package/src/events.js +15 -0
  27. package/src/export.js +5 -0
  28. package/src/fingerprint.js +5 -0
  29. package/src/format.js +5 -0
  30. package/src/fuzzy.js +5 -0
  31. package/src/gate.js +12 -0
  32. package/src/history.js +5 -0
  33. package/src/init.js +5 -0
  34. package/src/input.js +5 -0
  35. package/src/keys.js +29 -2
  36. package/src/limits.js +192 -0
  37. package/src/markdown.js +5 -0
  38. package/src/mcp.js +13 -0
  39. package/src/models.js +5 -0
  40. package/src/naming.js +5 -0
  41. package/src/overlays.js +7 -2
  42. package/src/panels.js +5 -0
  43. package/src/permissions.js +56 -1
  44. package/src/ping.js +5 -0
  45. package/src/presence.js +5 -0
  46. package/src/provenance.js +238 -0
  47. package/src/provenance.lock.json +36 -0
  48. package/src/render.js +5 -0
  49. package/src/screen.js +5 -0
  50. package/src/screens.js +48 -37
  51. package/src/secret.js +5 -0
  52. package/src/securefs.js +5 -0
  53. package/src/settings.js +5 -0
  54. package/src/shared.js +5 -0
  55. package/src/sharedpaths.js +5 -0
  56. package/src/signup.js +5 -0
  57. package/src/summarize.js +5 -0
  58. package/src/sysdiag.js +582 -0
  59. package/src/system.js +5 -0
  60. package/src/theme.js +5 -0
  61. package/src/title.js +5 -0
  62. package/src/todos.js +5 -0
  63. package/src/tokens.js +5 -0
  64. package/src/topup.js +5 -0
  65. package/src/update.js +5 -0
  66. package/vendor/client/aegis.js +5 -0
  67. package/vendor/client/attest.js +5 -0
  68. package/vendor/client/authorship-key.js +5 -0
  69. package/vendor/client/auto-provision.js +5 -0
  70. package/vendor/client/brain-catalog.js +5 -0
  71. package/vendor/client/byok-catalog.js +5 -0
  72. package/vendor/client/credentials.js +5 -0
  73. package/vendor/client/device-fingerprint.js +5 -0
  74. package/vendor/client/env-file.js +5 -0
  75. package/vendor/client/fingerprint.js +5 -0
  76. package/vendor/client/foreign-memory.js +5 -0
  77. package/vendor/client/hooks.js +5 -0
  78. package/vendor/client/model-discovery.js +332 -0
  79. package/vendor/client/platform.js +5 -0
  80. package/vendor/client/prefs.js +5 -0
  81. package/vendor/client/presence-constants.js +5 -0
  82. package/vendor/client/presence.js +5 -0
  83. package/vendor/client/record-vault.js +5 -0
  84. package/vendor/client/session-store.js +5 -0
  85. package/vendor/client/topup.js +5 -0
  86. package/vendor/client/touch.js +5 -0
  87. package/vendor/client/update.js +5 -0
  88. package/vendor/client/user-models.js +5 -0
  89. package/vendor/desktop/lib/local/aegis-seal.mjs +5 -0
  90. package/vendor/desktop/lib/local/agents.js +5 -0
  91. package/vendor/desktop/lib/local/autonomous.js +5 -0
  92. package/vendor/desktop/lib/local/context.js +5 -0
  93. package/vendor/desktop/lib/local/covenant.js +5 -0
  94. package/vendor/desktop/lib/local/engine.js +129 -0
  95. package/vendor/desktop/lib/local/entitlement.js +5 -0
  96. package/vendor/desktop/lib/local/git-scope.js +5 -0
  97. package/vendor/desktop/lib/local/local.js +5 -0
  98. package/vendor/desktop/lib/local/prompt.js +5 -0
  99. package/vendor/desktop/lib/local/queue.js +5 -0
  100. package/vendor/desktop/lib/local/session-rounds.js +5 -0
  101. package/vendor/desktop/lib/local/shell.js +88 -9
  102. package/vendor/desktop/lib/local/tools.js +13 -6
  103. package/vendor/desktop/lib/local/turn-guard.js +5 -0
  104. package/vendor/desktop/lib/local/worktree-lock.js +5 -0
  105. package/vendor/desktop/lib/settings.js +5 -0
  106. package/vendor/desktop/renderer/usage.js +5 -0
  107. package/vendor/mcp/server.js +5 -0
  108. package/vendor/mcp/tools.js +5 -0
  109. package/vendor/tools/agent-gate.mjs +23 -0
package/src/keys.js CHANGED
@@ -46,6 +46,16 @@ const KEY = Object.freeze({
46
46
  CTRL_B: 'ctrl-b',
47
47
  CTRL_LEFT: 'ctrl-left',
48
48
  CTRL_RIGHT: 'ctrl-right',
49
+ // Shift is a MODIFIER here, not a duplicate of the bare key: the pickers bind
50
+ // shift+arrow to "move the highlight and commit it", so decoding mod 2 as the
51
+ // plain arrow (which is what this decoder did) would make shift silently
52
+ // identical to an unmodified arrow — the chord the status line advertises
53
+ // would do nothing the arrow does not. `SHIFT_ENTER` is here for the palettes
54
+ // that want a non-Enter commit; it arrives in two spellings (see
55
+ // decodeEscSequence) because terminals disagree about which one to send.
56
+ SHIFT_UP: 'shift-up',
57
+ SHIFT_DOWN: 'shift-down',
58
+ SHIFT_ENTER: 'shift-enter',
49
59
  });
50
60
 
51
61
  /** Decode a bare character (no escape prefix) into a key object. */
@@ -114,10 +124,14 @@ function decodeEscSequence(seq) {
114
124
  const params = m[1] ? m[1].split(';') : [];
115
125
  const mod = params.length > 1 ? parseInt(params[1], 10) : 0;
116
126
  switch (m[2]) {
127
+ // Modifier 2 is shift (`1;2A` = shift+up). It has to be named, not
128
+ // folded into the bare arrow: the /model picker binds shift+arrow to
129
+ // "move the highlight and pin it", so decoding it as a plain arrow is
130
+ // what made the advertised chord indistinguishable from the arrow.
117
131
  case 'A':
118
- return { name: KEY.UP };
132
+ return { name: mod === 2 ? KEY.SHIFT_UP : KEY.UP };
119
133
  case 'B':
120
- return { name: KEY.DOWN };
134
+ return { name: mod === 2 ? KEY.SHIFT_DOWN : KEY.DOWN };
121
135
  case 'C':
122
136
  return mod === 5 ? { name: KEY.CTRL_RIGHT } : { name: KEY.RIGHT };
123
137
  case 'D':
@@ -126,6 +140,15 @@ function decodeEscSequence(seq) {
126
140
  return { name: KEY.HOME };
127
141
  case 'F':
128
142
  return { name: KEY.END };
143
+ case 'u': {
144
+ // Kitty/modifyOtherKeys spelling: `CSI <codepoint> ; <modifier> u`.
145
+ // A terminal in that mode sends shift+enter as `\x1b[13;2u` rather
146
+ // than the legacy `\x1b\r`, and both have to land on the same key
147
+ // name or the chord works on one terminal and not the next.
148
+ const code = parseInt(params[0] || '0', 10);
149
+ if (code === 13 && mod === 2) return { name: KEY.SHIFT_ENTER };
150
+ return null;
151
+ }
129
152
  case '~': {
130
153
  const n = parseInt(params[0] || '0', 10);
131
154
  if (n === 3) return { name: KEY.DELETE };
@@ -147,6 +170,10 @@ function decodeEscSequence(seq) {
147
170
  if (c === 'F') return { name: KEY.END };
148
171
  return null;
149
172
  }
173
+ // The legacy spelling of shift+enter, for terminals that never send the CSI
174
+ // `u` form above. `\x1b\r` is only ever shift+enter (a bare `\r` is ENTER and
175
+ // arrives without the ESC), so it cannot be confused with anything else.
176
+ if (seq === '\x1b\r' || seq === '\x1b\n') return { name: KEY.SHIFT_ENTER };
150
177
  return { name: KEY.ESC };
151
178
  }
152
179
 
package/src/limits.js ADDED
@@ -0,0 +1,192 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
+ 'use strict';
7
+
8
+ /**
9
+ * limits — the second gate. This is the one that does not explain itself.
10
+ *
11
+ * `src/provenance.js` is the gate that speaks: it compares this install to a
12
+ * manifest and tells you, by name, when the two disagree. Anyone assembling a
13
+ * modified build reads that output once and knows exactly which file to edit
14
+ * next. Speaking is the defect.
15
+ *
16
+ * This module is the same question asked with nothing to read. It derives a
17
+ * single digest from the safety files *as one closed set* — changing any one of
18
+ * them changes the whole — and compares that to a value sealed into this file.
19
+ * When it does not match:
20
+ *
21
+ * - it prints one bland line naming no file, no category and no remedy, and
22
+ * - it refuses the privileged subcommands outright (`gate`, `provenance`,
23
+ * `mcp`), so the gate's own key management is unavailable to the build that
24
+ * failed the check, and
25
+ * - it marks the process `AEGIS_REDUCED_MODE=1` for modules that opt in.
26
+ *
27
+ * Nothing in the package maps ids back to paths. The paths here are base64 and
28
+ * the sealed digest is XORed with a derived pad. That is obfuscation, not
29
+ * cryptography, and this file does not pretend otherwise: whoever holds the
30
+ * bytes can read it. The cost being raised is the cost of *noticing* — there is
31
+ * no runtime switch to disable it, no manifest telling you what is covered, and
32
+ * no self-describing failure to imitate. The map lives only in
33
+ * `tools/provenance.mjs`, which is a development tool and is not what ships.
34
+ *
35
+ * ## Why `armed()` exists, and why it is called from four files
36
+ *
37
+ * A check that is invoked from exactly one place is removed by deleting one
38
+ * line, and the entry point that invoked it is the file a manipulator is
39
+ * already editing. So the question is not asked only from `bin/aegiscode.js`:
40
+ * every module that OWNS one of the privileges this set protects asks it for
41
+ * itself — `gate.js` before it loads the gate, `mcp.js` before it touches a
42
+ * host's configuration, `autonomous.js` before it runs a queue with nobody
43
+ * watching, `permissions.js` before it resolves a skip. Deleting the call from
44
+ * the entry point stops the earliest refusal and leaves four behind, each of
45
+ * which lives in a file the digest above covers — so silencing them is not one
46
+ * edit but five, across five files, any one of which the other four notice.
47
+ *
48
+ * That is a real cost imposed on a careless patch and no obstacle at all to a
49
+ * deliberate one, and the difference is stated here rather than implied.
50
+ *
51
+ * A tree that is mid-edit trips this on purpose. Re-sealing is deliberate and
52
+ * manual: `node tools/provenance.mjs seal --write`. There is no environment
53
+ * variable that turns this off, because a gate with a documented off switch is
54
+ * a gate the manipulator reads about in the same file as the gate.
55
+ */
56
+
57
+ const { createHash } = require('node:crypto');
58
+ const { existsSync, readFileSync } = require('node:fs');
59
+ const path = require('node:path');
60
+
61
+ const PACKAGE_ROOT = path.join(__dirname, '..');
62
+
63
+ /** Domain separator, so this digest cannot be confused with the manifest's. */
64
+ const SALT = 'aegiscode-interlock-v1';
65
+ /** Pad derivation, so the sealed value is not a plain digest of the set. */
66
+ const PAD = 'aegis-interlock-pad-v1';
67
+
68
+ const sha256 = (data) => createHash('sha256').update(data).digest('hex');
69
+ const PAD_HEX = sha256(PAD);
70
+
71
+ /** Nibble-wise XOR against the derived pad; self-inverse. */
72
+ function unmask(sealed) {
73
+ let out = '';
74
+ for (let i = 0; i < sealed.length; i++) {
75
+ const a = parseInt(sealed[i], 16);
76
+ const b = parseInt(PAD_HEX[i % PAD_HEX.length], 16);
77
+ if (Number.isNaN(a) || Number.isNaN(b)) return null;
78
+ out += (a ^ b).toString(16);
79
+ }
80
+ return out;
81
+ }
82
+
83
+ /**
84
+ * The sealed set, base64 so a `cat` of this file is not a table of contents.
85
+ * Order is part of the digest: reordering is as detectable as editing.
86
+ * This file is deliberately NOT in its own set — the seal lives here, so
87
+ * including it would make the digest self-referential and unstable. It is
88
+ * covered by the published manifest instead (see src/provenance.js).
89
+ */
90
+ const UNITS = Object.freeze([
91
+ { id: 'p1', rel: Buffer.from('YmluL2FlZ2lzY29kZS5qcw==', 'base64').toString('utf8') },
92
+ { id: 'p2', rel: Buffer.from('c3JjL3Byb3ZlbmFuY2UuanM=', 'base64').toString('utf8') },
93
+ { id: 'p3', rel: Buffer.from('c3JjL2dhdGUuanM=', 'base64').toString('utf8') },
94
+ { id: 'p4', rel: Buffer.from('c3JjL3Blcm1pc3Npb25zLmpz', 'base64').toString('utf8') },
95
+ { id: 'p5', rel: Buffer.from('c3JjL2NhcHMuanM=', 'base64').toString('utf8') },
96
+ { id: 'p6', rel: Buffer.from('c3JjL2F1dG9ub21vdXMuanM=', 'base64').toString('utf8') },
97
+ { id: 'p8', rel: Buffer.from('c3JjL21jcC5qcw==', 'base64').toString('utf8') },
98
+ ]);
99
+
100
+ /**
101
+ * The masked digest of the sealed set. Rewritten ONLY by
102
+ * `node tools/provenance.mjs seal --write`, never by hand.
103
+ */
104
+ const SEALED = '400c9a8d7deb897b43ba3d993b4fff04d8d11e9426fef06141898b320ecff365';
105
+
106
+ /** Subcommands that a build failing this check does not get to run. */
107
+ const PRIVILEGED = Object.freeze(['gate', 'provenance', 'mcp']);
108
+
109
+ /**
110
+ * Ask the question. Never throws — a check that can break the program it is
111
+ * checking is a check an attacker would rather have present.
112
+ *
113
+ * @returns {{ tripped: boolean, code: string|null, units: number }}
114
+ */
115
+ function check() {
116
+ const parts = [];
117
+ for (const unit of UNITS) {
118
+ const abs = path.join(PACKAGE_ROOT, unit.rel);
119
+ if (!existsSync(abs)) return { tripped: true, code: 'p1', units: UNITS.length };
120
+ try {
121
+ parts.push(sha256(readFileSync(abs)));
122
+ } catch {
123
+ return { tripped: true, code: 'p1', units: UNITS.length };
124
+ }
125
+ }
126
+ const combined = sha256(`${SALT}\n${parts.join('\n')}`);
127
+ const sealed = typeof SEALED === 'string' ? SEALED.trim() : '';
128
+ if (sealed.length !== 64) return { tripped: true, code: 'p2', units: UNITS.length };
129
+ const expected = unmask(sealed);
130
+ if (expected !== combined) return { tripped: true, code: 'p3', units: UNITS.length };
131
+ return { tripped: false, code: null, units: UNITS.length };
132
+ }
133
+
134
+ /** The only sentence a failing build says about itself. Blunt, not a manual. */
135
+ function line(state) {
136
+ if (!state || !state.tripped) return null;
137
+ return `aegiscode: reduced mode (${state.code}) — this build is not the one that was published.\n`;
138
+ }
139
+
140
+ /**
141
+ * Ask once, remember the answer, and print the one bland line on the way.
142
+ *
143
+ * This is the entry point the modules that OWN a privilege call for themselves
144
+ * (see the header): `gate.js`, `mcp.js`, `autonomous.js`, `permissions.js`. It
145
+ * exists so the question is asked at each privilege rather than only once, at
146
+ * the top, in the file a manipulator is already editing.
147
+ *
148
+ * The answer is memoised for one process, and only so that four callers produce
149
+ * one sentence instead of four. It is NOT a cache an attacker can prime: the
150
+ * first caller computes it from the bytes on disk, and every later caller gets
151
+ * that verdict.
152
+ *
153
+ * It cannot throw — a gate that can break the program it guards is a gate an
154
+ * attacker would rather have present (see `check`).
155
+ *
156
+ * @returns {boolean} true when this build is not the published one.
157
+ */
158
+ let ARMED = null;
159
+ function armed() {
160
+ if (ARMED !== null) return ARMED;
161
+ let state;
162
+ try {
163
+ state = check();
164
+ } catch {
165
+ state = { tripped: true, code: 'p2', units: UNITS.length };
166
+ }
167
+ ARMED = Boolean(state.tripped);
168
+ if (ARMED) {
169
+ // The mark is the mechanism; the line is only its announcement.
170
+ process.env.AEGIS_REDUCED_MODE = '1';
171
+ const said = line(state);
172
+ if (said) process.stderr.write(said);
173
+ }
174
+ return ARMED;
175
+ }
176
+
177
+ function isPrivileged(command) {
178
+ return PRIVILEGED.includes(command);
179
+ }
180
+
181
+ /** A refused subcommand exits non-zero and says nothing further. */
182
+ function refuse() {
183
+ return 1;
184
+ }
185
+
186
+ /** The seal writer's half of the contract; the tool owns the mapping. */
187
+ function sealOf(files) {
188
+ const parts = files.map((abs) => sha256(readFileSync(abs)));
189
+ return sha256(`${SALT}\n${parts.join('\n')}`);
190
+ }
191
+
192
+ module.exports = { UNITS, PRIVILEGED, SALT, PAD, check, armed, line, isPrivileged, refuse, sealOf, mask: (hex) => unmask(hex) };
package/src/markdown.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  // Minimal markdown → styled span lines, in the spirit of Claude Code's
package/src/mcp.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -44,6 +49,7 @@ const { spawn } = require('node:child_process');
44
49
  // uses to find the shared modules in both layouts (a source checkout and an
45
50
  // installed package), and `hosts/` is staged into the same vendor tree.
46
51
  const { resolveShared } = require('./sharedpaths.js');
52
+ const limits = require('./limits.js');
47
53
 
48
54
  const install = require(resolveShared(path.join('hosts', 'install.js')));
49
55
  const targets = require(resolveShared(path.join('hosts', 'targets.js')));
@@ -648,6 +654,13 @@ async function runMcpCommand(command, argv, io = {}) {
648
654
  const stderr = io.stderr || process.stderr;
649
655
  const out = { stdout, stderr };
650
656
 
657
+ // The interlock, asked here as well as at the entry point. This surface WRITES
658
+ // a host's own configuration files and spawns a server inside another
659
+ // program's process, so it is a privilege in its own right and it refuses on
660
+ // the same terms as `gate` (see src/limits.js). Before argv is even parsed: a
661
+ // refused command that parses first can still be read as a supported one.
662
+ if (limits.armed()) return limits.refuse();
663
+
651
664
  let opts;
652
665
  try {
653
666
  opts = parseFlags(argv || []);
package/src/models.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/naming.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/overlays.js CHANGED
@@ -126,7 +126,7 @@ function renderPalette(commands, state = {}, width = 80, height = 24) {
126
126
  lines.push([
127
127
  span(
128
128
  C.gray,
129
- ` type to filter ${GLYPH.bullet} enter to run ${GLYPH.bullet} esc to close`
129
+ ` type to filter ${GLYPH.bullet} shift+enter runs the top row ${GLYPH.bullet} enter runs ${GLYPH.bullet} esc closes`
130
130
  ),
131
131
  ]);
132
132
  return fit(lines, width);
@@ -209,7 +209,12 @@ function renderModelPicker(models, sel = 0, width = 80, height = 24, current = n
209
209
  }
210
210
  if (end < count) lines.push([span('', ' '), span(C.gray, `↓ ${count - end} more below`)]);
211
211
  lines.push(blank(width));
212
- lines.push([span('', ' '), span(C.gray, `arrow keys to navigate ${GLYPH.bullet} enter to select ${GLYPH.bullet} esc to cancel`)]);
212
+ // The shift chord is advertised only because it is handled now (chatflow's
213
+ // handleOverlayKey): shift+↑/↓ moves the highlight and pins that row in one
214
+ // keystroke, and shift+enter commits the row the highlight is on. The
215
+ // reference picker asked for a separate Enter every time and this hint said
216
+ // nothing about a way around it.
217
+ lines.push([span('', ' '), span(C.gray, `↑↓ navigate ${GLYPH.bullet} shift+↑↓ pins as it moves ${GLYPH.bullet} enter pins ${GLYPH.bullet} esc cancels`)]);
213
218
  return fit(lines, width);
214
219
  }
215
220
 
package/src/panels.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**
@@ -1,5 +1,26 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
8
+ // The silent gate, loaded directly rather than trusted to have been asked by
9
+ // somebody up the call stack. FAIL CLOSED if it cannot be loaded at all: a tree
10
+ // with no `src/limits.js` is a tree someone edited to remove the question, and
11
+ // "the checker is missing" must read as "not the published build" for the same
12
+ // reason `src/provenance.js` treats a missing manifest as a failure and not a
13
+ // pass. Note what this deliberately does NOT do: it never throws, and it never
14
+ // stops `resolveSkip` from returning a decision — it only ever takes the skip
15
+ // away, so the worst a broken gate can cause is a confirmation prompt.
16
+ const limits = (() => {
17
+ try {
18
+ return require('./limits.js');
19
+ } catch {
20
+ return { armed: () => true, refuse: () => 1, check: () => ({ tripped: true, code: 'p2', units: 0 }) };
21
+ }
22
+ })();
23
+
3
24
  /**
4
25
  * Real enforcement for the /permissions rules (src/config.js) in the
5
26
  * direct-provider tool loop. The `claude` CLI path already has its own real
@@ -172,6 +193,32 @@ const SKIP = Object.freeze({
172
193
 
173
194
  const isTruthyEnv = (v) => v !== undefined && SKIP.truthy.includes(String(v).trim().toLowerCase());
174
195
 
196
+ /**
197
+ * The mark an interlock-failed build carries (`AEGIS_REDUCED_MODE`, set in
198
+ * bin/aegiscode.js from src/limits.js). A build that is not the published one
199
+ * does not get to disarm the confirmation gate — from the flag, from the
200
+ * product env or from the CI env. That is the whole payoff of editing this
201
+ * file, so it is the one thing this file will not do when it is not itself.
202
+ *
203
+ * Read from the caller's env AND from process.env, because the two callers
204
+ * differ: `one/src/permissions.js` passes an env it assembled, and the mark is
205
+ * set on the process. Deliberately not documented anywhere a manipulator would
206
+ * read before deciding what to edit next.
207
+ *
208
+ * …and asked for directly, through `limits.armed()`, rather than only read off
209
+ * the environment. Reading the mark alone made this file's refusal depend on
210
+ * somebody else's call: delete the one line in `bin/aegiscode.js` that sets it
211
+ * and `--dangerously-skip-permissions` starts working again on a build that is
212
+ * not the published one. The question is now asked HERE, by the module that owns
213
+ * the privilege, and the answer is memoised in src/limits.js — so the same edit
214
+ * buys nothing, and a scrubbed `input.env` cannot spoof the answer either.
215
+ */
216
+ function reducedMode(input = {}) {
217
+ const env = input.env || {};
218
+ if (isTruthyEnv(env.AEGIS_REDUCED_MODE) || isTruthyEnv(process.env.AEGIS_REDUCED_MODE)) return true;
219
+ return limits.armed();
220
+ }
221
+
175
222
  /** Rule 5's warning, spelled once so both callers print the same sentence. */
176
223
  const SKIP_ENV_WARNING =
177
224
  `AEGIS_SKIP_PERMISSIONS is set but this session is interactive — ignoring it. ` +
@@ -183,7 +230,7 @@ const SKIP_ENV_WARNING =
183
230
  * @param {boolean} [input.flag] the flag was explicitly passed
184
231
  * @param {object} [input.env] environment to read (never mutated)
185
232
  * @param {boolean} [input.interactive] both stdio ends are a terminal
186
- * @returns {{skip: boolean, source: 'flag'|'product'|'env'|'env-ignored'|'none',
233
+ * @returns {{skip: boolean, source: 'flag'|'product'|'env'|'env-ignored'|'reduced'|'none',
187
234
  * flag: boolean, envSet: boolean, interactive: boolean,
188
235
  * warned: boolean, warning: string|null}}
189
236
  */
@@ -194,6 +241,14 @@ function resolveSkip(input = {}) {
194
241
  const envSet = isTruthyEnv(env[SKIP.env]);
195
242
  const productSet = isTruthyEnv(env[SKIP.productEnv]);
196
243
 
244
+ // A build that failed the interlock never skips, whatever it was asked: the
245
+ // flag and both env spellings are refused at the source, so the confirm gate
246
+ // is the one thing a modified build cannot switch off. Reported as its own
247
+ // source so a caller does not print "the user asked for this".
248
+ if (reducedMode(input)) {
249
+ return { skip: false, source: 'reduced', flag, envSet, interactive, warned: false, warning: null };
250
+ }
251
+
197
252
  // src: flag → product → env(non-interactive). No `catch`-all default that
198
253
  // could skip: every other path returns skip: false.
199
254
  if (flag || productSet) {
package/src/ping.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**
package/src/presence.js CHANGED
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
+ // Conveying a modified copy, or running one as a network service, owes the
5
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
1
6
  'use strict';
2
7
 
3
8
  /**