6 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 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 bdd26779b4 fix(cli): only a test build reads the test overrides
DEVVM_HOST_MISE (which replaced the pinned, checksummed mise), DEVVM_KVM
and DEVVM_UBUNTU_URL were read in every build, a release's included. One
ldflag in a leaf package, internal/testbuild (testBuild=yes, set by
tests/e2e.sh and the CLI tests), now marks a test build, and cli's
readOverrides is the one place devvm reads every test override, into
Overrides (registry.Overrides, with platform.Overrides for the host's
size, and HostMise): empty unless testbuild.On(). registry.New takes
them; lima.New takes Ubuntu's URL; ubuntu.New takes a URL, not getenv;
Lima's and smolvm's KVM default to /dev/kvm; tools.Env has Mise in place
of reading DEVVM_HOST_MISE; platform.NewHost takes Overrides. Gone:
registry.unreviewed, registry.Host, newFor, hostFor, ubuntu.URLEnv. The
documented settings (DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE,
DEVVM_NO_TOOL_CHECK, DEVVM_FROM) stay as they are.

Tests: TestReleaseReadsNoOverrides (cli: a release reads none, its mise,
KVM, unreviewed and host its own), TestOverrides (registry: every override
reaches its backend, none leaves the defaults), TestHostOverrides and
TestListTimeout (platform) and ubuntu's TestNew moved to the new shapes.

Docs: contributing/testing.md's Test builds, contributing's sandbox table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:13:23 -07: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