How code-stick lays out a USB and what runs at launch time.
<USB>/
├── code-stick.json manifest (v2: multi-model)
├── start-windows.bat launcher → engine/windows-{x64,arm64}/ollama.exe + opencode
├── start-mac.command launcher → engine/darwin-{arm64,x64}/...
├── start-linux.sh launcher → engine/linux-{x64,arm64}/...
├── engine/<target>/ ollama binary per target
├── opencode/<target>/ opencode binary per target
├── data/ OLLAMA_MODELS — model blobs (OS-agnostic)
└── config/opencode/ opencode.json (XDG_CONFIG_HOME / APPDATA redirect)
engine/andopencode/hold per-target binaries — six trees on a fully portable stick (windows-x64, windows-arm64, darwin-arm64, darwin-x64, linux-x64, linux-arm64). Each tree is independent; a stick trimmed with--targets hostonly contains one.start-windows.batpicks betweenengine/windows-x64/andengine/windows-arm64/at launch time based onPROCESSOR_ARCHITECTURE, falling back to x64 via Prism emulation on ARM64 hosts if only x64 is staged.data/is the Ollama model store. Format is OS-agnostic (sha256 blob files + JSON manifests), so the same blobs serve Windows, macOS, and Linux launches without re-downloading.config/opencode/opencode.jsonis opencode's normal config file — launchers redirectXDG_CONFIG_HOME(POSIX) andAPPDATA(Windows) to<USB>/configso opencode reads it from the stick instead of the host.
Each launcher does the same four things in order:
- Spawn
ollama servefrom<USB>/engine/<target>/ollama[.exe]withOLLAMA_MODELS=<USB>/dataandOLLAMA_HOST=127.0.0.1:11434. The server binds only to loopback — no exposure to the network. - Wait for Ollama to respond on
/api/version(45 s health-check window). - Redirect opencode's config dir at
<USB>/configvia the env vars above, then run opencode in the foreground. - On exit, kill only the Ollama process the launcher spawned — by
PID, never
taskkill /IM ollama.exe. A host-installed Ollama is untouched.
The launcher tracks its child by PID. If it crashes, a stale ollama serve can survive on port 11434 — code-stick doctor detects this and
prints the PID to kill manually.
code-stick install, code-stick add-model, and code-stick upgrade-engine all need to interact with Ollama (pull blobs, bake
num_ctx, list models) but the launcher's Ollama process isn't running
yet. They each spin up a temporary Ollama server pointed at the
stick's data/ directory, run the needed subcommands, and tear it down
when finished. Same loopback-only safety as the launcher.
The temp server is registered with the process manager so SIGINT /
unexpected exit tears it down via tree-kill + grace period — orphaned
ollama serve processes never outlive the installer.
- Network: Ollama binds only to
127.0.0.1:11434. No outbound connections after install (model pulls happen at install time, not at run time). - Host filesystem: opencode and Ollama read/write only within
<USB>/. They never touch~/.ollamaor the host's opencode config. - Exit: The launcher kills only the Ollama PID it spawned. A host-installed Ollama on a different port stays running.
- Residue: Nothing is written to the host after exit. Pull the stick and the host has no record code-stick ever ran.
See SECURITY.md for the full trust model and threat boundaries.