跳到主要内容

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

提交记录
修改CHANGELOG.md+4 −2看文件
@@ -10,6 +10,10 @@
1010 or `dnf install ./agent-vm-X.Y.Z-1.aarch64.rpm`.
1111- A Nix flake (Linux): `nix run github:sylvinus/agent-vm`. QEMU comes with it,
1212 ssh is the system's.
13新增:- `agent-vm setup --preinstall=code-opencode`: the OpenCode extension
14新增: (`sst-dev.opencode`) in code-server (#37). Unlike the other extensions it
15新增: runs the `opencode` command, so `opencode` is installed with it, and its
16新增: config allows every tool, as `agent-vm opencode` does with `--auto`.
1317
1418### Fixed
1519
@@ -35,8 +39,6 @@
3539 backend (QEMU 7.2 or later): no stream, nothing to lose. An older QEMU keeps
3640 the former backend, and so does Windows (it has no unix datagram sockets).
3741
38删除:- `agent-vm setup`: Added `code-opencode` preinstall option to install the OpenCode VS Code extension (`sst-dev.opencode`) into code-server (#37).
39删除:
4042## 0.3.0
4143
4244agent-vm 0.3 is one Go binary with Lima built in. The
修改agent-vm.setup.sh+8 −0看文件
@@ -496,6 +496,14 @@ if [[ "$INSTALL_CODE_SERVER" == "1" ]]; then
496496 if [[ "$INSTALL_CODE_VIBE" == "1" ]]; then
497497 toml_prepend "$HOME/.vibe/config.toml" default_agent '"auto-approve"'
498498 fi
499新增: # OpenCode's extension runs `opencode` in a terminal, without the --auto of
500新增: # `agent-vm opencode`: its config allows everything instead.
501新增: if [[ "$INSTALL_CODE_OPENCODE" == "1" ]]; then
502新增: mkdir -p "$HOME/.config/opencode"
503新增: oc_config="$HOME/.config/opencode/opencode.json"
504新增: [ -f "$oc_config" ] || echo '{"$schema": "https://opencode.ai/config.json"}' > "$oc_config"
505新增: jq '.permission = "allow"' "$oc_config" > "$oc_config.tmp" && mv "$oc_config.tmp" "$oc_config"
506新增: fi
499507 # Written by code-server on its first run, with a password of its own.
500508 rm -rf "$HOME/.config/code-server"
501509fi
修改internal/cli/cli_test.go+2 −0看文件
@@ -88,6 +88,8 @@ func TestHelp(t *testing.T) {
8888 }
8989 strip := func(s string) string {
9090 s = strings.Replace(s, "agent-vm rm agent-vm-old-name-1a2b3c4d ", "agent-vm rm old-name-1a2b3c4d ", 1)
91新增: // code-opencode is new.
92新增: s = strings.Replace(s, "(or code-opencode, code-codex", "(or code-codex", 1)
9193 for _, cut := range []string{
9294 "AGENT_VM_BIN_DIR). Run it from the clone:\n ./agent-vm.sh install\n",
9395 "AGENT_VM_BIN_DIR)\n",
修改internal/cli/help.txt+1 −1看文件
@@ -21,7 +21,7 @@ Commands:
2121 address and the password, made in each VM, are
2222 printed: open it in your browser. Opt-in at setup, with the agents'
2323 extensions or without: --preinstall=default,code-claude
24删除: (or code-codex, code-vibe, code-server)
24新增: (or code-opencode, code-codex, code-vibe, code-server)
2525 stop [vm-name] Stop the VM for the current directory, or the named one
2626 rm [vm-name] Stop and delete the VM for the current directory, or the
2727 named one. Pass a name from 'agent-vm list' to reach a VM
修改internal/cli/setup.go+10 −10看文件
@@ -52,12 +52,13 @@ Options:
5252 code-opencode, code-codex, code-vibe
5353 'code-server' is VS Code in the browser, for
5454 'agent-vm code', with GitHub Copilot turned off.
55删除: 'code-claude', 'code-opencode', 'code-codex' and 'code-vibe' add that
56删除: agent's extension, and code-server with it. Each
57删除: extension brings its own copy of the agent: 'claude',
58删除: 'codex' and 'vibe' are the command-line ones, for
59删除: 'agent-vm claude' and the others (OpenCode's extension
60删除: requires its command-line tool, which is installed with it).
55新增: 'code-claude', 'code-opencode', 'code-codex' and
56新增: 'code-vibe' add that agent's extension, and code-server
57新增: with it. The Claude, Codex and Vibe extensions bring
58新增: their own copy of the agent: 'claude', 'codex' and
59新增: 'vibe' are the command-line ones, for 'agent-vm claude'
60新增: and the others. OpenCode's does not: 'code-opencode'
61新增: also installs 'opencode'.
6162 Selecting codex or pi also installs node (npm). So does
6263 mcp-chrome when chromium and an agent are selected
6364 (npx). mcp-playwright does not: list node yourself.
@@ -109,7 +110,7 @@ func (in install) nodeNeededBy() string {
109110 return "Codex CLI requires npm"
110111 case in["pi"]:
111112 return "Pi requires npm"
112删除: case in["chromium"] && in["mcp-chrome"] && (in["claude"] || in["opencode"] || in["vibe"] || in["code-claude"] || in["code-opencode"] || in["code-codex"] || in["code-vibe"]):
113新增: case in["chromium"] && in["mcp-chrome"] && (in["claude"] || in["opencode"] || in["vibe"] || in["code-claude"] || in["code-codex"] || in["code-vibe"]):
113114 return "Chrome DevTools MCP uses npx"
114115 }
115116 return ""
@@ -361,11 +362,10 @@ func (e *app) askCodeExtensions(in install) {
361362 return
362363 }
363364 fmt.Fprintf(e.io.Stderr, " %s in the editor:\n", strings.Join(names, ", "))
364删除: promptExtOnly := "Extension only"
365365 if in["opencode"] {
366删除: promptExtOnly = "Extension only (OpenCode keeps the CLI, required by its extension)"
366新增: fmt.Fprintln(e.io.Stderr, " (OpenCode's extension needs its command line: it stays installed.)")
367367 }
368删除: choice := e.ui.AskChoice("Pick one", 1, "Extension and command line (agent-vm claude...)", promptExtOnly, "Command line only")
368新增: choice := e.ui.AskChoice("Pick one", 1, "Extension and command line (agent-vm claude...)", "Extension only", "Command line only")
369369 if choice == 3 {
370370 return
371371 }
修改internal/cli/setup_test.go+3 −5看文件
@@ -70,7 +70,6 @@ func on(m map[string]string) string {
7070 return strings.Join(out, ",")
7171}
7272
73删除:// TestSetupPreinstall verifies --preinstall flag combinations.
7473func TestSetupPreinstall(t *testing.T) {
7574 for _, c := range []struct {
7675 args []string
@@ -134,7 +133,6 @@ func wizardRun(t *testing.T, answers ...string) (*testEnv, []string) {
134133 return te, stdin
135134}
136135
137删除:// TestSetupWizard verifies interactive setup wizard choices and defaults.
138136func TestSetupWizard(t *testing.T) {
139137 // Enter everywhere: the default set and resources.
140138 te, stdin := wizardRun(t)
@@ -170,7 +168,7 @@ func TestSetupWizard(t *testing.T) {
170168
171169 // OpenCode as extension only (keeps the required OpenCode CLI)
172170 te, stdin = wizardRun(t,
173删除: "n", // the default set
171新增: "n", // the default set
174172 "n", "y", "n", "n", "", // Claude, OpenCode, Codex, Vibe, Pi
175173 "y", "2", // code-server, extension only
176174 "n", "n", "n", // Docker, Chromium, gh
@@ -180,8 +178,8 @@ func TestSetupWizard(t *testing.T) {
180178 if got := on(exportsOf(t, stdin)); got != "opencode,code-server,code-opencode" {
181179 t.Errorf("opencode extension: %s", got)
182180 }
183删除: if !strings.Contains(te.out(), "Extension only (OpenCode keeps the CLI, required by its extension)") {
184删除: t.Errorf("prompt not shown: %s", te.out())
181新增: if !strings.Contains(te.out(), "OpenCode's extension needs its command line: it stays installed.") {
182新增: t.Errorf("note not shown: %s", te.out())
185183 }
186184}
187185
修改tests/setup-script.sh+20 −1看文件
@@ -110,7 +110,6 @@ check "sshfs wrapper: an older sshfs gets the arguments unchanged" \
110110# config (managed settings, MCP servers) is written. The lines setup derives
111111# it with, run as setup does.
112112has_block="$(awk '/^HAS_CLAUDE=0 HAS_OPENCODE=0 HAS_CODEX=0 HAS_VIBE=0$/,/HAS_VIBE=1$/' "$SETUP_SH")"
113删除:# has derives the HAS_* flags for the given set of agent install flags.
114113# shellcheck disable=SC2034 # read by the eval'd block
115114has() { ( INSTALL_CLAUDE="$1" INSTALL_CODE_CLAUDE="$2" INSTALL_OPENCODE="$3" INSTALL_CODE_OPENCODE="$4" INSTALL_CODEX="$5" INSTALL_CODE_CODEX="$6" INSTALL_VIBE="$7" INSTALL_CODE_VIBE="$8"
116115 eval "$has_block"; echo "$HAS_CLAUDE$HAS_OPENCODE$HAS_CODEX$HAS_VIBE" ); }
@@ -179,6 +178,23 @@ else
179178 check "pi: skipped without node" "$( [ -e "$PIH0/sudo.log" ] || [ -e "$PIH0/.pi" ]; echo $?)" "1"
180179fi
181180
181新增:# =============================================================================
182新增:section "OpenCode install block"
183新增:# =============================================================================
184新增:# The extension needs the command line: either flag installs it.
185新增:oc_block="$(awk '/^if \[\[ "\$INSTALL_OPENCODE" == "1" \|\| "\$INSTALL_CODE_OPENCODE" == "1" \]\]; then/,/^fi$/' "$SETUP_SH")"
186新增:# shellcheck disable=SC2034 # read by the eval'd block
187新增:run_oc_block() {
188新增: ( HOME="$SB/oc-home"; mkdir -p "$HOME"; rm -f "$HOME/curl.log"
189新增: INSTALL_OPENCODE="$1" INSTALL_CODE_OPENCODE="$2"
190新增: curl() { echo "curl $*" >> "$HOME/curl.log"; }
191新增: eval "$oc_block" ) >/dev/null 2>&1
192新增: cat "$SB/oc-home/curl.log" 2>/dev/null
193新增:}
194新增:check "opencode: installed for the command line" "$(run_oc_block 1 0)" "curl -fsSL https://opencode.ai/install"
195新增:check "opencode: installed for the extension alone" "$(run_oc_block 0 1)" "curl -fsSL https://opencode.ai/install"
196新增:check "opencode: not installed for neither" "$(run_oc_block 0 0)" ""
197新增:
182198# =============================================================================
183199section "code-server JSON schemas"
184200# =============================================================================
@@ -322,6 +338,9 @@ $(awk '/^configure_mcp\(\) \{/,/^\}/' "$SETUP_SH")"
322338 check "vibe: auto-approve, once, before any table" \
323339 "$(head -n 1 "$CSA/.vibe/config.toml"; grep -c '^default_agent' "$CSA/.vibe/config.toml")" \
324340 "$(printf 'default_agent = "auto-approve"\n1')"
341新增: check "opencode: everything allowed, next to the MCP server, written twice" \
342新增: "$(jq -r '[.permission, (.mcp | keys | join(","))] | join(" ")' "$CSA/.config/opencode/opencode.json")" "allow chrome-devtools"
343新增: check "code-server alone: no OpenCode config" "$([ -e "$CSB/.config/opencode" ]; echo $?)" "1"
325344 if python3 -c 'import tomllib' 2>/dev/null; then
326345 check "codex: the file parses, keys at the top level" \
327346 "$(python3 -c 'import sys,tomllib; d=tomllib.load(open(sys.argv[1],"rb")); print(d["approval_policy"], "chrome-devtools" in d["mcp_servers"])' "$CSA/.codex/config.toml")" \
修改www/src/i18n/en.ts+1 −1看文件
@@ -686,7 +686,7 @@ export const en = {
686686 contentsCode:
687687 'agent-vm setup --preinstall=default # no prompts\nagent-vm setup --preinstall=default,rust # plus Rust\nagent-vm setup --preinstall=python,docker,claude # minimal Claude setup\nagent-vm setup --preinstall=default,code-claude # plus the editor\nagent-vm setup --disk 50 --memory 16 --cpus 8 # a bigger template',
688688 contentsNote:
689删除: '`codex` and `pi` pull in `node`, and so does `mcp-chrome` with `chromium` and an agent. Both MCP servers are skipped without `node` and `chromium`. Each editor extension ships its own copy of its agent (200 to 600 MB): the wizard asks whether to keep the command-line one too (OpenCode’s extension requires the CLI, which is always installed with it). Without it, `agent-vm claude` says it is not installed. This is only what the template ships: the agent is root in the VM and reaches the internet, so it installs whatever else it needs.',
689新增: '`codex` and `pi` pull in `node`, and so does `mcp-chrome` with `chromium` and an agent. Both MCP servers are skipped without `node` and `chromium`. The Claude, Codex and Mistral Vibe extensions ship their own copy of their agent (200 to 600 MB): the wizard asks whether to keep the command-line one too. Without it, `agent-vm claude` says it is not installed. OpenCode’s extension does not: it runs the `opencode` command, so `code-opencode` always installs it. This is only what the template ships: the agent is root in the VM and reaches the internet, so it installs whatever else it needs.',
690690 dockerTitle: 'Why not Docker',
691691 dockerLede:
692692 'On Linux, containers share the host kernel, so a compromised dependency that finds a kernel bug is on your host. On macOS, Docker Desktop already runs a VM, which narrows the gap, but it is one VM shared by every container rather than one per project. A VM brings its own kernel, and root inside it still has the hypervisor between it and your machine. The practical differences matter as much as the security one.',
修改www/src/i18n/fr.ts+1 −1看文件
@@ -688,7 +688,7 @@ export const fr: Dictionary = {
688688 contentsCode:
689689 'agent-vm setup --preinstall=default # sans question\nagent-vm setup --preinstall=default,rust # avec Rust en plus\nagent-vm setup --preinstall=python,docker,claude # Claude seul, minimal\nagent-vm setup --preinstall=default,code-claude # avec l\'éditeur\nagent-vm setup --disk 50 --memory 16 --cpus 8 # une image plus grosse',
690690 contentsNote:
691删除: '`codex` et `pi` entraînent `node`, tout comme `mcp-chrome` avec `chromium` et un agent. Les deux serveurs MCP sont ignorés sans `node` et `chromium`. Chaque extension de l\'éditeur apporte sa propre copie de son agent (200 à 600 Mo) : l\'assistant demande s\'il faut garder aussi celle en ligne de commande (l\'extension d\'OpenCode nécessite l\'outil en ligne de commande, qui est toujours installé avec elle). Sans elle, `agent-vm claude` dit qu\'il n\'est pas installé. Ce n\'est que ce que l\'image contient au départ : l\'agent est root dans la VM et atteint Internet, il installe lui-même ce qui lui manque.',
691新增: '`codex` et `pi` entraînent `node`, tout comme `mcp-chrome` avec `chromium` et un agent. Les deux serveurs MCP sont ignorés sans `node` et `chromium`. Les extensions Claude, Codex et Mistral Vibe apportent leur propre copie de leur agent (200 à 600 Mo) : l\'assistant demande s\'il faut garder aussi celle en ligne de commande. Sans elle, `agent-vm claude` dit qu\'il n\'est pas installé. Celle d\'OpenCode non : elle lance la commande `opencode`, donc `code-opencode` l\'installe toujours. Ce n\'est que ce que l\'image contient au départ : l\'agent est root dans la VM et atteint Internet, il installe lui-même ce qui lui manque.',
692692 dockerTitle: 'Pourquoi pas Docker',
693693 dockerLede:
694694 'Sous Linux, les conteneurs partagent le noyau de l\'hôte : une dépendance compromise qui trouve une faille dans le noyau se retrouve sur ta machine. Sous macOS, Docker Desktop fait déjà tourner une VM, ce qui réduit l\'écart, mais c\'est une seule VM partagée par tous tes conteneurs, pas une par projet. Une VM a son propre noyau, et root dans la VM a encore l\'hyperviseur entre lui et ton poste. Les différences pratiques comptent autant que celle-ci.',