aegisone 0.0.0-stage → 1.0.3

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 (266) hide show
  1. package/README.md +98 -2
  2. package/bin/aegis.js +295 -0
  3. package/install.ps1 +151 -0
  4. package/install.sh +178 -0
  5. package/package.json +44 -4
  6. package/scripts/bump.mjs +184 -0
  7. package/scripts/bundle.js +126 -0
  8. package/scripts/predist.mjs +673 -0
  9. package/src/child.js +163 -0
  10. package/src/dispatch.js +265 -0
  11. package/src/doctor.js +636 -0
  12. package/src/host.js +108 -0
  13. package/src/permissions.js +239 -0
  14. package/src/probes.js +156 -0
  15. package/src/release.js +397 -0
  16. package/vendor/cli/LICENSE +661 -0
  17. package/vendor/cli/README.md +745 -0
  18. package/vendor/cli/bin/aegiscode.js +742 -0
  19. package/vendor/cli/package.json +42 -0
  20. package/vendor/cli/scripts/check.mjs +50 -0
  21. package/vendor/cli/scripts/demo.mjs +92 -0
  22. package/vendor/cli/scripts/predist.mjs +48 -0
  23. package/vendor/cli/scripts/runtests.mjs +54 -0
  24. package/vendor/cli/src/agents.js +136 -0
  25. package/vendor/cli/src/app.js +2164 -0
  26. package/vendor/cli/src/art.js +286 -0
  27. package/vendor/cli/src/autonomous.js +468 -0
  28. package/vendor/cli/src/caps.js +876 -0
  29. package/vendor/cli/src/chatflow.js +2389 -0
  30. package/vendor/cli/src/checkpoint.js +87 -0
  31. package/vendor/cli/src/clipboard.js +421 -0
  32. package/vendor/cli/src/cloudsync.js +525 -0
  33. package/vendor/cli/src/commands.js +3014 -0
  34. package/vendor/cli/src/config.js +527 -0
  35. package/vendor/cli/src/credentials.js +30 -0
  36. package/vendor/cli/src/deps.js +106 -0
  37. package/vendor/cli/src/devrun.js +184 -0
  38. package/vendor/cli/src/diff.js +330 -0
  39. package/vendor/cli/src/diffview.js +293 -0
  40. package/vendor/cli/src/engine.js +142 -0
  41. package/vendor/cli/src/entitlement.js +320 -0
  42. package/vendor/cli/src/events.js +694 -0
  43. package/vendor/cli/src/export.js +64 -0
  44. package/vendor/cli/src/fingerprint.js +559 -0
  45. package/vendor/cli/src/format.js +84 -0
  46. package/vendor/cli/src/fuzzy.js +116 -0
  47. package/vendor/cli/src/gate.js +45 -0
  48. package/vendor/cli/src/history.js +398 -0
  49. package/vendor/cli/src/init.js +172 -0
  50. package/vendor/cli/src/input.js +136 -0
  51. package/vendor/cli/src/keys.js +153 -0
  52. package/vendor/cli/src/markdown.js +303 -0
  53. package/vendor/cli/src/mcp.js +683 -0
  54. package/vendor/cli/src/models.js +409 -0
  55. package/vendor/cli/src/naming.js +226 -0
  56. package/vendor/cli/src/overlays.js +338 -0
  57. package/vendor/cli/src/panels.js +1402 -0
  58. package/vendor/cli/src/permissions.js +237 -0
  59. package/vendor/cli/src/ping.js +223 -0
  60. package/vendor/cli/src/presence.js +235 -0
  61. package/vendor/cli/src/render.js +469 -0
  62. package/vendor/cli/src/screen.js +504 -0
  63. package/vendor/cli/src/screens.js +776 -0
  64. package/vendor/cli/src/secret.js +56 -0
  65. package/vendor/cli/src/securefs.js +356 -0
  66. package/vendor/cli/src/settings.js +152 -0
  67. package/vendor/cli/src/shared.js +49 -0
  68. package/vendor/cli/src/sharedpaths.js +50 -0
  69. package/vendor/cli/src/signup.js +153 -0
  70. package/vendor/cli/src/summarize.js +92 -0
  71. package/vendor/cli/src/system.js +37 -0
  72. package/vendor/cli/src/theme.js +567 -0
  73. package/vendor/cli/src/title.js +217 -0
  74. package/vendor/cli/src/todos.js +109 -0
  75. package/vendor/cli/src/tokens.js +230 -0
  76. package/vendor/cli/src/topup.js +207 -0
  77. package/vendor/cli/src/update.js +87 -0
  78. package/vendor/cli/vendor/client/aegis.js +1738 -0
  79. package/vendor/cli/vendor/client/attest.js +439 -0
  80. package/vendor/cli/vendor/client/authorship-key.js +407 -0
  81. package/vendor/cli/vendor/client/auto-provision.js +52 -0
  82. package/vendor/cli/vendor/client/brain-catalog.js +265 -0
  83. package/vendor/cli/vendor/client/byok-catalog.js +192 -0
  84. package/vendor/cli/vendor/client/credentials.js +478 -0
  85. package/vendor/cli/vendor/client/device-fingerprint.js +145 -0
  86. package/vendor/cli/vendor/client/env-file.js +1016 -0
  87. package/vendor/cli/vendor/client/fingerprint.js +1061 -0
  88. package/vendor/cli/vendor/client/foreign-memory.js +666 -0
  89. package/vendor/cli/vendor/client/hooks.js +427 -0
  90. package/vendor/cli/vendor/client/platform.js +934 -0
  91. package/vendor/cli/vendor/client/prefs.js +348 -0
  92. package/vendor/cli/vendor/client/presence-constants.js +104 -0
  93. package/vendor/cli/vendor/client/presence.js +435 -0
  94. package/vendor/cli/vendor/client/record-vault.js +834 -0
  95. package/vendor/cli/vendor/client/session-store.js +545 -0
  96. package/vendor/cli/vendor/client/topup.js +294 -0
  97. package/vendor/cli/vendor/client/touch.js +455 -0
  98. package/vendor/cli/vendor/client/update.js +343 -0
  99. package/vendor/cli/vendor/covenant/README.md +21 -0
  100. package/vendor/cli/vendor/covenant/aegis.seal +177 -0
  101. package/vendor/cli/vendor/desktop/lib/local/aegis-seal.mjs +236 -0
  102. package/vendor/cli/vendor/desktop/lib/local/agents.js +102 -0
  103. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +921 -0
  104. package/vendor/cli/vendor/desktop/lib/local/context.js +92 -0
  105. package/vendor/cli/vendor/desktop/lib/local/covenant.js +562 -0
  106. package/vendor/cli/vendor/desktop/lib/local/engine.js +2155 -0
  107. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +568 -0
  108. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +225 -0
  109. package/vendor/cli/vendor/desktop/lib/local/local.js +2132 -0
  110. package/vendor/cli/vendor/desktop/lib/local/prompt.js +242 -0
  111. package/vendor/cli/vendor/desktop/lib/local/queue.js +557 -0
  112. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +205 -0
  113. package/vendor/cli/vendor/desktop/lib/local/shell.js +603 -0
  114. package/vendor/cli/vendor/desktop/lib/local/tools.js +1197 -0
  115. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +297 -0
  116. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +232 -0
  117. package/vendor/cli/vendor/desktop/lib/settings.js +846 -0
  118. package/vendor/cli/vendor/desktop/renderer/usage.js +964 -0
  119. package/vendor/cli/vendor/hosts/install.js +638 -0
  120. package/vendor/cli/vendor/hosts/openai-shim.js +516 -0
  121. package/vendor/cli/vendor/hosts/spec.js +164 -0
  122. package/vendor/cli/vendor/hosts/targets.js +346 -0
  123. package/vendor/cli/vendor/mcp/server.js +217 -0
  124. package/vendor/cli/vendor/mcp/tools.js +405 -0
  125. package/vendor/cli/vendor/tools/agent-gate.mjs +1180 -0
  126. package/vendor/desktop/README.md +365 -0
  127. package/vendor/desktop/bin/aegis.js +30 -0
  128. package/vendor/desktop/lib/auto.js +423 -0
  129. package/vendor/desktop/lib/avatar/companion.js +695 -0
  130. package/vendor/desktop/lib/avatar/cosmetics.js +529 -0
  131. package/vendor/desktop/lib/avatar/events.js +341 -0
  132. package/vendor/desktop/lib/avatar/holder-turn.js +347 -0
  133. package/vendor/desktop/lib/avatar/holders.js +609 -0
  134. package/vendor/desktop/lib/avatar/identity.js +638 -0
  135. package/vendor/desktop/lib/avatar/level.js +365 -0
  136. package/vendor/desktop/lib/avatar/mirror.js +521 -0
  137. package/vendor/desktop/lib/avatar/packs/README.md +47 -0
  138. package/vendor/desktop/lib/avatar/packs/core-wardrobe.pack.json +15 -0
  139. package/vendor/desktop/lib/avatar/packs/local-voice-core.pack.json +16 -0
  140. package/vendor/desktop/lib/avatar/packs/seasonal-winter.pack.json +14 -0
  141. package/vendor/desktop/lib/avatar/persona.js +385 -0
  142. package/vendor/desktop/lib/avatar/profile.js +974 -0
  143. package/vendor/desktop/lib/avatar/register.js +304 -0
  144. package/vendor/desktop/lib/avatar/store.js +469 -0
  145. package/vendor/desktop/lib/avatar/tiers.js +35 -0
  146. package/vendor/desktop/lib/avatar/transfer.js +412 -0
  147. package/vendor/desktop/lib/avatar/turn.js +213 -0
  148. package/vendor/desktop/lib/avatar/voice.js +325 -0
  149. package/vendor/desktop/lib/avatar/xp.js +401 -0
  150. package/vendor/desktop/lib/deep-link.js +83 -0
  151. package/vendor/desktop/lib/fingerprint.js +327 -0
  152. package/vendor/desktop/lib/local/aegis-seal.mjs +236 -0
  153. package/vendor/desktop/lib/local/agents.js +102 -0
  154. package/vendor/desktop/lib/local/autonomous.js +921 -0
  155. package/vendor/desktop/lib/local/context.js +92 -0
  156. package/vendor/desktop/lib/local/covenant.js +562 -0
  157. package/vendor/desktop/lib/local/engine.js +2155 -0
  158. package/vendor/desktop/lib/local/entitlement.js +568 -0
  159. package/vendor/desktop/lib/local/git-scope.js +225 -0
  160. package/vendor/desktop/lib/local/local.js +2132 -0
  161. package/vendor/desktop/lib/local/prompt.js +242 -0
  162. package/vendor/desktop/lib/local/queue.js +557 -0
  163. package/vendor/desktop/lib/local/session-rounds.js +205 -0
  164. package/vendor/desktop/lib/local/shell.js +603 -0
  165. package/vendor/desktop/lib/local/telemetry.js +467 -0
  166. package/vendor/desktop/lib/local/tools.js +1197 -0
  167. package/vendor/desktop/lib/local/turn-guard.js +297 -0
  168. package/vendor/desktop/lib/local/worktree-lock.js +232 -0
  169. package/vendor/desktop/lib/provider-key-mirror.js +136 -0
  170. package/vendor/desktop/lib/quick-launcher.js +81 -0
  171. package/vendor/desktop/lib/settings.js +846 -0
  172. package/vendor/desktop/lib/sync/memory-queue.js +57 -0
  173. package/vendor/desktop/lib/sync/persist-gate.js +145 -0
  174. package/vendor/desktop/lib/sync/sessions.js +103 -0
  175. package/vendor/desktop/lib/window-state.js +63 -0
  176. package/vendor/desktop/main.js +3726 -0
  177. package/vendor/desktop/package.json +70 -0
  178. package/vendor/desktop/preload.js +557 -0
  179. package/vendor/desktop/renderer/app.js +5080 -0
  180. package/vendor/desktop/renderer/avatar/assemble.js +332 -0
  181. package/vendor/desktop/renderer/avatar/avatar.css +260 -0
  182. package/vendor/desktop/renderer/avatar/avatar.js +377 -0
  183. package/vendor/desktop/renderer/avatar/cards.js +138 -0
  184. package/vendor/desktop/renderer/avatar/hud.js +203 -0
  185. package/vendor/desktop/renderer/avatar/machine.js +210 -0
  186. package/vendor/desktop/renderer/avatar/pane.js +436 -0
  187. package/vendor/desktop/renderer/avatar/parts.js +434 -0
  188. package/vendor/desktop/renderer/budget.js +156 -0
  189. package/vendor/desktop/renderer/diff.js +356 -0
  190. package/vendor/desktop/renderer/diffview.js +333 -0
  191. package/vendor/desktop/renderer/fingerprint.css +143 -0
  192. package/vendor/desktop/renderer/fingerprint.js +583 -0
  193. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcQ72j00.woff2 +0 -0
  194. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcg72j00.woff2 +0 -0
  195. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKcw72j00.woff2 +0 -0
  196. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKew72j00.woff2 +0 -0
  197. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKfA72j00.woff2 +0 -0
  198. package/vendor/desktop/renderer/fonts/4iCs6KVjbNBYlgoKfw72.woff2 +0 -0
  199. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej70l0k.woff2 +0 -0
  200. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej73l0mwFg.woff2 +0 -0
  201. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej74l0mwFg.woff2 +0 -0
  202. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej75l0mwFg.woff2 +0 -0
  203. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej76l0mwFg.woff2 +0 -0
  204. package/vendor/desktop/renderer/fonts/4iCu6KVjbNBYlgoKej7wl0mwFg.woff2 +0 -0
  205. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3js2yNL4U.woff2 +0 -0
  206. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jsGyN.woff2 +0 -0
  207. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jtGyNL4U.woff2 +0 -0
  208. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvGyNL4U.woff2 +0 -0
  209. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvWyNL4U.woff2 +0 -0
  210. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCjC3jvmyNL4U.woff2 +0 -0
  211. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjs2yNL4U.woff2 +0 -0
  212. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjsGyN.woff2 +0 -0
  213. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjtGyNL4U.woff2 +0 -0
  214. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvGyNL4U.woff2 +0 -0
  215. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvWyNL4U.woff2 +0 -0
  216. package/vendor/desktop/renderer/fonts/4iCv6KVjbNBYlgoCxCvjvmyNL4U.woff2 +0 -0
  217. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm25L9Hz_.woff2 +0 -0
  218. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm2BL9A.woff2 +0 -0
  219. package/vendor/desktop/renderer/fonts/8vIH7w4qzmVxm2NL9Hz_.woff2 +0 -0
  220. package/vendor/desktop/renderer/fonts/NOTICE.md +57 -0
  221. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvrGyEY2tbZX9.woff2 +0 -0
  222. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvrGyEYOtbQ.woff2 +0 -0
  223. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvumzEY2tbZX9.woff2 +0 -0
  224. package/vendor/desktop/renderer/fonts/aFTR7PB1QTsUX8KYvumzEYOtbQ.woff2 +0 -0
  225. package/vendor/desktop/renderer/fonts/aFTU7PB1QTsUX8KYthSQBLyM.woff2 +0 -0
  226. package/vendor/desktop/renderer/fonts/aFTU7PB1QTsUX8KYthqQBA.woff2 +0 -0
  227. package/vendor/desktop/renderer/fonts/aFTW7PB1QTsUX8KYth-gBqSI.woff2 +0 -0
  228. package/vendor/desktop/renderer/fonts/aFTW7PB1QTsUX8KYth-gCKSIUKw.woff2 +0 -0
  229. package/vendor/desktop/renderer/fonts/fonts.css +368 -0
  230. package/vendor/desktop/renderer/index.html +864 -0
  231. package/vendor/desktop/renderer/markdown.js +165 -0
  232. package/vendor/desktop/renderer/quick.css +151 -0
  233. package/vendor/desktop/renderer/quick.html +42 -0
  234. package/vendor/desktop/renderer/quick.js +188 -0
  235. package/vendor/desktop/renderer/stream-policy.js +281 -0
  236. package/vendor/desktop/renderer/style.css +2519 -0
  237. package/vendor/desktop/renderer/transcript-view.js +320 -0
  238. package/vendor/desktop/renderer/usage.js +964 -0
  239. package/vendor/desktop/renderer/vendor/NOTICE.md +20 -0
  240. package/vendor/desktop/renderer/vendor/aegis-highlight.js +135 -0
  241. package/vendor/desktop/renderer/vendor/marked.umd.js +80 -0
  242. package/vendor/desktop/renderer/vendor/purify.min.js +3 -0
  243. package/vendor/desktop/vendor/aegis.js +1738 -0
  244. package/vendor/desktop/vendor/agent-gate.mjs +1180 -0
  245. package/vendor/desktop/vendor/attest.js +439 -0
  246. package/vendor/desktop/vendor/authorship-key.js +407 -0
  247. package/vendor/desktop/vendor/auto-provision.js +52 -0
  248. package/vendor/desktop/vendor/brain-catalog.js +265 -0
  249. package/vendor/desktop/vendor/byok-catalog.js +192 -0
  250. package/vendor/desktop/vendor/covenant/README.md +21 -0
  251. package/vendor/desktop/vendor/covenant/aegis.seal +177 -0
  252. package/vendor/desktop/vendor/credentials.js +478 -0
  253. package/vendor/desktop/vendor/device-fingerprint.js +145 -0
  254. package/vendor/desktop/vendor/env-file.js +1016 -0
  255. package/vendor/desktop/vendor/fingerprint.js +1061 -0
  256. package/vendor/desktop/vendor/foreign-memory.js +666 -0
  257. package/vendor/desktop/vendor/hooks.js +427 -0
  258. package/vendor/desktop/vendor/platform.js +934 -0
  259. package/vendor/desktop/vendor/prefs.js +348 -0
  260. package/vendor/desktop/vendor/presence-constants.js +104 -0
  261. package/vendor/desktop/vendor/presence.js +435 -0
  262. package/vendor/desktop/vendor/record-vault.js +834 -0
  263. package/vendor/desktop/vendor/session-store.js +545 -0
  264. package/vendor/desktop/vendor/topup.js +294 -0
  265. package/vendor/desktop/vendor/touch.js +455 -0
  266. package/vendor/desktop/vendor/update.js +343 -0
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # AEGISONE
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Product version: **1.0.3**
4
+
5
+ One product, two faces: the terminal (`aegiscode`) and the window (`aegis-desktop`),
6
+ reached through one command — `aegis` — and released as one version.
7
+
8
+ `aegis` decides which face runs and hands off to it. The window opens only when
9
+ there is nothing else to do: with a display and Electron resolvable, a bare
10
+ `aegis` opens the window, and everywhere else it runs the terminal face and says
11
+ why in one line. `aegis code` and `aegis desktop` force a face; `aegiscode` keeps
12
+ behaving exactly as it always has.
13
+
14
+ ## One version, three manifests
15
+
16
+ This package is the single source of truth for the product version. The two face
17
+ versions are **derived** from it by `one/src/release.js`, never hand-typed: the
18
+ terminal face stays on its `6.8.x` line and the window face on its `0.8.x` line,
19
+ because installed apps and their update channels are pinned to those lines, and
20
+ the patch counters advance one per product release.
21
+
22
+ ```
23
+ node one/scripts/bump.mjs patch # bump product + both derived faces
24
+ node one/scripts/bump.mjs 1.0.1 --dry-run # print the diff, write nothing
25
+ ```
26
+
27
+ One command, one version:
28
+
29
+ ```
30
+ aegis --version # 1.0.0
31
+ aegis --version --verbose # 1.0.0, then the version each face carries
32
+ ```
33
+
34
+ ## What ships on a `v*` tag
35
+
36
+ `.github/workflows/release.yml` builds the desktop installers for Linux, macOS
37
+ and Windows, then publishes three packages to npm — the two faces first, the
38
+ product last. The product tarball *vendors* both faces, so it has no hard
39
+ registry dependency on them; the order is kept because this README and the
40
+ electron-updater feed point at the face packages, and those must be live first.
41
+ `test/one-version.test.mjs` asserts that property and the publish order
42
+ together, so a future change that adds a real dependency cannot ship out of
43
+ order silently.
44
+
45
+ ## Install
46
+
47
+ ```
48
+ sh one/install.sh # npm path, then the OS bundle for the window
49
+ AEGISONE_FACE=cli sh one/install.sh # terminal only — Electron is never attempted
50
+ powershell -File one/install.ps1 # the same on Windows
51
+ ```
52
+
53
+ Both installers honour `AEGISONE_FACE=cli|gui`, install the npm path first, and
54
+ then name the OS bundle for the window. **Electron is optional and its absence is
55
+ not a failure:** when Electron cannot be installed the installer exits 0 with a
56
+ working terminal face and prints the line you need — `aegis --tui`. It never
57
+ fails, and it never leaves you with "nothing happened". Afterwards: `aegis`
58
+ (dispatch) · `aegis desktop` (force the window) · `aegis code` / `aegis --tui`
59
+ (force the terminal) · `aegiscode` (the compatibility bin, unchanged).
60
+
61
+ ## Size, measured not claimed
62
+
63
+ Measured size: **2.00 MB** (2,101,414 bytes) with Electron absent — both faces inside.
64
+
65
+ The plan's "~2 MB" was a target, so it is measured here rather than published:
66
+ `npm pack one/` on this tree, with Electron absent, produces that tarball, and it
67
+ contains both faces:
68
+
69
+ ```
70
+ vendor/cli/bin/aegiscode.js # the terminal face
71
+ vendor/desktop/bin/aegis.js # the window face
72
+ ```
73
+
74
+ `one/test/one-compat.test.mjs` re-measures the tarball, lists it, and fails if
75
+ either face is missing or if this number drifts by more than 3%. The number is a
76
+ measurement, not a constant: the staged face sources are copied from `cli/` and
77
+ `desktop/`, so they move with the tree — which is exactly why the assertion is a
78
+ tolerance around a real measurement instead of a hand-typed figure.
79
+
80
+ ## Layout
81
+
82
+ ```
83
+ one/
84
+ ├── bin/aegis.js decide, then hand off — no third behaviour
85
+ ├── src/dispatch.js the pure rule: gui | tui | refusal
86
+ ├── src/probes.js the one impure read (display, Electron, tty)
87
+ ├── src/host.js the OS answer, asked of client/platform.js
88
+ ├── src/release.js product version + face-version derivation
89
+ ├── src/doctor.js one report, one exit code for scripts
90
+ ├── scripts/predist.mjs the only stager: one manifest, both shapes
91
+ ├── scripts/bump.mjs the only writer of the three versions
92
+ ├── scripts/bundle.js which OS bundle the window needs (via platform.js)
93
+ ├── install.sh npm path first, then the bundle; TUI on Electron miss
94
+ ├── install.ps1 the same on Windows
95
+ └── vendor/ composed at publish: the cli and desktop faces
96
+ ```
97
+
98
+ The brain, the routing, the tiers and the billing stay server-side. This package
99
+ is a packaging and identity layer over the two hosts — nothing else moves here.
package/bin/aegis.js ADDED
@@ -0,0 +1,295 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * AEGISONE — the `aegis` command.
6
+ *
7
+ * This file is deliberately thin, and deliberately boring. It does exactly
8
+ * three things, in this order:
9
+ *
10
+ * 1. gather the process facts (`src/probes.js`) — the only impure read in
11
+ * the product's dispatch path;
12
+ * 2. ask the pure rule which face runs (`src/dispatch.js`);
13
+ * 3. hand off to that face, forwarding argv untouched and exiting with the
14
+ * child's status.
15
+ *
16
+ * There is no third behaviour hiding in here. If you are looking for the
17
+ * decision, it is not in this file — that is the point of it not being here:
18
+ * everything decided in `run()` is a line a test cannot reach on a headless
19
+ * box, and this product is authored on one.
20
+ *
21
+ * `aegiscode` is wired to this same bin and is forwarded verbatim as the
22
+ * compatibility spelling; see the first rule in `dispatch.js`.
23
+ *
24
+ * Debugging: `AEGISONE_PRINT_DECISION=1 aegis …` prints the decision as one
25
+ * JSON line on stderr and continues. It never changes the face.
26
+ */
27
+
28
+ const fs = require('node:fs');
29
+ const path = require('node:path');
30
+ const { spawnSync, spawn } = require('node:child_process');
31
+ const { decide, FACE } = require('../src/dispatch.js');
32
+ const probes = require('../src/probes.js');
33
+ const release = require('../src/release.js');
34
+
35
+ const EXIT_USAGE = 2;
36
+ const PRODUCT = require('../package.json');
37
+
38
+ /**
39
+ * Where a face manifest can be, nearest to furthest:
40
+ *
41
+ * 1. `vendor/<face>/package.json` — inside the published product tarball,
42
+ * which vendors both faces (plan D6);
43
+ * 2. `../<face>/package.json` — a checkout of this repo, where the faces are
44
+ * siblings of `one/`.
45
+ *
46
+ * Both are tried, in that order, because the answer differs between an installed
47
+ * product and the tree it was built from, and `--version --verbose` must report
48
+ * what is actually there rather than what the derivation says should be.
49
+ */
50
+ function faceManifestPaths(face, dir) {
51
+ const binDir = dir || __dirname;
52
+ return [
53
+ path.join(binDir, '..', 'vendor', face.dir, 'package.json'),
54
+ path.join(binDir, '..', '..', face.dir, 'package.json')
55
+ ];
56
+ }
57
+
58
+ /** The version each face actually carries beside this product (`null` if none). */
59
+ function readFaceVersions(dir) {
60
+ return release.FACE_LINES.map((face) => {
61
+ for (const candidate of faceManifestPaths(face, dir)) {
62
+ try {
63
+ return { package: face.package, version: JSON.parse(fs.readFileSync(candidate, 'utf8')).version, source: candidate };
64
+ } catch {
65
+ /* try the next layout */
66
+ }
67
+ }
68
+ return { package: face.package, version: null, source: null };
69
+ });
70
+ }
71
+
72
+ function write(stream, line) {
73
+ try {
74
+ stream.write(line.endsWith('\n') ? line : line + '\n');
75
+ } catch {
76
+ /* a closed pipe is not our problem to report */
77
+ }
78
+ }
79
+
80
+ /** Exit status for a finished child, in shell terms (128 + n when signalled). */
81
+ function statusOf(res) {
82
+ if (typeof res.status === 'number') return res.status;
83
+ if (res.signal === 'SIGINT') return 130;
84
+ if (res.signal === 'SIGTERM') return 143;
85
+ return 1;
86
+ }
87
+
88
+ /**
89
+ * Decide, report, hand off.
90
+ *
91
+ * @param {string[]} argv arguments after the program name
92
+ * @param {object} [deps] injected for tests: { input, spawnSync, spawn, env,
93
+ * stderr, stdout }
94
+ * @returns {number} the process exit code
95
+ */
96
+ function run(argv, deps) {
97
+ const d = deps || {};
98
+ const stderr = d.stderr || process.stderr;
99
+ const stdout = d.stdout || process.stdout;
100
+ const base = d.input || probes.collect({ argv });
101
+ // The `argv` parameter wins over whatever an injected input carries. It used
102
+ // to be silently ignored when `deps.input` was present, which meant a caller
103
+ // could hand in arguments and have a completely different set decided on —
104
+ // and a test found it. One source of truth: the argv you pass is the argv
105
+ // that is decided on.
106
+ const input = Array.isArray(argv) ? { ...base, argv } : base;
107
+
108
+ // ── D4: `aegis --version` is the PRODUCT's version, not the face's. ───────
109
+ // ON1 left this branch open on purpose: `--version` reached the dispatcher as
110
+ // a terminal-face verb, so `aegis --version` printed the CLI face's `6.x`
111
+ // version and the product had no version of its own to print. It is answered
112
+ // here, before the decision, because it is not a question about which face
113
+ // runs — and only in the two shapes `release.versionRequest` accepts, so no
114
+ // prompt or flag can be swallowed by it.
115
+ const asked = release.versionRequest(input.argv);
116
+ if (asked) {
117
+ const faces = asked.verbose
118
+ ? (d.readFaceVersions ? d.readFaceVersions() : readFaceVersions(d.binDir))
119
+ : null;
120
+ write(stdout, release.renderVersion({ product: { name: PRODUCT.name, version: PRODUCT.version }, faces }));
121
+ return 0;
122
+ }
123
+
124
+ // ── D7: `doctor` is answered here, before the face decision. ─────────────
125
+ // It is a *product* verb: `aegis doctor` is a question about this install,
126
+ // not about which face runs, and it must answer on a machine with no display
127
+ // (ON1 routes `doctor` to the terminal face so it can never open a window —
128
+ // but going through the CLI would mean the report only exists when the
129
+ // terminal face is installed). The answer plus its exit code is the product's
130
+ // own (0 healthy / 1 warn / 2 broken), and scripts branch on it, so it is
131
+ // returned unmodified — never merged with a child's status.
132
+ const doctorAt = (input.argv || []).indexOf('doctor');
133
+ if (doctorAt !== -1 && !(input.argv || []).slice(0, doctorAt).some((a) => !a.startsWith('-'))) {
134
+ const doctor = d.doctor || require('../src/doctor.js');
135
+ const code = doctor.main((input.argv || []).slice(doctorAt + 1), Object.assign({ env: input.env, stdout }, d.doctorDeps || {}));
136
+ return typeof code === 'number' ? code : EXIT_USAGE;
137
+ }
138
+
139
+ const decision = decide(input);
140
+
141
+ // ── D8: the permission posture, resolved ONCE, before any hand-off. ───────
142
+ //
143
+ // `--dangerously-skip-permissions` is a product flag, not a face flag: it is
144
+ // answered HERE (like `--version` and `doctor` above) because its effect
145
+ // spans both faces — the confirmation gate the user is about to run inside,
146
+ // and the Claude child whose prompt nobody can answer (D8 rules 3–5).
147
+ //
148
+ // Three things happen, in this order, and nothing else:
149
+ //
150
+ // 1. the posture is resolved from the flag, the environment and whether a
151
+ // human is present (rule 5 lives in `cli/src/permissions.js`
152
+ // `resolveSkip()`, so this face and the terminal face share it);
153
+ // 2. a skip prints the one line rule 3 requires, naming the classes; a
154
+ // rule-5 refusal prints its warning and the run stays gated;
155
+ // 3. the flag is STRIPPED from the arguments forwarded to a face (the CLI's
156
+ // parser has never heard of it, and silently eating a flag is its own
157
+ // small lie), and the resolved decision is handed to the child through
158
+ // `AEGISONE_SKIP_PERMISSIONS` — the product's own spelling, which the
159
+ // face reads. The user-facing `AEGIS_SKIP_PERMISSIONS` is never
160
+ // forwarded as an authorisation: rule 5's check has already been applied
161
+ // to it here, and re-applying it one process down would be a second
162
+ // place to get it wrong.
163
+ const perms = d.permissions || require('../src/permissions.js');
164
+ const skipFlagAt = (input.argv || []).indexOf(perms.SKIP_FLAG || '--dangerously-skip-permissions');
165
+ const ttyInteractive = Boolean(input.tty && input.tty.stdin && input.tty.stdout);
166
+ const childKind = ttyInteractive ? 'interactive' : 'headless';
167
+ const posture = perms.resolvePosture({
168
+ rules: d.rules,
169
+ flag: skipFlagAt !== -1,
170
+ env: input.env,
171
+ interactive: ttyInteractive,
172
+ childKind,
173
+ });
174
+
175
+ if (posture.warning) write(stderr, `aegis: ${posture.warning}`);
176
+ if (posture.skip) write(stderr, perms.skipReport(posture));
177
+
178
+ const faceArgs = skipFlagAt === -1
179
+ ? decision.args
180
+ : decision.args.filter((a) => a !== (perms.SKIP_FLAG || '--dangerously-skip-permissions'));
181
+ const postureEnv = posture.skip ? { AEGISONE_SKIP_PERMISSIONS: '1' } : {};
182
+
183
+ if ((input.env || {}).AEGISONE_PRINT_DECISION === '1') { write(
184
+ stderr,
185
+ 'aegis: decision ' +
186
+ JSON.stringify({
187
+ face: decision.face,
188
+ kind: decision.kind,
189
+ reason: decision.reason,
190
+ args: faceArgs,
191
+ skip: posture.skip,
192
+ })
193
+ );
194
+ }
195
+
196
+ // ── Refused outright: an explicit request the machine cannot honour. ──────
197
+ if (decision.face === null) {
198
+ write(stderr, `aegis: ${decision.error}`);
199
+ if (decision.hint) write(stderr, `aegis: ${decision.hint}`);
200
+ return decision.code || EXIT_USAGE;
201
+ }
202
+
203
+ // ── One line explaining a fallback. Never silence, never a question. ─────
204
+ if (decision.notice) write(stderr, `aegis: ${decision.notice} — running the terminal face.`);
205
+
206
+ const doSpawn = d.spawnSync || spawnSync;
207
+ const doSpawnAsync = d.spawn || spawn;
208
+ const spawnEnv = Object.assign({}, process.env, d.env || {});
209
+
210
+ if (decision.face === FACE.TUI) {
211
+ const bin = input._cliBin || d.cliBin;
212
+ if (!bin) {
213
+ write(stderr, 'aegis: the terminal face is not installed beside aegisone.');
214
+ write(stderr, 'aegis: reinstall aegisone, or set AEGISONE_CLI_BIN to bin/aegiscode.js.');
215
+ return 127;
216
+ }
217
+ const res = doSpawn(process.execPath, [bin, ...faceArgs], {
218
+ stdio: 'inherit',
219
+ env: Object.assign({}, spawnEnv, postureEnv),
220
+ argv0: 'aegiscode',
221
+ });
222
+ return statusOf(res || {});
223
+ }
224
+
225
+ // ── GUI ──────────────────────────────────────────────────────────────────
226
+ // The dispatch rule already refused this path unless Electron resolved, so a
227
+ // miss here means the tree changed under us; say so rather than fall back to
228
+ // a terminal, because the user did ask for the window.
229
+ const electron = input._electron || d.electron;
230
+ const main = input._desktopMain || d.desktopMain;
231
+ if (!electron || !main) {
232
+ write(
233
+ stderr,
234
+ 'aegis: cannot open the window — Electron or the desktop entry point went missing after the check.'
235
+ );
236
+ write(stderr, 'aegis: Use --tui for the terminal face.');
237
+ return EXIT_USAGE;
238
+ }
239
+
240
+ // Handed to **Node**, not to Electron — and this was a live bug, not a
241
+ // preference. `desktop/bin/aegis.js` is a launcher: under Node it does
242
+ // `require('electron')` and gets the path to the binary, then spawns it with
243
+ // the app dir. Running that file *inside* Electron instead makes the same
244
+ // require return the Electron module object, and `spawn(object, …)` dies with
245
+ // ERR_INVALID_ARG_TYPE inside the app's own bootstrap. The desktop package
246
+ // already owns "find Electron and launch it"; AEGISONE delegates to it
247
+ // rather than keeping a second, divergent copy of that logic. The resolved
248
+ // Electron path is still what the *probe* consumes — capability to open a
249
+ // window is one question, and who does the opening is another.
250
+ //
251
+ // ELECTRON_RUN_AS_NODE would make Electron behave as plain node and never
252
+ // open a window — the classic silent-no-op, removed rather than inherited.
253
+ delete spawnEnv.ELECTRON_RUN_AS_NODE;
254
+
255
+ // `spawn`, not `spawnSync`: the window should not hold the shell's tty
256
+ // hostage. The parent waits only so the exit code is still the child's.
257
+ const child = doSpawnAsync(process.execPath, [main, ...faceArgs], {
258
+ stdio: 'inherit',
259
+ env: Object.assign({}, spawnEnv, postureEnv),
260
+ detached: false,
261
+ });
262
+
263
+ return new Promise((resolve) => {
264
+ child.on('error', (err) => {
265
+ write(stderr, `aegis: could not start the window: ${err && err.message}`);
266
+ resolve(1);
267
+ });
268
+ child.on('exit', (code, signal) => resolve(statusOf({ status: code, signal })));
269
+ });
270
+ }
271
+
272
+ /** Synchronous wrapper for the entry point: returns a code or a Promise. */
273
+ function main(argv) {
274
+ const outcome = run(argv);
275
+ if (typeof outcome === 'number') {
276
+ process.exitCode = outcome;
277
+ return outcome;
278
+ }
279
+ return outcome.then((code) => {
280
+ process.exitCode = code;
281
+ return code;
282
+ });
283
+ }
284
+
285
+ module.exports = { main, run, statusOf, EXIT_USAGE };
286
+
287
+ if (require.main === module) {
288
+ const result = main(process.argv.slice(2));
289
+ if (result && typeof result.then === 'function') {
290
+ result.catch((err) => {
291
+ write(process.stderr, `aegis: ${(err && err.stack) || err}`);
292
+ process.exitCode = 1;
293
+ });
294
+ }
295
+ }
package/install.ps1 ADDED
@@ -0,0 +1,151 @@
1
+ <#
2
+ .SYNOPSIS
3
+ AEGISONE installer (Windows) — plan ON6 (D2, D3).
4
+
5
+ .DESCRIPTION
6
+ Two steps, in this order: the npm path (`npm i -g <product>`), then the OS
7
+ bundle for the window, named by scripts/bundle.js — which asks
8
+ client/platform.js which OS this is. This script branches on no OS itself.
9
+
10
+ The rule that matters: Electron is optional and its absence is NOT a failure.
11
+ When Electron cannot be installed the installer still exits 0, with a working
12
+ terminal face and the one line the user needs — `aegis --tui`.
13
+
14
+ Faces (D3): AEGISONE_FACE=cli (terminal only) | gui (window if possible).
15
+ Spellings honoured afterwards: `aegis` · `aegis desktop` · `aegis code` ·
16
+ `aegis --tui` · `aegiscode` (the compatibility bin, unchanged).
17
+
18
+ Test seam (CI + one/test/one-compat.test.mjs):
19
+ $env:AEGISONE_ELECTRON_FORCE_ABSENT = '1' simulates "Electron cannot be
20
+ installed here" without touching the host.
21
+
22
+ .EXAMPLE
23
+ irm https://aegiscloud.org/install.ps1 | iex
24
+ #>
25
+ [CmdletBinding()]
26
+ param(
27
+ [ValidateSet('', 'cli', 'gui')][string]$Face = '',
28
+ [string]$From = '',
29
+ [string]$Prefix = '',
30
+ [switch]$DryRun
31
+ )
32
+
33
+ $ErrorActionPreference = 'Stop'
34
+
35
+ $Here = Split-Path -Parent $MyInvocation.MyCommand.Path
36
+
37
+ # The face env var is honoured whatever its case; `tui` is accepted because D3
38
+ # spells the face both ways (`--tui` on the command, `cli` in the env).
39
+ if ([string]::IsNullOrWhiteSpace($Face)) { $Face = $env:AEGISONE_FACE }
40
+ if ([string]::IsNullOrWhiteSpace($Face)) { $Face = 'gui' }
41
+ $Face = $Face.Trim().ToLowerInvariant()
42
+ switch ($Face) {
43
+ { $_ -in @('cli', 'tui') } { $Face = 'cli' }
44
+ { $_ -in @('gui', 'desktop') } { $Face = 'gui' }
45
+ default {
46
+ Write-Error "install: AEGISONE_FACE/-Face must be cli or gui (got: $Face)"
47
+ exit 2
48
+ }
49
+ }
50
+
51
+ if ([string]::IsNullOrWhiteSpace($From)) { $From = $env:AEGISONE_PACKAGE }
52
+ if ([string]::IsNullOrWhiteSpace($From)) { $From = 'aegisone' }
53
+
54
+ if ([string]::IsNullOrWhiteSpace($Prefix)) { $Prefix = $env:AEGISONE_PREFIX }
55
+ $NpmArgs = @('install', '-g')
56
+ if (-not [string]::IsNullOrWhiteSpace($Prefix)) { $NpmArgs += @('--prefix', $Prefix) }
57
+
58
+ function Invoke-Step {
59
+ param([string]$Command, [string[]]$Arguments)
60
+ if ($DryRun) {
61
+ Write-Host ("would run: {0} {1}" -f $Command, ($Arguments -join ' '))
62
+ return 0
63
+ }
64
+ & $Command @Arguments
65
+ return $LASTEXITCODE
66
+ }
67
+
68
+ function Get-BundleLine {
69
+ $bundle = Join-Path $Here 'scripts/bundle.js'
70
+ if ($null -ne (Get-Command node -ErrorAction SilentlyContinue) -and (Test-Path $bundle)) {
71
+ $line = & node $bundle 2>$null
72
+ if ($LASTEXITCODE -eq 0 -and $line) { return $line }
73
+ }
74
+ return 'AEGIS Desktop: https://github.com/aegiscloud-devs/aegiscode-plugin/releases'
75
+ }
76
+
77
+ # ── Node is not optional for the npm path ────────────────────────────────────
78
+ if ($null -eq (Get-Command node -ErrorAction SilentlyContinue)) {
79
+ Write-Host 'install: Node.js >= 18 was not found on PATH, so the npm path and the terminal face are unavailable here.'
80
+ Write-Host 'install: the window ships as a bundle that needs no Node — install it from:'
81
+ Write-Host (Get-BundleLine)
82
+ exit 1
83
+ }
84
+ if ($null -eq (Get-Command npm -ErrorAction SilentlyContinue)) {
85
+ Write-Host "install: npm was not found on PATH (Node.js is present: $(& node --version))."
86
+ Write-Host 'install: the npm path is how AEGISONE is installed; see https://nodejs.org and re-run.'
87
+ exit 1
88
+ }
89
+
90
+ # The Electron requirement is *carried*, not re-invented: it is read out of
91
+ # one/package.json's optionalDependencies, the same declaration the desktop
92
+ # package has carried since before AEGISONE existed.
93
+ $ElectronRange = ''
94
+ $manifest = Join-Path $Here 'package.json'
95
+ if (Test-Path $manifest) {
96
+ try {
97
+ $ElectronRange = (Get-Content -Raw $manifest | ConvertFrom-Json).optionalDependencies.electron
98
+ } catch { $ElectronRange = '' }
99
+ }
100
+
101
+ Write-Host "AEGISONE: installing $From (face: $Face)"
102
+ $code = Invoke-Step 'npm' @('install', '-g', $From)
103
+ if (-not $DryRun -and $code -ne 0) {
104
+ Write-Host "install: npm could not install $From."
105
+ Write-Host 'install: for the window with no npm at all, use the OS bundle:'
106
+ Write-Host (Get-BundleLine)
107
+ exit 1
108
+ }
109
+
110
+ # ── The window: best effort, never fatal ────────────────────────────────────
111
+ $ElectronOk = $false
112
+ if ($Face -eq 'gui') {
113
+ if ($env:AEGISONE_ELECTRON_FORCE_ABSENT -eq '1') {
114
+ Write-Host 'install: Electron is unavailable on this machine (AEGISONE_ELECTRON_FORCE_ABSENT=1).'
115
+ } elseif (-not [string]::IsNullOrWhiteSpace($ElectronRange)) {
116
+ $code = Invoke-Step 'npm' @('install', '-g', "electron@$ElectronRange")
117
+ if ($DryRun -or $code -eq 0) { $ElectronOk = $true }
118
+ }
119
+ }
120
+
121
+ if ($Face -eq 'gui' -and $ElectronOk) {
122
+ Write-Host ''
123
+ Write-Host 'AEGISONE is installed.'
124
+ Write-Host ' aegis open the window (terminal when there is no display)'
125
+ Write-Host ' aegis desktop force the window'
126
+ Write-Host ' aegis code force the terminal'
127
+ Write-Host ' aegis --tui the same, spelled the other way'
128
+ Write-Host ' aegis doctor check this install (exit 0 when healthy)'
129
+ exit 0
130
+ }
131
+
132
+ if ($Face -eq 'cli') {
133
+ Write-Host ''
134
+ Write-Host 'AEGISONE is installed with the terminal face only (AEGISONE_FACE=cli).'
135
+ Write-Host ' aegis --tui run the terminal face'
136
+ Write-Host ' aegis code the same, spelled the other way'
137
+ Write-Host ' aegis doctor check this install (exit 0 when healthy)'
138
+ Write-Host ' aegis desktop will refuse with exit 2 and name --tui until Electron is installed'
139
+ exit 0
140
+ }
141
+
142
+ # Electron could not be installed: the user gets a working product and one clear
143
+ # line, never a failure and never silence.
144
+ Write-Host ''
145
+ Write-Host 'AEGISONE is installed, with the terminal face.'
146
+ Write-Host 'aegis: the window needs Electron and it could not be installed here — everything else works.'
147
+ Write-Host 'aegis: run `aegis --tui` (or `aegis code`) for the terminal face.'
148
+ Write-Host 'aegis: `aegis desktop` will refuse with exit 2 and name --tui while Electron is missing.'
149
+ Write-Host 'aegis: for the window, install the OS bundle:'
150
+ Write-Host (Get-BundleLine)
151
+ exit 0