@amritk/nish-aarch64-linux 0.39.0 → 0.40.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.
Files changed (54) hide show
  1. package/INSTALL.md +74 -129
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +112 -33
  4. package/package.json +1 -1
  5. package/runtime/nish.d.ts +21 -17
  6. package/runtime/nish.h +10 -0
  7. package/runtime/page-frame.d.ts +123 -0
  8. package/runtime/page-frame.mjs +736 -0
  9. package/runtime/page-game.d.ts +132 -0
  10. package/runtime/page-game.mjs +738 -0
  11. package/runtime/runtime-aes.c +85 -8
  12. package/runtime/runtime-bytes.c +88 -4
  13. package/runtime/runtime-net.c +32 -0
  14. package/runtime/runtime-sandbox.c +55 -28
  15. package/runtime/runtime-wasm.c +422 -0
  16. package/runtime/vite.mjs +1 -1
  17. package/scripts/build.sh +15 -0
  18. package/std/README.md +73 -87
  19. package/std/array.ts +36 -3
  20. package/std/collections.ts +51 -0
  21. package/std/crypto/hmac.ts +37 -10
  22. package/std/crypto/p256.ts +1388 -2664
  23. package/std/crypto/pki.ts +116 -4
  24. package/std/crypto/sha256.ts +34 -6
  25. package/std/crypto/x509.ts +7 -0
  26. package/std/host/game.ts +273 -0
  27. package/std/input.ts +56 -0
  28. package/std/json-tokenizer.ts +325 -112
  29. package/std/json-typed.ts +43 -8
  30. package/std/json-value.ts +144 -3
  31. package/std/json.ts +63 -8
  32. package/std/net/fetch.ts +22 -4
  33. package/std/net/http-server.ts +3382 -0
  34. package/std/net/http1-client-codec.ts +6 -2
  35. package/std/net/http1-codec.ts +137 -12
  36. package/std/net/http1-server.ts +83 -29
  37. package/std/net/http2.ts +47 -14
  38. package/std/net/http3-server.ts +29 -3
  39. package/std/net/http3.ts +180 -7
  40. package/std/net/quic-recovery.ts +240 -9
  41. package/std/net/quic-stream.ts +21 -1
  42. package/std/net/quic.ts +98 -4
  43. package/std/net/router.ts +378 -31
  44. package/std/net/serve.ts +873 -65
  45. package/std/net/tls/verify.ts +19 -1
  46. package/std/net/url.ts +83 -35
  47. package/std/net/websocket.ts +74 -1
  48. package/std/net/webtransport.ts +7 -1
  49. package/std/raster.ts +837 -0
  50. package/std/release.ts +593 -0
  51. package/std/synth.ts +143 -0
  52. package/std/threads.ts +298 -0
  53. package/std/yaml-json.ts +368 -28
  54. package/std/yaml.ts +122 -27
package/INSTALL.md CHANGED
@@ -7,10 +7,10 @@ else that turns `.ll` into machine code) needs an LLVM toolchain.
7
7
 
8
8
  ## 1. Prerequisites
9
9
 
10
- - **Node.js 22.18 or newer** (22 is what CI uses), for the npm route and for
11
- building from a checkout — the launcher, the postinstall step and the test
12
- harness are Node scripts. It is the version where Node strips TypeScript
13
- types without a flag, which `docs/RUN_UNDER_NODE.md` relies on. The
10
+ - **Node.js 22.18 or newer**, for the npm route and for building from a
11
+ checkout — the launcher, the postinstall step and the test harness are Node
12
+ scripts. It is the version where Node strips TypeScript types without a
13
+ flag, which [running a program under Node](RUN_UNDER_NODE.md) relies on. The
14
14
  `install.sh` route below needs no Node at all.
15
15
  - **clang** (LLVM 18 recommended) and **lld**, for `--link`. Without them
16
16
  `nish` still writes the `.ll` files and exits 3 with the install
@@ -116,7 +116,7 @@ of its own architecture by the release workflow before the release existed, and
116
116
  installing is a download and an unpack.
117
117
 
118
118
  Through npm, which is also how an Nish *program* resolves its dependencies
