mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
A VM's ~/.claude/plugins was the agent store's plugins folder, mounted
read-only, so everything Claude Code writes there failed with EROFS: a
plugin's data (${CLAUDE_PLUGIN_DATA}), installs, marketplace refreshes,
mcpb/ and the rest. Making the store writable would let one VM change
what Claude Code runs in every other VM, so each VM's ~/.claude/plugins
is now its own folder on its disk (CLAUDE_CODE_PLUGIN_CACHE_DIR), and the
store's folder is linked at ~/.claude/plugins-seed and read as Claude
Code's own read-only seed (CLAUDE_CODE_PLUGIN_SEED_DIR). Checked on a
devvm VM first: a seed-cached plugin from a GitHub-style marketplace
loads with only enabledPlugins, its hook writes ${CLAUDE_PLUGIN_DATA} in
the VM's own folder, installs in the VM work, and seed marketplaces
refuse updates.
- agents: Def.Seeds (Rel, Link, Entries), Seeds, SeedOf, MachineOwn;
Env gains Home; Claude's Env sets both variables below $HOME.
- vm: the setup links a seed at its Link and stages own-dirs, which
sync.sh makes a folder in place of a link; agentEnv writes Home values
through homeValue (shared with toolchainEnv); a remake keeps the VM's
own folder and skips the seed's link.
- devvm agent import copies only a seed's entries (known_marketplaces.json,
marketplaces, cache), directly and through followed links, so the
host's plugins' data, mcpb, synced, .trash, store and
installed_plugins.json never reach the store.
- devvm agent save: the VM's script excludes a seed folder's other
entries by name, and readSent refuses any (listedPath); a seed folder
adds and changes, never removes or prunes; claudeRecords renames the
VM's plugins path to the store's and joins known_marketplaces.json by
key, leaving records Claude Code registered from the seed as the
store's, and the store's file as it is when nothing changed.
- History: an export leaves the VM's plugins folder out and an import
skips it and the seed's link: it's settings and plugin data (which can
hold a plugin's own logins), not history, and reaches other VMs only
through devvm agent save's reviewed diff.
- Review fixes (security-audit): historyImport refuses a name with a
., .. or empty part (GNU tar's anchored excludes missed
.claude/./plugins and .claude//plugins, which now reach a writable
folder) and deletes importSkips by path after the link sweep; the save
script never excludes a name with a wildcard's character (it's sent
and refused); only a marketplace record whose exact installLocation is
clean and in the store's marketplaces joins the store's.
- Tests: claude_test.go (TestClaudePluginsSeed, TestClaudePluginsHistory,
TestAgentImportClaudePlugins, TestAgentSaveScriptClaudePlugins,
TestReadSentClaudePlugins, TestAgentSaveClaudePlugins), TestSeeds,
TestListedPath cases, the agent, agent_save and sync CLI tests, goldens,
and e2e project checks of the seed, the VM's folder and a plugin's data.
- Docs: coding-agents (store table, Claude Code's plugins under Mounts,
the save's plugin example), internals/agents, a design note with its
threat check, extending.md, CHANGELOG Fixed and After you upgrade.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
109 lines
4.7 KiB
Plaintext
109 lines
4.7 KiB
Plaintext
# devvm agent import: the agents' settings and logins copied from the
|
|
# home folder into devvm's store, never their history; logins only the
|
|
# user's to read and kept out of Time Machine; links out of an agent's
|
|
# folder left out without a terminal (agent_import_links has the rest);
|
|
# the store replaced only after asking, or with --force.
|
|
|
|
# Bare, it prints its help; its arguments are agents.
|
|
exec devvm agent
|
|
stdout 'devvm agent import'
|
|
! exec devvm agent import nope
|
|
stderr '^devvm: arg_not_choice choices='$AGENT_CHOICES' command=devvm agent import given=nope$'
|
|
|
|
# Nothing to import: said once, or for each agent named.
|
|
exec devvm agent import
|
|
stdout '^==> agent_import_nothing$'
|
|
exec devvm agent import codex
|
|
stderr '^devvm: agent_import_none agent=codex$'
|
|
! exists $CFG/agents
|
|
|
|
# The home folder's files, its history and a link out of the folder.
|
|
mkdir $HOME/.claude/skills/s $HOME/.claude/projects/p $HOME/outside
|
|
cp $WORK/skill.md $HOME/.claude/skills/s/SKILL.md
|
|
cp $WORK/settings.json $HOME/.claude/settings.json
|
|
cp $WORK/claude.json $HOME/.claude.json
|
|
cp $WORK/history.jsonl $HOME/.claude/projects/p/h.jsonl
|
|
cp $WORK/skill.md $HOME/outside/secret.md
|
|
symlink $HOME/.claude/skills/escape -> ../../outside/secret.md
|
|
exec devvm agent import
|
|
stdout '^==> agent_settings_imported agent=claude dir=\S*/config/devvm/agents/claude$'
|
|
stdout '^==> agent_login_imported agent=claude file=\S*/data/devvm/logins/claude/\.claude\.json$'
|
|
stderr '^devvm: agent_import_link_not_followed path=\S*/home/\.claude/skills/escape target=\S*/home/outside/secret\.md$'
|
|
cmp $CFG/agents/claude/.claude/settings.json $WORK/settings.json
|
|
cmp $CFG/agents/claude/.claude/skills/s/SKILL.md $WORK/skill.md
|
|
! exists $CFG/agents/claude/.claude/skills/escape
|
|
! exists $CFG/agents/claude/.claude/projects
|
|
grep '"theme": "dark"' $DATA/logins/claude/.claude.json
|
|
! grep 'projects|testfake-history' $DATA/logins/claude/.claude.json
|
|
[!darwin] exec sh -c 'stat -c %a "$DATA/logins/claude" "$DATA/logins/claude/.claude.json"'
|
|
[darwin] exec sh -c 'stat -f %Lp "$DATA/logins/claude" "$DATA/logins/claude/.claude.json"'
|
|
stdout '^700\n600\n$'
|
|
stub_calls
|
|
[darwin] stdout '^tmutil addexclusion \S*/data/devvm/logins/claude$'
|
|
|
|
# Claude Code's plugins: only what a VM reads as its seed (its marketplaces, their records and
|
|
# the plugins' cache), the records naming the store's folders; never what is this machine's own,
|
|
# such as each plugin's data or the plugins it installed (installed_plugins.json).
|
|
exec cp -R $WORK/plugins $HOME/.claude/plugins
|
|
exec sh -c 'printf "{\"m\":{\"installLocation\":\"%s/.claude/plugins/marketplaces/m\"}}\n" "$HOME" > "$HOME/.claude/plugins/known_marketplaces.json"'
|
|
exec devvm agent import --force claude
|
|
exists $CFG/agents/claude/.claude/plugins/cache/m/p/1.0.0/SKILL.md
|
|
exists $CFG/agents/claude/.claude/plugins/marketplaces/m/marketplace.json
|
|
grep '"installLocation":"\S*/config/devvm/agents/claude/\.claude/plugins/marketplaces/m"' $CFG/agents/claude/.claude/plugins/known_marketplaces.json
|
|
! exists $CFG/agents/claude/.claude/plugins/data
|
|
! exists $CFG/agents/claude/.claude/plugins/mcpb
|
|
! exists $CFG/agents/claude/.claude/plugins/synced
|
|
! exists $CFG/agents/claude/.claude/plugins/.trash
|
|
! exists $CFG/agents/claude/.claude/plugins/store
|
|
! exists $CFG/agents/claude/.claude/plugins/installed_plugins.json
|
|
exec rm -r $HOME/.claude/plugins
|
|
exec devvm agent import --force claude
|
|
! exists $CFG/agents/claude/.claude/plugins
|
|
|
|
# The store has claude's: without a terminal the import is refused,
|
|
# naming --force, and nothing changes; a yes replaces it, and so does
|
|
# --force without asking.
|
|
rm $HOME/.claude/skills/escape
|
|
cp $WORK/settings2.json $HOME/.claude/settings.json
|
|
! exec devvm agent import
|
|
stderr '^agent_import_replace agents=claude\ndevvm: no_input answer=--force$'
|
|
cmp $CFG/agents/claude/.claude/settings.json $WORK/settings.json
|
|
env DEVVM_PIPED_ANSWERS=1
|
|
stdin yes
|
|
exec devvm agent import claude
|
|
env DEVVM_PIPED_ANSWERS=
|
|
cmp $CFG/agents/claude/.claude/settings.json $WORK/settings2.json
|
|
cp $WORK/settings.json $HOME/.claude/settings.json
|
|
exec devvm agent import --force
|
|
! stderr agent_import_replace
|
|
cmp $CFG/agents/claude/.claude/settings.json $WORK/settings.json
|
|
|
|
-- yes --
|
|
y
|
|
-- plugins/cache/m/p/1.0.0/SKILL.md --
|
|
# a plugin's skill
|
|
-- plugins/marketplaces/m/marketplace.json --
|
|
{"name":"m"}
|
|
-- plugins/installed_plugins.json --
|
|
{"version":2,"plugins":{}}
|
|
-- plugins/data/p-m/state.json --
|
|
{"token":"testfake-plugin-data"}
|
|
-- plugins/mcpb/b/manifest.json --
|
|
{}
|
|
-- plugins/synced/s.json --
|
|
{}
|
|
-- plugins/.trash/t.json --
|
|
{}
|
|
-- plugins/store/s.json --
|
|
{}
|
|
-- skill.md --
|
|
# a skill
|
|
-- settings.json --
|
|
{"theme":"dark"}
|
|
-- settings2.json --
|
|
{"theme":"light"}
|
|
-- claude.json --
|
|
{"theme":"dark","projects":{"/p":{"history":["testfake-history"]}}}
|
|
-- history.jsonl --
|
|
{"prompt":"testfake-history"}
|