# devvm rm checks the worktrees opencode made in the VM first, as an # export leaves them out: one with uncommitted changes is shown under its # path and asked about, which --force never answers, so without a # terminal rm refuses, naming --no-worktree-check, and in one no keeps # the VM. --no-worktree-check warns and deletes it unchecked. A remake # with --clean-home checks them too, after its own question, and # --no-worktree-check goes only with --clean-home. (The stubs keep the # VM's home folder in $STUB_DIR/vmhome-.) env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t project web exec git init -q -b main exec git commit -q --allow-empty -m one exec devvm --network open --no-git-protect --agents opencode vm_name WEB web # An uncommitted change in a worktree: shown, and without a terminal rm # keeps the VM. A folder that isn't a worktree is passed over. exec sh -c 'r="$STUB_DIR/vmhome-$WEB/.local/share/opencode/worktree/abc123"; git worktree add -q -b brave "$r/brave" && mkdir -p "$r/plain" && echo x > "$r/brave/new"' ! exec devvm rm --force --no-export stdout '^agent_tree_dirty agent=opencode path=~/\.local/share/opencode/worktree/abc123/brave$' stdout '^\?\? new$' stderr '^devvm: no_terminal_delete_trees command=devvm rm$' exists $WEB_dir/vm.json # In a terminal: yes to rm, then no keeps it. ttyin -stdin $WORK/yes-no.txt exec devvm rm --no-export stderr 'delete_anyway \[y/N\] ' stdout '^==> kept vm=devvm-web-[0-9a-f]{14}$' exists $WEB_dir/vm.json # A remake with --clean-home checks them too; one that keeps the home # folder doesn't. --no-worktree-check goes only with --clean-home. ! exec devvm layer add docker --force --no-export --no-worktree-check stderr '^devvm: flag_needs_flag flag=--no-worktree-check needs=--clean-home$' ! exec devvm layer add docker --force --no-export --clean-home stdout '^agent_tree_dirty agent=opencode path=~/\.local/share/opencode/worktree/abc123/brave$' stderr '^devvm: no_terminal_delete_trees command=devvm layer add docker --clean-home\n' vm_state $WEB_dir/vm.json stdout '^image=base$' # --no-worktree-check: warned, and deleted with the change. exec devvm rm --force --no-export --no-worktree-check stderr '^devvm: trees_check_skipped command=devvm rm vm=devvm-web-[0-9a-f]{14}$' ! stdout agent_tree stdout '^==> deleted vm=devvm-web-[0-9a-f]{14}$' ! exists $WEB_dir # Clean worktrees: deleted without the question. project api exec git init -q -b main exec git commit -q --allow-empty -m one exec devvm --network open --no-git-protect --agents opencode vm_name API api exec sh -c 'git worktree add -q -b calm "$STUB_DIR/vmhome-$API/.local/share/opencode/worktree/def456/calm"' exec devvm rm --force --no-export ! stdout agent_tree ! stderr 'trees|delete_anyway' stdout '^==> deleted vm=devvm-api-[0-9a-f]{14}$' stub_calls stdout 'cd ~ \|\| exit 1' -- yes.txt -- y -- no.txt -- n -- yes-no.txt -- y n