mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
Every VM gets its agents' settings and logins from devvm's own store, never from the agents' files in the home folder: settings in ~/.config/devvm/agents/<agent>/, logins in ~/.local/share/devvm/logins/<agent>/ (folders 700, files 600, each agent's logins folder kept out of Time Machine), each laid out as in a home folder. The store's settings folders are mounted read-only and linked into the VM's home; its files and logins are copied in, with network policy as placeholders the proxy fills from the store. devvm agent import [AGENT...] [--force] copies the home folder's agent settings and logins into the store once: only agentDirs, agentFiles and secrets.LoginRel's paths, never history; .claude.json reduced to its settings, account state and MCP servers; read through each agent's folder as an os.Root, so no link out of it is followed (a link to a file inside becomes a copy, any other is left out with a warning, and so is a login file that's a link); Claude Code's plugin records renamed to the store's folders. It asks before replacing what the store has (refused without a terminal, naming --force), replaces in place, keeping the mounted folders, and prunes what the home folder no longer has. - paths: Dirs.AgentSettings, Dirs.AgentLogins - secrets: LoginRel, LoginFile(Dirs, kind), SaveLogin, HasLogin, Store.ExcludeFromBackup; Logins, VMLogin, ClaudeCopy, MCPSecrets and the proxy's Get read the store - vm: agentStore, agentMounts/homeSkips/Inventory.Mounts take Dirs, syncer.stageAgents, AgentImport; the guest's links file holds each folder's home path and its mount's (host_home is gone) - structure: callers takes methods (pkg.Type.Name); Dirs.AgentSettings only in vm/agents.go, Dirs.AgentLogins only in secrets/secrets.go - messages: agent_import_none, agent_import_nothing, agent_import_replace, nothing_imported, agent_settings_imported, agent_login_imported, agent_import_link_left_out, agent_login_read_failed, agent_import_failed; the login refresh messages point at devvm agent import - tests: agentimport_test.go, testdata/script/agent.txtar, sync and network scripts through the store, e2e project and network sections - docs: coding agents (devvm's agent store, importing from this machine), README, getting started, safety, internals, contributing Co-Authored-By: Claude Opus 5.5 <[email protected]>
72 lines
3.0 KiB
Plaintext
72 lines
3.0 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; 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=claude, codex, opencode 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_left_out path=\S*/home/\.claude/skills/escape$'
|
|
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$'
|
|
|
|
# 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.
|
|
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
|
|
-- 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"}
|