mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
devvm setup chooses default layers, as it chooses new VMs' coding
agents: settings' layers key (config.toml's layers = [...], or
settings.json's, saved by devvm setup), bottom first, each name checked
as a layer's (not base or a shared tool's).
- devvm setup --layers LIST|none saves them without asking; a name that
isn't a layer is a usage error with a did-you-mean, and config.toml's
are refused (set_in_config). In a terminal, setup asks for them last,
after the agents (layers_help), with each layer's description.
- A new VM's picker checks setup's layers under Layers ("from devvm
setup"), and they keep their order at the bottom of the image, with
what's added on top. Without a terminal a new VM gets them; --layers
replaces them and --layers none gives none. A devcontainer.json's
layers go on top.
- A default layer whose script is gone is skipped with a warning
(default_layer_gone); one the backend can't run fails before anything
is built, naming the layer and both ways out (default_layer_lacks).
- pick_setup_agent becomes pick_from_setup, for agents and layers;
desktop_no_layer names devvm setup --layers too.
Code: settings.KeyLayers, Defaults.Layers, checkLayers, layerKind;
vm.LayersChoice (Set, Ask), creation.addSetupLayers,
requireSetupLayers, inOrder; cli addLayersFlag, setup's --layers and its
completion.
Tests: TestReadConfig, TestConfigRefused, TestPrecedence,
TestReadSaved; TestLayersChoice, TestUpParts (setup's layers, --layers
replacing them, --layers none, a gone layer), TestUpSetupLayerLacks,
TestUpPicker (setup's layers checked, their order kept); TestSetupLayers,
TestSetupAsks, TestSetupConfigSets; setup.txtar (--layers, none, unknown
names, a new VM getting them, --layers and --layers none replacing them,
a gone layer warned, config.toml's layers refused and given to a new VM).
Docs: settings (config.toml's layers key, devvm setup's fifth question
and flag, Layers for new VMs), images (what a new VM gets), customizing,
desktop, commands, first VM; the CLI reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
201 lines
7.6 KiB
Plaintext
201 lines
7.6 KiB
Plaintext
# setup: base's features, and new VMs' size, network policy, agents and
|
|
# layers (all asked in a terminal, which Go tests cover; without one, the
|
|
# size and network policy aren't asked and the features are kept, or
|
|
# every one until they're chosen; --features, --agents and --layers
|
|
# without asking), each saved in settings.json. A new choice of features says base rebuilds, and once
|
|
# images are built that devvm gc deletes the old ones.
|
|
env SAVED=$DATA/settings.json
|
|
|
|
# Kept: none chosen; no size asked.
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
! stdout base_will_rebuild
|
|
! stdout 'size_question|size_defaults'
|
|
! grep '"backend"|"size"|"agents"' $SAVED
|
|
grep '^ "features": \[\]$' $SAVED
|
|
! stdout default_agents
|
|
! stderr .
|
|
! stub_calls
|
|
|
|
# Unchosen: every feature.
|
|
rm $SAVED
|
|
exec devvm setup
|
|
stdout '^==> base_features features=cli-tools fzf omb$'
|
|
! stdout base_will_rebuild
|
|
|
|
# --features, in the order features run; nothing built yet.
|
|
exec devvm setup --features omb,fzf
|
|
stdout '^==> base_features features=fzf omb$'
|
|
stdout '^==> base_will_rebuild$'
|
|
! stdout gc_old_hint
|
|
grep '^ "features": \[\n "fzf",\n "omb"\n \]$' $SAVED
|
|
exec devvm setup --features fzf,omb
|
|
! stdout base_will_rebuild
|
|
|
|
# Built: a new choice rebuilds base, and gc deletes the old one.
|
|
exec devvm build base
|
|
exec devvm setup --features none
|
|
stdout '^==> base_features_none$'
|
|
stdout '^==> base_will_rebuild$'
|
|
stdout '^gc_old_hint$'
|
|
exec devvm build base
|
|
stdout '^==> building_image image=base key='
|
|
exec devvm gc --force
|
|
stdout '^gc_image image=base key='
|
|
|
|
# A name that isn't a feature changes nothing: desktop is a layer.
|
|
! exec devvm setup --features fzf,nope
|
|
stderr '^devvm: no_feature feature=nope features=cli-tools fzf omb$'
|
|
! stdout base_features
|
|
! exec devvm setup --features desktop
|
|
stderr '^devvm: no_feature feature=desktop features=cli-tools fzf omb$'
|
|
! stdout base_features
|
|
exec devvm setup
|
|
stdout '^==> base_features_none$'
|
|
|
|
# New VMs' size is devvm size -g's, and without a terminal nothing asks
|
|
# for it or for new VMs' network policy. Flags for a new VM are devvm's
|
|
# alone, so setup doesn't take them, and no command chooses a backend.
|
|
! exec devvm setup --backend lima
|
|
stderr '^devvm: flag_unknown command=devvm setup flag=--backend$'
|
|
! exec devvm setup --cpus 2
|
|
stderr '^devvm: flag_unknown command=devvm setup flag=--cpus$'
|
|
! exec devvm setup --memory 8
|
|
stderr '^devvm: flag_unknown command=devvm setup flag=--memory$'
|
|
! grep '"size"|"network"' $SAVED
|
|
|
|
# --features none chooses none; --features '' is refused, and changes
|
|
# nothing.
|
|
exec devvm setup --features fzf
|
|
! exec devvm setup --features ''
|
|
stderr '^devvm: flag_blank flag=features$'
|
|
grep '^ "features": \[\n "fzf"\n \]$' $SAVED
|
|
exec devvm setup --features none
|
|
stdout '^==> base_features_none$'
|
|
grep '^ "features": \[\]$' $SAVED
|
|
|
|
# The network policy saved for new VMs: off makes one without it.
|
|
exec devvm network -g off
|
|
project off git
|
|
exec devvm --no-git-protect
|
|
vm_name OFF off
|
|
vm_state $OFF_dir/vm.json
|
|
stdout '^net.on=false$'
|
|
cd $WORK
|
|
|
|
# --agents: the coding agents new VMs get, without asking; none for none.
|
|
# An agent that isn't one is a usage error, with a did-you-mean.
|
|
exec devvm setup --agents claude,codex
|
|
stdout '^==> default_agents agents=claude codex$'
|
|
grep '^ "agents": \[\n "claude",\n "codex"\n \]$' $SAVED
|
|
exec devvm setup --agents none
|
|
stdout '^==> default_agents_none$'
|
|
grep '^ "agents": \[\]$' $SAVED
|
|
! exec devvm setup --agents cladue
|
|
stderr '^devvm: unknown_part_like flag=--agents given=cladue like=claude$'
|
|
stderr '^usage_help command=devvm setup$'
|
|
! exec devvm setup --agents node
|
|
stderr '^devvm: part_other_flag flag=--agents given=node other=--tools$'
|
|
grep '^ "agents": \[\]$' $SAVED
|
|
# A new VM made without a terminal gets setup's agents, and says so.
|
|
exec devvm setup --agents codex
|
|
project agents git
|
|
exec devvm --no-network-policy --no-git-protect
|
|
stdout '^==> new_vm_gets layers=none tools=codex vm=devvm-agents-[0-9a-f]{14}$'
|
|
vm_name AGENTS agents
|
|
vm_state $AGENTS_dir/vm.json
|
|
stdout '^tools.names=codex$'
|
|
cd $WORK
|
|
|
|
# --layers: the layers new VMs get, bottom first as given, without
|
|
# asking; none for none. A name that isn't a layer is a usage error, with
|
|
# a did-you-mean, and changes nothing.
|
|
exec devvm setup --layers nix,docker
|
|
stdout '^==> default_layers layers=nix docker$'
|
|
grep '^ "layers": \[\n "nix",\n "docker"\n \]$' $SAVED
|
|
! exec devvm setup --layers dokcer
|
|
stderr '^devvm: unknown_part_like flag=--layers given=dokcer like=docker$'
|
|
stderr '^usage_help command=devvm setup$'
|
|
! exec devvm setup --layers node
|
|
stderr '^devvm: part_other_flag flag=--layers given=node other=--tools$'
|
|
grep '^ "layers": \[\n "nix",\n "docker"\n \]$' $SAVED
|
|
exec devvm setup --layers none
|
|
stdout '^==> default_layers_none$'
|
|
grep '^ "layers": \[\]$' $SAVED
|
|
# A new VM made without a terminal gets setup's layers, and says so;
|
|
# --layers replaces them, and --layers none gives it none.
|
|
exec devvm setup --layers desktop
|
|
project layers git
|
|
exec devvm --no-network-policy --no-git-protect
|
|
stdout '^==> new_vm_gets layers=desktop tools=codex vm=devvm-layers-[0-9a-f]{14}$'
|
|
vm_name LAYERS layers
|
|
vm_state $LAYERS_dir/vm.json
|
|
stdout '^image=desktop$'
|
|
project layersflag git
|
|
exec devvm --no-network-policy --no-git-protect --layers docker
|
|
stdout '^==> new_vm_gets layers=docker tools=codex vm=devvm-layersflag-[0-9a-f]{14}$'
|
|
project layersnone git
|
|
exec devvm --no-network-policy --no-git-protect --layers none
|
|
stdout '^==> new_vm_gets layers=none tools=codex vm=devvm-layersnone-[0-9a-f]{14}$'
|
|
cd $WORK
|
|
# A default layer of yours whose script is gone: warned, naming it, and
|
|
# the VM is made without it.
|
|
mkdir $CFG/layers
|
|
cp mailpit.sh $CFG/layers/mailpit.sh
|
|
exec devvm setup --layers mailpit
|
|
stdout '^==> default_layers layers=mailpit$'
|
|
rm $CFG/layers/mailpit.sh
|
|
project gone git
|
|
exec devvm --no-network-policy --no-git-protect
|
|
stderr '^devvm: default_layer_gone dir=\S*/config/devvm/layers layer=mailpit vm=devvm-gone-[0-9a-f]{14}$'
|
|
stdout '^==> new_vm_gets layers=none tools=codex vm=devvm-gone-[0-9a-f]{14}$'
|
|
cd $WORK
|
|
exec devvm setup --layers none
|
|
|
|
# What config.toml sets wins over settings.json, and devvm setup's flags
|
|
# can't change it: refused, naming the file and the key, with nothing
|
|
# saved.
|
|
cp config.toml $CFG/config.toml
|
|
! exec devvm setup --features omb
|
|
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=features$'
|
|
! exec devvm setup --agents claude
|
|
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=agents$'
|
|
grep '^ "agents": \[\n "codex"\n \],$' $SAVED
|
|
! exec devvm setup --layers docker
|
|
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=layers$'
|
|
grep '^ "layers": \[\]$' $SAVED
|
|
# Without a terminal, setup keeps config.toml's features, saying so.
|
|
exec devvm setup
|
|
stdout '^==> setup_in_config file=\S*/config/devvm/config\.toml key=features$'
|
|
! stdout base_features
|
|
# A new VM gets config.toml's layers.
|
|
project configlayers git
|
|
exec devvm --no-network-policy --no-git-protect
|
|
stdout '^==> new_vm_gets layers=nix tools=opencode vm=devvm-configlayers-[0-9a-f]{14}$'
|
|
cd $WORK
|
|
rm $CFG/config.toml
|
|
|
|
# config.toml has no backend key: a file that sets one is refused.
|
|
cp backend.toml $CFG/config.toml
|
|
! exec devvm setup
|
|
stderr '^devvm: setup_failed reason=\S*/config/devvm/config\.toml:1: unknown key "backend"$'
|
|
rm $CFG/config.toml
|
|
|
|
# An unreadable choice stays for you to fix.
|
|
cp bad.json $SAVED
|
|
! exec devvm setup
|
|
stderr '^devvm: setup_failed reason=\S*/data/devvm/settings\.json: features: not a feature''s name: "Not_A_Feature"$'
|
|
cmp $SAVED bad.json
|
|
|
|
-- config.toml --
|
|
features = ["fzf"]
|
|
agents = ["opencode"]
|
|
layers = ["nix"]
|
|
-- mailpit.sh --
|
|
#!/bin/bash
|
|
# mailpit: a layer of the user's
|
|
-- backend.toml --
|
|
backend = "lima"
|
|
-- bad.json --
|
|
{"features": ["Not_A_Feature"]}
|