# devvm agent save: the folder's VM's agents' settings read from the VM # (the stub's agent-save.tar stands for its stream), shown as a diff and a # list of a folder's files, then saved into devvm's store after a yes. It # always asks: without a terminal or with --no-input it's refused, and the # store stays as it is. A stream with anything outside the agents' # settings saves nothing. env COPYFILE_DISABLE=1 # Its arguments are agents; without a VM there's nothing to save from. ! exec devvm agent save nope stderr '^devvm: arg_not_choice choices='$AGENT_CHOICES' command=devvm agent save given=nope$' project agent ! exec devvm agent save stderr '^devvm: no_vm dir=\S*/agent$' # A VM with Claude Code: an agent it doesn't have is warned about, and # an empty stream is nothing to save. exec devvm --network open --no-git-protect --agents claude vm_name AGENT agent stub_reset exec devvm agent save codex stderr '^devvm: agent_save_none agent=codex vm='$AGENT'$' exec devvm agent save stdout '^==> agent_save_nothing vm='$AGENT'$' stub_calls stdout '\.devvm-save' stdout 'jq --argjson k' # The VM's settings: without a terminal, the diff and the folder's files, # then the refusal; nothing saved. mkdir $CFG/agents/claude/.claude cp $WORK/old-settings.json $CFG/agents/claude/.claude/settings.json exec tar -cf $STUB_DIR/agent-save.tar -C $WORK/vm .devvm-save .claude/settings.json .claude/skills ! exec devvm agent save stdout '^--- \S*/config/devvm/agents/claude/\.claude/settings\.json$' stdout '^\+\+\+ '$AGENT':~/\.claude/settings\.json$' stdout '^- "theme": "dark"$' stdout '^\+ "theme": "light"$' stdout '^~/\.claude/skills in '$AGENT', into \S*/config/devvm/agents/claude/\.claude/skills:$' stdout '^ A s/SKILL\.md$' stdout '^\+\+\+ '$AGENT':~/\.claude\.json$' stderr '^devvm: agent_save_refused$' ! stderr agent_save_ask cmp $CFG/agents/claude/.claude/settings.json $WORK/old-settings.json ! exists $CFG/agents/claude/.claude/skills ! exec devvm agent save --no-input stderr '^devvm: agent_save_refused$' # In a terminal it says what saved settings run, and asks: no saves # nothing, yes saves them, with ~/.claude.json's subset, never its # projects. ttyin -stdin $WORK/no.txt exec devvm agent save stderr '^agent_save_runs$' stderr 'agent_save_ask vm='$AGENT' \[y/N\] ' stdout '^==> nothing_saved$' cmp $CFG/agents/claude/.claude/settings.json $WORK/old-settings.json ttyin -stdin $WORK/yes.txt exec devvm agent save claude stdout '^==> agent_settings_saved agent=claude dir=\S*/config/devvm/agents/claude vm='$AGENT'$' cmp $CFG/agents/claude/.claude/settings.json $WORK/vm/.claude/settings.json cmp $CFG/agents/claude/.claude/skills/s/SKILL.md $WORK/vm/.claude/skills/s/SKILL.md grep '"theme": "light"' $DATA/logins/claude/.claude.json ! grep projects $DATA/logins/claude/.claude.json # Saved, it's the same as the store's. exec devvm agent save stdout '^==> agent_save_nothing vm='$AGENT'$' # Claude Code's plugins: the VM's own plugins folder holds what it installed, and its seed, the # store's, the rest, so a save adds and changes the store's plugins and never takes one out; the # VM's marketplaces join the store's, each record naming the store's folders. The stream is only # the seed's entries (its marketplaces, their records and the plugins' cache). A marketplace that # Claude Code registered from the seed (m) is the store's own, and stays as the store has it; saved, # the same folder is no change. mkdir $CFG/agents/claude/.claude/plugins/cache/m/p/1.0.0 cp $WORK/plugin-skill.md $CFG/agents/claude/.claude/plugins/cache/m/p/1.0.0/SKILL.md exec sh -c 'printf "{\"m\":{\"installLocation\":\"%s/.claude/plugins/marketplaces/m\"}}\n" "$CFG/agents/claude" > "$CFG/agents/claude/.claude/plugins/known_marketplaces.json"' exec tar -cf $STUB_DIR/agent-save.tar --no-recursion -C $WORK/vm .devvm-save .devvm-save/home .devvm-save/claude.json .claude/settings.json .claude/plugins .claude/plugins/known_marketplaces.json .claude/plugins/cache .claude/plugins/cache/v .claude/plugins/cache/v/p .claude/plugins/cache/v/p/1.0.0 .claude/plugins/cache/v/p/1.0.0/SKILL.md ! exec devvm agent save stdout '^~/\.claude/plugins in '$AGENT', into \S*/config/devvm/agents/claude/\.claude/plugins:$' stdout '^ A cache/v/p/1\.0\.0/SKILL\.md$' stdout '^ M known_marketplaces\.json$' ! stdout '^ D ' ttyin -stdin $WORK/yes.txt exec devvm agent save claude cmp $CFG/agents/claude/.claude/plugins/cache/v/p/1.0.0/SKILL.md $WORK/vm/.claude/plugins/cache/v/p/1.0.0/SKILL.md cmp $CFG/agents/claude/.claude/plugins/cache/m/p/1.0.0/SKILL.md $WORK/plugin-skill.md grep '"m": \{\n *"installLocation": "\S*/agents/claude/\.claude/plugins/marketplaces/m"' $CFG/agents/claude/.claude/plugins/known_marketplaces.json grep '"v": \{\n *"installLocation": "\S*/agents/claude/\.claude/plugins/marketplaces/v"' $CFG/agents/claude/.claude/plugins/known_marketplaces.json ! grep 'u\.linux|autoUpdate' $CFG/agents/claude/.claude/plugins/known_marketplaces.json exec devvm agent save stdout '^==> agent_save_nothing vm='$AGENT'$' # Anything else of the VM's plugins folder, such as a plugin's data, is the VM's own: a stream # with it saves nothing. exec tar -cf $STUB_DIR/agent-save.tar --no-recursion -C $WORK/vm .devvm-save .devvm-save/home .claude/plugins .claude/plugins/data .claude/plugins/data/p .claude/plugins/data/p/state.json ! exec devvm agent save stderr '^devvm: agent_save_unsafe path=\.claude/plugins/data vm='$AGENT'$' ! exists $CFG/agents/claude/.claude/plugins/data # A stream with a path outside the agents' settings saves nothing. cp $WORK/new-settings.json $WORK/vm/.claude/settings.json exec tar -cf $STUB_DIR/agent-save.tar -C $WORK/vm .devvm-save .claude/settings.json .bashrc env DEVVM_PIPED_ANSWERS=1 stdin $WORK/yes.txt ! exec devvm agent save env DEVVM_PIPED_ANSWERS= stderr '^devvm: agent_save_unsafe path=\.bashrc vm='$AGENT'$' ! stdout '^\+\+\+' cmp $CFG/agents/claude/.claude/settings.json $WORK/old-light.json # The VM's tar failing is a failed read. exec sh -c 'echo .devvm-save > "$STUB_DIR/shell-fails-on"' ! exec devvm agent save stderr '^devvm: agent_save_not_read vm='$AGENT'$' rm $STUB_DIR/shell-fails-on -- old-settings.json -- {"theme": "dark"} -- old-light.json -- {"theme": "light"} -- new-settings.json -- {"theme": "blue"} -- vm/.claude/settings.json -- {"theme": "light"} -- vm/.claude/skills/s/SKILL.md -- # a skill made in the VM -- vm/.bashrc -- echo hi -- plugin-skill.md -- # the store's plugin -- vm/.claude/plugins/known_marketplaces.json -- { "v": {"installLocation": "/home/u.linux/.claude/plugins/marketplaces/v"}, "m": {"installLocation": "/home/u.linux/.claude/plugins-seed/marketplaces/m", "autoUpdate": false} } -- vm/.claude/plugins/cache/v/p/1.0.0/SKILL.md -- # a plugin installed in the VM -- vm/.claude/plugins/data/p/state.json -- {"token":"testfake-plugin-data"} -- vm/.devvm-save/home -- /home/u.linux -- vm/.devvm-save/claude.json -- {"theme": "light", "projects": {"/p": {"history": ["testfake-history"]}}} -- no.txt -- n -- yes.txt -- y