aegisone 1.0.22 → 1.0.24

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