aegisone 1.0.33 → 1.0.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.
Files changed (226) hide show
  1. package/README.md +1 -1
  2. package/bin/aegis.js +322 -1
  3. package/package.json +5 -4
  4. package/scripts/bump.mjs +211 -1
  5. package/scripts/bundle.js +129 -1
  6. package/scripts/predist.mjs +976 -1
  7. package/src/child.js +285 -1
  8. package/src/dispatch.js +269 -1
  9. package/src/doctor.js +639 -1
  10. package/src/host.js +111 -1
  11. package/src/permissions.js +383 -1
  12. package/src/probes.js +159 -1
  13. package/src/release.js +409 -1
  14. package/vendor/cli/package.json +7 -3
  15. package/vendor/cli/scripts/check.mjs +52 -1
  16. package/vendor/cli/scripts/demo.mjs +94 -1
  17. package/vendor/cli/scripts/predist.mjs +75 -1
  18. package/vendor/cli/scripts/runtests.mjs +56 -1
  19. package/vendor/cli/scripts/seal-gate.mjs +74 -1
  20. package/vendor/cli/src/agents.js +139 -1
  21. package/vendor/cli/src/app.js +2957 -1
  22. package/vendor/cli/src/art.js +289 -1
  23. package/vendor/cli/src/chatflow.js +3023 -1
  24. package/vendor/cli/src/checkpoint.js +90 -1
  25. package/vendor/cli/src/clipboard.js +424 -1
  26. package/vendor/cli/src/cloudsync.js +528 -1
  27. package/vendor/cli/src/commands.js +4089 -1
  28. package/vendor/cli/src/config.js +581 -1
  29. package/vendor/cli/src/connect.js +349 -1
  30. package/vendor/cli/src/credentials.js +33 -1
  31. package/vendor/cli/src/deps.js +232 -1
  32. package/vendor/cli/src/devrun.js +187 -1
  33. package/vendor/cli/src/diff.js +333 -1
  34. package/vendor/cli/src/diffview.js +296 -1
  35. package/vendor/cli/src/engine.js +297 -1
  36. package/vendor/cli/src/entitlement.js +355 -1
  37. package/vendor/cli/src/events.js +707 -1
  38. package/vendor/cli/src/export.js +67 -1
  39. package/vendor/cli/src/filepreview.js +153 -1
  40. package/vendor/cli/src/fingerprint.js +592 -1
  41. package/vendor/cli/src/format.js +259 -1
  42. package/vendor/cli/src/fuzzy.js +119 -1
  43. package/vendor/cli/src/history.js +423 -1
  44. package/vendor/cli/src/init.js +175 -1
  45. package/vendor/cli/src/input.js +139 -1
  46. package/vendor/cli/src/keys.js +183 -1
  47. package/vendor/cli/src/markdown.js +306 -1
  48. package/vendor/cli/src/models.js +507 -1
  49. package/vendor/cli/src/naming.js +57 -1
  50. package/vendor/cli/src/overlays.js +462 -1
  51. package/vendor/cli/src/panels.js +1418 -1
  52. package/vendor/cli/src/ping.js +226 -1
  53. package/vendor/cli/src/presence.js +238 -1
  54. package/vendor/cli/src/render.js +516 -1
  55. package/vendor/cli/src/screen.js +518 -1
  56. package/vendor/cli/src/screens.js +896 -1
  57. package/vendor/cli/src/secret.js +59 -1
  58. package/vendor/cli/src/securefs.js +359 -1
  59. package/vendor/cli/src/settings.js +155 -1
  60. package/vendor/cli/src/shared.js +52 -1
  61. package/vendor/cli/src/sharedpaths.js +53 -1
  62. package/vendor/cli/src/signup.js +156 -1
  63. package/vendor/cli/src/summarize.js +95 -1
  64. package/vendor/cli/src/sysdiag.js +585 -1
  65. package/vendor/cli/src/system.js +40 -1
  66. package/vendor/cli/src/theme.js +570 -1
  67. package/vendor/cli/src/title.js +220 -1
  68. package/vendor/cli/src/todos.js +115 -1
  69. package/vendor/cli/src/tokens.js +263 -1
  70. package/vendor/cli/src/topup.js +210 -1
  71. package/vendor/cli/src/update.js +191 -1
  72. package/vendor/cli/vendor/client/aegis.js +2441 -1
  73. package/vendor/cli/vendor/client/attest.js +518 -1
  74. package/vendor/cli/vendor/client/authorship-key.js +410 -1
  75. package/vendor/cli/vendor/client/auto-provision.js +134 -1
  76. package/vendor/cli/vendor/client/brain-catalog.js +268 -1
  77. package/vendor/cli/vendor/client/byok-catalog.js +199 -1
  78. package/vendor/cli/vendor/client/catalog-client.js +487 -1
  79. package/vendor/cli/vendor/client/conversation-export.js +177 -1
  80. package/vendor/cli/vendor/client/credentials.js +494 -1
  81. package/vendor/cli/vendor/client/device-fingerprint.js +141 -1
  82. package/vendor/cli/vendor/client/drive-connect.js +110 -1
  83. package/vendor/cli/vendor/client/drive-upload.js +234 -1
  84. package/vendor/cli/vendor/client/env-file.js +1273 -1
  85. package/vendor/cli/vendor/client/fingerprint.js +1064 -1
  86. package/vendor/cli/vendor/client/foreign-memory.js +669 -1
  87. package/vendor/cli/vendor/client/google-signin.js +133 -1
  88. package/vendor/cli/vendor/client/hooks.js +430 -1
  89. package/vendor/cli/vendor/client/model-discovery.js +373 -1
  90. package/vendor/cli/vendor/client/naming.js +283 -1
  91. package/vendor/cli/vendor/client/platform.js +937 -1
  92. package/vendor/cli/vendor/client/prefs.js +351 -1
  93. package/vendor/cli/vendor/client/presence-constants.js +107 -1
  94. package/vendor/cli/vendor/client/presence.js +438 -1
  95. package/vendor/cli/vendor/client/record-vault.js +1055 -3
  96. package/vendor/cli/vendor/client/session-store.js +575 -1
  97. package/vendor/cli/vendor/client/topup.js +297 -1
  98. package/vendor/cli/vendor/client/touch.js +458 -1
  99. package/vendor/cli/vendor/client/update.js +763 -1
  100. package/vendor/cli/vendor/client/user-models.js +381 -1
  101. package/vendor/cli/vendor/desktop/lib/local/agents.js +105 -1
  102. package/vendor/cli/vendor/desktop/lib/local/attachments.js +276 -1
  103. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1045 -1
  104. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1028 -1
  105. package/vendor/cli/vendor/desktop/lib/local/context.js +125 -1
  106. package/vendor/cli/vendor/desktop/lib/local/engine.js +3666 -1
  107. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +660 -1
  108. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +228 -1
  109. package/vendor/cli/vendor/desktop/lib/local/local.js +2145 -1
  110. package/vendor/cli/vendor/desktop/lib/local/prompt.js +280 -1
  111. package/vendor/cli/vendor/desktop/lib/local/queue.js +560 -1
  112. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +238 -1
  113. package/vendor/cli/vendor/desktop/lib/local/spill.js +75 -1
  114. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +300 -1
  115. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +235 -1
  116. package/vendor/cli/vendor/desktop/lib/settings.js +890 -1
  117. package/vendor/cli/vendor/desktop/renderer/usage.js +1239 -1
  118. package/vendor/cli/vendor/hosts/install.js +638 -1
  119. package/vendor/cli/vendor/hosts/openai-shim.js +515 -1
  120. package/vendor/cli/vendor/hosts/spec.js +164 -1
  121. package/vendor/cli/vendor/hosts/targets.js +346 -1
  122. package/vendor/cli/vendor/mcp/server.js +221 -1
  123. package/vendor/cli/vendor/mcp/tools.js +408 -1
  124. package/vendor/cli/vendor/one/src/child.js +285 -1
  125. package/vendor/cli/vendor/one/src/permissions.js +383 -1
  126. package/vendor/desktop/bin/aegis.js +32 -1
  127. package/vendor/desktop/lib/account-key.js +56 -1
  128. package/vendor/desktop/lib/auto.js +461 -1
  129. package/vendor/desktop/lib/avatar/companion.js +698 -1
  130. package/vendor/desktop/lib/avatar/cosmetics.js +532 -1
  131. package/vendor/desktop/lib/avatar/events.js +344 -1
  132. package/vendor/desktop/lib/avatar/holder-turn.js +350 -1
  133. package/vendor/desktop/lib/avatar/holders.js +612 -1
  134. package/vendor/desktop/lib/avatar/identity.js +641 -1
  135. package/vendor/desktop/lib/avatar/level.js +368 -1
  136. package/vendor/desktop/lib/avatar/mirror.js +524 -1
  137. package/vendor/desktop/lib/avatar/persona.js +388 -1
  138. package/vendor/desktop/lib/avatar/profile.js +977 -1
  139. package/vendor/desktop/lib/avatar/register.js +307 -1
  140. package/vendor/desktop/lib/avatar/store.js +472 -1
  141. package/vendor/desktop/lib/avatar/tiers.js +38 -1
  142. package/vendor/desktop/lib/avatar/transfer.js +415 -1
  143. package/vendor/desktop/lib/avatar/turn.js +216 -1
  144. package/vendor/desktop/lib/avatar/voice.js +328 -1
  145. package/vendor/desktop/lib/avatar/xp.js +404 -1
  146. package/vendor/desktop/lib/deep-link.js +120 -1
  147. package/vendor/desktop/lib/fingerprint.js +347 -2
  148. package/vendor/desktop/lib/google-connect.js +323 -1
  149. package/vendor/desktop/lib/local/agents.js +105 -1
  150. package/vendor/desktop/lib/local/attachments.js +276 -1
  151. package/vendor/desktop/lib/local/autonomous.js +1045 -1
  152. package/vendor/desktop/lib/local/claude-pro.js +1028 -1
  153. package/vendor/desktop/lib/local/context.js +125 -1
  154. package/vendor/desktop/lib/local/engine.js +3666 -1
  155. package/vendor/desktop/lib/local/entitlement.js +660 -1
  156. package/vendor/desktop/lib/local/git-scope.js +228 -1
  157. package/vendor/desktop/lib/local/local.js +2145 -1
  158. package/vendor/desktop/lib/local/prompt.js +280 -1
  159. package/vendor/desktop/lib/local/queue.js +560 -1
  160. package/vendor/desktop/lib/local/session-rounds.js +238 -1
  161. package/vendor/desktop/lib/local/spill.js +75 -1
  162. package/vendor/desktop/lib/local/telemetry.js +470 -1
  163. package/vendor/desktop/lib/local/turn-guard.js +300 -1
  164. package/vendor/desktop/lib/local/worktree-lock.js +235 -1
  165. package/vendor/desktop/lib/provider-key-mirror.js +252 -1
  166. package/vendor/desktop/lib/quick-launcher.js +84 -1
  167. package/vendor/desktop/lib/settings.js +890 -1
  168. package/vendor/desktop/lib/sync/memory-queue.js +60 -1
  169. package/vendor/desktop/lib/sync/persist-gate.js +148 -1
  170. package/vendor/desktop/lib/sync/sessions.js +106 -1
  171. package/vendor/desktop/lib/window-state.js +66 -1
  172. package/vendor/desktop/package.json +5 -3
  173. package/vendor/desktop/preload.js +679 -1
  174. package/vendor/desktop/renderer/app.js +7250 -1
  175. package/vendor/desktop/renderer/avatar/assemble.js +335 -1
  176. package/vendor/desktop/renderer/avatar/avatar.js +380 -1
  177. package/vendor/desktop/renderer/avatar/cards.js +141 -1
  178. package/vendor/desktop/renderer/avatar/hud.js +206 -1
  179. package/vendor/desktop/renderer/avatar/machine.js +213 -1
  180. package/vendor/desktop/renderer/avatar/pane.js +439 -1
  181. package/vendor/desktop/renderer/avatar/parts.js +437 -1
  182. package/vendor/desktop/renderer/budget.js +172 -1
  183. package/vendor/desktop/renderer/companion.js +223 -1
  184. package/vendor/desktop/renderer/diff.js +359 -1
  185. package/vendor/desktop/renderer/diffview.js +336 -1
  186. package/vendor/desktop/renderer/filepreview.js +211 -1
  187. package/vendor/desktop/renderer/fingerprint.js +789 -3
  188. package/vendor/desktop/renderer/markdown.js +168 -1
  189. package/vendor/desktop/renderer/provider-mark.js +311 -1
  190. package/vendor/desktop/renderer/provider-toolbar.js +134 -1
  191. package/vendor/desktop/renderer/providers.js +259 -1
  192. package/vendor/desktop/renderer/quick.js +285 -1
  193. package/vendor/desktop/renderer/stream-policy.js +387 -1
  194. package/vendor/desktop/renderer/transcript-view.js +323 -1
  195. package/vendor/desktop/renderer/usage.js +1239 -1
  196. package/vendor/desktop/vendor/aegis.js +2441 -1
  197. package/vendor/desktop/vendor/attest.js +518 -1
  198. package/vendor/desktop/vendor/authorship-key.js +410 -1
  199. package/vendor/desktop/vendor/auto-provision.js +134 -1
  200. package/vendor/desktop/vendor/brain-catalog.js +268 -1
  201. package/vendor/desktop/vendor/byok-catalog.js +199 -1
  202. package/vendor/desktop/vendor/catalog-client.js +487 -1
  203. package/vendor/desktop/vendor/conversation-export.js +177 -1
  204. package/vendor/desktop/vendor/credentials.js +494 -1
  205. package/vendor/desktop/vendor/device-fingerprint.js +141 -1
  206. package/vendor/desktop/vendor/drive-connect.js +110 -1
  207. package/vendor/desktop/vendor/drive-upload.js +234 -1
  208. package/vendor/desktop/vendor/env-file.js +1273 -1
  209. package/vendor/desktop/vendor/fingerprint.js +1064 -1
  210. package/vendor/desktop/vendor/foreign-memory.js +669 -1
  211. package/vendor/desktop/vendor/google-signin.js +133 -1
  212. package/vendor/desktop/vendor/hooks.js +430 -1
  213. package/vendor/desktop/vendor/model-discovery.js +373 -1
  214. package/vendor/desktop/vendor/naming.js +283 -1
  215. package/vendor/desktop/vendor/platform.js +937 -1
  216. package/vendor/desktop/vendor/prefs.js +351 -1
  217. package/vendor/desktop/vendor/presence-constants.js +107 -1
  218. package/vendor/desktop/vendor/presence.js +438 -1
  219. package/vendor/desktop/vendor/record-vault.js +1055 -3
  220. package/vendor/desktop/vendor/session-store.js +575 -1
  221. package/vendor/desktop/vendor/topup.js +297 -1
  222. package/vendor/desktop/vendor/touch.js +458 -1
  223. package/vendor/desktop/vendor/update.js +763 -1
  224. package/vendor/desktop/vendor/user-models.js +381 -1
  225. package/LICENSE +0 -661
  226. package/SOURCE-OFFER.txt +0 -9
