Skip to content

Commit ae46506

Browse files
Harden Diogenes native runtime installation
1 parent c438d81 commit ae46506

28 files changed

Lines changed: 601 additions & 223 deletions

‎.env.example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ ULYSSES_COLIBRI_HY3_MODEL=${HOME}/colibri-models/UnderstandLing--Hy3-colibri-int
100100
# 3.6.0). Set an absolute override only when deliberately testing another
101101
# compiled lock. Remote SSH targets keep their own normal package flow.
102102
# ULYSSES_VLLM_LOCK=/absolute/path/to/an/alternate.lock
103+
# Set ULYSSES_VLLM_LOCK=disabled only when deliberately opting into the
104+
# upstream/latest vLLM pip flow. Cookbook will then show normal upgrade actions
105+
# instead of the exact lock-backed Reconcile action.
103106

104107
# ============================================================
105108
# Auth & Security

‎bun.lock‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bunsetup.sh‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
6+
MODE=install
7+
8+
usage() {
9+
cat <<'EOF'
10+
Usage: ./bunsetup.sh [--check|--update|--audit]
11+
12+
default install the exact versions in bun.lock
13+
--check show outdated packages without changing the lockfile
14+
--update update package.json-compatible dependencies and bun.lock
15+
--audit run Bun's package vulnerability audit
16+
17+
This project uses Bun directly. Node, npm, pnpm, and Yarn are not required.
18+
EOF
19+
}
20+
21+
case "${1:-}" in
22+
'') ;;
23+
--check) MODE=check ;;
24+
--update) MODE=update ;;
25+
--audit) MODE=audit ;;
26+
-h|--help) usage; exit 0 ;;
27+
*) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
28+
esac
29+
30+
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
31+
export DO_NOT_TRACK=1
32+
BUN="${SANDWICH_BUN:-$BUN_INSTALL/bin/bun}"
33+
[[ -x "$BUN" ]] || BUN="$(command -v bun 2>/dev/null || true)"
34+
[[ -n "$BUN" && -x "$BUN" ]] || {
35+
echo "Bun was not found. Install Sandwich at the configured services root first." >&2
36+
exit 1
37+
}
38+
39+
cd "$ROOT"
40+
case "$MODE" in
41+
install)
42+
[[ -f bun.lock ]] || {
43+
echo "bun.lock is missing; a source checkout must include its reviewed lockfile." >&2
44+
exit 1
45+
}
46+
"$BUN" install --frozen-lockfile
47+
;;
48+
check) "$BUN" outdated ;;
49+
update)
50+
"$BUN" update
51+
"$BUN" audit
52+
;;
53+
audit) "$BUN" audit ;;
54+
esac

‎components/sandwich/.gitignore‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Sandwich keeps runtime state outside the source tree. These entries also
2+
# protect a checkout if a tool ignores the configured state/cache locations.
3+
.cache/
4+
.state/
5+
.tmp/
6+
.sandbox/
7+
node_modules/
8+
bun-error.log
9+
*.log
10+
*.bak
11+
*.orig
12+
*.rej
13+
.DS_Store

‎components/sandwich/README.md‎

Lines changed: 17 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,28 @@
11
# Sandwich
22

