mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]>
139 lines
5.2 KiB
Plaintext
139 lines
5.2 KiB
Plaintext
# devvm host, devvm code and devvm cursor: the folder's VM launched as
|
|
# devvm does without its shell (checked, started, self-checked, set up, in
|
|
# devvm's ssh config), then its host name shown, or its folder opened in
|
|
# VS Code or Cursor (a stub code or cursor) with the SSH agent devvm
|
|
# started with. The Include line is offered for the sandbox's own
|
|
# ~/.ssh/config only.
|
|
|
|
# No VM.
|
|
project web
|
|
! exec devvm host
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! exec devvm code
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! exec devvm cursor
|
|
stderr '^devvm: no_vm dir=\S*/web$'
|
|
! stderr cursor_agent_in_vm
|
|
|
|
# A stopped VM: started and set up, no shell. Without a terminal, the
|
|
# Include line is shown, not added.
|
|
exec devvm --network open --no-git-protect
|
|
vm_name WEB web
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
exec devvm host
|
|
stdout '^==> starting what=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^ssh_include_needed line=Include /\S*/data/devvm/ssh_config$'
|
|
stderr '^devvm: ssh_include_yourself$'
|
|
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
|
|
stub_calls
|
|
stdout '^limactl start --tty=false devvm-web-[0-9a-f]{14}$'
|
|
stdout 'tar -xf'
|
|
! stdout 'limactl shell --workdir /\S*/web devvm-web'
|
|
catg $DATA/ssh_config
|
|
stdout '^Host devvm-web devvm-web-[0-9a-f]{14}$'
|
|
! exists $HOME/.ssh
|
|
|
|
# With the line there: nothing asked. A size its state asks for waits for
|
|
# the running VM's next start, as on a launch.
|
|
exec sh -c 'mkdir -p "$HOME/.ssh" && echo "Include $DATA/ssh_config" > "$HOME/.ssh/config"'
|
|
# ssh by the folder's name reads devvm's ssh config in its data folder
|
|
# through that line: the real ssh resolves the name, connecting to nothing.
|
|
[exec:/usr/bin/ssh] exec /usr/bin/ssh -F $HOME/.ssh/config -G devvm-web
|
|
[exec:/usr/bin/ssh] stdout '^hostname 127\.0\.0\.1$'
|
|
[exec:/usr/bin/ssh] stdout '^userknownhostsfile \S*/data/devvm/vms/[0-9a-f]{14}/run/known_hosts$'
|
|
[exec:/usr/bin/ssh] stdout '^hostkeyalias devvm-web-[0-9a-f]{14}$'
|
|
json_set $WEB_dir/vm.json size.cpus=6
|
|
stub_reset
|
|
exec devvm host
|
|
! stdout 'starting|ssh_include'
|
|
stderr '^devvm: next_start_size vm=devvm-web-[0-9a-f]{14}\ndevvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
|
|
stub_calls
|
|
! stdout 'limactl (start|edit)'
|
|
|
|
# devvm code: the folder in VS Code over Remote-SSH, with the SSH agent
|
|
# devvm started with, though this VM's own connections carry none.
|
|
env SSH_AUTH_SOCK=$WORK/user-agent.sock
|
|
stub_reset
|
|
exec devvm code
|
|
stub_calls
|
|
stdout '^code --remote ssh-remote\+devvm-web /\S*/web$'
|
|
exec sh -c 'cat "$STUB_DIR/code-agent"'
|
|
stdout '^\S*/user-agent\.sock$'
|
|
|
|
# devvm cursor: the same in the Cursor editor, with its cursor command,
|
|
# first warning that Cursor's Agent will run in the VM while Cursor's
|
|
# user settings on this machine don't route it through the app here.
|
|
stub_reset
|
|
exec devvm cursor
|
|
stderr '^devvm: cursor_agent_in_vm file=.*/Cursor/User/settings\.json$'
|
|
stub_calls
|
|
stdout '^cursor --remote ssh-remote\+devvm-web /\S*/web$'
|
|
! stdout '^code '
|
|
exec sh -c 'cat "$STUB_DIR/cursor-agent"'
|
|
stdout '^\S*/user-agent\.sock$'
|
|
env SSH_AUTH_SOCK=
|
|
# With the route set there, no warning, and the file stays as it was.
|
|
[darwin] env CURSOR_USER=$HOME/Library/Application' Support'/Cursor/User
|
|
[!darwin] env CURSOR_USER=$XDG_CONFIG_HOME/Cursor/User
|
|
mkdir $CURSOR_USER
|
|
cp $WORK/cursor-settings.json $CURSOR_USER/settings.json
|
|
exec devvm cursor
|
|
! stderr cursor_agent_in_vm
|
|
cmp $CURSOR_USER/settings.json $WORK/cursor-settings.json
|
|
|
|
# Two folders named web: the VM by its full name.
|
|
mkdir $WORK/other/web
|
|
cd $WORK/other/web
|
|
exec devvm --network open --no-git-protect
|
|
stub_reset
|
|
exec devvm code
|
|
stub_calls
|
|
stdout '^code --remote ssh-remote\+devvm-web-[0-9a-f]{14} /\S*/other/web$'
|
|
stub_reset
|
|
exec devvm cursor
|
|
stub_calls
|
|
stdout '^cursor --remote ssh-remote\+devvm-web-[0-9a-f]{14} /\S*/other/web$'
|
|
|
|
# No code or cursor command on PATH: said, with the host to connect to,
|
|
# and no warning about Cursor's Agent, without Cursor's settings too.
|
|
rm $CURSOR_USER/settings.json
|
|
exec sh -c 'mkdir "$WORK/nocode" && for f in "$(dirname "$DEVVM_HOST_MISE")"/*; do case "${f##*/}" in code|cursor) ;; *) ln -s "$f" "$WORK/nocode/";; esac; done'
|
|
env SAVED_PATH=$PATH
|
|
env PATH=$DEVVM_BIN:$WORK/nocode:/usr/bin:/bin:/usr/sbin:/sbin
|
|
stub_reset
|
|
! exec devvm code
|
|
stderr '^devvm: no_code_command host=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm cursor
|
|
stderr '^devvm: no_cursor_command host=devvm-web-[0-9a-f]{14}$'
|
|
! stderr cursor_agent_in_vm
|
|
stub_calls
|
|
! stdout '^(code|cursor) '
|
|
env PATH=$SAVED_PATH
|
|
|
|
# Network policy: a VM devvm started confined that still reaches the
|
|
# internet directly is stopped, as on a launch; no host name. (Its
|
|
# hostagent here: the test's runner, which runs on, in place of the
|
|
# stub's.)
|
|
project leak
|
|
exec devvm --network allowlist --no-git-protect
|
|
vm_name LEAK leak
|
|
exec sh -c 'echo $PPID > "$LIMA_HOME/$LEAK/ha.pid"; echo "$PPID 1" > "$LEAK_dir/run/started"'
|
|
stub_reset
|
|
exec sh -c ': > "$STUB_DIR/net-direct"'
|
|
! exec devvm host
|
|
stderr '^devvm: net_direct_route vm=devvm-leak-[0-9a-f]{14}$'
|
|
! stdout ssh_host_info
|
|
stub_calls
|
|
stdout '^limactl stop devvm-leak-[0-9a-f]{14}$'
|
|
! stdout 'tar -xf'
|
|
rm $STUB_DIR/net-direct
|
|
|
|
-- cursor-settings.json --
|
|
// Cursor's user settings, with comments and a trailing comma.
|
|
{
|
|
"editor.fontSize": 14,
|
|
"cursorAgentHost.remoteInferenceRoute": "always",
|
|
}
|