@amritk/nish-x86_64-linux 0.20.0 → 0.22.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 (74) hide show
  1. package/INSTALL.md +52 -10
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +2777 -0
  4. package/package.json +2 -1
  5. package/runtime/browser.d.ts +6 -0
  6. package/runtime/browser.mjs +77 -0
  7. package/runtime/core/arrays.d.ts +36 -0
  8. package/runtime/core/arrays.mjs +153 -0
  9. package/runtime/core/checks.mjs +20 -0
  10. package/runtime/core/host.d.ts +80 -0
  11. package/runtime/core/host.mjs +325 -0
  12. package/runtime/core/numbers.d.ts +66 -0
  13. package/runtime/core/numbers.mjs +343 -0
  14. package/runtime/core/result.d.ts +45 -0
  15. package/runtime/core/result.mjs +140 -0
  16. package/runtime/core/strings.d.ts +14 -0
  17. package/runtime/core/strings.mjs +169 -0
  18. package/runtime/core.d.ts +9 -0
  19. package/runtime/core.mjs +55 -0
  20. package/runtime/host.d.ts +6 -0
  21. package/runtime/nish.d.ts +46 -2
  22. package/runtime/nish.h +75 -2
  23. package/runtime/nish.mjs +23 -3
  24. package/runtime/node.mjs +386 -0
  25. package/runtime/runtime-bytes.c +401 -0
  26. package/runtime/runtime-cross.c +1 -1
  27. package/runtime/runtime-host.c +1 -1
  28. package/runtime/runtime-net.c +12 -1
  29. package/runtime/runtime-os.c +1 -1
  30. package/runtime/runtime-parallel.c +1 -1
  31. package/runtime/runtime-simd.c +231 -7
  32. package/runtime/runtime-term.c +504 -0
  33. package/runtime/runtime-wasm.c +0 -11
  34. package/runtime/runtime.c +190 -6
  35. package/runtime/shim.mjs +6 -985
  36. package/runtime/sqlite/LICENSE.md +85 -0
  37. package/runtime/sqlite/README.md +45 -0
  38. package/runtime/sqlite/nish-sqlite.c +359 -0
  39. package/runtime/sqlite/sqlite3.c +271131 -0
  40. package/runtime/sqlite/sqlite3.h +14447 -0
  41. package/scripts/build.sh +311 -59
  42. package/std/LICENSE-fast-float +23 -0
  43. package/std/LICENSE-fdlibm +8 -0
  44. package/std/README.md +32 -12
  45. package/std/base64.ts +116 -0
  46. package/std/bytes.ts +256 -0
  47. package/std/cli.ts +344 -0
  48. package/std/collections.ts +6 -5
  49. package/std/crypto/LICENSE-crypt_blowfish +26 -0
  50. package/std/crypto/base64url.ts +125 -0
  51. package/std/crypto/bcrypt.ts +1557 -0
  52. package/std/crypto/hmac.ts +138 -2
  53. package/std/crypto/x509.ts +11 -122
  54. package/std/json-tokenizer.ts +2998 -57
  55. package/std/json-value.ts +22 -3
  56. package/std/json.ts +87 -8
  57. package/std/math.ts +608 -0
  58. package/std/net/http1-server.ts +282 -40
  59. package/std/net/http1.ts +40 -21
  60. package/std/net/http3-server.ts +50 -12
  61. package/std/net/postgres.ts +2294 -0
  62. package/std/net/prefork.ts +23 -3
  63. package/std/net/quic-listener.ts +20 -4
  64. package/std/random.ts +66 -4
  65. package/std/regex.ts +4274 -0
  66. package/std/sqlite.ts +391 -0
  67. package/std/term-io.ts +978 -0
  68. package/std/term-pixels.ts +874 -0
  69. package/std/term-probe.ts +459 -0
  70. package/std/term-rate.ts +993 -0
  71. package/std/term.ts +2453 -0
  72. package/std/text.ts +90 -7
  73. package/std/yaml-lines.ts +141 -0
  74. package/std/yaml.ts +4675 -0
