21 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -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 d58b24affe refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.

The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.

Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.

A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.

The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.

Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 11:49:57 -07:00
w3cjandClaude Opus 5.5 7bdaf8e99e refactor: one Reporter for every package's messages and prompts
msg.Reporter is what every package below cli prints and asks through:
Info, Say, Note, Warn, Status, Ask, Confirm, Answer, the terminal checks
and CanPick, the run log (LogNote, LogWriter, LoggedCmd, WithSteps),
Stdout, Stderr, AddCleanup and Interrupted, under the UI's signatures.
*ui.UI implements it (a compile-time check in ui), and msg.Fake is the
tests': quiet as its zero value, its On funcs and fields record and
answer.

The six UI interfaces (tools, netpolicy, lima, registry, sshagent, vm)
are gone, and the copied output and prompt func fields of tools.Env,
tools.Making, gitprotect.Protector, secrets.Store, netpolicy.Proxy,
from.Lookup, backend.Review, lima.Lima, sshagent.Agent, vm.Env,
vm.SizeChoice, vm.AgentsChoice, vm.LayersChoice, vm.NetworkChoice,
vmssh.Forwards, build.Env and sshconfig.Config: each embeds the
Reporter. Lima's and the shared tools' Warn, which says where the run
log is too, is a method of their own over it; vm's interactive check is
a function over it. The pickers (build.Env.Pick, vm.Env's PickFeatures
and PickParts, the choices' Pick) and vm.Env.CanAsk stay fields: they
carry types of their own or cli's answer. The test UIs of tools,
netpolicy, lima, registry, build and vm become msg.Fake.

Coverage baselines raised: internal/backend/lima, internal/msg,
internal/tools.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:57:23 -07:00
w3cjandClaude Opus 5.5 0d9154bd8a refactor(vm): one handle for the VM a command acts on, and Env's parts made once
The finder returns a target (target.go): the VM's folder, state, backend
and the instance its backend gave the finder, which each start
(starter.start, target.started, backend.Apply) and stop (target.stop)
then sets as the backend has it, without asking again. It runs what a
command does with that VM: exec, shell, shellDir, running, stop,
ensureRunning, ownSSH, sshHost and widen. Stop, network, ports, size and
ssh-agent read the finder's instance instead of asking again; git-protect
reads it again after its question (refresh), as before.

Env's parts are made once over it (wire, from NewEnv): the finder,
starter, linkRuns, syncer, remaking, clones, vmFolders, devcontainers,
creation, and the command types one reaches from another (launcher,
lifecycle, vmTools, groups, links, leftovers). The 110 conversions
between the package's struct{ *Env } types (finder(e), Launch(e),
starter{e}, creation{Launch(e)}...) are gone: none is left outside wire.
setUp and Groups.warnUnenforced went, their callers using setUpVM with
the target and Links.warnUnenforced; seedClone, gitSSH, fetchUnfetched
and setUpVM take the target. The fake backend applies a Want with
backend.Apply too.

TestTargetAfterStartAndStop: a target's instance after a start and a
stop is the backend's, a start reading it once and a stop not at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 08:18:35 -07:00
w3cjandClaude Opus 5.5 ac0e2c2abb refactor(vm): one start pipeline and one confinement function
Every start of a project VM goes through starter.bringUp (start.go), a
type of its own: devvm's launch, devvm host and code, ensureRunning
(exports, rm's clone check, a remake's home folder), a remake's new
machine and a new VM. It reads the VM's instance once (opening an
existing VM now inspects twice, the finder's and the start's, not four
times), matches agent folder mounts for a launch, runs the host checks,
refuses what the backend can't give, checks the user's agent, starts a
stopped VM or goes on with a running one, says what changes at the next
start in one place (nextStart: size, agent forwarding, mounts, network
policy turned off), then runs the self-check.

