15 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 19f9900b86 fix(sshagent): a VM reaches its SSH agent only through its proxy's relay
OpenSSH's ssh-agent answers every request a forwarded connection sends,
so a VM that forwarded your agent or devvm's own (shared by every VM
that uses it) could remove all its keys (ssh-add -D), lock it with a
password of its own (ssh-add -x) or add keys without bound, denying the
agent to you and to the other VMs. Checked with a throwaway sshd and
ssh-agent: all three succeed over ssh -A.

Each VM's proxy now relays the agent its start chose on a socket of the
VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and
the VM's backend, devvm's own connections and the ssh entries for
editors name that socket. The relay passes on only
SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the
[email protected] extension (so destination-constrained keys keep
their constraints), answers everything else with SSH_AGENT_FAILURE,
reads messages whole up to OpenSSH's 256 KiB, carries at most 16
connections and closes one idle for 2 minutes. A filtering relay rather
than an agent per VM: it covers your own agent too, needs no copy of a
key or a passphrase per VM, and fronts hardware and app-held keys.

- proxy: Config.Agent/AgentSocket (checked together, absolute), the
  relay in agent.go, listened before the proxy says it's ready; its
  accept loop backs off after an error that leaves the listener open
  (EMFILE), 5 ms doubling to 1 s, logging the first.
- daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only
  package the proxy already imports, so the relay, the port forwarder,
  the link session and a login's forward share one owner.
- netpolicy: Prepare takes a start's agent; a running VM's proxy keeps
  its start's agent from proxy.json (relayedAgent); Stop deletes the
  relay's socket.
- structure: paths.Dirs may have 62 methods (AgentRelay); the relay's
  goroutines in goroutineSites.
- sshagent: Made.Relayed, which RecordStart sets on every start of this
  devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK
  included, and ReachOf(st,
  start): a relayed start gets the relay (or none while it's down), a
  start devvm didn't record (one outside devvm) gets none, or its
  proxy's relay, and only an older devvm's recorded start keeps the raw
  agent until its next start (runningConfinement, finder.inspect,
  sshconfig).
- vm: LeftoverSockets also finds a killed proxy's relay socket for
  devvm gc --orphans and devvm space.
- Tests: relay filter, wiring through Main, bounds and idle close, real
  ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay,
  RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar,
  an outside start in ssh_agent.txtar, and e2e checks that the VM can't
  remove, lock or add to your agent, nor the VM or an editor's
  connection remove devvm's agent's keys.
- Docs: processes (the SSH agents, listeners), ssh, attack-vectors,
  security, design, lima, overview, space, structure, proxy README,
  AGENTS.md, CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00
w3cjandClaude Opus 5.5 d17e62961e refactor(msg): one message for each kind of setting, flag and requirement
Messages that said the same thing for different settings are one message
each, given what differs:

- new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command)
  replace from_ignored, net_flag_ignored, git_protect_flag_ignored,
  size_flags_ignored, ports_flag_ignored, parts_flags_ignored,
  ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning
  for each command that changes the same on the VM, naming only the
  flags given (ignoredFlags).
- setting_already (command, vm) replaces net_already, agent_already,
  clone_on_already and clone_off_already.
- setting_set (vm), for a stopped VM, replaces net_set_stopped,
  agent_set_stopped and links_next_start.
- next_start (count, vm), for a running VM, replaces net_set_running,
  agent_set_running, size_next_start, agent_next_start,
  mounts_next_start, folder_next_start and net_off_next_start; a launch
  warns of each change with its next_start_* line, then next_start once.
- program_missing, program_broken and program_old (+ _fix) replace
  lima_missing, lima_broken, lima_old, qemu_missing, macos_old and
  their _fix messages; the minimum versions are minLima and minMacOS in
  the lima backend, passed into program_old.
- ports_list_needed replaces link_ports_invalid: devvm link publish and
  unpublish check their ports with ParsePortList, as devvm ports add
  does, and ParsePublish is gone.
- no_vm replaces no_vm_link.
- vm_unfinished says nothing of the user's is in the VM, as
  remake_unfinished does.

