@durableintel/nenya 0.0.0-stage → 1.2.1

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/README.md CHANGED
@@ -1,3 +1,393 @@
1
- # Temporary Holding Version
1
+ # @qwntllabs/nenya
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The install line Nenya's invite mail carries, from the first Nenya release (DQ-DESK-10 (b), GO-4;
4
+ RULINGS.md release decisions):
5
+
6
+ ```sh
7
+ npx -y @qwntllabs/nenya@latest setup --invite CODE
8
+ ```
9
+
10
+ On Windows the line starts with `npx.cmd` (#1543): PowerShell runs a bare `npx` as Node's `npx.ps1`,
11
+ which its default execution policy (Restricted) refuses.
12
+
13
+ ```powershell
14
+ npx.cmd -y @qwntllabs/nenya@latest setup --invite CODE
15
+ ```
16
+
17
+ `nenya setup` installs Nenya for this account, with no administrator prompt, and opens it with the
18
+ invite code filled in. `nenya repair` installs it again over the copy that is there. The package is
19
+ one Node.js script with no dependencies, for Node.js 20 or newer: `bin/nenya.js` builds the real
20
+ runners (network, `ditto`, `open`, `Setup.exe`) and hands them to `lib/cli.mjs`; the tests hand in
21
+ stand-ins instead, so they never touch the network or a home directory. npm runs `bin/nenya.cjs`
22
+ first, a CommonJS file any Node.js parses: on a Node.js older than 20 it prints
23
+ `Nenya needs Node.js 20 or newer (this computer has <version>). nodejs.org has it, and the same line works once it's installed.`
24
+ and exits 1, with no stack trace; otherwise it loads `bin/nenya.js` (through `bin/start.cjs`).
25
+
26
+ | OS | What `setup` does |
27
+ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
28
+ | macOS | Reads the channel's `RELEASES.json` for Apple silicon, downloads `Nenya-darwin-arm64-<v>.zip`, verifies it (below), unpacks it with the system's `ditto -x -k` (what Squirrel.Mac uses: links, modes and the code signature survive) into a staging folder beside `~/Applications`, swaps it into `~/Applications/Nenya.app`, then `open -n` with `--args --invite CODE`. |
29
+ | Windows | Reads the channel's `RELEASES`, downloads `Nenya-<v>-Setup.exe` (the Squirrel installer; `collect.mjs` turns the space in Forge's name into `-`), verifies it, runs it with `--silent` (a per-user install under `%LOCALAPPDATA%\<squirrel id>`, which starts the app itself), then starts the installed app once more with `--invite CODE`. |
30
+ | Linux | Installs nothing: Linux is "one admin install" (operator O2). Prints the repository set-up from `scripts/release/linux-repos/INSTALL.md` as single lines and `sudo apt-get install nenya-app` or `sudo dnf install nenya-app`, chosen from `/etc/os-release` (both when the family is unknown); on Arch and `ID_LIKE=arch`, the AUR package `nenya-app-bin` (`git clone https://aur.archlinux.org/nenya-app-bin.git && cd nenya-app-bin && makepkg -si`, #6321), then the invite code to enter when signing up. With another feed (below) the lines name that feed, after a first line `Packages come from <base>.` |
31
+
32
+ The invite reaches the app the way the old installer handed it over: as the launch arguments
33
+ `--invite CODE` (the old app's `deepLinks.ts` reads them on first launch and from a second
34
+ instance, and keeps the code in prefs across a relaunch). No pending-invite file is written. If
35
+ the app cannot be opened or found, the line `Your invite code is CODE: Nenya asks for it when
36
+ you sign up.` is printed instead. `repair` on macOS and Windows runs the same install over
37
+ the existing copy; on Linux it prints `sudo apt-get install --reinstall nenya-app` or
38
+ `sudo dnf reinstall nenya-app`.
39
+
40
+ Everything the person sees is plain language: one outcome line, then what to do next; nothing is
41
+ logged. A download that does not verify is refused with the one line
42
+ `The download of Nenya <v> doesn't match its signature, so it wasn't installed.` and nothing of it
43
+ stays on disk. Exit status: 0 done, 1 refused or failed, 2 usage. Node.js built-ins only, all in
44
+ Node.js 20 (`fetch`, `node:crypto`, `node:stream`, `fs.openAsBlob`); nothing is pinned from npm.
45
+
46
+ Every read is bounded. A manifest or signature bundle may be at most 4 MiB. The macOS ZIP is bounded
47
+ by the `updateTo.size` its `RELEASES.json` declares; the Windows installer by `Content-Length` when
48
+ the server sends one; both by a fixed ceiling of 512 MiB. A stream that runs past its bound is cut
49
+ off, the partial file removed, and the person told in one line
50
+ (`The download of Nenya <v> is larger than expected, so it wasn't installed.`).
51
+
52
+ On macOS the ZIP is unpacked into a staging folder `~/Applications/.nenya-install-*`, beside the
53
+ target on the same volume, so the swap is two renames: the previous `Nenya.app` moves into the
54
+ stage, the new one moves into place. If the second rename fails the previous copy is moved back
55
+ before the stage is removed. The unpacked bundle is accepted only when `Contents/Info.plist`
56
+ names a `CFBundleExecutable` that exists under `Contents/MacOS/`.
57
+
58
+ ## Windows: administrator terminals, another copy, PowerShell
59
+
60
+ `lib/windows.mjs` keeps the rules the app can't keep itself, because they act before the app exists
61
+ (ported from the a21 installer; the app's own start checks are `apps/desktop/src/main/core/elevation.ts`):
62
+
63
+ - An elevated run (an administrator terminal: `whoami /groups` shows a High or System mandatory
64
+ label) whose desktop is signed in as another account, or whose desktop owner can't be read
65
+ (`tasklist /v`), stops before anything is fetched or written, with the one line
66
+ `Nothing was installed: this terminal runs as an administrator, not as you. This command works in a terminal opened without Run as administrator.`
67
+ (BA-40: it would install into the administrator's profile).
68
+ - An elevated run as the person installs for them as any run does (Nenya is per user; the app then
69
+ starts again as the person, BA-24), and gives what it made in their profile back to them, since
70
+ everything an elevated process creates is owned by Administrators (BA-76): Squirrel's install
71
+ folder and its `SquirrelTemp`, the npm cache npx wrote in, whole (`icacls <folder> /setowner
72
+ *<SID> /T /C /L /Q`), and the Start menu folder and shortcuts Squirrel made, alone. Each place must
73
+ be strictly inside `%USERPROFILE%`, exist, and not be a link or junction (a shortcut with a second
74
+ hard link is left alone too); `/L` acts on any link inside as itself.
75
+ - A Nenya installed for everyone (an earlier `Nenya-Setup.exe /ALLUSERS`: HKLM's
76
+ `Software\qwntl\Nenya` names its folder, else `%ProgramW6432%\Nenya`, counted only inside Program
77
+ Files and holding `Nenya.exe`) is named once after the install:
78
+ `Another copy of Nenya is installed for everyone on this computer, in <folder>; this one is yours. Removing that copy, with its uninstaller or from Settings > Apps, also removes this Nenya's data and its connections to your agents.`
79
+ The line names no removal: that copy's uninstaller (which Settings > Apps runs) first removes
80
+ every account's own Nenya, each from its ledger (`--everyone`), and this install keeps its ledger
81
+ and data in the same `%LOCALAPPDATA%\Nenya`. Removing it safely, without its uninstaller, is
82
+ adoption's (as `removeOldWindows.ts` does for alpha.20's per-user install).
83
+ - In Windows PowerShell plain `npx` resolves to npm's `npx.ps1`, which the default execution
84
+ policy on Windows client (Restricted) refuses to load; `npx.cmd` runs in PowerShell and in
85
+ `cmd.exe` with no policy change. A line shown to a Windows user names `npx.cmd`
86
+ (`npx.cmd -y @qwntllabs/nenya@alpha setup --invite CODE`).
87
+
88
+ ## Channel and base URL
89
+
90
+ Downloads come from the release bucket `https://downloads.harness.platform.qwntl.com`
91
+ (CONTRACTS.md §8; layout in `scripts/release/README.md`) under `desktop/v2/<channel>/<platform>/<arch>/`,
92
+ else `desktop/<channel>/<platform>/<arch>/`, and the Linux lines name its `linux/` repositories.
93
+ The v2 feed is read first (spec 15, signing rotation; "Where the public keys come from" below);
94
+ only when its release list (`RELEASES.json` on macOS, `RELEASES` on Windows) answers 404 is the
95
+ legacy feed read, as before. Any other answer from the v2 feed, or a v2 release or download that
96
+ is refused, is refused: it never falls back to the legacy feed. The channel is the package's own:
97
+ `0.12.0-alpha.1` installs from `alpha`, a stable version from `stable`; `--channel alpha|beta|stable`
98
+ or `NENYA_CHANNEL` overrides it (an unstamped `0.0.0` checkout follows `alpha`). The file to
99
+ download is built from the base, the feed root actually read and the name the feed gives; a URL
100
+ inside the feed is never followed.
101
+
102
+ `--feed URL`, or `NENYA_FEED` with the same value, reads another feed with the same layout. There
103
+ is no keyword and no built-in second feed: a feed is always a URL the person gives. The base is the
104
+ first of `--feed`, `NENYA_FEED`, `NENYA_DOWNLOAD_BASE_URL` (another bucket, the tests' loopback
105
+ server) and the release bucket; an empty variable counts as unset, so with none of them set nothing
106
+ changes.
107
+
108
+ - A feed is `https://host[:port]/path` (`http:` only for `127.0.0.1` or `localhost`), or
109
+ `file:///absolute/path`, a local copy of a feed (on Windows `file:///C:/path`). No user name, password, query,
110
+ fragment or IPv6 literal, and only letters, digits and `-._~:/%` in its path, so the printed
111
+ lines can carry it unquoted. Trailing slashes are dropped. Anything else, `qa` or another word
112
+ included, exits 2 with `'<value>' isn't a feed: a feed is an https:// or file:// URL.`
113
+ - A `file://` feed is how a qa build is installed: the qa feed bucket `harness-feed-qa` is private
114
+ (CONTRACTS.md §0), so a job with the qa identity copies a build (`builds/<job id>/`, named by the
115
+ object `latest`) to a folder and runs `nenya setup --feed file:///that/folder`. curl, apt
116
+ (`URIs: file:/…`, with `Signed-By`) and dnf (`baseurl=file:///…`, with `gpgcheck` and
117
+ `repo_gpgcheck`) all read `file:` URLs, so the signature checks are the same as over https. On
118
+ macOS and Windows the command reads the folder itself (`lib/filefeed.mjs`; Node's fetch reads no
119
+ `file:` URL), in the bucket's layout: `desktop/<channel>/darwin/arm64/RELEASES.json`,
120
+ `Nenya-darwin-arm64-<v>.zip` and its `.sigstore.json`; `desktop/<channel>/win32/x64/RELEASES`,
121
+ `Nenya-<v>-Setup.exe` and its `.sigstore.json` (or the same under `desktop/v2/`, read first, as
122
+ from the bucket). Every file is bounded and verified as from the bucket (a missing file reads as
123
+ the bucket's 404); the verified copy in a temporary folder is what is unpacked or run. An https
124
+ feed there is read as the release bucket is.
125
+ - On macOS and Windows a local feed's builds verify with: `NENYA_RELEASE_PUBLIC_KEY`'s file (one
126
+ or more PEM blocks, any of which may verify) when it is set; else `releaseKey` in the feed's
127
+ `feed.json`, the PEM text of one EC P-256 public key (as `cosign.pub`), for a qa build signed
128
+ with its own key; else the release keys this package carries (a local copy of the release
129
+ bucket). The command then says
130
+ `This feed's builds are checked with the key its feed.json names, not the Nenya release key.`
131
+ A `releaseKey` that isn't one EC P-256 public key (two PEM blocks included) exits 1 with
132
+ `The feed's feed.json names a releaseKey that isn't an EC P-256 public key.`, and a download that
133
+ doesn't verify with the key is refused, so nothing unverified is installed from any feed. Only a
134
+ local feed's `feed.json` is read, and only one that names `qa` or `staging`: an https feed's keys
135
+ are always the release keys (or `NENYA_RELEASE_PUBLIC_KEY`).
136
+ - A `file://` feed may name the environment its builds are for in `feed.json` at its root
137
+ (`{"env": "qa", …}`; `ci/qa-feed.gitlab-ci.yml` writes one into every qa build). The packages carry
138
+ no environment (one build for every environment) and the app takes `HARNESS_ENV`, else `env` in
139
+ `<userData>/harness.json`, else production (`apps/desktop/src/main/core/config.ts`), so `setup` and
140
+ `repair` set `env` in this account's `harness.json`, keeping its other settings:
141
+ `<appData>/com.qwntl.nenya.desktop/harness.json`, with Electron's `<appData>`: on Linux
142
+ `$XDG_CONFIG_HOME` (`~/.config` when unset), on macOS `~/Library/Application Support`, on Windows
143
+ `%APPDATA%` (`~\AppData\Roaming` when unset); or `NENYA_TEST_USER_DATA/harness.json` under
144
+ `NENYA_TEST=1`, as the app reads it. On macOS and Windows it is written once the download has
145
+ verified and before Nenya is installed or started, so the first start reads it. They say so in one
146
+ line: `This feed's builds are for qa: Nenya on this account will sign in to qa (<file>).` Only `qa`
147
+ and `staging` are accepted; an unusable `feed.json` or `harness.json` exits 1 with one line and
148
+ changes nothing. An https feed and a folder with no `feed.json` set nothing.
149
+ The recorded `env` stays until it is changed: a later `setup` from the release bucket doesn't
150
+ clear it; remove `env` from that `harness.json` (or the file) to go back to production.
151
+ - On Linux, when the base is not the release bucket, the lines start with
152
+ `Packages come from <base>.`; the rest is the same, with that base.
153
+
154
+ ## Messages between agents
155
+
156
+ `nenya message` lets any agent that can run a shell command message its swarm (the other
157
+ top-level agents on the same goal) through the Nenya that is running, so MCP isn't needed
158
+ (agent-loop-1027 DESIGN §2, §4.4; CONTRACT C11):
159
+
160
+ ```sh
161
+ nenya message reviewer ask "Review the retry change" --ref mr:42 --done-when "a verdict on mr:42"
162
+ nenya message lead reply "Fixed; the clock was the flake" --thread <id> --ref check:unit
163
+ nenya message builder review "parse() drops the last line" --verdict fix --reproduced --ref check:unit
164
+ nenya message list
165
+ ```
166
+
167
+ `nenya message --help` teaches the kinds (notice, ask, reply, handoff, review, help, and list for
168
+ the open threads), the addresses (a teammate's name or role, `lead`, `swarm`, `nenya`) and the ref
169
+ forms (`sha:<commit>`, `mr:<n>`, `check:<id>`, `file:<path>`, `pipeline:<n>`). It is one call of
170
+ Nenya's `message` tool, sent as the installed `nenya-hook` relay sends one: a shim frame of kind
171
+ `mcp` (u32 big-endian length, then UTF-8 JSON; `apps/desktop/src/shared/ipc/shim.ts`) carrying a
172
+ JSON-RPC `tools/call`, on the endpoint Edge writes to `<dataDir>/run/edge.addr` (else
173
+ `<dataDir>/run/edge.sock`, or on Windows `\\.\pipe\nenya-edge-<user>`). `<dataDir>` is
174
+ `NENYA_DATA_DIR` when Nenya sets it for a run, else the desktop's: `~/Library/Application
175
+ Support/Nenya`, `%LOCALAPPDATA%\Nenya`, `$XDG_DATA_HOME/nenya` (`~/.local/share/nenya`). Edge tells
176
+ the sender from the calling process (its pid, parent and folder, with `NENYA_AGENT`,
177
+ `NENYA_RUN_ID` and `NENYA_SESSION_ID` when the run sets them); no option names a sender.
178
+
179
+ The tool's answer is the outcome: whether it went, to whom and on which thread, exit status 0.
180
+ Edge's refusal goes to stderr with exit status 1, as does
181
+ `Nenya isn't running, so the message wasn't sent.`; with no answer within 20 seconds (Edge answers
182
+ "queued" itself well before) it isn't known whether the message went, so the line says so and how to check
183
+ (`nenya message list`), exit status 1. What Edge would refuse anyway
184
+ (an unknown kind, no text, more than 1,200 characters, a ref in no known form, a verdict outside a
185
+ review, a reply with no thread) is refused before anything is sent, with exit status 2.
186
+ `lib/message.mjs` imports only `node:` built-ins, so the desktop can ship that one file as the
187
+ `nenya` command on a run's PATH; run on its own it takes `nenya message …` or the message's
188
+ arguments.
189
+
190
+ ## Verification
191
+
192
+ Every file `release:sign` publishes has a Sigstore bundle beside it, `<file>.sigstore.json`,
193
+ written by `cosign sign-blob --key <release KMS key>` with no transparency log or timestamp
194
+ service (`scripts/release/sign/sign.mjs`, `VERIFY.md`). For a key signature cosign 3.1.3 writes
195
+
196
+ ```json
197
+ {
198
+ "mediaType": "application/vnd.dev.sigstore.bundle.v0.3+json",
199
+ "verificationMaterial": {
200
+ "publicKey": { "hint": "<base64 sha256 of the public key, SPKI DER>" }
201
+ },
202
+ "messageSignature": {
203
+ "messageDigest": {
204
+ "algorithm": "SHA2_256",
205
+ "digest": "<base64 sha256 of the file>"
206
+ },
207
+ "signature": "<base64 DER ECDSA P-256 signature over sha256(file)>"
208
+ }
209
+ }
210
+ ```
211
+
212
+ `lib/verify.mjs` checks, with `node:crypto` only and the listed release keys (below), that (1) the
213
+ bundle is such a bundle with a `SHA2_256` message digest, (2) the digest equals the SHA-256 of the
214
+ bytes that were downloaded, (3) the key hint, when present, names one of the listed keys (a hint
215
+ naming none is refused; with no hint every listed key is tried), and (4) the ECDSA signature
216
+ verifies over those bytes with that key. Each listed key gets its own streamed check of the bytes,
217
+ so a download is read once. For one key that is the whole of what
218
+ `cosign verify-blob --key cosign.pub --insecure-ignore-tlog --bundle` checks for this kind of
219
+ bundle; there is no certificate, log entry or timestamp to check. `test/verify.test.mjs` signs a
220
+ file with cosign 3.1.3 itself (from `mise.toml`) and checks that the verifier accepts it, also
221
+ listed after another key, and refuses a changed byte; and it holds spec 15's locked cases: with
222
+ the two listed keys, a download signed by the old key or the new key passes, and one signed by an
223
+ unknown key or with its signature stripped fails.
224
+
225
+ The artifact's own bundle is verified rather than `SHA256SUMS` plus `SHA256SUMS.sigstore.json`:
226
+ both are signed by the same key over a SHA-256 of the same bytes, the per-file bundle is the one
227
+ whose published path `scripts/release/README.md` fixes (upload step 2, beside its file), and
228
+ `SHA256SUMS` names files by their path under `dist/`, not under the bucket. Verifying the
229
+ checksum file would add a second, equivalent signature over the same digest and nothing more.
230
+
231
+ ### Where the public keys come from
232
+
233
+ `release-keys.pub` holds the release signing keys' public halves, two PEM blocks in this order:
234
+
235
+ 1. The Cloud KMS key `release:sign` signs with today, EC P-256
236
+ (`projects/grantx-anthropic-dev/locations/us-central1/keyRings/harness-release/cryptoKeys/harness-release-signing/cryptoKeyVersions/1`),
237
+ read on 2026-10-14 with
238
+ `gcloud kms keys versions get-public-key 1 --key harness-release-signing --keyring harness-release --location us-central1 --project grantx-anthropic-dev`.
239
+ SHA-256 of its SPKI DER: `687f34c49443a7da0652ab07b7d0e1006b0e177cb4a2700fc14d4f2f9b27fd20`
240
+ (cosign's key hint `aH80xJRDp9oGUqsHt9DhAGsOF3y0onAPwU1PL5sn/SA=`). This block is byte for byte
241
+ the `release-key.pub` this package pinned alone before the bridge.
242
+ 2. Its successor, the Key Vault `kv-harness-signing` key `release-signing-2` (Key Vault Premium,
243
+ EC-HSM P-256, signs ES256), read on 2026-10-25 with
244
+ `az keyvault key download --vault-name kv-harness-signing --name release-signing-2 --encoding PEM --file release-signing-2.pub`.
245
+ SHA-256 of its SPKI DER: `c6419c341d89a4dab6ad186e5cd217b5533e1f850890e80e1a8ada04f1d99262`
246
+ (cosign's key hint `xkGcNB2JpNq2rRhuXNIXtVM+H4UIkOgOGoraBPHZkmI=`).
247
+
248
+ Why two (spec 15, signing rotation): Cloud KMS keys can't be exported, so moving release signing
249
+ to Azure Key Vault is a rotation, not a move, and a client that pins exactly one key would refuse
250
+ everything the new key signs. This package version is the bridge: still signed with the Cloud KMS
251
+ key, it accepts a download that either listed key verifies (the bundle's key hint picks the key;
252
+ with no hint both are tried), and it reads the v2 feeds first (`desktop/v2/<channel>/…`, which
253
+ will carry only Key Vault signatures) and the legacy feeds only while the v2 release list answers
254
+ a 404. The legacy feeds freeze at the bridge release, so an older package still finds a release its
255
+ one key verifies. The Cloud KMS key goes away after the switch: once CI signs only with Key Vault
256
+ and publishes only to the v2 feeds (spec 15 step 3), a later package version drops the first
257
+ block and pins the Key Vault key alone; the Cloud KMS key is then disabled, not destroyed.
258
+
259
+ Pinning the keys in the package means trust rests on the npm package the person already runs, not
260
+ on a file fetched from the bucket being verified. A key rotation is a new package version.
261
+ `NENYA_RELEASE_PUBLIC_KEY=<pem file>` replaces the list (the file may hold one or more PEM blocks;
262
+ the tests' throwaway keys); for a local feed on macOS and Windows, so does the one `releaseKey` its
263
+ `feed.json` names (above).
264
+
265
+ Keeping the pin honest: `release:sign` publishes the signer's public key as `cosign.pub`, and the
266
+ release jobs (`release:sign` itself, and promote through `ci/release-transition.sh`) run
267
+ `node ci/tools/release-key-member.mjs dist/cosign.pub packages/nenya-cli/release-keys.pub` after
268
+ it, so a release whose `cosign.pub` is not one of the pinned keys (compared as SPKI DER) fails
269
+ before anything is uploaded; and the release lead confirms each block once against its source
270
+ with the commands above.
271
+
272
+ ## Publish
273
+
274
+ A release publishes this package from the release-tag pipeline's `release:npm` job (rs-platform's
275
+ !350, `ci/release-npm.gitlab-ci.yml`): `packages/cli/scripts/release-npm.mjs` stamps `VERSION` into
276
+ this `package.json`, packs it last, after the harness CLI packages and the SDK, into `dist/npm/`, and
277
+ publishes exactly that tarball with the org's credentials (Secret Manager
278
+ `harness-npm-publish-token`, or trusted publishing). A release tree without `packages/nenya-cli`
279
+ fails before anything is published. npm tarballs are not signed by the publish job; what the person
280
+ runs is what the registry serves under the dist-tag.
281
+
282
+ `scripts/release-npm.mjs` here (`npm run release:npm:nenya`) publishes this package on its own, by
283
+ hand, from the repository root. It is not the release route. It reuses
284
+ `packages/cli/scripts/{npm,dist-tags}.mjs`: the same registry selection (`HARNESS_NPM_REGISTRY`), the
285
+ same credentials (`NPM_ID_TOKEN` for trusted publishing, else the org's token in `NODE_AUTH_TOKEN`),
286
+ the same `npm publish <tarball> --tag $NPM_TAG --access public`, and the same less-stable dist-tag
287
+ propagation (CONTRACTS.md §5). A dry run packs the package and runs `npm publish --dry-run`:
288
+
289
+ ```sh
290
+ VERSION=0.11.1-alpha.21 NPM_TAG=alpha npm run release:npm:nenya -- --dry-run
291
+ ```
292
+
293
+ It stamps `VERSION` into this `package.json` (not committed; run
294
+ `git checkout -- packages/nenya-cli/package.json` after a local dry run) and packs one tarball into
295
+ `dist/npm/`.
296
+
297
+ Every install, repair and update line names `@latest` (conductor ruling 2026-10-15), and this
298
+ script never sets `latest` for a pre-release. For the cutover, `0.11.1-alpha.21` publishes to the
299
+ holding dist-tag `next-harness` with no `alpha` or `latest` move; at C12 the manual
300
+ `release:npm:promote` job (!350) moves `alpha` and `latest` together to it, with a read-back, and a
301
+ rollback moves both back to `0.11.0-alpha.22` (restart DECISIONS 95). Before the first tag, check
302
+ that the org token's scope covers `@qwntllabs/nenya` (RULINGS.md ~23:20Z).
303
+
304
+ ## Tests
305
+
306
+ ```sh
307
+ npm test -w @qwntllabs/nenya # node --test test/*.test.mjs; needs cosign on PATH (mise install)
308
+ npm run lint -w @qwntllabs/nenya
309
+ # the suite on the floor Node.js too (test/node-floor.test.mjs runs it when this names a Node.js 20):
310
+ NENYA_FLOOR_NODE="$(mise which node --tool node@20)" npm test -w @qwntllabs/nenya
311
+ ```
312
+
313
+ `test/node-floor.test.mjs` holds the floor: the guard's line and exit status under an older
314
+ Node.js (its `process.versions.node` set by a preload), the guard's floor against `engines.node`,
315
+ the command through `bin/nenya.cjs` on this Node.js, every `node:` built-in the command imports by
316
+ name against the names Node.js 20.0.0 has, and, with `NENYA_FLOOR_NODE`, the whole suite on that
317
+ Node.js.
318
+
319
+ `test/setup.test.mjs` runs `setup` and `repair` per OS against a loopback HTTP server standing in
320
+ for the bucket and a P-256 key generated in the test, exposed through `NENYA_RELEASE_PUBLIC_KEY`:
321
+ the macOS and Windows happy paths, the invite hand-over (and the fallback line), the tampered
322
+ artifact and the wrong-key refusals, the Linux lines, `repair` and `--help`, and `--feed`: the
323
+ default lines unchanged (a fixed Debian text), an https feed, a `file://` feed (apt and dnf), the
324
+ precedence, and refused values (keywords such as `qa` included); and spec 15's bridge: a release
325
+ signed by either of two listed keys installs, an unknown key's or a stripped signature is refused,
326
+ the v2 feed is read first and alone when it is there, the legacy feed only on the v2 list's 404,
327
+ and a v2 feed that is there but refused (another HTTP status, no connection, an unreadable list, a
328
+ changed, unsigned, wrongly signed or missing download) never falls back. `test/localfeed.test.mjs`
329
+ runs `setup --feed file:///…` on macOS and Windows against a local feed folder: read from disk with
330
+ nothing fetched, the v2 folder first and the legacy folder when the v2 list is missing, the
331
+ tampered, missing and oversized refusals, the feed's `releaseKey` (and `NENYA_RELEASE_PUBLIC_KEY`
332
+ over it, the release keys without either, an unusable key refused), and the environment recorded
333
+ in the account's `harness.json` before Nenya starts. The fake `ditto` and `Setup.exe` write what
334
+ the real ones would into a temporary home; nothing else is touched.
335
+
336
+ `test/message.test.mjs` runs `nenya message` against a fake Edge (a unix socket in a scratch data
337
+ folder, named in its `run/edge.addr`) that reads the frame and answers as Edge's MCP server does:
338
+ the frame and the tool's arguments as given, `list`, Edge's refusal, a JSON-RPC error, Nenya not
339
+ running, no answer within the budget, Edge closing without an answer, the refusals before sending,
340
+ sender options refused, the help text, the data folder per OS and the endpoint shapes; and the
341
+ command through `bin/nenya.cjs` and `lib/message.mjs` run on their own, as real processes.
342
+
343
+ `test/windows.test.mjs` checks `lib/windows.mjs` against stand-ins for `whoami`, `tasklist`,
344
+ `icacls` and `reg`; `test/setup.test.mjs` also runs the Windows administrator-terminal cases and
345
+ the other-copy line through `nenya setup`, and pins that the setup line says only what this run
346
+ did (one outcome line, no connect claim, no earlier run's result). `test/npm-global.test.mjs`
347
+ packs the package into a temporary home whose `~/.npmrc` sets `prefix`, installs it with
348
+ `npm install --global` and runs it with `npx -y`, offline, using the npm beside the Node that runs
349
+ the test (skipped when there is none). `test/e2e-lib.test.mjs` checks the on-machine scripts'
350
+ shared parts on any OS.
351
+
352
+ ### On a real machine
353
+
354
+ Two scripts run the setup line on a disposable machine (runner-agnostic: any CI runner or VM
355
+ image can call them from a checkout; no network beyond 127.0.0.1, no credentials or signing keys;
356
+ each refuses without `NENYA_DISPOSABLE_PROFILE=1`). Both build a loopback feed in the bucket's
357
+ layout from a build's artifact, signed with a key made for the run, pack this package and run
358
+ `npx … nenya setup --invite …` as a person types it, and print one PASS or FAIL line per check.
359
+
360
+ ```sh
361
+ # Windows, as a standard account, an administrator, and the administrator elevated (NT-B-009);
362
+ # --messy adds NT-B-065's profile (execution policy Restricted, Codex-style ACLs, OneDrive
363
+ # Documents, a WinGet Claude stand-in; run with nvm-windows' Node)
364
+ NENYA_DISPOSABLE_PROFILE=1 node packages/nenya-cli/scripts/e2e/windows-setup.mjs \
365
+ --setup "out/make/squirrel.windows/x64/Nenya-<v> Setup.exe" \
366
+ [--update-from <a newer build's out/make/squirrel.windows/x64>] [--messy] [--expect standard|admin]
367
+
368
+ # macOS, as a standard account logged in at the desktop (NT-B-009, NEW-T5-OP-UR-U3)
369
+ NENYA_DISPOSABLE_PROFILE=1 node packages/nenya-cli/scripts/e2e/macos-setup.mjs \
370
+ --zip out/make/zip/darwin/arm64/Nenya-darwin-arm64-<v>.zip [--update-zip <newer zip>] [--expect standard]
371
+ ```
372
+
373
+ ## Open
374
+
375
+ - The on-machine runs (above) need a Windows and a macOS runner with a build's artifacts; until a
376
+ runner runs them, the macOS steps are exercised with a fake `ditto` and `open`, the Windows
377
+ steps with a fake `Setup.exe` and stand-ins for Windows' tools.
378
+ - Until the D8 identity (!155) lands, the feeds name `Harness-*` files; this installer refuses
379
+ them by design (it accepts only `Nenya-darwin-<arch>-<v>.zip` and `Nenya-<v>-Setup.exe`).
380
+ - The Linux repository files are the ones the `nenya-app` package writes itself (D116):
381
+ `/etc/apt/sources.list.d/nenya.sources` with `/usr/share/keyrings/nenya-archive-keyring.gpg`, and
382
+ `/etc/yum.repos.d/nenya.repo`, with the keyring fetched as `<feed>/linux/nenya-archive-keyring.*`
383
+ (published from rs-platform's !584 on). Each file's first line is the marker the package and
384
+ install.sh write too (`# Managed by Nenya (nenya-app). Removed when nenya-app is purged.`), so
385
+ purging or erasing `nenya-app` removes it. The lines first take away what earlier lines wrote for
386
+ the same feed (`harness.sources` with `/etc/apt/keyrings/harness-archive-keyring.gpg`,
387
+ `harness.repo`), since apt 3 refuses one repository with two `Signed-By` values, by the package's
388
+ rule: only a file exactly as written (any channel, whitespace aside), and its key only when nothing
389
+ else names it. Any other one (edited, disabled, pointed at a mirror, another feed's), or one `rm`
390
+ cannot remove, stays and the lines stop there (each but the last ends in `&&`) with one line saying
391
+ how to switch. If the package's paths change
392
+ (`apps/desktop/scripts/forge-linux-repo.mts`), `lib/linux.mjs` follows.
393
+ - Windows arm64 reads `desktop/<channel>/win32/arm64/`, published once D14 ships it.
package/bin/nenya.cjs ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // The `nenya` command as npm runs it. It is CommonJS (.cjs) and written in syntax every Node.js since 6
3
+ // parses, so a Node.js older than this package supports gets one plain line and exit status 1, never
4
+ // a SyntaxError's stack trace. Only once the version is new enough does it load start.cjs, which
5
+ // imports the real command (bin/nenya.js, an ES module with top-level await): Node.js before 10
6
+ // can't parse `import()`, so that call stays out of this file.
7
+ "use strict";
8
+
9
+ // The oldest Node.js major Nenya runs on: package.json engines.node is `>=${FLOOR}.0.0`.
10
+ const FLOOR = 20;
11
+
12
+ const version = String(process.versions.node);
13
+ if (!(parseInt(version.split(".")[0], 10) >= FLOOR)) {
14
+ console.error(
15
+ "Nenya needs Node.js " +
16
+ FLOOR +
17
+ " or newer (this computer has " +
18
+ version +
19
+ "). nodejs.org has it, and the same line works once it's installed.",
20
+ );
21
+ process.exit(1);
22
+ }
23
+
24
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- CommonJS on purpose: see the header
25
+ require("./start.cjs");
package/bin/nenya.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ // `npx -y @qwntllabs/nenya@latest setup --invite CODE`: the real command line, the real operating
3
+ // system and the real network, loaded by bin/nenya.cjs once its Node.js version check passes.
4
+ // Everything that acts (downloads, `ditto`, `open`, `Setup.exe`) reaches lib/ through the runners
5
+ // built here, so the tests can replace them.
6
+ import { spawn, spawnSync } from "node:child_process";
7
+ import { existsSync, readFileSync } from "node:fs";
8
+ import { homedir, tmpdir } from "node:os";
9
+ import { main } from "../lib/cli.mjs";
10
+ import { edgeConnect } from "../lib/message.mjs";
11
+
12
+ const system = {
13
+ // Runs a command to completion with no shell and no window; its output is never shown (plain
14
+ // language only). With `output` its stdout is handed back for lib/ to read (lsappinfo on macOS;
15
+ // whoami, tasklist, reg on Windows); without, nothing is piped: a pipe handed to Setup.exe would
16
+ // pass on to the app Squirrel starts, and this run would wait for the app to quit.
17
+ run(file, args, { timeout, output = false } = {}) {
18
+ const result = spawnSync(file, args, {
19
+ stdio: output ? ["ignore", "pipe", "ignore"] : "ignore",
20
+ encoding: "utf8",
21
+ maxBuffer: 16 * 1024 * 1024,
22
+ timeout,
23
+ windowsHide: true,
24
+ });
25
+ return {
26
+ status: result.error ? null : result.status,
27
+ stdout: output ? (result.stdout ?? "") : "",
28
+ // spawnSync's timeout: the child was stopped (said, never taken for a failure of its own)
29
+ timedOut: result.error?.code === "ETIMEDOUT",
30
+ };
31
+ },
32
+ // Starts a program that outlives this command (the installed app on Windows): true once it has started, false when
33
+ // it couldn't be (spawn reports that as an error event, after spawn() returns).
34
+ launch(file, args) {
35
+ return new Promise((resolve) => {
36
+ try {
37
+ const child = spawn(file, args, { detached: true, stdio: "ignore" });
38
+ child.once("spawn", () => {
39
+ child.unref();
40
+ resolve(true);
41
+ });
42
+ child.once("error", () => resolve(false));
43
+ } catch {
44
+ resolve(false);
45
+ }
46
+ });
47
+ },
48
+ };
49
+
50
+ const osRelease =
51
+ process.platform === "linux" && existsSync("/etc/os-release")
52
+ ? readFileSync("/etc/os-release", "utf8")
53
+ : "";
54
+
55
+ process.exitCode = await main(process.argv.slice(2), {
56
+ platform: process.platform,
57
+ arch: process.arch,
58
+ env: process.env,
59
+ home: homedir(),
60
+ tmpdir: tmpdir(),
61
+ fetch: globalThis.fetch,
62
+ system,
63
+ osRelease,
64
+ // `nenya message`: Edge's local socket, and the process and folder Edge tells the sender from
65
+ connect: edgeConnect,
66
+ cwd: process.cwd(),
67
+ pid: process.pid,
68
+ ppid: process.ppid,
69
+ uid: process.getuid ? process.getuid() : -1,
70
+ out: (line) => console.log(line),
71
+ err: (line) => console.error(line),
72
+ });
package/bin/start.cjs ADDED
@@ -0,0 +1,9 @@
1
+ // Loaded by nenya.cjs once Node.js is new enough: the real command is the ES module bin/nenya.js.
2
+ "use strict";
3
+
4
+ import("./nenya.js").catch((error) => {
5
+ console.error(
6
+ `Nenya couldn't start: ${error && error.message ? error.message : error}`,
7
+ );
8
+ process.exitCode = 1;
9
+ });