mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
16
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
01e5d2488a |
feat(network): rules by HTTP method and path, and secrets by method
A policy rule for a host name can narrow it to some of its requests: `api.github.com GET,HEAD /repos/` in a policy file, written by devvm network allow, deny and rm from --method and --path. Allows add up and a deny beats any allow, as for every rule, so narrowing a host that a rule allows whole, such as devvm's built-in GitHub, takes a deny: `devvm network deny api.github.com --method POST,PUT,PATCH,DELETE`, or `devvm network deny github.com --path '/*/*/git-receive-pack'`. An allow by method and path for a host already allowed whole warns that it narrows nothing and names the deny. The proxy decrypts such a host's HTTPS on :443 with the VM's CA, refuses its tunnels on other ports and without a CA, and judges every request on the connection, kept-alive HTTP/1.1 and HTTP/2 alike, every absolute-form one, and the shared Nix cache's own fetches. A connection's verdict and whether its requests are judged come from one read of the policy files. A blocked request gets 403 and a blocked event with its method and path; devvm network log shows it, and an allowed one's forward event names the rule that let it through. One matcher, internal/proxy/request.go, judges rules and secrets' bindings: methods from a closed list (RFC 9110's, PATCH, QUERY; never CONNECT); the methods a request names besides its own (every override-like header in any spelling, `_` for `-`, and the query's _method), each word judged, and while a rule narrows by method, a value that isn't exactly one method refused; path patterns with *, ** and a last / for everything below; and only a path in plain form. Allows and bindings match strictly, denies broadly: any case, every path that isn't plain, the prefix above a trailing /, and a last segment cut at its first dot (/admin.json, /admin.). A method devvm doesn't know isn't a rule, so a typo in a deny is a broken deny. Upgrades other than WebSocket and CONNECT inside a decrypted tunnel are refused for narrowed hosts. devvm secret set takes an optional --method (none for every method), and a secret's --path takes the same patterns, marked path_pattern in custom-secrets.json; a saved path with a * from before is refused rather than read as a wildcard. The bindings file stays version 1 while every binding reads alike to an older proxy, so devvm secret set and rm after an upgrade don't take a running older proxy's bindings away; a binding with methods or a pattern makes it version 2, which such a proxy refuses instead of putting a value in for every method, and writing one warns for each such VM. devvm network allow, deny and rm warn, naming the VM, when a rule by method and path changes while the VM's proxy runs from another devvm binary, or one devvm can't tell. A query with a ; or one Go can't read whole is refused while a rule narrows the host by method, and denies also match each segment with its trailing dots dropped. An allow that narrows nothing names the VMs, with -g by each VM's own allowlist, and says when it narrows only port 80's plain HTTP. - proxy: match, Methods, ParseMethods, PathOK, plainPath, matchPath, overrides, overrideLike, server.judgeRequest; parseRule/parseHostRule, CanonicalRule, NarrowRule, Narrowable, hostRules (rulesFor, verdict, byRequest, judge, unjudgeable), egress.checkHost, Allowlist.CoversWhole, trimDots; Binding.Methods, BindingListVersion 2 when needed (v1Binding); pathWithin and PathPrefixOK folded into match; the Nix cache judged - netpolicy: Rule(rule, deny, methods, path), NarrowedHost, sameRule, Proxy.Allowlist, Proxy.NarrowNotes, Proxy.OtherBinaries, BasePolicy, Proxy.SecretsWritten (after RefreshSecrets and devvm agent login --api-key's write); FormatEvent shows a blocked request's method and path and a forward's rule - secrets: Def/Secret/customJSON Methods, path_pattern, CheckMethods, CheckPath on proxy.PathOK - vm: RuleChange, PolicyChange(ctx, rules, RuleChange) - cli: --method and --path on network allow, deny and rm, --method on secret set, METHODS in devvm secret and "methods" in its --json - messages: bad_request_path (was bad_secret_path), bad_methods, rule_not_narrowable, rule_narrows, rule_narrows_nothing, rule_narrows_http_only, rule_narrows_unknown, proxy_other_binary, secrets_other_binary - tests: TestParseRuleNarrowed, TestMatchPath, TestDenyBypasses, TestAllowNarrowed, TestCoversWhole, TestForRequestMethods, TestInterceptRules and TestInterceptSecretMethods (HTTP/1.1 kept alive and HTTP/2), TestNarrowedNotDecrypted, TestNixCacheRulesByPath, FuzzDenyBypass (paths, methods, headers, _method), TestRule, TestNarrowedRules, TestOtherBinaries, TestRefreshSecretsOtherBinary, TestNarrowNotesUnreadable, TestDefine's path of /, TestReadBindings' versions, TestCustomsUnreadable's prefix path, network_narrow.txtar (narrows nothing), secret_custom.txtar's --method; on 0.1.0's frozen state: TestV010Bindings, TestV010ProxyConfig, TestV010Rules (0.1.0's TestParsePolicy and TestDecide, frozen), fixture_v010_network.txtar; e2e network: netRequestRules and the basic secret's --method GET,HEAD - docs: safety/network.md's Rules by method and path, the secrets' flags and an example, internals/network.md's Requests by method and path, the design note replacing the open-work entry, attack vectors, the commands page, internal/proxy/README.md, the CLI reference Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
20d2fe1db7 |
feat(clone): workspace clones of a folder of repos
devvm --clone in a folder of git repos gives one VM a clone of each repo the user chooses, each at the same path as on the host, so paths between them (file:../pkg, ../Lib/Lib.csproj) work in the VM, and a copy of the folder's own files outside the repos, made once. - Discovery by .git protection's walk (4 folders down, the same skipped folders, 100 repos); each repo checked as --clone checks one; a linked worktree of a repo in the folder isn't a repo of its own; a repo whose folder, or common dir, another VM mounts is refused, naming it, as is one whose name a terminal can't show. A picker in a terminal (every copyable repo ticked, the others shown with why); --repos all|none|LIST answers without one, and the question is refused naming it. A folder that's a repo keeps today's single clone unless --repos is given; one inside another repo's working tree is refused (workspace_inside_repo). The choice is recorded in the VM's state. - A single --clone, or devvm clone on, in a folder another VM mounts is refused too (clone_folder_mounted), at plan time and before the seed's push. - Each repo seeded with its current and default branch (origin/HEAD, else main, else master); a detached HEAD checks out the default. One VM command makes every repo, leaving one an earlier push reached as it is; each repo is checked again just before its push, and its remote chosen once the one before is added. The folder's own repo's clone excludes the other clones (escaped, anchored lines) and the host's info/exclude, at the seed and at devvm clone add. - The folder's own files: walked folder by folder beneath the folder (safefile.Root.OpenDir), no links followed, no hard-linked files, no bare repos, no set-id bits, bounded; refused folders (checkUnsafe) apply. - devvm clone fetch [--json]: every repo's branches into its remote's remote-tracking branches (--refmap=, one refspec), listed by branch name with their repos; nothing new is said only when a repo was fetched from. devvm clone add PATH: one more repo; one whose copy didn't finish is copied again. - rm, devvm clone off and the switch loop over the repos; rm's check reads every repo in one VM command (cloneState), parsed strictly and capped (8 MiB, 10,000 branches in all), counting only worktrees inside the folder, a VM-side folder never made read as every repo gone; a clone missing in the VM is asked about, an unfinished repo checked when it's there; a host repo that changed refuses the check, and one another VM mounts, a single clone's too, gets no host git and is asked about; each repo is checked again before rm's fetch. - The finder opens a workspace clone VM inside one of its repos; --here still makes the repo's own. --repos's dependencies go through needs(), which now takes a first argument too (devvm clone on). - State is additive: clone.workspace, clone.repos, clone.made.files; a 0.1.0 clone reads as one repo at ".". CHANGELOG: an Unreleased section. Messages: flag_needs_flag, repos_value, repos_not_workspace, workspace_repo_unknown, workspace_pick_help, workspace_pick_cannot, workspace_reason_*, workspace_inside_repo, workspace_repos_past, workspace_skipped, workspace_repo_dropped, workspace_detached, copying_repo, uncommitted_not_copied_repos, workspace_ready, workspace_files_failed, workspace_files_skipped, unfetched_commits_in, clone_repo_dirty, clone_repo_gone, clone_repo_changed, clone_repo_mounted, clone_repo_unchecked, clone_folder_mounted, clone_check_repo_changed, fetch_before_delete_repos, no_terminal_fetch_repos, clone_fetch_*, fetching_repo, clone_fetched_*, clone_add_*, clone_added. Tests: TestDefaultBranch, TestBranchPlan, TestIsWorkspace, TestChooseRepos, TestPickRepos, TestFindRepos, TestRepoExcludes, TestWorkspaceFiles, TestCloneChangesAcrossRepos, TestFetchedByBranch, TestCloneRepos, TestV010CloneReadsAsOneRepo, TestCoversRepo, TestParseCloneState, TestCloneStateScript, TestWorktreePathPins, TestOpenDir; the clone_workspace, clone_workspace_repo, subfolder and nested_replaced scripts; fixture_v010_clone (0.1.0's web clone fetched, checked by rm, made a workspace clone by devvm clone add, switched off; its scratch switched on); the e2e clone section's cloneWorkspace. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8f6b30a887 |
feat(secret): your own secrets, bound to the hosts you choose
devvm secret set NAME --host HOST[,HOST…] --env VARIABLE [--header H] [--prefix P] [--stdin] saves a secret of your own: the value from a hidden prompt or stdin (never argv) into the Keychain or devvm's secrets folder, and its definition into custom-secrets.json. A VM that uses it (devvm secret use NAME) gets only a per-VM placeholder in VARIABLE, and its proxy puts the real value in that header only for those exact hosts, over TLS on 443; the hosts join that VM's allowlist. Names, hosts, headers, variables and prefixes are checked; wildcards, addresses, internal names and other ports are refused. One placeholder builder serves every secret and login, and the proxy caches values by kind, agent and name. After an independent review, a secret goes in only in four exact shapes (alone; Bearer, Token or a saved --scheme in Authorization; the Basic password; the Basic username only with --basic-user), values are printable ASCII under 3,800 bytes, the proxy checks each binding against its definition, definitions carry IDs and VMs record their hosts, and custom values are stored apart from the known secrets. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2865158e02 |
feat(network): learn the hosts a new VM needs, then lock it to them (#22)
--network learn runs a VM on the internet tier while it records the hosts it reaches beyond its allowlist, shown as internet (learning). devvm network lock picks which of them go into the VM's own rules, ticking only reviewed registries on 443 and listing risky hosts apart, then gives the VM the allowlist tier at once. learn is per VM only. The lock command names its docs page in its about. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d44175601 |
refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5f7289e6f7 |
feat(cli): devvm upgrade, the newest release the way devvm was installed
devvm upgrade [--check] [--to VERSION] [-f/--force] [--json] installs devvm's newest release the way this devvm was installed, asking first (upgrade_confirm, answered by --force). upgrade is a top-level exception in the cli skill: it acts on devvm itself, not this folder's VM, and it's the name other tools give the verb. It skips the layout check, as a layout a newer devvm wrote is a reason to run it. - install.sh's (<prefix>/lib/devvm/<version>/devvm, which <prefix>/bin/devvm links to): SHA256SUMS and its .minisig over HTTPS, the signature checked against the key built in from packaging/minisign.pub (packaging/key.go embeds the folder; no file, no key, and upgrade_no_key), the archive's SHA-256, unpacked into lib/.<v>.new.<pid>, run (--version), renamed to lib/<v>, the link switched atomically (symlink beside, rename over), run again through the link, rolled back on any failure; then older versions pruned as install.sh does (kept: the one that ran, any a running process names, another upgrade's staging folder). - Homebrew's (a Cellar/devvm/ keg): brew upgrade devvm, asked first, through the run log; --to refused. - Anything else: says how it was installed (a checkout build, go install, a copy elsewhere) and fails. - Already latest says so; a newest release older than this devvm is refused even with --force (rollback); --to installs a named one, older asked about (upgrade_confirm_older). --check and --json install nothing. minisign verification is Go's: ed25519 over blake2b.Sum512 for the default prehashed ED signature (legacy Ed refused), the key ID, the global signature over signature||trusted comment, and the trusted comment "devvm <version>" as scripts/release.sh writes it. Verified against a signature minisign 0.12 made. golang.org/x/crypto v0.58.0 added for blake2b only (approved; depguard allows only golang.org/x/crypto/blake2b); MVS raised x/text to v0.43.0 and x/tools to v0.51.0. mise run vuln: no vulnerability reached; the module-level GO-2026-5932 is x/crypto/openpgp, which devvm doesn't import. New: internal/upgrade (Detect, Source: Latest, Check for the release notice to call, Fetch; ParsePublicKey/Verify; Valid/Compare; Upgrader), internal/upgrade/upgradetest (TLS release server, minisign signer; tests only, a structure layer), fetch.Resolve (where a HEAD's redirects end), fetch.Download's size cap (mise's 256 MiB too). Test-build overrides: DEVVM_REPO_URL, DEVVM_RELEASE_KEY, DEVVM_RELEASE_CA, DEVVM_TEST_VERSION; script command release_server [-badsig]. Security review (security-audit skill, guidance mode, a fresh reviewer): - Prerelease order compared suffixes as text (rc.10 < rc.9), which let an older signed prerelease past the rollback refusal: fixed, semver precedence, with table cases. - No cap on the archive download (a host could fill TMPDIR before the checksum failed): fixed, fetch.Download takes a limit. - Two upgrades at once: prune removed another's staging folder: fixed, .<v>.new/old.<pid> folders are kept while that pid runs. - A failed rollback of the link was silent: fixed, upgrade_rollback_failed names the link and the old devvm, and the new folder stays so the link isn't left dangling. - QEMU's guestfwd names devvm with commas doubled, which the in-use check missed: fixed. - Freeze (a host serving the current version as newest forever): no boundary crossed, inherent without signed expiring metadata; documented in internals/install.md. Checked sound: nothing untrusted runs or unpacks before the signature and SHA-256; versions from the redirect and --to pass Valid before any URL or path; tar takes only regular files in its one folder (no links, subfolders, ..), 512 MiB cap, fixed modes; test overrides are read only by test builds. Tests: minisign (real minisign fixture, tampering, legacy, other key), each install kind against the fake TLS server, bad signature, wrong trusted comment, replaced archive (wrong SHA), bad archives, a new devvm that fails before and after the switch, a failed switch (old kept), a failed rollback, downgrade refused and --to, pruning, Homebrew via a brew script, Check, Latest's failures, Compare; CLI test upgrade.txtar. Docs: getting-started/install.md (Upgrading: how, what it checks, an older release, --json), getting-started/commands.md (This machine row, Upgrading devvm, questions, output for scripts), internals/install.md (devvm upgrade), contributing (release_server), the CLI reference. 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]>
|
||
|
|
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]> |
||
|
|
79b3ef94d4 |
refactor(cli): one backend: no --backend flag, no BACKEND column
devvm runs every VM on Lima, so the command line has no backend choice: - --backend is gone from devvm, build, rebuild, images, images rm, gc, space, doctor and setup (addBackendFlag, addBackendFilterFlag, setup's own, checkFlagValue's case, its completion); a removed flag now fails as an unknown flag (exit 2). - devvm setup no longer asks for or saves a default backend; config.toml and settings.json have no backend key (settings.KeyBackend, Values and Defaults' Backend, checkBackend, Value.With, Source.File, FromFlag). - Tables lose BACKEND: ls, images (both tables), space (both tables); doctor's FEATURE table is FEATURE and SUPPORT for Lima. space's images row is freed by images rm. - --json keeps every backend field (ls, images, tool records, space, doctor's backend, backend_source "built-in" and every backend's features). - The registry keeps Lookup, For and Default: For(d, vm) gives a VM its recorded backend and a new VM NewVMs, else Default; tests set NewVMs. vm.Env's lookups lose the flag parameter, found.flagIgnored and Options.Backend. - Messages removed: backend_unknown, backend_unknown_default, default_backend, backend_help, doctor_backend_from, backend_flag_ignored; backend_unknown_vm stays (a VM's recorded backend), linked to backends#a-vms-backend. - Docs: Backends' choosing section becomes "A VM's backend"; settings, setup, images, gc, space, doctor, commands and install pages lose --backend and BACKEND; Contributing gains "How a backend plugs in". - Tests: unit tests for For, settings, setup, doctor's table, the tables; CLI scripts check --backend as an unknown flag on devvm, build, restart, images, gc, space, doctor and setup, and a config.toml backend key as unknown; e2e's table checks lose the column. 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]> |
||
|
|
7929eafaf5 |
fix(msg): every message value renders without control characters
A value a VM made reached the terminal unfiltered wherever a caller forgot msg.Shown, such as the errors passed as err.Error() and a link's name. Four cleaners did the job in different ways: msg.Shown (quoting), ui's printable and oneLine, netpolicy's oneLine and the port forwarder's log (which let C1 through, in UTF-8). msg.Printable and msg.OneLine are now the one cleaner: they drop C0 but newline and tab (OneLine drops those too), DEL and C1, in UTF-8 or as a lone byte. Every message value goes through OneLine as the message renders, in Text, Segments and names mode, so no caller can forget it, and msg.Shown is gone with its 68 calls. The status line, the run log's end and verbose output, Pick, devvm network log, the forwarder's log and a clone's status lines use them too. Tests: TestPrintable and TestValuesArePrintable (internal/msg), the hostile-value segments test, TestLogLimit (internal/backend/vmssh) with C1 in UTF-8 and as a lone byte; TestCheckLinks and TestNewVMOtherRepoAndCommondir expect the cleaned values. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4ea141b918 |
feat(link): devvm link, link add, rm, publish and unpublish, with their state and checks
Links between VMs' commands and state, without anything carrying a connection yet. - state: every VM gets a random ID (KeyID, "id") when CreateVM makes it. - vm: Links (links.go) lists, adds and removes the folder's VM's links (KeyLinks, "links": NAME,PORT,TARGET,TARGET_ID,ADDR entries) and publishes and withdraws its ports (KeyPublish, "publish"). Each target gets one address in 127.77.0.0/16 per client, the lowest free. CheckLink says why a link doesn't apply (gone, replaced, unpublished, policy). - project: Matching (which sshconfig.Alias now uses), IsPath, ForDir and Targets resolve a link's TARGET: a path, a VM's name or a folder name. - cli: link.go, in the Links between VMs group; --json on devvm link and devvm link publish; --as checked with the other flag values. - Messages: no_vm_link, link_failed, link_port_invalid, link_ports_invalid, link_unknown_target, link_ambiguous_target, link_self, link_not_published, link_policy_mismatch, link_name_invalid, link_name_host, link_name_taken, link_target_named, link_exists, link_added, link_trust, link_removed, link_not_found, link_port_taken, published, unpublished, port_not_published. - Docs: the Links between VMs table on the Commands page, the CLI reference, AGENTS.md and the cli skill's tree. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e782de9ae8 |
feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory, --disk, --ports, --network-policy, --no-network-policy) are the root's own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown flags. build, rebuild and images rm take --backend and --from; images, gc and space take --backend as a filter of their own (images and space now filter: only that backend's rows); doctor takes --backend; restart and tools take none. ports -g is local on ports, ports add and ports rm. No command has a persistent flag. One name, one meaning: network log --follow loses -f (-f is --force's, and gc --force gains it); the hidden secret get's --force becomes --to-terminal. Flag defaults name the setting command (devvm size -g, devvm ports -g, devvm setup --backend); descriptions lose then/also openings. Special values are words: an empty flag value (flag_blank) or an empty argument (arg_blank) is refused everywhere, replacing features_empty. Durations: state.ParseDuration (a whole number and m, h, d or w) for gc --older-than, retention's ages and ssh-agent add --lifetime (which also takes forever, via sshagent.CheckLifetime), with one message, bad_duration, replacing gc_bad_age and agent_lifetime_invalid. Blanks are checked with the other usage errors (checkCommand, before checkFlags), and an unknown --backend NAME is a usage error checked first too (checkFlagValue, against registry.Names, which a test keeps equal to the registry's own). Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning, TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root, setup, images, space, gc_history, retention, ssh_agent and network_log scripts. Docs: commands.md (Flags and values), from.md, install.md, images.md, space.md, settings.md, ssh.md, network pages; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fe32d2a01c |
feat(cli): reserved command names, and did-you-mean for devvm WORD
A word after devvm that's neither a command nor an image (no +, and not base, a shared tool or a layer) is a usage error, exit 2, suggesting the closest command (Cobra's SuggestionsFor, distance 2) and the closest image name. devvm help WORD and devvm WORD --help fail the same way instead of printing the root's help. Layers can't take a word devvm keeps for its commands. - internal/image/reserved.go: Reserved (every command and subcommand name, hidden ones and help, and link, group, join, leave, publish, unpublish kept for later), IsReserved; LayerName refuses them, so Layers() and completion leave such files out. - build.CheckLayerName refuses one (layer_name_command); CheckLayers refuses a layer file named with one wherever an image names it (layer_is_command, naming the file). - internal/cli/word.go: checkWord (the root's Args), closest and levenshtein, addHelp (devvm's own help command, and a help func that panics with wordPanic for execute to recover), helpTarget, printUsage. - Messages: layer_name_command, layer_is_command, no_command_or_image, no_command_or_image_command, no_command_or_image_image, no_command_or_image_both, with doc links. - Tests: TestEveryCommandReserved, TestImagesNotReserved, TestLevenshtein, TestUnknownWord; layer.txtar and up_checks.txtar; e2e checks a mistyped command exits 2 with its suggestion. - Docs: customizing (layer names), commands (devvm WORD), contributing, AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |