14 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 376f1c2ad7 fix(agents): opencode's save, plugin approvals and the history scripts' framing
devvm agent save refused a VM whose ~/.config/opencode held a bun.lock (which opencode's plugins' installs write), a package-lock.json, a .gitignore or a .DS_Store: the save's script sent every entry of that folder but node_modules and FolderOwn, while the host's listedPath refuses those files (fileSetting), so it saved nothing. notSettings is now their one list, as patterns path.Match and the shell's case read alike: fileSetting leaves them out and the script sends a file of those names no more, only a folder that isn't a link, which is a setting. TestAgentSaveScriptRuns plants them and a folder named old.lock, and failed with agent_save_unsafe before the fix.

opencode's HistoryOwn names its native client's plugin approvals, in its state folder (cli-rs's plugin/src/loader/approval.rs and tui/src/plugins/host.rs, opencode v2.4.1): plugin-approvals.json, its .lock and the .plugin-approvals.json.<pid>.<n>.tmp it's written through, and plugin-staged, the approved trees' copies, which it reuses by their hash's name without hashing them again, so a hostile VM's export could approve a project plugin for the VM that imports it. That client doesn't ship in 2.4.1. TestHistoryExportRuns and TestHistoryImportRuns plant them, with plugin-notes.json as the control, and failed on fedora without the entries.

The history scripts' framing (onInputCmd) now says why on its stderr, which goes to the VM's log, when its input was cut short: TestOnInputCutShort checks it for every cut, an empty input included, and none for a whole one, and failed before. TestHistoryScriptsOnInput holds each script under 128 KiB, Linux's limit on one argument, which bash -c "$s" passes it as. The CLI scripts match the framing's new start.

Docs: the save's and the store's table say which files stay in the VM; the import's and How it works' lists name the plugin approvals; the release page gets opencode's lock files in a save and the approvals; the changelog's opencode block gets the save's fix, and the hardening line names approved plugins. The review's optional wording: the design note's `*` matches every resource, and the plain-password steps set this machine's password first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:03:05 -07:00
w3cjandClaude Opus 5.5 962c183117 fix(agents): imported opencode history brings no automations, approvals or resumed turns
An export of opencode's history held what opencode 2.4 acts on without asking, so a hostile VM's export could run commands in the VM that imports it (opencode v2.4.1's source): its automations (automation), each a trigger and a shell command that it approved once and never asks about again (core/src/automation/shell.ts); the requests you said always to allow (permission, which Permission.evaluate turns into allow rules); each session's own rules (session_v2.permission, a Permission.Ruleset); the subagents' jobs (job), the queued messages (session_inbox) and the suspended sessions (session_v2.time_suspended), which its service starts or resumes when it starts (core/src/session/execution/restart.ts), with the session's agent's own rules, explore's allowing shell; a project's commands (project.commands), whose start command it runs with bash -lc for each worktree (core/src/worktree.ts); and its git repositories in its data folder (snapshot, repos, worktree), whose config can name a clean filter or core.fsmonitor that its own git update-index runs (core/src/snapshot.ts, git.ts).

opencodeClean now empties the tables opencodeUnattended picks (automation, permission, job, session_inbox, and any whose name starts so), sets the columns opencodeNulled picks to NULL (time_suspended, commands, in any case), keeps only the deny and ask rules with a text action of every permission column, each written again from what sqlite3 read, so a key written twice can't keep an allow effect for JSON.parse (opencodeAllowRules), drops every view, and fails its check on a generated column (opencodeHidden). Its check counts each and must print 0, so a sqlite3 without JSON leaves the database out. A view, an upper-case column, a generated column and a duplicate key bypassed the first version, as the security review showed.

opencode's HistoryOwn now names its background service's registration on every channel and the files written beside it (service-*.json, service.json.*, service-*.json.*) and its git repositories (snapshot, repos, worktree): an export leaves them out and an import never writes them, while a VM made again keeps them. The import's clean-up loop expands each as a pattern; TestHistoryImportScript holds every skip to a path's plain characters.

Tests that failed first (fedora's gate): TestOpencodeCleanSchema (automation and permission emptied, a session's allow rule gone), TestHistoryImportRuns and TestHistoryExportRuns (service-local.json, the handoff's and the registration's temporary files); TestOpencodeCleanSessionRules fails closed without the statements. The review's additions: TestOpencodeCleanSchema (job, session_inbox, a suspended session, a project's commands), TestOpencodeCleanSessionRules (a key written twice, a non-text action, an upper-case column), TestOpencodeCleanHidden (a view, a generated column), and the git folders in the export and import tests.

The review's docs fixes across the stack land here too: the changelog's What to do steps, the release page, the coding agents page, How it works and the design note.

A kept rule whose resource is missing or isn't text gets "*", as opencode's Permission.Rule needs one, and the check also counts a rule that isn't in the rebuilt form, so a copy whose rules weren't rebuilt fails closed. A stack-wide review's last docs fixes land here: devvm rm deletes opencode's worktrees with the VM, so the changelog has a What to do step to commit their work first.

The export's and the import's scripts, which the stack doubled, now go on the VM's input (onInput): a line with the script's length, the script, then the import's export. In the command's arguments, quoted for ssh's shared connection, macOS's ssh failed to start the session (mm_send_fd: sendmsg: Message too long), which the mini's e2e hit, the export first and then the import. The VM reads exactly that many bytes (dd bs=1) and runs the script only when it read them all, so an input cut short runs nothing (TestOnInputCutShort), and the script gets the rest as its input. TestHistoryScriptsOnInput holds every argument under 4 KiB; TestHistoryExportRuns and the import's runs use onInput too. The stub guest takes such a script off its input (inputScript), matches its switches and files() against it and keeps an export's and an import's in history-export.sh and history-import.sh, which history, history_import, rm_vm, existing_agents and layer_add read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:17:55 -07:00
w3cjandClaude Opus 5.5 b3e614743d fix(agents): opencode's service settings never reach the store or VMs
opencode 2 keeps its background service's settings in ~/.config/opencode/service.json, or service-<channel>.json on another channel (opencode v2.4.1's service-config.ts): the service's password, which the service makes when the file has none, and with remote access on, the secret route its address is served on and remoteAccepted. devvm agent import, and devvm agent save, copied every file of opencode's folder into the store, so every VM with opencode got a copy at each launch, with devvm-redacted in place of the password and the route as it was: each such VM's service took the known password devvm-redacted.

