+9
-21
@@ -135,7 +135,7 @@ These files are **read from disk by the seeder** and written into the system dri
|
||||
- **Behavior**:
|
||||
- Reads `/etc/os-release` from `drive`, logs UTF-8 string via `b4a.toString`.
|
||||
- Logs a one-line help string.
|
||||
- Loop: `readLine('bare-os> ')`. If `null`, break. Empty line skips. `exit` breaks. Otherwise `await execLine(t)` (booter dispatches to `/bin/<cmd>`).
|
||||
- Loop: `readLine('')` (TTY shows `[user@host:path] > ` from the booter). If `null`, break. Empty line skips. `exit` breaks. Otherwise `await execLine(t)` (booter dispatches to `/bin/<cmd>`).
|
||||
|
||||
### 9.2 [kernel/bin/echo](kernel/bin/echo)
|
||||
|
||||
@@ -314,19 +314,15 @@ Pear-safe path resolution (same idea as Holepunch [pear-rti](https://github.com/
|
||||
|
||||
**`createReadLine()`**
|
||||
|
||||
- Resolves [resolve-stdio.js](packages/bare-os-booter/lib/resolve-stdio.js) first; returns **`stdin`**, **`stdout`**, **`readLine`**, flags.
|
||||
- If `BARE_OS_SKIP_REPL === '1'`: `readLine` is `async () => null`.
|
||||
- Else tries `node:readline` `createInterface` + `question` per prompt, then `bare-readline`, then [cli-readline.js](packages/bare-os-booter/lib/cli-readline.js) stream reader.
|
||||
- On failure: warns and `readLine` → `async () => null`.
|
||||
- If `BARE_OS_SKIP_REPL === '1'`: returns `async () => null`.
|
||||
- Else tries `node:readline` `createInterface` + `question` per prompt.
|
||||
- On failure: warns and returns `async () => null`.
|
||||
|
||||
**`executeKernel(disk, store, swarm, initSource)`** (`store`/`swarm` unused but kept for signature symmetry / future use)
|
||||
|
||||
- Builds `shellEnv` (`HOME`, `PATH=/bin`, `USER`, `PWD`, `SHELL`, `HOSTNAME`, `UID`/`GID`/`GROUP`, `0`) and `createVfs(drive, personalDrive, shellEnv)` → `ctx.vfs` (same `env` object as `ctx.env`).
|
||||
- **`createReadLine()`** returns `stdin` / `stdout` / fallback `readLine` as above.
|
||||
- **`writeScreen(str)`** — ANSI / clear to session stdout, then `console.clear` if present.
|
||||
- **Fish-style TTY editor** — if interactive, `BARE_OS_FISH !== '0'`, and `createFishReadLine(ctx, { stdin, stdout, writeScreen })` succeeds (`stdin.isTTY` + `setRawMode`), `ctx.readLine` uses that implementation (raw keyboard, ghost suggestions, tab cycling, Ctrl+R history search, multiline `\`, syntax colors, history on personal drive **`/.bare_history`** in `#timestamp:command` format). Otherwise `ctx.readLine` uses the classic `readLine` from `createReadLine()`.
|
||||
- **`finally`**: `disableFishRawMode(stdin)` after the kernel returns so the process TTY is restored.
|
||||
- Builds `ctx`: `disk`, `drive`, `personalDrive`, `vfs`, `env`, `console`, `b4a`, `topic: topicKey()`, `readLine`, `writeScreen`, `execLine` → `execShellLine(ctx, line)` (returns `'ok'` or `'exit'`).
|
||||
- **`createReadLine()`** always resolves stdio first and returns `stdout` (may be `null`) alongside `readLine` so the kernel can write to the **same** stream as the REPL (including `bare-stdio` under Pear).
|
||||
- Builds `ctx`: `disk`, `drive`, `personalDrive`, `vfs`, `env`, `console`, `b4a`, `topic: topicKey()`, `readLine`, **`writeScreen(str)`** (ANSI / clear to session stdout, then `console.clear` if present), `execLine` → `execShellLine(ctx, line)` (returns `'ok'` or `'exit'`).
|
||||
- Sets `disk.os` with stub `searchLocal` ([]) and `execRpc` (`''`).
|
||||
- `runKernelFromSource(b4a.toString(initSource), ctx)`.
|
||||
|
||||
@@ -344,7 +340,7 @@ Pear-safe path resolution (same idea as Holepunch [pear-rti](https://github.com/
|
||||
**`main()`**
|
||||
|
||||
- `Corestore(bootStorePath())`, `Hyperswarm`, `SwarmDisk`, join `topicKey()`.
|
||||
- Wait loop: 500ms steps until `disk.peers.size > 0` or `BARE_OS_PEER_WAIT_MS` (default 60000, same as boot budget).
|
||||
- Wait loop: 500ms steps until `disk.peers.size > 0` or `BARE_OS_PEER_WAIT_MS` (default 8000).
|
||||
- If peers: `bootFromPeers`; else `bootLocal`.
|
||||
- **`finally`**: close `personalDrive`, `disk.drive`, `swarm.destroy()`, `store.close()` (each in try/catch).
|
||||
|
||||
@@ -422,7 +418,6 @@ Tests:
|
||||
5. **`createVfs`** — write under `$HOME` lands on personal drive only.
|
||||
6. **Shell** — `tokenize`, `expandWord`, `execShellLine` (`cd`, external from `/bin`).
|
||||
7. **Tier-1 `cat`** — loads concatenated script from repo `kernel/bin/cat`.
|
||||
8. **Fish history helpers** — parse/serialize, ghost, substring search, `fuzzyMatch` / `SHELL_BUILTINS`.
|
||||
|
||||
Uses Node builtins: `node:fs`, `node:path`, `node:url`.
|
||||
|
||||
@@ -430,11 +425,6 @@ Uses Node builtins: `node:fs`, `node:path`, `node:url`.
|
||||
|
||||
- **[packages/bare-os-seeder/index.js](packages/bare-os-seeder/index.js)** — when not on Pear (`import.meta.url` is `file:`), dynamic `import('../bare-os-coreutils/build.mjs')` then `await build()`. Pear has no sibling `bare-os-coreutils` in the bundle; use pre-built files under vendored `kernel/bin/`.
|
||||
|
||||
### 12.11 Fish-style line editor
|
||||
|
||||
- **[packages/bare-os-booter/lib/fish-readline.js](packages/bare-os-booter/lib/fish-readline.js)** — `createFishReadLine(ctx, opts)` → `(prompt) => Promise<string | null>` or `null` if not a TTY. Ports patterns from Swarm-NodeOS [hyper-os/os/init.js](file:///Users/raven/dev/hyper-os/os/init.js) `startShell`: green `[user@host:path] > ` prompt with `~`, gray **ghost** from history, **Right** accepts ghost, **Tab** cycles completions (`/bin` + shell builtins + `vfs` paths + `$VAR` + flag map), cyan known commands / yellow paths / magenta `$VAR`, **Up/Down** history, **Ctrl+R** reverse search, **Ctrl+L** via `writeScreen`, **Ctrl+D** EOF on empty line, **Ctrl+C** reset line, multiline `\`. Executes full lines through the normal `execShellLine` path (no duplicate pipe splitting).
|
||||
- **[packages/bare-os-booter/lib/fish-history.js](packages/bare-os-booter/lib/fish-history.js)** — `parseHistoryFile`, `serializeHistory`, `dedupeHistory`, `ghostFromHistory`, `searchHistorySubstring` (unit-tested).
|
||||
|
||||
---
|
||||
|
||||
## 13. End-to-end data flow
|
||||
@@ -467,10 +457,8 @@ sequenceDiagram
|
||||
| `BARE_OS_SEED_STORE` | Seeder | Corestore directory (default: `repo/data/corestore-seeder`) |
|
||||
| `BARE_OS_BOOT_STORE` | Booter | Corestore for boot side (default: `repo/data/corestore-booter`) |
|
||||
| `BARE_OS_LOCAL_SEED` | Booter | Corestore path for local boot (default: `repo/data/corestore-seeder`) |
|
||||
| `BARE_OS_PEER_WAIT_MS` | Booter | Max ms to wait for ≥1 peer before local boot (default `60000`) |
|
||||
| `BARE_OS_PEER_WAIT_MS` | Booter | Max ms to wait for ≥1 peer before local boot (default `8000`) |
|
||||
| `BARE_OS_SKIP_REPL` | Booter | If `1`, readline returns null — non-interactive exit |
|
||||
| `BARE_OS_FISH` | Booter | If `0`, disable Fish-style raw TTY line editor (use classic readline) |
|
||||
| `BARE_OS_FISH_HISTORY_MAX` | Booter / fish-readline | Max history entries persisted to `/.bare_history` (default `1000`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -479,7 +467,7 @@ sequenceDiagram
|
||||
| Area | Status |
|
||||
|------|--------|
|
||||
| **VFS** | Two-drive unified paths; `$HOME` → personal Hyperdrive; mutations outside `$HOME` rejected. |
|
||||
| **Shell** | Quoting, `|`, `>`/`>>`/`<`, `cd`, `export`, `exit`, `$VAR` / `${VAR}`, `$PATH` for `/bin` discovery. On a real TTY, optional Fish-style line editor (§12.11). No `&&`/`||`, job control, or full POSIX `sh` grammar. |
|
||||
| **Shell** | Quoting, `|`, `>`/`>>`/`<`, `cd`, `export`, `exit`, `$VAR` / `${VAR}`, `$PATH` for `/bin` discovery. No `&&`/`||`, job control, or full POSIX `sh` grammar. |
|
||||
| **Hyperdrive limits** | No real `chmod`/`chown`; executable bit only via `put(..., { executable })` where supported. |
|
||||
| **Utilities** | Tier-1 JS ports in `/bin` (see §12.8). `test` sets `ctx.exitCode`; the shell does not yet branch on it for `&&`. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user