- confinementFor(st) replaces three copies (run, remaking.check,
  creation's newVM.conf); runningConfinement replaces run's running
  branches and linkRuns.runningConf.
- requirements(needs) is the one list of backend features (a new
  machine's, ports, network, layers, agent forwarding and toggle, ssh for
  --clone), used by bringUp, creation.plan, remaking.check (which now
  checks ports too), SetSSHAgent (now before its question) and SetPorts;
  Env.start's and checkAgentForwarding's checks go.
- hostChecks (.git, set-id files, the SSH origin) replaces checkGit and
  creation's own checks; devvm stop uses it.
- Links' policy rule is one predicate, policyRule over policySide, used
  by CheckLink, checkTarget, the launch's warnings, guestLinks,
  policyLinked, group join and the link session. A VM whose network
  policy section can't be read is refused on either side, not read as
  off (a client read as off let a link through).
- refuseUnfinished is the one unfinished refusal: the finder's and
  bringUp's; Env.start's, open's and run's copies go.

Tests: TestStartPaths characterises each start path (open, ready,
ensureRunning) on stopped, running (with and without its proxy),
network policy turned off while running, agent changes and refused
features; TestStartNew a new VM's; TestRequirements, TestOpenInspectsOnce,
TestPolicyRule, TestCheckLinkUnreadPolicy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 03:31:58 -07:00
w3cjandClaude Opus 5.5 1b9755a7df refactor(vm): one finder for the VM every command acts on
finder.target(ctx, need) finds the VM a command acts on: the folder's
own, the nearest parent folder's (resolveFolder), or one named for
devvm rm VM. Its need says what the command needs (has: any, the VM,
its machine, made; own; folder; noVM), and need.check is the one place
that refuses a missing VM, one made for an earlier folder at its path
(found.other, from sameFolder), a pending remake and an unfinished one.

It replaces Env's find, own, findExisting, existing (10 callers),
folderVM (7 callers) and the linkVM, groupVM, portsVM and agentVM
wrappers, Net's policyVM, up's and toRemake's checkFolder, and rm VM's
inspect by name. devvm rm VM refuses a state whose folder doesn't hash
to the VM's name (rm_vm_state_mismatch), so a changed vm.json never
sends it to this folder's VM.

The environment reads the folder devvm runs in lazily (finder.dir), so
devvm build, rebuild, images, space and gc run from a deleted folder;
NewEnv no longer fails.

Guard: the structure test's callers rule, state.ReadHash and
project.Parents called only in internal/vm/finder.go outside their
package and tests. Tests: TestFinder (need x none, own, parent, nested
repo, other folder, unfinished, remake pending with and without its
machine), TestRmVMFolderOfAnother, callerCases, no_folder.txtar and
rm_vm.txtar's mismatch case (its fixtures' hashes now match their dirs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 01:52:45 -07:00
w3cjandClaude Opus 5.5 0503008524 refactor(backend): remove Instance.AgentFixed and the agent_fixed message
No backend sets AgentFixed: Lima's agent-toggle is native, applied at
the next start. The emulation contract for agent-toggle is the spec's
AgentToggle at create, the made-ready record in the VM's state and
Confinement.NoAgent at each start; a backend that can't apply a start's
Want refuses it in Start, as its contract says, so a separate flag on
Inspect isn't part of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:35:34 -07:00
w3cjandClaude Opus 5.5 5a9f1b71c2 feat(cli): changes that apply at the next start ask to restart now
devvm size, devvm network on and off, devvm ssh-agent and devvm
git-protect (macOS) on a running VM ask in a terminal, without
--no-input, whether to restart it now ([Y/n]): yes restarts it as devvm
restart does, no or no question (no terminal, --no-input) keeps today's
message (size_next_start, net_set_running, agent_set_running,
git_protect_next_stop). Agents' mounts ask the same question.

- one owner: Env.restartNow (Env.CanAsk, then restart_now) and
  Env.restartOr (yes: Launch.Restart; else the later message), in
  internal/vm/existing.go; UpdateAgentDirs uses restartNow
- restart_now replaces update_mounts (AnswerFor: devvm restart)
- tests: TestRestartToApply (each command: yes, no, no terminal,
  --no-input), TestUpdateAgentDirs's --no-input case
- e2e: network's no-terminal on and off say net_set_running
- docs: commands.md's restarting note and answers table, ports-size,
  ssh, safety/network, git-protection, coding-agents; CLI reference

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 15:43:41 -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 3da8ffa208 fix: Lima-only review: docs and messages describe Lima alone, doctor --json drops backend_source
- doctor --json: backend_source goes (it could only be built-in).
- AgentWhileRunning and the agent_on_risk_running and
  agent_devvm_risk_running messages go: nothing sets the field.
  Confinement.SSH, NoAgent and AgentFixed stay, as the generic
  emulation contract for ssh and agent-toggle.
- The unused experimental badge goes: its shortcode, Markdown version,
  partial, CSS, llms.txt filter and flask icon.
- Messages: space_backend_unknown, space_stray, gc_backend_skipped and
  gc_orphans_unknown start with "The lima backend" instead of a
  lowercase name; backend_lacks and backend_unreviewed point at doctor's
  features, not other backends; space_caches_note says Lima's caches;
  setup_in_config's description no longer names a backend key.
- Docs: "on every backend" and similar leftovers go (limits, devcontainer,
  images, ports, lima, design, the docs index); space's "Lima's caches";
  safety/network and security say every Lima VM can have network
  policy; images says a docker-layer VM keeps it; ports.md says devvm
  records every VM's ssh port; security's set-id paragraph says where a
  root-owned file comes from; Contributing lists the invariants a new
  backend's threat check covers.
- AGENTS.md: msg.IDOf, now used only by tests, joins deadcode's list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 13:23:49 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-02 16:07:15 -07:00
w3cjandClaude Opus 5.5 15630460a8 fix(msg): SSH agent and agent folder messages fit every backend
The agent warnings said "while you're connected", but smolvm forwards
the agent the whole time a VM runs, and the agent folder warning named
Lima on every backend.

- backend.Instance has AgentWhileRunning, which smolvm sets; devvm
  ssh-agent on or devvm warns with agent_on_risk_running or
  agent_devvm_risk_running for such a VM, linked to smolvm's page.
- agent_holds_note names smolvm's case.
- agent_dir_comma names no backend, and links to the coding agents
  page's Mounts, which names Lima's and Docker's limits.

Tests: TestSetSSHAgentRisk (internal/vm); smolvm's TestAgentToggle
checks AgentWhileRunning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 17:50:39 -07: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 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 1812867162 fix(vm): a subfolder's lookup stops at the nearest parent with state; widening a parent's VM asks
The parent-folder lookup passed over a parent whose VM was made for an
earlier folder or that its backend had lost, and went on to a VM further
out. A VM can rename a nested project folder through its mount (a new
device and inode), so devvm skipped the nested folder's VM and acted on
the outer one, the VM that replaced it. parentVM now stops at the first
parent folder with state of its own: its VM is used only when its backend
has it and it was made for that folder, else the folder devvm runs in has
no VM (no_vm; devvm makes a new one). Only folders without state are
passed over.

Commands that give a parent folder's VM more access, run from a
subfolder, ask first ([y/N]), naming the VM and its folder, and refuse
without a terminal: devvm secret use, ssh-agent on and devvm, network
off, policy allow, policy rm of a deny, and git-protect off (found.widen).

Messages: widen_parent_vm (the prompt), widen_parent_vm_refused (linked
to getting-started/commands#a-subfolder).

Tests: TestLookupParents (a parent's lost VM and another folder's VM stop
the search: no VM, no_vm), TestWidenParentVM (each command refused
without a terminal, a no changing nothing, a yes changing it; taking
access away asks nothing), subfolder.txtar (the refusals without a
terminal).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:51:07 -07:00
w3cjandClaude Opus 5.5 75652b3097 feat(smolvm): turn ssh-agent forwarding on or off for an existing VM
smolvm forwards an agent only if the machine was made with --ssh-agent,
and reads SSH_AUTH_SOCK at each start. agent-toggle is now an emulation,
reviewed:

- Every new smolvm VM is made with --ssh-agent. Each start points
  SSH_AUTH_SOCK at the user's agent (on), devvm's agent (devvm), or a
  path no socket can exist at, /dev/null/devvm-no-agent (off): nothing
  listens, so off VMs share no agent to add keys to or sign with.
  Every other smolvm command runs without SSH_AUTH_SOCK.
- Off wins whenever the record or Confinement.NoAgent says so, so starts
  for exports and clone checks give no agent either.
- A VM made without forwarding can't be turned on (agent_fixed).
- Each start records the machine's lifeline; a running VM whose lifeline
  differs and whose mode isn't on (started outside devvm, with whatever
  agent that shell had) is stopped at launch, ssh, code, restart and
  export (agent_unchosen_stop), through backend.AgentStarter.

Docs: smolvm.md (SSH agent forwarding), backends.md, ssh.md,
security.md, limits.md, testing.md, design.md (the design note and
threat check). e2e: each mode, toggling on an existing VM, devvm's agent
ending, a start outside devvm stopped; direct starts in the network
checks pass an agent path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 00:39:10 -06:00
w3cjandClaude Opus 5.5 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]>
2026-10-25 16:44:53 -06:00
w3cjandClaude Opus 5.5 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]>
2026-10-25 16:23:51 -06:00
w3cjandClaude Opus 5.5 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]>
2026-10-25 15:12:36 -06:00
w3cjandClaude Opus 5.5 4bdb3ea843 feat(ssh): ssh config and pinned host keys
Each running project VM can be reached as devvm-<folder> (or by its full
name when two folders share a name) through ~/.config/devvm/ssh_config,
which up rewrites after the VM's setup. Every entry checks the VM's own
host keys, kept in ~/.config/devvm/known_hosts and read from the VM
through its backend, and sets StrictHostKeyChecking yes, ForwardAgent no
(unless the VM forwards), and its own connection. Only Lima's login
options are copied. Host keys are dropped before each start, and when an
interrupted new VM is deleted, so they're read again.

