Docs+AutoPass patch

This commit is contained in:
2026-05-27 00:00:13 +00:00
parent 21580f21bc
commit 82dd5855b6
32 changed files with 7141 additions and 6691 deletions
+74 -28
View File
@@ -1,65 +1,111 @@
# Chapter 7 — Apps beyond the shell (what is realistic today)
# Chapter 7 — Apps beyond the shell
Bare OS does not have an app store, sandboxed widgets, or a second GUI runtime inside the image. An **application** here is usually:
Bare OS now ships a **P2P App Store** client (`/bin/appstore`) and **guest Pear tooling** (`/bin/pear`) so “applications” can be authored, published, installed, and launched **inside the shell** without a second GUI runtime.
- a **workflow** built from the **shell**, **`/bin`** tools, and files on the **personal** drive; or
- a **custom kernel** + utilities; or
- a **host Pear app** that changes boot behavior.
This chapter orients you without over-promising.
This chapter orients you to what is **real today** versus what still requires a **host Pear** process.
---
## The default “app”: shell + `/bin` + git
## Three application models
Most user goals are met by:
| Model | When to use | Entry points |
| --- | --- | --- |
| **Shell + `/bin` + files** | Scripts, pipelines, git on the VFS | `$HOME`, `run(ctx, argv)` utilities |
| **Pear app (guest)** | P2P apps with `pear://` distribution | `pear init``stage``release``appstore install``launch` |
| **Host Pear app** | Custom booter/seeder images, native addons, desktop Pear | Repo root `pear run`, new Pear project (Chapter 1) |
Most **end-user Pear apps** you build in Bare OS follow the **guest Pear + App Store** row. See **[Guest Pear and App Store workflow](../docs/guides/guest-pear-and-appstore-workflow.md)** for copy-paste commands.
---
## Guest Pear pipeline (`/bin/pear`)
Implemented in `packages/bare-os-coreutils` (`pear.js`, `pear-stage.js`, `pear-release.js`).
```bash
pear init
cd ~/pear-projects/my-pear-app
pear stage
login # unlock identity / HDMS
pear release .
pear seed .
```
- **`pear stage`** — Writes `<project>/.pear/stage/` (`sources/`, `package.json`, `app.bundle.js`, `stage.json`).
- **`pear release`** — Mirrors the stage tree onto a writable HDMS mount (`/mnt/pear-<name>/`) and prints **`pear://`** links (uses HDMS registry keys; does not require host Pear CLI).
- **`pear seed`** — Best-effort Hyperswarm flush so peers can replicate the release drive.
Release metadata is stored in **`<project>/.pear/release.json`**.
---
## P2P App Store (`/bin/appstore`)
Implemented in `packages/bare-os-coreutils` (`appstore.js`, `appstore-pear.js`, `p2p-suite.js` preamble).
```bash
appstore install my-app pear://0.<length>.<key> --yes
appstore launch my-app
```
- **`install`** — Fetches the `pear://` release tree (local HDMS mount with matching key, or ephemeral readonly HDMS fetch) into `~/.appstore/packages/<name>/` (or `/mnt/appstore/packages/<name>/` when the store HDMS drive is mounted).
- **`launch`** — Runs the materialized entry script (`sources/index.js` or `package.json` `main`) in the guest shell; output appears on **`ctx.console`**.
- **`update`** — Re-fetches from the packages stored `pearLink`.
- **`setup`** — Prints how to create/mount the optional **`appstore`** HDMS label.
Design and trust model: **[p2p-app-store.md](../docs/design/p2p-app-store.md)**.
---
## The default platform: shell + `/bin` + git
Workflows that are not Pear-packaged still use:
- Scripts in **`$HOME`** (`run(ctx, argv)`).
- Pipelines and redirection (simulated stdin/stdout).
- **`git`** for repositories on the VFS (see [Handbook ch.8](../handbook/08-git-on-bare-os.md)).
That is the **intended** application platform for end users.
- **`git`** on the VFS ([Handbook ch.8](../handbook/08-git-on-bare-os.md)).
---
## initd and background flavor
## initd, cron, and services
The booter registers **initd**-style disposers via [`bare-initd.js`](../packages/bare-os-booter/lib/bare-initd.js). The stock system uses this lightly (e.g. kernel logger). **Extending** this usually means **host** booter changes: register a start function during `executeKernel`, not from arbitrary `/bin` scripts.
**initd** — User units under `~/.config/bare-os/units/`. `appstore services` can generate initd unit stubs for packages that declare a service manifest (see `appstore.js`).
Read [`bare-initd.js`](../packages/bare-os-booter/lib/bare-initd.js) before adding long-running tasks—teardown must be explicit (`stopBareInitd`).
---
## Cron and timers
**`bare-cron`** reads **`/etc/bare-os/crontab`** on the system image (if present), then the users **`~/.crontab`** on the personal drive; invalid lines are logged and skipped. **`crontab`** installs/lists/removes the **user** file (requires login). Timer drop-ins under `**~/.config/bare-os/timers/*.timer`** (**`[Timer]`** `**OnCalendar=**` + `**ExecLine=`**) merge into the same minute scheduler. See [Handbook ch.4](../handbook/04-the-booter-runtime.md) and [Developer guide ch.11](11-kernel-pear-cookbook.md).
**Socket-shaped activation:** initd unit drop-ins can set **`SocketActivationIpc=<fifo-name>`** so a services **`start()`** runs when something first **`readFile`**s that logical FIFO under **`/run/bare-os/ipc/`** (see **`bare-initd.js`**).
**Timers / cron** — See [Chapter 11](11-kernel-pear-cookbook.md) and handbook ch.4.
---
## HDMS and `/mnt`
After identity unlock, optional **HDMS** mounts may appear under **`/mnt`**. Utilities use **`ctx.vfs`**; HDMS integration is advanced and covered narratively in the handbook (identity + HDMS chapter). User scripts should prefer **`vfs.readFile`** / **`writeFile`** over hard-coding drive objects.
After **login**, HDMS mounts extra Hyperdrives under **`/mnt/<label>/`**. Pear releases use labels like **`pear-my-pear-app`**. The App Store prefers label **`appstore`** at **`/mnt/appstore`**.
User scripts should use **`ctx.vfs`** rather than hard-coding drive handles.
---
## Replacing the kernel
A heavier “app” might ship a **different `/boot/init.js**`—for example a menu-driven UI using **`readLine`** or a non-interactive worker when `**BARE_OS_SKIP_REPL=1`**. You still have the **single JavaScript realm** per session; there is no fork into a second Bare process from inside the image.
Shipping a different **`/boot/init.js`** remains a **kernel image** change (non-interactive worker, custom menu, etc.). Pear **user apps** do not require replacing the stock kernel.
---
## When you actually need a new Pear app
## When you need a new host Pear app
If you need **multiple OS images**, **custom networking**, or **native addons** not suitable for `AsyncFunction` utilities, create a **new Pear application** that embeds or forks the booter pattern—this is **host** development (Chapter 1), not `/bin` development.
Use a **new Pear application** on the host when you need:
- A different system image or booter embedding model
- Native addons unsuitable for `AsyncFunction` `/bin` scripts
- Desktop/mobile Pear runtime features
Guest **`pear release`** still produces valid **`pear://`** links consumable by host **`pear run`**.
---
## See also
- [Guest Pear and App Store workflow](../docs/guides/guest-pear-and-appstore-workflow.md)
- [Chapter 12 — Bare modules and Pear](12-bare-modules-and-pear-ecosystem.md)
- [Chapter 3 — Kernel](03-kernel-boot-init.md)
- [Handbook — Booter runtime](../handbook/04-the-booter-runtime.md)
- [Handbook — Identity, vault, HDMS](../handbook/05-identity-vault-and-hdms.md)
---
@@ -54,6 +54,7 @@ Storage write limits use existing hooks (**`BARE_OS_VFS_QUOTA_*`**, **`BARE_OS_H
## Pear / Git / HTTP
- **Guest Pear apps** — Author, release, install, and launch Pear apps entirely in the shell: see **[Guest Pear and App Store workflow](../docs/guides/guest-pear-and-appstore-workflow.md)** (`/bin/pear`, `/bin/appstore`). Host **`pear run pear://…`** remains for full Pear desktop/runtime on a Pear-capable machine.
- **Mirror-drive hints** — `ctx.bareOsEmitMirrorDriveHint({ label?, key? })` emits `bare-os:mirror-drive-hint` on Node-style hosts for mirror-drivestyle workflows (labels/keys only; trust boundaries unchanged).
- **Release metadata** — Host can set `BARE_OS_PEAR_CHANNEL`, `BARE_OS_PEAR_RELEASE`, and `BARE_OS_IMAGE_DIGEST`; they appear in `/run/bare-os/boot.json`.
- **`ctx.bareOsRequestPearReload()`** — Returns hints and env strings; the host `**pear-runtime` / `pear-runtime-updater**` must perform any real reload. A successful host reload can swap the Pear **booter** bundle so a new **`bare-module-manifest.data.mjs`** (from **`npm run sync:bare-manifest`** at staging time) takes effect; **`ctx.bareOsRequestPearReload`** does not rewrite **`ctx.bare`** in-process—expect a new guest boot for an updated host import list. Drive-only edits to **`/lib/bare/bare-module-manifest.json`** still merge bundles from the image without re-staging Pear.
@@ -76,16 +76,25 @@ This chapter ties together **Holepunch `bare-*` packages**, the **Pear** host ru
---
## New: `ctx.pear` surface (2026)
## New: `ctx.pear` surface and `/bin/pear` (2026)
In addition to `ctx.bare`, a parallel `ctx.pear` surface now exists for Pear-level development tooling.
A parallel **`ctx.pear`** surface exposes Pear-level development tooling to in-image scripts.
- Populated from the new `pearEntries` tier in the module manifest.
- Initial packages include `pear-build`, `pear-bundle`, `pear-ref`, plus re-exposed bare bundle helpers.
- Exposed via the real `/bin/pear` command (`pear info`, `pear list`, etc.).
- Full design, audit findings, and remaining implementation plan live in `docs/design/ctx-pear-surface-and-bare-audit-plan.md` and the audit notes.
- Populated from **`pearEntries`** in `bare-module-manifest.json` (`pear-build`, `pear-bundle`, `pear-ref`, `bare-bundle-compile`, …).
- Static host imports under `pear://` via `bare-os-ctx-pear-host.js` (see HDMS manager pattern — no dynamic `import("pkg")` from guest bundles).
- **`/bin/pear`**: `help`, `info`, `list`, `init`, `stage`, `release`, `seed` (`build`/`bundle` alias `stage`).
This enables creating, staging, and (with host delegates) releasing real Pear apps entirely from inside a booted Bare OS instance, with natural integration into the P2P App Store.
**Guest workflow (no host Pear CLI required for release):**
```bash
pear init && pear stage && pear release . && pear seed .
appstore install my-app pear://0.<length>.<key> --yes
appstore launch my-app
```
Full operator guide: **[docs/guides/guest-pear-and-appstore-workflow.md](../docs/guides/guest-pear-and-appstore-workflow.md)**.
Design and audit: `docs/design/ctx-pear-surface-and-bare-audit-plan.md`, `docs/audit/ctx-bare-audit-notes.md`.
---
+1 -1
View File
@@ -64,7 +64,7 @@ Full script index: [scripts/README.md](../scripts/README.md). Gate everything wi
- **[04 — User scripts and PATH resolution](04-user-scripts-and-path.md)** — `run(ctx, argv)`, shebangs, `*.js` in cwd, `./` paths, `/bin`.
- **[05 — Modules and `import`](05-modules-and-imports.md)** — Why ESM does not apply to in-image scripts; bundling and alternatives.
- **[06 — Extending `/bin` (coreutils)](06-extending-bin-coreutils.md)** — `commands.mjs`, `build.mjs`, preamble, man pages.
- **[07 — Apps beyond the shell](07-apps-beyond-the-shell.md)** — What an “app” means here; initd, cron, git, custom kernels (overview).
- **[07 — Apps beyond the shell](07-apps-beyond-the-shell.md)** — P2P App Store (`/bin/appstore`), guest Pear (`/bin/pear`), HDMS mounts; initd, cron, git.
- **[08 — Testing and debugging](08-testing-and-debugging.md)** — `npm test`, Brittle, Pear dev, common failure modes.
- **[09 — Security and trust](09-security-and-trust.md)** — System vs personal drive; eval boundaries.
- **[10 — Glossary and FAQ](10-glossary-and-faq.md)** — Quick definitions; frequent questions.