Files
w3cjandClaude Opus 5.5 d94929523d feat(vm): a new VM shows a summary, then asks whether to customize it
Before devvm makes a new VM it shows a summary of what the VM gets:
each toolchain, coding agent and layer with why (the file that calls for
it, devvm setup, config.toml or the flag that gave it), its size, network
tier and ports, and the devcontainer.json it's made as. Where the picker
shows (CanPick) and something is left to choose, it asks
"Customize it? [y/N]": Enter makes the VM as shown; y opens the picker
(a part a flag gave greyed out), then the network tier question when no
tier is given or saved, then the VM's CPUs and memory (for this VM
alone). Without a terminal or with --no-input the summary ends with the
flags that choose others. The summary replaces new_vm_gets and
devcontainer_using. devvm's first run asks its size and agents first,
as before, then shows the summary.

A test build's DEVVM_PICK_ON_PIPE shows the picker with a terminal on
stdin alone, so testscript's ttyin reaches it (up_customize.txtar).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 16:48:53 -07:00

148 lines
5.8 KiB
Plaintext

# What devvm checks before it builds or creates anything: the folder, its
# path and name, and its toolchains, agents and layers.
# A folder that is or holds the home folder or devvm's state is refused,
# and so is one inside devvm's own folders, unless --unsafe-folder.
cd $HOME
! exec devvm --network open
stderr '^devvm: unsafe_folder dir=/\S*/home holds=\S*/home$'
cd $XDG_DATA_HOME
! exec devvm --network open
stderr '^devvm: unsafe_folder dir=/\S*/data holds=\S*/data/devvm$'
cd $XDG_CONFIG_HOME
! exec devvm --network open
stderr '^devvm: unsafe_folder dir=/\S*/config holds=\S*/config/devvm$'
mkdir $XDG_CONFIG_HOME/devvm/layers
cp $WORK/config/foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
cd $XDG_CONFIG_HOME/devvm/layers
! exec devvm --network open
stderr '^devvm: unsafe_folder_inside dir=/\S*/config/devvm/layers inside=\S*/config/devvm$'
mkdir $DEVVM_LIMA_HOME/x
cd $DEVVM_LIMA_HOME/x
! exec devvm --network open
stderr '^devvm: unsafe_folder_inside dir=/\S*/lima/x inside=\S*/lima$'
stub_calls
! stdout 'create|clone'
# A project in the home folder is fine; --unsafe-folder mounts it anyway.
mkdir $HOME/proj
cd $HOME/proj
exec devvm --network open
! stderr unsafe_folder
stdout '^==> creating_from image=base vm=devvm-proj-[0-9a-f]{14}$'
cd $XDG_CONFIG_HOME/devvm/layers
exec devvm --unsafe-folder --network open
stderr '^devvm: unsafe_folder_used dir=/\S*/config/devvm/layers holds=\S*/config/devvm$'
! stderr 'unsafe_folder_inside'
stub_calls
stdout '^limactl clone .* devvm-layers-[0-9a-f]{14} '
# Lima can't mount paths with a comma or a control character.
project a,b
! exec devvm --network open
stderr '^devvm: bad_path dir=/\S*/a,b$'
cd $WORK
exec sh -c 'mkdir "$(printf "t\tab")" && cd "$(printf "t\tab")" && ! devvm --network open'
stderr '^devvm: bad_path dir=/\S*/tab$'
# The VM's name: the folder's, lowercase, other characters as dashes, at
# most 20 of them, then the hash of its path.
project My_App.v2
exec devvm --network open
stdout '^==> creating_from image=base vm=devvm-my-app-v2-[0-9a-f]{14}$'
project 'My App'
exec devvm --network open
stdout '^==> creating_from image=base vm=devvm-my-app-[0-9a-f]{14}$'
project a-very-long-folder-name-for-a-project
exec devvm --network open
stdout '^==> creating_from image=base vm=devvm-a-very-long-folder-n-[0-9a-f]{14}$'
# A Lima home too long for any folder's name is refused for a new VM.
project roomless
env DEVVM_LIMA_HOME=/tmp/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
! exec devvm --network open
stderr '^devvm: vm_name_no_room backend=lima max=[0-9]+$'
env DEVVM_LIMA_HOME=$LIMA_HOME
! vm_name ROOMLESS roomless
# Without a terminal, a new VM gets the defaults: nothing detected is base
# with no shared tools, as its summary says, ending with the flags.
# --no-input is the same in a terminal.
project empty
exec devvm --network open --no-input
stdout '^==> new_vm_summary vm=devvm-empty-[0-9a-f]{14}\nnew_vm_toolchains_none\nnew_vm_agents_none\nnew_vm_layers_none\n'
stdout '^new_vm_choose$'
stdout '^==> creating_from image=base vm=devvm-empty-[0-9a-f]{14}$'
vm_name EMPTY empty
vm_state $EMPTY_dir/vm.json
stdout '^image=base$'
! stdout '^tools.names='
# The flags' values are checked before anything runs: an unknown name
# with a did-you-mean, none only alone. A word after devvm is no image.
project node
cp $WORK/package.json package.json
stub_reset
! exec devvm --network open stray
stderr '^devvm: no_command word=stray$'
stderr '^usage_help command=devvm$'
! exec devvm --network open node
stderr '^devvm: no_command_part flags=--tools node word=node$'
! exec devvm --network open --layers stray
stderr '^devvm: unknown_part flag=--layers given=stray names=desktop docker foo nix$'
stderr '^usage_help command=devvm$'
! exec devvm --network open --layers fooo
stderr '^devvm: unknown_part_like flag=--layers given=fooo like=foo$'
! exec devvm --network open --tools claude
stderr '^devvm: part_other_flag flag=--tools given=claude other=--agents$'
! exec devvm --network open --agents cladue
stderr '^devvm: unknown_part_like flag=--agents given=cladue like=claude$'
! exec devvm --network open --tools node,none
stderr '^devvm: part_none_alone flag=--tools$'
stub_calls
! stdout 'create|clone|start'
! vm_name NODE node
# Each flag is the exact list of its part: --layers alone keeps the
# toolchains the folder calls for.
exec devvm --network open --layers foo
stdout '^new_vm_toolchain_for file=package\.json tool=node\nnew_vm_agents_none\nnew_vm_layer_from from=--layers layer=foo\n'
stdout '^==> creating_from image=foo vm=devvm-node-[0-9a-f]{14}$'
vm_name NODE node
vm_state $NODE_dir/vm.json
stdout '^image=foo$'
stdout '^tools.names=node$'
stdout '^chain=base=[0-9a-f]{12} foo=[0-9a-f]{12}$'
# A Nix project's flake.nix doesn't give it the nix layer: layers are
# chosen. The toolchains detected are the default, setup's agents join
# them, and --tools none takes the toolchains out.
project flake
cp $WORK/package.json package.json
cp $WORK/flake.nix flake.nix
exec devvm setup --agents claude
exec devvm --network open --no-git-protect
stdout '^new_vm_toolchain_for file=package\.json tool=node\nnew_vm_agent_from agent=claude from=devvm setup\nnew_vm_layers_none\n'
stdout '^==> creating_from image=base vm=devvm-flake-[0-9a-f]{14}$'
vm_name FLAKE flake
vm_state $FLAKE_dir/vm.json
stdout '^tools.names=node claude$'
stdout '^chain=base=[0-9a-f]{12}$'
project flake2
cp $WORK/package.json package.json
exec devvm --network open --no-git-protect --tools none --layers nix
stdout '^new_vm_toolchains_none\nnew_vm_agent_from agent=claude from=devvm setup\nnew_vm_layer_from from=--layers layer=nix\n'
vm_name FLAKE2 flake2
vm_state $FLAKE2_dir/vm.json
stdout '^image=nix$'
stdout '^tools.names=claude$'
# Any word is a usage error.
! exec devvm xyzzy b
stderr '^devvm: no_command word=xyzzy$'
-- package.json --
{}
-- config/foo.sh --
#!/bin/bash
echo foo
-- flake.nix --
{ outputs = { self }: { }; }