The agents' registry gets FolderOwn, the names of a WholeFolder agent's entries that are each machine's own; MachineOwn covers them, so agentFiles, agentDirs, agentLinks and listedPath leave them out: the import never copies them, no VM gets them from a store that holds them, and the save's script never sends the VM's own (which would have made the save fail). cleanStore (cleanSeeds, which now also runs cleanFolderOwn through the shared cleanOwn) takes them out of the store at a start, warning once (agent_store_own_cleaned, agent_store_own_clean_failed). The setup gets machine-own (agents.MachineOwnFiles) and DEVVM_REDACTED (agentlogin.RedactMark, exported, and now the one source of the placeholder in agentlogin's copies), and sync.sh's clean_machine_own takes out each regular file of those names that holds the placeholder, failing the setup with the cause when it can't, so the VM's opencode makes its own password; opencode service get password shows it.

Tests that failed first: TestSeeds' MachineOwn cases, TestOpencodeServiceNotImported, TestOpencodeServiceNotStaged, TestOpencodeServiceNotSaved, TestCleanStoreOpencodeService and TestSyncCleansMachineOwn. e2e's network section plants the store's service.json and checks the start takes it out, no VM gets its password or route, two VMs' passwords differ, and a launch takes out devvm's old copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 16:16:12 -07:00
w3cjandClaude Opus 5.5 9acdd0c47c fix(agents): history exports leave out opencode's machine key
opencode 2.4 keeps the private Ed25519 key of its home, which every machine it pairs with `opencode machine add` trusts and which it never replaces, in ~/.local/state/opencode/machine/home-key. That folder is in opencode's History, so devvm history export, and the exports devvm rm and a remake write, copied the key onto this machine, and devvm history import wrote it into other VMs, with the background service's registration (service.json and its .pty-handoff, the service's password and a handoff ticket) and the terminals' daemons (pty, their sockets and access tokens).

The agents' registry gets HistoryOwn: what of an agent's history is the VM's own as a machine. HistoryExcludes() returns it after each agent's HistoryExcludes, so the export leaves it out and the import never writes it, by its paths after it unpacks too. HistoryLogins() is each agent's HistoryExcludes alone, which a remake's home copy (homeSkips) leaves out, so a remade VM, the same machine, keeps its key. The copy of opencode's database empties its machine table (opencodeLogins), the paired machines' public keys, which are the VM's own pairings.

opencode's schema fixture moves to 2.4.1 (testdata/opencode-2.4.1.sql, from its release's schema.gen.ts, which matched 2.2.5's VM-printed file line for line): automation replaces schedule and is kept; machine is emptied.

Tests: TestHistoryExportRuns, TestHistoryImportRuns and TestHistoryImportV010 plant the key, service.json, its handoff and pty, and fail without the fix; TestHomeSkipsEveryLogin checks each HistoryExcludes is skipped and each HistoryOwn kept in a remake; TestLists covers HistoryLogins; e2e's network section plants the key in a VM and finds it in no export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 15:22:38 -07:00
w3cjandClaude Opus 5.5 47593e21ab fix(proxy): NormHost keeps an address's trailing dot, its IPv6 zone's, and Public calls no zoned address the internet's
NormHost dropped one trailing dot from any host, so an IPv6 address whose
zone is "." (::1%.) became ::1%, an empty zone, which netip reads as no
address. The proxy refused both forms (HostOK), but a partial clone's
promisor warning (privateHost) no longer saw ::1%. as private, as
FuzzPromisorHostSite found. NormHost now leaves an address as it is, its
dot included, so every judge reads such a host as the zoned address it
is. Public now calls no address with a zone the internet's: netip's
prefixes never contain a zoned address, so the ranges alone missed, for
example, a zoned documentation address, which --from's registry check
took as public.

No VM could reach anything through such a host: every way in (CONNECT,
absolute-form requests, a transparent connection's Host and its TLS
server name) refused it with 400 before any lookup or connection, on
every tier, the broker refuses a lookup of it and a connection to a
zoned address, and no rule or NO_PROXY entry names one.

Tests: TestZonedHostsRefused sends each zoned and empty-zone host
through CONNECT, plain HTTP and the transparent path on the open,
internet, allowlist, none and loopback-allowing tiers, checking each
refusal is the proxy's own where net/http lets the request through,
with a control on each path that [::1] itself reaches the dialer where
allowed; it passed before the fix too, and fails when HostOK takes a
zone. TestNormHost, TestBrokerLookup, TestBrokerDial, TestInternal and
TestPublicAddr gain zoned cases; FuzzHostSites' splitSite and
policySite list the new divergence (zoneDot), and FuzzPromisorHostSite
lists a zoned address now counting as private; its crash input and the
zoned-unspecified one ([::%[]:) are added. design.md's list of the
host readers' differences names both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 17:36:57 -07:00
w3cjandClaude Opus 5.5 c4b4c02424 test: FuzzCapture skips devvm's own placeholders; FuzzParseLFSPointer counts a size as it parses
The nightly fuzz run found two inputs that failed the tests' own checks,
not devvm:

- FuzzCapture: a 26-character access token that is a prefix of fakeJWT's
  fixed header. The VM's reply held only placeholders, and the check
  matched the placeholder's header. It now looks for the tokens in the
  reply without devvm-proxy-managed and JWT-shaped placeholders whose
  header and claims are fakeJWT's own (its mark and an expiry).
- FuzzParseLFSPointer: "size -0", which strconv.ParseInt and git-lfs read
  as 0. The check counted only a canonical size or one with a leading +
  or zeros; it now counts a size line that parses to the size taken.

Both inputs are in the corpus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 02:13:41 -07:00
w3cjandClaude Opus 5.5 0fdb2ba5a2 test(vm): a 0.1.0 history export imports today
TestHistoryImportV010: devvm 0.1.0's own export script, the string its
historyExport returned, frozen in
internal/vm/testdata/v0.1.0-history-export.sh (made by running 0.1.0's
code from git archive v0.1.0), runs with real bash and GNU tar in a
home as a 0.1.0 VM had it: Claude Code's projects and todos, its
.credentials.json, settings.json and .claude.json, the store's plugins
and skills folders linked at their paths as 0.1.0 linked its mounts,
Codex's sessions, history and auth.json, opencode's storage, auth.json
and, where sqlite3 is, its database, and opencode's state. The export
holds the links and the copied settings (exportNames), the controls
for what the import leaves out, while 0.1.0's own excludes keep the
logins out of it. Today's historyImport takes it without
devvm-history-unsafe: the history arrives, opencode's database with its
session included, and the links, the copied settings and the plugins
stay out. The import's run moves to runImport, which
TestHistoryImportRuns shares, so that test stays within revive's
limit. Nothing found to fix. (It runs where GNU tar is, as the other
history tests do.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 e97db057fd fix(agents): Claude Code's plugins get a folder of each VM's own, the store's a read-only seed (#56)
A VM's ~/.claude/plugins was the agent store's plugins folder, mounted
read-only, so everything Claude Code writes there failed with EROFS: a
plugin's data (${CLAUDE_PLUGIN_DATA}), installs, marketplace refreshes,
mcpb/ and the rest. Making the store writable would let one VM change
what Claude Code runs in every other VM, so each VM's ~/.claude/plugins
is now its own folder on its disk (CLAUDE_CODE_PLUGIN_CACHE_DIR), and the
store's folder is linked at ~/.claude/plugins-seed and read as Claude
Code's own read-only seed (CLAUDE_CODE_PLUGIN_SEED_DIR). Checked on a
devvm VM first: a seed-cached plugin from a GitHub-style marketplace
loads with only enabledPlugins, its hook writes ${CLAUDE_PLUGIN_DATA} in
the VM's own folder, installs in the VM work, and seed marketplaces
refuse updates.

- agents: Def.Seeds (Rel, Link, Entries), Seeds, SeedOf, MachineOwn;
  Env gains Home; Claude's Env sets both variables below $HOME.
- vm: the setup links a seed at its Link and stages own-dirs, which
  sync.sh makes a folder in place of a link; agentEnv writes Home values
  through homeValue (shared with toolchainEnv); a remake keeps the VM's
  own folder and skips the seed's link.
- devvm agent import copies only a seed's entries (known_marketplaces.json,
  marketplaces, cache), directly and through followed links, so the
  host's plugins' data, mcpb, synced, .trash, store and
  installed_plugins.json never reach the store.
- devvm agent save: the VM's script excludes a seed folder's other
  entries by name, and readSent refuses any (listedPath); a seed folder
  adds and changes, never removes or prunes; claudeRecords renames the
  VM's plugins path to the store's and joins known_marketplaces.json by
  key, leaving records Claude Code registered from the seed as the
  store's, and the store's file as it is when nothing changed.
- History: an export leaves the VM's plugins folder out and an import
  skips it and the seed's link: it's settings and plugin data (which can
  hold a plugin's own logins), not history, and reaches other VMs only
  through devvm agent save's reviewed diff.
- Review fixes (security-audit): historyImport refuses a name with a
  ., .. or empty part (GNU tar's anchored excludes missed
  .claude/./plugins and .claude//plugins, which now reach a writable
  folder) and deletes importSkips by path after the link sweep; the save
  script never excludes a name with a wildcard's character (it's sent
  and refused); only a marketplace record whose exact installLocation is
  clean and in the store's marketplaces joins the store's.
- Tests: claude_test.go (TestClaudePluginsSeed, TestClaudePluginsHistory,
  TestAgentImportClaudePlugins, TestAgentSaveScriptClaudePlugins,
  TestReadSentClaudePlugins, TestAgentSaveClaudePlugins), TestSeeds,
  TestListedPath cases, the agent, agent_save and sync CLI tests, goldens,
  and e2e project checks of the seed, the VM's folder and a plugin's data.
- Docs: coding-agents (store table, Claude Code's plugins under Mounts,
  the save's plugin example), internals/agents, a design note with its
  threat check, extending.md, CHANGELOG Fixed and After you upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 11:37:40 -07:00
w3cjandClaude Opus 5.5 c597c21e85 fix(history): an export packed with macOS's tar imports
devvm history import refused an export made with macOS's tar (bsdtar):
for each file with extended attributes, such as the com.apple.provenance
that recent macOS puts on new files, bsdtar adds an AppleDouble ._ file
beside it, and ._.claude, at the top, is outside the agents' history.
bsdtar's own listing hides those entries; GNU tar's, which the VM
checks, shows them. e2e's from section packs its Alpine export on the
host, so it failed on the mini (macOS) and passed on fedora (GNU tar).
The import script is unchanged since before the agents stack, so this
isn't a regression from it.

- historyImport leaves a name whose last part starts with ._ out of the
  path check (appleDouble), and never unpacks one (--exclude=._* and
  */._*); what's below a folder so named is still checked.
- TestHistoryImportRuns (GNU tar, so Linux): an export laid out as
  macOS's tar writes it imports without its ._ files (it failed before
  the fix on fedora), ._.claude/a is still refused, and an export that
  devvm history export writes imports whole (a round trip).
- The agents' golden scripts, internals' Coding agents and the
  CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:42:38 -07:00
52bb0f467b feat(clone): a --clone VM gets the repo as it is here
A --clone VM's clone is now seeded with a snapshot, not git push, and
gets everything a working copy has. devvm clone fetch brings it all
back, and devvm rm and clone off check it before deleting.

- Refs: every branch, tag and notes ref, and a detached HEAD.
- Uncommitted changes: staged, unstaged and untracked files; files
  skip-worktree by hand get the index's version, named.
- Operations in progress (merge, rebase, cherry-pick, revert, bisect)
  and the stash; a stash's untracked part goes as its own branch.
- The repo's settings and hooks, sent as settings only where they live
  in the repo (husky); ORIG_HEAD never goes.
- Partial clones, with their promisor remote, and messages per network
  tier when it can't be reached.
- Initialised submodules, nested ones too, each with a clone of its
  own; a submodule's own folder is refused as a top-level --clone.
  vm.json gains an optional `submodules` field.
- Git LFS both ways: objects hash-checked, written under os.Root with
  no link followed, a question past 2 GiB; the filter is set only in
  the clone's repos; git-lfs 3.8.1 in base, pinned by SHA-256.
- rm and clone off keep the VM when anything the VM has didn't come
  back, and name it.
- Every shell script embedded in Go is shellchecked.
- clone.md is a guide that leads with commands; TestUserPageProse
  covers it and coding-agents.md.

After you upgrade: base and every image on it build again once, for
git-lfs.

Fixes #40, reported by @Josuesp1620. Thanks to @dhruv1220 for #42,
which found the cause (receive-pack refusing a shallow push); its
receive.shallowUpdate setting stays in the VM's repos.

Co-authored-by: Dhruv Arora <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:54:42 -07:00
d349868c31 feat(agents): one definition per coding agent, and Cursor's CLI
Every list of the coding agents now derives from internal/agents'
registry, one Def each, and Cursor's CLI (cursor-agent) is a fifth
agent.

The registry:
- each agent's login command, login formats and capture on its Def;
  one message for every agent where each had its own
- the agents' table, the README's list and the docs' history lists are
  generated from the registry (cli.DocBlocks, TestDocBlocks); scripts
  and Go tests take their lists from it too
- each agent's own code lives in a file named for it; the structure
  test lets only an agent's own files choose by its name, following
  constants named after an agent
- a VM remade by clone on/off keeps no agent's login files
  (agents.LoginFiles from every Def.Logins; Claude Code's .claude.json
  stays, as it is also history)

Cursor's CLI:
- `devvm --agents cursor`, `devvm agent login cursor`, history import
  and export of ~/.cursor/chats
- the proxy captures its login at a GET endpoint, guards a shared host
  by path, and puts the login in only where the CLI sends it, bound to
  the CLI's 57 methods
- account changes and the agent store are refused in a VM; Cursor's
  headers and trailers are scanned for tokens
- e2e: Cursor's CLI in the network section, its poll behind the fake
  company proxy

Docs: the agents' pages lead with commands, with a How it works page
for the agents.

Co-authored-by: JB <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:49:48 -07:00
w3cjandClaude Opus 5.5 33ec9eb0dc refactor(tools): one definition per toolchain
Each toolchain is one image.ToolDef in image.SharedTools, which also
holds its guest environment, its PATH folders and its version files. They
leave base's devvm-tools.sh for /etc/devvm/toolchains.sh, which every
launch writes, so base.sh changes and every image rebuilds once. The
structure test's names rule fails on a toolchain's name as a literal
outside internal/image, TestToolchainsComplete checks the toolchains
page, and Contributing gains Adding a toolchain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:29 -07:00
w3cjandClaude Opus 5.5 9f51e79421 refactor(agents): one definition per coding agent (#29)
Each coding agent gets one definition, an agents.Def in a new stdlib-only
leaf package, internal/agents, and everything else iterates over
agents.Defs: agentlogin's format per login kind, secrets' login kinds,
settings' [pass-keys], image.SharedTools, the vm package's store tables
and scripts, and cli's help lists. The VM copies of every login file,
their bindings, the store's layout, the scripts and the CLI reference
stay the same byte for byte, as golden tests made before the refactor
show.

The agents' guest variables leave base.sh for /etc/devvm/agents.sh,
written at every launch, so every image rebuilds once. Messages are
merged per agent (login_kept, login_passed, login_withheld,
login_oauth_withheld, agent_login_key_only). The structure test's new
names rule fails on an agent's name or login kind as a literal outside
internal/agents, and literals on one holding an agent's folder. Docs
link the supported coding agents rather than listing them, and
Contributing gains Adding a coding agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:16:40 -07:00
w3cjandClaude Opus 5.5 48fee3a42b fix(agents): opencode history export drops well-known remote configs, tested on opencode's own schema
opencode 2.2.5's real database schema (sqlite3 .schema in an e2e VM after
opencode auth import, opencode mcp auth and opencode run; no rows) is now
a fixture, internal/vm/testdata/opencode-2.2.5.sql. TestOpencodeCleanSchema
builds a database from it, plants a row in every table, cleans it, and
checks that no byte of the copy holds a value of credential, account,
control_account or account_state, while every other table's row (the
session's included) stays; a table in neither list fails the test.

The real schema has no session_share (opencode 2.2.5 keeps share_url on
session_v2), and its kv table keeps each organization's remote config,
fetched with a well-known login, under wellknown:config:<origin>, which
the cleaning kept. The cleaning now deletes those rows (opencodeWellknown)
and checks none is left. e2e's network check plants one too.

Docs: the design note's steps and what it doesn't cover (plugin storage in
kv, remote workspaces' bindings); Maintaining says when and how to refresh
the fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 07:12:56 -07:00