package/INSTALL.md CHANGED
@@ -143,6 +143,36 @@ for — which catches a truncated download, a tarball built for another
143
143
  architecture, and an asset whose name does not match what is inside it — and
144
144
  only then swapped in. If any of that fails the install you had is untouched.
145
145
 
146
+ **Every download is checked before it is unpacked.** install.sh compares the
147
+ tarball's SHA-256 with the release's `SHA256SUMS` (or with the digest pinned
148
+ for releases that predate it) and refuses a mismatch. For releases after
149
+ 0.21.0 it also checks the release's **build provenance attestation** when a
150
+ signed-in GitHub CLI is present whose `gh attestation verify` takes the
151
+ options below. The attestation
152
+ is a Sigstore-signed statement, made by `actions/attest-build-provenance` in
153
+ the release workflow, that every file in `SHA256SUMS` was built by
154
+ `.github/workflows/release.yml` at the release's tag on a GitHub-hosted
155
+ runner. A failed verification refuses the install; with no `gh`, a signed-out
156
+ one or one too old for those options, the check is skipped with a note saying so, and the
157
+ SHA-256 still applies. The same command by hand, on a tarball you downloaded:
158
+
159
+ ```bash
160
+ gh attestation verify nish-<version>-<asset>.tar.gz \
161
+ --repo amritk/nish \
162
+ --signer-workflow amritk/nish/.github/workflows/release.yml \
163
+ --source-ref refs/tags/v<version> \
164
+ --deny-self-hosted-runners
165
+ ```
166
+
167
+ It works on any file the release attaches, the npm tarballs included. Each
168
+ release also attaches `nish-<version>.spdx.json`, an SPDX 2.3 software bill of
169
+ materials: every attached file with its SHA-256, the clang, linker, Node.js
170
+ and seed compiler that built each tarball (recorded by the build row itself),
171
+ and the vendored code from
172
+ [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md) that each of them contains.
173
+ How these fit the rest of the release's defences is
174
+ [docs/security/supply-chain.md](security/supply-chain.md).
175
+
146
176
  The npm route installs the **native** compiler, and it is a download rather than a
147
177
  build: nothing is compiled on your machine. The package declares one
148
178
  `nish-<os>-<arch>` package per supported platform as an `optionalDependencies`
@@ -224,7 +254,7 @@ routes are
224
254
  # on the musl host, with its own clang and the runtime from this repository
225
255
  clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
226
256
  runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
227
- runtime/runtime-simd.c runtime/runtime-aes.c -lm -o app
257
+ runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-term.c runtime/runtime-bytes.c -lm -o app
228
258
  ```
229
259
 
230
260
  `--link`ing inside the container is the mistake to avoid: it shells out to the
@@ -360,22 +390,25 @@ it into `build/seed/`; `NISH_BOOTSTRAP=<path>` names one you already have and
360
390
  skips the download. §2a has what the build does with it.
361
391
 
362
392
  The published package ships `bin/` (the `nish` command, which is a launcher),
363
- `runtime/` (the C runtime — eight translation units, the wasm subset and their header),
364
- `scripts/build.sh` (the link pipeline) and `std/` (the standard library). The
393
+ `runtime/` (the C runtime — ten translation units, the wasm subset and their
394
+ header — and `runtime/sqlite/`, SQLite's vendored source),
395
+ `scripts/build.sh` (the link pipeline), `std/` (the standard library) and
396
+ `docs/AI.md` (the rules card). The
365
397
  compiler itself is not in it: it arrives as one prebuilt
366
398
  `@amritk/nish-<asset>` package per platform, and `bin/nish` hands over to
367
- whichever one npm installed. `nish` locates the runtime, the script and `std/`
399
+ whichever one npm installed. That package carries its own copy of all of
400
+ these, and its `docs/AI.md` is the one an agent's `nish --help` names. `nish` locates the runtime, the script and `std/`
368
401
  relative to its own install directory, so a global install works from any
369
402
  working directory — and the binary runs from inside its own platform package
370
403
  for exactly that reason.
371
404
 
372
405
  Building the IR yourself rather than through `--link` means naming the runtime
373
- on the `clang` line, and it is eight files:
406
+ on the `clang` line, and it is ten files:
374
407
 
375
408
  ```bash
