提交记录修改README.md+2 −2看文件
修改agent-vm.setup.sh+20 −0看文件
修改agent-vm.sh+4 −3看文件
| @@ -71,8 +71,8 @@ agent-vm vibe # Mistral Vibe | ||
| 71 | 71 | Creates a persistent VM for the current directory (or reuses it if one already exists), mounts your working directory, and runs the agent with full permissions. The VM persists after the agent exits so you can reconnect later. Ports opened inside the VM (e.g. by Docker containers or dev servers) are automatically forwarded to your host by Lima. |
| 72 | 72 | |
| 73 | 73 | Each agent runs with its respective auto-approve flag: |
| 74 | 删除:- `claude` runs with `--dangerously-skip-permissions` | |
| 75 | 删除:- `opencode` does not yet have an auto-approve flag (waiting on [this PR](https://github.com/anomalyco/opencode/pull/11833)) | |
| 74 | 新增:- `claude` runs with `--dangerously-skip-permissions`, and the VM also enforces bypass mode via managed settings (`/etc/claude-code/managed-settings.json`) so autonomy survives Claude Code's self-update/fullscreen relaunches — which otherwise drop the CLI flag ([#72479](https://github.com/anthropics/claude-code/issues/72479)) | |
| 75 | 新增:- `opencode` runs with `--auto` (auto-approves permission prompts that aren't explicitly denied) | |
| 76 | 76 | - `codex` runs with `--dangerously-bypass-approvals-and-sandbox` |
| 77 | 77 | - `vibe` runs with `--agent auto-approve` |
| 78 | 78 | |
| @@ -144,6 +144,26 @@ if [[ "$INSTALL_CLAUDE" == "1" ]]; then | ||
| 144 | 144 | curl -fsSL https://claude.ai/install.sh | bash |
| 145 | 145 | echo 'export PATH=$HOME/.claude/local/bin:$PATH' >> ~/.zshrc |
| 146 | 146 | echo 'export PATH=$HOME/.claude/local/bin:$PATH' >> ~/.zshenv |
| 147 | 新增: | |
| 148 | 新增: # Enforce full autonomy via *managed* settings (highest precedence), not the | |
| 149 | 新增: # user's ~/.claude/. A user can bind-mount or overwrite their own ~/.claude/ | |
| 150 | 新增: # dir freely; this system-level policy is untouched and always wins. | |
| 151 | 新增: # | |
| 152 | 新增: # Why not just rely on the `claude --dangerously-skip-permissions` launch flag: | |
| 153 | 新增: # Claude Code relaunches itself in-process on self-update and on the first-run | |
| 154 | 新增: # fullscreen-TUI opt-in, and the relaunched process drops the CLI flag (see | |
| 155 | 新增: # https://github.com/anthropics/claude-code/issues/72479), reverting to the | |
| 156 | 新增: # "ask" permission mode. Settings are re-read on every (re)launch, so encoding | |
| 157 | 新增: # the policy here makes it survive those relaunches. `tui: fullscreen` also | |
| 158 | 新增: # pins fullscreen from the first launch, so the opt-in relaunch never fires. | |
| 159 | 新增: echo "Configuring Claude managed settings (bypass permissions + fullscreen)..." | |
| 160 | 新增: sudo mkdir -p /etc/claude-code | |
| 161 | 新增: cat << 'JSON' | sudo tee /etc/claude-code/managed-settings.json > /dev/null | |
| 162 | 新增:{ | |
| 163 | 新增: "permissions": { "defaultMode": "bypassPermissions" }, | |
| 164 | 新增: "tui": "fullscreen" | |
| 165 | 新增:} | |
| 166 | 新增:JSON | |
| 147 | 167 | fi |
| 148 | 168 | |
| 149 | 169 | if [[ "$INSTALL_OPENCODE" == "1" ]]; then |
| @@ -1160,10 +1160,11 @@ _agent_vm_opencode() { | ||
| 1160 | 1160 | _agent_vm_ensure_running "$vm_name" "$host_dir" "${vm_opts[@]}" || return 1 |
| 1161 | 1161 | _agent_vm_print_resources "$vm_name" |
| 1162 | 1162 | |
| 1163 | 删除: # TODO: add --dangerously-skip-permissions once released | |
| 1164 | 删除: # (waiting on https://github.com/anomalyco/opencode/pull/11833) | |
| 1163 | 新增: # --auto auto-approves permission prompts that aren't explicitly denied, | |
| 1164 | 新增: # giving full autonomy (safe inside the sandbox). This is OpenCode's shipped | |
| 1165 | 新增: # equivalent of a "yolo" mode; the proposed --yolo flag was never merged. | |
| 1165 | 1166 | local exit_code=0 |
| 1166 | 删除: limactl shell --tty --workdir "$host_dir" "$vm_name" opencode "${args[@]}" | |
| 1167 | 新增: limactl shell --tty --workdir "$host_dir" "$vm_name" opencode --auto "${args[@]}" | |
| 1167 | 1168 | exit_code=$? |
| 1168 | 1169 | [[ -n "$rm" ]] && { echo "Removing VM..."; _agent_vm_destroy; } |
| 1169 | 1170 | return $exit_code |

