@amritk/nish-x86_64-linux 0.18.0 → 0.21.0

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 (104) hide show
  1. package/INSTALL.md +58 -28
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +2759 -0
  4. package/package.json +3 -2
  5. package/runtime/browser.d.ts +14 -0
  6. package/runtime/browser.mjs +88 -0
  7. package/runtime/core/arrays.d.ts +18 -0
  8. package/runtime/core/arrays.mjs +125 -0
  9. package/runtime/core/checks.mjs +20 -0
  10. package/runtime/core/host.d.ts +70 -0
  11. package/runtime/core/host.mjs +311 -0
  12. package/runtime/core/numbers.d.ts +53 -0
  13. package/runtime/core/numbers.mjs +316 -0
  14. package/runtime/core/result.d.ts +41 -0
  15. package/runtime/core/result.mjs +127 -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 +99 -5
  22. package/runtime/nish.h +289 -19
  23. package/runtime/nish.mjs +39 -3
  24. package/runtime/node.mjs +383 -0
  25. package/runtime/runtime-aes.c +490 -0
  26. package/runtime/runtime-bytes.c +401 -0
  27. package/runtime/runtime-cross.c +366 -0
  28. package/runtime/runtime-host.c +8 -7
  29. package/runtime/runtime-net.c +93 -34
  30. package/runtime/runtime-os.c +214 -16
  31. package/runtime/runtime-parallel.c +590 -107
  32. package/runtime/runtime-simd.c +235 -11
  33. package/runtime/runtime-term.c +504 -0
  34. package/runtime/runtime-wasm.c +5 -14
  35. package/runtime/runtime.c +257 -17
  36. package/runtime/shim.mjs +6 -915
  37. package/runtime/sqlite/LICENSE.md +85 -0
  38. package/runtime/sqlite/README.md +45 -0
  39. package/runtime/sqlite/nish-sqlite.c +359 -0
  40. package/runtime/sqlite/sqlite3.c +271131 -0
  41. package/runtime/sqlite/sqlite3.h +14447 -0
  42. package/scripts/build.sh +437 -28
  43. package/std/LICENSE-fast-float +23 -0
  44. package/std/LICENSE-fdlibm +8 -0
  45. package/std/README.md +108 -58
  46. package/std/base64.ts +116 -0
  47. package/std/bytes.ts +419 -0
  48. package/std/cli.ts +328 -0
  49. package/std/collections.ts +6 -5
  50. package/std/crypto/LICENSE-crypt_blowfish +26 -0
  51. package/std/crypto/LICENSE-libsecp256k1 +19 -0
  52. package/std/crypto/aes.ts +238 -76
  53. package/std/crypto/base64url.ts +125 -0
  54. package/std/crypto/bcrypt.ts +760 -0
  55. package/std/crypto/chacha20poly1305.ts +43 -9
  56. package/std/crypto/ed25519.ts +840 -0
  57. package/std/crypto/hkdf.ts +304 -12
  58. package/std/crypto/hmac.ts +382 -54
  59. package/std/crypto/p256.ts +932 -61
  60. package/std/crypto/x25519.ts +55 -37
  61. package/std/crypto/x509-random.ts +71 -0
  62. package/std/crypto/x509.ts +20 -131
  63. package/std/json-tokenizer.ts +4237 -0
  64. package/std/json-typed.ts +1014 -0
  65. package/std/json-value.ts +1182 -0
  66. package/std/json.ts +1202 -34
  67. package/std/math.ts +608 -0
  68. package/std/net/buffer-pool.ts +151 -0
  69. package/std/net/hpack.ts +416 -112
  70. package/std/net/http-fields.ts +93 -0
  71. package/std/net/http1-server.ts +501 -62
  72. package/std/net/http1.ts +31 -6
  73. package/std/net/http2-tls.ts +112 -24
  74. package/std/net/http2.ts +333 -75
  75. package/std/net/http3-server.ts +261 -43
  76. package/std/net/http3.ts +187 -28
  77. package/std/net/postgres.ts +1875 -0
  78. package/std/net/prefork.ts +412 -0
  79. package/std/net/quic-listener.ts +108 -11
  80. package/std/net/quic-packet.ts +243 -82
  81. package/std/net/quic-recovery.ts +361 -30
  82. package/std/net/quic-stream.ts +424 -24
  83. package/std/net/quic.ts +519 -167
  84. package/std/net/router.ts +676 -0
  85. package/std/net/tls/codec.ts +426 -27
  86. package/std/net/tls/record-server.ts +478 -132
  87. package/std/net/tls/record.ts +133 -42
  88. package/std/net/tls/schedule.ts +464 -55
  89. package/std/net/tls/ticket.ts +610 -0
  90. package/std/net/tls-tcp.ts +196 -53
  91. package/std/net/tls.ts +1018 -260
  92. package/std/net/url.ts +571 -0
  93. package/std/random.ts +94 -0
  94. package/std/regex.ts +4274 -0
  95. package/std/sqlite.ts +391 -0
  96. package/std/term-io.ts +978 -0
  97. package/std/term-pixels.ts +874 -0
  98. package/std/term-probe.ts +459 -0
  99. package/std/term-rate.ts +993 -0
  100. package/std/term.ts +2453 -0
  101. package/std/text.ts +90 -7
  102. package/std/threads.ts +438 -14
  103. package/std/yaml-lines.ts +141 -0
  104. package/std/yaml.ts +4675 -0
