跳到主要内容

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

提交记录
修改agent-vm.sh+18 −2看文件
@@ -63,7 +63,7 @@ _agent_vm_ensure_running() {
6363 local vm_name="$1"
6464 local host_dir="$2"
6565 shift 2
66删除: local disk="" memory="" cpus="" reset="" offline="" rdonly=""
66新增: local disk="" memory="" cpus="" reset="" offline="" rdonly="" git_ro=""
6767 while [[ $# -gt 0 ]]; do
6868 case "$1" in
6969 --disk) disk="$2"; shift 2 ;;
@@ -72,6 +72,7 @@ _agent_vm_ensure_running() {
7272 --reset) reset=1; shift ;;
7373 --offline) offline=1; shift ;;
7474 --readonly) rdonly=1; shift ;;
75新增: --git-read-only|--git-ro) git_ro=1; shift ;;
7576 *) shift ;;
7677 esac
7778 done
@@ -183,6 +184,12 @@ _agent_vm_ensure_running() {
183184 echo "Mounting project directory as read-only..."
184185 limactl shell "$vm_name" sudo mount -o remount,ro "$host_dir"
185186 fi
187新增:
188新增: if [[ -n "$git_ro" ]] && [[ -d "$host_dir/.git" ]]; then
189新增: echo "Mounting .git directory as read-only..."
190新增: limactl shell "$vm_name" sudo mount --bind "$host_dir/.git" "$host_dir/.git"
191新增: limactl shell "$vm_name" sudo mount -o remount,ro,bind "$host_dir/.git"
192新增: fi
186193}
187194
188195agent-vm() {
@@ -208,6 +215,8 @@ agent-vm() {
208215 vm_opts+=(--offline); shift ;;
209216 --readonly)
210217 vm_opts+=(--readonly); shift ;;
218新增: --git-read-only|--git-ro)
219新增: vm_opts+=(--git-read-only); shift ;;
211220 --rm)
212221 vm_opts+=(--rm); shift ;;
213222 *)
@@ -288,6 +297,7 @@ VM options (for claude, opencode, codex, shell, run):
288297 --reset Destroy and re-clone the VM from the base template
289298 --offline Block outbound internet (keeps host/VM communication)
290299 --readonly Mount the project directory as read-only
300新增: --git-read-only Mount .git directory as read-only (allows git diff/log but not commit/stash)
291301 --rm Automatically destroy the VM after the command exits
292302
293303Examples:
@@ -300,6 +310,7 @@ Examples:
300310 agent-vm --rm claude # Destroy VM after Claude exits
301311 agent-vm --offline claude # No internet access
302312 agent-vm --readonly shell # Read-only project mount
313新增: agent-vm --git-ro claude # Protect .git from writes
303314 agent-vm shell # Shell into the VM
304315 agent-vm run npm install # Run a command in the VM
305316 agent-vm claude -p "fix lint errors" # Pass args to claude
@@ -359,7 +370,7 @@ _agent_vm_setup() {
359370 cpus="${1#*=}"
360371 shift
361372 ;;
362删除: --reset|--offline|--readonly)
373新增: --reset|--offline|--readonly|--git-read-only|--git-ro)
363374 shift ;;
364375 *)
365376 echo "Unknown option: $1" >&2
@@ -431,6 +442,7 @@ _agent_vm_claude() {
431442 --reset) vm_opts+=(--reset); shift ;;
432443 --offline) vm_opts+=(--offline); shift ;;
433444 --readonly) vm_opts+=(--readonly); shift ;;
445新增: --git-read-only|--git-ro) vm_opts+=(--git-read-only); shift ;;
434446 --rm) rm=1; shift ;;
435447 *) args+=("$1"); shift ;;
436448 esac
@@ -462,6 +474,7 @@ _agent_vm_opencode() {
462474 --reset) vm_opts+=(--reset); shift ;;
463475 --offline) vm_opts+=(--offline); shift ;;
464476 --readonly) vm_opts+=(--readonly); shift ;;
477新增: --git-read-only|--git-ro) vm_opts+=(--git-read-only); shift ;;
465478 --rm) rm=1; shift ;;
466479 *) args+=("$1"); shift ;;
467480 esac
@@ -495,6 +508,7 @@ _agent_vm_codex() {
495508 --reset) vm_opts+=(--reset); shift ;;
496509 --offline) vm_opts+=(--offline); shift ;;
497510 --readonly) vm_opts+=(--readonly); shift ;;
511新增: --git-read-only|--git-ro) vm_opts+=(--git-read-only); shift ;;
498512 --rm) rm=1; shift ;;
499513 *) args+=("$1"); shift ;;
500514 esac
@@ -525,6 +539,7 @@ _agent_vm_shell() {
525539 --reset) vm_opts+=(--reset); shift ;;
526540 --offline) vm_opts+=(--offline); shift ;;
527541 --readonly) vm_opts+=(--readonly); shift ;;
542新增: --git-read-only|--git-ro) vm_opts+=(--git-read-only); shift ;;
528543 --rm) rm=1; shift ;;
529544 *) shift ;;
530545 esac
@@ -562,6 +577,7 @@ _agent_vm_run() {
562577 --reset) vm_opts+=(--reset); shift ;;
563578 --offline) vm_opts+=(--offline); shift ;;
564579 --readonly) vm_opts+=(--readonly); shift ;;
580新增: --git-read-only|--git-ro) vm_opts+=(--git-read-only); shift ;;
565581 --rm) rm=1; shift ;;
566582 *) args+=("$1"); shift ;;
567583 esac