跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

help.txt

203 行 · 12.5 KB历史下载
1Usage: agent-vm [options] <command> [args]
2
3Commands:
4 install Put agent-vm on your PATH (a link in ~/.local/bin, or
5 AGENT_VM_BIN_DIR)
6 uninstall Remove that link. VMs and ~/.agent-vm are left alone.
7 setup Create the base VM template (run once)
8 claude [args] Run Claude Code in the VM for the current directory
9 opencode [args] Run OpenCode in the VM for the current directory
10 codex [args] Run Codex CLI in the VM for the current directory
11 vibe [args] Run Mistral Vibe in the VM for the current directory
12 pi [args] Run Pi in the VM for the current directory (opt-in at
13 setup: --preinstall=default,pi)
14 shell, sh Open a shell in the VM. Add -c "..." to run a one-shot
15 command via login zsh and exit.
16 run <cmd> [args] Run a command in the VM (no shell: for pipes/redirects
17 use 'shell -c "..."' instead; pass --tty for TUIs like
18 opencode, vibe, htop, etc.)
19 code Serve VS Code (code-server) from the VM, at
20 http://<vm-name>.localhost:<port>/, until Ctrl-C. The
21 address and the password, made in each VM, are
22 printed: open it in your browser. Opt-in at setup, with the agents'
23 extensions or without: --preinstall=default,code-claude
24 (or code-opencode, code-codex, code-vibe, code-server)
25 stop [vm-name] Stop the VM for the current directory, or the named one
26 rm [vm-name] Stop and delete the VM for the current directory, or the
27 named one. Pass a name from 'agent-vm list' to reach a VM
28 whose directory was renamed or deleted: its name is a
29 hash of the old path, so no 'cd' can name it any more.
30 destroy-all Stop and delete every agent-vm VM, the base template
31 included ('agent-vm setup' rebuilds it)
32 list, status List all agent-vm VMs, the current directory's marked
33 with >, with the agent-vm version and date of the base
34 each was cloned from
35 doctor Check the host, Lima, the base template and this
36 directory, and say how to fix what is wrong. Read-only.
37 licenses Print the licenses of agent-vm and of what is built into it
38 name [dir] Print the VM name for a directory (default: cwd)
39 info [dir] Print machine-readable state as key=value lines
40 (version, template, state_dir, project_env, dir,
41 vm_name, base_exists, vm_exists, vm_running, vm_stale,
42 ssh_host, ssh_config, git_protected,
43 security_questions).
44 Use this from scripts instead of parsing the output
45 of the human-facing commands.
46 env <sub> [args] Read/write ~/.agent-vm/env, the secrets pushed into every
47 VM. Subcommands: set KEY [VALUE] (without VALUE, read
48 from stdin, or typed unseen: out of your shell history),
49 get KEY, has KEY (exit status only), unset KEY, list
50 (key names, never values).
51 Use this rather than editing the file: it is sourced by a
52 shell, so one bad quote costs every secret in it.
53 project-env <sub> Same subcommands, for THIS directory's project only. Its
54 values are pushed after the shared ones, so a key set in
55 both takes the project's value. Stored IN the project
56 (.agent-vm.env by default, AGENT_VM_PROJECT_ENV to put it
57 elsewhere): so it follows the project and dies with it.
58 Being in a repository, it is the wrong place for a secret:
59 `agent-vm env` is outside any. `set` warns, with the line
60 to run, when the file is not ignored by git. `info` prints
61 the path as project_env=.
62 version Print the agent-vm version
63 version --min X.Y.Z
64 Check it: silent and 0 when this engine is at least
65 X.Y.Z, an actionable error and 1 when it is older
66 (2 when the call itself is wrong). For integrators.
67 help Show this help
68
69VM options (for claude, opencode, codex, vibe, pi, shell, run, code), read before the
70command or right after its name, never later: in 'agent-vm run docker run
71--rm x', --rm belongs to docker.
72 --disk GB VM disk size
73 --memory GB VM memory
74 --cpus N Number of CPUs
75 Without them, a new VM has the base template's: 10, 3
76 and 1 unless 'setup' was given others.
77 Memory and CPUs are clamped to a share of the host (half
78 of it, with a notice) so the VM cannot starve the
79 machine it runs on.
80 AGENT_VM_HOST_SHARE overrides the divisor.
81 --ssh-port N Fixed host port for the VM's SSH, for tools that save the
82 port (default: a new one on each start; 0 goes back)
83 --reset Destroy and re-clone the VM from the base template
84 --readonly Make every host share read-only: the project and the
85 ~/.agent-vm/volumes entries, rw ones included. Enforced
86 on the host side, so root in the VM cannot lift it.
87 A running VM in the other mode is restarted, asked first
88 (no by default; declined or with no terminal, the
89 command fails). The resource options ask the same, and
90 declined, the VM keeps its settings.
91 --unsafe-writable-git
92 Leave every .git writable, so the agent can commit (see
93 below). Also accepted as --unsafe-writable-git=1.
94 --unsafe-disable-security-prompts
95 Go on where a start would stop to ask about a security
96 risk (below), without offering to change your git
97 config; the warnings are still printed. For scripts
98 with no terminal. Also
99 AGENT_VM_UNSAFE_DISABLE_SECURITY_PROMPTS=1 in your shell.
100 --rm Automatically destroy the VM after the command exits
101 --scratch A new VM with nothing of yours mounted (no project, no
102 volumes), deleted when the command ends, Ctrl-C included.
103 On a terminal, the deletion is asked first: no opens a
104 shell in the VM, and its exit asks again.
105 The project's env file and runtime script stay out;
106 ~/.agent-vm/env and runtime.sh go in. The folder's own
107 VM is left alone, and several can run at once.
108
109Examples:
110 agent-vm setup # Create base VM
111 agent-vm claude # Run Claude in a VM
112 agent-vm opencode # Run OpenCode in a VM
113 agent-vm codex # Run Codex in a VM
114 agent-vm vibe # Run Mistral Vibe in a VM
115 agent-vm pi # Run Pi in a VM
116 agent-vm --disk 50 --memory 16 --cpus 8 claude # Custom resources
117 agent-vm --reset claude # Fresh VM from base template
118 agent-vm --rm claude # Destroy VM after Claude exits
119 agent-vm --readonly shell # Nothing on the host is writable
120 agent-vm --scratch claude # Nothing of yours mounted, then deleted
121 agent-vm shell # Shell into the VM
122 agent-vm sh -c "ls -la | grep config" # One-shot command via login zsh
123 agent-vm run npm install # Run a command in the VM
124 agent-vm run --tty opencode -p "..." # Run a TUI with PTY allocated
125 agent-vm code # VS Code in the browser
126 agent-vm claude -p "fix lint errors" # Pass args to claude
127 agent-vm rm old-name-1a2b3c4d # Delete a VM by name (see 'list')
128
129VMs are persistent and unique per directory. Running "agent-vm shell" or
130"agent-vm claude" in the same directory will reuse the same VM.
131
132Every .git in the shared folders is read-only for the VMs (Lima's
133sshfs.readonlyNames, built into agent-vm). Every .hg is too, and so is the
134folder of each core.hooksPath in the project (.husky for husky).
135'agent-vm doctor' says where you stand.
136
137Before a VM boots with writable shares, agent-vm stops on what it cannot
138protect, and asks whether to go on (no by default, and when it cannot ask):
139hooks no read-only name covers (the top of a share or of a repository, or a
140writable volume), git config, commands it names, or hooks linked to files, in
141the project or a writable volume, and git ignoring
142safe.bareRepository=explicit (which it offers to set: git would otherwise use
143a folder with HEAD, objects/ and refs/ as a repository, under any name). It
144checks the repository holding each share and those at most two folders below
145it, 50 per share; deeper ones are not checked.
146A VM that already runs gets the warnings only,
147and a restart when it lacks a protection; once stopped to boot again, it is
148asked like any other.
149'agent-vm info' lists what a start would ask
150(security_questions=).
151--unsafe-writable-git, or AGENT_VM_UNSAFE_WRITABLE_GIT=1 in your shell, leaves
152.git writable anyway, so the agent can commit in the project; a warning is
153printed on every run. Changing it applies when the VM is next started.
154
155The writable shares are served without sshfs's cache, so the VM never writes
156back a file as it was before you changed it. AGENT_VM_SSHFS_CACHE=1 in your
157shell turns the cache on, faster on many files (git status, find), at that
158risk, for 20 seconds. It applies when a VM is next started.
159
160The VMs reach the internet, not this machine nor its local networks.
161~/.agent-vm/network (none by default) allows more, one line each:
162'allow 192.168.1.10:5432', 'allow 10.0.0.0/8', 'allow localhost:11434' (a
163service on this machine's loopback, at 192.168.5.2 in the VM; 'localhost'
164alone: every port). 'domain github.com' lines make those domains,
165subdomains included, the only names of the internet the VMs reach.
166AGENT_VM_UNSAFE_OPEN_NETWORK=1 in your shell turns isolation off. A port a
167VM listens on is forwarded to this machine's loopback, unless a program here
168uses it: a desktop notification says which (none with AGENT_VM_NOTIFY=0).
169Ports 32768-60999, those the guest hands out to whoever asks for any free
170one, are not forwarded.
171
172Before a VM writes a file this machine runs on its own (.envrc,
173.vscode/tasks.json, .pre-commit-config.yaml, mise.toml...), a dialog asks
174you; the write is refused where none can be shown, and always with
175AGENT_VM_GUARDED_WRITES=deny. ~/.agent-vm/guarded adds paths, one per line,
176and '!path' removes one. Both files are read when a VM starts.
177
178Customization:
179 ~/.agent-vm/env Shared env vars / tokens (dotenv-style;
180 pushed into every VM, loaded in its shells)
181 ~/.agent-vm/volumes Extra host paths to mount in VMs, one per
182 line, directories or files:
183 source[:destination][:ro|rw[:project]]
184 (ro by default; a relative destination is
185 in the project; project, after an explicit
186 mode, limits the entry to the projects it
187 matches, * as wildcard)
188 ~/.agent-vm/setup.sh Per-user setup (runs under zsh during
189 "agent-vm setup")
190 ~/.agent-vm/network What the VMs may reach (above)
191 ~/.agent-vm/guarded More files to ask about (above)
192 <project>/.agent-vm.env Per-project env (agent-vm project-env)
193 Override the path with AGENT_VM_PROJECT_ENV
194 ~/.agent-vm/runtime.sh Per-user runtime (runs on every command
195 that enters a VM)
196 <project>/.agent-vm.runtime.sh Per-project runtime (same, after the
197 per-user one)
198 Override the path with AGENT_VM_PROJECT_RUNTIME
199 (relative to the project, or absolute).
200 Runtimes run under the shell their shebang
201 names (bash, sh; zsh otherwise).
202
203More info: https://www.agent-vm.org/