Kept apart: git_protect_next_stop (it applies at the next stop, and
devvm stop applies it), already_stopped and ports_all_already (not
settings), group_already (joining again syncs the group's links),
has_tools and has_layers (they name which of those given were there),
docker_missing (Docker is optional, so it never says to install it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 12:10:45 -07:00
w3cjandClaude Opus 5.5 39c2ff4f4e test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of
them) are one Go binary, internal/stubtest/stub, which acts as the command
it's run as (argv[0]): limactl, docker, security, ssh, ssh-add, ssh-agent,
ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags,
tmutil, sw_vers, uname, open, code and mise, and stub, scripts' commands
on the stubs' state. stub-log is gone: each stub logs its call itself, in
one write to $STUB_LOG, its arguments on no other process's command line.

- internal/stubtest builds the binary once, into
  $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link
  per command, which every test process and later run reuses until the
  sources change; a day-old folder of another build is removed.
  stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs'
  VM, Size, VMs, Keychain and SetKeychain on the state.
- internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json,
  typed JSON under a file lock (Lima's instances with their status, size
  and config, the Keychain, the SSH agent and its keys, Time Machine's
  exclusions, the tools build VM's folder). The instances file wasn't
  locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes
  at once.
- guest.go is the VM behind limactl shell and ssh alike: a --clone VM's
  git on vmfs, a remake's home, a base build's packages, the setup's tar,
  the direct connection, host keys, a forwarder's ports, link forwards.
- A link session's master listens with a backlog of one and never
  accepts, as the Perl one did, so a killed session's socket reads as
  stale once probed (link_life). TestScript's cleanup stops the sandbox's
  masters by their -M -S arguments.
- Structure: the stubtest layers cover internal/stubtest/..., the binary
  and its state import nothing else of devvm's; execSites lists
  internal/stubtest/build.go and internal/stubtest/stub/process.go.

Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state:
instances, size-<vm>, config-<vm>, keychain/<account>, agent-up,
agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size,
keychain, keychain-set, agent and agent-stop instead (build, existing,
from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm,
secret, size, space, ssh, ssh_agent, up).

Tests: stub_test.go (every stub in-process, TestShellWords),
stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima,
platform, vm, tools and build tests use the state helpers and
stubtest.Command. Coverage: internal/stubtest/stub and stubstate added,
stubtest, build and tools raised (and lima, netpolicy on Linux).
Docs: contributing (Stubs: the binary, logging, the state and the stub
command, switches, the guest, adding a stub or a switch; Go test
helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:00:12 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-03 14:47:06 -07:00
w3cjandClaude Opus 5.5 d8a7d4de7f refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/,
where <hash> is the 14-hex hash of the project folder's path that the VM's
name ends with: its state, its own rules (policy), its backend's files
(backend/: record.json, key, known_hosts, proxy, ports and the port
forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb,
started, lifeline.pid, secrets.*, links.*) and its logs (logs/:
network.jsonl, proxy.log, links.log). Build VMs keep the same layout in
run/builds/<name>/. The top-level run/ holds only what isn't one VM's or
must be short: the hashed control sockets, links' link-<hash>.sock/.ctl,
the QEMU wrapper and the ports lock.

A folder's VM is found by its path's hash (state.ReadHash), with the name
and backend its state records, so devvm --backend docker then devvm in
the same folder opens the one VM, and a backend's name limit applies to
new VMs only. The state records the VM's name and its ssh alias, chosen
once at creation (sshconfig.ChooseAlias) and never recomputed. Links'
targets match recorded names, aliases and folders (project.Targets).

One teardown (vmFolders.teardown) replaces Lifecycle.forget,
undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's
leftoverFiles: it stops the proxy and link session, then the pieces
outside the folder (clone remote or .git locks, other VMs' links and the
group, host keys, the backend's leftovers), removes the folder, and
writes the ssh config. Each backend's Delete and Forget remove the VM's
backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier
one's folder was left clears it first. devvm space counts an orphan's
whole folder as leftover state and the other VMs' logs as network logs.

Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files
(secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog,
LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file,
vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and
lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the
user's cache folder for Lima's and smolvm's caches is Dirs.UserCache,
from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and
DockerVM go. vmname.HashOf and IsHash, project.Hash.

The proxy takes the links' sockets' folder (-link-sockets, devvm's run
folder) apart from the links' list, which is in the VM's run folder.

Tests: a VM made and removed (rm, gc --orphans) leaves nothing under
vms/, and with network policy has no file named for it outside its
folder (TestTeardownLeavesNothing); a new VM over an old folder starts
clean; lookup finds a VM made on another backend with a long folder name
and makes no second one (TestLookupOtherBackend, and in docker.txtar);
the alias stays put when a second VM shares the folder name
(TestChooseAlias, ssh.txtar); every socket fits under a 35-character
home with the longest VM name (TestSocketsFit); space counts an
orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by
hash and name; the proxy refuses a socket in the list's own folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 08:16:39 -07:00
w3cjandClaude Opus 5.5 dd3f0deb3f feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).

internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.

devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.

ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.

Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:56:29 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-03 00:45:09 -07:00
w3cjandClaude Opus 5.5 ddbc377f8f test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN
and CFG by default, and adds stub_reset, catg (the one file a glob
matches), vm_name VAR NAME (the folder's VM) and project NAME [git];
script_cmds.txtar checks each. Every script is rewritten onto them, its
assertions kept; TestCommandLines leaves the scripts' own commands out.

mise run test runs scripts/test.sh: the tests as before, with the CLI
tests' devvm built with -cover for every package (CLI_GOCOVERDIR),
merged with the Go tests' counters by go tool covdata, then
scripts/coverage.sh holds each package to testdata/coverage/<os>.txt.
mise run coverage raises the baselines; coverage.txtar checks the
comparison. The macOS baseline is recorded from this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:25:09 -07:00
w3cjandClaude Opus 5.5 e782de9ae8 feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory,
--disk, --ports, --network-policy, --no-network-policy) are the root's
own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown
flags. build, rebuild and images rm take --backend and --from;
images, gc and space take --backend as a filter of their own (images
and space now filter: only that backend's rows); doctor takes
--backend; restart and tools take none. ports -g is local on ports,
ports add and ports rm. No command has a persistent flag.

One name, one meaning: network log --follow loses -f (-f is --force's,
and gc --force gains it); the hidden secret get's --force becomes
--to-terminal. Flag defaults name the setting command (devvm size -g,
devvm ports -g, devvm setup --backend); descriptions lose then/also
openings.

Special values are words: an empty flag value (flag_blank) or an empty
argument (arg_blank) is refused everywhere, replacing features_empty.
Durations: state.ParseDuration (a whole number and m, h, d or w) for gc
--older-than, retention's ages and ssh-agent add --lifetime (which also
takes forever, via sshagent.CheckLifetime), with one message,
bad_duration, replacing gc_bad_age and agent_lifetime_invalid.
Blanks are checked with the other usage errors (checkCommand, before
checkFlags), and an unknown --backend NAME is a usage error checked
first too (checkFlagValue, against registry.Names, which a test keeps
equal to the registry's own).

Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning,
TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root,
setup, images, space, gc_history, retention, ssh_agent and network_log
scripts. Docs: commands.md (Flags and values), from.md, install.md,
images.md, space.md, settings.md, ssh.md, network pages; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:14:23 -08:00
w3cjandClaude Opus 5.5 cd6fc60576 feat(cli): --json on every command that shows or lists
ls, images, tools, size, ports, network (and -g), network log (and
--blocked), ssh-agent, git-protect, secret, history, space, retention and
doctor take --json: one JSON object on stdout with "version": 1 first,
messages on stderr (ui.DataOnly), lists [] when empty. Settings commands
only show with --json and refuse a value (json_shows_only). doctor --json
replaces --fixes: problems with key, fix (null without one) and message,
warnings, docker and every backend's features; it prints nothing else and
succeeds whatever is missing, and install.sh reads its problems with awk.
TestJSONShapes holds each command's field names and types. Each shape is
documented on its command's page, with the contract under Everyday
commands' Output for scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:06:56 -08:00
w3cjandClaude Opus 5.5 f9e14e9b37 feat(cli): usage errors as devvm messages, checked before anything runs, exit code 2
Every argument and flag error is a devvm message naming what the command
expected, followed by usage_help naming that command's own --help, and
exits with 2. Arguments and flag values are checked in Args, before the
root's PersistentPreRun and any VM lookup.

- internal/cli/args.go: noArgs, exactArgs, maxArgs, minArgs (argsN, with
  ValidArgs), argsOf (the arguments in Use), checkCommands (wraps every
  command's Args with checkFlags and marks RunE's errors as ranError),
  checkFlagValue (--cpus, --memory, --disk, --ports, --lifetime,
  --older-than), exclusive (flag groups checked first, then Cobra's own
  required flags and groups), flagError (SetFlagErrorFunc: pflag's
  NotExist, ValueRequired, InvalidValue, InvalidSyntax errors).
- Execute: 0, 1 for a failure (RunE's error: a message, or
  output_failed), 2 for a usage error; usage_error is only the fallback.
- Checked early: ports LIST and add/rm LIST (vm.ParsePortList), network
  allow/deny RULEs, network on/off(/ask with -g), layer new NAME
  (build.CheckLayerName), retention KEY=VALUE (state.CheckRetention),
  setup --features '', secret NAME, completion SHELL, git-protect and
  ssh-agent values.
- ui.UI.Error prints an error without ending the run (UI's method limit
  44).
- Messages: usage_help, arg_missing, args_too_many, args_none,
  arg_not_choice, no_subcommand, flag_unknown, flag_needs_value,
  flag_bad_value, flag_bad_switch, flags_exclusive, output_failed;
  usage_error reworded; doc links to troubleshooting.
- Tests: TestUsageErrorsEveryCommand, TestRanErrorIsAFailure, TestArgsOf,
  TestFlagErrors; txtars check message names; e2e checks a bad port list
  exits 2.
- Docs: troubleshooting (a command refused before it runs, exit codes),
  contributing (command arguments), AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 18eefddc16 feat(cli): devvm retention, bare secret and ssh-agent, ssh-agent rm, and setup's network question
- devvm retention [KEY=VALUE...] shows every retention setting (off when
  unset) and changes them; KEY=off turns one off, KEY= is refused and
  nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
  Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
  agent's keys once one is added (it starts no agent without one).
  devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
  its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
  key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
  refused). In a terminal it also asks for new VMs' network policy (ask,
  on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
  VMs read unless --network-policy or --no-network-policy is given.

Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:38:54 -07:00
w3cjandClaude Opus 5.5 db07c9a43d fix(ssh-agent): the ssh config's agent follows the VM's running start
A VM's ssh config entry, devvm's own SSH_AUTH_SOCK and its key reloads
use the agent choice the VM's current start was made with; a stopped
VM, or one started outside devvm, follows the stored choice. Turning
forwarding on or off for a running VM reaches ssh by name, editors and
devvm's shell at its next start, as agent_next_start says.

- Backend.StartID: Lima's hostagent pid file, smolvm's lifeline, the
  container ID and StartedAt on Docker; the fake counts starts
- state: ssh_agent_started=<mode>_<hash of the start>, written after
  each start; sshagent.Running reads it
- tests: TestRunningAgent, TestWriteAgentStarted, ssh_agent.txtar,
  docker.txtar, smolvm.txtar; e2e on Lima, smolvm and Docker

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 23:11:51 -06:00
w3cjandClaude Opus 5.5 fd479df9d8 feat(ssh-agent): devvm ssh-agent and --ssh-agent, with devvm's own agent
SSH agent forwarding per VM: off by default, on (your agent, --ssh-agent
for a new VM) or devvm (devvm's own agent, holding only keys added to it).
devvm ssh-agent [on|devvm|off] shows or changes it from the VM's next
start; devvm ssh-agent add KEY_FILE [--confirm] [--lifetime D] loads a key
into devvm's agent and records it with its pinned fingerprint
(agent-keys); devvm ssh-agent keys lists them. Keys are loaded again on
launch (after a reboot or their lifetime), only while the file holds the
pinned key and isn't in a folder a VM mounts.

- internal/sshagent: Mode/Key, Agent (Ensure, Add, Keys), its messages.
- vm: --ssh-agent on create, applyAgent and checkAgent on relaunch,
  ssh_agent_flag_ignored, devvm's agent socket at start, SSH_AUTH_SOCK
  per mode for devvm's own connections, SetSSHAgent/SSHAgent.
- sshconfig: ForwardAgent from the VM's state; devvm mode forwards and
  names devvm's socket (IdentityAgent).
- ssh_remote_hint names devvm ssh-agent on; skipped with --ssh-agent.
- Tests: sshagent table tests (the five bats cases) plus one with real
  OpenSSH tools and a throwaway agent; vm tests; ssh_agent.txtar with
  ssh-agent/ssh-add/ssh-keygen stubs; e2e project section "SSH agents".
  The test task and e2e unset SSH_AUTH_SOCK.
- Docs: ssh.md agent forwarding and devvm's own agent, commands,
  security, contributing; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 19:41:09 -06:00