package/src/release.js CHANGED
@@ -1,3 +1,411 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- "use strict";const FACE_LINES=Object.freeze([Object.freeze({dir:"cli",package:"aegiscode",line:Object.freeze([7,0]),anchor:0}),Object.freeze({dir:"desktop",package:"aegis-desktop",line:Object.freeze([1,0]),anchor:0})]),ANCHOR_PRODUCT="1.0.8",MINOR_STRIDE=100,MAJOR_STRIDE=1e4,VERSION_RE=/^(\d+)\.(\d+)\.(\d+)$/;function parseVersion(e){const n=String(null==e?"":e).trim(),r=VERSION_RE.exec(n);if(!r)throw new Error(`${JSON.stringify(String(e))} is not a strict MAJOR.MINOR.PATCH version (prereleases and ranges are refused on purpose — see release.js)`);const t={major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),text:n};if(t.minor>=MINOR_STRIDE||t.patch>=MINOR_STRIDE)throw new Error(`${n}: minor and patch must stay under ${MINOR_STRIDE} for the face derivation to stay injective`);return t}function isVersion(e){return VERSION_RE.test(String(null==e?"":e).trim())}function releaseCounter(e){const n="string"==typeof e?parseVersion(e):e;return n.major*MAJOR_STRIDE+n.minor*MINOR_STRIDE+n.patch}const ANCHOR_COUNTER=releaseCounter("1.0.8");function deriveFaceVersion(e,n){const r=releaseCounter(e)-ANCHOR_COUNTER,t=n.anchor+r;if(t<n.anchor)throw new Error(`product ${e} would move ${n.package} backwards (${n.line.join(".")}.${t} < published ${n.line.join(".")}.${n.anchor})`);if(!Number.isSafeInteger(t))throw new Error(`product ${e} overflows the ${n.package} patch counter`);return`${n.line[0]}.${n.line[1]}.${t}`}function deriveFaceVersions(e){const n={};for(const r of FACE_LINES)n[r.package]=Object.freeze({package:r.package,dir:r.dir,version:deriveFaceVersion(e,r)});return n}function tagFor(e){return"v"+parseVersion(e).text}function parseTag(e){const n=String(null==e?"":e).trim(),r=n.startsWith("refs/tags/")?n.slice(10):n;if(!r.startsWith("v"))throw new Error(`${JSON.stringify(n)} is not a release tag — expected vMAJOR.MINOR.PATCH`);return parseVersion(r.slice(1)).text}function nextVersion(e,n){const r=parseVersion(e),t=String(null==n?"":n).trim();if("major"===t)return`${r.major+1}.0.0`;if("minor"===t)return`${r.major}.${r.minor+1}.0`;if("patch"===t)return`${r.major}.${r.minor}.${r.patch+1}`;const o=parseVersion(t).text;if(releaseCounter(o)<=releaseCounter(r))throw new Error(`${o} is not newer than ${r.text} — a released version is never rewritten`);return o}function versionRequest(e){const n=(Array.isArray(e)?e:[]).map(String);if(0===n.length)return null;const r=new Set(["--version","-v","--verbose"]);return n.some((e=>!r.has(e)))?null:n.includes("--version")||n.includes("-v")?{verbose:n.includes("--verbose")}:null}function renderVersion(e){const n=e||{},r=[parseVersion((n.product||{}).version).text];for(const e of n.faces||[])r.push(e&&e.version?`${e.package} ${e.version}`:`${e&&e.package} unknown (no manifest beside this package)`);return r.join("\n")+"\n"}const README_VERSION_RE=/^(Product version: \*\*)(\d+\.\d+\.\d+)(\*\*.*)$/m;function setManifestVersion(e,n){const r=JSON.parse(e);if("string"!=typeof r.version||!isVersion(r.version))throw new Error("that package.json has no usable `version` field");return r.version=parseVersion(n).text,JSON.stringify(r,null,2)+"\n"}function setReadmeVersion(e,n){if(!README_VERSION_RE.test(e))throw new Error('the product README has no "Product version: **X.Y.Z**" line for the bump to maintain');return e.replace(README_VERSION_RE,((e,r,t,o)=>r+parseVersion(n).text+o))}function planBump(e){const n=e||{},r=parseVersion(n.version).text;return(n.documents||[]).map((e=>{const n=parseVersion(e.version||r).text,t=e.content;let o;if("json"===e.kind){const r=JSON.parse(t).version;return r===n?{file:e.file,kind:e.kind,from:r,to:n,before:t,content:t,unchanged:!0}:(o=setManifestVersion(t,n),{file:e.file,kind:e.kind,from:r,to:n,before:t,content:o,unchanged:!1})}if("readme"===e.kind){const r=README_VERSION_RE.exec(t);if(!r)throw new Error(`${e.file} has no version line for the bump to maintain`);const o=r[2];return o===n?{file:e.file,kind:e.kind,from:o,to:n,before:t,content:t,unchanged:!0}:{file:e.file,kind:e.kind,from:o,to:n,before:t,content:setReadmeVersion(t,n),unchanged:!1}}throw new Error(`${e.file}: unknown document kind ${JSON.stringify(e.kind)}`)}))}function unifiedDiff(e,n,r){if(e===n)return"";const t=e.split("\n"),o=n.split("\n");let i=0;for(;i<t.length&&i<o.length&&t[i]===o[i];)i++;let s=0;for(;s<t.length-i&&s<o.length-i&&t[t.length-1-s]===o[o.length-1-s];)s++;const a=t.slice(i,t.length-s),c=o.slice(i,o.length-s),f=Math.max(0,i-3),u=Math.min(t.length,t.length-s+3),l=Math.min(o.length,o.length-s+3),d=t.slice(f,u),p=(o.slice(f,l),[`--- a/${r}`,`+++ b/${r}`,`@@ -${f+1},${u-f} +${f+1},${l-f} @@`]);for(const e of d.slice(0,i-f))p.push(" "+e);for(const e of a)p.push("-"+e);for(const e of c)p.push("+"+e);const R=d.slice(i-f+a.length);for(const e of R)p.push(" "+e);return p.join("\n")+"\n"}module.exports={FACE_LINES:FACE_LINES,ANCHOR_PRODUCT:"1.0.8",MINOR_STRIDE:MINOR_STRIDE,MAJOR_STRIDE:MAJOR_STRIDE,parseVersion:parseVersion,isVersion:isVersion,releaseCounter:releaseCounter,deriveFaceVersion:deriveFaceVersion,deriveFaceVersions:deriveFaceVersions,tagFor:tagFor,parseTag:parseTag,nextVersion:nextVersion,versionRequest:versionRequest,renderVersion:renderVersion,planBump:planBump,setManifestVersion:setManifestVersion,setReadmeVersion:setReadmeVersion,unifiedDiff:unifiedDiff,README_VERSION_RE:README_VERSION_RE};
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
+ * AEGISONE — one product version, two derived face versions (plan D4).
10
+ *
11
+ * The rule this file exists to enforce: **the product version is written down
12
+ * once, and every other version in the tree is computed from it.** Before ON3,
13
+ * a release was three hand-typed numbers in one commit (`chore(release):
14
+ * aegis-desktop 0.8.28, aegiscode 6.8.30`) held together by discipline, not by
15
+ * anything that could fail. This module is the arithmetic; `one/scripts/bump.mjs`
16
+ * is the only writer; `test/one-version.test.mjs` is the assertion that the
17
+ * manifests in the tree still equal what this file computes for the product
18
+ * version they carry.
19
+ *
20
+ * Two rules from D4 that constrain the derivation, both user-visible:
21
+ *
22
+ * 1. **The face LINES do not move.** `aegiscode` stays on `6.8.x` and
23
+ * `aegis-desktop` stays on `0.8.x`, because installed apps and their
24
+ * auto-update channels are pinned to those lines. The product version
25
+ * `1.0.0` therefore cannot simply BE the face version.
26
+ * 2. **No face may move backwards, and no product release may be reordered.**
27
+ * Each face's patch counter is anchored at its published version for the
28
+ * product's first release (`6.8.30` / `0.8.28` at product `1.0.0` — the
29
+ * versions the last hand-typed release commit shipped) and advances by the
30
+ * *flattened product counter*, one product patch == one face patch, one
31
+ * product minor == 100 face patches, one product major == 10000. So the
32
+ * face numbers stay recognisable AND the mapping is total and monotonic:
33
+ * two different product versions can never produce the same face version,
34
+ * and a bump can never publish a lower version than the registry has.
35
+ *
36
+ * Everything here is pure: it takes versions and file CONTENTS and returns
37
+ * values and new contents. No fs, no process, no clock — `bump.mjs` owns the
38
+ * IO, so the whole bump can be asserted without touching a file.
39
+ *
40
+ * Standing rule for `one/` (Phase 30.1): nothing at module scope touches the
41
+ * process, and nothing here branches on an OS. This file reads neither.
42
+ */
43
+
44
+ /**
45
+ * The face packages, their unchanged lines, and their published anchor.
46
+ *
47
+ * `line` is the `major.minor` that must not move (D4 rule 1). `anchor` is the
48
+ * patch each face had published at `ANCHOR_PRODUCT` — the calibration point for
49
+ * the whole derivation.
50
+ *
51
+ * Re-anchored at product `1.0.8`: `aegiscode` graduates from the `6.8.x` line
52
+ * to `7.0.x` and `aegis-desktop` from `0.8.x` to `1.0.x`, both starting at
53
+ * patch 0 — a deliberate one-time line move, not a normal release. Nothing
54
+ * before this point is derivable under the new anchor (an older product
55
+ * version would compute a negative patch and `deriveFaceVersion` refuses it as
56
+ * "backwards"), which is correct: the old `6.8.x`/`0.8.x` history stays real,
57
+ * it is just not reachable through this formula anymore. A product version
58
+ * `>= 1.0.8` is unaffected either way, because the derivation only ever looks
59
+ * at the DELTA from the anchor, never at history before it.
60
+ */
61
+ const FACE_LINES = Object.freeze([
62
+ Object.freeze({ dir: 'cli', package: 'aegiscode', line: Object.freeze([7, 0]), anchor: 0 }),
63
+ Object.freeze({ dir: 'desktop', package: 'aegis-desktop', line: Object.freeze([1, 0]), anchor: 0 })
64
+ ]);
65
+
66
+ /** The product version the two anchors above were measured at. */
67
+ const ANCHOR_PRODUCT = '1.0.8';
68
+
69
+ /** One product minor reserves 100 face patches; one major reserves 10000. */
70
+ const MINOR_STRIDE = 100;
71
+ const MAJOR_STRIDE = 10000;
72
+
73
+ const VERSION_RE = /^(\d+)\.(\d+)\.(\d+)$/;
74
+
75
+ /**
76
+ * Parse a strict `X.Y.Z` version.
77
+ *
78
+ * A prerelease is REFUSED rather than carried: the face versions below have no
79
+ * honest spelling for one (`6.8.30-rc.1` would have to be invented per face and
80
+ * would land on the updater feeds of every installed app), so a prerelease
81
+ * product version fails here, loudly, instead of shipping a guess.
82
+ *
83
+ * @param {string} value
84
+ * @returns {{major: number, minor: number, patch: number, text: string}}
85
+ */
86
+ function parseVersion(value) {
87
+ const text = String(value == null ? '' : value).trim();
88
+ const m = VERSION_RE.exec(text);
89
+ if (!m) {
90
+ throw new Error(
91
+ `${JSON.stringify(String(value))} is not a strict MAJOR.MINOR.PATCH version ` +
92
+ '(prereleases and ranges are refused on purpose — see release.js)'
93
+ );
94
+ }
95
+ const parts = { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]), text };
96
+ // The flattening below is total only while minor and patch stay under their
97
+ // stride. Refusing the version is the fail-closed answer; silently colliding
98
+ // two releases onto one face version is not.
99
+ if (parts.minor >= MINOR_STRIDE || parts.patch >= MINOR_STRIDE) {
100
+ throw new Error(
101
+ `${text}: minor and patch must stay under ${MINOR_STRIDE} for the face derivation to stay injective`
102
+ );
103
+ }
104
+ return parts;
105
+ }
106
+
107
+ /** Does this look like a version at all? Never throws. */
108
+ function isVersion(value) {
109
+ return VERSION_RE.test(String(value == null ? '' : value).trim());
110
+ }
111
+
112
+ /**
113
+ * The product counter: a single strictly increasing integer for a version.
114
+ *
115
+ * `1.0.0` -> 10000, `1.0.1` -> 10001, `1.1.0` -> 10100, `2.0.0` -> 20000.
116
+ */
117
+ function releaseCounter(value) {
118
+ const v = typeof value === 'string' ? parseVersion(value) : value;
119
+ return v.major * MAJOR_STRIDE + v.minor * MINOR_STRIDE + v.patch;
120
+ }
121
+
122
+ const ANCHOR_COUNTER = releaseCounter(ANCHOR_PRODUCT);
123
+
124
+ /**
125
+ * The version a face must carry for a given product version.
126
+ *
127
+ * @param {string} productVersion
128
+ * @param {{dir: string, package: string, line: number[], anchor: number}} face
129
+ * @returns {string} e.g. `6.8.30` for `aegiscode` at product `1.0.0`
130
+ */
131
+ function deriveFaceVersion(productVersion, face) {
132
+ const delta = releaseCounter(productVersion) - ANCHOR_COUNTER;
133
+ const patch = face.anchor + delta;
134
+ if (patch < face.anchor) {
135
+ throw new Error(
136
+ `product ${productVersion} would move ${face.package} backwards ` +
137
+ `(${face.line.join('.')}.${patch} < published ${face.line.join('.')}.${face.anchor})`
138
+ );
139
+ }
140
+ if (!Number.isSafeInteger(patch)) {
141
+ throw new Error(`product ${productVersion} overflows the ${face.package} patch counter`);
142
+ }
143
+ return `${face.line[0]}.${face.line[1]}.${patch}`;
144
+ }
145
+
146
+ /**
147
+ * Every face version for a product version, keyed by npm package name.
148
+ *
149
+ * @param {string} productVersion
150
+ * @returns {Object<string, {package: string, dir: string, version: string}>}
151
+ */
152
+ function deriveFaceVersions(productVersion) {
153
+ const out = {};
154
+ for (const face of FACE_LINES) {
155
+ out[face.package] = Object.freeze({
156
+ package: face.package,
157
+ dir: face.dir,
158
+ version: deriveFaceVersion(productVersion, face)
159
+ });
160
+ }
161
+ return out;
162
+ }
163
+
164
+ /** The tag a product version ships as. */
165
+ function tagFor(productVersion) {
166
+ return 'v' + parseVersion(productVersion).text;
167
+ }
168
+
169
+ /**
170
+ * Read a version out of a tag or a GitHub ref.
171
+ *
172
+ * Accepts `v1.0.1` and `refs/tags/v1.0.1`; refuses `1.0.1` and `v1.0` — a
173
+ * release that cannot name its tag is a release that cannot be verified.
174
+ */
175
+ function parseTag(tag) {
176
+ const raw = String(tag == null ? '' : tag).trim();
177
+ const stripped = raw.startsWith('refs/tags/') ? raw.slice('refs/tags/'.length) : raw;
178
+ if (!stripped.startsWith('v')) {
179
+ throw new Error(`${JSON.stringify(raw)} is not a release tag — expected vMAJOR.MINOR.PATCH`);
180
+ }
181
+ return parseVersion(stripped.slice(1)).text;
182
+ }
183
+
184
+ /**
185
+ * The next product version.
186
+ *
187
+ * @param {string} current
188
+ * @param {string} kind `major` | `minor` | `patch` | an explicit `X.Y.Z`
189
+ * @returns {string}
190
+ */
191
+ function nextVersion(current, kind) {
192
+ const from = parseVersion(current);
193
+ const word = String(kind == null ? '' : kind).trim();
194
+ if (word === 'major') return `${from.major + 1}.0.0`;
195
+ if (word === 'minor') return `${from.major}.${from.minor + 1}.0`;
196
+ if (word === 'patch') return `${from.major}.${from.minor}.${from.patch + 1}`;
197
+ const next = parseVersion(word).text;
198
+ if (releaseCounter(next) <= releaseCounter(from)) {
199
+ throw new Error(`${next} is not newer than ${from.text} — a released version is never rewritten`);
200
+ }
201
+ return next;
202
+ }
203
+
204
+ // ---------------------------------------------------------------------------
205
+ // The version request (`aegis --version`, `aegis --version --verbose`)
206
+ // ---------------------------------------------------------------------------
207
+
208
+ /**
209
+ * Is this argv asking for the product version?
210
+ *
211
+ * Deliberately narrow: the ONLY accepted shapes are `--version` (or `-v`), with
212
+ * an optional `--verbose`. Anything else — a prompt, `-p`, a verb — returns
213
+ * null and takes the ordinary dispatch path, because `aegis --version` must not
214
+ * be able to swallow an argument somebody meant.
215
+ *
216
+ * @param {string[]} argv
217
+ * @returns {{verbose: boolean}|null}
218
+ */
219
+ function versionRequest(argv) {
220
+ const args = (Array.isArray(argv) ? argv : []).map(String);
221
+ if (args.length === 0) return null;
222
+ const allowed = new Set(['--version', '-v', '--verbose']);
223
+ if (args.some((a) => !allowed.has(a))) return null;
224
+ if (!args.includes('--version') && !args.includes('-v')) return null;
225
+ return { verbose: args.includes('--verbose') };
226
+ }
227
+
228
+ /**
229
+ * Render the version report.
230
+ *
231
+ * The first line is the bare product version, matching the terminal face's own
232
+ * `--version` (cli/bin/aegiscode.js writes `pkg.version` and nothing else), so
233
+ * `aegis --version` and `aegiscode --version` agree on line one and scripts
234
+ * that parse either keep working. `--verbose` adds one line per face; a face
235
+ * whose manifest is not beside the product is reported as unknown rather than
236
+ * guessed from the derivation, because this command reports facts.
237
+ *
238
+ * @param {{product: {name: string, version: string},
239
+ * faces?: Array<{package: string, version: string|null}>}} input
240
+ * @returns {string}
241
+ */
242
+ function renderVersion(input) {
243
+ const src = input || {};
244
+ const product = src.product || {};
245
+ const lines = [parseVersion(product.version).text];
246
+ for (const face of src.faces || []) {
247
+ lines.push(
248
+ face && face.version
249
+ ? `${face.package} ${face.version}`
250
+ : `${face && face.package} unknown (no manifest beside this package)`
251
+ );
252
+ }
253
+ return lines.join('\n') + '\n';
254
+ }
255
+
256
+ // ---------------------------------------------------------------------------
257
+ // The bump plan: pure content in, new content out
258
+ // ---------------------------------------------------------------------------
259
+
260
+ /** The README line the product version is written on. */
261
+ const README_VERSION_RE = /^(Product version: \*\*)(\d+\.\d+\.\d+)(\*\*.*)$/m;
262
+
263
+ /**
264
+ * Replace the `version` field of a package.json string, preserving everything
265
+ * else byte for byte (2-space indent, key order, trailing newline).
266
+ *
267
+ * @param {string} content
268
+ * @param {string} version
269
+ * @returns {string}
270
+ */
271
+ function setManifestVersion(content, version) {
272
+ const parsed = JSON.parse(content);
273
+ if (typeof parsed.version !== 'string' || !isVersion(parsed.version)) {
274
+ throw new Error('that package.json has no usable `version` field');
275
+ }
276
+ parsed.version = parseVersion(version).text;
277
+ return JSON.stringify(parsed, null, 2) + '\n';
278
+ }
279
+
280
+ /** Replace the README's version line, or fail loudly if it is not there. */
281
+ function setReadmeVersion(content, version) {
282
+ if (!README_VERSION_RE.test(content)) {
283
+ throw new Error(
284
+ 'the product README has no "Product version: **X.Y.Z**" line for the bump to maintain'
285
+ );
286
+ }
287
+ return content.replace(README_VERSION_RE, (_, head, _old, tail) => head + parseVersion(version).text + tail);
288
+ }
289
+
290
+ /**
291
+ * The whole bump, computed from file contents.
292
+ *
293
+ * Each document names its OWN target version. That is not a convenience: the
294
+ * product manifest and the README take the product version, and each face takes
295
+ * the version `deriveFaceVersions` computes for it — one version is the source
296
+ * of truth, and a plan that writes the product number into a face manifest is
297
+ * the exact bug the first dry run of this function caught (the faces went to
298
+ * `1.0.1`; the derivation says `6.8.31` / `0.8.29`).
299
+ *
300
+ * @param {{version: string, documents: Array<{file: string, kind: string,
301
+ * content: string, version?: string}>}} input
302
+ * `kind` is `json` (a package.json) or `readme` (the product README);
303
+ * `version` defaults to the product version.
304
+ * @returns {Array<{file: string, kind: string, from: string|null, to: string,
305
+ * before: string, content: string, unchanged: boolean}>}
306
+ */
307
+ function planBump(input) {
308
+ const src = input || {};
309
+ const product = parseVersion(src.version).text;
310
+ return (src.documents || []).map((doc) => {
311
+ const version = parseVersion(doc.version || product).text;
312
+ const before = doc.content;
313
+ let after;
314
+ if (doc.kind === 'json') {
315
+ const current = JSON.parse(before).version;
316
+ if (current === version) {
317
+ return { file: doc.file, kind: doc.kind, from: current, to: version, before, content: before, unchanged: true };
318
+ }
319
+ after = setManifestVersion(before, version);
320
+ return { file: doc.file, kind: doc.kind, from: current, to: version, before, content: after, unchanged: false };
321
+ }
322
+ if (doc.kind === 'readme') {
323
+ const m = README_VERSION_RE.exec(before);
324
+ if (!m) throw new Error(`${doc.file} has no version line for the bump to maintain`);
325
+ const current = m[2];
326
+ if (current === version) {
327
+ return { file: doc.file, kind: doc.kind, from: current, to: version, before, content: before, unchanged: true };
328
+ }
329
+ return {
330
+ file: doc.file,
331
+ kind: doc.kind,
332
+ from: current,
333
+ to: version,
334
+ before,
335
+ content: setReadmeVersion(before, version),
336
+ unchanged: false
337
+ };
338
+ }
339
+ throw new Error(`${doc.file}: unknown document kind ${JSON.stringify(doc.kind)}`);
340
+ });
341
+ }
342
+
343
+ /**
344
+ * A unified diff of two texts, for `bump --dry-run`.
345
+ *
346
+ * One hunk per contiguous block of changed lines, with three lines of context —
347
+ * enough for a version bump, and small enough to read: the dry run exists to be
348
+ * pasted into a release review, not to be a diff engine.
349
+ *
350
+ * @param {string} before
351
+ * @param {string} after
352
+ * @param {string} file
353
+ * @returns {string} empty string when nothing changed
354
+ */
355
+ function unifiedDiff(before, after, file) {
356
+ if (before === after) return '';
357
+ const a = before.split('\n');
358
+ const b = after.split('\n');
359
+ let head = 0;
360
+ while (head < a.length && head < b.length && a[head] === b[head]) head++;
361
+ let tail = 0;
362
+ while (
363
+ tail < a.length - head &&
364
+ tail < b.length - head &&
365
+ a[a.length - 1 - tail] === b[b.length - 1 - tail]
366
+ ) {
367
+ tail++;
368
+ }
369
+ const aChanged = a.slice(head, a.length - tail);
370
+ const bChanged = b.slice(head, b.length - tail);
371
+ const context = 3;
372
+ const start = Math.max(0, head - context);
373
+ const aEnd = Math.min(a.length, a.length - tail + context);
374
+ const bEnd = Math.min(b.length, b.length - tail + context);
375
+ const aHunk = a.slice(start, aEnd);
376
+ const bHunk = b.slice(start, bEnd);
377
+ const aSpan = aEnd - start;
378
+ const bSpan = bEnd - start;
379
+ const out = [`--- a/${file}`, `+++ b/${file}`, `@@ -${start + 1},${aSpan} +${start + 1},${bSpan} @@`];
380
+ // Changed lines are emitted as a removal block then an addition block: a
381
+ // version bump rewrites lines, and a reviewer reading the dry run wants the
382
+ // before and the after plain, not interleaved.
383
+ for (const line of aHunk.slice(0, head - start)) out.push(' ' + line);
384
+ for (const line of aChanged) out.push('-' + line);
385
+ for (const line of bChanged) out.push('+' + line);
386
+ const trailing = aHunk.slice(head - start + aChanged.length);
387
+ for (const line of trailing) out.push(' ' + line);
388
+ return out.join('\n') + '\n';
389
+ }
390
+
391
+ module.exports = {
392
+ FACE_LINES,
393
+ ANCHOR_PRODUCT,
394
+ MINOR_STRIDE,
395
+ MAJOR_STRIDE,
396
+ parseVersion,
397
+ isVersion,
398
+ releaseCounter,
399
+ deriveFaceVersion,
400
+ deriveFaceVersions,
401
+ tagFor,
402
+ parseTag,
403
+ nextVersion,
404
+ versionRequest,
405
+ renderVersion,
406
+ planBump,
407
+ setManifestVersion,
408
+ setReadmeVersion,
409
+ unifiedDiff,
410
+ README_VERSION_RE
411
+ };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegiscode",
3
3
  "productName": "AEGIS Code",
