Add edit program
This commit is contained in:
+4
-4
@@ -180,7 +180,7 @@ These files are **read from disk by the seeder** and written into the system dri
|
||||
|
||||
- **Staged as**: `/bin/help`
|
||||
- **Contract**: `async function run(ctx, _argv)`.
|
||||
- **Behavior**: Logs `Commands: help, echo <text>, exit`.
|
||||
- **Behavior**: Logs a compact list of **`/bin`** names, builtins, and pointers to **`man`** / identity commands (not an exhaustive tutorial; see **`man edit`** / **`man nano`** for the TTY editor).
|
||||
|
||||
### 9.4 [kernel/etc/os-release](kernel/etc/os-release)
|
||||
|
||||
@@ -430,7 +430,7 @@ Pear-safe path resolution (same idea as Holepunch [pear-rti](https://github.com/
|
||||
- If **`argv[0]`** is **`wget`** under the same basename rules, **delegates** to **`runWgetCli`** in [`wget-cli.js`](packages/bare-os-booter/lib/wget-cli.js) (HTTP download via Fetch / **bare-fetch**; manual **`wget(1)`** in the merged JSON DB).
|
||||
- If `argv[0]` contains `/`, resolves with `ctx.vfs.resolveLogical`, `route`, loads script bytes from the routed Hyperdrive (`get` with `follow`).
|
||||
- Else walks `$PATH` (`ctx.vfs.env.PATH`, default `/bin`), joining each directory with `unix-path-resolve(dir, cmd)` (not three-argument resolve), loads from **system** `ctx.drive` only.
|
||||
- Builds `AsyncFunction('ctx','argv', ...)` requiring `run`, invokes `run(ctx, argv)`.
|
||||
- Builds `AsyncFunction('ctx','argv', ...)` with the script source plus `if (typeof run === 'function') await run(ctx, argv)` (top-level statements run first; optional `run` matches `/bin` utilities).
|
||||
- Unknown command: `ctx.console.log('unknown command: ...')`.
|
||||
|
||||
**`resolveBinInPath(ctx, name)`** — returns the first **`PATH`** hit on the system drive (absolute `/bin/...` path string) or **`null`**; used by shell **`command -v`** / **`type`**.
|
||||
@@ -464,9 +464,9 @@ Pear-safe path resolution (same idea as Holepunch [pear-rti](https://github.com/
|
||||
### 12.10 Package `bare-os-coreutils`
|
||||
|
||||
- **[packages/bare-os-coreutils/lib/commands.mjs](packages/bare-os-coreutils/lib/commands.mjs)** — **`COREUTILS_COMMANDS`**: authoritative sorted `/bin` names for **`build.mjs`** and the manual database builder (keeps the image and **`man`** coverage in sync).
|
||||
- **[packages/bare-os-coreutils/build.mjs](packages/bare-os-coreutils/build.mjs)** — `export async function build()`: runs **`scripts/build-man-db.mjs`** (validates **`man/pages/*.json`**, writes **`kernel/share/man/man.json`** and the same path under **`packages/bare-os-seeder/kernel/share/man/`**); then for each command concatenates `lib/runtime.js`, optional **`preamble`** libs (`sed` → `lib/sed-engine.js`, `awk` → `lib/awk-engine.js`, **`man`** → `lib/man-render.js`), then `src/<name>.js`; writes to `kernel/bin/<name>` and `packages/bare-os-seeder/kernel/bin/<name>`. CLI: `node build.mjs` when executed as main.
|
||||
- **[packages/bare-os-coreutils/build.mjs](packages/bare-os-coreutils/build.mjs)** — `export async function build()`: runs **`scripts/build-man-db.mjs`** (validates **`man/pages/*.json`**, writes **`kernel/share/man/man.json`** and the same path under **`packages/bare-os-seeder/kernel/share/man/`**); then for each command concatenates `lib/runtime.js`, optional **`preamble`** libs (`sed` → `lib/sed-engine.js`, `awk` → `lib/awk-engine.js`, **`man`** → `lib/man-render.js`, **`ls`** / **`dircolors`** → lscolors helpers, **`edit`** / **`nano`** → `lib/edit-*.js` + shared TUI), then `src/<name>.js` (**`nano`** reuses **`src/edit.js`**); writes to `kernel/bin/<name>` and `packages/bare-os-seeder/kernel/bin/<name>`. CLI: `node build.mjs` when executed as main.
|
||||
- **Manual pages** — Authoring: **`packages/bare-os-coreutils/man/pages/<name>.json`**; schema: **`man/schema.json`**. Optional **`examples`** (cheat.sh-style) and **`descriptionMode`**: **`preserve`** for preformatted text. **`scripts/ingest-handbook-for-man.mjs`** merges every **`handbook/*.md`** as **`man(7)`** at build time (**`man handbook`**, **`man handbook-01-introduction`**, …). Regenerate JSON stubs with **`node packages/bare-os-coreutils/scripts/seed-man-pages.mjs`**. Runtime: **`/bin/man`** reads **`/share/man/man.json`**. **Handbook:** [handbook/10-manpages-and-online-help.md](handbook/10-manpages-and-online-help.md).
|
||||
- **Commands** (sources under `src/`, same order as **`COREUTILS_COMMANDS`** in [`commands.mjs`](packages/bare-os-coreutils/lib/commands.mjs)): `awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `dircolors`, `du`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `git-pear`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `jq`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mktemp`, `mv`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `theme`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`. Each built script begins with **`BARE_OS_BIN_API`** in the concatenated prelude; root **`pretest`** runs **[`scripts/verify-kernel-seeder-parity.mjs`](scripts/verify-kernel-seeder-parity.mjs)** to keep **`kernel/bin/*`** and **`packages/bare-os-seeder/kernel/bin/*`** in sync and to require that pragma on every staged binary. Scripts are plain `async function run(ctx, argv)` using `ctx.vfs`, `ctx.drive`, `ctx.b4a`, `ctx.console`, optional `bareStdin(ctx)`, optional `ctx.runBinCommand` — no ESM `import` in `src/` (Bare-safe `AsyncFunction` load). **Booter-delegated** (stubs under `kernel/bin/`, logic in `packages/bare-os-booter/lib/`): `systemctl`, `journalctl` (bare-initd control; `bare-initctl` alias; see [handbook/04-the-booter-runtime.md](handbook/04-the-booter-runtime.md)). **Narrative reference:** [handbook/09-posix-utilities-shell-and-vfs.md](handbook/09-posix-utilities-shell-and-vfs.md).
|
||||
- **Commands** (sources under `src/`, same order as **`COREUTILS_COMMANDS`** in [`commands.mjs`](packages/bare-os-coreutils/lib/commands.mjs)): `awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `dircolors`, `du`, `edit`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `git-pear`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `jq`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mktemp`, `mv`, `nano`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `theme`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`. The interactive TTY editor is **`edit`**; **`nano`** is the same built script under **`/bin/nano`**, and the default shell maps **`nano` → `edit`** (see **`defaultShellAliases`** in [`shell.js`](packages/bare-os-booter/lib/shell.js)). Each built script begins with **`BARE_OS_BIN_API`** in the concatenated prelude; root **`pretest`** runs **[`scripts/verify-kernel-seeder-parity.mjs`](scripts/verify-kernel-seeder-parity.mjs)** to keep **`kernel/bin/*`** and **`packages/bare-os-seeder/kernel/bin/*`** in sync and to require that pragma on every staged binary. Scripts are plain `async function run(ctx, argv)` using `ctx.vfs`, `ctx.drive`, `ctx.b4a`, `ctx.console`, optional `bareStdin(ctx)`, optional `ctx.runBinCommand` — no ESM `import` in `src/` (Bare-safe `AsyncFunction` load). **Booter-delegated** (stubs under `kernel/bin/`, logic in `packages/bare-os-booter/lib/`): `systemctl`, `journalctl` (bare-initd control; `bare-initctl` alias; see [handbook/04-the-booter-runtime.md](handbook/04-the-booter-runtime.md)). **Narrative reference:** [handbook/09-posix-utilities-shell-and-vfs.md](handbook/09-posix-utilities-shell-and-vfs.md).
|
||||
|
||||
### 12.11 [packages/bare-os-booter/test.js](packages/bare-os-booter/test.js) and [test.identity.js](packages/bare-os-booter/test.identity.js)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user