mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
18
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e4b44b5994 |
fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.
The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.
TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
52bb0f467b |
feat(clone): a --clone VM gets the repo as it is here
A --clone VM's clone is now seeded with a snapshot, not git push, and gets everything a working copy has. devvm clone fetch brings it all back, and devvm rm and clone off check it before deleting. - Refs: every branch, tag and notes ref, and a detached HEAD. - Uncommitted changes: staged, unstaged and untracked files; files skip-worktree by hand get the index's version, named. - Operations in progress (merge, rebase, cherry-pick, revert, bisect) and the stash; a stash's untracked part goes as its own branch. - The repo's settings and hooks, sent as settings only where they live in the repo (husky); ORIG_HEAD never goes. - Partial clones, with their promisor remote, and messages per network tier when it can't be reached. - Initialised submodules, nested ones too, each with a clone of its own; a submodule's own folder is refused as a top-level --clone. vm.json gains an optional `submodules` field. - Git LFS both ways: objects hash-checked, written under os.Root with no link followed, a question past 2 GiB; the filter is set only in the clone's repos; git-lfs 3.8.1 in base, pinned by SHA-256. - rm and clone off keep the VM when anything the VM has didn't come back, and name it. - Every shell script embedded in Go is shellchecked. - clone.md is a guide that leads with commands; TestUserPageProse covers it and coding-agents.md. After you upgrade: base and every image on it build again once, for git-lfs. Fixes #40, reported by @Josuesp1620. Thanks to @dhruv1220 for #42, which found the cause (receive-pack refusing a shallow push); its receive.shallowUpdate setting stays in the VM's repos. Co-authored-by: Dhruv Arora <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
2933b535a9 |
feat(clone): devvm clone on|off switches a VM to or from its own clone
devvm clone [on|off] is a setting: bare (and --json) it shows whether the folder's VM has its own clone of the repo. on and off make the VM again through the shared remake, keeping its home folder and settings, after asking (--force, --no-export, --clean-home as devvm layer add). - on: a mounted VM is made again with nothing of the folder mounted; its branches are seeded as a new --clone VM's, and once the old machine is deleted, .git is checked as a launch does and unlocked. - off: the clone is checked as devvm rm does (unfetched branches offered for fetching into saved/<remote>/*, uncommitted changes asked about, terminal only; --no-clone-check skips it after a warning); the remote goes before the new machine's .git is locked, and is added back if the switch is undone. - The remake records its clone mode (remake.clone), so a remake that didn't finish finishes in it, and undo restores the old mode. - devvm --clone on a mounted VM and layer add/rm/update on a clone VM now name devvm clone on/off. rm's clone check messages name the command; --no-clone-check has one help text (addNoCloneCheckFlag). - teardown removes a clone's remote and .git's locks independently. Tests: TestSetCloneOn, TestSetCloneOff, TestSetCloneUndo, TestSetCloneRefuses, clone_switch.txtar, e2e clone section checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e148ca33ca |
fix(clone): the --clone push and fetch's ssh always connects to the VM itself
devvm's ssh for a --clone VM's seed push and rm's fetch read devvm's ssh config, so a url.*.insteadOf, pushInsteadOf or remote URL in the repo's config could send them to another host; only the pinned host key (HostKeyAlias, BatchMode) stood in the way. Their GIT_SSH_COMMAND (gitSSHCommand) is now a shell function that ignores the host, port and options git passes, and runs ssh with vmssh.SSH's new CommandArgs: no ssh config (-F none), the VM's loopback port, user and key from vmssh.FromTarget, and the host keys pinned for its current start (vmssh.KnownHostsFor) under HostKeyAlias, with BatchMode and nothing forwarded. In the VM it runs only git-receive-pack or git-upload-pack, whichever git's last argument asks for, on the clone's own path; anything else fails without ssh. Links' linkSSH is now Env's ownSSH, which both use. Tests: TestUpCloneInsteadOf (failed on the previous code), TestGitSSHCommand, TestForwarderSSH's command args, clone.txtar's push past an insteadOf, and e2e's clone section (an insteadOf on the first push, and a git worktree's clone with only its branch and upstream). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4477a1285d |
fix(clone): --clone takes only a repo of the folder's own or a verified git worktree
A project folder whose .git pointed into another repo on the host (a gitdir file, a commondir, alternates) passed the --clone check, and the seed push copied that other repo's branches into the VM. gitprotect.OwnRepo now checks what git reads in the folder: a .git folder without a commondir, or a linked worktree's .git file whose link git made both ways (its gitdir is <repo>/.git/worktrees/<name>, that entry's gitdir file names this .git back, and its commondir leads to that <repo>/.git); no alternates, and no objects, packed-refs, reftable or refs that are symlinks, in the git dir or the common dir. cloneSource runs it before the VM is made and again before the push, and checks that git's rev-parse --absolute-git-dir and --git-common-dir agree. A worktree's push sends only its branch and that branch's upstream. gitprotect's commondir and gitdir resolution are shared (commonOf, resolvedDir) rather than copied. New messages: clone_git_elsewhere, clone_alternates. Tests: TestCheckCloneRepoPointers (failed on the previous code), TestSeedRefs, TestUpCloneWorktree, TestOwnRepo, and clone.txtar's refusals. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
50b0db2f7e |
refactor(vmssh): one host-key record per VM per start, which every ssh of devvm's checks
vmssh owns a VM's host keys: PinHostKeys reads them from the running VM through its backend (at most 64 KiB within 30 s) once for each start, into one record in the VM's folder, vms/<hash>/run/known_hosts (paths.VM.KnownHosts), whose first line names the start it was read for (backend.Run.ID). A record of another start is read again, keys read while the VM started again aren't recorded, and ErrNoHostKeys says none can be pinned. KnownHostsFor returns the record for the current start without reading, for links' sessions; ForgetHostKeys removes it before each start. ParseHostKeys is the one parser, for every key type: a line is kept only when its key decodes, names its own type and has more after it, and certificates, markers, patterns and anything else are dropped. The ssh config's entries, the port forwarder (-known-hosts), links' sessions and a --clone VM's git all check the VM against that record. sshconfig's own parser, recordHostKeys, changeKnownHosts, HostKey and ForgetHostKeys go, with the shared known_hosts and its lock (Dirs.KnownHosts, Dirs.KnownHostsLock): a record per VM, each written whole, loses no other VM's keys. The forwarder's ports.known_hosts copy and Forwards.HostKey go, and teardown leaves the record to the VM's folder. paths.Dirs's method limit drops to 47. Tests: TestParseHostKeys, TestPinHostKeys, TestPinHostKeysNone, TestPinHostKeysTogether (vmssh); TestForwardsStart and TestForwardsRun use the record; TestWrite reads keys again after a start, TestWriteUnreadableRecord (sshconfig); TestLinkConn refuses a target without a record and never reads one; up_test's call lists. The limactl stub shows a wire-format ed25519 key per VM. testscripts ssh (a launch keeps the record, a restart reads it again), up, existing, host_code, clone and layout updated; e2e's project and link checks read the VM's record. Docs: internals/security.md, design.md, overview.md, ports.md, lima.md, backends.md, git-protection.md, using/ssh.md and space.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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
5f9e2e2408 |
fix(rm, git-protect): messages whose advice looped now name what works
- rm_export_failed names devvm rm --no-export, the flag that skips the export, in place of devvm rm -f. - devvm rm --no-clone-check deletes a --clone VM without checking its clone, after warning that its unfetched commits and uncommitted changes go with it (clone_check_skipped). clone_check_failed names it. - devvm git-protect on, strict or off on a running VM (macOS) is saved in the VM's state (git_protect_next) and applied the next time devvm finds the VM stopped: devvm stop, devvm restart, or the next launch of a VM stopped some other way, before it starts (git_protect_next_stop). So git_protect_flag_ignored's advice, devvm git-protect off, works on a running VM, and git_protect_running is gone. gitprotect owns the key (Next, SetNext; Set drops it); vm's checkGit applies it, then the .git check and set-id files, for devvm stop and every launch. Tests: TestSetNext (internal/gitprotect); git_protect.txtar (a running VM's choice saved, replaced, applied by devvm stop and by the next launch); clone.txtar (clone_check_failed, then --no-clone-check); e2e project's git-protect check and clone's rm check. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
3c4a77349c |
fix(clone): rm checks every worktree inside a --clone VM's clone
devvm rm on a --clone VM ran git status only in the clone's main checkout, so uncommitted changes in other worktrees in the VM went with it unasked. It lists the clone's worktrees (git worktree list --porcelain -z, at most 1 MiB read) and checks each one's status, showing the changes under each worktree's path, 20 in all. The list comes from the VM, so only clean absolute paths inside the clone are used, each once, and bare or prunable ones are skipped; a worktree whose folder is gone has nothing to lose. Paths go to the VM only as an argument and are shown through msg.Shown. At most 100 worktrees are checked; past that devvm says so and asks anyway. - internal/vm/clone.go: cloneChanges, cloneWorktrees, insideClone, showChanges, cloneExec, worktreeStatus, cloneWorktreesMax - messages: clone_worktree_dirty, clone_worktrees_unchecked (linked to using/clone#deleting-the-vm) - tests: TestCloneWorktrees, TestCloneRmWorktrees, TestCloneRmTooManyWorktrees; clone.txtar's dirty worktree; the limactl stub's git worktree list and worktree status; e2e clone's dirty-worktree check - docs: using/clone.md's Deleting the VM and a new section, Several agents in one VM; internals/overview.md Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5c345b43b3 |
fix(clone): rm keeps fetched branches as local branches
rm on a clone VM now fetches the VM's unfetched branches into new local branches, saved/<remote>/<branch>, and removes the remote fully with git remote remove (its remote-tracking branches and upstream settings too). Before removing it, any of the remote's remote-tracking branches with commits no other ref has (fetched by hand, or with rm -f) are kept the same way, in one update-ref transaction that never overwrites. The prefix is saved/<remote>, else saved/<remote>-2 up to -99: the first that no local branch is, is in or holds. Remote names devvm picks start with devvm, so these never shadow a later VM's remote-tracking branches. No free prefix: rm refuses before fetching (saved_names_taken), and at deletion the remote stays (remote_kept). Branch names from the VM are checked with git check-ref-format, passed only as argv, and shown quoted; invalid ones are skipped (branch_names_invalid). The fetch uses --no-tags. A branch counts as fetched only when a ref reaches its commit, not merely when the object exists. Inventory: - vm: fetchUnfetched, validBranch, savedPrefix, quoted, saveFetched; unfetchedRefs reads full refnames and checks reachability; removeRemote saves, then git remote remove - messages: branch_names_invalid, saved_names_taken, saved_branches, remote_kept; fetch_before_delete and fetching take prefix; removed_remote and unfetched_commits reworded. Doc links: saved_names_taken, remote_kept - tests: TestCloneRm (saved/devvm/main, no remote-tracking refs left, a dangling commit unfetched), TestFetchUnfetchedInvalid, TestSavedPrefix, TestRemoveRemote (unique branches saved under saved/devvm-2, upstream gone, no free names keeps the remote); clone.txtar: rm -f keeps fetched-only work as saved/devvm/main - e2e: clone's rm -f check wants saved/devvm/main and no remote-tracking branches - docs: clone.md, commands.md Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bdd781c037 |
feat(clone): --clone gives the VM its own clone
devvm --clone makes a VM that mounts nothing of the folder's: only the shared tools and its agents' config folders. Once it runs, devvm makes a repo at the folder's path in the VM (receive.denyCurrentBranch updateInstead, HEAD on the host's branch), pushes every local branch into it with host git over devvm's own ssh config (pinned host keys), and adds a remote to the host repo (devvm, else devvm-<folder>, else the VM's name), URL <vm>:<dir>. It offers the ~/.ssh/config Include line (EnsureInclude's first caller), else says how to fetch until then, warns about uncommitted changes, which aren't copied, and opens the shell in the clone. No .git protection, set-id check or ssh remote hint for clone VMs. A copy that fails is retried on the next launch. --clone on a VM that mounts its folder is refused. rm on a clone VM (not -f) starts it if stopped, lists branches whose commits the host repo lacks (VM answers looked up only when they're object names) and offers to fetch them into <remote>/*, then shows the clone's uncommitted changes and asks before deleting; without a terminal either refuses and keeps the VM. Deleting removes the remote's config if it still points at the VM, keeping fetched branches. Inventory: - vm: clone.go (isClone, checkCloneRepo, seedClone, freeRemote, remoteURL, cloneRmCheck, cloneGit, unfetchedRefs, removeRemote, gitSSH, hostGit, capped); state keys mode, clone_remote, seeded; Options.Clone; create skips the unsafe-folder check, the mount, .git protection; setUp seeds unseeded clone VMs; open refuses clone_needs_new_vm and skips Check/setid for clones; ensureRunning (from export); Rm runs the clone check; delete removes the remote; the interrupt cleanup removes it too - cli: --clone on up; rm and root Long, rm -f's help - messages: clone_needs_git, clone_not_top, clone_no_commits, clone_detached, clone_needs_new_vm, copying_branches, clone_seed_failed, remotes_taken, remote_add_failed, fetch_until, uncommitted_not_copied, clone_ready, unfetched_commits, no_terminal_fetch, fetch_before_delete, fetching, fetch_failed, clone_check_failed, clone_dirty, no_terminal_delete, delete_anyway, kept, removed_remote; unsafe_folder and git_protect_needs_macos_new name --clone. Doc links: clone_not_top, clone_no_commits, clone_detached, clone_needs_new_vm, remotes_taken, fetch_until, no_terminal_fetch, no_terminal_delete - tests: testscript clone.txtar (refusals, the new VM's mounts, state, push, remote and clone; no reseed; rm clean, unfetched, dirty, -f, a remote pointed elsewhere; a failed copy retried; clone_needs_new_vm); Go TestUpClone, TestCloneRm (fetch yes/no, delete anyway, a stopped VM started, VM answers that aren't object names), TestCheckCloneRepo, TestFreeRemote, TestRemoveRemote. Stubs: limactl runs a clone's git on $STUB_DIR/vmfs; new ssh stub pushes and fetches there - converted: the bats suite has no clone cases besides cli.bats parse_args, which waits for --from - e2e: clone section (own HOME and git config, throwaway repo): clone with every branch and only the tools mounted, shell in it, remote, nothing locked, rm refusing unfetched commits and uncommitted changes, fetch over devvm's ssh config, rm -f removing the remote and keeping fetched branches - docs: clone.md; commands, security, git-protection, ssh, contributing, index; CLI reference Co-Authored-By: Claude Opus 5.5 <[email protected]> |