FISH style
CI / test (push) Failing after 4m58s

This commit is contained in:
Raven Scott
2026-04-02 22:57:23 -04:00
parent c337a8aaa6
commit 5991f4f8e8
8 changed files with 823 additions and 37 deletions
+18 -5
View File
@@ -314,14 +314,19 @@ Pear-safe path resolution (same idea as Holepunch [pear-rti](https://github.com/
**`createReadLine()`**
- If `BARE_OS_SKIP_REPL === '1'`: returns `async () => null`.
- Else tries `node:readline` `createInterface` + `question` per prompt.
- On failure: warns and returns `async () => null`.
- 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`.
**`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`).
- Builds `ctx`: `disk`, `drive`, `personalDrive`, `vfs`, `env`, `console`, `b4a`, `topic: topicKey()`, `readLine`, `execLine``execShellLine(ctx, line)` (returns `'ok'` or `'exit'`).
- **`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'`).
- Sets `disk.os` with stub `searchLocal` ([]) and `execRpc` (`''`).
- `runKernelFromSource(b4a.toString(initSource), ctx)`.
@@ -417,6 +422,7 @@ 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`.
@@ -424,6 +430,11 @@ 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
@@ -458,6 +469,8 @@ sequenceDiagram
| `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 `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`) |
---
@@ -466,7 +479,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. No `&&`/`||`, job control, or full POSIX `sh` grammar. |
| **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. |
| **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 `&&`. |