| bin | ||
| data | ||
| .gitignore | ||
| lima.yaml | ||
| README.md | ||
datcode
⚠️ Note: this is not a reusable tool (yet) as it contains hard-coded paths and configuration.
Run OpenCode directly in an isolated Lima VM with a complete Docker Engine. The VM starts when a session begins and stops when the tmux session ends.
Prerequisites
- Lima 2.0 or newer
- QEMU with KVM access
- Projects stored under
/dat
Usage
Invoke the wrapper from the project OpenCode should work on:
/dat/datcode/bin/datcode
The first invocation creates an Ubuntu VM, installs Docker Engine as a system service, and installs Bun and OpenCode directly in the guest. This can take several minutes and is bounded by a ten-minute startup timeout. Later invocations reuse the VM disk but stop the VM after each session.
Only the invocation's current working directory and data are mounted into the
VM. The mounts are replaced before each start, so only one datcode session may
run at a time.
Docker images, containers, and volumes persist on the VM disk while it is
stopped. OpenCode can use docker and docker compose normally from inside the
VM.
Update OpenCode with:
/dat/datcode/bin/datcode update
OpenCode data remains on the host:
| Host | VM |
|---|---|
data/config |
~/.config/opencode |
data/share |
~/.local/share/opencode |
data/state |
~/.local/state/opencode |
data/tmux |
~/.config/tmux |
Use /connect inside OpenCode to save provider credentials in these mounted
directories.
OpenCode runs in a tmux session named dat. The guest uses the tmux
configuration copied from the host into data/tmux/tmux.conf. Exiting OpenCode
returns to a guest shell; exit that shell or detach from tmux to stop the VM.
Remove the VM and all Docker data with:
limactl delete datcode
Delete and recreate the VM after changing lima.yaml; Lima stores the resolved
configuration when it creates the instance.