跳到主要内容

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

提交记录
修改agent-vm.setup.sh+2 −1看文件
@@ -404,7 +404,8 @@ code_server_schemas() {
404404 continue
405405 fi
406406 cat "$f.entry" >> "$dir/entries"
407删除: base="$(jq -r '(."$id" // .id // empty) | strings | select(test("^https?://"))' "$f")"
407新增: # A schema may be true or false, which has no $id to read.
408新增: base="$(jq -r 'objects | (."$id" // .id // empty) | strings | select(test("^https?://"))' "$f")"
408409 [[ -n "$base" ]] || base="$u"
409410 while IFS= read -r r; do
410411 r="$(schema_url_resolve "$base" "$r")" && next+=("$r")
修改lib/git.sh+10 −10看文件
@@ -313,23 +313,23 @@ _agent_vm_scan_risk() {
313313}
314314
315315# The risk lines of the config of the repository <at> of kind <kind>, whose
316删除:# work tree is <top> (see _agent_vm_git_at): its own config, or git's global
317删除:# and system config for G. Config files in a share, included ones whether
318删除:# they exist yet or not (git skips a missing one, and the VM can create it).
319删除:# Settings whose command a share holds: a path in their value, relative to
320删除:# the top of the repository, where git runs most of them (git's own config
321删除:# has none to take them from). awk sorts the config first, so the shell only
316新增:# work tree is <top> (see _agent_vm_git_at): every scope git reads there
317新增:# (system, global, local, worktree), or git's global and system config alone
318新增:# for G. Config files in a share, included ones whether they exist yet or not
319新增:# (git skips a missing one, and the VM can create it). Settings whose command
320新增:# a share holds: a path in their value, relative to the top of the
321新增:# repository, where git runs most of them, a global alias included (G has no
322新增:# repository to take them from). awk sorts the config first, so the shell only
322323# sees each file once and the settings that hold a command (section and key
323324# names lowercased, as `git config --list` prints them) with a path in their
324325# value: a start runs this, and a fork per line would show.
325326_agent_vm_scan_config() {
326删除: local kind="$1" at="$2" cmd_base="$3" base=/ scope=--local k a b c w shown
327新增: local kind="$1" at="$2" cmd_base="$3" base=/ k a b c w shown
327328 case "$kind" in
328329 W) base="$(_agent_vm_git_spelling "$at")" || return 0 ;;
329330 B) cmd_base="$at" ;;
330删除: *) scope="" ;;
331331 esac
332删除: _agent_vm_git_at "$kind" "$at" config --list ${scope:+"$scope"} --show-origin --includes 2>/dev/null \
332新增: _agent_vm_git_at "$kind" "$at" config --list --show-origin --includes 2>/dev/null \
333333 | awk -F '\t' '
334334 {
335335 origin = $1; kv = substr($0, length($1) + 2); f = ""
@@ -593,7 +593,7 @@ _agent_vm_sha256_sums_check() {
593593 echo "Error: no checksum listed for $f." >&2
594594 return 1
595595 fi
596删除: actual="$(_agent_vm_sha256 < "$dir/$f" 2>/dev/null | cut -d' ' -f1)"
596新增: actual="$( { _agent_vm_sha256 < "$dir/$f"; } 2>/dev/null | cut -d' ' -f1)"
597597 if [[ -z "$actual" || "$actual" != "$expected" ]]; then
598598 echo "Error: checksum mismatch for $f (expected $expected, got ${actual:-unreadable})." >&2
599599 return 1
修改lib/mounts.sh+2 −2看文件
@@ -438,7 +438,7 @@ _agent_vm_protection_why() {
438438_agent_vm_hostagent_is_limactl() {
439439 local pid="" exe="" run="" mine
440440 _agent_vm_on_windows && return 0
441删除: read -r pid < "$(_agent_vm_lima_home)/$1/ha.pid" 2>/dev/null
441新增: { read -r pid < "$(_agent_vm_lima_home)/$1/ha.pid"; } 2>/dev/null
442442 [[ "$pid" =~ ^[0-9]+$ ]] || return 0
443443 if [[ -e "/proc/$pid/exe" ]]; then
444444 exe="$(readlink "/proc/$pid/exe" 2>/dev/null)"
@@ -468,7 +468,7 @@ _agent_vm_sshfs_cache_mode() {
468468# by _agent_vm_apply_shares).
469469_agent_vm_mounts_sshfs_current() {
470470 local mode=""
471删除: read -r mode < "$AGENT_VM_STATE_DIR/.agent-vm-sshfs-cache-$1" 2>/dev/null
471新增: { read -r mode < "$AGENT_VM_STATE_DIR/.agent-vm-sshfs-cache-$1"; } 2>/dev/null
472472 [[ "$mode" == "$(_agent_vm_sshfs_cache_mode)" ]]
473473}
474474
修改tests/06-help-and-setup-script.sh+4 −2看文件
@@ -240,7 +240,9 @@ else
240240 # a: an absolute ref, a relative one with ./ and a fragment, a local one,
241241 # and one to the editor's own schemas.
242242 echo '{"$ref":"#/definitions/x","definitions":{"x":{"$ref":"https://h.test/abs.json"},"y":{"$ref":"./rel.json#/z"},"z":{"$ref":"vscode://schemas/settings"},"w":{"properties":{"$ref":{"type":"string"}}}}}' > "$SCH/web/$(web https://h.test/s/a)"
243删除: echo '{"type":"object"}' > "$SCH/web/$(web https://h.test/abs.json)"
243新增: # abs refers to a schema that is no object: true is a valid schema.
244新增: echo '{"type":"object","properties":{"t":{"$ref":"https://h.test/true.json"}}}' > "$SCH/web/$(web https://h.test/abs.json)"
245新增: echo 'true' > "$SCH/web/$(web https://h.test/true.json)"
244246 echo '{"$ref":"../top.json"}' > "$SCH/web/$(web https://h.test/s/rel.json)"
245247 echo '{"type":"string"}' > "$SCH/web/$(web https://h.test/top.json)"
246248 echo '{"type":"number"}' > "$SCH/web/$(web https://www.schemastore.org/b)"
@@ -273,7 +275,7 @@ else
273275 code_server_schemas "$SCH/ext" "$SCH/machine/settings.json"; echo "rc=$?" ) 2>&1)"
274276 check "every schema named, and every one they refer to, by the URL the editor asks" \
275277 "$(jq -r '."json.schemas"[].url' "$SCH/machine/settings.json" 2>/dev/null | sort | tr '\n' ' ')" \
276删除: "https://h.test/abs.json https://h.test/s/a https://h.test/s/a/b/d.json https://h.test/s/c.json https://h.test/s/rel.json https://h.test/top.json https://json.schemastore.org/b https://json.schemastore.org/eslintrc.json https://www.schemastore.org/package "
278新增: "https://h.test/abs.json https://h.test/s/a https://h.test/s/a/b/d.json https://h.test/s/c.json https://h.test/s/rel.json https://h.test/top.json https://h.test/true.json https://json.schemastore.org/b https://json.schemastore.org/eslintrc.json https://www.schemastore.org/package "
277279 check "a level of references fetched in one call" "$(wc -l < "$SCH/calls" | tr -d ' ')" "3"
278280 check "each with its content" \
279281 "$(jq -r '."json.schemas"[] | select(.url == "https://h.test/top.json") | .schema.type' "$SCH/machine/settings.json" 2>/dev/null)" "string"
修改tests/14-git-protection.sh+16 −5看文件
@@ -344,7 +344,7 @@ rm -f "$CACHE_MODE"
344344out="$(rec run true)"
345345rec_has "edit $PV" && fail "cache: a running VM was changed" || pass "cache: a running VM is left as it is"
346346rec_has "stop $PV" && fail "cache: a running VM was stopped" || pass "cache: and not stopped"
347删除:case "$out" in *Warning*) fail "cache: a running VM warned about: $out" ;; *) pass "cache: and nothing said" ;; esac
347新增:case "$out" in *Warning*|*"No such file"*) fail "cache: a running VM warned about: $out" ;; *) pass "cache: and nothing said" ;; esac
348348AGENT_VM_TEST_STOPPED=1 rec run true >/dev/null
349349rec_has "edit $PV --set .mountType = \"reverse-sshfs\" | .mounts = [{$(mnt "$PROJ"), \"writable\": true, $SSHFS_RO}]" \
350350 && pass "cache: a stopped VM gets its shares with the cache off" || fail "cache: not updated: $(grep '^edit' "$REC")"
@@ -433,7 +433,7 @@ else
433433 fi
434434 rm -f "$(_agent_vm_lima_home)/$PV/ha.pid" "$(_agent_vm_lima_home)/$PV/lima.yaml"
435435 out="$(rec run true)"
436删除: case "$out" in *"another limactl"*) fail "hostagent: no pid file, warned anyway" ;; *) pass "hostagent: when it cannot tell, nothing is said" ;; esac
436新增: case "$out" in *"another limactl"*|*"No such file"*) fail "hostagent: no pid file, warned anyway: $out" ;; *) pass "hostagent: when it cannot tell, nothing is said" ;; esac
437437fi
438438
439439# core.hooksPath in the project: its first component joins the names.
@@ -493,10 +493,10 @@ if command -v git >/dev/null 2>&1; then
493493 ( _agent_vm_fs_nocase() { return 1; }; _agent_vm_rel_in /Work/Proj/x /work/proj ) >/dev/null \
494494 && fail "a path in other capitals counted as inside where case matters" \
495495 || pass "and not where case matters"
496删除: # The same through a whole scan.
497删除: hp "$(printf '%s' "$PROJ" | tr '[:lower:]' '[:upper:]')/.husky/_"
496新增: # The same through a whole scan, as macOS (Windows ignores case already).
497新增: hp "$(_agent_vm_git_spelling "$PROJ" | tr '[:lower:]' '[:upper:]')/.husky/_"
498498 check "hooks: a hooks path in other capitals is named, where case is ignored" \
499删除: "$( uname() { echo Darwin; }; names )" '[".git", ".hg", ".husky"]'
499新增: "$( if ! _agent_vm_on_windows; then uname() { echo Darwin; }; fi; names )" '[".git", ".hg", ".husky"]'
500500 hp .husky/_
501501
502502 # A repository below the project has hooks of its own.
@@ -726,6 +726,17 @@ if command -v git >/dev/null 2>&1; then
726726 ( git -C "$PROJ" config --unset-all includeIf.gitdir:/.path
727727 git -C "$PROJ" config --unset-all include.path
728728 git -C "$PROJ" config include.path ../.gitconfig )
729新增: # The other scopes git reads in the repository: a global alias run from the
730新增: # top of the project, and the worktree's config.
731新增: ( git config --global alias.g '!./g.sh'
732新增: git -C "$PROJ" config extensions.worktreeConfig true
733新增: git -C "$PROJ" config --worktree core.editor ./ed.sh )
734新增: risks="$(_agent_vm_share_config_risks "$PROJ")"
735新增: case "$risks" in *"alias.g = !./g.sh"*) pass "config: a global alias naming a file of the project" ;; *) fail "config: global: $risks" ;; esac
736新增: case "$risks" in *"core.editor = ./ed.sh"*) pass "config: the worktree's config" ;; *) fail "config: worktree: $risks" ;; esac
737新增: ( git config --global --unset alias.g
738新增: git -C "$PROJ" config --worktree --unset core.editor
739新增: git -C "$PROJ" config --unset extensions.worktreeConfig )
729740 names_rec '[".git", ".hg"]'
730741 out="$( unset AGENT_VM_UNSAFE_DISABLE_SECURITY_PROMPTS; _agent_vm_can_ask() { return 1; }; AGENT_VM_TEST_STOPPED=1 rec run true )"
731742 case "$out" in *"git on this machine uses these"*".gitconfig"*"Aborted."*) pass "config: a start stops on it" ;; *) fail "config: start: $out" ;; esac
修改tests/18-windows.sh+3 −0看文件
@@ -369,3 +369,6 @@ if _agent_vm_sha256_sums_check "$(sums)" "$SB/sums" missing.zip >/dev/null 2>&1;
369369else
370370 pass "an unlisted file is refused"
371371fi
372新增:rm "$SB/sums/c.zip"
373新增:check "a listed file missing: agent-vm's error only" \
374新增: "$(_agent_vm_sha256_sums_check "$(sums)" "$SB/sums" c.zip 2>&1 | grep -c 'No such file')" "0"