mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
devvm 0.1.0's agent import copied the whole of ~/.claude/plugins into the agent store, each plugin's data and installed_plugins.json included, and every VM with Claude Code mounts the store's plugins folder whole as its seed, so that data kept reaching every VM until agent import ran again. Every start (starter.bringUp) now takes out of each seed's folder in the store the entries a seed doesn't have (agents.MachineOwn), before the VM runs, and warns once, naming them (agent_seed_cleaned). The folder itself stays, so no VM's mounts or Lima config change. A running VM stops seeing them through its mount at once on macOS; on Linux, 9p's cache can keep what it read until its next start. The folder is reached from devvm's config folder as a root, each part of the path below it a folder: a link there (only a hand-made store has one, and the VM's mount would follow it, perhaps to the user's own ~/.claude/plugins) is refused (agent_seed_link), a link among the entries is removed, never followed, and the opened folder is checked to be the one checked. The temporary files a concurrent agent import or save writes known_marketplaces.json through, regular files, stay. A folder that can't be cleaned fails the start of a VM with that agent and warns for any other (agent_seed_clean_failed, naming what the folder should hold). - vm: Env.cleanSeeds, cleanSeed and seedTemp (agents.go), called first in bringUp with the VM's agents. - msg: agent_seed_cleaned, agent_seed_clean_failed, agent_seed_link. - Tests: TestCleanSeeds (0.1.0-style store, a link entry, a concurrent import's temporary file, no store, once only), TestCleanSeedsFails (a link at the store, .claude or plugins, for a VM with and without Claude Code; an entry that can't go); fixture_v010_plugins.txtar (0.1.0's app with the store's plugins as 0.1.0's import left them and their mount: the warning, no edit but the ssh port's, the seed's link to a folder without data/, nothing said again; then the store's plugins folder a link, and an entry that can't go, each refusing app's start with agent_seed_link or agent_seed_clean_failed). - Docs: coding-agents, internals/agents, the design note's threat check; CHANGELOG Breaking, After you upgrade (running VMs, Linux's cache, plugin logins) and #56's Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
107 lines
5.4 KiB
Plaintext
107 lines
5.4 KiB
Plaintext
# devvm 0.1.0's app VM (testdata/v0.1.0/GOOS: see fixture_v010.txtar),
|
|
# with Claude Code's plugins in its agent store as 0.1.0's devvm agent
|
|
# import left them: this machine's whole ~/.claude/plugins, each folder
|
|
# 0700 and each file 0644, installed_plugins.json's paths named in the
|
|
# store, and every Claude Code VM mounting the store's folder. Its next
|
|
# launch takes out of the store what is this machine's own, such as a
|
|
# plugin's data, says so once, and leaves the folder and so the VM's
|
|
# mounts as they were: no edit but the ssh port's, and the VM's
|
|
# plugins-seed links to a folder with no data/. A store devvm can't
|
|
# clean, its plugins folder a link or an entry that can't go, keeps the
|
|
# VM from starting, naming why.
|
|
[!darwin] [!linux] skip 'a fixture for macOS and Linux only'
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
mkdir $HOME/src/db $HOME/src/app $HOME/src/web $HOME/src/scratch
|
|
cd $HOME/src/app
|
|
exec git init -q -b main
|
|
exec git commit -q --allow-empty -m one
|
|
fixture v0.1.0
|
|
vm_name APP app
|
|
|
|
# The store's plugins, as 0.1.0 copied them, and its Claude Code VMs'
|
|
# mounts of them, after skills, in its agents' folders' order.
|
|
exec sh $WORK/plugins.sh
|
|
exec sed -i.bak -f $WORK/mount.sed $STUB_DIR/state.json
|
|
exec limactl list --json
|
|
stdout '"location":"\S*/agents/claude/\.claude/plugins","writable":false'
|
|
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> starting what=devvm-app-[0-9a-f]{14}$'
|
|
stderr '^devvm: agent_seed_cleaned agent=Claude Code dir=\S*/agents/claude/\.claude/plugins entries=\.trash, data, installed_plugins\.json, mcpb$'
|
|
! stderr 'unreadable|corrupt|layout_|replaced|refused|failed|agent_dirs_'
|
|
stub_calls
|
|
stdout '^limactl start --tty=false devvm-app-[0-9a-f]{14}$'
|
|
stdout '^limactl edit --tty=false devvm-app-[0-9a-f]{14} --set \.ssh\.localPort=[0-9]+$'
|
|
! stdout '(?s)limactl edit .*limactl edit'
|
|
! stdout 'limactl (create|clone|delete)'
|
|
|
|
# The seed is the store's folder, which keeps what a seed has, and
|
|
# nothing else.
|
|
exec tar -xOf $STUB_DIR/sync.tar links
|
|
stdout '^\.claude/plugins-seed\n\S*/agents/claude/\.claude/plugins$'
|
|
! exists $CFG/agents/claude/.claude/plugins/data
|
|
! exists $CFG/agents/claude/.claude/plugins/installed_plugins.json
|
|
! exists $CFG/agents/claude/.claude/plugins/mcpb
|
|
! exists $CFG/agents/claude/.claude/plugins/.trash
|
|
exists $CFG/agents/claude/.claude/plugins/known_marketplaces.json
|
|
exists $CFG/agents/claude/.claude/plugins/marketplaces/m/.claude-plugin/marketplace.json
|
|
exists $CFG/agents/claude/.claude/plugins/cache/m/p/1.0.0/.claude-plugin/plugin.json
|
|
|
|
# Once only.
|
|
exec devvm stop
|
|
stub_reset
|
|
exec devvm
|
|
! stderr agent_seed_cleaned
|
|
stub_calls
|
|
! stdout 'limactl edit'
|
|
exec devvm stop
|
|
|
|
# A store devvm can't clean: a VM with Claude Code doesn't start, naming
|
|
# why, and nothing of where a link leads goes. First the store's plugins
|
|
# folder a link, as only a hand-made store has one, here to a folder
|
|
# with a plugin's data.
|
|
exec sh $WORK/linked.sh
|
|
! exec devvm
|
|
! stdout starting
|
|
stderr '^devvm: agent_seed_link agent=Claude Code dir=\S*/agents/claude/\.claude/plugins keep=known_marketplaces\.json, marketplaces, cache link=\S*/agents/claude/\.claude/plugins$'
|
|
exists $WORK/elsewhere/data/p/state.json
|
|
# Then a folder of its own again, with an entry devvm can't take out.
|
|
exec sh $WORK/locked.sh
|
|
! exec devvm
|
|
! stdout starting
|
|
stderr '^devvm: agent_seed_clean_failed agent=Claude Code dir=\S*/agents/claude/\.claude/plugins keep=known_marketplaces\.json, marketplaces, cache why='
|
|
exec chmod 700 $CFG/agents/claude/.claude/plugins/data
|
|
|
|
-- linked.sh --
|
|
# The store's plugins folder becomes a link to $WORK/elsewhere, which
|
|
# holds a plugin's data; the folder itself goes to $WORK/plugins.real.
|
|
set -e
|
|
p="$CFG/agents/claude/.claude/plugins"
|
|
mkdir -p "$WORK/elsewhere/data/p"
|
|
echo '{"token":"testfake-elsewhere"}' >"$WORK/elsewhere/data/p/state.json"
|
|
mv "$p" "$WORK/plugins.real"
|
|
ln -s "$WORK/elsewhere" "$p"
|
|
-- locked.sh --
|
|
# The store's plugins folder is a folder again, with a plugin's data in
|
|
# a folder its owner can't write, so its entry can't be taken out.
|
|
set -e
|
|
p="$CFG/agents/claude/.claude/plugins"
|
|
rm "$p"
|
|
mv "$WORK/plugins.real" "$p"
|
|
mkdir -p "$p/data/p"
|
|
echo '{}' >"$p/data/p/state.json"
|
|
chmod 500 "$p/data"
|
|
-- plugins.sh --
|
|
p="$CFG/agents/claude/.claude/plugins"
|
|
mkdir -m 700 "$p" "$p/data" "$p/data/p-m" "$p/mcpb" "$p/mcpb/b" "$p/.trash" "$p/marketplaces" "$p/marketplaces/m" "$p/marketplaces/m/.claude-plugin" "$p/cache" "$p/cache/m" "$p/cache/m/p" "$p/cache/m/p/1.0.0" "$p/cache/m/p/1.0.0/.claude-plugin" || exit 1
|
|
printf '{"m":{"source":{"source":"github","repo":"o/m"},"installLocation":"%s/marketplaces/m"}}' "$p" >"$p/known_marketplaces.json"
|
|
printf '{"version":2,"plugins":{"p@m":[{"scope":"user","installPath":"%s/cache/m/p/1.0.0","version":"1.0.0"}]}}' "$p" >"$p/installed_plugins.json"
|
|
echo '{"name":"m","plugins":[{"name":"p","source":"./p"}]}' >"$p/marketplaces/m/.claude-plugin/marketplace.json"
|
|
echo '{"name":"p","version":"1.0.0"}' >"$p/cache/m/p/1.0.0/.claude-plugin/plugin.json"
|
|
echo '{"token":"testfake-plugin-data-v010"}' >"$p/data/p-m/state.json"
|
|
echo '{}' >"$p/mcpb/b/manifest.json"
|
|
chmod 644 "$p/known_marketplaces.json" "$p/installed_plugins.json" "$p/marketplaces/m/.claude-plugin/marketplace.json" "$p/cache/m/p/1.0.0/.claude-plugin/plugin.json" "$p/data/p-m/state.json" "$p/mcpb/b/manifest.json"
|
|
-- mount.sed --
|
|
s|\(\\"location\\":\\"\([^"]*\)/\.claude/skills\\",\\"writable\\":false}\)|\1,{\\"location\\":\\"\2/.claude/plugins\\",\\"writable\\":false}|g
|