aegisone 1.0.34 → 1.0.37

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 (372) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -1
  3. package/SOURCE-OFFER.txt +9 -0
  4. package/bin/aegis.js +1 -322
  5. package/package.json +4 -5
  6. package/scripts/bump.mjs +1 -211
  7. package/scripts/bundle.js +1 -129
  8. package/scripts/predist.mjs +1 -976
  9. package/src/child.js +1 -285
  10. package/src/dispatch.js +1 -269
  11. package/src/doctor.js +1 -639
  12. package/src/host.js +1 -111
  13. package/src/iface/paths.js +3 -0
  14. package/src/iface/pty.js +3 -0
  15. package/src/iface/update.js +3 -0
  16. package/src/iface/window.js +3 -0
  17. package/src/permissions.js +1 -383
  18. package/src/probes.js +1 -159
  19. package/src/protocol.js +3 -0
  20. package/src/release.js +1 -409
  21. package/src/selfhost.js +3 -0
  22. package/vendor/cli/package.json +3 -7
  23. package/vendor/cli/scripts/check.mjs +1 -52
  24. package/vendor/cli/scripts/demo.mjs +1 -94
  25. package/vendor/cli/scripts/predist.mjs +1 -75
  26. package/vendor/cli/scripts/runtests.mjs +1 -56
  27. package/vendor/cli/scripts/seal-gate.mjs +1 -74
  28. package/vendor/cli/src/agents.js +1 -139
  29. package/vendor/cli/src/app.js +1 -2957
  30. package/vendor/cli/src/art.js +1 -289
  31. package/vendor/cli/src/chatflow.js +1 -3023
  32. package/vendor/cli/src/checkpoint.js +1 -90
  33. package/vendor/cli/src/clipboard.js +1 -424
  34. package/vendor/cli/src/cloudsync.js +1 -528
  35. package/vendor/cli/src/commands.js +1 -4089
  36. package/vendor/cli/src/config.js +1 -581
  37. package/vendor/cli/src/connect.js +1 -349
  38. package/vendor/cli/src/credentials.js +1 -33
  39. package/vendor/cli/src/deps.js +1 -232
  40. package/vendor/cli/src/devrun.js +1 -187
  41. package/vendor/cli/src/diff.js +1 -333
  42. package/vendor/cli/src/diffview.js +1 -296
  43. package/vendor/cli/src/engine.js +1 -297
  44. package/vendor/cli/src/entitlement.js +1 -355
  45. package/vendor/cli/src/events.js +1 -707
  46. package/vendor/cli/src/export.js +1 -67
  47. package/vendor/cli/src/filepreview.js +1 -153
  48. package/vendor/cli/src/fingerprint.js +1 -592
  49. package/vendor/cli/src/format.js +1 -259
  50. package/vendor/cli/src/fuzzy.js +1 -119
  51. package/vendor/cli/src/history.js +1 -423
  52. package/vendor/cli/src/init.js +1 -175
  53. package/vendor/cli/src/input.js +1 -139
  54. package/vendor/cli/src/keys.js +1 -183
  55. package/vendor/cli/src/markdown.js +1 -306
  56. package/vendor/cli/src/models.js +1 -507
  57. package/vendor/cli/src/naming.js +1 -57
  58. package/vendor/cli/src/overlays.js +1 -462
  59. package/vendor/cli/src/panels.js +1 -1418
  60. package/vendor/cli/src/ping.js +1 -226
  61. package/vendor/cli/src/presence.js +1 -238
  62. package/vendor/cli/src/render.js +1 -516
  63. package/vendor/cli/src/screen.js +1 -518
  64. package/vendor/cli/src/screens.js +1 -896
  65. package/vendor/cli/src/secret.js +1 -59
  66. package/vendor/cli/src/securefs.js +1 -359
  67. package/vendor/cli/src/settings.js +1 -155
  68. package/vendor/cli/src/shared.js +1 -52
  69. package/vendor/cli/src/sharedpaths.js +1 -53
  70. package/vendor/cli/src/signup.js +1 -156
  71. package/vendor/cli/src/summarize.js +1 -95
  72. package/vendor/cli/src/sysdiag.js +1 -585
  73. package/vendor/cli/src/system.js +1 -40
  74. package/vendor/cli/src/theme.js +1 -570
  75. package/vendor/cli/src/title.js +1 -220
  76. package/vendor/cli/src/todos.js +1 -115
  77. package/vendor/cli/src/tokens.js +1 -263
  78. package/vendor/cli/src/topup.js +1 -210
  79. package/vendor/cli/src/update.js +1 -191
  80. package/vendor/cli/vendor/client/aegis.js +1 -2441
  81. package/vendor/cli/vendor/client/attest.js +1 -518
  82. package/vendor/cli/vendor/client/authorship-key.js +1 -410
  83. package/vendor/cli/vendor/client/auto-provision.js +1 -134
  84. package/vendor/cli/vendor/client/brain-catalog.js +1 -268
  85. package/vendor/cli/vendor/client/byok-catalog.js +1 -199
  86. package/vendor/cli/vendor/client/catalog-client.js +1 -487
  87. package/vendor/cli/vendor/client/conversation-export.js +1 -177
  88. package/vendor/cli/vendor/client/credentials.js +1 -494
  89. package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
  90. package/vendor/cli/vendor/client/drive-connect.js +1 -110
  91. package/vendor/cli/vendor/client/drive-upload.js +1 -234
  92. package/vendor/cli/vendor/client/env-file.js +1 -1273
  93. package/vendor/cli/vendor/client/fingerprint.js +1 -1064
  94. package/vendor/cli/vendor/client/foreign-memory.js +1 -669
  95. package/vendor/cli/vendor/client/google-signin.js +1 -133
  96. package/vendor/cli/vendor/client/hooks.js +1 -430
  97. package/vendor/cli/vendor/client/model-discovery.js +1 -373
  98. package/vendor/cli/vendor/client/naming.js +1 -283
  99. package/vendor/cli/vendor/client/platform.js +1 -937
  100. package/vendor/cli/vendor/client/prefs.js +1 -351
  101. package/vendor/cli/vendor/client/presence-constants.js +1 -107
  102. package/vendor/cli/vendor/client/presence.js +1 -438
  103. package/vendor/cli/vendor/client/record-vault.js +3 -1055
  104. package/vendor/cli/vendor/client/session-store.js +1 -575
  105. package/vendor/cli/vendor/client/topup.js +1 -297
  106. package/vendor/cli/vendor/client/touch.js +1 -458
  107. package/vendor/cli/vendor/client/update.js +1 -763
  108. package/vendor/cli/vendor/client/user-models.js +1 -381
  109. package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
  110. package/vendor/cli/vendor/desktop/lib/local/attachments.js +1 -276
  111. package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
  112. package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -1028
  113. package/vendor/cli/vendor/desktop/lib/local/context.js +1 -125
  114. package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3666
  115. package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
  116. package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
  117. package/vendor/cli/vendor/desktop/lib/local/integrity.js +1 -1
  118. package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2145
  119. package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -280
  120. package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
  121. package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -238
  122. package/vendor/cli/vendor/desktop/lib/local/spill.js +1 -75
  123. package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
  124. package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
  125. package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
  126. package/vendor/cli/vendor/desktop/main.js +67 -1
  127. package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
  128. package/vendor/cli/vendor/hosts/install.js +1 -638
  129. package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
  130. package/vendor/cli/vendor/hosts/spec.js +1 -164
  131. package/vendor/cli/vendor/hosts/targets.js +1 -346
  132. package/vendor/cli/vendor/mcp/server.js +1 -221
  133. package/vendor/cli/vendor/mcp/tools.js +1 -408
  134. package/vendor/cli/vendor/one/src/child.js +1 -285
  135. package/vendor/cli/vendor/one/src/permissions.js +1 -383
  136. package/vendor/cli/vendor/one/src/selfhost.js +3 -0
  137. package/vendor/desktop/bin/aegis.js +1 -32
  138. package/vendor/desktop/lib/account-key.js +1 -56
  139. package/vendor/desktop/lib/auto.js +1 -461
  140. package/vendor/desktop/lib/avatar/companion.js +1 -698
  141. package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
  142. package/vendor/desktop/lib/avatar/events.js +1 -344
  143. package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
  144. package/vendor/desktop/lib/avatar/holders.js +1 -612
  145. package/vendor/desktop/lib/avatar/identity.js +1 -641
  146. package/vendor/desktop/lib/avatar/level.js +1 -368
  147. package/vendor/desktop/lib/avatar/mirror.js +1 -524
  148. package/vendor/desktop/lib/avatar/persona.js +1 -388
  149. package/vendor/desktop/lib/avatar/profile.js +1 -977
  150. package/vendor/desktop/lib/avatar/register.js +1 -307
  151. package/vendor/desktop/lib/avatar/store.js +1 -472
  152. package/vendor/desktop/lib/avatar/tiers.js +1 -38
  153. package/vendor/desktop/lib/avatar/transfer.js +1 -415
  154. package/vendor/desktop/lib/avatar/turn.js +1 -216
  155. package/vendor/desktop/lib/avatar/voice.js +1 -328
  156. package/vendor/desktop/lib/avatar/xp.js +1 -404
  157. package/vendor/desktop/lib/deep-link.js +1 -120
  158. package/vendor/desktop/lib/fingerprint.js +2 -347
  159. package/vendor/desktop/lib/google-connect.js +1 -323
  160. package/vendor/desktop/lib/local/agents.js +1 -105
  161. package/vendor/desktop/lib/local/attachments.js +1 -276
  162. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  163. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  164. package/vendor/desktop/lib/local/context.js +1 -125
  165. package/vendor/desktop/lib/local/engine.js +1 -3666
  166. package/vendor/desktop/lib/local/entitlement.js +1 -660
  167. package/vendor/desktop/lib/local/git-scope.js +1 -228
  168. package/vendor/desktop/lib/local/integrity.js +1 -1
  169. package/vendor/desktop/lib/local/local.js +1 -2145
  170. package/vendor/desktop/lib/local/prompt.js +1 -280
  171. package/vendor/desktop/lib/local/queue.js +1 -560
  172. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  173. package/vendor/desktop/lib/local/spill.js +1 -75
  174. package/vendor/desktop/lib/local/telemetry.js +1 -470
  175. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  176. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  177. package/vendor/desktop/lib/provider-key-mirror.js +1 -252
  178. package/vendor/desktop/lib/quick-launcher.js +1 -84
  179. package/vendor/desktop/lib/settings.js +1 -890
  180. package/vendor/desktop/lib/sync/memory-queue.js +1 -60
  181. package/vendor/desktop/lib/sync/persist-gate.js +1 -148
  182. package/vendor/desktop/lib/sync/sessions.js +1 -106
  183. package/vendor/desktop/lib/window-state.js +1 -66
  184. package/vendor/desktop/main.js +67 -1
  185. package/vendor/desktop/package.json +3 -5
  186. package/vendor/desktop/preload.js +1 -679
  187. package/vendor/desktop/renderer/app.js +1 -7250
  188. package/vendor/desktop/renderer/avatar/assemble.js +1 -335
  189. package/vendor/desktop/renderer/avatar/avatar.js +1 -380
  190. package/vendor/desktop/renderer/avatar/cards.js +1 -141
  191. package/vendor/desktop/renderer/avatar/hud.js +1 -206
  192. package/vendor/desktop/renderer/avatar/machine.js +1 -213
  193. package/vendor/desktop/renderer/avatar/pane.js +1 -439
  194. package/vendor/desktop/renderer/avatar/parts.js +1 -437
  195. package/vendor/desktop/renderer/budget.js +1 -172
  196. package/vendor/desktop/renderer/companion.js +1 -223
  197. package/vendor/desktop/renderer/diff.js +1 -359
  198. package/vendor/desktop/renderer/diffview.js +1 -336
  199. package/vendor/desktop/renderer/filepreview.js +1 -211
  200. package/vendor/desktop/renderer/fingerprint.js +3 -789
  201. package/vendor/desktop/renderer/markdown.js +1 -168
  202. package/vendor/desktop/renderer/provider-mark.js +1 -311
  203. package/vendor/desktop/renderer/provider-toolbar.js +1 -134
  204. package/vendor/desktop/renderer/providers.js +1 -259
  205. package/vendor/desktop/renderer/quick.js +1 -285
  206. package/vendor/desktop/renderer/stream-policy.js +1 -387
  207. package/vendor/desktop/renderer/transcript-view.js +1 -323
  208. package/vendor/desktop/renderer/usage.js +1 -1239
  209. package/vendor/desktop/vendor/aegis.js +1 -2441
  210. package/vendor/desktop/vendor/attest.js +1 -518
  211. package/vendor/desktop/vendor/authorship-key.js +1 -410
  212. package/vendor/desktop/vendor/auto-provision.js +1 -134
  213. package/vendor/desktop/vendor/brain-catalog.js +1 -268
  214. package/vendor/desktop/vendor/byok-catalog.js +1 -199
  215. package/vendor/desktop/vendor/catalog-client.js +1 -487
  216. package/vendor/desktop/vendor/conversation-export.js +1 -177
  217. package/vendor/desktop/vendor/credentials.js +1 -494
  218. package/vendor/desktop/vendor/device-fingerprint.js +1 -141
  219. package/vendor/desktop/vendor/drive-connect.js +1 -110
  220. package/vendor/desktop/vendor/drive-upload.js +1 -234
  221. package/vendor/desktop/vendor/env-file.js +1 -1273
  222. package/vendor/desktop/vendor/faces/cli/LICENSE +661 -0
  223. package/vendor/desktop/vendor/faces/cli/README.md +784 -0
  224. package/vendor/desktop/vendor/faces/cli/bin/aegiscode.js +20 -0
  225. package/vendor/desktop/vendor/faces/cli/package.json +44 -0
  226. package/vendor/desktop/vendor/faces/cli/scripts/check.mjs +4 -0
  227. package/vendor/desktop/vendor/faces/cli/scripts/demo.mjs +4 -0
  228. package/vendor/desktop/vendor/faces/cli/scripts/predist.mjs +4 -0
  229. package/vendor/desktop/vendor/faces/cli/scripts/runtests.mjs +4 -0
  230. package/vendor/desktop/vendor/faces/cli/scripts/seal-gate.mjs +3 -0
  231. package/vendor/desktop/vendor/faces/cli/src/agents.js +3 -0
  232. package/vendor/desktop/vendor/faces/cli/src/app.js +3 -0
  233. package/vendor/desktop/vendor/faces/cli/src/art.js +3 -0
  234. package/vendor/desktop/vendor/faces/cli/src/autonomous.js +3 -0
  235. package/vendor/desktop/vendor/faces/cli/src/caps.js +3 -0
  236. package/vendor/desktop/vendor/faces/cli/src/chatflow.js +3 -0
  237. package/vendor/desktop/vendor/faces/cli/src/checkpoint.js +3 -0
  238. package/vendor/desktop/vendor/faces/cli/src/clipboard.js +3 -0
  239. package/vendor/desktop/vendor/faces/cli/src/cloudsync.js +3 -0
  240. package/vendor/desktop/vendor/faces/cli/src/commands.js +3 -0
  241. package/vendor/desktop/vendor/faces/cli/src/config.js +3 -0
  242. package/vendor/desktop/vendor/faces/cli/src/connect.js +3 -0
  243. package/vendor/desktop/vendor/faces/cli/src/credentials.js +3 -0
  244. package/vendor/desktop/vendor/faces/cli/src/deps.js +3 -0
  245. package/vendor/desktop/vendor/faces/cli/src/devrun.js +3 -0
  246. package/vendor/desktop/vendor/faces/cli/src/diff.js +3 -0
  247. package/vendor/desktop/vendor/faces/cli/src/diffview.js +3 -0
  248. package/vendor/desktop/vendor/faces/cli/src/engine.js +3 -0
  249. package/vendor/desktop/vendor/faces/cli/src/entitlement.js +3 -0
  250. package/vendor/desktop/vendor/faces/cli/src/events.js +3 -0
  251. package/vendor/desktop/vendor/faces/cli/src/export.js +3 -0
  252. package/vendor/desktop/vendor/faces/cli/src/filepreview.js +3 -0
  253. package/vendor/desktop/vendor/faces/cli/src/fingerprint.js +3 -0
  254. package/vendor/desktop/vendor/faces/cli/src/format.js +3 -0
  255. package/vendor/desktop/vendor/faces/cli/src/fuzzy.js +3 -0
  256. package/vendor/desktop/vendor/faces/cli/src/gate.js +3 -0
  257. package/vendor/desktop/vendor/faces/cli/src/history.js +3 -0
  258. package/vendor/desktop/vendor/faces/cli/src/init.js +3 -0
  259. package/vendor/desktop/vendor/faces/cli/src/input.js +3 -0
  260. package/vendor/desktop/vendor/faces/cli/src/keys.js +3 -0
  261. package/vendor/desktop/vendor/faces/cli/src/limits.js +3 -0
  262. package/vendor/desktop/vendor/faces/cli/src/markdown.js +3 -0
  263. package/vendor/desktop/vendor/faces/cli/src/mcp.js +3 -0
  264. package/vendor/desktop/vendor/faces/cli/src/models.js +3 -0
  265. package/vendor/desktop/vendor/faces/cli/src/naming.js +3 -0
  266. package/vendor/desktop/vendor/faces/cli/src/overlays.js +3 -0
  267. package/vendor/desktop/vendor/faces/cli/src/panels.js +3 -0
  268. package/vendor/desktop/vendor/faces/cli/src/permissions.js +3 -0
  269. package/vendor/desktop/vendor/faces/cli/src/ping.js +3 -0
  270. package/vendor/desktop/vendor/faces/cli/src/presence.js +3 -0
  271. package/vendor/desktop/vendor/faces/cli/src/provenance.js +58 -0
  272. package/vendor/desktop/vendor/faces/cli/src/provenance.lock.json +36 -0
  273. package/vendor/desktop/vendor/faces/cli/src/render.js +3 -0
  274. package/vendor/desktop/vendor/faces/cli/src/screen.js +3 -0
  275. package/vendor/desktop/vendor/faces/cli/src/screens.js +3 -0
  276. package/vendor/desktop/vendor/faces/cli/src/secret.js +3 -0
  277. package/vendor/desktop/vendor/faces/cli/src/securefs.js +3 -0
  278. package/vendor/desktop/vendor/faces/cli/src/settings.js +3 -0
  279. package/vendor/desktop/vendor/faces/cli/src/shared.js +3 -0
  280. package/vendor/desktop/vendor/faces/cli/src/sharedpaths.js +3 -0
  281. package/vendor/desktop/vendor/faces/cli/src/signup.js +3 -0
  282. package/vendor/desktop/vendor/faces/cli/src/summarize.js +3 -0
  283. package/vendor/desktop/vendor/faces/cli/src/sysdiag.js +3 -0
  284. package/vendor/desktop/vendor/faces/cli/src/system.js +3 -0
  285. package/vendor/desktop/vendor/faces/cli/src/theme.js +3 -0
  286. package/vendor/desktop/vendor/faces/cli/src/title.js +3 -0
  287. package/vendor/desktop/vendor/faces/cli/src/todos.js +3 -0
  288. package/vendor/desktop/vendor/faces/cli/src/tokens.js +3 -0
  289. package/vendor/desktop/vendor/faces/cli/src/topup.js +3 -0
  290. package/vendor/desktop/vendor/faces/cli/src/update.js +3 -0
  291. package/vendor/desktop/vendor/faces/cli/vendor/client/aegis.js +4 -0
  292. package/vendor/desktop/vendor/faces/cli/vendor/client/attest.js +3 -0
  293. package/vendor/desktop/vendor/faces/cli/vendor/client/authorship-key.js +3 -0
  294. package/vendor/desktop/vendor/faces/cli/vendor/client/auto-provision.js +3 -0
  295. package/vendor/desktop/vendor/faces/cli/vendor/client/brain-catalog.js +3 -0
  296. package/vendor/desktop/vendor/faces/cli/vendor/client/byok-catalog.js +3 -0
  297. package/vendor/desktop/vendor/faces/cli/vendor/client/catalog-client.js +3 -0
  298. package/vendor/desktop/vendor/faces/cli/vendor/client/conversation-export.js +3 -0
  299. package/vendor/desktop/vendor/faces/cli/vendor/client/credentials.js +3 -0
  300. package/vendor/desktop/vendor/faces/cli/vendor/client/device-fingerprint.js +3 -0
  301. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-connect.js +3 -0
  302. package/vendor/desktop/vendor/faces/cli/vendor/client/drive-upload.js +3 -0
  303. package/vendor/desktop/vendor/faces/cli/vendor/client/env-file.js +3 -0
  304. package/vendor/desktop/vendor/faces/cli/vendor/client/fingerprint.js +3 -0
  305. package/vendor/desktop/vendor/faces/cli/vendor/client/foreign-memory.js +3 -0
  306. package/vendor/desktop/vendor/faces/cli/vendor/client/google-signin.js +3 -0
  307. package/vendor/desktop/vendor/faces/cli/vendor/client/hooks.js +3 -0
  308. package/vendor/desktop/vendor/faces/cli/vendor/client/model-discovery.js +3 -0
  309. package/vendor/desktop/vendor/faces/cli/vendor/client/naming.js +3 -0
  310. package/vendor/desktop/vendor/faces/cli/vendor/client/platform.js +3 -0
  311. package/vendor/desktop/vendor/faces/cli/vendor/client/prefs.js +3 -0
  312. package/vendor/desktop/vendor/faces/cli/vendor/client/presence-constants.js +3 -0
  313. package/vendor/desktop/vendor/faces/cli/vendor/client/presence.js +3 -0
  314. package/vendor/desktop/vendor/faces/cli/vendor/client/record-vault.js +105 -0
  315. package/vendor/desktop/vendor/faces/cli/vendor/client/session-store.js +3 -0
  316. package/vendor/desktop/vendor/faces/cli/vendor/client/topup.js +3 -0
  317. package/vendor/desktop/vendor/faces/cli/vendor/client/touch.js +3 -0
  318. package/vendor/desktop/vendor/faces/cli/vendor/client/update.js +3 -0
  319. package/vendor/desktop/vendor/faces/cli/vendor/client/user-models.js +3 -0
  320. package/vendor/desktop/vendor/faces/cli/vendor/covenant/README.md +21 -0
  321. package/vendor/desktop/vendor/faces/cli/vendor/covenant/aegis.seal +177 -0
  322. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/aegis-seal.mjs +241 -0
  323. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/agents.js +3 -0
  324. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/attachments.js +3 -0
  325. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/autonomous.js +3 -0
  326. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/claude-pro.js +3 -0
  327. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/context.js +3 -0
  328. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/covenant.js +567 -0
  329. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/engine.js +3 -0
  330. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/entitlement.js +3 -0
  331. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/exec-plan.js +3 -0
  332. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/git-scope.js +3 -0
  333. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/integrity.js +3 -0
  334. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/local.js +3 -0
  335. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/prompt.js +3 -0
  336. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/queue.js +3 -0
  337. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/session-rounds.js +3 -0
  338. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/shell.js +3 -0
  339. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/spill.js +3 -0
  340. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/tools.js +3 -0
  341. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/turn-guard.js +3 -0
  342. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/local/worktree-lock.js +3 -0
  343. package/vendor/desktop/vendor/faces/cli/vendor/desktop/lib/settings.js +3 -0
  344. package/vendor/desktop/vendor/faces/cli/vendor/desktop/main.js +4 -0
  345. package/vendor/desktop/vendor/faces/cli/vendor/desktop/renderer/usage.js +3 -0
  346. package/vendor/desktop/vendor/faces/cli/vendor/hosts/install.js +1 -0
  347. package/vendor/desktop/vendor/faces/cli/vendor/hosts/openai-shim.js +2 -0
  348. package/vendor/desktop/vendor/faces/cli/vendor/hosts/spec.js +1 -0
  349. package/vendor/desktop/vendor/faces/cli/vendor/hosts/targets.js +1 -0
  350. package/vendor/desktop/vendor/faces/cli/vendor/mcp/server.js +4 -0
  351. package/vendor/desktop/vendor/faces/cli/vendor/mcp/tools.js +3 -0
  352. package/vendor/desktop/vendor/faces/cli/vendor/one/src/child.js +3 -0
  353. package/vendor/desktop/vendor/faces/cli/vendor/one/src/permissions.js +3 -0
  354. package/vendor/desktop/vendor/faces/cli/vendor/one/src/selfhost.js +3 -0
  355. package/vendor/desktop/vendor/faces/cli/vendor/tools/agent-gate.mjs +1203 -0
  356. package/vendor/desktop/vendor/fingerprint.js +1 -1064
  357. package/vendor/desktop/vendor/foreign-memory.js +1 -669
  358. package/vendor/desktop/vendor/google-signin.js +1 -133
  359. package/vendor/desktop/vendor/hooks.js +1 -430
  360. package/vendor/desktop/vendor/model-discovery.js +1 -373
  361. package/vendor/desktop/vendor/naming.js +1 -283
  362. package/vendor/desktop/vendor/platform.js +1 -937
  363. package/vendor/desktop/vendor/prefs.js +1 -351
  364. package/vendor/desktop/vendor/presence-constants.js +1 -107
  365. package/vendor/desktop/vendor/presence.js +1 -438
  366. package/vendor/desktop/vendor/record-vault.js +3 -1055
  367. package/vendor/desktop/vendor/selfhost.js +3 -0
  368. package/vendor/desktop/vendor/session-store.js +1 -575
  369. package/vendor/desktop/vendor/topup.js +1 -297
  370. package/vendor/desktop/vendor/touch.js +1 -458
  371. package/vendor/desktop/vendor/update.js +1 -763
  372. package/vendor/desktop/vendor/user-models.js +1 -381
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const path=require("node:path"),{spawn:spawn}=require("node:child_process"),{resolveShared:resolveShared}=require("./sharedpaths.js"),limits=require("./limits.js"),install=require(resolveShared(path.join("hosts","install.js"))),targets=require(resolveShared(path.join("hosts","targets.js"))),spec=require(resolveShared(path.join("hosts","spec.js"))),SUBCOMMANDS=new Set(["install","remove","status","list","print","serve","shim","help"]),USAGE="aegiscode mcp — put AEGIS inside your editor.\n\nUsage:\n aegiscode mcp install [options] write the editor config (merges, never replaces)\n aegiscode mcp status [options] which hosts are configured, and do they still work\n aegiscode mcp list every supported host, its config file and its docs\n aegiscode mcp print <host> show the entry that would be written, touch nothing\n aegiscode mcp remove [options] take our entry out again\n aegiscode mcp serve run the stdio MCP server (editors spawn this themselves)\n aegiscode mcp shim [options] run the OpenAI-compatible endpoint on loopback\n\nTargets:\n --target <id> one host, repeatable and comma-separated (see `aegiscode mcp list`)\n --all every supported host, not just the ones detected\n --scope <s> user (default) or workspace — workspace writes into the\n current directory, which is committed in many projects\n\nInstall options:\n --dry-run print what would change, write nothing\n --with-key embed the resolved API key in the config file. Off by\n default: these files are plain and often world-readable, and\n the server already finds a key from the environment, the\n 0600 store, or ~/.aegiscode/.env\n --prompt-key VS Code only: reference its own secret prompt instead of\n storing a value anywhere\n --base <url> API base to record (default $AEGIS_API_BASE or aegiscloud.org)\n\nShim options:\n --port <n> default 8787\n --host <addr> default 127.0.0.1; any non-loopback address also requires\n --allow-remote ... this flag, because the endpoint spends your tokens\n\nOptions:\n --json machine-readable output\n -h, --help this text\n",BOOL_FLAGS=new Set(["json","all","dry-run","with-key","prompt-key","yes","allow-remote","help"]),VALUE_FLAGS=new Set(["target","scope","base","port","host"]);function parseFlags(e){const t={terms:[],json:!1,flags:{},targetList:[]};for(let s=0;s<e.length;s++){const n=e[s];if("--json"===n){t.json=!0;continue}if("-h"===n){t.flags.help=!0;continue}if(!n.startsWith("--")){t.terms.push(n);continue}const[r,o]=n.slice(2).split("="),i=r.trim();if(BOOL_FLAGS.has(i)){t.flags[i]=!0;continue}if(!VALUE_FLAGS.has(i))throw new Error(`unknown option: --${i}`);const a=void 0!==o?o:e[++s];if(void 0===a)throw new Error(`--${i} needs a value`);if("target"!==i)t.flags[i]=a;else for(const e of String(a).split(",")){const s=e.trim();s&&t.targetList.push(s)}}return t}function selectTargets(e,t,s){const n=[];let r,o=[];if(e.targetList.length){r="named";for(const t of e.targetList){const e=targets.getTarget(t);e?o.push(e.id):n.push(t)}o=[...new Set(o)]}else e.flags.all?(r="all",o=targets.targetIds()):(r="detected",o=[...install.detected({ctx:t})]);return{targets:o.map((e=>targets.getTarget(e))).filter(Boolean),ids:o,source:r,unknown:n}}function specOptsFor(e,t){const s={};if(e.flags.base&&(s.apiBase=String(e.flags.base)),e.flags["prompt-key"]&&(s.promptKey=!0),e.flags["with-key"]){const e=require("./credentials.js").keyStatus();if(!e.configured)return t.stderr.write("aegiscode mcp: --with-key was given but no key is configured. Run `aegiscode login` first, or export AEGIS_API_KEY.\n"),null;s.apiKey=e.key}return s}function scopeFor(e,t,s,{quiet:n=!1}={}){const r=String(t.flags.scope||"user").toLowerCase();if("user"!==r&&"workspace"!==r&&"project"!==r)return null;const o="project"===r?"workspace":r;return(e.scopes||["user"]).includes(o)?o:(n||s.stderr.write(`aegiscode mcp: ${e.label} has no ${o} config — it supports: ${(e.scopes||["user"]).join(", ")}\n`),null)}function homeShort(e,t){const s=t.home||t.env.HOME||t.env.USERPROFILE;return s&&e.startsWith(s)?`~${e.slice(s.length)}`:e}function statusWord(e){return e.error?"unreadable":e.installed?!1===e.serverExists?"BROKEN":e.serverUnverifiable?"host-resolved":"installed":e.exists?"not installed":"no config"}function statusText(e,t,s){const n=Math.max(9,...e.map((e=>statusWord(e).length))),r=[];for(const s of e)r.push(` ${statusWord(s).padEnd(n)} ${s.id.padEnd(14)} ${homeShort(s.file,t)}${"workspace"===s.scope?" (workspace)":""}`),s.error&&r.push(` ${" ".repeat(n)} ${s.error}`),!1===s.serverExists&&r.push(` ${" ".repeat(n)} the server this names is gone: ${s.serverPath}\n ${" ".repeat(n)} re-run \`aegiscode mcp install --target ${s.id}\``),s.serverUnverifiable&&r.push(` ${" ".repeat(n)} path is host-resolved (${s.serverPath}) — the editor\n ${" ".repeat(n)} expands it at load time, so it cannot be checked from here.`);return r.join("\n")+"\n"}function runList(e,t,s){const n=install.detected({ctx:t}),r=targets.TARGETS.map((e=>({id:e.id,label:e.label,kind:e.kind,scopes:e.scopes||["user"],docs:e.docs,verified:Boolean(e.verified),detected:n.has(e.id),files:(e.scopes||["user"]).map((s=>e.path(s,t))),note:e.note||null})));if(e.json)return s.stdout.write(`${JSON.stringify(r,null,2)}\n`),0;s.stdout.write(`${r.length} hosts AEGIS can appear in:\n\n`);for(const e of r)s.stdout.write(` ${e.id.padEnd(16)} ${e.label}${e.detected?" [present on this machine]":""}\n`),s.stdout.write(` ${" ".repeat(16)} ${homeShort(e.files[0],t)} (${e.scopes.join(", ")})\n`),e.note&&s.stdout.write(` ${" ".repeat(16)} ${e.note}\n`),e.verified||s.stdout.write(` ${" ".repeat(16)} ✗ NOT VERIFIED against this host's own docs — check ${e.docs} before relying on it\n`);return s.stdout.write("\n `aegiscode mcp install` with no --target configures every host detected above.\n API keys are NOT written unless you pass --with-key.\n"),0}function runStatus(e,t,s){const n=selectTargets(e,t,s);if(n.unknown.length)return s.stderr.write(`aegiscode mcp: unknown host${n.unknown.length>1?"s":""}: ${n.unknown.join(", ")} — run \`aegiscode mcp list\`\n`),2;const r=e.flags.scope?scopeFor(n.targets[0],e,s):null;if(e.flags.scope&&!r)return 2;const o=e.targetList.length?n.ids:[];let i=install.status(o,{ctx:t});if(e.flags.all||e.targetList.length||(i=i.filter((e=>e.exists||e.installed||e.error))),e.json)return s.stdout.write(`${JSON.stringify(i.map((e=>({id:e.id,label:e.label,scope:e.scope,file:e.file,exists:e.exists,installed:e.installed,state:statusWord(e),server_path:e.serverPath||null,server_exists:void 0===e.serverExists?null:e.serverExists,server_unverifiable:Boolean(e.serverUnverifiable),entry:e.entry,error:e.error,docs:e.docs,verified:e.verified}))),null,2)}\n`),0;if(!i.length)return s.stdout.write("aegiscode mcp: no editor configs found on this machine.\n `aegiscode mcp list` shows every host AEGIS supports,\n `aegiscode mcp install --target <id>` configures one.\n"),0;s.stdout.write(statusText(i,t,s));const a=i.filter((e=>!1===e.serverExists)).length,l=i.filter((e=>e.installed)).length,c=i.filter((e=>e.serverUnverifiable)).length;return s.stdout.write(`\n ${l} configured`+(c?`, ${c} host-resolved`:"")+(a?`, ${a} pointing at a missing server — re-run install`:"")+".\n"),0}function runInstall(e,t,s){const n=selectTargets(e,t,s);if(n.unknown.length)return s.stderr.write(`aegiscode mcp: unknown host${n.unknown.length>1?"s":""}: ${n.unknown.join(", ")} — run \`aegiscode mcp list\`\n`),2;if(!n.targets.length)return s.stderr.write("aegiscode mcp: no editor detected, so there is nothing to configure automatically.\n `aegiscode mcp list` shows the hosts AEGIS supports;\n `aegiscode mcp install --target <id>` names one explicitly.\n"),2;const r=specOptsFor(e,s);if(!r)return 2;if(e.flags["prompt-key"]&&n.targets.some((e=>!e.supportsKeyPrompt)))return s.stderr.write("aegiscode mcp: --prompt-key only works for VS Code, which is the only host with a secret-prompt mechanism. Drop it for the rest.\n"),2;const o=spec.resolveServer(),i=[];let a=0;for(const o of n.targets){const l="named"===n.source,c=scopeFor(o,e,s,{quiet:!l});if(!c){l?a++:(i.push({id:o.id,file:null,applied:!1,skipped:!0}),s.stdout.write(`aegiscode mcp: ${o.label} — skipped (no ${String(e.flags.scope||"user")} config)\n`));continue}const d=install.planTarget(o,c,{ctx:t,specOpts:r});if(d.error){s.stderr.write(`aegiscode mcp: ${o.label} — ${d.error.message}\n`),i.push({id:o.id,file:d.file,error:d.error.message,applied:!1}),a++;continue}if(!d.changed){s.stdout.write(`aegiscode mcp: ${o.label} — already configured (${homeShort(d.file,t)})\n`),i.push({id:o.id,file:d.file,applied:!1,changed:!1});continue}if(e.flags["dry-run"]){i.push({id:o.id,file:d.file,applied:!1,changed:!0,dryRun:!0}),s.stdout.write(`aegiscode mcp: ${o.label} — would write ${homeShort(d.file,t)}\n${indent(d.after)}\n`);continue}const p=install.apply(d,{withKey:Boolean(e.flags["with-key"])});i.push({id:o.id,file:d.file,applied:p.applied,changed:d.changed,backup:p.backupOf||null}),s.stdout.write(`aegiscode mcp: ${o.label} — wrote ${homeShort(d.file,t)}`+(p.backupOf?` (backup: ${homeShort(p.backupOf,t)})`:"")+"\n")}return e.flags["dry-run"]||a||!i.some((e=>e.applied))||(o.exists?s.stdout.write("\n Restart the editor (or its MCP host) to pick this up. Configured hosts\n spawn the AEGIS server themselves — nothing needs to keep running in a terminal.\n"):(s.stderr.write(`aegiscode mcp: WARNING — the server file does not exist at ${o.path}, so the editors just configured will not start it.\n`),a++)),e.flags["dry-run"]&&s.stdout.write("\naegiscode mcp: dry run — nothing was written.\n"),e.json&&s.stdout.write(`${JSON.stringify({changed:i,server:o.path,exists:o.exists},null,2)}\n`),a?1:0}function indent(e){return String(e||"").split("\n").filter(((e,t,s)=>!(t===s.length-1&&""===e))).map((e=>` ${e}`)).join("\n")}function runRemove(e,t,s){const n=selectTargets(e,t,s);if(n.unknown.length)return s.stderr.write(`aegiscode mcp: unknown host${n.unknown.length>1?"s":""}: ${n.unknown.join(", ")}\n`),2;const r=e.targetList.length||e.flags.all?n.ids:[],o={};e.flags.base&&(o.apiBase=String(e.flags.base));const i=install.status(r,{ctx:t,specOpts:o}).filter((e=>e.installed));let a=0;if(!i.length)return s.stdout.write("aegiscode mcp: nothing to remove — no config names an AEGIS server.\n"),e.json&&s.stdout.write(`${JSON.stringify({removed:[],changed:[]},null,2)}\n`),0;const l=[];for(const n of i){const r=targets.getTarget(n.id),i=install.planRemove(r,n.scope,{ctx:t,specOpts:o});if(i.error){s.stderr.write(`aegiscode mcp: ${n.label} — ${i.error.message}\n`),a++;continue}if(!i.changed){s.stdout.write(`aegiscode mcp: ${n.label} — nothing of ours in ${homeShort(i.file,t)}\n`);continue}if(e.flags["dry-run"]){l.push({id:n.id,file:i.file,dryRun:!0}),s.stdout.write(`aegiscode mcp: ${n.label} — would update ${homeShort(i.file,t)}\n`);continue}const c=install.apply(i);l.push({id:n.id,file:i.file,backup:c.backupOf||null}),s.stdout.write(`aegiscode mcp: ${n.label} — removed from ${homeShort(i.file,t)}`+(c.backupOf?` (backup: ${homeShort(c.backupOf,t)})`:"")+"\n")}return e.flags["dry-run"]&&s.stdout.write("\naegiscode mcp: dry run — nothing was written.\n"),e.json&&s.stdout.write(`${JSON.stringify({changed:l},null,2)}\n`),a?1:0}function runPrint(e,t,s){const n=e.terms[0]||e.targetList[0];if(!n)return s.stderr.write("aegiscode mcp print: name a host — `aegiscode mcp print vscode`\n"),2;const r=targets.getTarget(n);if(!r)return s.stderr.write(`aegiscode mcp print: unknown host "${n}" — run \`aegiscode mcp list\`\n`),2;const o={};e.flags.base&&(o.apiBase=String(e.flags.base)),e.flags["prompt-key"]&&(o.promptKey=!0);const i=spec.buildSpec(o),a=install.renderEntry(r,i),l=r.path(r.scopes?r.scopes[0]:"user",t);return"mcp-toml"===r.kind?(s.stdout.write(`# ${l}\n[${r.container}.${a.name||"aegis"}]\n${a.join("\n")}\n`),0):e.json?(s.stdout.write(`${JSON.stringify({file:l,container:r.container,entry:a},null,2)}\n`),0):(s.stdout.write(`# ${l}\n${JSON.stringify({[r.container]:{aegis:a}},null,2)}\n`),e.flags["prompt-key"]&&s.stdout.write(`\n# VS Code also needs this in the same file so the prompt can resolve:\n${JSON.stringify({inputs:[spec.vscodeKeyInput()]},null,2)}\n`),0)}function runChild(e,t,s){return new Promise((n=>{const r=spawn(process.execPath,[e,...t],{stdio:"inherit"});r.on("error",(t=>{s.stderr.write(`aegiscode mcp: could not start ${e}: ${t.message}\n`),n(1)})),r.on("exit",((e,t)=>{n(t?0:null===e?1:e)}))}))}function runServe(e,t,s){const n=spec.resolveServer();return n.exists?(s.stderr.write(`aegiscode mcp: serving ${n.path} on stdio.\n Editors start this themselves — you only need it to test one by hand.\n`),runChild(n.path,[],s)):(s.stderr.write(`aegiscode mcp serve: no server found at ${n.path}.\n Looked in:\n ${n.candidates.join("\n ")}\n`),2)}function runShim(e,t,s){const n=resolveShared(path.join("hosts","openai-shim.js")),r=[];return e.flags.port&&r.push("--port",String(e.flags.port)),e.flags.host&&r.push("--host",String(e.flags.host)),e.flags["allow-remote"]&&r.push("--allow-remote"),runChild(n,r,s)}async function runMcpCommand(e,t,s={}){const n=s.stdout||process.stdout,r=s.stderr||process.stderr,o={stdout:n,stderr:r};if(limits.armed())return limits.refuse();let i;try{i=parseFlags(t||[])}catch(e){return r.write(`aegiscode mcp: ${e.message}\n`),2}if(i.json=Boolean(s.json||i.json),o.json=i.json,"help"===e||!SUBCOMMANDS.has(e)||i.flags.help)return n.write(USAGE),"help"===e||i.flags.help?0:2;if("serve"===e||"shim"===e){const t=install.hostCtx({cwd:s.cwd||process.cwd(),home:s.home||null});return"serve"===e?runServe(i,t,o):runShim(i,t,o)}if("list"===e)return runList(i,install.hostCtx({cwd:s.cwd||process.cwd(),home:s.home||null}),o);if("print"===e)return runPrint(i,install.hostCtx({cwd:s.cwd||process.cwd(),home:s.home||null}),o);const a=install.hostCtx({cwd:s.cwd||process.cwd(),home:s.home||null});return"install"===e?runInstall(i,a,o):"remove"===e?runRemove(i,a,o):"status"===e?runStatus(i,a,o):2}module.exports={runMcpCommand:runMcpCommand,parseFlags:parseFlags,selectTargets:selectTargets,USAGE:USAGE,SUBCOMMANDS:SUBCOMMANDS};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const path=require("node:path"),{resolveShared:resolveShared}=require("./sharedpaths.js"),{offerableCatalog:offerableCatalog}=require(resolveShared(path.join("client","brain-catalog.js"))),envFile=require(resolveShared(path.join("client","env-file.js"))),claudePro=require(resolveShared(path.join("desktop","lib","local","claude-pro.js")));function claudeProLoggedIn(){try{return!!claudePro.claudeProStatus({env:process.env}).loggedIn}catch{return!1}}const NO_PIN=null,ID_NOTES=Object.freeze({"openai-gpt4o-mini":"OpenAI gpt-4o-mini, pooled","anthropic-haiku":"Anthropic Haiku, pooled","nexus-brain":"pooled brain · multi-call fan-out, sized by /effort"});function normalizeModel(e){const o="string"==typeof e?{id:e}:e;if(!o||"object"!=typeof o)return null;const r="string"==typeof o.id?o.id.trim():"";if(!r)return null;const n="string"==typeof o.alias_of&&o.alias_of.trim()?o.alias_of.trim():null,i=Array.isArray(o.capabilities)?o.capabilities.filter((e=>"string"==typeof e&&e)):[],t={id:r,label:"string"==typeof o.label&&o.label.trim()||"string"==typeof o.name&&o.name.trim()||r,note:("string"==typeof o.note&&o.note.trim()?o.note.trim():"")||(n?`alias of ${n}`:ID_NOTES[r]||i.join(", ")),hidden:!0===o.hidden,aliasOf:n,capabilities:i};return"string"==typeof o.provider&&o.provider.trim()&&(t.provider=o.provider.trim()),!0===o.configured&&(t.configured=!0),"string"==typeof o.cls&&o.cls.trim()&&(t.cls=o.cls.trim()),t}function normalizeModelCatalog(e){const o=Array.isArray(e)?e:Array.isArray(e&&e.models)?e.models:[],r=[],n=new Set;for(const e of o){const o=normalizeModel(e);o&&!n.has(o.id)&&(n.add(o.id),r.push(o))}return r}function pickerEntries(e){const o=Array.isArray(e)?e.filter(Boolean):[],r=offerableCatalog(o).map(normalizeModel).filter(Boolean);if(r.length)return r;const n=o.filter((e=>!e.aliasOf));return n.length?n:o}function findModel(e,o){const r="string"==typeof o?o.trim():"";return r&&(Array.isArray(e)?e:[]).find((e=>e&&e.id===r))||null}function catalogIds(e){return new Set((Array.isArray(e)?e:[]).map((e=>String(e&&e.id||"").toLowerCase())).filter(Boolean))}function modelKeyPlan(e,o={}){const r=e&&e.id||"",n=envFile.keyForModelId(r,e&&e.cls);if(!n.env)return{needed:!1,env:"",provider:"",pooled:n.pooled,status:null,why:"this id has no key variable"};if(n.foreign){const e=!!envFile.resolveForeignSecret(n.env)||claudeProLoggedIn();return{needed:!e,env:n.env,provider:"",pooled:!1,status:{present:e,inFile:e,source:e?"file":"none"},why:e?`${n.env} is already set aside for Claude Code Pro`:`no ${n.env} is set aside for Claude Code Pro`}}const i=envFile.keyStatus(n.env);if(n.pooled){const e=!i.present&&!o.accountConfigured;return{needed:e,env:n.env,provider:"",pooled:!0,status:i,why:e?`no ${n.env} is set on this machine`:`account key present (${o.accountConfigured&&!i.present?"credentials.json":i.source})`}}const t=!i.inFile&&!o.hasStored;return{needed:t,env:n.env,provider:n.provider,pooled:!1,status:i,why:t?`no ${n.env} is stored for provider "${n.provider}"`:`${n.env} is already stored (${i.inFile?i.source:"provider store"})`}}function modelKeyQueue(e,o={}){const r=e&&e.id||"";if(!String(r).trim())return[];const n=envFile.keyForModelId(r,e&&e.cls);if(!n.env)return[];if(n.foreign)return envFile.resolveForeignSecret(n.env)||claudeProLoggedIn()?[]:[{env:n.env,provider:"",vendor:"",role:"claude-pro",needed:!0,status:{present:!1},why:`no ${n.env} is set aside for Claude Code Pro`}];const i=[],t=envFile.keyStatus(envFile.ACCOUNT_ENV_VAR);t.present||o.accountConfigured||i.push({env:envFile.ACCOUNT_ENV_VAR,provider:"",vendor:"",role:"account",needed:!0,status:t,why:`no ${envFile.ACCOUNT_ENV_VAR} is set on this machine`});const l=n.vendor||"",d=l?envFile.envVarFor(l):"",s=!(!l||"function"!=typeof o.hasStoredFor||!o.hasStoredFor(l));if(d){const e=envFile.keyStatus(d);e.inFile||s||i.push({env:d,provider:l,vendor:l,role:"provider",needed:!0,status:e,why:e.present?`${d} is exported in this shell only — the desktop cannot see it`:`no ${d} is stored for provider "${l}"`})}return i}function storeModelKey(e,o,r={}){const n=envFile.keyForModelId(e&&e.id,e&&e.cls),i=String(r.env||"").trim()||n.env;if(!i)return{ok:!1,file:"",changed:!1,error:`cannot name a key variable for "${e&&e.id||""}"`,env:"",provider:"",pooled:n.pooled};const t={...r};delete t.env;const l=n.foreign?envFile.setForeignSecret(i,o,t):envFile.setEnvValue(i,o,t),d=!n.foreign&&i===envFile.ACCOUNT_ENV_VAR;return{...l,env:i,provider:i===n.env?n.provider:"",pooled:d,foreign:!!n.foreign}}function keyVarForModel(e){return envFile.keyForModelId(e&&e.id,e&&e.cls).env}function providerForModel(e){const o=String(e&&e.id||"").trim();return o&&(envFile.keyForModelId(o,e&&e.cls).provider||envFile.providerForModelId(o,e&&e.cls))||""}module.exports={NO_PIN:null,ID_NOTES:ID_NOTES,normalizeModel:normalizeModel,normalizeModelCatalog:normalizeModelCatalog,pickerEntries:pickerEntries,findModel:findModel,catalogIds:catalogIds,modelKeyPlan:modelKeyPlan,modelKeyQueue:modelKeyQueue,storeModelKey:storeModelKey,keyVarForModel:keyVarForModel,providerForModel:providerForModel,claudeProLoggedIn:claudeProLoggedIn};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),CANDIDATES=[path.join(__dirname,"..","..","client","naming.js"),path.join(__dirname,"..","vendor","client","naming.js"),path.join(__dirname,"..","vendor","naming.js")];let resolved=null;for(const e of CANDIDATES)if(fs.existsSync(e)){resolved=e;break}if(!resolved)throw new Error("aegiscode: cannot find client/naming.js. Expected it beside cli/ (in the repo) or under cli/vendor/ (installed package). Reinstall the package, or run `node scripts/predist.mjs` from cli/ if this is a source checkout.");module.exports=require(resolved);
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{span:span,padLine:padLine}=require("./screen.js"),{C:C,BOLD:BOLD,BOLD_OFF:BOLD_OFF,GLYPH:GLYPH}=require("./theme.js");let fuzzy=null;try{fuzzy=require("./fuzzy.js")}catch{fuzzy=null}function rankCommands(e,a){if(fuzzy&&"function"==typeof fuzzy.fuzzyRankWithAliases)return fuzzy.fuzzyRankWithAliases(e,a,(e=>e.name),(e=>e.aliases||[]));const n=String(e||"").toLowerCase();return n?a.filter((e=>`${e.name} ${(e.aliases||[]).join(" ")}`.toLowerCase().includes(n))):a}const descOf=e=>null!=e.help?e.help:null!=e.desc?e.desc:"",hintOf=e=>null!=e.hint?e.hint:null!=e.args?e.args:"";function fit(e,a){return e.map((e=>padLine(e,a)))}const blank=e=>[span(""," ".repeat(Math.max(0,e)))];function boldMatched(e,a,n){const s=fuzzy&&"function"==typeof fuzzy.fuzzyMatchPositions?fuzzy.fuzzyMatchPositions(e,a):[];if(!s||!s.length)return[span(n,a)];const t=[];let r=0;for(const e of s)e>r&&t.push(span(n,a.slice(r,e))),t.push(span(n+BOLD,a[e])),r=e+1;return r<a.length&&t.push(span(n,a.slice(r))),t}function renderPalette(e,a={},n=80,s=24){!Array.isArray(e)&&e&&"object"==typeof e&&(a=e,e=Array.isArray(e.commands)?e.commands:[]);const t=rankCommands(a.query||"",e||[]),r=Number.isInteger(a.sel)?a.sel:0,p=t.length,l=Math.max(1,Math.min(12,s-8)),o=Math.max(0,Math.min(r-Math.floor(l/2),Math.max(0,p-l))),u=t.slice(o,o+l),h=[];h.push(blank(n)),h.push([span(C.gray," "+"─".repeat(Math.max(10,n-4)))]);for(let e=0;e<u.length;e++){const n=u[e],s=o+e===r,t=s?span(C.lavender,GLYPH.cursor):span(""," "),p=s?C.blue:C.white,l=[span(p,"/"),...boldMatched(a.query||"",n.name,p)],i=" ".repeat(Math.max(1,22-[...n.name].length));h.push([span(""," "),t,span(""," "),...l,span(n.unavailable?C.dim:C.gray,i+descOf(n))]),s&&hintOf(n)&&h.push([span(""," "),span(C.gray,`${GLYPH.hook} Usage: /${n.name} ${hintOf(n)}`)])}for(;h.length<4+2*l;)h.push(blank(n));return h.push([span(C.gray," "+"─".repeat(Math.max(10,n-4)))]),h.push([span(C.gray,` type to filter ${GLYPH.bullet} shift+enter runs the top row ${GLYPH.bullet} enter runs ${GLYPH.bullet} esc closes`)]),fit(h,n)}const PICKER_HINT=`↑↓ or tab move ${GLYPH.bullet} enter pins ${GLYPH.bullet} shift+↑↓ pins at once ${GLYPH.bullet} esc cancels`;function renderModelPicker(e,a=0,n=80,s=24,t=null,r=null,p=null){const l=[],o="function"==typeof p&&r?p(r):null;l.push(blank(n)),l.push([span(""," "),span(C.white+BOLD,"Select model"),span(BOLD_OFF,""),...o?[span(C.gray,` — running on ${o}`)]:[]]),l.push([span(""," "),span(C.gray,"Switch between models. Your pick becomes the default for new sessions.")]),l.push([span(""," "),span(C.gray,"Nexus is pooled; any other row prompts for its provider key on pick.")]),l.push(blank(n));const u=Math.max(1,(s||24)-8),h=e.length,i=h>u?Math.min(Math.max(0,a-Math.floor(u/2)),h-u):0,c=Math.min(h,i+u);i>0&&l.push([span(""," "),span(C.gray,`↑ ${i} more above`)]);for(let n=i;n<c;n++){const s=e[n]||{},r=s.label||s.name||s.id||"",p=n===a,o=null!=t&&s.id===t,u=p?span(C.lavender,GLYPH.cursor):span(""," "),h=span(C.gray,`${n+1}.`),i=span(p?C.lavender:C.white,r),c=o?span(C.green," "+GLYPH.check):span("",""),d=" ".repeat(Math.max(1,22-[...r].length)),g="byok"!==s.cls||s.configured?"":"[key needed] ";l.push([span(""," "),u,span(""," "),h,span(""," "),i,c,span(C.gray,d+g+(s.note||s.model||""))])}return c<h&&l.push([span(""," "),span(C.gray,`↓ ${h-c} more below`)]),l.push(blank(n)),l.push([span(""," "),span(C.gray,PICKER_HINT)]),fit(l,n)}const EFFORT_LEVELS=[{label:"Low",note:"Fastest, cheapest budget"},{label:"Medium",note:"Balanced"},{label:"High",note:"Highest budget, slowest (default)"},{label:"Max",note:"Deepest reasoning where the model defines it; same budget as high"}],EFFORT_VALUES=EFFORT_LEVELS.map((e=>void 0===e.value?e.label.toLowerCase():e.value));function renderEffortPicker(e=0,a=80,n=null,s=EFFORT_LEVELS){const t=[];t.push(blank(a)),t.push([span(""," "),span(C.white+BOLD,"Select effort"),span(BOLD_OFF,"")]),t.push([span(""," "),span(C.gray,"Sets the token budget the pool sizes each turn from.")]),t.push(blank(a));for(let a=0;a<s.length;a++){const r=s[a],p=a===e,l=String(n||"high").toLowerCase()===String(r.label).toLowerCase(),o=p?span(C.lavender,GLYPH.cursor):span(""," "),u=span(p?C.lavender:C.white,r.label),h=l?span(C.green," "+GLYPH.check):span("",""),i=" ".repeat(Math.max(1,12-[...r.label].length));t.push([span(""," "),o,span(""," "),u,h,span(C.gray,i+r.note)])}return t.push(blank(a)),t.push([span(""," "),span(C.gray,PICKER_HINT)]),fit(t,a)}function renderClassPicker(e,a=0,n=80,s=null,t=null){const r=Array.isArray(e)?e:[],p=e=>("function"==typeof t?t(e):e)||e,l=[];l.push(blank(n)),l.push([span(""," "),span(C.white+BOLD,"Select class"),span(BOLD_OFF,"")]),l.push([span(""," "),span(C.gray,"Which route the next turn takes — who pays, and with which credential.")]),l.push(blank(n));for(let e=0;e<r.length;e++){const n=r[e]||{},t=n.class,o=e===a,u=null!=s&&t===s,h=o?span(C.lavender,GLYPH.cursor):span(""," "),i=p(t),c=span(o?C.lavender:C.white,i),d=u?span(C.green," "+GLYPH.check):span("",""),g=" ".repeat(Math.max(1,14-[...i].length)),f="byok"===t?n.configured?"your key, relayed by AEGIS — billed a handling fee":"needs a provider key: /byok-key <provider>":"the pool — your AEGIS account key pays for it";l.push([span(""," "),h,span(""," "),c,d,span(C.gray,g+f)])}return l.push(blank(n)),l.push([span(""," "),span(C.gray,PICKER_HINT)]),fit(l,n)}function renderResumeList(e,a=0,n=80,s=24){const t=Array.isArray(e)?e:[],r=[];r.push(blank(n)),r.push([span(""," "),span(C.gray,"─".repeat(Math.max(10,n-4)))]),r.push([span(""," "),span(C.white+BOLD,"Resume session"),span(C.gray,` (${a+1} of ${Math.max(1,t.length)})`),span(BOLD_OFF,"")]);const p=Math.max(10,n-4);r.push([span(""," "),span(C.gray,"╭"+"─".repeat(Math.max(0,p-2))+"╮")]),r.push([span(""," "),span(C.gray,"│"),span(C.white,"⌕ Search…"),span(""," ".repeat(Math.max(0,p-9))),span(C.gray,"│")]),r.push([span(""," "),span(C.gray,"╰"+"─".repeat(Math.max(0,p-2))+"╯")]),r.push(blank(n));const l=Math.max(2,Math.min(6,s-16)),o=Math.max(0,Math.min(a-Math.floor(l/2),Math.max(0,t.length-l))),u=t.slice(o,o+l);for(let e=0;e<u.length;e++){const n=u[e]||{},s=o+e===a,t=s?span(C.lavender,GLYPH.cursor):span(""," "),p=n.own?span(C.green,GLYPH.star+" "):span(C.gray,GLYPH.bullet+" "),l=span(s?C.white+BOLD:C.white,n.summary||"(untitled)");r.push([span(""," "),t,span(""," "),p,l]),r.push([span(""," "),span(C.gray,`${n.cwd||"~"} ${GLYPH.bullet} ${ago(n.time)}`)])}for(;r.length<6+2*l;)r.push(blank(n));return r.push([span(""," "),span(C.gray,"─".repeat(Math.max(10,n-4)))]),r.push([span(""," "),span(C.gray,`Ctrl+A all projects ${GLYPH.bullet} Space to preview ${GLYPH.bullet} Type to search ${GLYPH.bullet} Esc to cancel`)]),fit(r,n)}function ago(e){if(!e)return"";const a=Date.now()-new Date(String(e)).getTime();return a>=0&&!Number.isNaN(a)?a<6e4?`${Math.max(1,Math.round(a/1e3))}s ago`:a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:`${Math.round(a/864e5)}d ago`:""}function renderProviderPicker(e,a=0,n=80,s=null,t=null){const r=Array.isArray(e)?e:[],p=[];p.push(blank(n)),p.push([span(""," "),span(C.white+BOLD,"Select provider"),span(BOLD_OFF,"")]),p.push([span(""," "),span(C.gray,"Which vendor the key you are about to paste belongs to.")]),p.push(blank(n));for(let e=0;e<r.length;e++){const n=r[e]||{},t=String(n.id||"");if(!t)continue;const l=e===a,o=null!=s&&t===s,u=l?span(C.lavender,GLYPH.cursor):span(""," "),h=span(l?C.lavender:C.white,t),i=o?span(C.green," "+GLYPH.check):span("",""),c=String(n.label||""),d=" ".repeat(Math.max(1,16-[...t].length)),g=n.configured?span(C.green,"set"+(n.masked?` (${n.masked})`:"")):span(C.gray,"not set");p.push([span(""," "),u,span(""," "),h,i,span(C.gray,d+(c?`${c} · `:"")),g])}return p.push(blank(n)),p.push([span(""," "),span(C.gray,t||`↑↓ or tab move ${GLYPH.bullet} enter picks ${GLYPH.bullet} esc cancels`)]),fit(p,n)}module.exports={boldMatched:boldMatched,renderPalette:renderPalette,renderModelPicker:renderModelPicker,renderEffortPicker:renderEffortPicker,renderClassPicker:renderClassPicker,renderProviderPicker:renderProviderPicker,renderResumeList:renderResumeList,EFFORT_LEVELS:EFFORT_LEVELS,EFFORT_VALUES:EFFORT_VALUES,PICKER_HINT:PICKER_HINT};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{span:span,getSize:getSize,lineWidth:lineWidth}=require("./screen.js"),{themeOf:themeOf,BOLD:BOLD,BOLD_OFF:BOLD_OFF,GLYPH:GLYPH}=require("./theme.js"),{goUrl:goUrl}=require("./signup.js"),{cwdName:cwdName,pathName:pathName}=require("./format.js"),VERSION=require("../package.json").version;function num(s){const e=Number(s);return Number.isFinite(e)?e:0}function str(s){return null==s?"":String(s)}function wrapRows(s,e,n,a){const t=Math.max(20,(Number(a)||80)-2-e),o=" ".repeat(e),r=str(s).split(/\s+/).filter(Boolean),p=[];let i="";for(const s of r){const e=i?`${i} ${s}`:s;i&&e.length>t?(p.push([span("",o),span(n,i)]),i=s):i=e}return i&&p.push([span("",o),span(n,i)]),p.length?p:[[span("",o),span(n,"")]]}function tokenBuckets(s){const e=num(s.input),n=num(s.output),a=num(s.cacheRead),t=num(s.cacheWrite),o=e+a+t;return{input:e,output:n,cacheRead:a,cacheWrite:t,prompt:o,total:num(s.total)||o+n}}function fmtTokens(s){const e=Number(s);return!Number.isFinite(e)||e<=0?"0":Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function fmtEur(s){const e=Number(s);if(!Number.isFinite(e))return"€?";const n=Math.abs(e);return`€${n<.01?n.toFixed(4):n.toFixed(2)}`}function ago(s){if(!s)return"";const e=Date.now()-new Date(String(s)).getTime();return e>=0&&!Number.isNaN(e)?e<6e4?`${Math.max(1,Math.round(e/1e3))}s ago`:e<36e5?`${Math.round(e/6e4)}m ago`:e<864e5?`${Math.round(e/36e5)}h ago`:`${Math.round(e/864e5)}d ago`:""}function contextBar(s,e,n,a=50){const t=Math.max(0,Math.min(1,e>0?num(s)/e:0)),o=Math.round(t*a);return[span(""," "),span(n.green,"█".repeat(o)),span(n.dim,"█".repeat(Math.max(0,a-o))),span(n.gray,` ${Math.round(100*t)}% used`)]}function kv(s,e,{indent:n=" ",keyStyle:a=null,valStyle:t=null}={}){const o=e.reduce(((s,e)=>Math.max(s,[...e[0]].length)),0);return e.map((([e,r])=>[span(null!=a?a:s.gray,n+e+" ".repeat(o-[...e].length)+" : "),span(null!=t?t:s.white,str(r))]))}function obj(s){return s&&"object"==typeof s?s:{}}function statsFrom(s){const e=obj(s);return e.stats&&"object"==typeof e.stats?e.stats:e.memory&&"object"==typeof e.memory&&(null!=e.memory.total||e.memory.tiers||null!=e.memory.sessions||e.memory.roles)?e.memory:null!=e.total||e.tiers||e.roles?e:null}const CATEGORY_LABELS={session:"Session & context",workspace:"Workspace",model:"Model & behavior",data:"Data",auth:"Auth",support:"Support",fun:"Fun",aegis:"Aegis plugin",custom:"Custom"};function categoryLabel(s){if(s&&s.categoryLabel)return String(s.categoryLabel);const e=str(s&&s.category);return CATEGORY_LABELS[e]?CATEGORY_LABELS[e]:e?e.charAt(0).toUpperCase()+e.slice(1):"Commands"}function buildHelp(s,e={}){const n=themeOf(e),a=Array.isArray(s)?s:Array.isArray(obj(s).commands)?s.commands:[],t=[];t.push([span(n.gold+BOLD,"Commands"),span(BOLD_OFF,"")]),t.push([span(n.gray,"─".repeat(30))]);let o=null;for(const s of a){if(!s||!s.name)continue;const e=str(s.category);e!==o&&(t.push([span("","")]),t.push([span(n.gray+BOLD,categoryLabel(s)),span(BOLD_OFF,"")]),o=e);const a=String(s.name),r=" ".repeat(Math.max(1,16-[...a].length)),p=str(null!=s.desc?s.desc:s.help),i=s.unavailable?n.gray:n.white,u=s.unavailable?n.dim:n.gray,l=s.unavailable?" (unavailable)":"";t.push([span(i,"/"+a),span(u,r+p+l)])}return a.length||(t.push([span("","")]),t.push([span(n.gray,"No commands registered.")])),t.push([span("","")]),t.push([span(n.gray,"Shortcuts: "),span(n.white,"?"),span(n.gray," · "),span(n.white,"/help"),span(n.gray," commands · "),span(n.white,"↑↓"),span(n.gray," history · "),span(n.white,"Ctrl-L"),span(n.gray," clear · "),span(n.white,"Ctrl-D"),span(n.gray," exit")]),t}function buildStatus(s,e={}){const n=themeOf(e),a=obj(s),t=[];t.push([span(n.gold+BOLD,"Status"),span(BOLD_OFF,"")]);const o=[],r=(s,e)=>{const n=str(e);""!==n&&o.push([s,n])};r("Session ID",a.sessionId),r("Working directory",a.cwd),r("Home",a.home),r("Model",a.model),r("Effort",a.effort||"high"),null!=a.thinking&&r("Thinking",a.thinking?"on":"off"),null!=a.stream&&r("Streaming",!1===a.stream?"off":"on"),null!=a.vim&&r("Vim keymap",a.vim?"on":"off"),r("Theme",a.theme?str(a.theme):e&&e.light?"Light mode":"Dark mode"),r("Backend",a.backend),r("Base",a.base),r("Plan",a.plan),r("Account",a.account),null!=a.online&&r("Online",a.online?"yes":"no"),null!=a.turns&&r("Turns",str(num(a.turns))),null!=a.calls&&r("Tool calls",str(num(a.calls))),null!=a.version&&r("Version","v"+str(a.version)),r("Node",process.version),r("Platform",`${process.platform} ${process.arch}`);const p=Array.isArray(e.caps)?e.caps:[],i=s=>{const e=p.find((e=>Array.isArray(e)&&String(e[0])===s));return e?str(e[1]):""};r("Terminal",i("terminal")),r("Mark",i("mark")),r("Star",i("star")),r("Color",i("color")),r("Control",i("control")),r("Frame",i("size"));for(const s of kv(n,o,{keyStyle:n.gray,valStyle:n.white}))t.push(s);t.push([span("","")]);const u=a.permissions&&a.permissions.mode?str(a.permissions.mode):"default";return t.push([span(n.gray,`Permissions: ${u} — tool use follows your AEGIS settings.`)]),t}function buildCost(s,e={}){const n=themeOf(e),a=obj(s),{cols:t}=getSize(),o=Math.max(30,t-2),r=a.tokens&&"object"==typeof a.tokens?a.tokens:{},{input:p,output:i,cacheRead:u,cacheWrite:l,prompt:h,total:c}=tokenBuckets(r),d=num(a.costEur),m=str(a.model)||"the pinned model",g=num(a.contextWindow)||2e5,y=g>0?Math.min(100,Math.round(c/g*100)):0,f=[];return f.push([span(n.gray,"─".repeat(o))]),f.push([span(""," "),span(n.white+BOLD,"Session"),span(BOLD_OFF,""),span(n.gray," Status Config Usage Stats")]),f.push([span(""," "),span(n.gray,"Session")]),f.push([span(""," "),span(n.white,"Total cost:"),span(n.gray," "+" ".repeat(Math.max(0,14-fmtEur(d).length))+fmtEur(d))]),null!=a.balance&&f.push([span(""," "),span(n.white,"Balance:"),span(n.gray," "+" ".repeat(Math.max(0,14-fmtEur(a.balance).length))+fmtEur(a.balance))]),null==a.turns&&null==a.calls||f.push([span(""," "),span(n.white,"Turns:"),span(n.gray,` ${num(a.turns)} turns · ${num(a.calls)} calls`)]),f.push([span(""," "),span(n.white," Usage by model:")]),f.push([span(""," "),span(n.gray,` ${m}: ${fmtTokens(h)} input, ${fmtTokens(i)} output (${fmtEur(d)})`)]),(u||l)&&f.push([span(""," "),span(n.dim,` ↳ miss ${fmtTokens(p)} · cache read ${fmtTokens(u)} · cache write ${fmtTokens(l)}`)]),f.push([span(""," ")]),f.push([span(""," "),span(n.white+BOLD,"Current session"),span(BOLD_OFF,"")]),f.push(contextBar(c,g,n)),f.push([span(""," ")]),f.push([span(""," "),span(n.gray,`Session context: ${y}% of ${fmtTokens(g)} used.`)]),f.push([span(""," "),span(n.dim,"Cost is metered from the AEGIS token bank; tokens are counted this session.")]),f}function buildContext(s,e={}){const n=themeOf(e),a=obj(s),{cols:t}=getSize(),o=Math.max(30,t-2),r=a.tokens&&"object"==typeof a.tokens?a.tokens:{},{input:p,output:i,cacheRead:u,cacheWrite:l,prompt:h,total:c}=tokenBuckets(r),d=num(a.contextWindow)||2e5,m=[];m.push([span(n.gold+BOLD,"Context usage"),span(BOLD_OFF,"")]),m.push([span(""," "),span(n.gray,"─".repeat(Math.max(1,o-2)))]);const g=(s,e)=>[span(""," "),span(n.white,s),span(""," ".repeat(Math.max(1,16-[...s].length))),span(n.gray,fmtTokens(e)),span(""," ".repeat(Math.max(1,10-fmtTokens(e).length))),...contextBar(e,d,n)];return m.push(g("Prompt tokens",h)),(u||l)&&m.push([span(""," "),span(n.dim,` ↳ miss ${fmtTokens(p)} · cache read ${fmtTokens(u)} · cache write ${fmtTokens(l)}`)]),m.push(g("Output tokens",i)),m.push([span(""," ")]),m.push([span(""," "),span(n.gray,"─".repeat(Math.max(1,o-2)))]),m.push([span(""," "),span(n.white+BOLD,"Total"),span(""," ".repeat(9)),span(n.gray,fmtTokens(c)),span(""," ".repeat(Math.max(1,10-fmtTokens(c).length))),...contextBar(c,d,n)]),m.push([span(""," ")]),m.push([span(""," "),span(n.gray,`Context window: ${fmtTokens(d)} tokens`)]),m}function renderSessionsOverlay(s,e,n,a={}){const t=themeOf(a),o=obj(s),r=Math.max(30,num(e)?num(e)-4:76),p=str(o.version),i=str(o.model)||"default model",u=cwdName(o.cwd),l=Array.isArray(o.sessions)?o.sessions.filter(Boolean):[],h=l.filter((s=>s.awaiting||s.needsInput)).length,c=l.filter((s=>s.working)).length,d=l.filter((s=>s.completed)).length,m=s=>[span(t.gray,"│"),span(""," "),...s,span(""," ".repeat(Math.max(0,r-1-lineWidth(s)))),span(t.gray,"│")],g=[];return g.push([span(t.coral,"╭─── Aegiscode v"+p+" "+"─".repeat(Math.max(0,r-24))+"╮")]),g.push(m([span(t.white,i),span(t.gray," · "),span(t.white,u)])),g.push(m([span(t.gray,`${h} awaiting input · ${c} working · ${d} completed`)])),g.push([span(t.gray,"├"+"─".repeat(r)+"┤")]),g.push(m([span(t.white+BOLD,"Needs input"),span(BOLD_OFF,"")])),g.push(m([span(t.gray,"Sessions that have a question or need your decision land here")])),g.push(m([span(t.coral,GLYPH.bloom),span(t.gray," current session send a prompt to start "),span(t.gray,"—")])),g.push(m([span(t.white+BOLD,"Working"),span(BOLD_OFF,"")])),g.push(m([span(t.gray,"Sessions AEGIS is actively working on — they keep running even if you close the terminal")])),g.push(m([span(t.white+BOLD,"Completed"),span(BOLD_OFF,"")])),g.push(m([span(t.gray,"Finished sessions wait here for you to review")])),g.push([span(t.gray,"╰"+"─".repeat(r)+"╯")]),g.push([span(""," "),span(t.gray,"Sub-agents that keep working in the background need a local agent loop;")]),g.push([span(""," "),span(t.gray,"this build hands a bigger task to the pooled brain instead.")]),g}function buildAgents(s,e={}){const{cols:n,rows:a}=getSize();return renderSessionsOverlay(s,n,a,e)}function buildPermissions(s,e,n={}){const a=themeOf(n),t=obj(s),o=s=>Array.isArray(s)?s:[],r=null!=e&&""!==e?String(e):null!=t.defaultMode?String(t.defaultMode):"default",p=[];p.push([span(a.gold+BOLD,"Permissions"),span(BOLD_OFF,"")]),p.push([span(""," "),span(a.gray,"Default mode: "),span(a.white,r)]),p.push([span(""," ")]);const i=(s,e)=>{const n=[[span(""," "),span(a.white+BOLD,s),span(BOLD_OFF,"")]];e.length||n.push([span(""," "),span(a.gray,"(none)")]);for(const s of e)n.push([span(""," "),span(a.gray,str(s))]);return n};for(const s of i("Allow",o(t.allow)))p.push(s);for(const s of i("Deny",o(t.deny)))p.push(s);for(const s of i("Ask",o(t.ask)))p.push(s);return p.push([span("","")]),p.push([span(a.gray,"Usage:")]),p.push([span(a.gray,' /permissions allow "Bash(npm run *)"')]),p.push([span(a.gray,' /permissions deny "Edit(src/**)"')]),p.push([span(a.gray,' /permissions ask "Read(**/*.env)"')]),p.push([span(a.gray," /permissions default ask · /permissions clear")]),p.push([span("","")]),p.push([span(a.dim,`Stored in ${str(t._path)||"~/.aegiscode/permissions.json"}`)]),p}function buildModelList(s,e,n={}){const a=themeOf(n),t=Array.isArray(e)?e:[],o=str(s),r=s=>s.cls?"byok"===s.cls:"byok"===n.modelClass,p=t.some(r),i=[];i.push([span(a.gold+BOLD,"Models"),span(BOLD_OFF,"")]),i.push([span(a.gray,"─".repeat(30))]);for(const s of t){if(!s)continue;const e=str(s.id)||str(s.model),n=(""!==e&&e===o?"▶ ":" ")+e,t=str(s.name||s.label||s.model),p=r(s)?str(s.note)||str(s.model):str(s.model)||"(default)";i.push([span(a.white,n),span(""," ".repeat(Math.max(1,26-[...n].length))),span(a.gray,t),span(""," ".repeat(Math.max(1,22-[...t].length))),span(a.gray,p)])}return t.length||i.push([span(""," "),span(a.gray,"(no models configured)")]),i.push([span("","")]),i.push([span(a.gray,p?"Switch: /model <id> · Add a provider key: /byok-key <provider> · Run on it: /class byok":"Switch: /model <id> · Add: /model add <id> <name> <model> <baseURL> [apiKey] · Remove: /model remove <id>")]),i}function buildRewindList(s,e={}){const n=themeOf(e),a=Array.isArray(s)?s:[],t=[];t.push([span(n.gold+BOLD,"Rewind"),span(BOLD_OFF,"")]),t.push([span(""," "),span(n.gray,"Snapshots are taken after every exchange.")]),t.push([span(""," ")]);for(const s of a){if(!s)continue;const e=str(num(s.idx));t.push([span(""," "),span(n.green,e),span(""," ".repeat(Math.max(1,4-[...e].length))),span(n.white,`${num(s.depth)} messages`),span(n.gray,` · ${num(s.words)} words · ${ago(s.ts)}`)])}return a.length||t.push([span(""," "),span(n.gray,"(no checkpoints)")]),t.push([span("","")]),t.push([span(n.gray,"Usage: /rewind N to restore that checkpoint (0 = session start)")]),t}function buildHooksStatus(s,e={}){const n=themeOf(e),a=obj(s),t=Array.isArray(a.events)?a.events:[],o=a.byEvent&&"object"==typeof a.byEvent?a.byEvent:{},r=Array.isArray(a.fromPaths)?a.fromPaths:Array.isArray(a.sources)?a.sources:[],p=[];p.push([span(n.gold+BOLD,"Hooks status"),span(BOLD_OFF,"")]);const i=[["status",a.enabled?"enabled":"disabled"],["hooks",str(num(a.hooks))],["events",str(t.length)]];for(const s of kv(n,i,{keyStyle:n.gray,valStyle:n.white}))p.push(s);if(num(a.hooks)>0){p.push([span("","")]),p.push([span(""," "),span(n.white+BOLD,"by event"),span(BOLD_OFF,"")]);for(const[s,e]of Object.entries(o))p.push([span(""," "),span(n.green,GLYPH.bullet),span(n.white,` ${s}`),span(n.gray,` ${num(e)}`)])}return p.push([span("","")]),p.push([span(n.gray,"/hooks list for full config")]),p.push([span("","")]),p.push([span(n.dim,r.length?`Settings: ${r.join(", ")}`:"Settings: no settings.json with hooks found (checked ~/.aegis, .aegis, ~/.aegiscode, .aegiscode, ~/.claude)")]),p.push([span(n.gray,"Config hooks are read, not managed — edit the files above.")]),p.push([span(n.gray,"The repo guard hooks (.githooks/) are installed by /hooks install.")]),p}function buildHooksList(s,e={}){const n=themeOf(e),a=obj(s),t=a.hooks&&"object"==typeof a.hooks?a.hooks:{},o=[];o.push([span(n.gold+BOLD,"Hooks config"),span(BOLD_OFF,"")]);let r=!1;for(const[s,e]of Object.entries(t))if(Array.isArray(e)&&0!==e.length){r=!0,o.push([span("","")]),o.push([span(""," "),span(n.white+BOLD,s),span(BOLD_OFF,"")]);for(const s of e)s&&(o.push([span(""," "),span(n.lavender,str(s.name)||"(unnamed)")]),s.matcher&&(s.matcher.tools&&o.push([span(""," - tools: "),span(n.gray,str(s.matcher.tools))]),s.matcher.paths&&o.push([span(""," - paths: "),span(n.gray,str(s.matcher.paths))]),s.matcher.commands&&o.push([span(""," - commands: "),span(n.gray,str(s.matcher.commands))])),o.push([span("",` - hooks: ${Array.isArray(s.hooks)?s.hooks.length:0}`)]),o.push([span("","")]))}return r?(o.push([span("","")]),o.push([span(n.gray,"/hooks status for the summary")])):(o.push([span(""," "),span(n.gray,"no hooks configured.")]),o.push([span("","")]),o.push([span(""," "),span(n.gray,"add hooks to settings.json:")]),o.push([span(""," "),span(n.gray,"- ~/.aegis/settings.json (user)")]),o.push([span(""," "),span(n.gray,"- .aegis/settings.json (project)")])),o}function buildTroubleshooting(s,e={}){const n=themeOf(e),a=[];a.push([span(n.gold+BOLD,"Troubleshooting"),span(BOLD_OFF,"")]);const t=[["No output / blank screen","Run with TERM=xterm-256color, or switch to a lighter theme (/theme light)."],["Keys not responding","This client needs a real TTY — run it from a terminal, not a CI job."],["401 / unauthorized","Check the account line with /status, or set a provider key with /byok-set."],["No answers from the brain","Confirm the token-bank balance with /billing."],["Memory looks empty","Recall is per-topic — try /aegis-recall <topic> or save one with /aegis-remember <note>."]];for(const[s,e]of t)a.push([span(n.green,GLYPH.bullet),span(n.white," "+s)]),a.push([span(""," "),span(n.gray,e)]);return a.push([span("","")]),a.push([span(n.gray,"Run /status for account state. Help: https://aegiscloud.org")]),a}function buildOnboarding(s,e={}){const n=themeOf(e),a=[];a.push([span(n.gold+BOLD,"Getting started"),span(BOLD_OFF,"")]);const t=[["/help","list every command"],["/","open the command palette"],["?","shortcuts"],["/model <id>","pin a model"],["/theme light|dark","switch the colour theme"],["/aegis-ask","ask the pooled brain a question"],["/memory","show your AEGIS cloud memory"],["Ctrl-D","exit"]];for(const[s,e]of t)a.push([span(""," "),span(n.lavender,s),span(""," ".repeat(Math.max(1,20-[...s].length))),span(n.gray,e)]);return a.push([span("","")]),a.push([span(n.gray,'Try "summarize this file for me" to see the full flow.')]),a}function buildShellCompletion(s,e={}){const n=themeOf(e),a=[];a.push([span(n.gold+BOLD,"Shell completion"),span(BOLD_OFF,"")]),a.push([span(""," "),span(n.gray,"Aegiscode completes /commands with Tab inside the app.")]),a.push([span(""," "),span(n.gray,"For shell-level completion of the aegiscode CLI itself:")]),a.push([span(""," ")]);const t=[["bash",'eval "$(aegiscode shell-completion bash)"'],["zsh",'eval "$(aegiscode shell-completion zsh)"'],["fish","aegiscode shell-completion fish | source"]];for(const[s,e]of t)a.push([span(""," "),span(n.white+BOLD,s),span(""," ".repeat(Math.max(1,6-s.length))),span(n.gray,e)]);return a.push([span("","")]),a.push([span(n.dim,"Add the eval line to your ~/.bashrc or ~/.zshrc to make it persist.")]),a}function buildTerminalSetup(s,e={}){const n=themeOf(e),a=obj(s),t="undefined"!=typeof process&&process.env?process.env:{},{cols:o,rows:r}=getSize(),p=str(a.shell)||pathName(str(t.SHELL)),i=[["TERM",str(a.term)||str(t.TERM)||"(unset)"],["LANG",str(a.lang)||str(t.LANG)||"(unset)"],["Shell",p||"unknown"],["Size",`${o}x${r}`]],u=[];u.push([span(n.gold+BOLD,"Terminal setup"),span(BOLD_OFF,"")]);for(const s of kv(n,i,{keyStyle:n.white,valStyle:n.gray}))u.push(s);return u.push([span("","")]),u.push([span(n.gray,"Tips:")]),u.push([span(n.gray," • TERM=xterm-256color enables full color + resize handling")]),u.push([span(n.gray," • Set LANG (e.g. en_US.UTF-8) for correct glyphs and word wrap")]),u.push([span(n.gray," • Resize mid-session is handled (SIGWINCH); overlays adapt")]),u}function buildTerminalCaps(s,e={}){const n=themeOf(e),a=(Array.isArray(s)?s:[]).filter((s=>Array.isArray(s)&&s.length>=2)).map((([s,e])=>[str(s),str(e)])),t=[];if(t.push([span(n.gold+BOLD,"Terminal capabilities"),span(BOLD_OFF,"")]),!a.length)return t.push([span(""," "),span(n.gray,"No capability report available.")]),t;for(const s of kv(n,a,{keyStyle:n.white,valStyle:n.gray}))t.push(s);return t.push([span("","")]),e&&e.pinned&&(t.push([span(n.coral,GLYPH.warn),span(n.gold," width is pinned — resizes are ignored until /terminal auto")]),t.push([span("","")])),t.push([span(n.gray,"Override: /terminal ascii | unicode | color | no-color | background <dark|light> | star <native|narrow>")]),t.push([span(n.gray," /terminal width <cols> | auto | status")]),t.push([span(n.gray,"At launch: --ascii --unicode --no-color --width <cols> --terminal")]),t}function buildPRs(s,e={}){const n=themeOf(e),a=[];a.push([span(n.gold+BOLD,"Open pull requests"),span(BOLD_OFF,"")]);const t=str(s).trim();if(!t)return a.push([span(""," "),span(n.gray,"No open PRs in this repository.")]),a;for(const s of t.split("\n").slice(0,10))a.push([span(""," "),span(n.white,s)]);return a.push([span("","")]),a.push([span(n.gray,"Review with /review · comments via /pr-comments")]),a}function buildBenchmark(s,e={}){const n=themeOf(e),a=Array.isArray(s)?s:[],t=[];t.push([span(n.gold+BOLD,"Benchmark"),span(BOLD_OFF,"")]),t.push([span(""," "),span(n.gray,"In-app micro-benchmarks (this process, this machine):")]),t.push([span(""," ")]);for(const s of a){if(!Array.isArray(s)||s.length<2)continue;const e=str(s[0]);t.push([span(""," "),span(n.white,e),span(""," ".repeat(Math.max(1,30-[...e].length))),span(n.gray,`${num(s[1])} ms`)])}return a.length||t.push([span(""," "),span(n.gray,"(no benchmarks run)")]),t.push([span("","")]),t.push([span(n.dim,"Spoiler: the terminal renders faster than you type.")]),t}const WAIFU_ART=[" ▄▄▄▄▄▄▄▄▄▄▄▄"," ▄█▓▓▓▓▓▓▓▓▓▓▓▓█▄"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓█▓▓▓▓▓▓▓█▓▓▓█"," █▓▓█▓▓█▓▓▓█▓▓█▓▓█"," █▓▓█▓█▓▓▓█▓█▓▓█"," █▓▓▓█▓▓▓█▓▓▓█"," ██▓▓▓▓▓▓▓▓▓▓▓▓▓██"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," █▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█"," ▀█▓▓▓▓▓▓▓▓▓▓▓▓▓█▀"," ▀▀▀███████▀▀▀"];function buildWaifu(s={}){const e=themeOf(s),n=[];n.push([span(e.gold+BOLD,"Waifu"),span(BOLD_OFF,"")]);for(const s of WAIFU_ART)n.push([span(e.lavender,s)]);return n.push([span("","")]),n.push([span(e.gray,"A distinguished gentleman, rendered in block characters.")]),n}function buildAegisStatus(s,e={}){const n=themeOf(e),a=obj(s),t=statsFrom(a),o=a.cloud&&"object"==typeof a.cloud?a.cloud:null,r=str(a.cloudNote),p=str(a.version),i=str(a.backend||a.store),u=[];u.push([span(n.gold+BOLD,"ÆGIS Status"),span(BOLD_OFF,"")]),u.push([span(n.gray,"─".repeat(30))]);const l=t?num(t.total):0,h=t?num(t.sessions):0;if(u.push([span(n.white,`Memory: ${l.toLocaleString()} entries across ${h} sessions`)]),t&&t.roles&&(null!=t.roles.user||null!=t.roles.assistant)){const s=t.roles,e=[];null!=s.user&&e.push(`${num(s.user)} user`),null!=s.assistant&&e.push(`${num(s.assistant)} assistant`),s.other&&e.push(`${num(s.other)} other`),e.length&&u.push([span(n.gray,` roles: ${e.join(" · ")}`)])}if(t&&t.tiers&&u.push([span(n.gray,` tiers: ${JSON.stringify(t.tiers)}`)]),i&&u.push([span(n.gray,` store: ${i}`)]),t&&null!=t.total){const s=num(t.withEmbeddings),e=l?Math.round(s/l*100):0;if(!0===t.embeddingsEnabled){const s=t.embeddingModels&&Object.keys(t.embeddingModels)[0]||"embedding";u.push([span(n.gray,` embed: ${s} · ${e}% coverage`)])}else!1===t.embeddingsEnabled&&l&&u.push([span(n.gray," embed: keyword-only")]);t.stale&&u.push([span(n.gray,` stale: ${num(t.stale)} entries >90d`)])}if(o){const s=o.key?"✓ connected":"✗ no API key",e=o.sync?"sync on":"sync off";u.push([span(n.white,`Cloud: ${s}, ${e}`)])}else r?u.push([span(n.gray,`Cloud: ${r}`)]):u.push([span(n.gray,"Cloud: not checked (aegis /cloud status unavailable)")]);return p&&u.push([span(n.gray,`CLI: aegis ${p}`)]),u}function buildAegisRecall(s,e={}){const n=themeOf(e),a=Array.isArray(s)?s.filter(Boolean):[],t=[];if(t.push([span(n.gold+BOLD,"ÆGIS Memory"),span(BOLD_OFF,"")]),t.push([span(n.gray,"─".repeat(30))]),!a.length)return t.push([span(n.gray,"No memory found for this topic.")]),t.push([span(n.gray,"Nothing relevant is stored yet — /aegis-remember <note> saves one.")]),t;for(const s of a.slice(0,10)){const e=str(s.content).split("\n")[0].slice(0,90);t.push([span(n.white+BOLD,`• ${e}`),span(BOLD_OFF,"")]);const a=s.timestamp?str(s.timestamp).slice(0,10):"",o=s.source?` (${str(s.source)})`:"",r=Array.isArray(s.tags)&&s.tags.length?" · tags: "+s.tags.join(", "):"";t.push([span(n.gray,` ${a}${o}${r}`)])}return a.length>10&&t.push([span(n.gray,`…and ${a.length-10} more`)]),t}function buildAegisMulti(s,e={}){const n=themeOf(e),a=str(s),t=[];return t.push([span(n.gold+BOLD,"ÆGIS Multi — compose"),span(BOLD_OFF,"")]),t.push([span(n.gray,"─".repeat(30))]),t.push([span(n.gray,"Paste into your aegis-cli session (the confirmation prompt works there):")]),t.push([span(n.white,` /multi ${a}`)]),t.push([span(n.gray," /multiyolo "+a+" — auto-approved variant")]),t.push([span("","")]),t.push([span(n.gray,"Optional flags: --save-as <name> · --template <id>")]),t.push([span(n.gray,'Add "run" to execute headless here instead: /aegis-multi <task> run')]),t}function buildAegisPrint(s,e={},n={}){const a=themeOf(n),t=obj(e),o=[];o.push([span(a.gold+BOLD,str(s)),span(BOLD_OFF,"")]),o.push([span(a.gray,"─".repeat(30))]);for(const s of str(t.result).split("\n"))o.push([span(a.white,s)]);return(t.model||t.provider)&&o.push([span(a.gray,` via ${str(t.provider)||"aegis"}${t.model?" · "+str(t.model):""}`)]),o}function buildBilling(s,e={}){const n=themeOf(e),a=obj(s),t=[];t.push([span(n.gold+BOLD,"Billing"),span(BOLD_OFF,"")]),t.push([span(n.gray,"─".repeat(30))]);const o=[];if(null!=a.balance&&o.push(["Balance",fmtEur(a.balance)]),null!=a.plan&&o.push(["Plan",str(a.plan)]),null!=a.account&&o.push(["Account",str(a.account)]),null!=a.costEur&&o.push(["This session",fmtEur(a.costEur)]),o.length)for(const s of kv(n,o,{indent:" ",keyStyle:n.gray,valStyle:n.white}))t.push(s);else t.push([span(""," "),span(n.gray,"No billing data available.")]);t.push([span("","")]),t.push([span(n.white,"AEGIS pooled inference"),span(n.gray," metered against your token bank")]);const r=a.payment&&"object"==typeof a.payment?a.payment:null;if(r){const{cols:s}=getSize(),e=r.paid?"✔":"✦";t.push(...wrapRows(`${e} ${str(r.label)||"Unlimited"}: ${str(r.reason)}`,2,r.paid?n.green:n.gold,s)),t.push(...wrapRows(str(r.honesty),2,n.gray,s)),!r.paid&&r.unlock&&t.push(...wrapRows(str(r.unlock),2,n.gray,s)),r.byok&&t.push(...wrapRows(str(r.byok),2,n.gray,s)),!1===r.verified&&t.push(...wrapRows("(account not confirmed this session — verdict may be stale)",2,n.gray,s)),r.url&&t.push([span(""," "),span(n.gray,str(r.url))])}else t.push([span(n.gray,` Top-ups and invoices: ${goUrl("topup","cost_screen")}`)]);return t}function buildTokens(s,e={}){const n=themeOf(e),a=obj(s),{cols:t}=getSize(),o=Math.max(24,t-2),r=a.tokens&&"object"==typeof a.tokens?a.tokens:{},{input:p,output:i,cacheRead:u,cacheWrite:l,total:h}=tokenBuckets(r),c=num(a.costEur),d=num(a.contextWindow)||2e5,m=d>0?Math.min(100,Math.round(h/d*100)):0,g=[];g.push([span(n.gold+BOLD,"Token usage"),span(BOLD_OFF,"")]),g.push([span(n.gray,"─".repeat(Math.min(30,o)))]);const y=Math.max(p,i,u,l,1),f=(s,e)=>{const a=Math.min(1,e/y),t=Math.max(0,Math.round(24*a));return[span(""," "),span(n.white,s),span(""," ".repeat(Math.max(1,11-[...s].length))),span(n.green,"█".repeat(t)),span(n.dim,"█".repeat(Math.max(0,24-t))),span(n.gray,` ${fmtTokens(e)}`)]};return g.push(f("input",p)),g.push(f("output",i)),g.push(f("cache read",u)),g.push(f("cache write",l)),g.push([span(""," ")]),g.push([span(""," "),span(n.white,"Total:"),span(n.gray,` ${fmtTokens(h)}`),span(""," ".repeat(8)),span(n.white,"Est. cost:"),span(n.gray,` ${fmtEur(c)}`)]),g.push([span(""," "),span(n.gray,`Context: ${m}% of ${fmtTokens(d)} window`)]),g.push([span(""," "),span(n.gray,"Tokens are counted from this session; cost is metered in euro.")]),g}function buildSkills(s,e,n={}){const a=themeOf(n),t=Array.isArray(s)?s.filter(Boolean):[],o=Array.isArray(e)?e:[],r=[];if(r.push([span(a.gold+BOLD,"Skills"),span(BOLD_OFF,"")]),r.push([span(a.gray,"─".repeat(30))]),!t.length){r.push([span(a.gray,"No skills found.")]),r.push([span(a.gray,"Skill dirs scanned:")]);for(const s of o)r.push([span(a.dim,` ${str(s)}`)]);return r.push([span("","")]),r.push([span(a.gray,"Add one: mkdir -p .aegis/skills/<name> and drop a SKILL.md inside.")]),r}let p=null;for(const s of t){s.source!==p&&(r.push([span(a.gray+BOLD,"user"===s.source?"User":"Project"),span(BOLD_OFF,"")]),p=s.source);const e=s.namespace?`${str(s.namespace)}/${str(s.name)}`:str(s.name),n=str(s.description)||"(no description)";r.push([span(a.white,` ${e}`),span(a.gray," ".repeat(Math.max(1,18-[...e].length))+n)])}return r.push([span("","")]),r.push([span(a.gray,"/skills <name> for details · /skills refresh to rescan")]),r}function buildSkillDetail(s,e={}){const n=themeOf(e),a=obj(s),t=a.namespace?`${str(a.namespace)}/${str(a.name)}`:str(a.name),o=[];o.push([span(n.gold+BOLD,`Skill: ${t}`),span(BOLD_OFF,"")]),o.push([span(n.gray,"─".repeat(30))]),a.description&&o.push([span(n.gray,str(a.description))]),o.push([span(n.dim,str(a.path))]),o.push([span("","")]);const r=str(a.content).split("\n"),p=r.slice(0,8).join("\n");for(const s of p.split("\n"))o.push([span(n.white,s)]);return r.length>8&&o.push([span(n.gray,`… (${r.length} lines)`)]),o}function buildMcp(s,e,n={}){const a=themeOf(n),t=Array.isArray(s)?s.map(((s,e)=>[str(s&&s.name)||String(e),s])):s&&"object"==typeof s?Object.entries(s):[],o=Array.isArray(e)?e:[],r=[];if(r.push([span(a.gold+BOLD,"MCP servers"),span(BOLD_OFF,"")]),r.push([span(a.gray,"─".repeat(30))]),t.length)for(const[s,e]of t){const n="string"==typeof e?e:(str(e&&e.command)+" "+(Array.isArray(e&&e.args)?e.args.join(" "):"")).trim();r.push([span(a.white,` ${str(s)}`),span(a.gray," ".repeat(Math.max(1,14-[...str(s)].length))+n)])}else r.push([span(a.gray,"No MCP servers configured.")]);return r.push([span("","")]),r.push([span(a.gray,"This build has no MCP runtime — servers are configuration only.")]),r.push([span(a.gray,"/mcp add <name> <command> [args…] · /mcp remove <name>")]),o.length&&r.push([span(a.dim,"Sources: "+o.join(", "))]),r}function buildRouter(s,e={}){const n=themeOf(e),a=obj(s),t=a.autoRouter&&"object"==typeof a.autoRouter?a.autoRouter:a.router&&"object"==typeof a.router?a.router:{enabled:!1,tiers:{}},o=t.tiers&&"object"==typeof t.tiers?t.tiers:{},r=[];return r.push([span(n.gold+BOLD,"Model router"),span(BOLD_OFF,"")]),r.push([span(n.gray,"─".repeat(30))]),r.push([span(n.white,"auto-router: "+(t.enabled?"on":"off"))]),r.push([span(n.gray,` simple ${str(o.simple)||"(auto)"}`)]),r.push([span(n.gray,` medium ${str(o.medium)||"(auto)"}`)]),r.push([span(n.gray,` complex ${str(o.complex)||"(auto)"}`)]),r.push([span("","")]),r.push([span(n.gray,"/router on|off · /router set <simple|medium|complex> <modelId>")]),r.push([span(n.dim,"Routing config is persisted for the real CLI; this build serves the model chosen by /model.")]),r}function buildMemory(s,e={}){const n=themeOf(e),a=obj(s),t=statsFrom(a),o=a.embedStatus&&"object"==typeof a.embedStatus?a.embedStatus:null,r=a.compactState&&"object"==typeof a.compactState?a.compactState:a.at?a:null,p=a.compactCfg&&"object"==typeof a.compactCfg?a.compactCfg:null,i=[];i.push([span(n.gold+BOLD,"ÆGIS Memory"),span(BOLD_OFF,"")]),i.push([span(n.gray,"─".repeat(30))]);const u=t?num(t.total):0,l=t?num(t.sessions):0;if(i.push([span(n.white,`${u.toLocaleString()} memories across ${l} sessions`)]),t&&t.roles&&"object"==typeof t.roles){const s=[];null!=t.roles.user&&s.push(`${num(t.roles.user)} user`),null!=t.roles.assistant&&s.push(`${num(t.roles.assistant)} assistant`),t.roles.other&&s.push(`${num(t.roles.other)} other`),s.length&&i.push([span(n.gray,` roles: ${s.join(" · ")}`)])}if(t&&t.tiers&&i.push([span(n.gray,` tiers: ${JSON.stringify(t.tiers)}`)]),t&&null!=t.total){const s=u?Math.round(num(t.withEmbeddings)/u*100):0;o&&o.engine?i.push([span(n.gray,` embed: ${str(o.engine)} · ${s}% coverage`)]):o&&i.push([span(n.gray," embed: keyword-only")]),t.stale&&i.push([span(n.gray,` stale: ${num(t.stale)} entries >90d`)])}return r&&i.push([span(n.gray,r.at?` last compact: ${str(r.at).slice(0,10)}`:" auto-compact: never run")]),p&&i.push([span(n.gray,` auto-compact: ${p.enabled?"on":"off"} (min ${num(p.minL1)} L1 · ${num(p.cooldownMin)}m cooldown)`)]),i.push([span("","")]),i.push([span(n.gray,"/memory tiers · /memory embeddings · /memory recall <q>")]),i.push([span(n.gray,"/memory compact · /memory profile · /aegis-remember <note> to save")]),i}function buildMemoryTiers(s,e={}){const n=themeOf(e),a=obj(s),t=statsFrom(a),o=Array.isArray(a.pending)?a.pending:[],r=a.compactState&&"object"==typeof a.compactState?a.compactState:null,p=a.compactCfg&&"object"==typeof a.compactCfg?a.compactCfg:null,i=[];if(i.push([span(n.gold+BOLD,"Memory Tiers"),span(BOLD_OFF,"")]),i.push([span(n.gray,"─".repeat(30))]),t&&t.tiers&&(i.push([span(n.white,`L0 turns ${num(t.tiers.L0)} raw session turns, volatile`)]),i.push([span(n.white,`L1 atomic ${num(t.tiers.L1)} facts · decisions · breakthroughs`)]),i.push([span(n.white,`L2 scenario ${num(t.tiers.L2)} distilled reusable context`)]),i.push([span(n.white,`L3 profile ${num(t.tiers.L3)} single distilled identity row`)])),i.push([span("","")]),i.push([span(n.gray,`pending L1 (auto-compact trigger): ${o.length}`)]),r&&r.at){const s=Array.isArray(r.scenarios)?r.scenarios.length:0;i.push([span(n.gray,`last auto-compact: ${str(r.at).slice(0,16)} · ${s} scenario${1===s?"":"s"}`)])}else i.push([span(n.gray,"last auto-compact: never")]);return i.push([span(n.gray,p?`auto-compact: ${p.enabled?"on":"off"} · min ${num(p.minL1)} L1 · ${num(p.cooldownMin)}m cooldown`:"auto-compact: on · min 5 L1 · 15m cooldown")]),i.push([span("","")]),i.push([span(n.gray,"/memory compact runs maintenance manually")]),i}function buildMemoryEmbeddings(s,e,n={}){const a=themeOf(n),t=s&&"object"==typeof s?s:null,o=e&&"object"==typeof e?e:null,r=[];if(r.push([span(a.gold+BOLD,"Memory Embeddings"),span(BOLD_OFF,"")]),r.push([span(a.gray,"─".repeat(30))]),t&&t.engine?(r.push([span(a.white,`engine: ${str(t.engine)} · ${str(t.model)}`)]),t.dim&&r.push([span(a.gray,` dim: ${num(t.dim)}`)])):(r.push([span(a.white,"engine: keyword-only (no embedder resolved)")]),t&&t.reason&&r.push([span(a.gray,` reason: ${str(t.reason)}`)])),r.push([span(a.gray,`mode: ${t&&str(t.mode)||"auto"} (env AEGIS_MEMORY_EMBED or memoryConfig.embedMode)`)]),o&&null!=o.total){const s=num(o.total),e=num(o.withEmbeddings),n=s?Math.round(e/s*100):0;if(r.push([span(a.gray,`coverage: ${e}/${s} rows (${n}%)`)]),o.embeddingModels&&Object.keys(o.embeddingModels).length){const s=Object.entries(o.embeddingModels).map((([s,e])=>`${s}: ${num(e)}`));r.push([span(a.gray,` models: ${s.join(" · ")}`)])}o.stale&&r.push([span(a.gray,` stale (>90d): ${num(o.stale)}`)])}return r.push([span("","")]),r.push([span(a.gray,"/memory embeddings on|off toggles the engine chain")]),r}function buildAutomode(s,e={}){const n=themeOf(e),a=[];return a.push([span(n.gold+BOLD,"⚠ automode enabled"),span(BOLD_OFF,"")]),a.push([span(n.gray,"─".repeat(30))]),a.push([span(n.white,"All tool executions are auto-approved: file writes,")]),a.push([span(n.white,"bash commands, and network requests run without asking.")]),a.push([span("","")]),a.push([span(n.gray,"Run /automode off to restore confirmations.")]),a.push([span(n.gray,"(/yolo is accepted as an alias.)")]),a}const buildYolo=buildAutomode;function buildReleaseNotes(s,e={}){const n=themeOf(e),a=[];a.push([span(n.gold+BOLD,`What's new in v${VERSION}`),span(BOLD_OFF,"")]),a.push([span(n.gray,"─".repeat(30))]);const t=["v6.7.3 — the shared renderer is re-staged into cli/vendor.","v6.7.1 — terminal capabilities are read from the terminal, not the platform.","v6.7.0 — a file edit renders as a coloured diff block.","v6.6.0 — autonomous mode: a persistent work queue with a detached worker.","v6.5.x — the live tool row, /cost billed from the ledger the server settled at.","v6.4.0 — `aegiscode login`/`logout`/`key`, a 0600 credential store, /cloud and /sync."];for(const s of t){const e=s.indexOf(" — "),t=-1===e?s:s.slice(0,e),o=-1===e?"":s.slice(e+3);a.push([span(n.green,"•"),span(n.gold,` ${t}`),span(n.white,o?` — ${o}`:"")])}let o=null;try{const s=require("./commands.js");o={n:s.visibleCommands().length,cats:s.CATEGORIES.length}}catch{}return o&&(a.push([span("","")]),a.push([span(n.gray,` ${o.n} commands across ${o.cats} categories — /help lists them.`)])),a.push([span(n.gray," The version above is read from the package; the prose is not.")]),a.push([span(n.gray," Repo: https://aegiscloud.org")]),a}function stubPanel(s,e,n){const a=themeOf(s);return[[span(a.gold+BOLD,e),span(BOLD_OFF,"")],[span(a.gray,` ${e} is not available in aegiscode — ${n}`)]]}function buildDoctor(s,e={}){return stubPanel(e,"Doctor","it needs the local environment diagnostic suite.")}function buildBuildPanel(s,e={}){const n=obj(s),a=themeOf(e);return[[span(a.gold+BOLD,`⬡ Build: ${str(n.plan&&n.plan.appName)||"build"}`),span(BOLD_OFF,"")],[span(a.gray," Build is not available in aegiscode — it needs a local multi-model agent build loop.")]]}module.exports={buildHelp:buildHelp,buildStatus:buildStatus,buildCost:buildCost,buildContext:buildContext,buildTokens:buildTokens,buildAgents:buildAgents,buildPermissions:buildPermissions,buildModelList:buildModelList,buildRewindList:buildRewindList,buildOnboarding:buildOnboarding,buildShellCompletion:buildShellCompletion,buildTerminalSetup:buildTerminalSetup,buildTerminalCaps:buildTerminalCaps,buildPRs:buildPRs,buildBenchmark:buildBenchmark,buildWaifu:buildWaifu,buildAegisStatus:buildAegisStatus,buildAegisRecall:buildAegisRecall,buildAegisMulti:buildAegisMulti,buildBilling:buildBilling,buildMemory:buildMemory,buildMemoryTiers:buildMemoryTiers,buildRouter:buildRouter,buildAutomode:buildAutomode,buildYolo:buildYolo,buildSkills:buildSkills,buildMcp:buildMcp,buildHooksStatus:buildHooksStatus,buildHooksList:buildHooksList,buildTroubleshooting:buildTroubleshooting,buildReleaseNotes:buildReleaseNotes,renderSessionsOverlay:renderSessionsOverlay,buildAegisPrint:buildAegisPrint,buildSkillDetail:buildSkillDetail,buildMemoryEmbeddings:buildMemoryEmbeddings,buildDoctor:buildDoctor,buildBuildPanel:buildBuildPanel,fmtEur:fmtEur,fmtTokens:fmtTokens};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const limits=(()=>{try{return require("./limits.js")}catch{return{armed:()=>!0,refuse:()=>1,check:()=>({tripped:!0,code:"p2",units:0})}}})(),RULE_RE=/^(\w+)(?:\((.*)\))?$/,TOOL_ALIAS={exec:"shell",Bash:"shell",readFile:"read",Read:"read",writeFile:"write",Write:"write",editFile:"edit",Edit:"edit",listDir:"list",LS:"list",glob:"glob",Glob:"glob",grep:"grep",Grep:"grep",task:"task",Task:"task"};function canonTool(e){const t=String(null==e?"":e);return TOOL_ALIAS[t]||t}function isShellTool(e){return"shell"===canonTool(e)}function globToRegex(e){let t="^";for(const n of e)"*"===n?t+=".*":"?"===n?t+=".":/[.+^${}()|[\]\\]/.test(n)?t+=`\\${n}`:t+=n;return new RegExp(t+"$")}function subjectFor(e,t={}){switch(canonTool(e)){case"shell":return String(t.command||"");case"read":case"write":case"edit":return String(t.file_path||"");case"glob":case"grep":return String(t.pattern||"");case"list":return String(t.path||"");default:return""}}function matchRule(e,t,n){const r=RULE_RE.exec(String(e||"").trim());if(!r)return!1;const[,i,s]=r;if(canonTool(i)!==canonTool(t))return!1;if(void 0===s)return!0;try{return globToRegex(s).test(n)}catch{return!1}}const matchesAny=(e,t,n)=>Array.isArray(e)&&e.some((e=>matchRule(e,t,n)));function isMultiDirCommand(e){return String(e||"").split(/&&|\|\||;|\n/).map((e=>e.trim())).filter((e=>/^cd(\s|$)/.test(e))).length>1}function evalPermission(e,t,n={}){const r=subjectFor(e,t);return matchesAny(n.deny,e,r)?"deny":matchesAny(n.allow,e,r)?"allow":isShellTool(e)&&isMultiDirCommand(t&&t.command)||matchesAny(n.ask,e,r)||n.explicitAsk&&"ask"===n.defaultMode?"ask":"allow"}const SKIP=Object.freeze({flag:"--dangerously-skip-permissions",env:"AEGIS_SKIP_PERMISSIONS",productEnv:"AEGISONE_SKIP_PERMISSIONS",truthy:Object.freeze(["1","true","yes","on"])}),isTruthyEnv=e=>void 0!==e&&SKIP.truthy.includes(String(e).trim().toLowerCase());function reducedMode(e={}){const t=e.env||{};return!(!isTruthyEnv(t.AEGIS_REDUCED_MODE)&&!isTruthyEnv(process.env.AEGIS_REDUCED_MODE))||limits.armed()}const SKIP_ENV_WARNING="AEGIS_SKIP_PERMISSIONS is set but this session is interactive — ignoring it. Pass --dangerously-skip-permissions to skip the configurable gates on purpose; the ÆGIS covenant and the write|shell|network|offDevice approvals are never skipped.";function resolveSkip(e={}){const t=!0===e.flag,n=e.env||{},r=!0===e.interactive,i=isTruthyEnv(n[SKIP.env]),s=isTruthyEnv(n[SKIP.productEnv]);return reducedMode(e)?{skip:!1,source:"reduced",flag:t,envSet:i,interactive:r,warned:!1,warning:null}:t||s?{skip:!0,source:t?"flag":"product",flag:t,envSet:i,interactive:r,warned:!1,warning:null}:i&&!r?{skip:!0,source:"env",flag:t,envSet:i,interactive:r,warned:!1,warning:null}:i&&r?{skip:!1,source:"env-ignored",flag:t,envSet:i,interactive:r,warned:!0,warning:SKIP_ENV_WARNING}:{skip:!1,source:"none",flag:t,envSet:!1,interactive:r,warned:!1,warning:null}}module.exports={canonTool:canonTool,isShellTool:isShellTool,subjectFor:subjectFor,matchRule:matchRule,isMultiDirCommand:isMultiDirCommand,evalPermission:evalPermission,SKIP:SKIP,SKIP_ENV_WARNING:SKIP_ENV_WARNING,resolveSkip:resolveSkip};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const PING_MODES=Object.freeze(["off","bell","notify","both"]),DEFAULT_PING_MODE="both",DEFAULT_PING_SECONDS=30,MAX_PING_SECONDS=3600,PING_TITLE="AEGIS Code",PING_TEXT_MAX=120,BEL="",ESC="",BODY="Reply ready";function normalizePingMode(n){const i=String(null==n?"":n).trim().toLowerCase();return PING_MODES.includes(i)?i:DEFAULT_PING_MODE}function normalizePingSeconds(n){const i="number"==typeof n?n:String(null==n?"":n).trim();if(""===i)return DEFAULT_PING_SECONDS;const e="number"==typeof i?i:Number(i);return!Number.isFinite(e)||e<0?DEFAULT_PING_SECONDS:Math.min(MAX_PING_SECONDS,Math.floor(e))}function sanitizePingText(n,i=PING_TEXT_MAX){const e=String(null==n?"":n).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim(),t=Number.isFinite(i)&&i>0?Math.floor(i):PING_TEXT_MAX;return e.length>t?`${e.slice(0,Math.max(0,t-1))}…`:e}function shouldPing({mode:n,elapsedMs:i,minSeconds:e,isTTY:t,aborted:o}={}){if("off"===normalizePingMode(n))return!1;if(o)return!1;if(!t)return!1;const r="number"==typeof i?i:String(null==i?"":i).trim();if(""===r)return!1;const u=Number(r);return!(!Number.isFinite(u)||u<0)&&u>=1e3*normalizePingSeconds(e)}function buildPing({mode:n=DEFAULT_PING_MODE,title:i=PING_TITLE,body:e=BODY}={}){const t=normalizePingMode(n);if("off"===t)return"";const o=sanitizePingText(i),r=sanitizePingText(e),u=[];return"notify"!==t&&"both"!==t||(u.push(`${ESC}]9;${r}${BEL}`),u.push(`${ESC}]777;notify;${o};${r}${BEL}`)),"bell"!==t&&"both"!==t||u.push(BEL),u.join("")}function writePing(n,i){if(!i)return!1;if(!n||"function"!=typeof n.write)return!1;try{return n.write(i),!0}catch{return!1}}function formatPingDuration(n){const i=Math.max(0,Math.floor(Number(n)||0));if(i<60)return`${i}s`;const e=Math.floor(i/60);return e<60?`${e}m${String(i%60).padStart(2,"0")}s`:`${Math.floor(e/60)}h${String(e%60).padStart(2,"0")}m`}function pingNoticeText({seconds:n,mode:i}={}){const e=normalizePingMode(i),t="bell"===e?"bell rung":"notify"===e?"notification sent":"bell rung, notification sent";return`[ping] reply ready after ${formatPingDuration(n)} — ${t}; /ping off silences this`}function pingTurn({stream:n,mode:i,minSeconds:e,elapsedMs:t,isTTY:o,aborted:r}={}){return shouldPing({mode:i,minSeconds:e,elapsedMs:t,isTTY:o,aborted:r})&&writePing(n,buildPing({mode:i}))?pingNoticeText({seconds:Number(t)/1e3,mode:i}):null}module.exports={PING_MODES:PING_MODES,DEFAULT_PING_MODE:DEFAULT_PING_MODE,DEFAULT_PING_SECONDS:DEFAULT_PING_SECONDS,MAX_PING_SECONDS:MAX_PING_SECONDS,PING_TITLE:PING_TITLE,PING_TEXT_MAX:PING_TEXT_MAX,normalizePingMode:normalizePingMode,normalizePingSeconds:normalizePingSeconds,sanitizePingText:sanitizePingText,shouldPing:shouldPing,buildPing:buildPing,writePing:writePing,formatPingDuration:formatPingDuration,pingNoticeText:pingNoticeText,pingTurn:pingTurn};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const path=require("node:path"),{resolveShared:resolveShared}=require("./sharedpaths.js"),KILL_ENV="AEGIS_NO_PRESENCE";function presenceDisabled(e){try{const r=e&&e[KILL_ENV];return null!=r&&""!==String(r).trim()&&/^(1|true|on|yes)$/i.test(String(r).trim())}catch{return!1}}function loadShared(){return{presence:require(resolveShared(path.join("client","presence.js"))),fingerprint:require(resolveShared(path.join("client","device-fingerprint.js")))}}function cliVersion(){try{return require(path.join(__dirname,"..","package.json")).version||null}catch{return null}}let current=null;function start(e={}){stop();const r=e.env||process.env;if(presenceDisabled(r))return current=inert("kill-switch");let t="";try{if(e.client&&"string"==typeof e.client.apiKey&&(t=e.client.apiKey),!t&&e.credentials&&"function"==typeof e.credentials.resolveApiKey){const n=e.credentials.resolveApiKey({env:r});t=n&&(n.key||n.apiKey)||""}}catch{t=""}if(!t)return current=inert("no-api-key");try{const{presence:r,fingerprint:n}=loadShared(),i=r.createPresence({apiKey:t,app:"cli",version:cliVersion(),platform:process.platform,install:n.machineFingerprint(),queueDepth:e.queueDepth,autonomous:Boolean(e.autonomous),log:e.log,fetchImpl:e.fetchImpl,now:e.now,setTimer:e.setTimer,clearTimer:e.clearTimer});return i.start(),current=i}catch(e){return current=inert(`load-failed:${String(e&&e.message||e).slice(0,80)}`)}}function inert(e){return{enabled:!1,reason:e,install:null,stop:()=>!0,state:()=>({enabled:!1,reason:e,beats:0,failures:0,running:!1})}}function stop(){if(!current)return!1;try{current.stop()}catch{}return current=null,!0}function active(){return current}function queueDepthReader(){let e=null;try{e=require(resolveShared(path.join("desktop","lib","local","queue.js")))}catch{e=null}return()=>{try{if(!e||"function"!=typeof e.readQueue||"function"!=typeof e.queuePath)return 0;const r=e.readQueue(e.queuePath());return(Array.isArray(r)?r:[]).filter((e=>e&&"pending"===e.status)).length}catch{return 0}}}function flush(e=1500){try{if(!current||"function"!=typeof current.pending)return Promise.resolve("none");const r=current.pending();if(!r)return Promise.resolve("none");const t=Number.isFinite(Number(e))&&Number(e)>0?Number(e):1500;return Promise.race([Promise.resolve(r).then((()=>"drained"),(()=>"drained")),new Promise((e=>{setTimeout((()=>e("timeout")),t)}))])}catch{return Promise.resolve("none")}}module.exports={start:start,stop:stop,active:active,flush:flush,presenceDisabled:presenceDisabled,queueDepthReader:queueDepthReader,cliVersion:cliVersion,KILL_ENV:KILL_ENV};
@@ -0,0 +1,58 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";
4
+ /**
5
+ * provenance — who this program is, and whether it is still the program that
6
+ * was published.
7
+ *
8
+ * Two questions, both asked from inside the CLI so the answer is available to
9
+ * the person running it and not only to whoever holds the git clone:
10
+ *
11
+ * 1. **Identity.** `IDENTITY` is the one place the product name, licence,
12
+ * copyright holder and source URL are written for a user to read: it is
13
+ * what `aegiscode provenance` prints, and what a rebranded copy has to
14
+ * deliberately delete rather than merely never mention. This half is
15
+ * *meant* to be read, and removing it is itself the evidence.
16
+ *
17
+ * 2. **Integrity of the safety files.** `selfCheck()` re-hashes the CLI files
18
+ * whose edit changes what the program ALLOWS — the agent-key gate, the
19
+ * permission evaluator, the frozen approval classes, the `runner with no
20
+ * one to answer it`, the entry point that wires them, the silent interlock
21
+ * in src/limits.js, and this file — against `provenance.lock.json`, which
22
+ * ships in the package.
23
+ *
24
+ * This half is deliberately OPAQUE. Its manifest carries no paths, only
25
+ * digests under non-identifying unit ids, and the manifest is the only
26
+ * place they appear: the id→path table lives in `UNITS` below, and every
27
+ * message this module emits names a unit id and nothing else. A report
28
+ * that said "src/gate.js: a1b2… → c3d4…" would be a repair manual for
29
+ * whoever neutered the gate, and the whole point of the check is that the
30
+ * build which fails it does not get told where to aim next.
31
+ *
32
+ * ## What this is not
33
+ *
34
+ * It is not DRM, and calling it tamper-proof would be a lie of the kind this
35
+ * repo keeps a ledger of. Whoever has the bytes can edit the safety file AND
36
+ * regenerate the lock; there is no key here and no server to ask, because a
37
+ * client that phones home to prove itself is a client that fails when the
38
+ * network does, and this program is used offline. What it buys is that the
39
+ * neutered build is no longer SILENT: either it announces the divergence to its
40
+ * own user, or its author deleted a check that is named in every file header and
41
+ * pinned by `tools/invariant-lock.mjs` — a deliberate act with a paper trail.
42
+ *
43
+ * The second gate is `src/limits.js`. It withholds capability instead of
44
+ * explaining a mismatch, so deleting the loud report is not enough: a build
45
+ * assembled that way still refuses its own privileged subcommands and says only
46
+ * that it is in reduced mode. It is also not asked from one place — each module
47
+ * that owns one of those privileges (`gate.js`, `mcp.js`, `autonomous.js`,
48
+ * `permissions.js`) asks it for itself, so the refusal survives the deletion of
49
+ * the entry point's call rather than going with it.
50
+ *
51
+ * ## Why a missing lock file is a failure, not a pass
52
+ *
53
+ * Fail-closed, like the repo's gate and its invariant lock, and for the same
54
+ * reason: deleting the manifest is the cheapest possible way to switch this off,
55
+ * so absence is reported (`unverifiable`) instead of being read as "nothing
56
+ * configured". `AEGIS_NO_PROVENANCE_CHECK=1` silences it for a development tree
57
+ * that is mid-edit — loudly, and by name, so it is never the quiet path.
58
+ */const{createHash:createHash}=require("node:crypto"),{existsSync:existsSync,readFileSync:readFileSync}=require("node:fs"),path=require("node:path"),limits=require("./limits.js"),IDENTITY=Object.freeze({product:"AEGIS Code",bin:"aegiscode",license:"AGPL-3.0-or-later",copyright:"Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.",source:"https://github.com/aegisinfo/aegiscode-plugin",homepage:"https://aegiscloud.org"}),UNITS=Object.freeze([Object.freeze({id:"p1",rel:"bin/aegiscode.js"}),Object.freeze({id:"p2",rel:"src/provenance.js"}),Object.freeze({id:"p3",rel:"src/gate.js"}),Object.freeze({id:"p4",rel:"src/permissions.js"}),Object.freeze({id:"p5",rel:"src/caps.js"}),Object.freeze({id:"p6",rel:"src/autonomous.js"}),Object.freeze({id:"p7",rel:"src/limits.js"}),Object.freeze({id:"p8",rel:"src/mcp.js"})]),PACKAGE_ROOT=path.join(__dirname,".."),MANIFEST_FILE=path.join(__dirname,"provenance.lock.json"),sha256=e=>createHash("sha256").update(e).digest("hex");function readManifest(){try{const e=JSON.parse(readFileSync(MANIFEST_FILE,"utf8"));return e?e.units&&"object"==typeof e.units?{units:e.units,legacyPaths:null}:e.files&&"object"==typeof e.files?{units:e.files,legacyPaths:e.files}:null:null}catch{return null}}function expectedFor(e,s){if(e)return e.legacyPaths?e.legacyPaths[s.rel]:e.units[s.id]}function selfCheck(){const e=readManifest();if(!e)return{ok:!1,checked:0,problems:[`${path.basename(MANIFEST_FILE)} is missing or unreadable`],unverifiable:!0};const s=[];let t=0;for(const i of UNITS){const r=path.join(PACKAGE_ROOT,i.rel);if(existsSync(r))try{const n=sha256(readFileSync(r));t++;const o=expectedFor(e,i);o&&n!==o&&s.push(`${i.id}: digest moved`)}catch{s.push(`${i.id}: unreadable`)}else s.push(`${i.id}: sealed unit missing from this install`)}return{ok:0===s.length,checked:t,problems:s,unverifiable:!1}}function warning(e){return!e||e.ok?null:process.env.AEGIS_NO_PROVENANCE_CHECK?`aegiscode: provenance check SKIPPED (AEGIS_NO_PROVENANCE_CHECK is set): ${e.problems[0]}\n`:`aegiscode: provenance — ${e.problems.length} sealed unit${1===e.problems.length?"":"s"} do not match the published manifest (${IDENTITY.license}):\n`+e.problems.map((e=>`aegiscode: ${e}\n`)).join("")+"aegiscode: this build is not the published one; do not trust what it reports about itself.\n"}function describe({version:e}={}){const s=selfCheck(),t=[`${IDENTITY.product} (${IDENTITY.bin})${e?` ${e}`:""} — ${IDENTITY.license}`,`source: ${IDENTITY.source}`,`homepage: ${IDENTITY.homepage}`,IDENTITY.copyright];if(limits.armed())return t.push("safety: reduced mode — this build is not the one that was published."),{text:t.join("\n")+"\n",ok:!1,report:{ok:!1,checked:s.checked,problems:[],unverifiable:s.unverifiable,withheld:!0}};if(s.ok)t.push(`safety: ${s.checked} sealed units verified`);else if(s.unverifiable)t.push(`safety: UNVERIFIABLE — ${s.problems[0]}`);else{t.push(`safety: ${s.problems.length} sealed unit(s) do not match the published manifest:`);for(const e of s.problems)t.push(` ${e}`)}return{text:t.join("\n")+"\n",ok:s.ok,report:s}}function sealMap(){return UNITS.map((e=>({id:e.id,rel:e.rel})))}module.exports={IDENTITY:IDENTITY,UNITS:UNITS,MANIFEST_FILE:MANIFEST_FILE,selfCheck:selfCheck,warning:warning,describe:describe,sealMap:sealMap};
@@ -0,0 +1,36 @@
1
+ {
2
+ "v": 1,
3
+ "alg": "sha256",
4
+ "comment": [
5
+ "Generated by tools/provenance.mjs (`lock --write`, which also seals the",
6
+ "interlock). Read that file, and cli/src/provenance.js, before editing this.",
7
+ "",
8
+ "IDS ONLY. The id-to-path table is in cli/src/provenance.js (`UNITS`) and is",
9
+ "never printed at runtime; this file deliberately does not name the files it",
10
+ "covers, because the manifest ships in the package and a manifest that listed",
11
+ "them would be a table of contents for whoever wants to edit one.",
12
+ "",
13
+ "cli/src/provenance.js re-hashes these at startup and writes one line to",
14
+ "stderr if a digest moved — by id, without naming the file or the fix. A",
15
+ "second, silent gate (cli/src/limits.js) asks the same question as a closed",
16
+ "set and, when it fails, withholds the privileged subcommands instead of",
17
+ "explaining anything.",
18
+ "",
19
+ "This is a speed bump with a loud voice, not DRM: whoever holds the bytes",
20
+ "can regenerate this file. It is worth regenerating only deliberately —",
21
+ "`tools/invariant-lock.mjs` pins this file and the safety files, so a silent",
22
+ "change upstream fails the lock instead of landing."
23
+ ],
24
+ "license": "AGPL-3.0-or-later",
25
+ "source": "https://github.com/aegisinfo/aegiscode-plugin",
26
+ "units": {
27
+ "p1": "909ac3005c25322fe6eeb99c817788c78699cac339482ebbfd2ebc16b3db5ad9",
28
+ "p2": "d63d147de5455eea111d000b748d7eef9572a11a08d31f2471d5ff146701342c",
29
+ "p3": "ff962ac8dbf42cecb2477e2f77bf5ec61f88aa1751b0d4e506bf030fbc5fc6c6",
30
+ "p4": "2e8385c3a653a2af324050b4b92aeb9d142fc6765c91a13ccc928c5d4a2dbedb",
31
+ "p5": "408d67f78f31f6d637a26d2852e0c809a260544e613afdc64b731401c0ba3801",
32
+ "p6": "22bcd0b5dc1afad8d870652fbf1fd25bd0a547be9d8700161449cafa35bab6eb",
33
+ "p7": "e1f4a85e7e7b38a043111aaf98d0d2703340fd5bc6919923beb1a3539355aa46",
34
+ "p8": "3cc054d06715e065fe635b37b7d1bb98bf7989d64453a572ddbb77cec5b830e7"
35
+ }
36
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{RGB:RGB,BG:BG,RESET:RESET,BOLD:BOLD,DIM:DIM,ITALIC:ITALIC,UNDER:UNDER,RESET_FG:RESET_FG,RESET_BG:RESET_BG,GLYPH:GLYPH,VERBS:VERBS,DONE_VERBS:DONE_VERBS,themeOf:themeOf}=require("./theme.js"),{WELCOME_TITLE:WELCOME_TITLE,WELCOME_BACK:WELCOME_BACK,TAGLINE:TAGLINE,STAR:STAR,stencilGlyph:stencilGlyph,welcomeArtParts:welcomeArtParts}=require("./art.js"),{w:w,pad:pad,padStart:padStart,wrapBlock:wrapBlock,clip:clip,span:span}=require("./screen.js"),{fmtTokens:fmtTokens,fmtEur:fmtEur,fmtElapsed:fmtElapsed,fmtUsageSplit:fmtUsageSplit,displayTokens:displayTokens,feeBillable:feeBillable}=require("./format.js"),{renderDiffBlock:renderDiffBlock}=require("./diffview.js");let markdown=null;try{markdown=require("./markdown.js")}catch{markdown=null}const errMark=()=>GLYPH.err,warnMark=()=>GLYPH.warn,fg=(e,t)=>`${t}`,bg=e=>BG(...e),spansToString=e=>e.map((e=>(e.s||"")+e.t)).join("")+RESET;function centerStyled(e,t,r){const n=clip(e,t),s=Math.max(0,Math.floor((t-w(n))/2));return" ".repeat(s)+r+n+RESET}function tintWhale(e,t){const r={"▓":t.blue,"▒":t.lavender,"░":t.dim,"█":t.white,[STAR]:t.gold,"·":t.dim},n={};for(const e of Object.keys(r))n[stencilGlyph(e)]=r[e];const s=[];let o=null,a="";for(const t of e){const e=null!=n[t]?n[t]:"";null!==o&&e===a?o+=t:(null!==o&&s.push(span(a,o)),o=t,a=e)}return null!==o&&s.push(span(a,o)),s}function artRow(e,t,r,n){const s=themeOf(e),o=t[0]||"",a=t[1]||"",l=[span(""," ".repeat(n))];return o&&a?(l.push(span(s.gold,o)),l.push(span(""," ".repeat(r.gutter))),l.push(...tintWhale(a,s))):o?(l.push(span(s.gold,o)),w(o)<r.width&&l.push(span(""," ".repeat(r.width-w(o))))):a?(l.push(...tintWhale(a,s)),w(a)<r.width&&l.push(span(""," ".repeat(r.width-w(a))))):l.push(span(""," ".repeat(r.width))),spansToString(l)}function renderBanner(e,t={}){const r=themeOf(e),n=Math.max(20,Number(t.width)||80),s=[];s.push(`${r.gold}${GLYPH.ruleHeavy}${GLYPH.rule.repeat(Math.max(0,n-2))}${GLYPH.ruleHeavy}${RESET}`),s.push("");const o=welcomeArtParts();if(n>=o.width+2){const t=Math.max(0,Math.floor((n-o.width)/2));for(const r of o.rows)s.push(artRow(e,r,o,t))}else s.push(centerStyled("AEGIS CODE",n,r.gold+BOLD));s.push("");const a=!1===t.firstRun?WELCOME_BACK:WELCOME_TITLE;s.push(centerStyled(a,n,r.coral+BOLD));const l=[t.version?`v${t.version}`:null,TAGLINE].filter(Boolean).join(` ${GLYPH.bullet} `);return s.push(centerStyled(l,n,r.gray)),s.push(""),s.push(...renderIdentityBox(e,t,n)),s}function renderIdentityBox(e,t={},r=80){const n=themeOf(e),s=[renderHeading(e,"aegiscode",r)],o=[["version",t.version?`v${t.version}`:null],["model",t.model||"server default"],["base",t.base||""],["key",t.key||"not set"],["render",!1===t.stream?"buffered":"streaming"]].filter((([,e])=>e));for(const[e,t]of o){const o=clip(String(t),Math.max(0,r-12));s.push(` ${n.gray}${e.padEnd(8)}${RESET}${n.white}${o}${RESET}`)}const a=clip(` type /help for commands ${GLYPH.bullet} /quit to exit`,r);return s.push(""),s.push(`${n.dim}${a}${RESET}`),s}function mdLines(e,t,r){const n=themeOf(r),s=[];let o=!1;const a=Math.max(20,t-4);for(const t of String(null==e?"":e).split("\n")){if(/^\s*```/.test(t)){o=!o;continue}if(o){for(const e of wrapBlock(t,a))s.push(`${n.gray} ${e}${RESET}`);continue}if(""===t.trim()){s.push("");continue}const e=/^(\s*)[-*]\s+(.*)$/.exec(t);if(e){const t=" ".repeat(Math.min(6,e[1].length));for(const o of wrapBlock(inline(e[2],r),a-2))s.push(`${t}${n.gray}${GLYPH.bullet}${RESET} ${o}`);continue}const l=/^(#{1,6})\s+(.*)$/.exec(t);if(l)s.push(`${n.gold}${BOLD}${inline(l[2],r)}${RESET}`);else for(const e of wrapBlock(inline(t,r),a,""))s.push(e)}return s}function inline(e,t){const r=themeOf(t);return String(null==e?"":e).replace(/`([^`]+)`/g,((e,t)=>`${r.green}${t}${RESET}`)).replace(/\*\*([^*]+)\*\*/g,((e,t)=>`${BOLD}${t}${RESET}`))}function assistantLines(e,t,r){return markdown&&"function"==typeof markdown.renderMarkdown?markdown.renderMarkdown(String(null==t?"":t),r,e).map(spansToString):mdLines(t,r,e)}function renderTurn(e,t,r=80){const n=themeOf(e),s=t.role||"assistant",o=String(null==t.text?"":t.text),a=[];if("user"===s)wrapBlock(o,Math.max(8,r-2)).forEach(((e,t)=>{0===t?a.push(`${n.gray}${GLYPH.cursor}${RESET} ${n.white}${e}${RESET}`):a.push(` ${n.white}${e}${RESET}`)}));else if("assistant"===s||"system"===s){const t=assistantLines(e,o,Math.max(8,r-2));t.length||t.push(""),t[0]=`${n.white}${GLYPH.block}${RESET} `+t[0],a.push(...t)}else if("tool"===s){const s=void 0===t.ok?"":t.ok?` ${n.green}${GLYPH.check}${RESET}`:` ${n.red}${errMark()}${RESET}`;a.push(`${n.gray}${t.label||"tool"}${RESET}${s}`);const o=null==t.args?"":"string"==typeof t.args?t.args:JSON.stringify(t.args);t.diff?a.push(...renderDiffBlock(t.diff,e,r,{open:!!t.diffOpen})):o&&a.push(` ${n.gray}${GLYPH.hook} $ ${clip(o,Math.max(0,r-6))}${RESET}`)}else if("error"===s)a.push(`${n.red}${errMark()} ${o}${RESET}`);else for(const e of wrapBlock(o,Math.max(8,r-2)))a.push(`${n.white}${e}${RESET}`);if(t.meta){const n=renderMeta(e,t.meta,r);n&&a.push(n)}return a}function renderMeta(e,t={},r=80){const n=themeOf(e),s=[];t.model&&s.push(`${n.blue}${t.model}${RESET}`);const o=t.usage&&"object"==typeof t.usage?t.usage:t,a=fmtUsageSplit(o);if(a)s.push(`${n.white}${a.output}${RESET}`);else{const e=displayTokens(o);null!=e&&s.push(`${n.white}${fmtTokens(e)} tokens${RESET}`)}if(null!=t.eur&&feeBillable()&&s.push(`${t.eur>0?n.coral:n.green}${fmtEur(t.eur)}${RESET}`),null!=t.ms&&s.push(`${n.gray}${fmtElapsed(t.ms)}${RESET}`),t.calls>1&&s.push(`${n.gray}${t.calls} calls${RESET}`),!s.length)return"";const l=`${n.dim} ${GLYPH.bullet} ${RESET}`;return`${n.dim}${GLYPH.hook} ${RESET}${s.join(l)}`}function renderStatus(e,t={},r=80){const n=themeOf(e),s=["aegis"];t.model&&s.push(t.model),null!=t.tokens&&s.push(`${fmtTokens(t.tokens)} tokens`),null!=t.spend&&s.push(fmtEur(t.spend)),t.mode&&s.push(t.mode);const o=t.hint||"ctrl+c quit",a=` ${s.join(` ${GLYPH.bullet} `)} `,l=r-w(a)-w(o)-1,i=l>0?a+" ".repeat(l)+o+" ":clip(a,r);return`${n.gray}${pad(i,r)}${RESET}`}function renderWorking(e,t={}){const r=themeOf(e);if(t.done){const e=t.verb||DONE_VERBS[t.tools?1:0]||DONE_VERBS[0],n=null!=t.secs?t.secs:Math.max(1,Math.round((t.elapsedMs||0)/1e3));return`${r.gray}${GLYPH.bloom} ${e} for ${n}s${RESET}`}const n=GLYPH.spin[Math.abs(Math.floor(t.tick||0))%GLYPH.spin.length],s=t.verb||VERBS[0],o=[];null!=t.elapsedMs&&o.push(fmtElapsed(t.elapsedMs)),null!=t.streamed&&o.push(`↓${t.streamedFloor?"≥":""}${fmtTokens(t.streamed)} tokens`);const a=o.length?` ${r.gray}(${o.join(` ${GLYPH.bullet} `)})${RESET}`:"";return`${r.coral}${n}${RESET} ${r.white}${s}${RESET}${r.white}…${RESET}${a}${r.dim} esc to interrupt${RESET}`}function renderHeading(e,t,r=80){const n=themeOf(e),s=` ${t} `,o=Math.max(0,r-w(s)),a=Math.floor(o/2),l=GLYPH.rule;return`${n.gray}${l.repeat(a)}${RESET}${n.gold}${BOLD}${s}${RESET}${n.gray}${l.repeat(Math.max(0,o-a))}${RESET}`}function renderToolResult(e,t,r,n=80){const s=themeOf(e),o=[renderHeading(e,t,n)];for(const e of wrapBlock(String(null==r?"":r),Math.max(8,n-2)))o.push(e?` ${s.white}${e}${RESET}`:"");return o}function renderApproval(e,t={},r=80){const n=themeOf(e),s=[renderHeading(e,`confirm ${t.tool||"tool"}`,r)],o=t.diff?t.diff:null==t.args?"":"string"==typeof t.args?t.args:JSON.stringify(t.args);for(const e of wrapBlock(o,Math.max(8,r-2)))s.push(e?` ${n.gray}${e}${RESET}`:"");return s.push(""),s.push(` ${n.coral}${GLYPH.bullet}${RESET} ${n.white}y${RESET}es once ${n.dim}${GLYPH.bullet}${RESET} ${n.white}s${RESET}ession ${n.dim}${GLYPH.bullet}${RESET} ${n.white}n${RESET}o ${n.dim}(default)${RESET}`),s}const NOTICE={info:["gray",()=>GLYPH.bullet],warn:["coral",warnMark],error:["red",errMark],ok:["green",()=>GLYPH.check]};function renderNotice(e,t,r){const n=themeOf(e),[s,o]=NOTICE[t]||NOTICE.info;return`${n[s]}${o()} ${r}${RESET}`}module.exports={renderBanner:renderBanner,renderIdentityBox:renderIdentityBox,renderTurn:renderTurn,renderMeta:renderMeta,renderStatus:renderStatus,renderWorking:renderWorking,renderHeading:renderHeading,renderToolResult:renderToolResult,renderApproval:renderApproval,renderNotice:renderNotice,mdLines:mdLines,inline:inline,artRow:artRow,tintWhale:tintWhale,fg:fg,bg:bg,UNDER:UNDER,ITALIC:ITALIC,RESET_FG:RESET_FG,RESET_BG:RESET_BG,pad:pad,padStart:padStart};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const ANSI_RE=/\x1b\[[0-9;]*[A-Za-z]/g,{caps:caps,cellWidth:cellWidth}=require("./caps.js"),cwidth=t=>cellWidth(t);function stripAnsi(t){return String(t).replace(ANSI_RE,"")}function w(t){let e=0;for(const o of stripAnsi(t))e+=cwidth(o);return e}function clip(t,e){if(w(t)<=e)return t;let o="",i=0;for(const n of String(t)){const t=cwidth(n);if(i+t>e)break;o+=n,i+=t}return o}function pad(t,e){const o=clip(t,e);return o+" ".repeat(Math.max(0,e-w(o)))}function padStart(t,e){const o=clip(t,e);return" ".repeat(Math.max(0,e-w(o)))+o}function span(t,e){return{t:e,s:t,w:w(e)}}const lineWidth=t=>t.reduce(((t,e)=>t+e.w),0);function padLine(t,e){let o=0;const i=[];for(const n of t){if(o>=e)break;let t=n.t,s=n.w;if(o+s>e){const i=e-o;let n="",r=0;for(const e of[...t]){const t=w(e);if(r+t>i)break;n+=e,r+=t}t=n,s=r}i.push({t:t,s:n.s,w:s}),o+=s}return o<e&&i.push(span(""," ".repeat(e-o))),i}const getSize=()=>{const t=caps();return{cols:t.cols,rows:t.rows}};function wrapLine(t,e,o=""){const i=Math.max(8,e);if(w(t)<=i)return[t];const n=t.split(" "),s=[];let r="";for(const t of n){const e=r?`${r} ${t}`:t;if(w(e)<=i){r=e;continue}if(r&&s.push(r),w(t)<=i){r=t;continue}let o=t;for(;w(o)>i;){const t=clip(o,i);s.push(t),o=o.slice(t.length)}r=o}return!r&&s.length||s.push(r),s}function wrapBlock(t,e,o="",i=!1){const n=[];for(const i of String(t).split("\n"))""!==i?wrapLine(i,e-w(o)).forEach((t=>n.push(o+t))):n.push("");return n}const ESC={hideCursor:"[?25l",showCursor:"[?25h",clearToEnd:"",clearLine:"",clearScreen:"",up:t=>t>0?`[${t}A`:"",down:t=>t>0?`[${t}B`:"",col:t=>`[${t}G`},hideCursor=()=>process.stdout.write("[?25l"),showCursor=()=>process.stdout.write("[?25h"),moveTo=(t,e)=>process.stdout.write(`[${t};${e}H`);function clearScreen(){process.stdout.write("")}let inAlt=!1;function enterAltScreen(){inAlt||(inAlt=!0,process.stdout.write("[?1049h"))}function leaveAltScreen(){inAlt&&(inAlt=!1,process.stdout.write("[?1049l"),flushExitNotice())}let exitNotice=null;function queueExitNotice(t){exitNotice=t}function flushExitNotice(){if(null===exitNotice)return;const t=exitNotice;exitNotice=null,process.stdout.write(t)}const hasExitNotice=()=>null!==exitNotice,isAltScreen=()=>inAlt,enableBracketedPaste=()=>process.stdout.write("[?2004h"),disableBracketedPaste=()=>process.stdout.write("[?2004l"),enableMouseTracking=()=>process.stdout.write("[?1000h[?1002h[?1006h"),disableMouseTracking=()=>process.stdout.write("[?1000l[?1002l[?1006l"),SELECT_ON="",SELECT_OFF="";function selectionRange(t,e){return t.row<e.row||t.row===e.row&&t.col<=e.col?{startRow:t.row,startCol:t.col,endRow:e.row,endCol:e.col}:{startRow:e.row,startCol:e.col,endRow:t.row,endCol:t.col}}function sliceLine(t,e,o){const i=[];let n=0;for(const s of t){const t=n;if(n+=s.w,n<=e||t>=o)continue;let r=s.t,c=t;if(c<e){const t=e-c;let o=0,i=0;for(const e of r){if(o>=t)break;o+=w(e),i+=e.length}r=r.slice(i),c+=o}if(c+w(r)>o){let t=0,e="";for(const i of r){const n=w(i);if(c+t+n>o)break;e+=i,t+=n}r=e}r&&i.push({t:r,s:s.s,w:w(r)})}return i}function selectionText(t,e){const o=[];for(let i=e.startRow;i<=e.endRow;i++){const n=t[i]||[],s=i===e.startRow?e.startCol:0,r=i===e.endRow?e.endCol:1/0;o.push(sliceLine(n,s,r).map((t=>t.t)).join("").replace(/[ \t]+$/,""))}for(;o.length&&""===o[0];)o.shift();for(;o.length&&""===o[o.length-1];)o.pop();return o.join("\n")}function applySelection(t,e,o){const i=t.slice();for(let t=e.startRow;t<=e.endRow;t++){if(t<0||t>=i.length)continue;const n=padLine(i[t]||[],o),s=t===e.startRow?e.startCol:0,r=t===e.endRow?e.endCol:o,c=sliceLine(n,s,r);c.length&&(i[t]=[...sliceLine(n,0,s),{t:"",s:"",w:0},...c,{t:"",s:"",w:0},...sliceLine(n,r,o)])}return i}function paint(t){const{rows:e,cols:o}=getSize();let i="";for(let n=0;n<e;n++){i+="";const s=t[n];if(s){const t=padLine(s,o);for(const e of t)i+=e.s+e.t;i+=""}else i+="";n<e-1&&(i+="\n")}i+="",process.stdout.write(i)}function paintFrom(t,e){const{rows:o,cols:i}=getSize();let n="";for(let s=0;s<o-e;s++){const o=t[e+s];if(s>0&&(n+="\n"),n+="",n+="",o){const t=padLine(o,i);for(const e of t)n+=e.s+e.t}}n+="",process.stdout.write(n)}function termWidth(t=80){const{cols:e}=getSize();return e>0?e:Math.max(20,t)}class LiveRegion{constructor(t=process.stdout){this.out=t,this.rows=0,this.active=!1}update(t){const e=t.map((t=>t+ESC.clearToEnd)).join("\n");this.active?this.out.write(ESC.col(1)+ESC.up(this.rows)+e+"\n"+ESC.col(1)+ESC.up(1)):(this.out.write(e),this.active=!0);const o=Math.max(1,getSize().cols);this.rows=t.reduce(((t,e)=>t+Math.max(1,Math.ceil(w(e)/o))),0)}clear(){if(this.active){this.out.write(ESC.col(1)+ESC.clearLine);for(let t=1;t<this.rows;t++)this.out.write(`\n${ESC.clearLine}`);this.out.write(ESC.up(this.rows-1)+ESC.col(1)),this.rows=0,this.active=!1}}}module.exports={queueExitNotice:queueExitNotice,flushExitNotice:flushExitNotice,hasExitNotice:hasExitNotice,w:w,clip:clip,pad:pad,padStart:padStart,stripAnsi:stripAnsi,wrapLine:wrapLine,wrapBlock:wrapBlock,span:span,lineWidth:lineWidth,padLine:padLine,paint:paint,paintFrom:paintFrom,getSize:getSize,EC:ESC,hideCursor:hideCursor,showCursor:showCursor,moveTo:moveTo,clearScreen:clearScreen,enterAltScreen:enterAltScreen,leaveAltScreen:leaveAltScreen,isAltScreen:isAltScreen,enableBracketedPaste:enableBracketedPaste,disableBracketedPaste:disableBracketedPaste,enableMouseTracking:enableMouseTracking,disableMouseTracking:disableMouseTracking,SELECT_ON:"",SELECT_OFF:"",selectionRange:selectionRange,sliceLine:sliceLine,selectionText:selectionText,applySelection:applySelection,LiveRegion:LiveRegion,termWidth:termWidth};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{getSize:getSize,paint:paint,span:span,lineWidth:lineWidth,clip:clip,w:w}=require("./screen.js"),events=require("./events.js"),{nextKey:nextKey,KEY:KEY}=events,{C:C,BOLD:BOLD,BOLD_OFF:BOLD_OFF,GLYPH:GLYPH,THEME_TABLE:THEME_TABLE,themeOf:themeOf,themeIsLight:themeIsLight,terminalIsLight:terminalIsLight}=require("./theme.js"),{TAGLINE:TAGLINE,TAGLINE_SHORT:TAGLINE_SHORT,welcomeArtParts:welcomeArtParts}=require("./art.js"),{renderDiffPreview:renderDiffPreview}=require("./markdown.js"),render=require("./render.js"),{updateConfig:updateConfig,configExists:configExists,loadConfig:loadConfig}=require("./config.js"),{updateNotice:updateNotice,updateLine:updateLine,serverNotice:serverNotice,serverUpdateLine:serverUpdateLine}=require("./update.js"),credentials=require("./credentials.js"),{signupUrl:signupUrl,signupDisplayUrl:signupDisplayUrl}=require("./signup.js"),{createSettingsStore:createSettingsStore,isReservedNamespace:isReservedNamespace}=require("./deps.js"),VERSION=require("../package.json").version,PRODUCT="AEGIS Code",TIPS=[" Run /init to create an AEGIS.md"," Use ↑↓ to recall past prompts"," Press / for commands"," Press Tab to complete a command"," Press ? for shortcuts"],KEY_HELP=[" Add a model: /model add"," <id> <name> <model> <url>"," Set a provider key: /byok-key"," <provider> — openai, anthropic"," Set your account key: /key <key>"," Switch model: /model, or alt+p"," Reasoning effort: /effort"," All commands: press / for the list"],CONNECT_BYOK=["Your own provider key: /byok-key <provider> — works with your AEGIS key"],CONNECT_CLOUD=["AEGIS Cloud, one account key: /key — no provider signup"],CONNECT_BOTH=["Your key, your bill: /byok-key <provider> — or AEGIS Cloud, /key"],CONNECT_DESKTOP=[`AEGIS Desktop: same engine on your machine — ${signupDisplayUrl()}`];function connectRows(){const e=[],t=byokRouteNeeded(),n=cloudRouteNeeded();return t&&n?e.push(...CONNECT_BOTH):t?e.push(...CONNECT_BYOK):n&&e.push(...CONNECT_CLOUD),e.length&&e.push(...CONNECT_DESKTOP),e}function centered(e,t,n){const s=clip(String(e),Math.max(1,t)),r=Math.max(0,Math.floor((t-w(s))/2));return[span(""," ".repeat(r)),span(n,s)]}function wrapped(e,t,n,s=0){const r=String(e).split(" "),o=[];let a=[],i=0;for(const e of r)i+w(e)+1>t-4-s&&a.length?(o.push([span(""," ".repeat(s)),span(n,a.join(" "))]),a=[e],i=w(e)):(a.length&&i++,a.push(e),i+=w(e));return a.length&&o.push([span(""," ".repeat(s)),span(n,a.join(" "))]),o}function trustLines(e,t,n=0,s=process.cwd()){const r=[];r.push([span(C.gold,"─".repeat(Math.max(1,t)))]),r.push([span(C.white+BOLD,"Accessing workspace:")]),r.push([span(C.white+BOLD,clip(s,Math.max(1,t-1)))]),r.push([span("","")]);for(const e of wrapped("Quick safety check: Is this a project you created or one you trust? (Like your own code, a well-known open source project, or work from your team). If not, take a moment to review what's in this folder first.",t,C.white))r.push(e);r.push([span("","")]),r.push([span(C.white,`${PRODUCT} will be able to read, edit, and execute files here.`)]),r.push([span("","")]),r.push([span(C.white+BOLD,"Security guide")]),r.push([span("","")]);for(let e=0;e<2;e++){const t=n===e,s=t?span(C.lavender,GLYPH.cursor):span(""," "),o=span(C.gray,` ${e+1}.`),a=0===e?"Yes, I trust this folder":"No, exit";r.push([s,o,span(t?C.lavender:C.white,a)])}return r.push([span("","")]),r.push([span(C.gray,`Enter to confirm ${GLYPH.bullet} Esc to cancel`)]),r}async function showTrustCheck(e){const{cols:t}=getSize();let n=0;const s=()=>paint(trustLines(e,t,n));for(s();;){const e=await nextKey();if(e.name===KEY.UP||e.name===KEY.DOWN||e.name===KEY.TAB)n=1-n,s();else{if(e.name===KEY.ENTER)return 0===n;if(e.name===KEY.ESC||e.name===KEY.CTRL_C||e.name===KEY.CTRL_D)return!1;if("char"===e.name){const t=String(e.ch).trim();"1"===t&&(n=0,s()),"2"===t&&(n=1,s())}}}}function applyTheme(e,t){return THEME_TABLE[t]||THEME_TABLE[1],e.themeIndex=t,e.light=themeIsLight(t),t}function themePickerLines(e,t,n,s){const r=[];r.push([span(C.coral,`Welcome to ${PRODUCT} v${VERSION}`)]),r.push([span(C.white+BOLD,"Let's get started.")]),r.push([span(C.white,"Choose the text style that looks best with your terminal")]),r.push([span(C.gray,"To change this later, run /theme")]),r.push([span("","")]);for(let e=0;e<THEME_TABLE.length;e++){const t=THEME_TABLE[e],n=s===e,o=n?span(C.lavender,GLYPH.cursor):span(""," "),a=span(C.gray,`${e+1}.`),i=n?span(C.green," "+GLYPH.check):span("","");r.push([o,a,span(n?C.lavender:C.white,t.name),...t.note?[span(C.gray," "+t.note)]:[],i])}for(const n of renderDiffPreview(t,e))r.push(n);for(r.push([span(C.gray," Syntax theme: Monokai Extended (ctrl+t to disable)")]);r.length<n-1;)r.push([span("","")]);return r}async function showThemePicker(e,t=`Welcome to ${PRODUCT}`){const{cols:n,rows:s}=getSize();let r="number"==typeof e.themeIndex?e.themeIndex:terminalIsLight()?2:1;const o=()=>paint(themePickerLines(e,n,s,r));for(o();;){const t=await nextKey();if(t.name===KEY.UP)r=Math.max(0,r-1),o();else if(t.name===KEY.DOWN)r=Math.min(THEME_TABLE.length-1,r+1),o();else{if(t.name===KEY.ENTER||t.name===KEY.ESC||t.name===KEY.CTRL_C||t.name===KEY.CTRL_D)return applyTheme(e,r);if(t.name===KEY.CTRL_T)e.light=!e.light,o();else if("char"===t.name){const e=parseInt(t.ch,10);e>=1&&e<=THEME_TABLE.length&&(r=e-1,o())}}}}function welcomeLines(e,t,n,s=!0){const r=themeOf(e),o=[];o.push([span(r.gold,"━"+"─".repeat(Math.max(0,t-2))+"━")]),o.push([span("","")]);let a=null;try{const e=loadConfig(),t=updateNotice({current:VERSION,cache:e.updateCheck,save:e=>{try{updateConfig({updateCheck:e})}catch{}}});a=updateLine({current:VERSION,...t});const n=serverNotice({current:VERSION,cache:e.updateCheckServer,save:e=>{try{updateConfig({updateCheckServer:e})}catch{}}});a=serverUpdateLine(n)||a}catch{}const i=welcomeArtParts();if(t>=i.width+2){const n=Math.max(0,Math.floor((t-i.width)/2));for(const t of i.rows)o.push(wrapPlain(render.artRow(e,t,i,n)))}else o.push(centered(`${PRODUCT}`,t,r.gold+BOLD));a&&(o.push([span("","")]),o.push(centered(a,t,r.gold))),o.push([span("","")]);const c=s?`Welcome to ${PRODUCT}`:"Welcome back!";o.push(centered(c,t,r.coral+BOLD));const p=t>=w(TAGLINE)+4?TAGLINE:TAGLINE_SHORT;o.push(centered(p,t,r.gray)),o.push([span("","")]),o.push(...boxes(r,t,n-o.length-4)),o.push([span("","")]);for(const e of connectRows())o.push(...wrapped(e,t,r.white,1));for(o.push([span(r.gray,GLYPH.hint),span(r.white,' Try "write a test for <filepath>"')]);o.length<n-1;)o.push([span("","")]);return o}function boxLines(e,t,n,s){const r=Math.max(1,s-4),o=` ${clip(t,Math.max(0,s-4))} `,a=[[span(e.gray,"╭─"),span(e.gray+BOLD,o),span(e.gray,"─".repeat(Math.max(0,s-3-o.length))+"╮")]];for(const t of n){const n=clip(String(t),r);a.push([span(e.gray,"│ "),span(e.white,n+" ".repeat(Math.max(0,r-w(n)))),span(e.gray," │")])}return a.push([span(e.gray,"╰"+"─".repeat(r+2)+"╯")]),a}function boxes(e,t,n){const s=Math.floor((t-2)/2),r=TIPS.map((e=>`${GLYPH.pointer}${e}`)),o=KEY_HELP,a=`Models & keys · v${VERSION}`;if(s>=30){let t=boxLines(e,"Tips for getting started",r,s),n=boxLines(e,a,o,s);const i=Math.max(t.length,n.length),c=t=>{if(t.length>=i)return t;const n=t.slice(0,t.length-1),r=[span(e.gray,"│ "),span(""," ".repeat(Math.max(0,s-4))),span(e.gray," │")];for(;n.length<i-1;)n.push(r);return n.push(t[t.length-1]),n};t=c(t),n=c(n);const p=[];for(let e=0;e<i;e++)p.push([...t[e],span(""," ".repeat(2)),...n[e]]);return p}const i=Math.max(20,t-1);return[...boxLines(e,"Tips for getting started",r,i),...boxLines(e,a,o,i)]}function wrapPlain(e){const t=[],n=/\x1b\[[0-9;]*m/g;let s,r=0,o="";for(;null!==(s=n.exec(e));)s.index>r&&t.push(make(o,e.slice(r,s.index))),o=s[0],r=s.index+s[0].length;return r<e.length&&t.push(make(o,e.slice(r))),t}function make(e,t){const n=span(e,t);return e&&(n.s=e,n.w=w(t)),n}function providerRouteConfigured(){try{return createSettingsStore({dir:credentials.aegisHome()}).list().some((e=>{if(!e||!e.provider||isReservedNamespace(e.provider))return!1;const t="string"==typeof e.baseURL?e.baseURL.trim():"";return Boolean(e.configured||t)}))}catch{return!1}}function connectNeeded(){try{return byokRouteNeeded()||cloudRouteNeeded()}catch{return!0}}function byokRouteNeeded(){try{return!providerRouteConfigured()}catch{return!0}}function cloudRouteNeeded(){try{return!credentials.keyStatus().configured}catch{return!0}}async function showWelcome(e,t=!0){for((()=>{const{cols:n,rows:s}=getSize();paint(welcomeLines(e,n,s,t))})();;){const e=await nextKey();if(e.name===KEY.ENTER||e.name===KEY.ESC)return{exit:!1};if(e.name===KEY.CTRL_C||e.name===KEY.CTRL_D)return{exit:!0}}}const KEY_URL=signupUrl("key_screen");function keyLines(e,t,{value:n="",error:s=null,verify:r=!1}={}){const o=themeOf(e),a=[];a.push([span(o.gold,"─".repeat(Math.max(1,t)))]),a.push([span(o.white+BOLD,"Connect your AEGIS account")]),a.push([span("","")]);for(const e of wrapped("Paste an API key to use AEGIS Cloud. It is stored in your user config directory with owner-only permissions, so later launches and scripts pick it up without an export.",t,o.white))a.push(e);a.push([span("","")]);const i=" No key yet? Free one at ";return w(i)+w(KEY_URL)+2<=t?a.push([span(o.white,i),span(o.cyan,KEY_URL)]):(a.push([span(o.white," No key yet? Free one:")]),a.push([span(o.cyan,` ${KEY_URL}`)])),a.push([span("","")]),a.push([span(o.lavender,GLYPH.cursor),span(o.gray," API key: "),span(o.white,"•".repeat(String(n).length)),span(r?o.cyan:o.gray,r?" verifying…":"")]),s&&a.push([span(o.coral,` ${s}`)]),a.push([span("","")]),a.push([span(o.gray,` ${GLYPH.check} `),span(o.gray,"Enter to save"),span(o.gray," · "),span(o.gray,"Esc to skip")]),a}async function requestApiKey(e,t={}){const n=t.submit||(async()=>({ok:!0})),{cols:s}=getSize();let r="",o=null,a=!1;const i=()=>paint(keyLines(e,s,{value:r,error:o,verify:a}));for(i();;){const e=await nextKey();if(e.name===KEY.ENTER){if(!r.trim())return{skipped:!0};let e;a=!0,o=null,i();try{e=await n(r)}catch(t){e={ok:!1,message:t&&t.message||String(t)}}if(a=!1,e&&!1===e.ok){o=e.message||"that key was refused",i();continue}return{key:r,result:e}}if(e.name===KEY.ESC)return{skipped:!0};if(e.name===KEY.CTRL_C||e.name===KEY.CTRL_D)return{exit:!0};if(e.name!==KEY.BACKSPACE)if("char"!==e.name)"paste"===e.name&&e.text&&(r=(r+String(e.text)).replace(/\s+/g,""),o=null,i());else{const t=e.ch;t&&t>=" "&&(r+=t,o=null,i())}else r=r.slice(0,-1),o=null,i()}}async function runOnboarding(e,t={}){const n=t.seen||configExists,s=t.save||updateConfig,r={showTrustCheck:showTrustCheck,showThemePicker:showThemePicker,showWelcome:showWelcome,requestApiKey:(e,n)=>requestApiKey(e,{submit:t.submitKey||(async()=>({ok:!0})),...n}),...t.ui||{}},o=t.needsKey||(()=>!credentials.hasApiKey()),a=t.canPrompt||(()=>!(!process.stdin||!process.stdin.isTTY)),i={set:!1,skipped:!1};if(t.continue)return{ok:!0,firstRun:!1,themeIndex:e.themeIndex,key:{set:!1,skipped:!1}};const c=!events.isKeyStreamAttached()&&!(!process.stdin||!process.stdin.isTTY);c&&events.attachKeyStream(process.stdin);try{return await async function(){if(!n()){if(!await r.showTrustCheck(e))return{ok:!1,firstRun:!0,themeIndex:e.themeIndex,key:i};if(await r.showThemePicker(e),s({themeIndex:e.themeIndex,light:e.light}),await p())return{ok:!1,firstRun:!0,themeIndex:e.themeIndex,key:i};const t=await r.showWelcome(e,!0);return t&&t.exit?{ok:!1,firstRun:!0,themeIndex:e.themeIndex,key:i}:{ok:!0,firstRun:!0,themeIndex:e.themeIndex,key:i}}if(await p())return{ok:!1,firstRun:!1,themeIndex:e.themeIndex,key:i};const t=await r.showWelcome(e,!1);return t&&t.exit?{ok:!1,firstRun:!1,themeIndex:e.themeIndex,key:i}:{ok:!0,firstRun:!1,themeIndex:e.themeIndex,key:i}}()}finally{c&&events.detachKeyStream()}async function p(){if(!o()||!a())return!1;const t=await r.requestApiKey(e);return!(!t||!t.exit)||(t&&t.key?i.set=!0:i.skipped=!0,!1)}}module.exports={PRODUCT:PRODUCT,TIPS:TIPS,KEY_HELP:KEY_HELP,CONNECT_BYOK:CONNECT_BYOK,CONNECT_CLOUD:CONNECT_CLOUD,CONNECT_BOTH:CONNECT_BOTH,CONNECT_DESKTOP:CONNECT_DESKTOP,connectRows:connectRows,connectNeeded:connectNeeded,byokRouteNeeded:byokRouteNeeded,cloudRouteNeeded:cloudRouteNeeded,providerRouteConfigured:providerRouteConfigured,trustLines:trustLines,themePickerLines:themePickerLines,keyLines:keyLines,applyTheme:applyTheme,welcomeLines:welcomeLines,boxes:boxes,boxLines:boxLines,centered:centered,wrapped:wrapped,wrapPlain:wrapPlain,showTrustCheck:showTrustCheck,showThemePicker:showThemePicker,requestApiKey:requestApiKey,showWelcome:showWelcome,runOnboarding:runOnboarding,KEY_URL:KEY_URL};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const MASK="•";function readSecret(e,t={}){const r=t.stdin||process.stdin,s=t.stdout||process.stdout;return r.isTTY&&"function"==typeof r.setRawMode?new Promise((t=>{s.write(e);let o="";const n=e=>{try{r.setRawMode(!1)}catch{}r.removeListener("data",c),s.write("\n"),t(e)},c=e=>{const t=String(e).replace(/\x1b\[[0-9;?]*[A-Za-z~]/g,"").replace(/\x1b./g,"");for(const e of t){if("\r"===e||"\n"===e)return n(o);if(""===e||""===e)return n("");""!==e&&"\b"!==e?(o+=e,s.write("•")):(o=o.slice(0,-1),s.write("\b \b"))}};r.setRawMode(!0),r.resume(),r.on("data",c)})):Promise.resolve("")}module.exports={readSecret:readSecret,MASK:"•"};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const fs=require("node:fs"),path=require("node:path"),NOFOLLOW=fs.constants.O_NOFOLLOW||0;function hasPosixModes(e=process.platform){return"win32"!==e}function ownedByUs(e){if("function"!=typeof process.getuid)return!0;try{return e.uid===process.getuid()}catch{return!1}}function chmodPrivate(e,t=384){try{const r=fs.lstatSync(e);return!r.isSymbolicLink()&&!!ownedByUs(r)&&((511&r.mode)===t||fs.chmodSync(e,t),!0)}catch{return!1}}function ensurePrivateDir(e){try{fs.mkdirSync(e,{recursive:!0,mode:448})}catch{return!1}try{const t=fs.lstatSync(e);return!(t.isSymbolicLink()||!t.isDirectory()||(hasPosixModes()&&ownedByUs(t)&&0!=(63&t.mode)&&fs.chmodSync(e,448),0))}catch{return!1}}function writePrivateFile(e,t,r={}){ensurePrivateDir(path.dirname(e));const o=fs.constants.O_WRONLY|fs.constants.O_CREAT|fs.constants.O_EXCL|NOFOLLOW;if(!1===r.atomic){try{fs.unlinkSync(e)}catch{}const r=fs.openSync(e,o,384);try{fs.fchmodSync(r,384),fs.writeFileSync(r,t)}finally{fs.closeSync(r)}return!0}const s=e+".tmp";try{fs.unlinkSync(s)}catch{}const n=fs.openSync(s,o,384);try{fs.fchmodSync(n,384),fs.writeFileSync(n,t)}finally{fs.closeSync(n)}return fs.renameSync(s,e),chmodPrivate(e,384),!0}const MAX_WALK_DEPTH=4;function fmtMode(e){return"0"+(511&e).toString(8).padStart(3,"0")}function targetMode(e){return e.isDirectory()||64&e.mode?448:384}function scanTree(e){const t=[],r=(e,o,s)=>{if(s>MAX_WALK_DEPTH)return;let n;try{n=fs.readdirSync(e,{withFileTypes:!0})}catch{return}for(const i of n){if(i.isSymbolicLink())continue;const n=path.join(e,i.name),c=o?`${o}/${i.name}`:i.name;let f;try{f=fs.lstatSync(n)}catch{continue}t.push({rel:c,full:n,st:f}),f.isDirectory()&&r(n,c,s+1)}};return r(e,"",0),t}function exposedBits(e){return 0!=(63&e)}function auditExposure(e,t={}){const r=hasPosixModes(t.platform||process.platform),o={root:e,exists:!1,rootMode:null,exposed:[],total:0,modesMeaningful:r};let s;try{s=fs.lstatSync(e)}catch{return o}if(s.isSymbolicLink()||!s.isDirectory())return o;if(o.exists=!0,o.rootMode=fmtMode(s.mode),!r)return o.total=scanTree(e).length,o;exposedBits(s.mode)&&o.exposed.push({rel:".",mode:o.rootMode,kind:"dir"});const n=scanTree(e);o.total=n.length;for(const e of n)exposedBits(e.st.mode)&&o.exposed.push({rel:e.rel,mode:fmtMode(e.st.mode),kind:e.st.isDirectory()?"dir":"file"});return o}function repairExposure(e,t={}){const r=t.platform||process.platform,o=hasPosixModes(r),s={root:e,exists:!1,fixed:[],failed:[],remaining:[],modesMeaningful:o};let n;try{n=fs.lstatSync(e)}catch{return s}if(n.isSymbolicLink()||!n.isDirectory())return s;if(s.exists=!0,!o)return s;const i=(e,t,r)=>{if(!ownedByUs(t))return void s.failed.push({rel:r,reason:"not owned by this user"});const o=targetMode(t);try{fs.chmodSync(e,o),s.fixed.push({rel:r,from:fmtMode(t.mode),to:fmtMode(o)})}catch(e){s.failed.push({rel:r,reason:e.code||String(e)})}};exposedBits(n.mode)&&i(e,n,".");for(const t of scanTree(e))exposedBits(t.st.mode)&&i(t.full,t.st,t.rel);return s.remaining=auditExposure(e,{platform:r}).exposed,s}module.exports={ensurePrivateDir:ensurePrivateDir,writePrivateFile:writePrivateFile,chmodPrivate:chmodPrivate,auditExposure:auditExposure,repairExposure:repairExposure,fmtMode:fmtMode};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{loadConfig:loadConfig,updateConfig:updateConfig,DEFAULT_CONFIG:DEFAULT_CONFIG}=require("./config.js"),{prefs:prefs}=require("./shared.js"),SHARED_KEYS=new Set(prefs.SHARED_PREF_KEYS);function configStore(e){return SHARED_KEYS.has(e)?"shared":"host"}function parseConfigValue(e){const t=String(null==e?"":e).trim();if(""===t)return"";if("true"===t)return!0;if("false"===t)return!1;if("null"===t)return null;if(/^-?\d+$/.test(t))return Number.parseInt(t,10);if(/^-?\d*\.\d+$/.test(t))return Number.parseFloat(t);if(t.startsWith("[")||t.startsWith("{"))try{return JSON.parse(t)}catch{return t}return t}function summarizeValue(e,t=48){if(null===e)return"null";if(void 0===e)return"(unset)";if(Array.isArray(e))return`[${e.length} item${1===e.length?"":"s"}]`;if("object"==typeof e){const t=Object.keys(e).length;return`{${t} key${1===t?"":"s"}}`}return"string"==typeof e?""===e?'""':e.length>t?`${e.slice(0,t-1)}…`:e:String(e)}function fullValue(e){return e&&"object"==typeof e?JSON.stringify(e,null,2):""===e?'""':String(e)}function configRows(e=loadConfig()){return Object.keys(e).sort().map((t=>({key:t,value:e[t],store:configStore(t),defaulted:Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG,t)&&JSON.stringify(e[t])===JSON.stringify(DEFAULT_CONFIG[t])})))}function formatConfigRows(e=configRows()){if(!e.length)return[" No config keys."];const t=Math.max(...e.map((e=>e.key.length)));return e.map((e=>` ${e.key.padEnd(t)} ${summarizeValue(e.value).padEnd(26)} ${e.store}${e.defaulted?" (default)":""}`))}function setConfigValue(e,t){const r=String(e||"").trim();if(!r)return{error:"usage: /config <key> <value>"};const n=loadConfig();if(!Object.prototype.hasOwnProperty.call(n,r))return{error:`unknown config key "${r}" — run /config to list the keys`};const o=parseConfigValue(t);return updateConfig({[r]:o}),{key:r,value:o,store:configStore(r)}}function resetConfigValue(e){const t=String(e||"").trim();return t?Object.prototype.hasOwnProperty.call(loadConfig(),t)?Object.prototype.hasOwnProperty.call(DEFAULT_CONFIG,t)?(updateConfig({[t]:DEFAULT_CONFIG[t]}),{key:t,value:DEFAULT_CONFIG[t],store:configStore(t)}):{error:`"${t}" has no shipped default to reset to — /config ${t} <value> sets it directly`}:{error:`unknown config key "${t}" — run /config to list the keys`}:{error:"usage: /config reset <key>"}}module.exports={SHARED_KEYS:SHARED_KEYS,configStore:configStore,parseConfigValue:parseConfigValue,summarizeValue:summarizeValue,fullValue:fullValue,configRows:configRows,formatConfigRows:formatConfigRows,setConfigValue:setConfigValue,resetConfigValue:resetConfigValue};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function candidates(e){return[path.join(__dirname,"..","..","client",e),path.join(__dirname,"..","vendor","client",e)]}function resolveClientModule(e){const s=candidates(e);for(const e of s)if(fs.existsSync(e))return e;throw new Error(`aegiscode: cannot find client/${e}. Expected it beside cli/ (in the repo) or under cli/vendor/client/ (installed package). Reinstall the package, or run \`node scripts/predist.mjs\` from cli/ if this is a source checkout.`)}const credentials=require(resolveClientModule("credentials.js")),sessionStore=require(resolveClientModule("session-store.js")),prefs=require(resolveClientModule("prefs.js"));module.exports={credentials:credentials,sessionStore:sessionStore,prefs:prefs,resolveClientModule:resolveClientModule};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const fs=require("node:fs"),path=require("node:path");function roots(){const e=__dirname,o=path.join(e,"..");return[path.join(e,"..",".."),path.join(o,"vendor")]}function resolveShared(e){for(const o of roots()){const r=path.join(o,e);if(fs.existsSync(r))return r}throw new Error(`aegiscode: cannot find ${e}. Expected it beside cli/ (in the repo) or under cli/vendor/ (installed package). Reinstall the package, or run \`node scripts/predist.mjs\` from cli/ if this is a source checkout.`)}module.exports={roots:roots,resolveShared:resolveShared};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ const SIGNUP_ORIGIN="https://aegiscloud.org",SIGNUP_PATH="/key",SIGNUP_SOURCE="cli",HOME_URL=SIGNUP_ORIGIN,CAMPAIGN_RE=/^[a-z0-9][a-z0-9_-]{0,63}$/;function signupUrl(t){const s=new URL(SIGNUP_ORIGIN+SIGNUP_PATH);s.searchParams.set("s",SIGNUP_SOURCE);const r=null==t?"":String(t).trim().toLowerCase();return CAMPAIGN_RE.test(r)&&s.searchParams.set("c",r),s.toString()}function link(t,s){const r=new URL(SIGNUP_ORIGIN+(String(t).startsWith("/")?t:`/${t}`));r.searchParams.set("utm_source",SIGNUP_SOURCE),r.searchParams.set("utm_medium","app");const n=null==s?"":String(s).trim().toLowerCase();return CAMPAIGN_RE.test(n)&&r.searchParams.set("utm_campaign",n),r.toString()}function signupDisplayUrl(t){return signupUrl(t).replace(/^https?:\/\//,"")}const GO_PATH="/go/";function goUrl(t,s){const r=String(null==t?"":t).trim().toLowerCase().replace(/^\/+|\/+$/g,""),n=new URL(SIGNUP_ORIGIN+"/go/"+r);n.searchParams.set("s",SIGNUP_SOURCE);const e=null==s?"":String(s).trim().toLowerCase();return CAMPAIGN_RE.test(e)&&n.searchParams.set("c",e),n.toString()}module.exports={signupUrl:signupUrl,signupDisplayUrl:signupDisplayUrl,goUrl:goUrl,link:link,HOME_URL:HOME_URL,SIGNUP_SOURCE:SIGNUP_SOURCE,SIGNUP_PATH:SIGNUP_PATH,SIGNUP_ORIGIN:SIGNUP_ORIGIN,CAMPAIGN_RE:CAMPAIGN_RE};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{estimateTokens:estimateTokens}=require("./tokens.js"),MAX_INPUT_CHARS=12e4,MAX_REPLY_CHARS=2e3;function extractiveSummary(e){const n=e.filter((e=>"user"===e.role)).map((e=>e.text||"")),t=[...e].reverse().find((e=>"assistant"===e.role)),r=n.slice(0,3).map((e=>`“${e.length>48?e.slice(0,45)+"…":e}”`)),i=[];if(n.length&&i.push(`Covered ${n.length} prompt${n.length>1?"s":""}: ${r.join("; ")}.`),t){const e=(t.text||"").split(/\s+/).slice(0,30).join(" ");i.push(`Last reply began: ${e.length>100?e.slice(0,97)+"…":e}`)}return i.length?i.join(" "):"Session with no exchanges yet."}function demoSummary(e){return`[demo summary] ${extractiveSummary(e)}`}async function summarizeTranscript(e,{callModel:n,model:t,signal:r}={}){return e&&e.length?"function"!=typeof n?demoSummary(e):callBackend("summarize",e,t,r,n,(()=>demoSummary(e))):"Session with no exchanges yet."}async function recapLine(e,{callModel:n,model:t,signal:r}={}){return e&&e.length?"function"!=typeof n?`[demo recap] ${extractiveSummary(e)}`:callBackend("recap",e,t,r,n,(()=>`[demo recap] ${extractiveSummary(e)}`)):"No exchanges yet."}async function callBackend(e,n,t,r,i,s){const a=transcriptToText(n).slice(0,MAX_INPUT_CHARS),o="recap"===e?"Recap the following conversation in one sentence. Be factual and specific.":"Summarize the following conversation. Preserve every requirement, decision, and open question, in 2-4 sentences.\n\n"+a;try{if(r&&r.aborted)return null;const e=await i(o,{model:t,signal:r});return r&&r.aborted?null:"string"==typeof e&&e.trim()?e.trim().slice(0,MAX_REPLY_CHARS):s()}catch{return s()}}function transcriptToText(e){return e.filter((e=>"user"===e.role||"assistant"===e.role||"note"===e.role)).map((e=>`${e.role}: ${e.text||""}`)).join("\n\n")}module.exports={summarizeTranscript:summarizeTranscript,recapLine:recapLine,estimateTokens:estimateTokens};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{spawnSync:spawnSync}=require("node:child_process"),SEVERITIES=["critical","high","medium","low"];function severityRank(e){const t=SEVERITIES.indexOf(e);return-1===t?SEVERITIES.length:t}const CHECKS=[{id:"restore-protection",title:"Restore protection",severity:"critical",why:"Without a restore point there is no way back from a bad driver or update.",remedy:"Enable System Protection on C: and create a restore point — SystemPropertiesProtection.exe"},{id:"vss-snapshot",title:"VSS snapshot",severity:"critical",why:"Event 8193 inside DoSnapshotSet means the snapshot never completes, which is why no restore point exists.",remedy:"vssadmin list writers → net stop vss && net stop swprv → net start swprv && net start vss"},{id:"os-support",title:"OS support window",severity:"high",why:"A build past its support end gets no security fixes; consumer ESU has its own closing date.",remedy:"Verify ESU status in Windows Update, then plan Windows 11 (or a supported Linux) — Settings → Update & Security"},{id:"unexpected-shutdown",title:"Unexpected shutdowns",severity:"high",why:"Kernel-Power 41 with no bugcheck is a power loss or a hard lock, and an empty dump directory means the cause cannot be read after the fact.",remedy:"powercfg /h off (kills fast startup) → check PSU and cabling → update BIOS"},{id:"defender-full-scan",title:"Defender full scan",severity:"high",why:"Real-time protection on with a full scan that has never run leaves an unscanned surface.",remedy:"Start-MpScan -ScanType FullScan"},{id:"system-disk",title:"System disk",severity:"medium",why:"A mechanical system disk is the single largest cost on everything the machine does, updates included.",remedy:"Plan an SSD (no action required today)"},{id:"pending-reboot",title:"Pending reboot",severity:"low",why:"Files deferred for deletion at next boot, and a long uptime, also deny VSS a clean start.",remedy:"Restart at the next opportunity"},{id:"perf-counters",title:"Performance counters",severity:"low",why:"LoadPerf events naming WmiApRpl are cosmetic but they fill the event log.",remedy:"lodctr /R (run twice in a row if the first pass does not clear it)"},{id:"python-runtime",title:"Python runtime",severity:"low",why:"`python` resolving to WindowsApps is the Microsoft Store stub: it runs nothing and exits into the Store.",remedy:"winget install Python.Python.3.12 — or turn the app-execution aliases off in Settings → Apps"}],CHECK_BY_ID=new Map(CHECKS.map((e=>[e.id,e])));function has(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)&&null!==e[t]&&void 0!==e[t]}function num(e){return"number"==typeof e&&Number.isFinite(e)?e:"string"==typeof e&&""!==e.trim()&&Number.isFinite(Number(e))?Number(e):null}function gb(e){const t=num(e);return null===t?null:`${(t/1024**3).toFixed(1)} GB`}function days(e){const t=num(e);return null===t?null:`${(t/86400).toFixed(1)} days`}function fullScanPhrase(e){const t=num(e);return null===t?null:4294967295===t||t>=4294967295?"never (FullScanAge is 0xFFFFFFFF)":`${t} days ago`}const WIN10_22H2_END="2025-10-14",CONSUMER_ESU_END="2026-10-13";function assess(e){const t=[],n=[],s=[],o=(e,n,s)=>{const o=CHECK_BY_ID.get(e);t.push({...o,detail:n,evidence:s||{},remedyText:o.remedy})},i=(e,t)=>n.push({...CHECK_BY_ID.get(e),detail:t}),r=(e,t)=>s.push({...CHECK_BY_ID.get(e),reason:t}),a=e&&"object"==typeof e?e:{};if(has(a,"shadowCopies")){const e=num(a.shadowCopies),t=num(a.restorePoints);0===e||0===t?o("restore-protection",`no shadow copies (${e??"?"}) and ${t??"unknown"} restore point(s)`,{shadowCopies:e,restorePoints:t}):i("restore-protection",`${e} shadow copy(ies), ${t??"unknown"} restore point(s)`)}else r("restore-protection","Win32_ShadowCopy returned nothing readable");if(has(a,"vss8193")){const e=num(a.vss8193);e>0?o("vss-snapshot",`${e} × event 8193 (Volume Shadow Copy failure)${a.vss8193Hr?` hr=${a.vss8193Hr}`:""}${a.vss8193Last?` last ${a.vss8193Last}`:""}`,{events:e,hr:a.vss8193Hr||null,last:a.vss8193Last||null}):i("vss-snapshot","no event 8193 in the window read")}else r("vss-snapshot","the Volume Shadow Copy event log was not read");if(has(a,"windowsCaption")||has(a,"windowsBuild")){const e=a.windowsCaption?String(a.windowsCaption):"Windows",t=a.windowsBuild?` build ${a.windowsBuild}`:"";if(/Windows 10/i.test(e)||String(a.windowsBuild||"").startsWith("1904")){const n=has(a,"esuKeyPresent")?!!a.esuKeyPresent:null,s=has(a,"consumerEsuStatus")?num(a.consumerEsuStatus):null,i=[];i.push("mainstream support ended 2025-10-14"),i.push("consumer ESU ends at the latest 2026-10-13"),i.push(null===n?"ESU key presence not read":n?"ESU key present":"no ESU key in the registry"),null!==s&&i.push(`win10ConsumerESUStatus=${s}`),o("os-support",`${e}${t} — ${i.join("; ")}`,{caption:e,build:a.windowsBuild||null,esuKeyPresent:n,consumerEsuStatus:s})}else i("os-support",`${e}${t}`)}else r("os-support","the OS version was not read");if(has(a,"kernelPower41")||has(a,"event6008")){const e=num(a.kernelPower41)||0,t=num(a.event6008)||0,n=void 0===a.crashDumpEnabled?null:num(a.crashDumpEnabled),s=has(a,"dumpFileExists")?!!a.dumpFileExists:null,r=has(a,"minidumpDirExists")?!!a.minidumpDirExists:null;if(e>0){const i=[`${e} × Kernel-Power 41`,`${t} × unexpected-shutdown 6008`];null!==n&&i.push(`CrashDumpEnabled=${n}`),null!==s&&i.push("MEMORY.DMP "+(s?"present":"missing")),null!==r&&i.push("Minidump "+(r?"present":"missing"));const l=days(a.uptimeSeconds);l&&i.push(`uptime ${l}`),o("unexpected-shutdown",i.join(", "),{kernelPower41:e,event6008:t,crashDumpEnabled:n,dumpFileExists:s,minidumpDirExists:r,uptimeSeconds:num(a.uptimeSeconds)})}else i("unexpected-shutdown",`no Kernel-Power 41 in the window read (${t} × 6008)`)}else r("unexpected-shutdown","the System log was not read");if(has(a,"defenderFullScanAge")||!1===a.defenderAvailable)if(!1===a.defenderAvailable)r("defender-full-scan","Get-MpComputerStatus is unavailable on this host");else if(has(a,"defenderFullScanAge")){const e=fullScanPhrase(a.defenderFullScanAge),t=a.quickScanEnd?`quick scan ${a.quickScanEnd}`:"no quick-scan timestamp",n=void 0===a.defenderRealtime?null:!!a.defenderRealtime;null===e||e.startsWith("never")?o("defender-full-scan",`full scan ${e||"unreadable"}, ${t}`+(null===n?"":", real-time "+(n?"on":"OFF")),{fullScanAge:num(a.defenderFullScanAge),quickScanEnd:a.quickScanEnd||null,realtime:n}):i("defender-full-scan",`full scan ${e}, ${t}`)}else r("defender-full-scan","Defender answered but FullScanAge was not in the reply");else r("defender-full-scan","Defender status was not read");if(has(a,"diskMediaType")||has(a,"freeBytes")){const e=a.diskMediaType&&String(a.diskMediaType)||"unknown media",t=a.diskModel?String(a.diskModel):"",n=gb(a.freeBytes),s=null!==num(a.freeBytes)&&num(a.sizeBytes)?Math.round(num(a.freeBytes)/num(a.sizeBytes)*100):null,r=/fixed hard disk|hdd/i.test(e)&&!/ssd|solid/i.test(e),l=[t,e,n?`${n} free${null===s?"":` (${s}%)`}`:null].filter(Boolean).join(", ");r?o("system-disk",`${l} — mechanical, so this is a performance ceiling, not a failure`,{media:e,model:t,freeBytes:num(a.freeBytes)}):i("system-disk",l||e)}else r("system-disk","the disk description was not read");if(has(a,"pendingRenameCount")){const e=num(a.pendingRenameCount)||0,t=days(a.uptimeSeconds);e>0?o("pending-reboot",`${e} deferred file operation(s) waiting for a restart${t?`, uptime ${t}`:""}`,{pendingRenameCount:e,uptimeSeconds:num(a.uptimeSeconds)}):i("pending-reboot","nothing pending"+(t?`, uptime ${t}`:""))}else r("pending-reboot","PendingFileRenameOperations was not read");if(has(a,"loadPerfEvents")){const e=num(a.loadPerfEvents)||0,t=void 0===a.loadPerfWmiApRpl?null:!!a.loadPerfWmiApRpl;e>0?o("perf-counters",`${e} LoadPerf 1000/1001 event(s)${null===t?"":t?" naming WmiApRpl":""}`,{events:e,wmiApRpl:t}):i("perf-counters","no LoadPerf counter errors in the window read")}else r("perf-counters","the LoadPerf log was not read");if(has(a,"pythonPath")||has(a,"pyPresent")){const e=a.pythonPath?String(a.pythonPath):"",t=/WindowsApps/i.test(e)||has(a,"pythonStoreStub")&&!!a.pythonStoreStub,n=has(a,"pyPresent")?!!a.pyPresent:null;t||!1===n?o("python-runtime",[e?`python → ${e}${t?" (Microsoft Store stub)":""}`:"python not on PATH",null===n?null:"py "+(n?"present":"missing")].filter(Boolean).join(", "),{pythonPath:e||null,storeStub:t,pyPresent:n}):i("python-runtime",`${e||"python resolved"}${n?", py present":""}`)}else r("python-runtime","the Python resolution was not read");return t.sort(((e,t)=>severityRank(e.severity)-severityRank(t.severity)||CHECKS.findIndex((t=>t.id===e.id))-CHECKS.findIndex((e=>e.id===t.id)))),{findings:t,clean:n,unassessed:s,summary:{assessed:t.length+n.length,total:CHECKS.length,findings:t.length,unassessed:s.length,worst:t.length?t[0].severity:null}}}function probeScript(){return['$ErrorActionPreference = "SilentlyContinue"',"$out = [ordered]@{}","$sc = @(Get-CimInstance Win32_ShadowCopy)","$out.shadowCopies = $sc.Count","$rp = @(Get-CimInstance -ClassName Win32_ShadowCopy -Namespace root\\default)","$out.restorePoints = (Get-ComputerRestorePoint | Measure-Object).Count","$since = (Get-Date).AddDays(-30)",'$vss = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="VSS"; Id=8193; StartTime=$since})',"$out.vss8193 = $vss.Count","if ($vss.Count -gt 0) {"," $m = $vss[0].Message",' if ($m -match "0x[0-9a-fA-F]{8}") { $out.vss8193Hr = $Matches[0] }',' $out.vss8193Last = $vss[0].TimeCreated.ToString("yyyy-MM-dd HH:mm:ss")',"}","$os = Get-CimInstance Win32_OperatingSystem","$out.windowsCaption = $os.Caption","$out.windowsBuild = $os.BuildNumber","$out.windowsVersion = $os.Version","$out.uptimeSeconds = [int]((Get-Date) - $os.LastBootUpTime).TotalSeconds",'if ($os.LastBootUpTime) { $out.lastBoot = $os.LastBootUpTime.ToString("yyyy-MM-dd HH:mm:ss") }','$out.esuKeyPresent = Test-Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU"','$esu = Get-ItemProperty "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ESU" -Name win10ConsumerESUStatus -ErrorAction SilentlyContinue',"if ($null -ne $esu) { $out.consumerEsuStatus = $esu.win10ConsumerESUStatus }",'$kp = @(Get-WinEvent -FilterHashtable @{LogName="System"; ProviderName="Microsoft-Windows-Kernel-Power"; Id=41; StartTime=(Get-Date).AddDays(-14)})',"$out.kernelPower41 = $kp.Count",'$out.event6008 = @(Get-WinEvent -FilterHashtable @{LogName="System"; Id=6008; StartTime=(Get-Date).AddDays(-14)}).Count','$cc = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\CrashControl" -ErrorAction SilentlyContinue',"if ($cc) { $out.crashDumpEnabled = $cc.CrashDumpEnabled; $out.dumpFilePath = $cc.DumpFile }",'$out.dumpFileExists = Test-Path "C:\\Windows\\MEMORY.DMP"','$out.minidumpDirExists = Test-Path "C:\\Windows\\Minidump"','$pwr = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" -Name HiberbootEnabled -ErrorAction SilentlyContinue',"if ($null -ne $pwr) { $out.hiberbootEnabled = $pwr.HiberbootEnabled }","$mp = Get-MpComputerStatus -ErrorAction SilentlyContinue","if ($null -ne $mp) {"," $out.defenderAvailable = $true"," $out.defenderFullScanAge = $mp.FullScanAge"," $out.defenderRealtime = $mp.RealTimeProtectionEnabled",' if ($mp.QuickScanEndTime) { $out.quickScanEnd = $mp.QuickScanEndTime.ToString("yyyy-MM-dd HH:mm") }',' if ($mp.FullScanEndTime) { $out.fullScanEnd = $mp.FullScanEndTime.ToString("yyyy-MM-dd HH:mm") }',"} else { $out.defenderAvailable = $false }","$d = Get-CimInstance Win32_DiskDrive | Where-Object { $_.Index -eq 0 } | Select-Object -First 1","if ($d) { $out.diskModel = $d.Model; $out.diskMediaType = $d.MediaType; $out.sizeBytes = [int64]$d.Size; $out.diskHealth = $d.Status }","$c = Get-CimInstance Win32_LogicalDisk -Filter \"DeviceID='C:'\"","if ($c) { $out.freeBytes = [int64]$c.FreeSpace; $out.sizeBytes = [int64]$c.Size }",'$sm = Get-ItemProperty "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager" -Name PendingFileRenameOperations -ErrorAction SilentlyContinue',"if ($null -ne $sm) { $out.pendingRenameCount = @($sm.PendingFileRenameOperations).Count }",'$lp = @(Get-WinEvent -FilterHashtable @{LogName="Application"; ProviderName="Microsoft-Windows-LoadPerf"; StartTime=(Get-Date).AddDays(-14)})',"$out.loadPerfEvents = $lp.Count",'if ($lp.Count -gt 0) { $out.loadPerfWmiApRpl = [bool]($lp | Where-Object { $_.Message -match "WmiApRpl" } | Select-Object -First 1) }',"$py = Get-Command python -ErrorAction SilentlyContinue",'if ($py) { $out.pythonPath = $py.Source; $out.pythonStoreStub = [bool]($py.Source -match "WindowsApps") } else { $out.pythonPath = "" }',"$out.pyPresent = [bool](Get-Command py -ErrorAction SilentlyContinue)",'$out.pythonCore = [bool](Test-Path "HKLM:\\SOFTWARE\\Python\\PythonCore")',"$out | ConvertTo-Json -Depth 4 -Compress"].join("\n")}function collect(e){const t=e||{},n=t.platform||process.platform;if("win32"!==n)return{ok:!1,reason:"not-windows",platform:n};const s=t.spawnSync||spawnSync,o=t.powershell||"powershell.exe",i=t.timeoutMs||6e4;let r;try{r=s(o,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",probeScript()],{timeout:i,maxBuffer:8388608,windowsHide:!0,encoding:"utf8"})}catch(e){return{ok:!1,reason:`probe failed to start: ${e&&e.message?e.message:e}`}}if(!r||r.error)return{ok:!1,reason:`probe failed to start: ${r&&r.error&&r.error.message||"unknown"}`};if(0!==r.status){const e=String(r.stderr||"").trim().split("\n")[0];return{ok:!1,reason:`probe exited ${r.status}${e?`: ${e}`:""}`}}const a=String(r.stdout||"").trim();if(!a)return{ok:!1,reason:"probe returned nothing"};try{return{ok:!0,data:JSON.parse(a.split("\n").filter(Boolean).pop())}}catch{return{ok:!1,reason:"probe output was not JSON"}}}function remedyScript(){return["# Run in an ELEVATED PowerShell (Run as Administrator).","# Order matters: VSS has to survive DoSnapshotSet before a restore point can exist.","","# 2. VSS — see which writer is not Stable, then restart the two services.","vssadmin list writers","vssadmin list providers","net stop vss","net stop swprv","net start swprv","net start vss","","# System files, if 8193 survives the restart.","sfc /scannow","DISM /Online /Cleanup-Image /RestoreHealth","","# 1. Restore protection — only meaningful once VSS completes.",'Enable-ComputerRestore -Drive "C:\\"','Checkpoint-Computer -Description "AEGIS baseline" -RestorePointType MODIFY_SETTINGS',"Get-ComputerRestorePoint","","# 4. No more mystery shutdowns: fast startup off, so a shutdown is a shutdown.","powercfg /h off # removes hiberfil.sys, fast startup and the hard-lock blur","# then: check PSU and cabling, and look for a newer BIOS.","","# 5. Defender — a full scan has never run on this machine.","Start-MpScan -ScanType FullScan","","# 8. Performance counters.","lodctr /R","lodctr /R # run twice in a row if the first pass does not clear it","","# 9. Python, if you want one:","winget install Python.Python.3.12","","# 3. This one cannot be scripted — verify it by hand:","# Settings -> Update & Security -> Windows Update (ESU status)","# Windows 10 22H2 mainstream support ended 2025-10-14;","# consumer ESU ends at the latest 2026-10-13.","","# 7. Then restart: it clears the deferred files AND gives VSS a clean start."].join("\n")}module.exports={CHECKS:CHECKS,SEVERITIES:SEVERITIES,assess:assess,collect:collect,probeScript:probeScript,remedyScript:remedyScript,fullScanPhrase:fullScanPhrase,severityRank:severityRank};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{spawn:spawn}=require("node:child_process");function openUrl(o){try{const s=process.platform,t="darwin"===s?["open"]:"win32"===s?["cmd","/c","start",""]:["xdg-open"];return spawn(t[0],[...t.slice(1),o],{stdio:"ignore",detached:!0}).unref(),!0}catch{return!1}}const URLS={troubleshooting:"https://aegiscloud.org",feedback:"https://aegiscloud.org",issues:"https://aegiscloud.org",docs:"https://aegiscloud.org",radio:"https://www.youtube.com/watch?v=cP8jB6YQWbQ"};module.exports={openUrl:openUrl,URLS:URLS};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const{caps:caps,detect:detect,onCapsChange:onCapsChange,rgb:rgb,bg:bg}=require("./caps.js"),{STAR:STAR,stencilGlyph:stencilGlyph}=require("./art.js"),RESET="",BOLD="",DIM="",ITALIC="",UNDER="",BOLD_OFF="",ITALIC_OFF="",UNDER_OFF="",RESET_FG="",RESET_BG="",RGB=(e,t,n)=>rgb(e,t,n),BG=(e,t,n)=>bg(e,t,n),C={},LIGHT={},CB_DARK={},CB_LIGHT={},ANSI_DARK={},ANSI_LIGHT={};function buildDark(){return{gold:RGB(255,193,7),coral:RGB(215,119,87),lavender:RGB(177,185,249),blue:RGB(120,160,250),green:RGB(78,186,101),red:RGB(220,90,90),gray:RGB(153,153,153),dim:RGB(80,80,80),white:RGB(255,255,255),black:RGB(30,30,30),darkBg:RGB(20,20,20)}}function buildLight(){return{gold:RGB(180,130,0),coral:RGB(190,100,70),lavender:RGB(120,130,220),blue:RGB(70,110,220),green:RGB(60,150,80),red:RGB(200,60,60),gray:RGB(110,110,110),dim:RGB(170,170,170),white:RGB(40,40,40),black:RGB(245,245,245),darkBg:RGB(255,255,255)}}function buildCbDark(){return{...buildDark(),green:RGB(86,182,194),red:RGB(255,146,43),gold:RGB(255,203,71)}}function buildCbLight(){return{...buildLight(),green:RGB(30,130,145),red:RGB(200,100,20),gold:RGB(150,110,0)}}const A=e=>caps().color?`[${e}m`:"";function buildAnsiDark(){return{gold:A(93),coral:A(91),lavender:A(94),blue:A(94),green:A(92),red:A(91),gray:A(90),dim:A(90),white:A(97),black:A(40),darkBg:caps().color?"":""}}function buildAnsiLight(){return{gold:A(33),coral:A(31),lavender:A(34),blue:A(34),green:A(32),red:A(31),gray:A(90),dim:A(37),white:A(30),black:A(47),darkBg:caps().color?"":""}}const DIFF={},DIFF_LIGHT={};function buildDiff(){return{delFg:RGB(220,90,90),delBg:BG(61,1,0),delHiFg:RGB(248,248,242),delHiBg:BG(92,2,0),addFg:RGB(80,200,80),addBg:BG(2,40,0),addHiFg:RGB(255,255,255),addHiBg:BG(4,71,0),codeFg:RGB(248,248,242),gutter:RGB(120,120,120),kw:RGB(102,217,239),fn:RGB(166,226,46),str:RGB(230,219,116),num:RGB(174,129,255),comment:RGB(117,113,94)}}function buildDiffLight(){return{delFg:RGB(160,40,40),delBg:BG(255,235,233),delHiFg:RGB(90,0,0),delHiBg:BG(255,205,200),addFg:RGB(30,130,40),addBg:BG(232,250,232),addHiFg:RGB(0,80,0),addHiBg:BG(195,240,195),codeFg:RGB(40,40,40),gutter:RGB(150,150,150),kw:RGB(0,120,160),fn:RGB(80,140,0),str:RGB(150,110,0),num:RGB(120,60,200),comment:RGB(140,140,130)}}const THEMES={dark:C,light:LIGHT},THEME_TABLE=[{name:"Auto",note:"(match terminal)",light:!1,palette:C},{name:"Dark mode",note:"",light:!1,palette:C},{name:"Light mode",note:"",light:!0,palette:LIGHT},{name:"Dark mode",note:"(colorblind-friendly)",light:!1,palette:CB_DARK},{name:"Light mode",note:"(colorblind-friendly)",light:!0,palette:CB_LIGHT},{name:"Dark mode",note:"(ANSI colors only)",light:!1,palette:ANSI_DARK},{name:"Light mode",note:"(ANSI colors only)",light:!0,palette:ANSI_LIGHT}],AUTO_THEME_INDEX=0;function terminalIsLight(e=caps()){return"light"===e.background}function themeIsLight(e,t=caps()){const n=THEME_TABLE[e];return!!n&&(e===AUTO_THEME_INDEX?terminalIsLight(t):!!n.light)}const SIBLING_THEME_INDEX=[0,2,1,4,3,6,5];function themeContradicts(e,t=caps()){const n=THEME_TABLE[e];return!(!n||e===AUTO_THEME_INDEX||!t||!t.backgroundKnown||!!n.light==("light"===t.background))}function reconcileThemeIndex(e,t=caps()){const n=THEME_TABLE[e];if(!themeContradicts(e,t))return{index:e,changed:!1,reason:"",from:n||null};const i=SIBLING_THEME_INDEX[e],r=THEME_TABLE[i],l=e=>`${e.name}${e.note?" "+e.note:""}`;return{index:i,changed:!0,from:n,reason:`saved theme "${l(n)}" is unreadable on this ${t.background} terminal (${t.reasons.background}) — using "${l(r)}" instead`}}function themeForIndex(e){const t=THEME_TABLE[e];return t?t.palette:C}function themeOf(e){return e&&"number"==typeof e.themeIndex&&e.themeIndex>=3&&e.themeIndex<=6?themeForIndex(e.themeIndex):e&&e.themeIndex===AUTO_THEME_INDEX?terminalIsLight()?LIGHT:C:e&&e.light?LIGHT:C}function diffOf(e){return(e&&"number"==typeof e.themeIndex&&e.themeIndex>=3&&e.themeIndex<=6?THEME_TABLE[e.themeIndex].light:e&&e.themeIndex===AUTO_THEME_INDEX?terminalIsLight():e&&e.light)?DIFF_LIGHT:DIFF}function glyphsFor(e=null){const t=e?"string"==typeof e?detect(process.env,process.stdout,e):e:caps(),n="ascii"===t.glyphs,i=n||"edges"===t.face;if(n)return{cursor:">",check:"+",divider:"-",bullet:".",hint:">",pause:"||",star:stencilGlyph(STAR,t),rightarrow:"->",pointer:">",hook:"_|",block:"*",bloom:"*",spin:["|","/","-","\\","*","-"],ellipse:"...",err:"x",warn:"!",rule:"-",ruleHeavy:"="};const r={cursor:"❯",check:"✔",divider:"╌",bullet:"·",hint:"❯",pause:i?"❚❚":"⏸",star:stencilGlyph(STAR,t),rightarrow:"→",pointer:"▸",hook:i?"_|":"⎿",block:"●",bloom:"✻",spin:["✢","·","✻","*","✽","✶"],ellipse:"…",err:"✗",warn:"⚠",rule:"─",ruleHeavy:"━"};return i?{...r,bloom:"*",spin:["|","/","-","\\","*","-"]}:r}const GLYPH=glyphsFor(),VERBS=["Incubating","Tempering","Determining","Beboppin'","Julienning","Inferring","Simmering","Twisting","Fermenting","Fiddle-faddling","Orbiting","Prestidigitating"],DONE_VERBS=["Churned","Worked"];function rematerialize(){Object.assign(C,buildDark()),Object.assign(LIGHT,buildLight()),Object.assign(CB_DARK,buildCbDark()),Object.assign(CB_LIGHT,buildCbLight()),Object.assign(ANSI_DARK,buildAnsiDark()),Object.assign(ANSI_LIGHT,buildAnsiLight()),Object.assign(DIFF,buildDiff()),Object.assign(DIFF_LIGHT,buildDiffLight()),Object.assign(GLYPH,glyphsFor())}rematerialize(),onCapsChange(rematerialize),module.exports={RGB:RGB,BG:BG,RESET:RESET,BOLD:BOLD,DIM:DIM,ITALIC:"",UNDER:UNDER,BOLD_OFF:"",ITALIC_OFF:"",UNDER_OFF:"",RESET_FG:"",RESET_BG:"",C:C,LIGHT:LIGHT,DIFF:DIFF,DIFF_LIGHT:DIFF_LIGHT,diffOf:diffOf,CB_DARK:CB_DARK,CB_LIGHT:CB_LIGHT,ANSI_DARK:ANSI_DARK,ANSI_LIGHT:ANSI_LIGHT,THEMES:THEMES,THEME_TABLE:THEME_TABLE,AUTO_THEME_INDEX:AUTO_THEME_INDEX,themeIsLight:themeIsLight,terminalIsLight:terminalIsLight,themeForIndex:themeForIndex,themeContradicts:themeContradicts,reconcileThemeIndex:reconcileThemeIndex,SIBLING_THEME_INDEX:SIBLING_THEME_INDEX,GLYPH:GLYPH,glyphsFor:glyphsFor,VERBS:VERBS,DONE_VERBS:DONE_VERBS,themeOf:themeOf,rematerialize:rematerialize};
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
+ "use strict";const DEFAULT_TITLE="AEGIS Code",TITLE_SPIN=["⠐","⠂","⠄","⠆","⠈","⠠","⠰","⠁"],TOPIC_MAX=48,TITLE_MAX=96,FILLER=/^(?:please|pls|plz|hey|hi|hello|ok(?:ay)?|so|now|just|also|and|then|maybe|well|um|uh|can you|could you|would you|will you|i want you to|i want to|i need you to|i need to|i'?d like you to|i would like you to|i'?d like to|help me|help|let'?s|lets|go ahead and|i'?m trying to|i am trying to|i'?m working on|i am working on)\b[\s,:;-]*/i,LEADING_NOISE=/^(?:[>#*•·\-–—]+|\d+[.)])\s*/,STOPWORDS=new Set(["the","and","for","with","that","this","these","those","you","your","yours","can","could","would","should","will","please","pls","hey","now","then","from","into","onto","over","under","about","also","just","like","want","need","make","made","use","using","get","got","let","lets","its","it","are","was","were","been","has","have","had","but","not","all","any","how","what","when","where","which","who","why","there","here","some","one","two","add","new","fix","fixing","help","doing","does","did","me","my","our","we","i","a","an","to","of","in","on","at","is","be","do"]);function sanitize(t,e=TITLE_MAX){const n=String(null==t?"":t).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim();return n.length<=e?n:`${n.slice(0,Math.max(0,e-1)).trimEnd()}…`}function topicFrom(t,{max:e=TOPIC_MAX}={}){if(null==t)return"";const n=String(t).split(/[\r\n]+/);let i="";for(const t of n){const e=sanitize(t,4e3).replace(LEADING_NOISE,"").trim();if(e&&!/^```/.test(e)){i=e;break}}if(!i)return"";let o=i;for(let t=0;t<6;t++){const t=o.replace(FILLER,"");if(t===o)break;o=t.replace(LEADING_NOISE,"").trim()}return o=o.replace(/[.!?]+$/,"").trim(),o||(o=i),/^[a-z]/.test(o)&&(o=o[0].toUpperCase()+o.slice(1)),sanitize(o,e)}function keywords(t){const e=new Set;for(const n of String(t||"").toLowerCase().match(/[\p{L}\p{N}_]+/gu)||[])n.length<3||STOPWORDS.has(n)||e.add(n);return[...e]}function titleShift(t,e,{threshold:n=.34}={}){if(!e)return!1;if(!t)return!0;const i=keywords(t),o=keywords(e);if(!i.length||!o.length)return!0;const r=new Set(i);let l=0;for(const t of o)r.has(t)&&l++;return l/Math.min(i.length,o.length)<n}function adoptTopic(t,e,n){const i=topicFrom(e);return i&&titleShift(t,i,n)?i:t||""}function titleText({topic:t="",frame:e=null,app:n="AEGIS Code"}={}){const i=sanitize(t,TOPIC_MAX);return i?sanitize(e?`${e?`${e} `:""}${i}`:`${i} · ${n}`,TITLE_MAX):sanitize(n,TITLE_MAX)||"AEGIS Code"}function flagOn(t){return!0===t||null!=t&&!1!==t&&/^(?:1|true|yes|on)$/i.test(String(t).trim())}function titleEnabled(t={},e={}){const n=t||{};if(flagOn(n.AEGIS_TERMINAL_TITLE))return!0;if(flagOn(n.AEGIS_DISABLE_TERMINAL_TITLE))return!1;if(flagOn(n.CLAUDE_CODE_DISABLE_TERMINAL_TITLE))return!1;const i=e||{};return!1!==i.terminalTitle&&!1!==i.terminalTitleBar}function writeTitle(t,e){const n=e||process.stdout;if(!n||"function"!=typeof n.write)return!1;try{return n.write(`]0;${sanitize(t,TITLE_MAX)}`),!0}catch{return!1}}module.exports={DEFAULT_TITLE:"AEGIS Code",TITLE_SPIN:TITLE_SPIN,TOPIC_MAX:TOPIC_MAX,TITLE_MAX:TITLE_MAX,sanitize:sanitize,topicFrom:topicFrom,keywords:keywords,titleShift:titleShift,adoptTopic:adoptTopic,titleText:titleText,titleEnabled:titleEnabled,writeTitle:writeTitle};