Ported: write_ssh_config (sshconfig.Write), record_host_keys,
forget_host_keys (ForgetHostKeys, in vm start and the interrupt cleanup),
ensure_ssh_include (EnsureInclude: asks with [Y/n] on a terminal, else
says to add the line; no caller yet: --clone and devvm ssh/code),
ssh_alias (Alias), is_project_vm (project.IsVM), check_ssh_agent (vm
checkAgent, run when a new VM forwards the agent). Backend.SSH's
SSHTarget gains Options (Lima: identityfile, identitiesonly,
preferredauthentications, batchmode, compression, gssapiauthentication,
ciphers). Registry.All, state.WriteFile.

Messages: ssh_include_needed, ssh_include_yourself, add_it_now,
ssh_include_added, no_ssh_agent, ssh_agent_empty, load_key, key_loaded,
key_loaded_keychain, load_key_with. Doc links: ssh_remote_hint,
ssh_include_yourself.

Converted bats cases: cli.bats "ssh config: only running VMs, each with
its own host key checked; Lima's unchecked settings left out" (ssh.txtar,
lima TestSSH, sshconfig TestWrite; the rm half waits for rm),
delete.bats "ls and the ssh config include a project VM named like an
image" (ssh config half: ssh.txtar, TestWrite), project.bats "ssh_alias:
short name unless two folders share it" (TestAlias, ssh.txtar). New:
TestWriteUnchecked, TestParseHostKeys, TestEnsureInclude, TestCheckAgent,
TestIsVM. Stub limactl: Lima-like ssh.config at start, host keys from
shell, sshLocalPort/sshConfigFile in list.

e2e: project checks the hostname, the entry, pinned host keys, ssh
devvm-web through an ~/.ssh/config of the run's own (Include plus Host *
ForwardAgent yes), no agent forwarded (a throwaway agent), a changed host
key refused; network checks ssh devvm-net. Nothing touches the real
~/.ssh.

Docs: ssh.md (from the ssh page), linked from the index, commands,
security, images and contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 11:39:20 -06:00