mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
main
50
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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]> |
||
|
|
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]>
|
||
|
|
63bb1ff9a8 |
fix(network): a confined VM's programs ask 127.0.0.1 directly, so names fail at once
With transparent mode off or stopped, a confined VM's only name server, 127.0.0.1 (Lima's DNS setting), has nothing listening. glibc asked it through systemd-resolved's stub, which could keep retrying it over UDP and TCP without answering, so a lookup such as getent's waited out its timeout instead of failing at once (seen on a Linux host: e2e network's checks of DNS with transparent mode stopped and off). Each launch's setup now replaces /etc/resolv.conf, the stub's link, with devvm's own file on a confined VM: nameserver 127.0.0.1 alone, the stub's search line, timeout:1 attempts:2. glibc gets a refusal at once with nothing listening, and dnsmasq's answer through transparent mode's nftables rule when it runs, as musl on Alpine does. An open VM gets the stub's link back. Only systemd guests that have the stub's file and whose /etc/resolv.conf is its link or devvm's own are touched. Root cause, as far as it could be pinned down: with resolved's stub in the path, a lookup depended on resolved's retry loop over a server that refuses everything (24 attempts, flipping UDP and TCP feature levels), and on the linux host that loop sometimes never answered the stub within getent's 3 s. It didn't reproduce on demand (a base run on the linux host passed both checks, and bursts of 200 parallel lookups and stops mid-lookup all failed in under 2 s), so the fix takes resolved out of glibc's path rather than tuning it. Going back to open restarts systemd-resolved: it reads a /etc/resolv.conf that isn't its own link as global servers and search domains, so it had taken 127.0.0.1 and "~." from devvm's file, and kept them once the link was back, which left an open VM unable to resolve names (caught by e2e network's open checks on the linux host and ubuntu). Review folded in: no change of a foreign or dangling link when the stub's file is missing; two attempts; Docker's user-defined networks in the docs. Second review: devvm's file alone is enough to go back on an open VM (a warning when the stub's file is missing); a failed write says so in one line and the launch goes on; troubleshooting's "An open VM resolves no names after a downgrade"; tests for resolved's own resolv.conf link, an open VM without the stub, a non-systemd guest with devvm's file and a failed write. workerd under wrangler dev, checked by hand on fedora with transparent mode off: its fetch fails at once (Temporary failure in name resolution), so the "about 40 seconds for each lookup" sentence is gone from lima.md, safety/network.md and troubleshooting.md, and testing.md's manual check covers it. testdata/coverage/darwin.txt: internal/sshagent's baseline rose with mise run coverage (unrelated to this change). - backend.Confinement.Resolver: the one owner of a confined guest's name server; Lima's start sets .dns from it, sync.go sends it to the setup as DEVVM_RESOLVER; sync.go's setupInputs as mise run fmt writes it. - assets/guest/sync.sh: resolver_conf; its unit test runs the function (internal/vm/resolver_test.go). sync.sh runs at each launch and goes in no image, so no image key changes. - CLI tests: DEVVM_RESOLVER on confined (transparent on and off) and open VMs. e2e network: the stopped-transparent check also checks the file. - Docs: network.md's The VM's resolver, lima.md, design.md, tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
2f0cc97392 |
feat(paste): devvm paste and devvm paste rm (#38)
feat(paste): devvm paste, an image, PDF or copied file from the clipboard into the VM (#38) devvm paste reads the host's clipboard and streams what's on it into the running VM's paste folder over the backend's Exec, with no SSH agent and no new channel, then copies the file's path in the VM to the host clipboard for the agent's prompt. devvm paste rm empties the folder after a question, and a launch that starts a stopped VM offers to. What it reads: - an image (PNG, JPEG, GIF, WebP; TIFF is converted to PNG), checked by its bytes; browsers hand over a PNG, so an animated GIF arrives as one frame - PDF data, sent as it is, and preferred over a file reference beside it (Preview's page copies) - one copied file, after a question that shows its path on this machine; --send-file answers it only for a file inside the project folder reached without links, and never for a --clone VM - never text; several files are refused Security: - macOS reads file URLs only through NSPasteboard (FileURLsOnly): AppleScript's «class furl» coercion turned any text, such as a path a web page or the VM's OSC 52 put there, into a file to send - copied files are opened with openat and O_NOFOLLOW|O_NOCTTY|O_NONBLOCK, following a root-owned link only in a folder only root can change, and read through internal/safefile (Checked), capped at 64 MiB - osascript and pbcopy by absolute path, Linux's tools only from system folders, never PATH - time limits on every clipboard tool and on paste.sh in the VM; bounded reads of everything the VM prints - the path copied back is built on the host, keeping only the file's extension: nothing the VM says reaches the clipboard Also: the paste-dir setting (default /tmp/devvm-paste, made at each launch), --json with sent, the agents' guide line, messages with doc links, stubs, CLI tests, an e2e check in the project section, and docs on coding-agents, settings, design, security and attack-vectors. Co-authored-by: dustypolk <[email protected]> Co-authored-by: w3cj <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
647ad4bf2a |
feat(network): transparent mode for tools that ignore the proxy settings
On every confined tier, a tool that ignores the proxy settings (workerd
under wrangler dev, a static Go binary, a container made through Docker's
API) reaches the VM's proxy by the names it looks up. In the VM, dnsmasq
answers every name with the stand-in address 198.18.0.1 and has no
upstream; nftables sends that address's ports 80, 443 and those the allow
rules name to socat listeners on it, which make each an authenticated
CONNECT transparent.devvm.proxy:PORT to the VM's proxy. The proxy reads the
host from the connection's first bytes (TLS SNI, or each HTTP request's
Host) and judges it as CONNECT host:PORT, with the same order of checks,
log, secrets and floor. A blocked HTTPS host gets the 403 over a
certificate from the VM's CA. Nothing new runs on the host, and the
backends don't change.
Proxy (internal/proxy):
- transparent.go: TransparentHost, ProxyDomain, SentinelAddr,
IsSentinelAddr, ViaDNS, transparent (serve, take, tls, handler,
refusePage, ports), sniHost, replay, reservedRefusal, withVia, viaOf.
- routeFor and route: the one order of checks for CONNECT and the
transparent path; carry, the one tunnel with its SNI check; block split
into the record and blockPage; links.refuse split (isLinkDomain);
caEndedRefusal's test moved to routeFor; handshake and serveOne shared
by intercept and the 403 page.
- devvm.proxy reserved whole, CONNECT devvm.proxy:P included; the stand-in
address refused with its own reason.
- Hosts and SNI in ASCII alone, never folded (the Kelvin sign), in
splitHostPort, sniMatches and sniHost.
- A ClientHello record past 16 KiB + 256 is never read; once it starts,
a ClientHello must arrive whole within 10 s, on every tunnel; a stream
whose first byte is 0x16 is TLS from then on, so a record header that
doesn't come whole, or isn't TLS's version, is refused, never passed on
unchecked; and only a ClientHello that parsed (sniOf) counts, so one
split across records is refused, an address's tunnel's included, which
may have no name (a gap older than this change).
- routeFor carries the method and path rules: a host they narrow is
refused where it can't be decrypted and intercepted where it can, on
the transparent path too.
- On the transparent HTTP path, devvm.proxy answers /blocked alone.
- policy.transparentPorts and /transparent/ports: 80, 443, then the ports
allow rules name for hosts by name, at most 32, never 22 or 53.
- Event.Via ("dns"), shown in devvm network log, /blocked and the prompt's
note as "without proxy settings".
Guest (assets/): base.sh installs dnsmasq(-base), socat and nftables;
guest/transparent.sh is devvm-transparent: setup and teardown from
sync.sh (the proxy URL on stdin), the supervisor service (systemd or
OpenRC), the ruleset (render: two filter chains at -150 keep every
interface but lo and Docker's bridges, and every protocol but TCP, UDP
and ICMP, off the stand-in address; both NAT chains at -110 map every port of
the stand-in address, so Docker's published ports never take one; DNS to
public servers and 127.0.0.1:53 go to dnsmasq, which listens on the
stand-in address alone; private, link-local, CGNAT and loopback servers
are left alone, but the VM's own name servers, which Lima's DHCP adds
beside 127.0.0.1 and Docker gives containers, go to dnsmasq too), slots,
the port list's check, and status for devvm-why. Names without a dot and
names under the search domains (this machine's network's, through Lima)
don't resolve.
Setting: config.toml's transparent-proxy, and devvm network transparent
[on|off], the VM's own value in net.transparent (Settings.Transparent,
SetTransparent; netpolicy.TransparentOf, TransparentAddr); the setup gets
DEVVM_TRANSPARENT_ADDR while the VM runs confined and its mode is on.
devvm network --json has transparent; devvm network lock lists apart the
hosts only tools without proxy settings reached (Learned.NoProxy, via in
--json). vmssh.dialAddr refuses the stand-in address.
Tests: the transparent path's unit tests and FuzzTransparent; the
setting, TransparentOf, FormatEvent's via and learned hosts; the ruleset,
slots and port list under bash 3.2; network_transparent.txtar and
sync.txtar; e2e: transparentRuns, the network section's checks, a docker
step, the from section's Debian 12 and Alpine on the allowlist tier, and
the guarantee checks run with transparent mode stopped and running.
Docs: safety/network.md (tools that ignore the proxy, what isn't
covered, the setting, logs, lock), internals/network.md (tools that skip
the proxy), internals/design.md (the design note and threat check),
using/settings.md, using/troubleshooting.md, using/limits.md,
using/images.md, safety/attack-vectors.md, internals/lima.md,
contributing/tests.md and testing.md, the proxy's README, the CLI
reference and the Commands page.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
b2b12ee55d |
feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only the folder's own: one walk (hostsafety.Walk, at most 4 folders down and 100 repos, no symlinks, one device) finds them, and each is locked on macOS, pinned on Linux or watched where Linux can't pin, scanned within its own top folder and the mount. A repo counts as covered only when a scan locks its git dir; git dirs follow git's own rule, .git is matched without case on macOS, and a recorded repo stays protected while anything is at its .git. Repos the walk can't protect, that appear, that leave or that look like bare repos are named, with the config keys and hooks a VM-made repo would run. Existing VMs get a one-time notice and opt in with devvm git-protect on. Ownership fails closed under one host lock, so a VM never unlocks what another protects; one scan budget covers every repo, and launches into a running VM check only the top repo. devvm doctor gives a tip to set safe.bareRepository=explicit, reading the user's GIT_CONFIG_GLOBAL when set. Refs #3. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8f6b30a887 |
feat(secret): your own secrets, bound to the hosts you choose
devvm secret set NAME --host HOST[,HOST…] --env VARIABLE [--header H] [--prefix P] [--stdin] saves a secret of your own: the value from a hidden prompt or stdin (never argv) into the Keychain or devvm's secrets folder, and its definition into custom-secrets.json. A VM that uses it (devvm secret use NAME) gets only a per-VM placeholder in VARIABLE, and its proxy puts the real value in that header only for those exact hosts, over TLS on 443; the hosts join that VM's allowlist. Names, hosts, headers, variables and prefixes are checked; wildcards, addresses, internal names and other ports are refused. One placeholder builder serves every secret and login, and the proxy caches values by kind, agent and name. After an independent review, a secret goes in only in four exact shapes (alone; Bearer, Token or a saved --scheme in Authorization; the Basic password; the Basic username only with --basic-user), values are printable ASCII under 3,800 bytes, the proxy checks each binding against its definition, definitions carry IDs and VMs record their hosts, and custom values are stored apart from the known secrets. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
84f1190b04 |
feat(agents): pi, as a fourth coding agent (#23)
Adds pi (earendil-works/pi) as a shared coding agent beside Claude Code, Codex and opencode: --agents pi, devvm tools add pi, the new-VM picker and devvm setup offer it. Its network policy allows pi.dev; base sets PI_SKIP_VERSION_CHECK=1 and PI_TELEMETRY=0 and installs fd-find, so base and every image on it build again once. The agent store mounts and copies pi's settings, with keys redacted as JSON. pi's auth.json is a new login kind: its API keys for Anthropic, OpenAI and OpenRouter become per-VM placeholders the proxy fills in (devvm agent login pi --api-key --provider PROVIDER), and everything else is withheld by default, unless config.toml's [pass-keys] lists the provider. pi's own account logins aren't supported, and pi has no musl build, so a musl VM refuses it (image.ToolDef.GlibcOnly). Its sessions go into devvm history export and import. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3c4e90da0c |
fix(tools): opencode's backend is named, so mise's registry can't move it to npm (#10)
## What this changes
**The cause.** The pin bump in
|
||
|
|
e0c4ed97e4 |
fix(vm): bound what devvm reads from a VM
The history export keeps at most 2 GiB: past it, devvm stops the VM's command, removes the partial file and keeps no export. devvm history export fails with history_too_large; devvm rm, devvm rm VM and a remake warn with it and go on. opencode's import of devvm's logins (devvm agent login) is read up to 1 MiB, then stopped and refused (opencode_import_too_much). Each VM command adds at most 4 MiB to the run log (Env.vmLog), then a "devvm: truncated" line. agentsave's bounded writer is the one owner, in bounded.go: it takes in vm's capped, and with a cancel it fails every write past its max, so a command that keeps writing ends. Its buffer is a field: embedded, it gave the writer bytes.Buffer's ReadFrom, which io.Copy (os/exec's copy of a command's output) used in place of Write, so no cap held, agent save's 128 MiB included. vmssh's capped had the same flaw, fixed the same way. Env.HistoryMax, and DEVVM_HISTORY_MAX in a test build, stand in for the export's cap in tests. The stub guest's opencode-floods and history-floods switches write without end. Tests: TestBounded (io.Copy too), TestVMLog, TestExportTooLarge, TestRemakeHistoryTooLarge, TestImportLoginsTooMuch, TestShellFloods, vmssh's capped through io.Copy; history_import.txtar (an export that never ends: export fails, rm deletes and warns, the run log truncated) and agent_login.txtar (opencode's import floods). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d44175601 |
refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b6b60d5cf3 |
fix(agents): opencode 2 VMs get the store's changed logins and keys at each launch
opencode 2 keeps its logins in its database, so a VM whose database existed kept the logins it had: a key saved from another VM, or a ChatGPT login for another account, never reached it. Every launch's setup now sends the store's opencode logins as opencode auth import reads them (agentlogin.OpencodeImport: each API key the proxy puts in and OpenAI's Codex login, placeholders alone, IDs cred_devvm_<provider>; methodID chatgpt-browser and a whole-number expires, as opencode 2.2.5's credential schema needs). The new guest script assets/guest/opencode.sh reads them on its input, never argv, and, once opencode has a database, imports them when they differ from its record (~/.local/state/devvm/opencode-import.json) or when the database no longer holds one of devvm's IDs (deleted, or replaced by a history import; checked with opencode auth export, only the IDs kept). It logs out of devvm's earlier entries (opencode auth import skips an ID it has), imports each entry on its own and switches its provider to devvm's entry; the user's own credentials stay in the database. devvm agent login opencode --api-key runs the same script at once, in place of the old one-key import. The record lives in the VM because only the VM knows its database and what it holds. No partial success: a provider whose import opencode refuses is printed as devvm-opencode-failed PROVIDER, the script exits 1 and records nothing, so the next launch tries again, and devvm agent login names the providers in the new message opencode_import_failed. Three faults found on real opencode 2.2.5 VMs and fixed: bash -lc runs ~/.bash_logout (Debian's clear_console, failing without a terminal), which under set -e became the script's status after a good import, so the work runs in a subshell; opencode 2.2.5 made its database without importing auth.json while the script had recorded the entries anyway, so nothing is recorded until the database exists; and a missing expires becomes 0. Every VM also sets OPENCODE_DISABLE_AUTOUPDATE=1, beside Claude Code's DISABLE_AUTOUPDATER in base's /etc/profile.d/devvm-tools.sh: the agents are read-only shared tools whose versions mise pins. Tests: TestOpencodeImport; TestOpencodeScript (the script against a fake opencode: no database, an import, the same input again, a database made again, a refused entry); TestOpencodeRefused; TestToolsEnvironment; agent_login.txtar (the script at a key's save, opencode-import.json in the setup, a refused provider named through the guest stub's new opencode-refuses switch). e2e's network section: OPENCODE_DISABLE_AUTOUPDATE in an opencode VM's login shell; a second opencode VM with a database and a credential of its own gets a key saved from the first at its next launch, its own credential kept; and gets it again once its database is deleted and made again. Failures print opencode.sh's stderr, the run logs' opencode lines and the VM's credential IDs. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b4b19759c5 |
feat(guest): a guide to devvm in every VM, for the agents in it, and devvm-help
Every launch sends assets/guest/guide.md with the guest setup, and sync.sh installs it as /usr/share/doc/devvm/README.md (root's, mode 644, again whenever it differs) with /usr/local/bin/devvm-help, which prints it. The guide covers what a devvm VM is, network tiers and secrets, tools and installs, and the host commands to ask the user for. TestGuideCommandLines checks that the guide is among TestCommandLines' files and that each devvm command and flag it names exists. Docs: using/coding-agents.md's The guide in every VM. e2e: the project section checks the file's owner and mode, devvm-help's output and that the VM's user can't write it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
36f910839e |
fix(desktop): browsers reach the web through a local proxy that adds the VM's password
Chrome, Chromium and Firefox ignore the password in HTTP(S)_PROXY, so in devvm desktop they asked for the proxy's username and password on every site. The guest setup now writes devvm-local-proxy, which socat (now in the desktop layer) serves on 127.0.77.1:3128, the VM's loopback alone. For each connection it reads the request's head, drops the client's Proxy-Authorization and Proxy-Connection, adds the VM's password and sends it to devvm's proxy, then socat carries the rest both ways. It takes only CONNECT HOST:PORT and absolute http(s):// requests, the latter with Connection: close, so each connection's one request carries the password. devvm-desktop starts it and points the Xfce session's http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY at it; on Xfce, Chrome and Chromium read those, and Firefox reads them first with its default system proxy setting. A blocked host still gets the proxy's 403. - proxy.LocalProxyAddr, LocalProxyPort, IsLocalProxyAddr: the one owner of the address, sent to the guest as DEVVM_LOCAL_PROXY (vm.localProxy). - vmssh: the port forwarder never forwards a server on 127.0.77.1. - Tests: netpolicy's TestLocalProxy runs sync.sh's script (bash 3.2 on macOS) against a fake proxy: the password replaced, Connection: close, a tunnel, the 403 passed on, origin-form and junk refused with 400 before any connection; TestListeners, TestIsLocalProxyAddr, TestLocalProxy (vm), sync.txtar. e2e desktop (tests/e2e.sh, still the bash section): the session's variables, the listener on 127.0.77.1 alone, curl without a password to github.com, example.com's 403 over CONNECT and plain HTTP, 400 for origin form, nothing on this machine's 3128. - Docs: using/desktop.md (Browsers), internals/desktop.md (The local proxy), design.md's desktop note, ports.md, network.md's setup. Security review (security-audit skill, guidance mode, local IPC and proxy request handling): - Fixed by design: devvm forwards every VM port by default, so a local proxy on 127.0.0.1 would have put a password-less route to the VM's proxy, and its secrets, on the host's localhost for every local user. The forwarder now skips the local proxy's address on every port. - The password goes only to the VM's proxy, whose address is fixed in the script, never to an address a request names, in the one header the local proxy adds; devvm's proxy strips Proxy-Authorization before forwarding. It's never in a process's arguments (bash builtins only). - Web pages: requests from a page to the loopback are origin form, refused with 400 before any connection; a page can't send CONNECT or an absolute-form line, and DNS rebinding changes only Host. - No new power in the VM: the same password is in /etc/environment; the script is mode 700, the VM user's. - Residual: a program in the VM can hold up to 256 connections slowly (30 s a line, 100 headers), only against the VM's own browsing; an ssh -L the user types to 127.0.77.1:3128 would expose it, as any forward they choose. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
62cdd16dd4 |
feat(agents): devvm agent login claude, Claude Code's login captured in the VM for every VM
Claude Code logs in from inside a VM, so this machine never needs it, and devvm keeps one Claude Code login on the host for every VM with Claude Code: the subscription's OAuth login, or a Claude Code token from claude setup-token. The newest replaces the other. The VM holds placeholders alone, so claude /login in a VM no longer leaves real tokens there. - Capture: every VM's proxy captures at platform.claude.com and console.anthropic.com /v1/oauth/token (agentlogin.Endpoints), only for a VM whose image has Claude Code (netpolicy.Capturer). setup-token's code grant (expires_in, agentlogin.SetupToken) gives the claude secret (agentlogin.ClaudeToken, secrets.Token's checks) and the VM the secret's placeholder. Any other code grant goes in the store's .claude/.credentials.json (a File of kind agentlogin.ClaudeOAuth: claudeAiOauth accessToken, refreshToken, expiresAt ms, scopes); the VM's reply holds sk-ant-oat01-devvm-proxy-managed-oauth-<salt> and a managed refresh token, and the VM's own refresh is answered from the store. Refused: a new login without user:inference (Console), any login or refresh with org:create_api_key, an access token that isn't sk-ant-oat01- shaped. - One login: saving the claude secret (captured or devvm secret set claude) removes the OAuth login, and an OAuth capture deletes the saved token, both under the claude logins folder's lock (agentlogin.LockFolder); a token that can't be deleted is a warning. CLAUDE_CODE_OAUTH_TOKEN in devvm's environment wins, as in Claude Code (secrets.ClaudeOf(store).Login). A launch gives the VM either CLAUDE_CODE_OAUTH_TOKEN or ~/.claude/.credentials.json (placeholder, managed refresh token, expiry 2099), never both. Both bindings (claude, claude-oauth) go into Authorization for api.anthropic.com while either login exists, and Store.Get gives each the login devvm keeps now, so a running VM survives the switch. - Refresh: the host refreshes the OAuth login when due, JSON to platform.claude.com with Claude Code's client ID and the login's scopes, through the company proxy (proxy.RouteOf), under the file's lock; claude_refresh_failed says to log in again. - devvm agent login claude [--setup-token]: claude auth login --claudeai or claude setup-token in the VM without CLAUDE_CODE_OAUTH_TOKEN, the code pasted back on this terminal (no forward); the VM is set up again once the store has a new login of the kind asked for (secrets.ClaudeOf(store).Sums); claude_env_token_wins when the environment's token wins. --device-code, --api-key and --stdin are usage errors with claude, --setup-token without it. - Confirmed in Claude Code 2.1.317's linux-arm64 bundle (sha256 checked): TOKEN_URL platform.claude.com/v1/oauth/token, client ID 9d1c250a-e61b-44d9-88ed-5944d1962f5e, the JSON code and refresh bodies, setup-token's expires_in 31536000 and user:inference scope, the claudeAiOauth fields, the anthropic-beta oauth-2025-04-20 header Claude Code sends itself, claude auth login's pasted code#state on stdin. The real claude auth login logged in in e2e against the fake. - Messages: agent_login_claude_paste, claude_login_saved, claude_setup_token_saved, claude_env_token_wins, agent_login_claude_flag, agent_login_setup_token_alone, claude_refresh_failed, claude_no_login; no_claude_token, claude_token_invalid, claude_token_howto and not_setup_token point at devvm agent login claude. - Tests: TestClaudeCapture, TestClaudeSetupToken, TestClaudeOAuthGet, TestCaptureRefuses' Claude cases (agentlogin); TestOneClaudeLogin, TestClaudeBindings, TestClaudeOAuthVMCopy (secrets); TestCapturer's Claude cases (netpolicy); agent_login.txtar's Claude section; network.txtar's bindings. - e2e (network): the fake company proxy fakes Claude's token endpoint and Anthropic's API too; setup-token's request makes the claude secret; devvm agent login claude runs the real claude auth login, the store keeps the login, the claude secret goes, the VM holds placeholders and no token, the API gets the store's token for the VM's placeholder; a due login makes the host refresh through the company proxy (which fails there, as the host doesn't trust the run's CA). - Docs: Claude Code login (using/coding-agents.md), first VM, the home page, README, commands, settings, safety/network.md, internals network.md, the design note's risk that this path is unofficial, Contributing's e2e, the proxy README; the CLI reference. Security review (security-audit skill, an independent read): - Fixed: a login granting org:create_api_key would let a VM make an API key through the binding and get it unread: refused, on refresh too. - Fixed: a refresh could install a Console login when the store had none: the scope check applies to every new login. - Fixed: any VM, without Claude Code, could replace the login or delete the token with a refresh grant: only a VM with Claude Code captures. - Fixed: two captures at once could leave neither login: one lock. - Fixed: a saved token that couldn't be deleted gave the VM a 502 for a saved login: a warning instead. - Fixed: captured and refreshed access tokens are shape-checked. - Accepted, documented: the bound login reaches every api.anthropic.com path its scopes allow (profile, sessions); any VM with Claude Code can replace the login; a token Claude Code mints in a VM for another use (install-github-app) becomes devvm's login. - Unconfirmed: whether another Anthropic host also answers /v1/oauth/token (it would pass unguarded). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fcbab78670 |
refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its tier, so even an open VM never holds a real secret: a request that goes around its proxy carries only the placeholder. - vm/sync.go: the open branches of stage go (the agents' logins copied as they are, the ClaudeCopy for unconfined VMs and its MCP warning, real values in ~/.config/devvm/env); stageNet is stageSecrets, run for every VM, and the salt is every VM's. - netpolicy: Prepare readies the CAs, salt and secret files on every tier, and the proxy config carries the CAs and bindings on every tier; dropCA and its caller are gone, so a VM keeps its CAs as its tier changes. - Removed without a caller left: the messages secret_unuse_copied, net_on_old_tokens and claude_mcp_secrets_copied; secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets, claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly. - Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for another host), TestStageSecretsEveryTier (every tier's setup sends the VM's CAs, the guard against a tier's own path); sync, ca, network and secret scripts for open VMs. - e2e: network checks that an open VM holds no real secret (its proxy puts the token in over TLS the VM verifies, a direct request carries only the placeholder and gets a 401); project checks an open VM's placeholder, and its company-CA checks allow for the VM's own CAs in /etc/ssl/devvm.pem. - Docs: safety/network (tiers, secrets), internals/network, the design note's tiers threat check, attack vectors, coding agents, first VM, staying safe, contributing; devvm secret's help. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c0f4b8fb5c |
feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none, in its state's net section (netpolicy.Tier), in place of on/off. Every VM has its proxy. Confined tiers start on NetProxy; open starts on the backend's own network with its proxy set in the guest (Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off. The proxy: Config.Open (every host and address, no floor, no policies), Config.DenyPolicies (files whose denies alone apply), the rule port :* (any port), and ** matching address literals (the floor still holds). Policies per tier (netpolicy.PolicySet): internet is network/internet.policy (**:*) plus your denies; none is the agents' built-in policies, the secrets' hosts and your denies; open none. Links: a client links only to a target on its tier or a stricter one, and a group's VMs are all on one tier. The self-check per tier: open asks its proxy through the guest's settings and warns (net_proxy_unreachable). devvm ls and devvm network show the tier. A backend without egress-proxy offers open alone (net_tier_backend). devvm network on/off and --network-policy/--no-network-policy map to allowlist/open. Design note, threat check and docs; e2e in the network and link sections. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
317bd8f978 |
feat(agents): devvm's agent store, filled by devvm agent import
Every VM gets its agents' settings and logins from devvm's own store, never from the agents' files in the home folder: settings in ~/.config/devvm/agents/<agent>/, logins in ~/.local/share/devvm/logins/<agent>/ (folders 700, files 600, each agent's logins folder kept out of Time Machine), each laid out as in a home folder. The store's settings folders are mounted read-only and linked into the VM's home; its files and logins are copied in, with network policy as placeholders the proxy fills from the store. devvm agent import [AGENT...] [--force] copies the home folder's agent settings and logins into the store once: only agentDirs, agentFiles and secrets.LoginRel's paths, never history; .claude.json reduced to its settings, account state and MCP servers; read through each agent's folder as an os.Root, so no link out of it is followed (a link to a file inside becomes a copy, any other is left out with a warning, and so is a login file that's a link); Claude Code's plugin records renamed to the store's folders. It asks before replacing what the store has (refused without a terminal, naming --force), replaces in place, keeping the mounted folders, and prunes what the home folder no longer has. - paths: Dirs.AgentSettings, Dirs.AgentLogins - secrets: LoginRel, LoginFile(Dirs, kind), SaveLogin, HasLogin, Store.ExcludeFromBackup; Logins, VMLogin, ClaudeCopy, MCPSecrets and the proxy's Get read the store - vm: agentStore, agentMounts/homeSkips/Inventory.Mounts take Dirs, syncer.stageAgents, AgentImport; the guest's links file holds each folder's home path and its mount's (host_home is gone) - structure: callers takes methods (pkg.Type.Name); Dirs.AgentSettings only in vm/agents.go, Dirs.AgentLogins only in secrets/secrets.go - messages: agent_import_none, agent_import_nothing, agent_import_replace, nothing_imported, agent_settings_imported, agent_login_imported, agent_import_link_left_out, agent_login_read_failed, agent_import_failed; the login refresh messages point at devvm agent import - tests: agentimport_test.go, testdata/script/agent.txtar, sync and network scripts through the store, e2e project and network sections - docs: coding agents (devvm's agent store, importing from this machine), README, getting started, safety, internals, contributing Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0b82dc189f |
feat(vm): a moved folder's Claude Code history follows it
A folder move records the path the agents' state is under in the VM's state (the moved section, set in recordMove under the VM's lock: the first move's old path, kept through more moves, cleared by a move back). The VM's next setup gets a moved file with both paths and their Claude Code slugs (claudeMoved, claudeSlug), and guest/claude.sh's claude_project_moved renames ~/.claude/projects/<old slug> to the new one, or merges into it without replacing anything, and moves ~/.claude.json's projects entry (claude_json_project_move, kept on its own for reuse). Once the setup succeeds, followed clears the section. The slug is Claude Code's own rule (2.1.318's sanitizePath): every UTF-16 unit but an ASCII letter or digit a dash; over 200, cut and ended with "-" and abs(h*31+u, int32) in base 36. Tests: TestClaudeSlug, TestClaudeMoved, TestClaudeProjectMoved, TestMovedTo, TestFollowed, TestMoveHere's record and its clearing, move.txtar, e2e project's moved checks. Docs: commands.md's moved folder (Claude Code, Codex, opencode), internals overview. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ea7af7c337 |
fix: each VM's SSH agent travels with its own commands, never devvm's environment
devvm set SSH_AUTH_SOCK process-wide from the finder's inspect, each start and a new VM's plan, so later limactl calls and every background process devvm spawned got whichever VM's agent was set last: a run that reached several VMs (a group's sync, a link's change) could hand one VM another's agent, and ssh-add -l checked the wrong agent. - vm: Env.useAgent is gone; Env.agentSocket maps a choice to its socket (devvm's, the user's from Environ, or none). The finder's found carries agent, set by inspect and by bringUp from the confinement it returns; found.exec passes it. start sets Confinement.AgentSocket for every mode, runningConfinement takes the running mode and sets it too, and the sync, devcontainer commands, --clone's seed, home copy, export, desktop and the shell carry it. - backend: ExecOpts.Agent, ShellOpts (Shell takes it), AgentSocket "" means none; the backend never reads devvm's SSH_AUTH_SOCK. - lima: limactl removes SSH_AUTH_SOCK from every command; Exec, Shell and start (confine) set the VM's own; a degraded start's check carries it. - daemon: Spawn drops SSH_AUTH_SOCK from the child environment. - Guard: forbidigo bans os/syscall Setenv, Unsetenv and Clearenv outside tests and daemon/status.go; testdata/lint breaks it. - Tests: TestAgentPerVM (two VMs, devvm's and the user's, in one run), TestDetach (no agent), TestExecAndShell and TestProfileAgent (Lima's per-command env), TestUpSSHAgent and TestOpenAgent check the shell's and Exec's agents and that devvm's environment stays as it started. - Docs: internals/security.md (how the agent travels), contributing's forbidigo list and owners table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
82127e7f2c |
refactor: Lima's builds take the company proxy from settings.CompanyProxy, vm calls agentlogin.Redact, and watched's chmod blind spot is documented
- Lima's buildUpstream asks the backend's settings.CompanyProxy (Lima.Company, cp from New, else one over the backend's Getenv) instead of running settings.HostProxy and HostProxy.Upstream again, so a build's check is the one VMs' proxies use, config.toml's password saved included. TestBuildUpstreamConfig covers the missing password, the lookup, NO_PROXY and no company proxy. - secrets.Redact, a one-caller pass-through, is gone: vm's stageNet calls agentlogin.Redact, whose own tests cover it. - watched[T] misses a change of mode or owner alone (its stamp is mtime, size and inode): documented in the proxy README and internals/network.md, with TestWatchedChmodOnly. - The shared ~/.local/share/devvm/ca that development builds from before layout version 1 left: a line in Contributing's state layout section says to delete it (no migration: nothing shipped). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
389ac9f326 |
fix(vm): a VM without network policy gets only ~/.claude.json's settings, account state and MCP servers
Without network policy, the setup sent the host's whole ~/.claude.json: primaryApiKey and customApiKeyResponses reached the VM's own ~/.claude.json, and the projects' history its setup's staging folder, though sync.sh dropped it from the merge. agentlogin.ClaudeCopy keeps only claudeTopKeys (claudeTop, which the network policy copy uses too), with the MCP servers as they are, and the setup sends it (Store.ClaudeCopy) for every VM without network policy. A ~/.claude.json devvm can't read stops the setup (login_copy_failed) instead of reaching the VM unread. stage.has had no caller left. Tests: sync.txtar's ~/.claude.json with an API key, its answers and a project's history, none of which the copy holds (failing before), and one that doesn't parse; TestClaudeCopy. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aee099e52c |
fix(agentlogin): opencode OAuth logins devvm doesn't bind lose their tokens, and opencode's other files stay on the host
With network policy, an opencode OAuth login devvm doesn't bind (Copilot Enterprise, a provider it doesn't know) reached the VM with its refresh token, against network policy's promise that a VM never holds one, and opencode's config folder's files that aren't settings, such as a .env, were copied unredacted. The VM's copy of opencode's auth.json now has devvm-redacted for such a login's access and refresh tokens, and devvm warns (opencode_login_withheld); API keys for providers devvm doesn't know stay as they are, warned as before. File.VMCopy returns a VMFile (Data, Kept, Withheld). With network policy, the VM doesn't get opencode's files that are neither settings nor Markdown (withheld in sync.go), each named with config_not_copied; AGENTS.md and other Markdown still go. Tests: TestOpencodeUnboundOAuthWithheld (failing before), TestWithheld, TestVMCopies's opencode_login_withheld, sync.txtar's opencode .env and AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1640feb608 |
feat(netpolicy): one CA per VM, with a successor the VM trusts ahead of time
Each VM with network policy has CAs of its own in its run folder, vms/<hash>/run/ca/ (paths.VM.CA, paths.CA: ca.pem/ca.key, next.pem/ next.key; folder 700, keys 600, kept out of Time Machine on macOS), so a leaked key reaches one VM and no proxy can sign for another VM. The shared ~/.local/share/devvm/ca (Dirs.CA) is gone. trust.InitCA(paths.CA) readies the current CA and the next one at each launch: the current one stays while it has over a week left, then the next one (started) takes its place, else a new one; the next one starts a week and an hour before the current one ends and is made again when it doesn't follow it. Each CA lasts 30 days and an hour, and its common name holds its serial, so a VM's two CAs never share a subject. The proxy's config gains ca_next, ca_next_key and ca_next_sha256 (part of Sum); the proxy signs with the next CA from an hour after its start (ca.signer), so the switch needs no launch or new proxy, and a VM not opened again stays verifiable for at least 30 days less an hour after its last launch. /ca.pem serves both certificates. loadCA reads the CA files with readPrivate (no links, a key only the user may read, 64 KiB cap) instead of tls.LoadX509KeyPair. The VM's setup sends both certificates (devvm-proxy.crt, devvm-proxy-next.crt) and no key. Tests: TestInitCA, TestInitCASwitch, TestInitCAReplaced (trust); TestNextCASigns, TestLoadCA, config check rows (proxy); TestPrepare and TestPrepareRestartsTheProxy for the VM's CA files and both sums (netpolicy); TestVMFiles; network, sync and layout txtar; e2e network: a second network-policy VM with different CAs, each VM trusting only its own and holding no key, each proxy serving and presenting only its own VM's CAs, devvm rm deleting one VM's CAs. Docs: internals/network.md (The VM's CA), design.md (A CA per VM, its threat check), safety/network.md, overview.md's per-VM files, space.md, security.md, attack-vectors.md, limits.md, coding-agents.md, contributing, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f6f62d28a |
refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name, alias, image, chain, from, dir, folder, backend, backend_at, created) and one section per package, each a json.RawMessage its owner decodes into its own type (state.Section, state.SetSection), what was asked for at its top level and what devvm made under "made": net (netpolicy), git (gitprotect), ports (the new internal/ports), agent (sshagent), tools (tools), secrets (secrets), and size, clone, devcontainer, desktop and links (vm, internal/vm/state.go). - state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the file again, applies a change and writes it once; a failed change, or write, writes nothing. VM.Set and its calls are gone; read-modify-write of lists (links, publish, secrets, tools, size, ports) happens inside Update. VM.Claim also holds run/claims.lock, after the VM's own; VM.Create writes a new VM's whole record once, its alias chosen (sshconfig.ChooseAlias) under the claims lock. Reads take no lock. - created replaces "net unset" as unfinished (VM.Finished). - internal/ports: the ports section (forward, host.ssh/proxy/desktop), ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy and desktop ports under the claims lock (desktop allocated without one before; run/ports.lock and netpolicy's own ports key are gone). - gitprotect: mode recorded before the backend makes the VM (NewMode; clone for --clone, which ls and git-protect share as gitprotect.Mode); made.git_id (platform.FolderID), one git_dirs list for modules and embedded git dirs, delegations, protected; Unlock takes the union of recorded and current git dirs. - links' entries, git dirs, tools and devcontainer commands are JSON lists, not strings in values; the key=value parser is gone. - vm.checkState reads every section of the folder's VM as it's found. - registry.For drops its unused Dirs. - Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate, TestVMUpdateTogether (two writers on one VM and on crossed VMs), TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether, TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded, TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a134e0d8a6 |
feat(cli): choose a new VM's toolchains, agents and layers in a picker or with --tools, --agents and --layers
devvm takes no IMAGE word any more than any other: in a terminal a new VM's toolchains, coding agents and layers are checked in one picker, under three headings, before the network-policy question; --tools, --agents and --layers (each an exact list, or none) skip it, and a part left out takes its default: the detected toolchains, devvm setup's agents, no layers (a devcontainer.json's features still count). Without a terminal, or with --no-input, the VM gets the defaults and new_vm_gets says so in one line. devvm setup --agents (and its first-run question) chooses new VMs' agents. devvm tools in a terminal opens the same picker for the VM, its layers fixed, and turns the changes into tools add and rm. An image is base and layers only: tools are the VM's tool_names state key. build, rebuild and images rm refuse a shared tool (tool_not_layer), and devvm build builds no tool images. devvm ls gains a TOOLS column and --json tools. gc's --tools is --tool-images, so --tools has one meaning. Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or no_command_like, did-you-mean over commands, msg.Closest), the lacks path in internal/vm/existing.go, and the messages vm_lacks_tools, vm_lacks_layer, layer_is_command, layer_name_command, no_image_for, no_command_or_image*, tools_not_images, tools_not_images_rm, detected, vm_is_now (vm_tools_now), secret_with_image (secret_with_claude). New: ui.Pick takes headed sections with fixed rows, ui.CanPick, vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go), state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents, project.DetectFiles. Image keys are unchanged in form: images never held tools; docker.sh's and nix.sh's comments changed, so those layers rebuild. Docs: the home page's quick start steps, diagram (sandbox.svg), cards and FAQ; README; getting started; using (images' What a new VM gets, coding agents' Running an agent, settings' agents); internals; contributing; the cli skill; AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9f791bc96 |
refactor: one owner for the proxy's constants, URLs, variables and tunnels
The proxy owns the links' addresses and domain and the proxy user: proxy.IsLinkAddr, proxy.LinkAddr, proxy.LinkDomain and proxy.ProxyUser replace vm.IsLinkAddr, vmssh.IsLinkAddr, vm.LinkNet, vm's linkNetAddr, vm.LinkDomain, netpolicy.LinkDomain and the proxy's own isLinkAddr and linkDomain. TestLinkAddrsAgree goes, because there's nothing left to agree. The proxy's link list now refuses an IPv4-mapped address too, as vm's parser already did. backend owns the guest's view of a proxy: ProxyUser (proxy.ProxyUser), ProxyURL, GuestProxyVars, ClientProxyVars and NewProxyPassword replace four URL builders (BuildProxy.URL, Lima's, Docker's and smolvm's), the user written out in three places (netpolicy.ProxyUser, buildProxyUser, Docker's proxyUser), the guest's variable list in three (Lima's inline loop, smolvm.proxyVars, Docker's proxyVars) and the client's in two (limaProxyVars, Docker's noClientProxy list), and the two password generators. Confinement.ProxyUser goes: Docker ignored it, and every backend now uses ProxyUser. A new VM's proxy key is NewProxyPassword's 64 hex digits, as a build proxy's was; a VM keeps the key it has. doctor reads HTTPS_PROXY through backend.ReadHostProxy. In the proxy, hijack and splice replace the three CONNECT copies (tunnels to allowed hosts, tunnels to links, interception's hijack) and the relay's pipe. A tunnel passes the bytes as they are, passes on the end of what the client sent, and ends, closing both connections, when the server's bytes end or the client has gone. A relayed connection now ends with the proxy's side too, where before it waited for both. Tests: splice_test.go characterises the allowed-host tunnel, the link tunnel and the relay (a megabyte of every byte value, a half-close answered, a client that goes away ending the tunnel), written against the code before this change; TestSpliceEnds, TestHijack and TestIsLinkAddr (every LinkAddr) are new, and so are TestProxyURL, TestNewProxyPassword and TestProxyVars. TestLinkListRefused gains a mapped address. e2e: the relaunch without a company proxy says which step failed, with the launch's output, the VM's status and the proxy's log, and a link helper that doesn't start shows its output. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5003d94cfb |
refactor: read HOME once, into paths.Dirs.Home
paths.FromEnv reads HOME, which must be absolute, and keeps it, cleaned,
as Dirs.Home; everything else takes the home folder from there. Six other
reads go: vm.NewEnv's and cli's devvm secret's os.Getenv("HOME"),
gitprotect.New's, Docker's and smolvm's os.UserHomeDir (Desktop's
settings file, the machines' location), and smolvm's Getenv("HOME")
(DiskDirs).
- vm.Env.Home and secrets.Store.Home are gone: both read Dirs.Home.
secrets.NewStore takes the Dirs alone; gitprotect.New takes the home
folder for ~ in git's paths.
- forbidigo bans os.UserHomeDir, with its line in
testdata/lint/forbidigo.go; the structure test's owners check gains
envOwners, HOME read only in internal/paths/dirs.go, with cases for a
read outside it, through a field, in paths and in a test.
Tests: TestFromEnv checks Home (and a HOME cleaned), TestNewHome (~ is
the home New is given, not the environment's), TestDiskDirs checks
Location too. Coverage unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
82566e9010 |
refactor: shell quoting, the VM-name grammar and value patterns each in one place
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.
internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.
Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.
netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.
The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
9c2511117b |
fix(hostgit): host git runs no program a repo names, nothing of devvm's environment, and ssh only to the VM
devvm ran git on the host bare: --clone's git status could run a repo's core.fsmonitor or filters, its push, fetch, update-ref and remote remove the repo's hooks, and git could ask on devvm's terminal or follow GIT_DIR from devvm's environment. internal/hostgit is now the one runner (Command, Output, Status), with its settings as GIT_CONFIG_COUNT pairs: core.fsmonitor=false, core.hooksPath=/dev/null, core.alternateRefsCommand=true, hook.EVENT.enabled=false for every githooks(5) event, protocol.allow=never with protocol.ssh.allow=always; and, for a command with -C DIR, hook.NAME.enabled=false and filter.NAME's clean/smudge/process emptied with required=false for each hook and filter driver DIR's config names. It drops every GIT_* variable and relative PATH folders, and sets GIT_TERMINAL_PROMPT=0, GIT_NO_LAZY_FETCH=1 (a repo that says it's a partial clone fetches nothing, with its core.sshCommand or ssh), GIT_SSH_COMMAND=false (no ssh but gitSSH's) and GIT_SSH_VARIANT=ssh; maintenance.auto=false and gc.auto=0. Status adds --no-optional-locks and --ignore-submodules=all. Callers: gitprotect (git, ignoreSubmodules), project.SSHRemote, vm/sync's gitConfig, vm/clone (hostGit, gitSSH, saveFetched, the uncommitted-changes status). gitSSH takes the VM: ssh with BatchMode, StrictHostKeyChecking, devvm's known hosts only, HostKeyAlias=VM, ForwardAgent=no and ClearAllForwardings=yes, so a url.*.insteadOf reaches only the VM with its pinned key. The seed push adds --no-verify, --no-recurse-submodules and --no-signed; rm's fetch --no-recurse-submodules. Not neutralized: an include.path can make gitConfig read user.name/email from another git-config file (sent to the VM as its identity), and a FIFO as a config file hangs git until Ctrl+C; neither runs code. A VM swapping the repo's config between repoOff's listing and the command could hide a filter from it, and a --clone VM's root (its host key) working with another VM that writes the repo could send the push to a server of theirs; both documented in internals/git-protection. Tests, each with plain git first running what the hardened one doesn't: hostgit's TestCommandNoFsmonitor, TestCommandNoHooks (reference- transaction, pre-push, from .git/hooks and a core.hooksPath; path, file:// and ext:: pushes refused), TestCommandNoConfigHooks (hook.NAME.*), TestCommandIgnoresGitEnv (GIT_DIR, GIT_WORK_TREE; environ), TestCommandNoLazyFetch (a partial clone's core.sshCommand), TestStatusNoFilters (clean, process, required, names with dots, = and capitals), TestStatusNoSubmodules; vm's TestHostGitNoFsmonitor and TestCloneRunsNoHooks (seed push and rm's fetch, update-ref and remote remove); clone.txtar's push ssh options. Docs: safety/attack-vectors (devvm's own git commands), internals/git-protection. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7929eafaf5 |
fix(msg): every message value renders without control characters
A value a VM made reached the terminal unfiltered wherever a caller forgot msg.Shown, such as the errors passed as err.Error() and a link's name. Four cleaners did the job in different ways: msg.Shown (quoting), ui's printable and oneLine, netpolicy's oneLine and the port forwarder's log (which let C1 through, in UTF-8). msg.Printable and msg.OneLine are now the one cleaner: they drop C0 but newline and tab (OneLine drops those too), DEL and C1, in UTF-8 or as a lone byte. Every message value goes through OneLine as the message renders, in Text, Segments and names mode, so no caller can forget it, and msg.Shown is gone with its 68 calls. The status line, the run log's end and verbose output, Pick, devvm network log, the forwarder's log and a clone's status lines use them too. Tests: TestPrintable and TestValuesArePrintable (internal/msg), the hostile-value segments test, TestLogLimit (internal/backend/vmssh) with C1 in UTF-8 and as a lone byte; TestCheckLinks and TestNewVMOtherRepoAndCommondir expect the cleaned values. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5db31c92be |
feat(link): the per-VM proxy reaches a VM's links, and link names leave NO_PROXY
In a VM with network policy, an HTTP client that honors HTTP_PROXY now reaches a link through the VM's proxy, so a link added while the VM runs works at once and nothing restarts. The ssh remote forward stays the transport for every link; the proxy is a second entrance to the same host socket, and devvm _links's per-connection checks apply to both. - devvm _links writes every link the client has, carried or not, to run/<vm>.links.json (proxy.LinkList, mode 600, written whole) whenever they change or the file is gone; it stays after the session, so a link with no socket is refused rather than asked of the rules. Forget removes it with the VM. - devvm _proxy -links FILE reads it per request (regular file, no symlink, owner-only writes, 1 MiB, version 1, O_NONBLOCK), before any rule: CONNECT and absolute-form http, exact match after lower case and one trailing dot, NAME and NAME.devvm.internal. An entry counts only when its socket is proxy.LinkSocket(list folder, -vm, addr, port) and its address is in 127.77.0.0/16. Bytes pass as they are: no SNI check, interception, secrets or rules; absolute form goes in origin form without the proxy's headers, one connection per request, cancelled with the client's request; https in absolute form gets 400. No event for a carried link (devvm _links logs link); a dead socket gets 502 and link_refused "not carried", after retries for a full backlog. Any other name under devvm.internal is refused (403, a refused block). - vmssh.Links.Socket uses proxy.LinkSocket and LinkHash (same names). - The link socket's accept loop only accepts, and hands a burst on whole (5 ms quiet, 50 ms at most, or 257 waiting) before relays start, as fork-heavy relay starts let macOS's 128 backlog overflow unlogged; past the cap, refused in the loop with link_limit. Temporary accept errors back off instead of ending the link. - NO_PROXY is localhost,127.0.0.1,::1 everywhere: netpolicy.LinkEnv and linksNoProxy are gone, netpolicy.NoProxy is a constant, the start only checks the links (checkStartLinks). No dockerd or nix-daemon restart and no limactl edit on link changes. assets/guest/sync.sh: comment only. - devvm network log's help says link events land there for every VM. - Docs: using/links.md, safety/network.md, internals/network.md (Links through the proxy, -links), ports.md, lima.md, design.md (the proxy's entrance, the burst, threat-check rows for the proxy path, links added while running and untouched bytes, the sshd row reworded, Not covered), contributing, internal/proxy/README.md. - Tests: proxy TestLinkConnect, TestLinkConnectUntouched, TestLinkForward, TestLinkGone, TestLinkListRefused, TestLinkDomainRefused, TestNoLinksFile, TestLinkSocket; vmssh TestLinksBurst, TestLinksList; netpolicy TestNoProxy and the -links argument; e2e lk_proxy_added and lk_proxy_own, and lk_cap's burst without pacing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
133a4d3cdb |
feat(guest): what a client VM needs for links: sshd's rule, low ports, /etc/hosts and NO_PROXY
Every VM's sshd (base.sh's 00-devvm.conf, services.sh) allows remote
forwards of TCP ports only on 127.77.0.0/16: AllowTcpForwarding all,
GatewayPorts clientspecified, PermitListen 127.77.*:*. Remote socket
forwards, tunnels and X11 stay refused. The setup sets
ip_unprivileged_port_start to 0 where it's 1024, writes the VM's links in
a marked /etc/hosts block in place (Docker's is a bind mount), and puts
DEVVM_NO_PROXY in every NO_PROXY it writes.
The links come from Env.Links (nil: none), a list of GuestLink {Addr,
Names}, checked on the host by checkLinks (link_setup_invalid) before the
start's NO_PROXY (netpolicy.LinkEnv) and the setup's hosts file. design.md,
security.md, smolvm.md and docker.md describe the sshd rule; e2e checks
it with rfwd_links on every backend, and low ports on Alpine and smolvm.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c9436eca97 |
fix(tools): bound the unmounted-tools read, drop a stale report first
After a failed setup, devvm reads /run/devvm/tools-unmounted from the VM with a command of its own. Root in the VM could make that read hang, so it now has its own 10 s timeout (unmountedWait, readUnmounted), after which no tool counts and the error is sync_failed. guest/sync.sh removes that report as its first command, so a report left from the VM's boot isn't read after a failure that comes before devvm-tools runs. Tests: TestReadUnmountedWait (a read in time counts; a hung one gives up after its wait); guest.txtar checks sync.sh's first command. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
906d598954 |
feat(trust): VMs, builds and the proxy trust a company's CAs from ~/.config/devvm/ca
Behind a proxy that inspects TLS, VMs and build VMs couldn't make TLS
connections. The CA certificates in ~/.config/devvm/ca (*.pem, *.crt) are
now read at each launch, build and proxy start, checked, and trusted;
images never keep them.
- internal/trust (new): Read parses every PEM block with crypto/x509 and
refuses anything but CA certificates (ca_not_certificate, ca_not_ca,
ca_invalid, naming the file); only the re-encoded certificates leave the
host. Env/GuestEnv (NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem,
SSL_CERT_FILE, REQUESTS_CA_BUNDLE, PIP_CERT, UV_SYSTEM_CERTS), Build
(a build's Add/Remove root scripts from guest/ca.sh), Script (Env
exported at a build script's start), Name, Bundle.
- assets/guest/ca.sh (new): installs exactly DIR's devvm-*.crt into
/usr/local/share/ca-certificates (update-ca-certificates --fresh), or
into the bundle file itself when there's no update-ca-certificates (the
old bundle kept and put back), writes /etc/ssl/devvm.pem; without DIR,
removes all of devvm's. sync.sh runs it with the proxy's CA
(ca/devvm-proxy.crt) and the user's (ca/devvm-extra-N.crt).
- backend: ImageSpec.Trust and ToolsSpec.Trust (backend.Trust{Add,
Remove}); VMSpec.Env. Lima runs Add after the start and Remove after the
scripts (runScript's root mode, sudo sh), the --from conversion VM runs
Add and oci/build.sh runs ca.sh in the image's chroot around bootify.sh
(guest/ mounted read-only, CA_SH argument); smolvm and Docker run Add
before prepare.sh and Remove after sshd.sh; tools builds run Add only.
Lima's clone sets the guest environment, so starts edit nothing.
- vm: every project VM starts with trust.Env (netpolicy.Env keeps only the
proxy's variables); the setup sends ca.sh and ca/; Dirs.TrustedCAs.
- proxy: -upstream-cas FILE adds CAs to the system roots for its own TLS
connections; netpolicy writes run/<vm>.proxy.cas and restarts a proxy
whose bundle changed.
- doctor: doctor_proxy_ca when HTTPS_PROXY is set and the folder has no
CAs (Say), a refused folder warned about.
- Tests: internal/trust unit tests (folder reading, scripts, ca.sh run in a
stand-in root with and without update-ca-certificates); ca.txtar; sync,
up, network, smolvm txtars and the limactl stub (clone's .env, list
shows lima.yaml's env); e2e: images (a layer built with a test CA, its
key unchanged, its image's copy without CA files), project ("a company's
CA" section), tools (node fetch), smolvm and docker build checks.
- Docs: using/settings (a company's CA), using/troubleshooting (TLS errors
behind a company proxy), internals/network and internals/images,
safety/network, design (assets written out), oci README, doctor's help.
- Structure: Dirs at 38 methods, trust.Env a table, trust above backends.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
b33b0a9b4c |
fix(tools): a shared tool that doesn't mount fails the launch
A tool image missing from the share, or one the VM couldn't mount or link, used to be skipped with a line on stderr, and mise's auto_install then downloaded the same version into the VM on first use. Now the launch stops with a message naming the VM and the tools. - assets/guest/tools.sh: tries every listed image, removes a failed one's empty mount point, says why on stderr, lists the failed files in /run/devvm/tools-unmounted (removed at the start of each run) and exits 1. Link failures (Docker's unpacked folders) count too. - assets/guest/sync.sh: its devvm-tools call failing fails the setup. - assets/container/services.sh: a devvm-tools failure doesn't stop a smolvm or Docker start; the launch's setup reports it. - internal/vm/sync.go: after a failed setup, syncer.unmounted reads the VM's report with its own Exec (capped at 16 KiB, unmountedMax), and reported keeps only whole lines that are one of the VM's own tool files from its state, so the message carries devvm's values, never the VM's text. The setup's output still goes straight to the run log (a pipe would wait on processes the setup leaves running). - internal/tools: label is exported as Label; VMs.Update builds the VM's tool images that the share lacks even when they're the newest, so devvm update repairs a missing image. - Message tools_unmounted (tools, vm), linked to using/troubleshooting#a-shared-tool-doesnt-mount. - Docs: troubleshooting "A shared tool doesn't mount"; images.md's shared tools and devvm update; internals/images.md "The share" has the mechanism; design.md says why. - Tests: TestReported (internal/vm), TestUpdate rebuilds a missing newest image, guest.txtar runs tools.sh with stubbed mount commands, sync.txtar checks tools_unmounted and that other report lines don't count (limactl stub: $STUB_DIR/sync-fails-with), e2e's tools section moves node's image out of the share and back. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3da0d6b0a6 |
feat(devcontainer): a project's devcontainer.json as input for new VMs
A new VM gets what the folder's .devcontainer/devcontainer.json (or .devcontainer.json) says, on every backend: image as --from (only an image its registry gives anyone, asked anonymously, pinned to that digest, never a registry on this machine or its network), features devvm has layers for (docker-in-docker as the docker layer, node, python, rust, go), forwardPorts as far as the user's ports allow, containerEnv and remoteEnv in the VM's environment, onCreate/updateContent/postCreate commands once and postStartCommand at each start, in the VM as its user. --no-devcontainer skips it; the command line wins. Later launches only warn when the file changed.
Nothing from it runs on or reaches the host: initializeCommand never runs, ${localEnv} and the host-folder variables are refused, builds, Compose and docker-outside-of-docker are refused, mounts, runArgs and privileged ignored. The file is read through os.Root, without blocking, at most 1 MiB. A docker layer only the file asks for still asks about network policy on Docker.
Reviewed with the security-audit skill (FuzzParse, design note); e2e: project 69/0, docker linux 135/0, smolvm 131/0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
548113d726 |
build(lint): enforce contexts, nolint reasons, reassign and function size
.golangci.yml: - forbidigo bans context.Background and context.TODO outside internal/ui and cmd/devvm. - nolintlint requires each //nolint to name its linters and say why, and reports unused ones. - reassign (patterns .*) forbids setting another package's variables, tests included. - revive keeps its default rules and adds function-length (100 statements, 160 lines) and cognitive-complexity (75). Fixes: - Backend.Lifeline takes a ctx: smolvm's machine data-dir lookup runs with the caller's. - The proxy's TLS handshake with a VM uses the request's context, limited to 30 seconds. - OAuth token refreshes run within refreshTimeout (30 seconds). - Tests use t.Context(). - Launch.create is split into plan, newVM.record and undoCreate. - lima's TestStartConfined is split into helpers. - smolvm's Terminal comes from its UI's StdinIsTerminal. - Unused //nolint directives are removed. - Fresh contexts that remain (an in-memory TLS parse, lookups shared by every request, a test cleanup) each carry a nolint saying why. Docs: contributing.md lists which lint rule enforces which convention; AGENTS.md names the linters behind its Go conventions. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
851e39ef86 |
build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/, shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which cli passes to every constructor; backends, the builder, the shared tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts reach VMs on stdin (backend.Script carries their contents). What needs a path (limactl create's base.yaml, oci/ mounted into the conversion VM, the proxies' policy files) is written out to ~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders 700; devvm gc deletes older copies no VM's proxy was started with (gc_assets, deleted_assets). Release archives hold the binary with README.md, CHANGELOG.md and LICENSE, and the formula installs the binary alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f24d2639e |
refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/, shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and oci/. devvm reads them from assets/ beside its binary (paths.Root, paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e put them there. Image keys hash them by their names in assets/. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1e4c772cc5 |
refactor(vm): split Env's commands into types by group
Env holds the shared dependencies NewEnv sets and the helpers every
group uses: finding the folder's VM, starting it, applying its size and
ports, the image builder and the ssh config. The commands are on types
that embed *Env:
- Launch: up, restart, remove, update, ssh and code; a new VM
(up.go), an existing one (existing.go), ssh.go, agents' mounts
- Lifecycle: stop, adopt, rm and export (lifecycle.go)
- Settings: .git protection (settings.go), size (size.go), ports
(ports.go), SSH agent forwarding (sshagent.go)
- Net: network policy, its log and allowlist (network.go), secrets
(secret.go)
- clones (clone.go) and syncer (sync.go), used by the others
env.go holds Env, UI, NewEnv and the shared helpers. cli's commands
call the group they need, e.g. vm.Launch{Env: env}.Up. Tests follow
their code: env_test.go holds the shared helpers, with up_test.go,
lifecycle_test.go, network_test.go and ports_test.go beside them.
The most methods on one type is 24 (Launch).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4bbd35a24b |
refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal flags, run log, status line, cleanup stack and interrupt flag, and its functions are methods. ui.Main makes the run's UI on devvm's own streams, owns signals, recovers Die and runs the cleanups; ui.New makes one on other streams. cmd/devvm passes it to cli.Execute, and every cli command gets it through its constructor. Only cmd/devvm and internal/cli import internal/ui (a depguard rule). Each other package defines the small UI interface it needs, which its constructor takes, filling fields tests set: - gitprotect.New, secrets.NewStore, from.NewLookup: a warn func - ubuntu.New: LoggedCmd, Note - netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its log lines drop control characters themselves (oneLine) - sshagent.New: Info, Note, Warn, LogWriter - tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup - lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run), WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too - backends.Registry: lima's and smolvm's - vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout, LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields - build.Builder: Terminal and LogNote fields - sshconfig.New: its caller sets what it prints and asks ui's tests build their own UI over buffers and run in parallel; other packages' tests use small fakes; cli's unit tests a UI over buffers. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d73c010ec4 |
feat(msg): messages carry the error they report
msg.M.Because(err) returns the message carrying err, and Unwrap returns it, so errors.Is and errors.As see through a message to its cause. The text stays the message's own. Messages made from an error carry it: proxy_failed (secrets and the proxy command), login_copy_failed, run_log_failed and fail's fallback message. TestBecause covers errors.Is and errors.As through a message, through %w wrapping, and through a message in a message. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
86a1466cec |
refactor: print and prompt only from cli
Packages other than cli and ui take what they print and ask as fields, set to ui's by their constructors or by cli: - vm.Env: Info, Warn, Note, Say, Ask, Confirm, PickFeatures (cli sets PickFeatures); AgentMounts, UpdateAgentDirs, warnIgnored, applyAgent, applySize, applyPorts, removeRemote and saveFetched are Env methods - build.Builder: Info, Warn, Say, Confirm, Pick (build.Feature); cli's newBuilder sets them, its pickFeatures asks through ui.Pick - netpolicy.Proxy: Note, Warn, Ask, Confirm; Choose, SelfCheck and Unproxied are Proxy methods - sshconfig.Config: Info, Warn, Say, Confirm - secrets.Store: Warn; LoginKept takes the warn function Tests set the fields and check messages through them. AGENTS.md: only cli calls ui's messages and prompts. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
49d7205360 |
feat(sync): host settings, agent config and mounts for VMs
A new VM's setup now sends the whole of guest/sync.sh and its host side, staged in memory: the hostname, timezone, UTF-8 locale and git identity; the agents' config files (never their history), with their folders mounted read-only at their host paths (one with a comma is left out, with a warning); and the VM's tokens, as they are without network policy (naming MCP servers whose secrets go too) or as its own placeholders with it. With network policy it also sends devvm's CA, the proxy's address (Backend.ProxyURL), the logins' copies with placeholders and the agents' settings files with secret-looking values redacted (one that can't be read that way isn't sent). UpdateAgentDirs keeps an existing VM's agent mounts current through Backend.SetAgentDirs; its caller comes with up for an existing VM. New docs page: coding agents. Ported: sync_vm, agent_dirs, agent_files, agent_mounts, update_agent_mounts, host_tz, claude_mcp_warn, the settings redaction; guest/sync.sh copied whole (one comment edited). Bats cases converted: - project.bats: agent_mounts (one per line, names with spaces); the four update_agent_mounts cases (Go table tests, plus a running VM restarted once the user agrees) - build.bats: sync_vm staging removed on failure, settings redacted with network policy (testscript sync.txtar) - guest.bats: the prompt, blocked since the last prompt, MCP servers' merge (testscript guest.txtar) - network.bats: claude_mcp_warn (sync.txtar, secrets Go test) Deferred: guest.bats VS Code settings (ssh/code). e2e: project gains agent folders and the VM's setup (mount read-only, settings copied, history never, git identity, timezone, hostname, the token without network policy); network becomes claude+codex and checks the CA installed, the VM's own placeholder, the logins' copies and the host's login files unchanged, with curl verifying TLS (no -k). Agent folders on relaunch and restart wait for those commands. Messages: agent_dir_comma, agent_dirs_added, agent_dirs_removed, update_mounts, mounts_next_start, mounts_updated, no_claude_token, claude_token_invalid, no_github_token, login_copy_failed, config_redacted, config_not_copied, claude_mcp_secrets_copied; sync_failed reworded. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
42d3fd4356 |
feat(tools): shared tools
The toolchains and agents an image name holds (node, python, rust, go, claude, codex, opencode) are shared tools: resolved per user into the tools lock by devvm's pinned, checksummed mise, built once into read-only EROFS images in a throwaway VM from base, and mounted into every VM that names them. The lock is checked again daily, in the background through devvm _refresh-tools, and before a new VM when due. Copies tools/ and guest/tools.sh, and the shared tools part of guest/sync.sh, which a new VM runs once it starts. e2e gains a tools section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |