跳到主要内容

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

提交记录
修改scripts/bundle-qemu-sources.sh+8 −2看文件
@@ -6,7 +6,7 @@ runtime=$(cygpath -u "$2")
66archive=$(cygpath -u "$3")
77node_command=${CAGE_NODE:-node}
88if [[ -n ${CAGE_NODE:-} ]]; then node_command=$(cygpath -u "$CAGE_NODE"); fi
9删除:for tool in "$node_command" git curl tar sha256sum find sort xargs pacman-key mkdir mktemp cp mv rm grep; do
9新增:for tool in "$node_command" git curl tar sha256sum find sort xargs pacman-key pacman-conf mkdir mktemp cp mv rm grep; do
1010 command -v "$tool" >/dev/null 2>&1 || { echo "Missing source-collection tool: $tool" >&2; exit 1; }
1111done
1212commit=$("$node_command" -p "JSON.parse(require('fs').readFileSync(process.argv[1])).qemuSource.commit" "$repository/packaging/windows/dependencies.json")
@@ -15,6 +15,12 @@ source_repository=$("$node_command" -p "JSON.parse(require('fs').readFileSync(pr
1515stage=$(mktemp -d)
1616trap 'rm -rf "$stage"' EXIT
1717mkdir -p "$stage/source/packages" "$stage/source/cage"
18新增:# pacman-key requires lock-never for verification. Keep the installed public
19新增:# keys and trust database intact; only the private verification copy gets it.
20新增:installed_keyring=$(pacman-conf gpgdir)
21新增:mkdir -p "$stage/keyring"
22新增:cp "$installed_keyring/pubring.gpg" "$installed_keyring/trustdb.gpg" "$stage/keyring/"
23新增:printf 'lock-never\n' > "$stage/keyring/gpg.conf"
1824git -c core.autocrlf=false init -q "$stage/source/qemu"
1925git -C "$stage/source/qemu" fetch --depth=1 "$source_repository" "$commit"
2026git -c core.autocrlf=false -C "$stage/source/qemu" checkout -q --detach FETCH_HEAD
@@ -48,7 +54,7 @@ while read -r base version; do
4854 url="https://repo.msys2.org/mingw/sources/$name"
4955 if curl --fail --location --retry 2 -o "$stage/source/packages/$name" "$url"; then
5056 curl --fail --location --retry 3 -o "$stage/source/packages/$name.sig" "$url.sig"
51删除: pacman-key --verify "$stage/source/packages/$name.sig" "$stage/source/packages/$name"
57新增: pacman-key --gpgdir "$stage/keyring" --verify "$stage/source/packages/$name.sig" "$stage/source/packages/$name"
5258 found=true
5359 break
5460 fi
修改scripts/bundle-qemu-sources.test.mjs+8 −5看文件
@@ -1,7 +1,7 @@
11import assert from 'node:assert/strict';
22import {execFileSync} from 'node:child_process';
33import {createHash} from 'node:crypto';
4删除:import {chmod,mkdir,mkdtemp,readFile,rm,writeFile} from 'node:fs/promises';
4新增:import {chmod,mkdir,mkdtemp,readFile,readdir,rm,writeFile} from 'node:fs/promises';
55import {tmpdir} from 'node:os';
66import {join} from 'node:path';
77import {fileURLToPath} from 'node:url';
@@ -9,8 +9,9 @@ import test from 'node:test';
99const collector=fileURLToPath(new URL('./bundle-qemu-sources.sh',import.meta.url));
1010test('source collector includes pinned firmware and authenticated package sources with a complete manifest',async t=>{
1111 const root=await mkdtemp(join(tmpdir(),'cage-qemu-source-test-'));t.after(()=>rm(root,{recursive:true,force:true}));
12删除: const repository=join(root,'repository'),runtime=join(root,'runtime'),bin=join(root,'bin'),artifact=join(root,'bundle.tar.gz');
13删除: for(const path of [bin,runtime,join(repository,'packaging/windows'),join(repository,'scripts'),join(repository,'patches/qemu')])await mkdir(path,{recursive:true});
12新增: const repository=join(root,'repository'),runtime=join(root,'runtime'),bin=join(root,'bin'),artifact=join(root,'bundle.tar.gz'),keyring=join(root,'installed-keyring');
13新增: for(const path of [bin,runtime,keyring,join(repository,'packaging/windows'),join(repository,'scripts'),join(repository,'patches/qemu')])await mkdir(path,{recursive:true});
14新增: for(const name of ['pubring.gpg','trustdb.gpg','private-keys-must-not-copy'])await writeFile(join(keyring,name),name);
1415 const sha='a'.repeat(40),content='fixture source archive\n';
1516 await writeFile(join(repository,'packaging/windows/dependencies.json'),JSON.stringify({qemuSource:{repository:'https://source.invalid/locked-qemu.git',commit:sha},qemuKeycodemap:{url:'https://source.invalid/keymap.tar.gz',hash:createHash('sha256').update(content).digest('hex')}}));
1617 for(const name of ['build-source-packages.txt','build-packages.txt','cage-build.json'])await writeFile(join(runtime,name),name==='build-source-packages.txt'?'mingw-w64-fixture 1.2.3-1\n':'fixture');
@@ -19,14 +20,16 @@ test('source collector includes pinned firmware and authenticated package source
1920 const command=async(name,body)=>{const path=join(bin,name);await writeFile(path,'#!/bin/bash\nset -e\n'+body+'\n');await chmod(path,0o755)};
2021 await command('cygpath','printf "%s\\n" "$2"');
2122 await command('node','echo "The collector must use the explicit CAGE_NODE path" >&2; exit 99');
23新增: await command('pacman-conf','[[ "$1" == gpgdir ]]; printf "%s\\n" "$SOURCE_TEST_KEYRING"');
2224 await command('git',`if [[ "$*" == *' init '* ]];then mkdir -p "\${@: -1}/.git";fi
2325 if [[ "$*" == *' fetch '* ]];then [[ "$*" == *'fetch --depth=1 https://source.invalid/locked-qemu.git ${sha}' ]] || exit 98;fi
2426 if [[ "$*" == *rev-parse* ]];then printf '${sha}\\n';fi
2527 if [[ "$*" == *'submodule update'* ]];then for ((i=1;i<=$#;i++));do if [[ "\${!i}" == -C ]];then j=$((i+1));q="\${!j}";fi;done;mkdir -p "$q/roms/seabios";echo 'firmware code' > "$q/roms/seabios/code.c";echo 'gitdir: private' > "$q/roms/seabios/.git";fi
2628 if [[ "$*" == *'submodule status'* ]];then printf ' ${sha} roms/seabios\\n';fi`);
2729 await command('curl',`while [[ $# -gt 0 ]];do if [[ "$1" == -o ]];then shift;destination=$1;fi;shift;done;printf '${content.replaceAll('\n','\\n')}' > "$destination"`);
28删除: await command('pacman-key','printf "%s\\n" "$*" >> "$SOURCE_TEST_VERIFICATIONS"');
29删除: execFileSync('bash',[collector,repository,runtime,artifact],{env:{...process.env,PATH:bin+':'+process.env.PATH,CAGE_NODE:process.execPath,SOURCE_TEST_VERIFICATIONS:join(root,'verified')},stdio:'pipe'});
30新增: await command('pacman-key','[[ "$1" == --gpgdir && "$3" == --verify && "$2" != "$SOURCE_TEST_KEYRING" ]]; [[ $(cat "$2/pubring.gpg") == pubring.gpg && $(cat "$2/trustdb.gpg") == trustdb.gpg ]]; [[ ! -e "$2/private-keys-must-not-copy" ]]; grep -qx lock-never "$2/gpg.conf"; printf "%s\\n" "$*" >> "$SOURCE_TEST_VERIFICATIONS"');
31新增: execFileSync('bash',[collector,repository,runtime,artifact],{env:{...process.env,PATH:bin+':'+process.env.PATH,CAGE_NODE:process.execPath,SOURCE_TEST_KEYRING:keyring,SOURCE_TEST_VERIFICATIONS:join(root,'verified')},stdio:'pipe'});
32新增: assert.deepEqual((await readdir(keyring)).sort(),['private-keys-must-not-copy','pubring.gpg','trustdb.gpg']);
3033 const listing=execFileSync('tar',['-tzf',artifact],{encoding:'utf8'});
3134 for(const path of ['source/firmware-revisions.txt','source/qemu/roms/seabios/code.c','source/packages/mingw-w64-fixture-1.2.3-1.src.tar.zst','source/cage/patches/fixture.patch','source/SHA256SUMS'])assert.ok(listing.includes(path),path);
3235 assert.ok(!listing.includes('/.git'));