119
- ([wp21-packages.md](https://github.com/amritk/nish/blob/main/docs/wp21-packages.md)), so this is the one to pick if you want
119
+ ([Packages](guide/language/modules.md#packages)), so this is the one to pick if you want
120
120
  the compiler pinned per project in a `package.json`:
121
121
 
122
122
  ```bash
@@ -132,22 +132,50 @@ curl -fsSL https://raw.githubusercontent.com/amritk/nish/main/install.sh | sh
132
132
 
133
133
  That unpacks into `~/.nish` and prints the one line to add to your shell
134
134
  profile. On a platform it has no binary for it says so and names the four it
135
- does build — the npm route covers exactly the same four and no more, because
136
- since 0.6.0 there is no compiler inside that package to fall back to either.
137
-
138
- **Upgrading is running it again.** There is no separate command: it installs
139
- over an existing install, says `upgrading nish 0.3.0 to 0.4.0`, and says
140
- `nothing to do` when the version already matches.
135
+ does build — the npm route covers exactly the same four and no more.
136
+
137
+ **Upgrade with `nish upgrade`.** It asks GitHub for the latest release and,
138
+ when it is newer than the compiler you are running, fetches that release's own
139
+ `install.sh` (from its tag, never `main`) into a private file and runs it over
140
+ your install's directory. `nish upgrade 0.4.0` installs a version you name, and
141
+ says so when it is older; `nish upgrade --check` only prints the version you
142
+ have and the latest. A compiler installed with npm is upgraded with npm:
143
+ `nish upgrade` prints the `npm install -g nish@<version>` line to run and
144
+ changes nothing. Running the install script again does the same job: it
145
+ installs over an existing install, says `upgrading nish 0.3.0 to 0.4.0`, and
146
+ says `nothing to do` when the version already matches.
147
+
148
+ Once a day at most, a command on a terminal that exits 0 or 1 (a compile,
149
+ `nish --version`, `nish --help` and the like) checks for a
150
+ newer release in the background and prints one line on stderr when there is
151
+ one. `NISH_NO_UPDATE_CHECK=1` turns it off; it is never shown in CI, with
152
+ `--json`, in `nish run`, or when stderr is not a terminal
153
+ ([the CLI guide](guide/using-nish/cli.md#staying-up-to-date-nish-upgrade)).
141
154
 
142
155
  ```bash
143
156
  curl -fsSL https://raw.githubusercontent.com/amritk/nish/main/install.sh | sh # latest
144
157
  curl -fsSL https://raw.githubusercontent.com/amritk/nish/main/install.sh | sh -s 0.4.0 # a version
145
158
  sh install.sh --dir /opt/nish # somewhere other than ~/.nish (or NISH_INSTALL)
146
159
  sh install.sh --force # reinstall the version already there
147
- sh install.sh --uninstall # remove it
160
+ sh install.sh --no-modify-path # leave shell startup files alone (or NISH_NO_MODIFY_PATH=1)
161
+ sh install.sh --uninstall # remove it, and the PATH line it added
148
162
  sh install.sh --help # all of the above
149
163
  ```
150
164
 
165
+ The script puts the install's `bin/` on your `PATH` in the startup file of the
166
+ shell `$SHELL` names: `~/.zshrc` for zsh (under `$ZDOTDIR` when that is set),
167
+ `~/.bashrc` for bash on Linux, for bash on macOS whichever of
168
+ `~/.bash_profile`, `~/.bash_login` and `~/.profile` a login bash already reads
169
+ (`~/.bash_profile` when there is none), `conf.d/nish.fish` in fish's
170
+ configuration directory for fish, and `~/.profile` for any other shell. The
171
+ line sits between `# >>> nish >>>` and `# <<< nish <<<` and is added once:
172
+ running the script again, or `nish upgrade`, leaves it as it is, and
173
+ `--uninstall` takes it out of every file it may have gone into. Nothing is
174
+ written when the directory is already on `PATH`, or when its path holds a
175
+ quote, a backslash, a colon or a newline (the script prints the line to add
176
+ instead). The script cannot change the `PATH` of the shell you ran it from, so
177
+ it ends by naming the file to `source` there.
178
+
151
179
  An upgrade cannot leave you without a compiler. The new one is unpacked beside
152
180
  the old, checked that it runs *and* that it reports the version that was asked
153
181
  for — which catches a truncated download, a tarball built for another
@@ -166,8 +194,11 @@ The attestation is a Sigstore-signed statement, made by
166
194
  `SHA256SUMS` was built by `.github/workflows/release.yml` at the release's tag
167
195
  on a GitHub-hosted runner. A failed verification refuses the install; with no
168
196
  `gh`, a signed-out one or one too old for those options, the check is skipped
169
- with a note saying so, and the SHA-256 still applies. The same command by hand,
170
- on a tarball you downloaded:
197
+ with a note saying so, and the SHA-256 still applies. Set
198
+ `NISH_REQUIRE_ATTESTATION=1` to refuse instead of skipping: the install then
199
+ fails unless `gh` verifies the attestation, and refuses a release of 0.21.0 or
200
+ older, which carries none. The same command by hand, on a tarball you
201
+ downloaded:
171
202
 
172
203
  ```bash
173
204
  gh attestation verify nish-<version>-<asset>.tar.gz \
@@ -180,7 +211,7 @@ gh attestation verify nish-<version>-<asset>.tar.gz \
180
211
  It works on any file the release attaches, the npm tarballs included. Each
181
212
  release also attaches `nish-<version>.spdx.json`, an SPDX 2.3 software bill of
182
213
  materials: every attached file with its SHA-256, the clang, linker, Node.js
183
- and seed compiler that built each tarball (recorded by the build row itself),
214
+ and the previous release's compiler that built each tarball,
184
215
  and the vendored code from
185
216
  [THIRD_PARTY_NOTICES.md](https://github.com/amritk/nish/blob/main/THIRD_PARTY_NOTICES.md) that each of them contains.
186
217
  How these fit the rest of the release's defences is
@@ -188,7 +219,7 @@ How these fit the rest of the release's defences is
188
219
 
189
220
  The npm route installs the **native** compiler, and it is a download rather than a
190
221
  build: nothing is compiled on your machine. The package declares one
191
- `nish-<os>-<arch>` package per supported platform as an `optionalDependencies`
222
+ `@amritk/nish-<asset>` package per supported platform as an `optionalDependencies`
192
223
  entry with `os` and `cpu` set, so npm fetches exactly the one that matches and
193
224
  skips the rest. Each of those carries the self-hosted compiler — `src/`
194
225
  compiled by itself — already built, `--verify`d and smoke-tested on a machine
@@ -210,16 +241,12 @@ never fails over it.
210
241
  > directory happens to be, while `--version` and `-o` keep working. Both
211
242
  > installers above handle it by running the binary through a one-line `exec` of
212
243
  > an absolute path. If you unpack a tarball by hand, invoke it by path
213
- > (`nish-<version>-<asset>/bin/nish`) or write that wrapper yourself. The
214
- > underlying defect is [wp19 §5a](https://github.com/amritk/nish/blob/main/docs/wp19-stage0-retirement.md#5a-what-r6-is-waiting-on)
215
- > item 4.
244
+ > (`nish-<version>-<asset>/bin/nish`) or write that wrapper yourself.
216
245
 
217
- **The package is `nish` from 0.20.0.** Releases up to 0.18.0 were published
218
- as `@amritk/nish` (0.19.0's publish to npm failed), which is deprecated and
219
- points here; `npm install -g nish`
220
- replaces it ([docs/wp12-release.md](https://github.com/amritk/nish/blob/main/docs/wp12-release.md#the-npm-name)). Versions
221
- 0.0.0 and 0.0.1 of `nish` are an unrelated 2014 project that held the name
222
- before it, so pin `nish@^0.20.0` or later rather than an older range.
246
+ **The package is `nish` from 0.20.0**; the older `@amritk/nish` is
247
+ deprecated, and `npm install -g nish` replaces it. Versions 0.0.0 and 0.0.1 of
248
+ `nish` are an unrelated project that held the name before it, so pin
249
+ `nish@^0.20.0` or later rather than an older range.
223
250
 
224
251
  **On a platform this project attaches no binary for, `npm install` gets you a
225
252
  command that refuses.** The table below is the whole list, so musl, FreeBSD and
@@ -243,22 +270,15 @@ nish: no prebuilt compiler for freebsd/x64
243
270
  binary runs on this platform at all.
244
271
  ```
245
272
 
246
- Until 0.6.0 it ran the TypeScript compiler that shipped in the same package
247
- instead — the same compiler by every test here, about eight times slower, and
248
- no C toolchain needed. That compiler was stage0, which was deleted in R6
249
- ([wp19](https://github.com/amritk/nish/blob/main/docs/wp19-stage0-retirement.md)), so there is nothing left in the package to
250
- fall back to. The cost is stated where the rest of that deletion's costs are,
251
- in [wp19 §6](https://github.com/amritk/nish/blob/main/docs/wp19-stage0-retirement.md#6-what-retirement-costs-stated-plainly),
252
- and it is a real one: **musl, FreeBSD and 32-bit platforms have no `npm
253
- install` route to a compiler any more.**
254
-
255
- What is left for those platforms is the bootstrap, and it needs one thing this
256
- page cannot hand you: a compiler that already runs on the machine. The seed does
257
- not have to be *for* the machine — it has to run *on* it — so the practical
258
- routes are
273
+ **musl, FreeBSD and 32-bit platforms have no `npm install` route to a
274
+ compiler.** What is left for them is building one from source, and that needs
275
+ one thing this page cannot hand you: a compiler that already runs on the
276
+ machine. It does not have to be built *for* the machine, only to run *on* it,
277
+ so the practical routes are
259
278
 
260
279
  - a glibc container or host to build in, when the target is musl. Build
261
- `build/nish` there with `NISH_BOOTSTRAP=<released nish> scripts/bootstrap.sh`,
280
+ `build/nish` there with `NISH_BOOTSTRAP=<released nish> scripts/bootstrap.sh`
281
+ ([building from source](https://github.com/amritk/nish/blob/main/CONTRIBUTING.md#building-the-compiler-from-source)),
262
282
  and then **emit the IR in the container and link it on the musl host**:
263
283
 
264
284
  ```bash
@@ -285,13 +305,9 @@ routes are
285
305
  If you need one of these to be a first-class install, that is the conversation
286
306
  to have on the issue tracker rather than a workaround to discover here.
287
307
 
288
- **On the registry from 0.10.0** — as `@amritk/nish` through 0.18.0, and as
289
- `nish` from 0.20.0; 0.19.0 is on GitHub only, because its npm publish
290
- failed. Every release publishes the main package and its platform packages to
291
- npm from `release.yml`, by trusted publishing
292
- ([docs/wp12-release.md](https://github.com/amritk/nish/blob/main/docs/wp12-release.md#release-procedure) step 4), so
293
- `npm install -g nish` is the whole install. The rest of this section is
294
- for a machine that cannot reach the registry, or a release before 0.10.0.
308
+ **On the registry from 0.10.0** (0.19.0 is on GitHub only), so
309
+ `npm install -g nish` is the whole install. The rest of this section is for a
310
+ machine that cannot reach the registry, or a release before 0.10.0.
295
311
 
296
312
  From a release tarball on GitHub — the same package `npm publish` uploads,
297
313
  carried by the release instead of the registry. The `Release` workflow attaches
@@ -336,22 +352,8 @@ cross-compiled, so the one you take has compiled and run two programs before it
336
352
  reached you — a one-module one and a two-module one, from a directory unrelated
337
353
  to the machine that built it.
338
354
 
339
- The last column is there because a release is a past event and a workflow is
340
- not. `release.yml` builds all four, but a release already published cannot grow
341
- an asset: **the releases before v0.4.0 attach `x86_64-linux` only**. Those
342
- versions are not prose — they are `attachedSince` in
343
- [`.github/seed-targets.json`](https://github.com/amritk/nish/blob/main/.github/seed-targets.json),
344
- the same file the release workflow builds its matrix from, so this table and
345
- the assets cannot drift apart without a test failing.
346
-
347
- **The three newer rows say v0.4.0 rather than v0.3.0 on purpose.** Nothing in
348
- this repository had run on macOS or on ARM Linux before, and a row that has
349
- never run is not something to put in front of a release: `release` needs the
350
- whole matrix, so one red row blocks the publish. So they waited until a run on
351
- their own hardware had exercised them. The two macOS rows waited on a second
352
- thing as well: the bootstrap's `stage3 == stage2` check did not hold as a raw
353
- byte comparison under `ld64` until both stages were linked at one output path.
354
- `scripts/verify-binaries.sh`'s header is the long version.
355
+ A release already published cannot grow an asset, so **the releases before
356
+ v0.4.0 attach `x86_64-linux` only**.
355
357
 
356
358
  Check [the releases page](https://github.com/amritk/nish/releases/latest) for
357
359
  what a given version actually carries; on a platform whose row has not shipped
@@ -367,13 +369,10 @@ nish-0.16.0-x86_64-linux/bin/nish --version
367
369
  Both URLs name the version rather than using GitHub's version-neutral
368
370
  `/releases/latest/download/` form, because that form needs the asset's exact
369
371
  file name and every asset name carries the version in it. The example names
370
- v0.16.0; v0.1.1 was the first release with a binary attached.
371
- The `v0.1.0` tag exists but has no release behind it and no assets, so every
372
- `v0.1.0` download URL is a 404 — the tag was pushed by a workflow, and GitHub
373
- raises no event for that, so nothing ever built it
374
- ([docs/wp12-release.md](https://github.com/amritk/nish/blob/main/docs/wp12-release.md#release-procedure) step 2). When a newer
375
- release exists, take its version from
376
- [the releases page](https://github.com/amritk/nish/releases/latest).
372
+ v0.16.0; take the current version from
373
+ [the releases page](https://github.com/amritk/nish/releases/latest). v0.1.1 was
374
+ the first release with a binary attached; the `v0.1.0` tag has no release and
375
+ no assets behind it.
377
376
 
378
377
  Unpack it and run `bin/nish` from wherever you like; put that on `PATH` if you
379
378
  want it there. Keep the directory intact rather than moving the binary out of
@@ -388,22 +387,10 @@ It still needs `clang` and `lld` on `PATH` for `--link` (§1), because linking
388
387
  is the C toolchain's job, not the compiler's; what it does not need is Node.
389
388
  On a platform outside the table, build from a checkout.
390
389
 
391
- From a checkout:
392
-
393
- ```bash
394
- git clone https://github.com/amritk/nish.git
395
- cd nish
396
- npm ci
397
- bash scripts/fetch-seed.sh # the last release, into build/seed/
398
- npm run build # seed -> stage1 -> stage2 = build/nish
399
- build/nish hello.ts --link hello
400
- ```
401
-
402
- The build is a bootstrap, the way Rust and Go build themselves: the compiler
403
- is written in Nish, so something has to compile it first, and that is the
404
- previous release's `nish` binary — the seed. `scripts/fetch-seed.sh` downloads
405
- it into `build/seed/`; `NISH_BOOTSTRAP=<path>` names one you already have and
406
- skips the download. §2a has what the build does with it.
390
+ To build the compiler from a checkout instead, follow
391
+ [building the compiler from source](https://github.com/amritk/nish/blob/main/CONTRIBUTING.md#building-the-compiler-from-source).
392
+ It needs Node, clang and a released `nish` to start from, which the build
393
+ fetches for you.
407
394
 
408
395
  The published package ships `bin/` (the `nish` command, which is a launcher),
409
396
  `runtime/` (the C runtime — seventeen translation units, the wasm subset and their
@@ -457,9 +444,7 @@ of `nish/bytes`, which `nish/json` steps over, `runtime-checksum.c` the CRC-32
457
444
  kernels of `nish/compress/checksum`, `runtime-sandbox.c` the confinement a
458
445
  `--sandbox` build applies, and `runtime-shm.c` the shared-memory regions of
459
446
  `nish/sync/shm`. They are separate so that each carries its own measured size
460
- ceiling
461
- ([docs/wp7-runtime.md](https://github.com/amritk/nish/blob/main/docs/wp7-runtime.md));
462
- the core is three files that call each other — `runtime-os.c` builds strings
447
+ ceiling; the core is three files that call each other — `runtime-os.c` builds strings
463
448
  with `runtime-text.c`'s `nish_str_new` — and calls into none of the others, so a
464
449
  line that names only `runtime.c`, `runtime-text.c` and `runtime-os.c` links a
465
450
  program that uses none of the other fourteen. Leave out `runtime-text.c` and it
@@ -476,46 +461,6 @@ hand-written line. `scripts/build.sh` adds it by itself; by hand, append
476
461
  "SQLite's compile-time options" (at least `-DSQLITE_THREADSAFE=0`, or `=2`
477
462
  beside `-DNISH_THREADS=1`).
478
463
 
479
- ## 2a. What `npm run build` does
480
-
481
- `src/` is the compiler, written in Nish, and it compiles itself
482
- ([docs/wp14-selfhost.md](https://github.com/amritk/nish/blob/main/docs/wp14-selfhost.md)). From a checkout, with clang on
483
- `PATH`, `npm run build` runs `scripts/bootstrap.sh` with the seed from §2:
484
-
485
- ```bash
486
- npm run build # build/nish
487
- NISH_BOOTSTRAP=~/.nish/bin/nish npm run build # the same, seeded by an installed nish
488
- scripts/bootstrap.sh --verify # and assert the fixed point
489
- ```
490
-
491
- The seed builds stage1, stage1 builds stage2, and stage2 is installed as
492
- `build/nish`. `--verify` also builds stage3 and asserts
493
- `IR(stage1) == IR(stage2)` and `stage3 == stage2` byte for byte; the seed's
494
- own IR is only reported beside them, because a codegen change since the
495
- release is expected to move it. `--stages 1` stops one link sooner.
496
-
497
- `build/nish` is then the compiler you run: it takes the same `-o`, `--link` and
498
- `--profile` spellings as an installed `nish`, because it is the same program,
499
- and makes every directory in the way of the IR, a sidecar or the binary itself.
500
- It looks for `scripts/build.sh` and the `runtime/*.c` files one level up from
501
- wherever it was invoked (and one level up from the file a symbolic link to it
502
- names), so it wants a checkout or an installed package around it the way `nish`
503
- does. It falls back to the working directory only when the compiler itself lies
504
- inside that directory, so a checkout you merely `cd` into cannot hand it a
505
- `scripts/build.sh` to run. Keep `bin/nish` beside `scripts/`, `runtime/` and
506
- `std/`, as every install above does, and keep that directory's parent writable
507
- only by you: the package root is the parent of the compiler's directory, so a
508
- compiler at `/tmp/x/nish` would trust `/tmp/scripts/build.sh` (CLI-9 in
509
- [docs/security/cli.md](security/cli.md)).
510
-
511
- Because the seed is the last release, `src/` may only *use* in its own
512
- source the constructs that release compiles. A new construct is implemented
513
- in `src/` and becomes usable inside `src/` from the next release on; CI's
514
- `bootstrap` job is what checks that the released seed still builds stage1.
515
- Until R6 the seed was a TypeScript compiler, stage0, run under Node; it was
516
- deleted once the native one answered every flag it did
517
- ([wp19](https://github.com/amritk/nish/blob/main/docs/wp19-stage0-retirement.md)).
518
-
519
464
  ## 3. Hello world
520
465
 
521
466
  Create `hello.ts`:
@@ -546,7 +491,7 @@ nish hello.ts -o hello.ll
546
491
 
547
492
  Other build profiles: `--profile size` (smallest binary), `--profile debug`
548
493
  (no optimisation, symbols kept). Run `nish --help` for every flag, and
549
- see the [README](https://github.com/amritk/nish/blob/main/README.md) for the language subset.
494
+ see the [user guide](guide/index.md) for the language.
550
495
 
551
496
  To use a program as a script rather than keep the binary, run it:
552
497
 
package/bin/nish CHANGED
Binary file