4
- "version": "7.0.25",
4
+ "version": "7.0.28",
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",
@@ -18,15 +18,19 @@
18
18
  "src",
19
19
  "scripts",
20
20
  "vendor",
21
- "README.md",
22
- "SOURCE-OFFER.txt"
21
+ "README.md"
23
22
  ],
24
23
  "engines": {
25
24
  "node": ">=22.0.0"
26
25
  },
27
26
  "scripts": {
28
27
  "start": "node bin/aegiscode.js",
28
+ "predist": "node scripts/predist.mjs",
29
+ "prepack": "node scripts/predist.mjs --quiet",
30
+ "prepublishOnly": "npm run predist",
31
+ "precheck": "node scripts/predist.mjs",
29
32
  "check": "node scripts/check.mjs",
33
+ "pretest": "node scripts/predist.mjs",
30
34
  "test": "node scripts/runtests.mjs"
31
35
  },
32
36
  "keywords": [
@@ -1,4 +1,55 @@
1
1
  #!/usr/bin/env node
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
- import{readdirSync as s}from"node:fs";import{spawnSync as e}from"node:child_process";import{dirname as t,join as o,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";const c=t(i(import.meta.url)),n=r(c,".."),a=o(n,"src"),p=[o(n,"bin","aegiscode.js"),...s(a).filter((s=>s.endsWith(".js"))).sort().map((s=>o(a,s))),o(c,"predist.mjs")];0===p.length&&(process.stderr.write("check: no files to check\n"),process.exit(1));const d=[];for(const s of p){const t=e(process.execPath,["--check",s],{stdio:"inherit"});0!==t.status&&d.push({file:s,status:t.status})}if(d.length){process.stderr.write(`\ncheck failed (${d.length}):\n`);for(const{file:s,status:e}of d)process.stderr.write(` ✗ ${s} (exit ${e})\n`);process.exit(1)}process.stdout.write(`check ok: ${p.length} files\n`);
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
7
+ /**
8
+ * Syntax-check every file `node --check` should gate on, and report all of
9
+ * them. Replaces the POSIX loop
10
+ *
11
+ * for f in src/*.js; do node --check "$f" || exit 1; done
12
+ *
13
+ * which npm runs through ComSpec on Windows, where `for…do…done` is not shell
14
+ * syntax. A Node walker keeps `npm run check` identical on every OS, and — like
15
+ * `runtests.mjs` — collects failures instead of stopping at the first one, so
16
+ * one broken file cannot hide every file after it.
17
+ */
18
+ import { readdirSync } from 'node:fs';
19
+ import { spawnSync } from 'node:child_process';
20
+ import { dirname, join, resolve } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+
23
+ const here = dirname(fileURLToPath(import.meta.url));
24
+ const cliRoot = resolve(here, '..');
25
+ const srcDir = join(cliRoot, 'src');
26
+
27
+ const targets = [
28
+ join(cliRoot, 'bin', 'aegiscode.js'),
29
+ ...readdirSync(srcDir)
30
+ .filter((f) => f.endsWith('.js'))
31
+ .sort()
32
+ .map((f) => join(srcDir, f)),
33
+ join(here, 'predist.mjs'),
34
+ ];
35
+
36
+ if (targets.length === 0) {
37
+ process.stderr.write('check: no files to check\n');
38
+ process.exit(1);
39
+ }
40
+
41
+ const failed = [];
42
+ for (const file of targets) {
43
+ const res = spawnSync(process.execPath, ['--check', file], { stdio: 'inherit' });
44
+ if (res.status !== 0) failed.push({ file, status: res.status });
45
+ }
46
+
47
+ if (failed.length) {
48
+ process.stderr.write(`\ncheck failed (${failed.length}):\n`);
49
+ for (const { file, status } of failed) {
50
+ process.stderr.write(` \u2717 ${file} (exit ${status})\n`);
51
+ }
52
+ process.exit(1);
53
+ }
54
+
55
+ process.stdout.write(`check ok: ${targets.length} files\n`);
@@ -1,4 +1,97 @@
1
1
  #!/usr/bin/env node
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
4
- import{createRequire as e}from"node:module";import n from"node:path";import{fileURLToPath as r}from"node:url";const t=e(import.meta.url),s=n.dirname(r(import.meta.url)),o=n.join(s,"..","src"),i=t(n.join(o,"render.js")),{stripAnsi:a}=t(n.join(o,"screen.js")),d=t(n.join(o,"art.js")),{version:u}=t(n.join(s,"..","package.json")),l=process.argv.slice(2),m=Number(((e,n)=>{const r=l.indexOf("--width");return-1===r?0:l[r+1]})())||Math.min(96,Math.max(48,process.stdout.columns||84)),c={light:l.includes("--light")},g=l.includes("--plain"),p=[],h=e=>p.push(...Array.isArray(e)?e:[e]);h(i.renderBanner(c,{width:m,version:u,model:"nexus-brain",base:"https://aegiscloud.org",key:"aegis_••••4f2a",stream:!0})),h(""),h(i.renderTurn(c,{role:"user",text:"summarise what changed in the token accounting"},m)),h(i.renderTurn(c,{role:"assistant",text:["Three things changed, and one of them was costing you money:","","- the pool **merges** worker usage instead of overwriting it","- cache reads and writes are billed, not ignored","- a zero-token call no longer refunds its reservation","","```","merge_usage({input_tokens: 1250}, {output_tokens: 312})","=> 1562 total","```","","Use `/balance` to see tokens beside € on every row."].join("\n"),meta:{model:"nexus-brain",tokens:1562,usage:{input:1250,output:312},eur:7e-4,ms:4200,calls:4}},m)),h(""),h(i.renderWorking(c,{tick:3,verb:"Consulting",elapsedMs:2100})),h(i.renderStatus(c,{model:"nexus-brain",tokens:1562,spend:7e-4,mode:"stream"},m)),process.stdout.write((g?p.map(a):p).join("\n")+"\n\n"),g||process.stdout.write(a(`${d.WELCOME_TITLE} — ${p.length} lines rendered at ${m} cols${c.light?" (light)":""}\n`));
4
+ // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
5
+ // Conveying a modified copy, or running one as a network service, owes the
6
+ // corresponding source under this licence (§5/§13) — see LICENSING.md.
7
+ /**
8
+ * Renders a canned session to stdout — banner, a prompt, a streamed answer with
9
+ * markdown, the accounting line, and the status bar.
10
+ *
11
+ * No network and no key: this exists so the look can be reviewed (and pasted
12
+ * into docs) without a live account, and so a regression in the layout is
13
+ * visible to a human, not only to the width assertions in test/cli-render.
14
+ *
15
+ * node cli/scripts/demo.mjs [--light] [--width 84] [--plain]
16
+ */
17
+
18
+ import { createRequire } from 'node:module';
19
+ import path from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+
22
+ const require = createRequire(import.meta.url);
23
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
24
+ const src = path.join(__dirname, '..', 'src');
25
+
26
+ const render = require(path.join(src, 'render.js'));
27
+ const { stripAnsi } = require(path.join(src, 'screen.js'));
28
+ const art = require(path.join(src, 'art.js'));
29
+ // Read the version rather than hardcoding it — a demo that reports a stale
30
+ // version is the kind of drift nobody notices until it is in the docs.
31
+ const { version } = require(path.join(__dirname, '..', 'package.json'));
32
+
33
+ const argv = process.argv.slice(2);
34
+ const flag = (name, fallback) => {
35
+ const i = argv.indexOf(name);
36
+ return i === -1 ? fallback : argv[i + 1];
37
+ };
38
+ const width = Number(flag('--width', 0)) || Math.min(96, Math.max(48, process.stdout.columns || 84));
39
+ const ctx = { light: argv.includes('--light') };
40
+ const plain = argv.includes('--plain');
41
+
42
+ const out = [];
43
+ const push = (lines) => out.push(...(Array.isArray(lines) ? lines : [lines]));
44
+
45
+ push(
46
+ render.renderBanner(ctx, {
47
+ width,
48
+ version,
49
+ model: 'nexus-brain',
50
+ base: 'https://aegiscloud.org',
51
+ key: 'aegis_••••4f2a',
52
+ stream: true,
53
+ })
54
+ );
55
+ push('');
56
+ push(render.renderTurn(ctx, { role: 'user', text: 'summarise what changed in the token accounting' }, width));
57
+ push(
58
+ render.renderTurn(
59
+ ctx,
60
+ {
61
+ role: 'assistant',
62
+ text: [
63
+ 'Three things changed, and one of them was costing you money:',
64
+ '',
65
+ '- the pool **merges** worker usage instead of overwriting it',
66
+ '- cache reads and writes are billed, not ignored',
67
+ '- a zero-token call no longer refunds its reservation',
68
+ '',
69
+ '```',
70
+ 'merge_usage({input_tokens: 1250}, {output_tokens: 312})',
71
+ '=> 1562 total',
72
+ '```',
73
+ '',
74
+ 'Use `/balance` to see tokens beside € on every row.',
75
+ ].join('\n'),
76
+ meta: {
77
+ model: 'nexus-brain',
78
+ tokens: 1562,
79
+ usage: { input: 1250, output: 312 },
80
+ eur: 0.0007,
81
+ ms: 4200,
82
+ calls: 4,
83
+ },
84
+ },
85
+ width
86
+ )
87
+ );
88
+ push('');
89
+ push(render.renderWorking(ctx, { tick: 3, verb: 'Consulting', elapsedMs: 2100 }));
90
+ push(render.renderStatus(ctx, { model: 'nexus-brain', tokens: 1562, spend: 0.0007, mode: 'stream' }, width));
91
+
92
+ process.stdout.write((plain ? out.map(stripAnsi) : out).join('\n') + '\n\n');
93
+ if (!plain) {
94
+ process.stdout.write(
95
+ stripAnsi(`${art.WELCOME_TITLE} — ${out.length} lines rendered at ${width} cols${ctx.light ? ' (light)' : ''}\n`)
96
+ );
97
+ }