package/INSTALL.md CHANGED
@@ -109,7 +109,7 @@ Through npm, which is also how an Nish *program* resolves its dependencies
109
109
  the compiler pinned per project in a `package.json`:
110
110
 
111
111
  ```bash
112
- npm install -g @amritk/nish
112
+ npm install -g nish
113
113
  nish --version
114
114
  ```
115
115
 
@@ -171,13 +171,12 @@ never fails over it.
171
171
  > underlying defect is [wp19 §5a](wp19-stage0-retirement.md#5a-what-r6-is-waiting-on)
172
172
  > item 4.
173
173
 
174
- **Do not install `nish`.** That name on the public registry has belonged to
175
- `stdarg`'s "A Node.js Interactive shell" since February 2014 — versions 0.0.0
176
- and 0.0.1, both deprecated by their author, nothing published since. **This
177
- compiler is `@amritk/nish`** (decided 2026-09-19,
178
- [docs/wp12-release.md](wp12-release.md#the-npm-name)), and the command it
179
- installs is still `nish` — the package name and the command are two different
180
- strings, and that is the one thing the scope costs.
174
+ **The package is `nish` from 0.20.0.** Releases up to 0.18.0 were published
175
+ as `@amritk/nish` (0.19.0's publish to npm failed), which is deprecated and
176
+ points here; `npm install -g nish`
177
+ replaces it ([docs/wp12-release.md](wp12-release.md#the-npm-name)). Versions
178
+ 0.0.0 and 0.0.1 of `nish` are an unrelated 2014 project that held the name
179
+ before it, so pin `nish@^0.20.0` or later rather than an older range.
181
180
 
182
181
  **On a platform this project attaches no binary for, `npm install` gets you a
183
182
  command that refuses.** The table below is the whole list, so musl, FreeBSD and
@@ -224,7 +223,8 @@ routes are
224
223
  build/nish app.ts -o app.ll
225
224
  # on the musl host, with its own clang and the runtime from this repository
226
225
  clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
227
- runtime/runtime-host.c runtime/runtime-net.c -lm -o app
226
+ runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
227
+ runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-term.c runtime/runtime-bytes.c -lm -o app
228
228
  ```
229
229
 
230
230
  `--link`ing inside the container is the mistake to avoid: it shells out to the
@@ -240,18 +240,20 @@ routes are
240
240
  If you need one of these to be a first-class install, that is the conversation
241
241
  to have on the issue tracker rather than a workaround to discover here.
242
242
 
243
- **On the registry from 0.10.0.** Every release publishes the main package and
244
- its platform packages to npm from `release.yml`, by trusted publishing
243
+ **On the registry from 0.10.0** — as `@amritk/nish` through 0.18.0, and as
244
+ `nish` from 0.20.0; 0.19.0 is on GitHub only, because its npm publish
245
+ failed. Every release publishes the main package and its platform packages to
246
+ npm from `release.yml`, by trusted publishing
245
247
  ([docs/wp12-release.md](wp12-release.md#release-procedure) step 4), so
246
- `npm install -g @amritk/nish` is the whole install. The rest of this section is
248
+ `npm install -g nish` is the whole install. The rest of this section is
247
249
  for a machine that cannot reach the registry, or a release before 0.10.0.
248
250
 
249
251
  From a release tarball on GitHub — the same package `npm publish` uploads,
250
252
  carried by the release instead of the registry. The `Release` workflow attaches
251
253
  the npm tarball to the release it builds for a `v*` tag. `npm pack` names it
252
- after `package.json#name`, so it is `amritk-nish-<version>.tgz` from 0.4.0 on
253
- and `nish-<version>.tgz` for the releases cut before the scope was taken — the
254
- example below is one of those:
254
+ after `package.json#name`, so it is `nish-<version>.tgz` before 0.4.0 and
255
+ from 0.20.0 on, and `amritk-nish-<version>.tgz` from 0.4.0 to 0.19.0, while the
256
+ package was scoped — the example below is one of the early ones:
255
257
 
256
258
  ```bash
257
259
  curl -LO https://github.com/amritk/nish/releases/download/v0.2.0/nish-0.2.0.tgz
@@ -358,21 +360,25 @@ it into `build/seed/`; `NISH_BOOTSTRAP=<path>` names one you already have and
358
360
  skips the download. §2a has what the build does with it.
359
361
 
360
362
  The published package ships `bin/` (the `nish` command, which is a launcher),
361
- `runtime/` (the C runtime — five translation units and their header),
362
- `scripts/build.sh` (the link pipeline) and `std/` (the standard library). The
363
+ `runtime/` (the C runtime — ten translation units, the wasm subset and their
364
+ header — and `runtime/sqlite/`, SQLite's vendored source),
365
+ `scripts/build.sh` (the link pipeline), `std/` (the standard library) and
366
+ `docs/AI.md` (the rules card). The
363
367
  compiler itself is not in it: it arrives as one prebuilt
364
368
  `@amritk/nish-<asset>` package per platform, and `bin/nish` hands over to
365
- whichever one npm installed. `nish` locates the runtime, the script and `std/`
369
+ whichever one npm installed. That package carries its own copy of all of
370
+ these, and its `docs/AI.md` is the one an agent's `nish --help` names. `nish` locates the runtime, the script and `std/`
366
371
  relative to its own install directory, so a global install works from any
367
372
  working directory — and the binary runs from inside its own platform package
368
373
  for exactly that reason.
369
374
 
370
375
  Building the IR yourself rather than through `--link` means naming the runtime
371
- on the `clang` line, and it is five files:
376
+ on the `clang` line, and it is ten files:
372
377
 
373
378
  ```bash
374
379
  clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
375
- runtime/runtime-host.c runtime/runtime-net.c -lm -o app
380
+ runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
381
+ runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-term.c runtime/runtime-bytes.c -lm -o app
376
382
  ```
377
383
 
378
384
  `runtime.c` is the part every program touches — the arena, strings, arrays,
@@ -380,16 +386,28 @@ number formatting, the panics — and `runtime-os.c` wraps the system calls:
380
386
  files, directories, subprocesses, `getenv`, the monotonic clock.
381
387
  `runtime-parallel.c` divides work across threads for `nish/threads` (a
382
388
  program built with `--threads`, as every importer of `nish/threads` is, also
383
- needs `-DNISH_THREADS=1 -pthread` on the line), `runtime-host.c` holds the
384
- wall clock, entropy, file times and signals, and `runtime-net.c` the sockets
385
- of `nish:net`. They are separate so that each
386
- carries its own measured size ceiling ([docs/wp7-runtime.md](wp7-runtime.md));
387
- nothing in the core calls into the others, so a line that names only
388
- `runtime.c` and `runtime-os.c` still links a program that uses none of the
389
- other three. `scripts/build.sh` compiles the other four beside any
389
+ needs `-DNISH_THREADS=1 -pthread` on the line), `runtime-cross.c` copies
390
+ the strings and arrays a task answers, a channel sends or a `Mutex` keeps out
391
+ of the arena they were made in, `runtime-host.c` holds the wall clock,
392
+ entropy, file times and signals, `runtime-net.c` the sockets of `nish:net`,
393
+ `runtime-simd.c` and `runtime-aes.c` the vector text search and AES-GCM,
394
+ `runtime-term.c` the stdin reads and terminal calls of `nish:term`, and
395
+ `runtime-bytes.c` the byte-class runs of `nish/bytes`, which `nish/json` steps
396
+ over.
397
+ They are separate so that each carries its own measured size ceiling
398
+ ([docs/wp7-runtime.md](wp7-runtime.md)); nothing in the core calls into the
399
+ others, so a line that names only `runtime.c` and `runtime-os.c` still links a
400
+ program that uses none of the other eight. `scripts/build.sh` compiles the other
401
+ eight beside any
390
402
  `runtime.c` it is handed, so a build that goes through it — every `--link`,
391
403
  and every `--profile` recipe in these documents — needs to name only the one.
392
404
 
405
+ A program whose IR declares an `sqlite3_*` function also needs SQLite on a
406
+ hand-written line. `scripts/build.sh` adds it by itself; by hand, append
407
+ `runtime/sqlite/sqlite3.c` with the options `scripts/build.sh` lists under
408
+ "SQLite's compile-time options" (at least `-DSQLITE_THREADSAFE=0`, or `=2`
409
+ beside `-DNISH_THREADS=1`).
410
+
393
411
  ## 2a. What `npm run build` does
394
412
 
395
413
  `src/` is the compiler, written in Nish, and it compiles itself
@@ -479,6 +497,18 @@ refuses the run without one rather than keep a binary in a shared directory.
479
497
  The first run that builds into the cache makes its root `0700`, so no other
480
498
  user can plant a binary in it ([docs/security/cli.md](security/cli.md)).
481
499
 
500
+ Every link with the debug, speed or size profile, `nish run`'s and `--link`'s
501
+ alike, keeps the compiled C runtime in `$XDG_CACHE_HOME/nish/runtime` (or
502
+ `~/.cache/nish/runtime`), one entry per profile, `-g`, `--threads`, `CC` and
503
+ the version that compiler reports, made `0700` the same way. The first link
504
+ compiles the runtime's six files at once into it, and every later link
505
+ compiles only the program's modules, also at once, and links against the
506
+ entry: a `hello.ts` debug link goes from about half a second to about a
507
+ tenth. `--link` with no absolute `HOME` or `XDG_CACHE_HOME`, or with a root
508
+ it cannot make private, compiles the runtime itself as it always did; the
509
+ wasi profile and `scripts/build.sh` called directly never use the cache.
510
+ Removing the directory is always safe.
511
+
482
512
  ## 4. Exit codes
483
513
 
484
514
  | Code | Meaning |
@@ -488,7 +518,7 @@ user can plant a binary in it ([docs/security/cli.md](security/cli.md)).
488
518
  | 2 | usage error: unknown flag, missing argument, no input files |
489
519
  | 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 |
490
520
  | | `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 |
491
- | 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 |
521
+ | 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 |
492
522
 
493
523
  ## Troubleshooting
494
524
 
package/bin/nish CHANGED
Binary file