an oven factory. node replacement that runs on delicious bread only.
Sandwich makes node, npm, npx, pnpm, yarn, and corepack resolve to
tested Bun translations. It supports workspaces, global installs, lifecycle
trust, frozen lockfiles, and foreign package-lock projects without installing a
second JavaScript runtime.
When Bun does not expose Node's experimental
node:module.stripTypeScriptTypes, Sandwich supplies its position-preserving
strip mode through the pinned Amaro implementation used by Node itself. This
lets Node-oriented loaders such as DeepSeek Harness import and strip erasable
TypeScript without modifying their installed source. Sandwich does not pretend
to provide worker isolation controls that Bun does not implement.
For DeepSeek Harness, Sandwich also bridges the private-loader call used by its zero-root user-profile watcher. Ordinary module imports and profile-file refreshes work; Node module-job inspection and module hot reload remain explicitly unsupported rather than silently approximated.
git clone https://github.com/CommanderTurtle/sandwich.git
cd sandwich
./install.sh
source ~/.bashrc
sandwich doctorFor an existing global DeepSeek Harness install, the same shim is automatic:
dsh web --port 7001 --no-openPreview with ./install.sh --check. Update Bun with
./install.sh --upgrade-bun. Existing user shims and shell configuration are
backed up under ~/.local/state/sandwich.
Run the repository installer from PowerShell:
.\windows.ps1
sandwich doctorThe script creates small ignored .cmd launchers under .windows-bin, puts
that directory first on the user PATH, and runs the canonical Sandwich Bash
entrypoints through Git for Windows. It installs no Node runtime and updates
the current PowerShell process immediately.
Hermes support is external by design. Sandwich never patches, commits, rebases,
or installs files into the official Hermes source tree. The wrapper runs the
official updater with Sandwich first on PATH, so Hermes' native node and
npm commands execute on Bun. It then rebuilds the generated UI/TUI output
against a frozen compatibility lock under ~/.local/state/sandwich/hermes.
The lock is staged only for the Bun process and removed immediately, leaving no
Bun lockfile or local compatibility commit in Hermes.
Hermes build compatibility remains fail-closed. When Bun exposes stricter optional-peer types than npm's installed layout, Sandwich accepts only a known, version-scoped declaration mismatch, still type-checks the application, and runs the real upstream build. Any additional diagnostic fails normally; no tracked Hermes source is changed.
./install.sh --with-hermes is an optional read-only verification of an
existing official Hermes install. No separate Git pull is part of the user
workflow.
sandwich doctor # verify Bun and every compatibility shim
sandwich bunRoot --all # print the Bun global root in use, then duplicates
sandwich audit # report foreign JavaScript runtimes without changing them
sandwich checkExpr # audit every Bun root, repair overrides, bun update
sandwich checkFence --dryrun # audit Cargo projects and installed binaries
sandwich checkZoo --dryrun # audit uv projects, venvs, and installed tools
sandwich hermes check # verify Hermes is an unmodified upstream checkout
sandwich hermes update # update Hermes and rebuild its Bun-compatible UI/TUI
sandwich hermes integrate # apply configured integrations, check, restart an active gateway
sandwich integrations configure # detect projects and create the local .env
sandwich integrations check # run each installed repository owner doctor
sandwich integrations reconcile # reapply and verify installed owner contracts
sandwich integrations update # update, integrate, and verify installed owners
sandwich repository audit ... # inspect one owner's source/fork/dependency state
sandwich repository update ... # prepare a verified owner branch; never push itclick to expand - verbose extra details
sandwich doctor # exact paths, runtime capability, mode
sandwich shadow # put the shims in front of PATH: node runs on Bun
sandwich unshadow # move them to the back: `which node` is the system one
sandwich inert # archive and remove the native Node install (asks for a password)
sandwich uninert # extract the archive back, exactly as it was
eval "$(sandwich shadow --shell=bash)" # activate in the current Bash shell
sandwich reshadow # re-verify and repair the shadow in place
sandwich refresh # re-read the disk: re-point drifted shim links,
# and say which directory answers node today
sandwich resolve --dry-run # inspect current stable release labels
sandwich resolve # save the labels for later invocationsMise owns the runtimes Omarchy installs (mise use -g bun@latest), so it keeps
updating them; Sandwich never copies or self-upgrades a managed runtime. The
Bun it runs on is resolved in that order: an exported SANDWICH_BUN, the
manager's copy, mise shims/bun, the command on PATH, then the Bun prefix's
own bin. A leftover binary inside the global bin directory is reported by
doctor as a foreign bin, because that directory holds the shims and leads
PATH; sandwich reshadow retires it into its backup and rewrites the links,
~/.bunfig.toml, and the shell block only where they drifted. Run
sandwich reshadow after mise upgrade, mup, or omarchy update so a
shadowed runtime is never left silently behind the manager's version.
./install.sh --upgrade-bun upgrades through Mise when Mise owns Bun and then
reapplies the same state.
doctor, shadow, unshadow, and refresh re-read the disk before they do
anything else: sandwich refresh re-points each shim link that drifted and walks
PATH from the front to name the directory that actually answers node, npm,
npx, pnpm, yarn, or corepack right now, and the other three run it first so
their own answer is about the machine as it stands. Nothing is installed and no
manager is called; rewriting ~/.bunfig.toml, the shell block, and the backups stays
sandwich reshadow's job.
Shadow and unshadow are PATH order, in both directions, and the installed block keeps
that order true. Mise holds its own tool directories ahead by re-prepending them at
every prompt, so the single PATH prepend made at shell start ends up behind the very
runtimes the shims replace. The block therefore re-applies the saved mode's order at
every prompt as well (sandwich_apply_path in PROMPT_COMMAND, or precmd under Zsh):
shadow moves the shim directories to the front, unshadow moves them to the back, so
sandwich unshadow && # which node -> ~/.local/share/mise/installs/node/latest/bin/node
sandwich shadow && # which node -> ~/.local/bin/nodeBuiltins only: no subprocess per prompt, the mode file is read with read, and
assigning PATH makes Bash forget where it last found each command, so the reversal
takes effect at the next prompt without a source. --shell emits the same reordering
for the shell you are standing in. doctor reports either direction being out of date:
a path: line naming the directory that answers when shadow is saved, or saying the
shim still answers when unshadow is saved, with sandwich reshadow as the durable fix
and the --shell line as the immediate one. sandwich reshadow treats a block that
only prepends once as drift and rewrites it.
unshadow leaves Sandwich callable either way: the shim directories are still on PATH,
just behind the system ones, so they answer only where the machine has no system command.
There the shim forwards, finds nothing, and exits 127 rather than inventing a runtime,
and doctor prints that as a note: - pnpm on a box that never installed one is a fact,
not a broken shadow. When a system command does exist, doctor prints the version its
resolved path declares (runs v26.14.0, the system command), read rather than executed.
Use --shell=zsh, --shell=fish, or --shell=powershell to print activation
code for those shells. Evaluate the emitted code in that shell (PowerShell:
sandwich shadow --shell=powershell | Out-String | Invoke-Expression). A child
program cannot change its parent shell's PATH, which is why the block does it at every
prompt instead: it never has to be sourced after mise, and --shell activation exists
only for the shell you are standing in. shadow, unshadow, inert and uninert also
accept --dry-run; nothing is removed, no manager is uninstalled, and no mise shim is
modified. hash -r (Bash) or
rehash (Zsh) clears command-location caches. An exported SANDWICH_MODE
overrides the saved mode; unset it to return to the persistent setting. The block
also defines sudo() { command sudo env PATH="$PATH" "$@"; }: sudo runs its
command through sudoers' secure_path, which never sees the two directories the
block moves, so sudo sandwich, sudo mise, and anything else installed in
them keep resolving without an absolute path and without editing root's sudoers.
A native runtime under /usr/bin may be pinned by a package dependency, and
Sandwich only reports it, never removes it: doctor prints it as retained:
with the dependents its packager names (on Arch, zed requires both nodejs
and npm), and the audit's Arch: line says the same, purging a pacman package
only when nothing requires it. The shims shadow those binaries while shadowing, so
node, npm, and npx run on Bun; unshadow is what hands them back.
PATH order can be reinforced, and the reinforcement is always stated: sandwich inert
archives the native Node install and takes it away, so a script, a build step, or an AI
agent that reaches for /usr/bin/node, /usr/bin/npm, or the code under
/usr/lib/node_modules finds nothing there and uses the shims on PATH instead. No file
mode is edited on the way in or out and ownership is never touched: root is asked for a
password only to move files, which is the whole privilege involved, and a background
process gains nothing from it either way.
The set of files is whatever the packager says the Node packages own (pacman -Ql,
falling back to dpkg -L), so the install goes as a unit and nothing belonging to
another package is disturbed: on Arch that is nodejs and npm, about 2000 files and
24 MB compressed. A gzip tar named after the moment and the packages
(20261109T0330Z--node-install--nodejs+npm.tar.gz) is written under
~/.local/state/sandwich/inert before anything is removed, then the files go, empty
directories unwind from the deepest upwards, and a what-is-this.txt is left in the
directory that held most of the install, telling whoever finds it that node, npm,
pnpm, yarn and corepack on PATH run on Bun and that npx --help prints the Bun
command in every shell. sandwich uninert extracts the archive back with mode,
ownership and timestamps intact, and because it extracts with skip-old-files, a packager
reinstall that happened in the meantime is left alone rather than downgraded; the marker
and the archive are then removed. A failure part way through cannot strand anything: the
record in ~/.config/sandwich/inert is written before the first removal and is restored
byte for byte if nothing was actually removed, and an archive that does not hold every
listed file is discarded instead of trusted.
Plain sandwich shadow and sandwich unshadow change the saved mode and move no file,
which is what keeps the mode switch safe to script; neither one archives, restores, or
extracts anything, and with the install archived unshadow only says so, because
forwarding to files that are not on disk needs sandwich uninert first.
doctor prints relocated: with the archive and marker while
the install is away, and reinstalled: with sandwich inert as the fix once the
packager puts it back; install-user.sh --reshadow reports the same drift without
deciding to archive again. Something that genuinely has to exec real Node - an extension
host, a native-module build - is simply absent while the install is archived, so
sandwich uninert is the answer, not a re-run with a different path. SANDWICH_INERT_FILES
and SANDWICH_INERT_PACKAGES override the discovery, SANDWICH_INERT_ARCHIVE moves the
archive directory, and SANDWICH_INERT_RM, SANDWICH_INERT_TAR, SANDWICH_INERT_INSTALL
replace the privileged commands for automation and tests.
Doctor separates PATH conflicts from runtime failures and prints each offender
and the expected path. Native/mise commands are valid in unshadow mode. The
Windows dispatcher checks its own Bash environment, not PowerShell aliases;
use Get-Command node,npm,npx,pnpm,yarn,corepack -All in the parent PowerShell
when investigating an outer-shell conflict.
Doctor's version numbers are re-read from the directories on every run, never
remembered and never installed: managers: names the version each manager's
install directory declares (Mise names the directory after the version and points
latest/global at it), labels: pairs each Bun compatibility label with the
version the system actually holds (disk 11.20.0 via mise, or no native pnpm on disk), and drift: appears when the running Bun is not the version the manager
declares. path: appears when PATH does not match the saved mode: a directory other
than the shims answering while shadow is saved, naming it and sandwich reshadow as the
fix, or the shim still answering while unshadow is saved, naming source ~/.bashrc and
the --shell line instead. No manager is executed to obtain
those numbers; the only thing doctor writes is a shim link that had drifted, from the
refresh it runs first. sandwich resolve remains the only thing that refreshes the
labels, and it does so from the npm registry.
The Bun global root is discovered on every run instead of assumed: an exported
BUN_INSTALL_GLOBAL_DIR always wins, then bunfig's [install] globalDir
(install-user.sh writes both ~/.bunfig.toml and its ~/.bashrc block from the
prefix it resolved, so a prefix chosen by Mise, Omarchy, or XDG survives while a
setting exported above the block stays in charge), then any install/global tree
beside a bin directory already on PATH, then the $BUN_INSTALL, ~/.bun, and
${XDG_CACHE_HOME:-~/.cache}/.bun defaults. A candidate counts only when it holds
package.json plus node_modules or a lockfile, so one root resolves unless an
older prefix is still installed. sandwich bunRoot prints that root, --all
appends the duplicates, and doctor names each duplicate, lists the packages it
still provides, and prints the bun install -g command that moves them.
checkExpr audits duplicates too, because a launcher on PATH can still execute
from one. Owners that patch globally installed packages resolve
sandwich bunRoot rather than hard-coding a prefix, so a moved prefix never
leaves a patched copy behind.
resolve fetches the stable npm latest dist-tags with a bounded request and
saves validated versions atomically in
${XDG_STATE_HOME:-~/.local/state}/sandwich/versions.tsv. These are npm/pnpm/yarn
compatibility labels, not claims those native managers are installed or
their complete APIs implemented. Registry failures leave the saved set intact.
The command also compares the running Bun with stable Bun; it does not upgrade
the runtime or change the Node API version Bun actually implements. Existing
SANDWICH_NPM_VERSION, SANDWICH_PNPM_VERSION, and SANDWICH_YARN_VERSION
environment overrides win. Corepack continues to identify itself as Sandwich.
There is no idle/background polling. Mode is stored under
${XDG_CONFIG_HOME:-~/.config}/sandwich/mode; SANDWICH_STATE_HOME and
SANDWICH_CONFIG_HOME can override these Sandwich-specific directories.
Localflame, Hermes Workspace, Context Mode, Camofox Browser, Camofox MCP,
Codebase Memory, Librarian, Leetcoder, Retrieval, and Persephone keep ownership
of their own harness configuration. Sandwich only invokes their checked-in
scripts in the numeric order configured in .env. It does not copy their MCP definitions, skills,
hooks, profiles, or generated state.
sandwich integrations check and reconcile skip owners that are not
installed. Add --strict when this workstation's complete roster is required.
Every action accepts --dry-run to print the exact owner entrypoints without
running them. None of the owner doctors contacts Firecrawl or starts a model.
Update Hermes and reapply integrations as two explicit workloads:
sandwich hermes update && sandwich hermes integrateThe updater runs the official Hermes updater and preserves the existing Bun dependency/build recovery. It does not run project integration scripts. The integration command runs each enabled project's integrator followed by its check, then Sandwich's doctor, and restarts the default gateway only if it was active before the update (or before integration when run on its own). A failed integration retains the pending gateway state for a retry.
On the first interactive integration run without .env, Sandwich detects
integration entrypoints under HERMES_PROJECTS_DIR (default ~/Hermes), plus
Localflame at LOCALFLAME_ROOT (default ~/Deepseek/localflame), and asks Y/N
for each project. sandwich integrations configure can also run this setup
directly. Noninteractive runs require a configured file; checks and dry runs
never create one. The local .env is ignored by Git. .env-example documents
the fields, and SANDWICH_ENV_FILE selects another configuration file.
Add PROJECT_1, PROJECT_2, and as many further numbered entries as needed.
Each declares a directory, an enabled flag, and repository-relative integrate,
check, and update scripts. Numbers determine execution order and may have gaps.
Optional argument arrays pass the owner's own harness selections and options;
with no arguments its existing defaults are preserved. Harness configuration,
including OMP and DSH settings, remains in each owning project.
sandwich checkExpr starts at ~/.bun/install/global, finds each user-owned
project with a Bun lockfile, and runs bun audit. Vulnerable packages are added
to (or refreshed inside) that project's top-level overrides block before a
normal bun update. Sandwich selects the newest non-vulnerable release that
still satisfies every installed consumer's declared range. It also repairs a
stale override that breaks a directly installed application's declared range
when one compatible release can satisfy all consumers and an isolated audit
confirms that release is clean; it will report an unresolved advisory instead
of forcing an API-incompatible major.
Existing unrelated overrides are preserved. Sandwich does not invoke a project
build or trust blocked dependency scripts; it reports the project's build hooks
and tells you when bun pm untrusted needs review.
Use sandwich checkExpr --dryrun to print the proposed overrides without
changing manifests, locks, or installed modules. --forceful (-f) drops the
declared-range gate: when a version is manually declared so that no published
release satisfies every installed consumer, the newest published non-vulnerable
release goes into overrides anyway and bun update still runs, because the
overrides block outranks declared ranges at resolution time. Combined with
--dryrun it prints that package as a proposed upgrade instead of an
unresolved advisory.
sandwich checkExpr --deep explains a blocker. For every package it cannot place
it searches this project's GitHub repository, then the package's own repository,
at /issues?q=<package> with filters left off, takes the top result, and cats
that conversation after removing GitHub's page chrome. It reads pages through the
firecrawl CLI and the npm registry metadata only: no package file is ever
downloaded. --deep exits nonzero when nothing was blocked, and a blocked run
without --deep prints the --dryrun --deep command to run in that directory.
Repository owners can reuse the same Git maintenance engine without copying it
into Diogenes or each integration. sandwich repository audit fetches the
declared source and publishing remotes, reports both divergences, runs a scoped
checkExpr --dryrun when a Bun lock exists, and invokes the owner's read-only
doctor. sandwich repository update repairs named remotes, safely merges the
publishing/source refs, applies the scoped dependency pass, invokes the owner's
verifier, commits only verified tracked maintenance edits, and prints the exact
normal or force-with-lease push command. It never pushes, stashes, rebases, or
discards worktree data.
sandwich checkFence walks user-owned Cargo roots containing both
Cargo.toml and Cargo.lock. It runs the RustSec auditor and Cargo's native
cargo update --dry-run; it does not compile a project or edit
Cargo.toml. Install RustSec once if it is not already available:
cargo install --locked cargo-audit
sandwich checkFence --dryrun
sandwich checkFence --apply=projectsThe global scope reads Cargo's own tracked-install metadata. It can recreate a crates.io installation with the original feature set, selected binaries, profile, target, version requirement, and packaged lockfile. Git, path, and custom-registry installations are reported but never guessed.
sandwich checkFence --dryrun --scope=global
sandwich checkFence --apply=global
sandwich checkFence --apply=global --protect iweAll mutations require --apply=projects, --apply=global, or --apply=all.
Cargo lockfiles are backed up before resolution and restored if update or
metadata validation fails. Manifest-level RustSec findings remain explicit;
Sandwich does not invoke the experimental manifest rewriter.
sandwich checkZoo discovers uv-locked projects and standalone virtual
environments, then checks uv-managed command-line tools. Locked projects use
native uv audit; standalone environments use uv pip check and
uv pip list --outdated. The latter cannot be represented honestly as a
lockfile security audit, so the distinction remains visible in the output.
sandwich checkZoo --dryrun
sandwich checkZoo --dryrun --scope=projects ~/Hermes
sandwich checkZoo --apply=projects --protect vllm,torch
sandwich checkZoo --apply=venvs --protect-file ~/.config/sandwich/python-protected.txt ~/multimedia
sandwich checkZoo --apply=toolsProject changes use targeted uv lock --upgrade-package operations. Existing
.venv directories are activated in isolated subshells, synchronized with the
new lock, and deactivated before the walker continues. A missing project
environment is never created implicitly. Standalone venv updates run a uv
resolution preflight before uv pip install; uv tools are upgraded one at a
time so protected names can be honored. Sandwich never invokes pip, selects
--system, or mutates a distro Python installation.
Protected names may be repeated with --protect, listed comma-separated, read
from --protect-file, or supplied through SANDWICH_ZOO_PROTECT. If present,
~/.config/sandwich/python-protected.txt is loaded automatically; set
SANDWICH_ZOO_PROTECT_FILE to choose another persistent list. Names use
Python's normalized -, _, and . equivalence. A protected version change
during project resolution aborts the operation and restores the original
uv.lock. Every write requires --apply=projects, --apply=venvs,
--apply=tools, or --apply=all; a bare checkZoo is rejected.
The lock and audit behavior follows the upstream uv locking and syncing, uv tool management, Cargo update, and RustSec cargo-audit contracts.
Sandwich fails loudly when another package manager’s semantics cannot be represented honestly. Runtime state and backups never live in this repository.
