~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).
internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.
devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.
ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.
Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9.5 KiB
title, weight
| title | weight |
|---|---|
| Working on a clone | 3 |
devvm --clone gives the VM its own clone of the repo instead of mounting your folder, so nothing in the VM can touch your working tree or .git. Use it when you don't trust what runs in the VM, such as an agent working unattended, and on Linux hosts, which have no .git protection. Files the VM writes lists what --clone keeps away from this machine.
devvm --clone # create the VM, copy your branches into it and open a shell in its clone
git fetch devvm # later, on this machine, fetch the VM's work as devvm/<branch>
git log -p main..devvm/main
sequenceDiagram
participant R as Your repo
participant V as The VM's clone
R->>V: devvm --clone pushes<br>every local branch
Note over V: you or an agent<br>commit in the VM
V->>R: git fetch devvm gives<br>devvm/#lt;branch#gt;
Note over R: review,<br>then merge
R->>V: devvm rm looks for<br>commits not fetched
V->>R: fetched into<br>saved/devvm/#lt;branch#gt;
Note over R,V: the VM is deleted,<br>and its remote removed
Requirements
- The folder is the top folder of a git repo that has at least one commit and a branch checked out, not a detached HEAD.
- git is installed on this machine. The VM's images already have it.
- You choose
--clonewhen the VM is created. devvm refuses--clonefor an existing VM that mounts its folder, so to switch, save any work in that VM, then rundevvm rmanddevvm --clone. Once a VM is a--cloneVM it stays one, and you don't need to pass--cloneagain.
What's copied
From this machine, the VM mounts only the shared tools and its agents' config folders. Once the VM is running, devvm creates a repo in it at the same path as your folder and pushes every local branch into it. The push goes over the VM's SSH entry, which checks the VM's pinned host keys. devvm checks out your current branch in the clone, and your shell opens there.
devvm copies only your local branches. Tags, uncommitted changes, and untracked or ignored files such as .env and node_modules stay on this machine. devvm warns you about uncommitted changes, so you can commit them and send them later with git push devvm BRANCH.
If the copy fails, for example because the VM can't be reached, devvm tries again the next time you run it in the folder.
The remote
devvm adds a git remote for the VM to your repo. It's named devvm, or devvm-<folder> if devvm is already taken, or the VM's full name if both are. The remote's URL is the VM's full name followed by the clone's path, so git connects through devvm's ssh config, and fetching needs two things:
- Your
~/.ssh/configneeds devvm'sIncludeline (SSH access by name). devvm offers to add it when it creates the clone, and again when you rundevvm hostordevvm code. Until the line is there, or when devvm had no terminal to ask in, fetch withGIT_SSH_COMMAND='ssh -F ~/.local/share/devvm/ssh_config' git fetch devvm. - The VM must be running. A stopped VM has no SSH entry, so
git fetchfails because it can't resolve the name. Rundevvmordevvm hostin the folder first.
Fetching the VM's work
Fetching runs nothing from the VM on this machine. git only receives objects and updates the devvm/* branches, or creates new saved/devvm/* branches when devvm rm does the fetch. The commits themselves are untrusted, though, so treat them as you would a contributor's branch and review them before you merge them, check them out or run anything they change.
Subfolders
When you run devvm in a subfolder of the repo's folder, devvm uses the --clone VM as it uses any parent folder's VM, asking first in a terminal (a subfolder). The clone is at the repo folder's path, so the subfolder's path in the VM is the same subfolder in the clone. When the clone has that subfolder, the shell opens there, and devvm host and devvm code give it as the folder to open. When the clone lacks it, for example because the subfolder is untracked or ignored and so never copied, they use the clone's top folder instead.
devvm --clone in a subfolder never uses a parent folder's VM. It makes a new --clone VM for the subfolder without asking, as devvm --here does, so the subfolder must be the top folder of a repo of its own.
Several agents in one VM
Several agents can work in one --clone VM, each on a branch of its own in a git worktree of its own, so each agent edits its own copy of the files. Put the worktrees inside the clone, such as in .worktrees/NAME, because the clone's parent folders in the VM belong to root, and so git worktree add ../NAME fails there. In the VM, in the clone:
echo .worktrees/ >> .git/info/exclude # once, so git status in the clone leaves the worktrees out
git worktree add -b agent/api .worktrees/api # a worktree on a new branch, agent/api
cd .worktrees/api # then start the agent here
Every worktree shares the clone's repo, so the agents' branches are all in it. One git fetch devvm on this machine brings every agent's branch back, such as devvm/agent/api, and you review each one as you would any of the VM's work (fetching the VM's work). Before devvm rm deletes the VM, it also checks each worktree inside the clone for uncommitted changes (deleting the VM).
Install each worktree's dependencies in that worktree, and never share one node_modules folder between worktrees, because each branch can need different packages, and two agents installing at once can break it. pnpm and bun keep one package store in the VM and hard-link packages from it into each worktree's node_modules when both are on the same disk, so another worktree costs little download or disk.
The agents also share the VM's ports, so two servers on the same port collide. Give each worktree's server a port of its own, such as with PORT=3001. A VM that forwards every port, as new VMs do by default, forwards each of them to this machine's localhost (ports).
The agents in one VM share its network policy, its secrets, and its CPUs, memory and disk, and each agent can read and change every other agent's worktree. When the agents need different network policies, secrets or sizes, or when one agent mustn't reach another's work, give each agent a folder of its own on this machine, such as a separate clone of the repo, and run devvm --clone in each, so each gets a VM of its own.
Deleting the VM
Before devvm rm deletes a --clone VM, it checks the clone for work you'd lose. It starts a stopped VM for the check as a launch does, so the VM's network policy is checked first:
- If the clone has branches with commits this repo hasn't fetched, devvm names them and offers to fetch them into new local branches named
saved/devvm/<branch>. It skips a branch whose name git on this machine refuses and names it, and that branch goes with the VM. To keep such a branch, rename it in the VM withgit branch -mbefore you rundevvm rm. - If the clone or a worktree inside its folder has uncommitted changes, devvm lists the first 20 of them in all, with each worktree's changes under its path, and asks before deleting them along with the VM. devvm skips a worktree whose folder is gone or that git would prune, and it doesn't check worktrees outside the clone's folder. When the clone has more than 100 worktrees, devvm checks the first 100 and asks before deleting the VM, even if none of them has changes.
If either check finds something and there's no terminal to ask in, devvm refuses and keeps the VM. These questions are asked only in a terminal, because only you can judge the work, so --force never answers them and --no-input makes them fail (questions devvm asks).
Once the checks pass, devvm deletes the VM. If the remote still points at the VM, devvm then removes it with git remote remove, which also deletes its devvm/* branches and their upstream settings. Before it does, devvm keeps every devvm/* branch that has commits no other branch has as a new local branch under saved/devvm/, whoever fetched it. devvm names each branch it creates, and they're yours to review, merge or delete, as with git branch -D saved/devvm/main.
The saved branches are named after the remote, as saved/<remote>/<branch>, and devvm never overwrites a branch. When a branch is in the way, devvm uses saved/<remote>-2, then -3 and so on, and if it finds no free name, devvm rm refuses and keeps the VM (saved branches).
devvm rm --force skips only the question whether to delete the VM at all, and both checks still run. devvm rm --no-export skips the export of the agents' history, and it also leaves both checks as they are.
devvm rm --no-clone-check skips both checks, so the VM goes with the commits this repo hasn't fetched and the uncommitted changes, and devvm warns you of that first. Use it when a check can't read the clone, such as when git in the VM is broken, and devvm refuses and keeps the VM. Use it too when the VM doesn't start for the check, such as when its network policy doesn't hold, because devvm then says what kept it from starting and keeps the VM. devvm still asks whether to delete the VM unless you also give --force, and it still keeps the devvm/* branches you fetched as saved/devvm/ branches.