11 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 ca8a91305b fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what)
when it may not be a message (replacing fail and the direct Die calls in
cli), and a.env returns its failure. checkLayout returns its error from the
root's PersistentPreRunE. execute alone prints a failure (showFailure): a
backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces
DieLogged), a message as it is, else what failed or output_failed, with a
corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130.

Die is now the UI's own die, for where no command can return: a question
without an answer, a run log that can't be opened. Error prints nothing once
the run is interrupted.

After INT, TERM or HUP, Main waited only for the logged command and then ran
the cleanups while the command's own code still ran. It now also waits for
the command to return, up to returnGrace (2 s), when there are cleanups to
run; a run without cleanups ends at once, so the proxy and the other
background processes still stop as soon as they are told to. A start's
undoStart stays registered once interrupted (interruptCleanup), as the
cleanups now run after the start returned.

Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old
ordering), TestSignalsWaitForAStuckCommandAWhile,
TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure;
DieLogged's tests are ErrorLogged's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:42:20 -07:00
w3cjandClaude Opus 5.5 e13839aa41 feat(cli): every command on the folder's VM takes --here and --parent, resolved in one place
The VM a folder uses is decided once, by vm's resolveFolder, from the
folder's own VM, the nearest parent folder's (with any repo of its own
in between) and the command's rule (vm.Env.Folder): by default the
folder's own, else the parent's unless a nested repo is in between,
else none (devvm makes the folder's own, other commands say no_vm).
--here takes only the folder's own; --parent takes the parent's across
a nested repo and past the folder's own, and refuses a folder inside
none with a VM (no_parent_vm). devvm asks nothing now, in a terminal
or not: use_parent_vm and use_parent_vm_repo are gone. The questions
before deleting, remaking or widening a parent's VM stay.

find resolves through it; own is the folder's own VM (adopt, --clone);
lookup and useParent are gone; Options.Here is the rule's.

cli: addFolderFlags (flags.go) adds --here and --parent into the run's
app, which vmEnv sets as the rule; the two are exclusive, and with -g
where a command has it; --clone and --parent are exclusive; devvm rm VM
takes neither (rm_vm_folder_flag). Commands: devvm, restart, stop,
update, rm, code, desktop, host, history export, tools (add, rm,
update), size, ports (add, rm), network (allow, deny, rm, log),
ssh-agent, git-protect, clone, secret use, secret unuse, layer add,
layer rm, group (join, leave), link (add, rm, publish, unpublish).

Tests: TestResolveFolder (own, parent, none, nested repo, --here,
--parent), TestFolderFlags (every folder command takes both, and no
other; refusals before anything runs; the rule each sets), the parent
tests and subfolder.txtar's cases updated for no questions and --parent.
Docs: the Commands page's subfolder section, first VM, --clone's
subfolders, the overview's subfolder VM; the CLI reference regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 01:21:41 -07:00
w3cjandClaude Opus 5.5 e132a29b5a refactor(cli): one per-run app holds the run's services
NewRoot makes one app for the run's UI and hands it to every command.
The app makes each service the first time a command asks for it and
keeps it, or its error, for the rest of the run: devvm's folders
(dirs), a test build's overrides, the secrets store, the backends'
registry, the shared tools, the VM environment (vmEnv) and the image
builder of the backend new VMs get (builder). The retention that runs
before a command and the command itself share them.

- paths.FromEnv: 23 of 24 calls go through a.dirs; partNames, which the
  parser's flag and word checks call before any command, keeps its own.
- The registry is made once (8 newRegistry calls and newEnv's).
- builder(u) (6 calls) and cli's newBuilder are gone: a.builder and the
  per-backend builders in images, space and gc are vm.Env.Builder,
  exported, the only builder. setup's feature choice takes a build.Env
  of its folders and prompts alone.
- The shared tools are made once (newTools and vm.NewEnv's), and the
  secrets store once (companyProxy's, newTools', vm.NewEnv's and
  _proxy's): vm.NewEnv takes the run's tools and store.
- withEnv (46 calls) is a.env; autoRetain, retainOrphans and gc
  --orphans use the run's VM environment.
- thisHost and readOverrides' other callers read the overrides once
  (a.host); space and gc --caches time out on the registry's host.

TestAppMakesEachServiceOnce checks that one run makes each service once
and that the VM environment and builder share the run's registry and
tools; TestAppKeepsAFailure that a failure is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:53:51 -07:00
w3cjandClaude Opus 5.5 0b03f334fb feat(cli): help in groups, with short texts, examples and each command's docs page
devvm --help lists the commands in groups: Your VM, Change your VM,
Images, Disk space and This machine, with help under Cobra's Additional
Commands. A group whose commands don't exist yet, such as Links between
VMs, stays out of the help.

Each command's Long is one to three sentences, and the rules it held are
on the command's docs page. Every visible command has an Example, with
the most common invocations first, each with a comment. Flag
descriptions are shorter. Each help ends with the address of the
command's docs page, and the root's also ends with the issue tracker.

- internal/cli/help.go: commandGroups, addGroups, addDocs (Cobra's usage
  template with Docs and Issues sections), examples
- internal/msg/docs.go: commandDocs, CommandDoc, CommandDocURL,
  IssuesURL; TestDocLinks checks commandDocs (user pages only)
- docgen: each reference page has a Docs section before See also
- docs: commands.md in the help's groups, with new sections on
  restarting and stopping and on deleting a VM; install.md has doctor's
  engine, feature values, Docker and CA notes; Contributing describes a
  command's help
- tests: TestExamples, TestHelpGroupsAndDocs, TestAddGroups,
  TestWithDocs, TestCheckCommandDocs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 04:39:39 -08:00
w3cjandClaude Opus 5.5 16b4ad8771 feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no
question is asked or read. The ui's prompts (Ask, Confirm, Answer,
Secret, Pick/PickOne in a terminal) show the question, then fail with
no_input naming what answers it (msg.AnswerFor, by the question's ID),
or no_input_terminal for a question only a terminal answers. ui.Flags
and SetFlags carry -v and --no-input.

Answers: --network-policy/--no-network-policy, --here, devvm size -g,
devvm setup --features/--backend, devvm network -g, devvm ssh-agent add,
devvm restart, --ssh-config (new, on devvm, host and code: the Include
line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude),
--stdin, and --force.

--force (-f) only skips a confirmation, and destructive commands need it
without a terminal (force_needed, a failure, not a usage error): rm (new
rm_confirm), gc (it went ahead without a terminal), gc --caches (now
allowed without a terminal with --force), images rm (images_rm_confirm),
secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images
are built on the one rebuilt (build.Env.Force). rm --no-export skips the
export; rm's parent-folder, earlier-folder and --clone confirmations are
terminal-only and --force never answers them (vm.RmOptions). gc --tools
--force splits: --recent (only with --tools, gc_recent_needs_tools)
drops the hour's hold and keeps the refusal while a VM is being made
(gc_recent_making); gc_tools_recent names devvm gc --tools --recent.
gc_caches_need_terminal goes.

Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt
(--force), TestRebuild (force_needed, then Force); secret, rebuild,
images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images
rm/secret rm/rebuild with --force (and --no-export where rm -f skipped
the export), and the clone section's rm with its checks. Docs:
commands.md (Questions devvm asks, rm, flags), first-vm, clone, images
(cleaning up, --recent), space, coding-agents, internals overview and
images; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:51:27 -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 07ca65c098 feat(cli): devvm host, the tools noun and devvm history
devvm ssh is devvm host. devvm tools shows this folder's VM's shared
tools (TOOL VERSION NEWER BUILT, from the lock as it is, never online);
devvm tools add/rm TOOL... add and take out shared tools, each a word of
its own (joined with + refused: tools_joined; add takes only shared
tools: unknown_tool), and devvm tools update moves the VM to the newest.
devvm IMAGE on a VM that exists adds nothing and asks nothing: it fails
with vm_lacks_tools, naming the devvm tools add command, or
vm_lacks_layer, as only a new VM gets a layer. devvm export is devvm
history export [FILE]; devvm history lists the exports in the exports
folder (FILE VM FOLDER DATE SIZE), the folder from a <export>.folder
file written beside devvm's own exports and deleted with them. gc
--exports is gc --history, retention's exports.age/count are
history.age/count, and devvm space's row is history.

The in-place layer machinery goes: Launch.addLayers and runLayers,
dockerLayers' inPlace/set/unset, backend.DockerLayerVM.SetDockerLayer
and the Docker backend's SetDockerLayer, with the add_in_place,
restart_for_mounts, no_terminal_confirm, keeping, adding and
add_layer_failed messages. vm.Tools (tools.go) holds Add, Remove,
Update and List; tools.VMs.Show lists a VM's tools; tools.Remove takes
names as a list; VMs.Update compares a VM's files as a set.

New messages: vm_lacks_tools, vm_lacks_layer, has_tools, tools_joined,
history_failed, tools_failed; renamed: unknown_tool, gc_history,
gc_history_export, deleted_history, gc_older_than_needs_history.
Command files: host.go, tools.go, history.go, refreshtools.go
(_refresh-tools); ssh.go, remove.go, update.go, export.go and
gc_exports.go gone. Tests: TestImageLacks, TestToolsAdd, TestShow,
TestCompleteToolNames; history.txtar, gc_history.txtar, host_code.txtar
and the e2e tools, docker layer and host checks updated. Docs, the CLI
reference, AGENTS.md and the e2e header follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:27:24 -08: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 06780fee5d feat(ssh): devvm ssh and devvm code, VS Code's Machine settings kept
devvm ssh gets this folder's VM ready for ssh and editors, as a launch
does without its shell, then names the host they reach it by; devvm code
does the same, then opens the folder in VS Code over Remote-SSH.

- vm: launch (from open: .git and set-id checks, a stopped VM's size,
  ports and agent forwarding, the user's agent checked, run with its
  self-check) and setUpVM (from setUp: sync, ssh config, a --clone VM's
  clone) shared by launches, SSH and Code; reach requires the backend's
  ssh, then offers the Include line (EnsureInclude). Code runs code
  --remote ssh-remote+HOST DIR in devvm's place with the environment
  devvm started with (Env.Environ), so the editor keeps the user's
  SSH_AUTH_SOCK.
- sshconfig: Host (the alias among every backend's project VMs), with
  the listing shared with Write.
- cli: ssh and code commands; CLI reference regenerated.
- Messages: ssh_host_info, no_code_command (linked to ssh.md),
  ssh_failed, code_failed.
- Tests: ssh_code.txtar (no VM, usage, a stopped VM started and set up
  without a shell, the Include line shown not added, a pending size
  waiting, code's arguments and agent, two folders named alike, no code
  on PATH, a direct route stopping the VM); guest.txtar's VS Code
  Machine settings case; a stub code. e2e: devvm ssh on a stopped VM and
  ssh reaching it, the Machine settings set and set again, devvm code
  with a stub code; network: devvm ssh's self-check, passing and
  stopping a VM started outside devvm.
- Docs: ssh.md (devvm ssh and devvm code, VS Code), commands.md,
  security.md, clone.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 22:33:29 -06:00