3-
A fail-loud Bun compatibility layer for systems that intentionally do not
4-
install Node.js, npm, pnpm, or Yarn.
3+
An oven factory for JavaScript: a direct Node replacement that runs on
4+
delicious Bun only.
55

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`. Its preload also resolves generated base64 JavaScript data
15-
modules used by Node-oriented test harnesses. Bun does not support general URL
16-
imports; oversized generated modules should use an ordinary temporary ESM file.
17-
- `npx` executes packages through `bun x --bun`.
18-
- common npm, pnpm, and Yarn operations translate to tested Bun commands.
19-
- `npm ci` requires `bun.lock` and uses `bun install --frozen-lockfile`.
20-
- unsupported dependency semantics fail loudly.
21-
- Bun telemetry and crash uploads are disabled.
22-
- installation is user-scoped, previewable, idempotent, and does not restart
23-
services.
24-
25-
Sandwich does not install Bun and does not remove an existing Node runtime.
26-
Install or update Bun through Bun's supported installer first, then let
27-
Sandwich control command resolution at the user level.
28-
29-
## Layout
30-
31-
- `bin/`: the canonical `sandwich` command and compatibility façades
32-
- `manifest.json`: versioned operations consumed by Diogenes
33-
- `lib/`: shared Bun discovery and translation helpers
34-
- `config/`: managed Bun and shell configuration
35-
- `scripts/install-user.sh`: previewable user-level installer
36-
- `scripts/apply-hermes-maintenance.sh`: guarded Hermes integration profile
37-
- `scripts/refresh-hermes-artifacts.sh`: maintainer-only Hermes profile refresh
38-
- `patches/` and `config/hermes.*`: version-pinned Hermes updater artifacts
39-
- `tests/compat.sh`: offline compatibility contract
40-
41-
## Install
42-
43-
Preview all destinations without changing the system:
6+
Sandwich makes `node`, `npm`, `npx`, `pnpm`, `yarn`, and `corepack` resolve to
7+
tested Bun translations. It supports workspaces, global installs, lifecycle
8+
trust, frozen lockfiles, and the Hermes update/build path without installing a
9+
second JavaScript runtime.
4410

4511
```bash
46-
./scripts/install-user.sh --check
47-
```
48-
49-
Apply the user-level configuration:
50-
51-
```bash
52-
./scripts/install-user.sh --apply
12+
git clone https://github.com/CommanderTurtle/sandwich.git
13+
cd sandwich
14+
./install.sh
5315
source ~/.bashrc
5416
sandwich doctor
5517
```
5618

57-
The installer creates timestamped backups under
58-
`~/.local/state/sandwich/backups`, installs user-owned links in
59-
`~/.local/bin`, and replaces only the marked Sandwich block in `~/.bashrc`.
60-
It preserves all unrelated PATH entries and shell
61-
configuration.
62-
63-
## Environment
64-
65-
Sandwich recognizes:
66-
67-
- `SANDWICH_BUN`: explicit Bun executable
68-
- `SANDWICH_NPM_VERSION`: npm compatibility version reported to tooling
69-
- `SANDWICH_PNPM_VERSION`: pnpm compatibility version
70-
- `SANDWICH_YARN_VERSION`: Yarn compatibility version
71-
- `BUN_INSTALL`: Bun installation root, normally `~/.bun`
72-
73-
## Hermes integration profile
74-
75-
Sandwich includes the tested Hermes updater repair. The profile keeps the
76-
Hermes root, state directory, protected production roots, and upstream
77-
reference configurable:
78-
79-
- `HERMES_LIVE_DIR`, default `~/.hermes/hermes-agent`
80-
- `HERMES_UPSTREAM_REF`, default `origin/main`
81-
- `SANDWICH_STATE_ROOT`, default `~/.local/state/sandwich`
82-
- `SANDWICH_PROTECTED_ROOTS`, a colon-separated list defaulting to
83-
`~/Hermes:~/Odysseus`
84-
85-
Previewing the profile is read-only and refuses while the Hermes worktree or a
86-
protected Compose project is active:
87-
88-
```bash
89-
./scripts/apply-hermes-maintenance.sh --check
90-
```
91-
92-
`--apply` is intentionally maintenance-window-only. It requires an exact
93-
Hermes commit match, rejects unrelated tracked changes, backs up the files it
94-
will replace, applies the pinned patch and Bun artifacts, performs frozen
95-
workspace installs, and rebuilds the TUI and Web workspaces. It never restarts
96-
Hermes or another service. `--allow-active` is an explicit human override, not
97-
an automatic Diogenes action.
98-
99-
After a reviewed upstream Hermes update, maintainers can refresh the profile
100-
against an explicitly selected upstream reference:
19+
Preview with `./install.sh --check`. Update Bun with
20+
`./install.sh --upgrade-bun`. Existing user shims and shell configuration are
21+
backed up under `~/.local/state/sandwich`.
10122

102-
```bash
103-
HERMES_UPSTREAM_REF=origin/main \
104-
./scripts/refresh-hermes-artifacts.sh
105-
```
106-
107-
## Contract
108-
109-
Run the offline compatibility suite at any time:
110-
111-
```bash
112-
./tests/compat.sh
113-
```
23+
Hermes support is baked in. On a reviewed maintenance window, run
24+
`./install.sh --with-hermes`; afterwards the normal `hermes update` path uses
25+
the pinned Bun workspace and UI/TUI build integration.
11426

115-
Use `bun` and `bun x` directly when Bun-native behavior is desired. Add a
116-
tested translation before relying on a package-manager command that Sandwich
117-
currently rejects.
27+
Sandwich fails loudly when another package manager’s semantics cannot be
28+
represented honestly. Runtime state and backups never live in this repository.

‎components/sandwich/bin/corepack‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
source "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")/../lib/common.sh"
4+
5+
case "${1:-}" in
6+
--version|-v)
7+
printf 'sandwich-%s\n' "$("$SANDWICH_ROOT/bin/sandwich" --version)"
8+
;;
9+
enable)
10+
# Sandwich installs deterministic user shims itself. Corepack's enable
11+
# operation is therefore already satisfied.
12+
"$SANDWICH_ROOT/scripts/install-user.sh" --apply
13+
;;
14+
disable)
15+
bs_die "corepack disable would remove Sandwich-owned shims; use the recorded installer backup explicitly"
16+
;;
17+
prepare|install|use|up)
18+
bs_die "Corepack package-manager downloads are disabled; Bun is the only package manager"
19+
;;
20+
--help|-h|'')
21+
cat <<'EOF'
22+
Sandwich Corepack compatibility
23+
24+
corepack enable refresh Sandwich shims
25+
corepack --version report the Sandwich compatibility version
26+
27+
Package-manager downloads are intentionally disabled. Use bun, bunx, or the
28+
Sandwich npm/npx/pnpm/yarn compatibility commands.
29+
EOF
30+
;;
31+
*)
32+
bs_die "unsupported corepack command '$1'; Bun is the only package manager"
33+
;;
34+
esac

‎components/sandwich/bin/sandwich‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,28 @@ doctor() {
1717
printf ' globalbin: %s\n' "$BUN_INSTALL_BIN"
1818
printf ' telemetry: DO_NOT_TRACK=%s\n' "${DO_NOT_TRACK:-unset}"
1919

20-
for name in sandwich node npm npx pnpm yarn; do
20+
for name in sandwich node npm npx pnpm yarn corepack; do
2121
command_path="$(command -v "$name" 2>/dev/null || true)"
2222
printf ' %-14s %s\n' "$name:" "${command_path:-missing}"
2323
if [[ -z "$command_path" || "$(readlink -f -- "$command_path")" != "$SANDWICH_ROOT/bin/$name" ]]; then
2424
failures=$((failures + 1))
2525
fi
2626
done
2727

28+
printf ' source: %s\n' "$SANDWICH_ROOT"
29+
for name in node npm npx pnpm yarn corepack; do
30+
system_path=""
31+
for candidate in "/usr/local/bin/$name" "/usr/bin/$name" "/bin/$name"; do
32+
if [[ -e "$candidate" || -L "$candidate" ]]; then
33+
system_path="$candidate"
34+
break
35+
fi
36+
done
37+
if [[ -n "$system_path" ]]; then
38+
printf ' shadowed: %-8s %s\n' "$name" "$system_path"
39+
fi
40+
done
41+
2842
if [[ -f "$HOME/package.json" ]]; then
2943
printf ' warning: %s is a package root (likely accidental non-global installs)\n' "$HOME/package.json"
3044
fi
@@ -44,7 +58,7 @@ case "${1:-doctor}" in
4458
doctor
4559
;;
4660
version|--version|-v)
47-
printf '%s\n' '0.2.0'
61+
printf '%s\n' '0.3.0'
4862
;;
4963
help|--help|-h)
5064
printf '%s\n' 'usage: sandwich [doctor|version|help]'

‎components/sandwich/install.sh‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
6+
mode=apply
7+
upgrade_bun=0
8+
with_hermes=0
9+
10+
usage() {
11+
cat <<'EOF'
12+
Usage: ./install.sh [--check] [--upgrade-bun] [--with-hermes]
13+
14+
--check inspect the install without changing anything
15+
--upgrade-bun update an existing Bun stable installation first
16+
--with-hermes apply the pinned native-Bun Hermes update profile
17+
18+
The default install is user-scoped. Existing command shims and shell files are
19+
backed up under ~/.local/state/sandwich before replacement.
20+
EOF
21+
}
22+
23+
while (($#)); do
24+
case "$1" in
25+
--check) mode=check ;;
26+
--upgrade-bun) upgrade_bun=1 ;;
27+
--with-hermes) with_hermes=1 ;;
28+
-h|--help) usage; exit 0 ;;
29+
*) printf 'sandwich: unknown option: %s\n' "$1" >&2; usage >&2; exit 2 ;;
30+
esac
31+
shift
32+
done
33+
34+
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
35+
export DO_NOT_TRACK=1
36+
bun="$BUN_INSTALL/bin/bun"
37+
38+
if [[ "$mode" == check ]]; then
39+
if [[ -x "$bun" ]]; then
40+
printf 'Bun %s (%s)\n' "$("$bun" --version)" "$("$bun" --revision)"
41+
else
42+
printf 'Bun is not installed at %s\n' "$bun"
43+
fi
44+
"$root/scripts/install-user.sh" --check
45+
if [[ "$with_hermes" -eq 1 ]]; then
46+
"$root/scripts/apply-hermes-maintenance.sh" --check
47+
fi
48+
exit 0
49+
fi
50+
51+
if [[ ! -x "$bun" ]]; then
52+
command -v curl >/dev/null 2>&1 || {
53+
echo 'sandwich: curl is required to install Bun' >&2
54+
exit 1
55+
}
56+
printf 'Installing Bun from the official installer...\n'
57+
curl -fsSL https://bun.com/install | bash
58+
elif [[ "$upgrade_bun" -eq 1 ]]; then
59+
"$bun" upgrade --stable
60+
fi
61+
62+
"$root/scripts/install-user.sh" --apply
63+
if [[ "$with_hermes" -eq 1 ]]; then
64+
"$root/scripts/apply-hermes-maintenance.sh" --apply
65+
fi
66+
67+
printf '\nSandwich is ready. Open a new shell or run: source ~/.bashrc\n'

‎components/sandwich/manifest.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"schema_version": "sandwich.component.v1",
33
"id": "sandwich",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"runtime": "bun",
66
"install_scope": "user",
7+
"repository": "https://github.com/CommanderTurtle/sandwich.git",
78
"entrypoints": {
89
"sandwich": "bin/sandwich",
910
"node": "bin/node",
1011
"npm": "bin/npm",
1112
"npx": "bin/npx",
1213
"pnpm": "bin/pnpm",
13-
"yarn": "bin/yarn"
14+
"yarn": "bin/yarn",
15+
"corepack": "bin/corepack"
1416
},
1517
"operations": {
1618
"doctor": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
35b1e578621af70c5dbffd2a6fd6c534a0a1a4b7
1+
07e97d2f5dc3d2092cfe693ef07b2527a36cd2d8

0 commit comments

Comments
 (0)