376
409
  clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
377
410
  runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
378
- runtime/runtime-simd.c runtime/runtime-aes.c -lm -o app
411
+ runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-term.c runtime/runtime-bytes.c -lm -o app
379
412
  ```
380
413
 
381
414
  `runtime.c` is the part every program touches — the arena, strings, arrays,
@@ -387,15 +420,24 @@ needs `-DNISH_THREADS=1 -pthread` on the line), `runtime-cross.c` copies
387
420
  the strings and arrays a task answers, a channel sends or a `Mutex` keeps out
388
421
  of the arena they were made in, `runtime-host.c` holds the wall clock,
389
422
  entropy, file times and signals, `runtime-net.c` the sockets of `nish:net`,
390
- and `runtime-simd.c` and `runtime-aes.c` the vector text search and AES-GCM.
423
+ `runtime-simd.c` and `runtime-aes.c` the vector text search and AES-GCM,
424
+ `runtime-term.c` the stdin reads and terminal calls of `nish:term`, and
425
+ `runtime-bytes.c` the byte-class runs of `nish/bytes`, which `nish/json` steps
426
+ over.
391
427
  They are separate so that each carries its own measured size ceiling
392
428
  ([docs/wp7-runtime.md](wp7-runtime.md)); nothing in the core calls into the
393
429
  others, so a line that names only `runtime.c` and `runtime-os.c` still links a
394
- program that uses none of the other six. `scripts/build.sh` compiles the other
395
- seven beside any
430
+ program that uses none of the other eight. `scripts/build.sh` compiles the other
431
+ eight beside any
396
432
  `runtime.c` it is handed, so a build that goes through it — every `--link`,
397
433
  and every `--profile` recipe in these documents — needs to name only the one.
398
434
 
435
+ A program whose IR declares an `sqlite3_*` function also needs SQLite on a
436
+ hand-written line. `scripts/build.sh` adds it by itself; by hand, append
437
+ `runtime/sqlite/sqlite3.c` with the options `scripts/build.sh` lists under
438
+ "SQLite's compile-time options" (at least `-DSQLITE_THREADSAFE=0`, or `=2`
439
+ beside `-DNISH_THREADS=1`).
440
+
399
441
  ## 2a. What `npm run build` does
400
442
 
401
443
  `src/` is the compiler, written in Nish, and it compiles itself
@@ -506,7 +548,7 @@ Removing the directory is always safe.
506
548
  | 2 | usage error: unknown flag, missing argument, no input files |
507
549
  | 3 | toolchain error: `--link` found no `clang` (`CC` overrides), or `scripts/build.sh` failed (its output is shown; the `.ll` files are still written) — or the `nish` command found no prebuilt compiler for this platform, or one that would not start. Under `--json` all of these are one `NL0002` object |
508
550
  | | `nish run` answers these codes until the program starts, and the program's own exit status (`128 + n` for a signal) after that. With neither `HOME` nor `XDG_CACHE_HOME` set to an absolute path it answers 3 |
509
- | 70 | internal compiler error: an unexpected exception. Please report it at <https://github.com/amritk/nish/issues> with the input and command line; `NISH_DEBUG=1` prints the stack trace |
551
+ | 70 | internal compiler error: a broken invariant in the compiler. Please report it at <https://github.com/amritk/nish/issues> with the input and command line; the compiler is self-hosted and has no stack trace to print, so the message it prints is the whole report |
510
552
 
511
553
  ## Troubleshooting
512
554
 
package/bin/nish CHANGED
Binary file