7 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 2a99183ea4 feat(vm): devvm update reads a changed devcontainer.json again
devvm update now makes the folder's VM again from its devcontainer.json
as it is now when the file changed, is gone or appeared since the VM was
made, as well as when its image is outdated. devcontainer_changed and
devcontainer_new name devvm update instead of devvm rm, then devvm. A
file's forwardPorts now join the VM's ports as devvm ports add adds them,
for a new VM and when devvm update reads the file again.

- vm.json's devcontainer section records what of the VM is the file's:
  image (the file's image, when the base starts from it), from_flag
  (--from won), parts (what its features mapped to), gave (those the VM
  got from the file alone, not from --tools/--layers, setup's layers,
  the folder's other files, nor unchecked), ports (its forwardPorts) and
  ports_gave (those it added to the VM's ports).
- devcontainer.Reread (pure) drops what the file gave that it no longer
  lists and adds what it lists anew that the VM lacks; the user's stay,
  and what the user took out stays out. It applies to parts
  (rereadParts) and to ports (filePorts, through AddPorts and
  RemovePorts, as devvm ports add and rm). devcontainers.reread
  re-pins a new image (or falls back to $DEVVM_FROM's), keeps --from's,
  and replaces variables and commands.
- The remake section carries reread (the new from, shared tools, ports
  and devcontainer section; tools built for the new base after the
  image) and was (what the VM had, kept when the new machine is made),
  which the undo gives back, for every remake.
- Messages: devcontainer_changed/new reworded, devcontainer_reread and
  devcontainer_gone added, devcontainer_ports_not_forwarded removed; the
  docs link points at the new "Updating a VM from the file" section.
- Tests: TestReread, TestRereadParts, TestFilePorts, TestFileParts,
  TestUpdateDevcontainer (undo and finish), TestUpDevcontainer and
  TestPlanDevcontainerFrom (the file's ports added), devcontainer.txtar
  (a new VM's ports, update after a change with the user's port added
  and the file's removed, --from winning, the file removed, a file that
  appeared), e2e's devcontainer section (the file's port reaches this
  machine; devvm update, the home kept, the new port in place of the
  old one).
- Docs: using/devcontainer (its ports, the security note), images,
  toolchains, commands, the internals overview's remake section and
  state table, the design note, the security model, attack vectors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:56:32 -07:00
w3cjandClaude Opus 5.5 74f41b0efb refactor(image): one shared-tool table
image.SharedTools, a table of image.ToolDef (name, kind, members, the
files that call for it, its installer), is the one list of shared
tools. image.Toolchains, image.Agents, GroupTools, IsTool, IsAgent and
SortTools derive from it, and so do project.DetectFiles' toolchain
markers (the nix layer's own files stay in project), the lock's rust
case (image.NoDownload, for a tool rustup installs) and the
devcontainer features devvm maps to a toolchain.

Tests: TestSharedTools (the views, NoDownload, each member once),
TestSharedToolsPolicies (shared-tools' policies are one per shared
tool), and TestConfigTools now checks mise.toml's tools against the
table's members. The contributing page names the table and what adding
a shared tool takes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:53:40 -07:00
w3cjandClaude Opus 5.5 361087f95a refactor(proxy): host-only modes out of proxy.Main, into agentlogin and trust
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:

- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
  File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
  keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
  MCPSecrets and Redact. The salt is a parameter, not a global or
  DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
  hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
  through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
  1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
  netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
  redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.

Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:04:31 -07:00
w3cjandClaude Opus 5.5 82566e9010 refactor: shell quoting, the VM-name grammar and value patterns each in one place
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.

internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.

Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.

netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.

The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 16:07:18 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-01 18:19:23 -07:00
w3cjandClaude Opus 5.5 3da0d6b0a6 feat(devcontainer): a project's devcontainer.json as input for new VMs
A new VM gets what the folder's .devcontainer/devcontainer.json (or .devcontainer.json) says, on every backend: image as --from (only an image its registry gives anyone, asked anonymously, pinned to that digest, never a registry on this machine or its network), features devvm has layers for (docker-in-docker as the docker layer, node, python, rust, go), forwardPorts as far as the user's ports allow, containerEnv and remoteEnv in the VM's environment, onCreate/updateContent/postCreate commands once and postStartCommand at each start, in the VM as its user. --no-devcontainer skips it; the command line wins. Later launches only warn when the file changed.

Nothing from it runs on or reaches the host: initializeCommand never runs, ${localEnv} and the host-folder variables are refused, builds, Compose and docker-outside-of-docker are refused, mounts, runArgs and privileged ignored. The file is read through os.Root, without blocking, at most 1 MiB. A docker layer only the file asks for still asks about network policy on Docker.

Reviewed with the security-audit skill (FuzzParse, design note); e2e: project 69/0, docker linux 135/0, smolvm 131/0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 04:33:54 -07:00