aegisone 1.0.22 → 1.0.23
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.
- package/LICENSE +661 -0
- package/README.md +1 -1
- package/SOURCE-OFFER.txt +9 -0
- package/bin/aegis.js +1 -322
- package/package.json +4 -2
- package/scripts/bump.mjs +1 -211
- package/scripts/bundle.js +1 -129
- package/scripts/predist.mjs +1 -939
- package/src/child.js +1 -285
- package/src/dispatch.js +1 -269
- package/src/doctor.js +1 -639
- package/src/host.js +1 -111
- package/src/permissions.js +1 -369
- package/src/probes.js +1 -159
- package/src/release.js +1 -409
- package/vendor/cli/bin/aegiscode.js +2 -914
- package/vendor/cli/package.json +3 -2
- package/vendor/cli/scripts/check.mjs +1 -52
- package/vendor/cli/scripts/demo.mjs +1 -94
- package/vendor/cli/scripts/predist.mjs +1 -75
- package/vendor/cli/scripts/runtests.mjs +1 -56
- package/vendor/cli/scripts/seal-gate.mjs +1 -74
- package/vendor/cli/src/agents.js +1 -139
- package/vendor/cli/src/app.js +1 -2932
- package/vendor/cli/src/art.js +1 -289
- package/vendor/cli/src/autonomous.js +1 -515
- package/vendor/cli/src/caps.js +1 -879
- package/vendor/cli/src/chatflow.js +1 -3020
- package/vendor/cli/src/checkpoint.js +1 -90
- package/vendor/cli/src/clipboard.js +1 -424
- package/vendor/cli/src/cloudsync.js +1 -528
- package/vendor/cli/src/commands.js +1 -4003
- package/vendor/cli/src/config.js +1 -581
- package/vendor/cli/src/connect.js +1 -349
- package/vendor/cli/src/credentials.js +1 -33
- package/vendor/cli/src/deps.js +1 -232
- package/vendor/cli/src/devrun.js +1 -187
- package/vendor/cli/src/diff.js +1 -333
- package/vendor/cli/src/diffview.js +1 -296
- package/vendor/cli/src/engine.js +1 -297
- package/vendor/cli/src/entitlement.js +1 -355
- package/vendor/cli/src/events.js +1 -707
- package/vendor/cli/src/export.js +1 -67
- package/vendor/cli/src/fingerprint.js +1 -592
- package/vendor/cli/src/format.js +1 -259
- package/vendor/cli/src/fuzzy.js +1 -119
- package/vendor/cli/src/gate.js +1 -55
- package/vendor/cli/src/history.js +1 -401
- package/vendor/cli/src/init.js +1 -175
- package/vendor/cli/src/input.js +1 -139
- package/vendor/cli/src/keys.js +1 -183
- package/vendor/cli/src/limits.js +1 -190
- package/vendor/cli/src/markdown.js +1 -306
- package/vendor/cli/src/mcp.js +1 -694
- package/vendor/cli/src/models.js +1 -487
- package/vendor/cli/src/naming.js +1 -229
- package/vendor/cli/src/overlays.js +1 -461
- package/vendor/cli/src/panels.js +1 -1418
- package/vendor/cli/src/permissions.js +1 -290
- package/vendor/cli/src/ping.js +1 -226
- package/vendor/cli/src/presence.js +1 -238
- package/vendor/cli/src/provenance.js +2 -182
- package/vendor/cli/src/render.js +1 -515
- package/vendor/cli/src/screen.js +1 -518
- package/vendor/cli/src/screens.js +1 -896
- package/vendor/cli/src/secret.js +1 -59
- package/vendor/cli/src/securefs.js +1 -359
- package/vendor/cli/src/settings.js +1 -155
- package/vendor/cli/src/shared.js +1 -52
- package/vendor/cli/src/sharedpaths.js +1 -53
- package/vendor/cli/src/signup.js +1 -156
- package/vendor/cli/src/summarize.js +1 -95
- package/vendor/cli/src/sysdiag.js +1 -585
- package/vendor/cli/src/system.js +1 -40
- package/vendor/cli/src/theme.js +1 -570
- package/vendor/cli/src/title.js +1 -220
- package/vendor/cli/src/todos.js +1 -115
- package/vendor/cli/src/tokens.js +1 -263
- package/vendor/cli/src/topup.js +1 -210
- package/vendor/cli/src/update.js +1 -181
- package/vendor/cli/vendor/client/aegis.js +1 -2179
- package/vendor/cli/vendor/client/attest.js +1 -442
- package/vendor/cli/vendor/client/authorship-key.js +1 -410
- package/vendor/cli/vendor/client/auto-provision.js +1 -134
- package/vendor/cli/vendor/client/brain-catalog.js +1 -268
- package/vendor/cli/vendor/client/byok-catalog.js +1 -230
- package/vendor/cli/vendor/client/credentials.js +1 -494
- package/vendor/cli/vendor/client/device-fingerprint.js +1 -141
- package/vendor/cli/vendor/client/drive-connect.js +1 -110
- package/vendor/cli/vendor/client/drive-upload.js +1 -174
- package/vendor/cli/vendor/client/env-file.js +1 -1273
- package/vendor/cli/vendor/client/fingerprint.js +1 -1064
- package/vendor/cli/vendor/client/foreign-memory.js +1 -669
- package/vendor/cli/vendor/client/google-signin.js +1 -133
- package/vendor/cli/vendor/client/hooks.js +1 -430
- package/vendor/cli/vendor/client/model-discovery.js +1 -373
- package/vendor/cli/vendor/client/platform.js +1 -937
- package/vendor/cli/vendor/client/prefs.js +1 -351
- package/vendor/cli/vendor/client/presence-constants.js +1 -107
- package/vendor/cli/vendor/client/presence.js +1 -438
- package/vendor/cli/vendor/client/record-vault.js +3 -1055
- package/vendor/cli/vendor/client/session-store.js +1 -548
- package/vendor/cli/vendor/client/topup.js +1 -297
- package/vendor/cli/vendor/client/touch.js +1 -458
- package/vendor/cli/vendor/client/update.js +1 -704
- package/vendor/cli/vendor/client/user-models.js +1 -381
- package/vendor/cli/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/cli/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/cli/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/cli/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/cli/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/cli/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/cli/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/cli/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/cli/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/cli/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/cli/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/cli/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/cli/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/cli/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/cli/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/cli/vendor/desktop/lib/settings.js +1 -890
- package/vendor/cli/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/cli/vendor/hosts/install.js +1 -638
- package/vendor/cli/vendor/hosts/openai-shim.js +1 -515
- package/vendor/cli/vendor/hosts/spec.js +1 -164
- package/vendor/cli/vendor/hosts/targets.js +1 -346
- package/vendor/cli/vendor/mcp/server.js +1 -221
- package/vendor/cli/vendor/mcp/tools.js +1 -408
- package/vendor/cli/vendor/one/src/child.js +1 -285
- package/vendor/cli/vendor/one/src/permissions.js +1 -369
- package/vendor/desktop/bin/aegis.js +1 -32
- package/vendor/desktop/lib/account-key.js +1 -56
- package/vendor/desktop/lib/auto.js +1 -430
- package/vendor/desktop/lib/avatar/companion.js +1 -698
- package/vendor/desktop/lib/avatar/cosmetics.js +1 -532
- package/vendor/desktop/lib/avatar/events.js +1 -344
- package/vendor/desktop/lib/avatar/holder-turn.js +1 -350
- package/vendor/desktop/lib/avatar/holders.js +1 -612
- package/vendor/desktop/lib/avatar/identity.js +1 -641
- package/vendor/desktop/lib/avatar/level.js +1 -368
- package/vendor/desktop/lib/avatar/mirror.js +1 -524
- package/vendor/desktop/lib/avatar/persona.js +1 -388
- package/vendor/desktop/lib/avatar/profile.js +1 -977
- package/vendor/desktop/lib/avatar/register.js +1 -307
- package/vendor/desktop/lib/avatar/store.js +1 -472
- package/vendor/desktop/lib/avatar/tiers.js +1 -38
- package/vendor/desktop/lib/avatar/transfer.js +1 -415
- package/vendor/desktop/lib/avatar/turn.js +1 -216
- package/vendor/desktop/lib/avatar/voice.js +1 -328
- package/vendor/desktop/lib/avatar/xp.js +1 -404
- package/vendor/desktop/lib/deep-link.js +1 -120
- package/vendor/desktop/lib/fingerprint.js +2 -347
- package/vendor/desktop/lib/google-connect.js +1 -227
- package/vendor/desktop/lib/local/agents.js +1 -105
- package/vendor/desktop/lib/local/autonomous.js +1 -1045
- package/vendor/desktop/lib/local/claude-pro.js +1 -993
- package/vendor/desktop/lib/local/context.js +1 -95
- package/vendor/desktop/lib/local/engine.js +1 -3301
- package/vendor/desktop/lib/local/entitlement.js +1 -660
- package/vendor/desktop/lib/local/git-scope.js +1 -228
- package/vendor/desktop/lib/local/local.js +1 -2135
- package/vendor/desktop/lib/local/prompt.js +1 -275
- package/vendor/desktop/lib/local/queue.js +1 -560
- package/vendor/desktop/lib/local/session-rounds.js +1 -208
- package/vendor/desktop/lib/local/shell.js +1 -680
- package/vendor/desktop/lib/local/telemetry.js +1 -470
- package/vendor/desktop/lib/local/tools.js +1 -1238
- package/vendor/desktop/lib/local/turn-guard.js +1 -300
- package/vendor/desktop/lib/local/worktree-lock.js +1 -235
- package/vendor/desktop/lib/provider-key-mirror.js +1 -252
- package/vendor/desktop/lib/quick-launcher.js +1 -84
- package/vendor/desktop/lib/settings.js +1 -890
- package/vendor/desktop/lib/sync/memory-queue.js +1 -60
- package/vendor/desktop/lib/sync/persist-gate.js +1 -148
- package/vendor/desktop/lib/sync/sessions.js +1 -106
- package/vendor/desktop/lib/window-state.js +1 -66
- package/vendor/desktop/main.js +1 -4529
- package/vendor/desktop/package.json +3 -2
- package/vendor/desktop/preload.js +1 -636
- package/vendor/desktop/renderer/app.js +1 -6660
- package/vendor/desktop/renderer/avatar/assemble.js +1 -335
- package/vendor/desktop/renderer/avatar/avatar.js +1 -380
- package/vendor/desktop/renderer/avatar/cards.js +1 -141
- package/vendor/desktop/renderer/avatar/hud.js +1 -206
- package/vendor/desktop/renderer/avatar/machine.js +1 -213
- package/vendor/desktop/renderer/avatar/pane.js +1 -439
- package/vendor/desktop/renderer/avatar/parts.js +1 -437
- package/vendor/desktop/renderer/budget.js +1 -168
- package/vendor/desktop/renderer/companion.js +1 -223
- package/vendor/desktop/renderer/diff.js +1 -359
- package/vendor/desktop/renderer/diffview.js +1 -336
- package/vendor/desktop/renderer/fingerprint.js +3 -736
- package/vendor/desktop/renderer/markdown.js +1 -168
- package/vendor/desktop/renderer/provider-toolbar.js +1 -134
- package/vendor/desktop/renderer/providers.js +1 -259
- package/vendor/desktop/renderer/quick.js +1 -191
- package/vendor/desktop/renderer/stream-policy.js +1 -306
- package/vendor/desktop/renderer/transcript-view.js +1 -323
- package/vendor/desktop/renderer/usage.js +1 -1239
- package/vendor/desktop/vendor/aegis.js +1 -2179
- package/vendor/desktop/vendor/attest.js +1 -442
- package/vendor/desktop/vendor/authorship-key.js +1 -410
- package/vendor/desktop/vendor/auto-provision.js +1 -134
- package/vendor/desktop/vendor/brain-catalog.js +1 -268
- package/vendor/desktop/vendor/byok-catalog.js +1 -230
- package/vendor/desktop/vendor/credentials.js +1 -494
- package/vendor/desktop/vendor/device-fingerprint.js +1 -141
- package/vendor/desktop/vendor/drive-connect.js +1 -110
- package/vendor/desktop/vendor/drive-upload.js +1 -174
- package/vendor/desktop/vendor/env-file.js +1 -1273
- package/vendor/desktop/vendor/fingerprint.js +1 -1064
- package/vendor/desktop/vendor/foreign-memory.js +1 -669
- package/vendor/desktop/vendor/google-signin.js +1 -133
- package/vendor/desktop/vendor/hooks.js +1 -430
- package/vendor/desktop/vendor/model-discovery.js +1 -373
- package/vendor/desktop/vendor/platform.js +1 -937
- package/vendor/desktop/vendor/prefs.js +1 -351
- package/vendor/desktop/vendor/presence-constants.js +1 -107
- package/vendor/desktop/vendor/presence.js +1 -438
- package/vendor/desktop/vendor/record-vault.js +3 -1055
- package/vendor/desktop/vendor/session-store.js +1 -548
- package/vendor/desktop/vendor/topup.js +1 -297
- package/vendor/desktop/vendor/touch.js +1 -458
- package/vendor/desktop/vendor/update.js +1 -704
- 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
|
-
|
|
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};
|