|
| 1 | +# Sandwich |
| 2 | + |
| 3 | +A fail-loud Bun compatibility layer for systems that intentionally do not |
| 4 | +install Node.js, npm, pnpm, or Yarn. |
| 5 | + |
| 6 | +Sandwich makes Bun the canonical JavaScript runtime and package manager while |
| 7 | +translating only the compatibility behavior it can represent honestly. |
| 8 | +Ambiguous state-changing commands fail with an explanation instead of |
| 9 | +pretending that Bun and another package manager have identical semantics. |
| 10 | + |
| 11 | +## Guarantees |
| 12 | + |
| 13 | +- `node` executes JavaScript with Bun and reports Bun's Node-compatible |
| 14 | + `process.version`. |
| 15 | +- `npx` executes packages through `bun x --bun`. |
| 16 | +- common npm, pnpm, and Yarn operations translate to tested Bun commands. |
| 17 | +- `npm ci` requires `bun.lock` and uses `bun install --frozen-lockfile`. |
| 18 | +- unsupported dependency semantics fail loudly. |
| 19 | +- Bun telemetry and crash uploads are disabled. |
| 20 | +- installation is user-scoped, previewable, idempotent, and does not restart |
| 21 | + services. |
| 22 | + |
| 23 | +Sandwich does not install Bun and does not remove an existing Node runtime. |
| 24 | +Install or update Bun through Bun's supported installer first, then let |
| 25 | +Sandwich control command resolution at the user level. |
| 26 | + |
| 27 | +## Layout |
| 28 | + |
| 29 | +- `bin/`: the canonical `sandwich` command and compatibility façades |
| 30 | +- `manifest.json`: versioned operations consumed by Ulysses |
| 31 | +- `lib/`: shared Bun discovery and translation helpers |
| 32 | +- `config/`: managed Bun and shell configuration |
| 33 | +- `scripts/install-user.sh`: previewable user-level installer |
| 34 | +- `scripts/apply-hermes-maintenance.sh`: guarded Hermes integration profile |
| 35 | +- `scripts/refresh-hermes-artifacts.sh`: maintainer-only Hermes profile refresh |
| 36 | +- `patches/` and `config/hermes.*`: version-pinned Hermes updater artifacts |
| 37 | +- `tests/compat.sh`: offline compatibility contract |
| 38 | + |
| 39 | +`bun-sovereign` remains as a backward-compatible alias for installations made |
| 40 | +before the project was renamed. |
| 41 | + |
| 42 | +## Install |
| 43 | + |
| 44 | +Preview all destinations without changing the system: |
| 45 | + |
| 46 | +```bash |
| 47 | +./scripts/install-user.sh --check |
| 48 | +``` |
| 49 | + |
| 50 | +Apply the user-level configuration: |
| 51 | + |
| 52 | +```bash |
| 53 | +./scripts/install-user.sh --apply |
| 54 | +source ~/.bashrc |
| 55 | +sandwich doctor |
| 56 | +``` |
| 57 | + |
| 58 | +The installer creates timestamped backups under |
| 59 | +`~/.local/state/sandwich/backups`, installs user-owned links in |
| 60 | +`~/.local/bin`, and replaces only the marked Sandwich or legacy Bun Sovereign |
| 61 | +block in `~/.bashrc`. It preserves all unrelated PATH entries and shell |
| 62 | +configuration. |
| 63 | + |
| 64 | +## Environment |
| 65 | + |
| 66 | +Sandwich recognizes: |
| 67 | + |
| 68 | +- `SANDWICH_BUN`: explicit Bun executable |
| 69 | +- `SANDWICH_NPM_VERSION`: npm compatibility version reported to tooling |
| 70 | +- `SANDWICH_PNPM_VERSION`: pnpm compatibility version |
| 71 | +- `SANDWICH_YARN_VERSION`: Yarn compatibility version |
| 72 | +- `BUN_INSTALL`: Bun installation root, normally `~/.bun` |
| 73 | + |
| 74 | +The former `BUN_SOVEREIGN_*` names remain accepted as compatibility fallbacks. |
| 75 | + |
| 76 | +## Hermes integration profile |
| 77 | + |
| 78 | +Sandwich includes the tested Hermes updater repair that originally shipped |
| 79 | +with Bun Sovereign. The profile keeps the Hermes root, state directory, |
| 80 | +protected production roots, and upstream reference configurable: |
| 81 | + |
| 82 | +- `HERMES_LIVE_DIR`, default `~/.hermes/hermes-agent` |
| 83 | +- `HERMES_UPSTREAM_REF`, default `origin/main` |
| 84 | +- `SANDWICH_STATE_ROOT`, default `~/.local/state/sandwich` |
| 85 | +- `SANDWICH_PROTECTED_ROOTS`, a colon-separated list defaulting to |
| 86 | + `~/Hermes:~/Odysseus` |
| 87 | + |
| 88 | +Previewing the profile is read-only and refuses while the Hermes worktree or a |
| 89 | +protected Compose project is active: |
| 90 | + |
| 91 | +```bash |
| 92 | +./scripts/apply-hermes-maintenance.sh --check |
| 93 | +``` |
| 94 | + |
| 95 | +`--apply` is intentionally maintenance-window-only. It requires an exact |
| 96 | +Hermes commit match, rejects unrelated tracked changes, backs up the files it |
| 97 | +will replace, applies the pinned patch and Bun artifacts, performs frozen |
| 98 | +workspace installs, and rebuilds the TUI and Web workspaces. It never restarts |
| 99 | +Hermes or another service. `--allow-active` is an explicit human override, not |
| 100 | +an automatic Ulysses action. |
| 101 | + |
| 102 | +After a reviewed upstream Hermes update, maintainers can refresh the profile |
| 103 | +against an explicitly selected upstream reference: |
| 104 | + |
| 105 | +```bash |
| 106 | +HERMES_UPSTREAM_REF=origin/main \ |
| 107 | + ./scripts/refresh-hermes-artifacts.sh |
| 108 | +``` |
| 109 | + |
| 110 | +## Contract |
| 111 | + |
| 112 | +Run the offline compatibility suite at any time: |
| 113 | + |
| 114 | +```bash |
| 115 | +./tests/compat.sh |
| 116 | +``` |
| 117 | + |
| 118 | +Use `bun` and `bun x` directly when Bun-native behavior is desired. Add a |
| 119 | +tested translation before relying on a package-manager command that Sandwich |
| 120 | +currently rejects. |
0 commit comments