跳到主要内容

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

浏览文件

build-client-windows.ps1

90 行 · 6.5 KB历史下载
1#requires -Version 7.0
2[CmdletBinding()]
3param(
4 [switch]$SkipUI,
5 [switch]$IncludeWebViewRuntime,
6 [string]$DependencyCache
7)
8. (Join-Path $PSScriptRoot 'windows-common.ps1')
9$repository = Split-Path $PSScriptRoot -Parent
10$version = Get-CageVersion $repository
11$go = Get-BuildCommand @('go')
12$dotnet = Get-BuildCommand @('dotnet')
13$node = Get-BuildCommand @('node')
14$npm = Get-BuildCommand @('npm.cmd', 'npm')
15$dependencies = Get-Content -LiteralPath (Join-Path $repository 'packaging/windows/dependencies.json') -Raw | ConvertFrom-Json
16if (-not $DependencyCache) { $DependencyCache = Join-Path $repository '_output/windows-deps' }
17$outputRoot = Join-Path $repository '_output/client-windows-amd64'
18New-Item -ItemType Directory -Path $outputRoot -Force | Out-Null
19$id = [guid]::NewGuid().ToString('N')
20$stage = Join-Path $outputRoot ('.stage-' + $id)
21$destination = Join-Path $outputRoot ('build-' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + $id.Substring(0, 8))
22$savedGoOS, $savedGoArch, $savedCGO = $env:GOOS, $env:GOARCH, $env:CGO_ENABLED
23New-Item -ItemType Directory -Path $stage | Out-Null
24Push-Location $repository
25try {
26 if (-not $SkipUI) {
27 if (-not (Test-Path -LiteralPath 'ui/node_modules')) { Invoke-BuildTool $npm @('--prefix', 'ui', 'ci', '--no-audit', '--no-fund') }
28 Invoke-BuildTool $npm @('--prefix', 'ui', 'run', 'build')
29 }
30 if (-not (Test-Path -LiteralPath 'internal/workbench/web/index.html')) { throw 'Build the UI before using -SkipUI.' }
31 if ($SkipUI) { Invoke-BuildTool $node @('ui/scripts/verify-build.mjs') }
32 $env:GOOS = 'windows'; $env:GOARCH = 'amd64'; $env:CGO_ENABLED = '0'
33 $goDependencies = & $go 'list' '-deps' './cmd/cage-client'
34 if ($LASTEXITCODE -ne 0 -or ($goDependencies -match 'internal/limaembed|github.com/lima-vm/lima/v2|github.com/Code-Hex/vz')) { throw 'Client dependency check failed or includes a virtual machine runtime.' }
35 $result = Join-Path $stage 'result'
36 $app = Join-Path $result 'app'
37 $resources = Join-Path $app 'resources'
38 New-Item -ItemType Directory -Path $resources -Force | Out-Null
39 Invoke-BuildTool $go @('build', '-trimpath', '-ldflags', "-s -w -X github.com/sylvinus/agent-vm/internal/version.Version=$version", '-o', (Join-Path $resources 'cage.exe'), './cmd/cage-client')
40 Invoke-BuildTool $dotnet @('publish', 'desktop/windows/Cage.Windows.csproj', '-c', 'Release', '-r', 'win-x64', '--self-contained', 'true',
41 '-p:EnableWindowsTargeting=true', '-p:PublishSingleFile=true', '-p:RestoreLockedMode=true', "-p:Version=$version", "-p:InformationalVersion=$version", '-o', $app)
42 Get-ChildItem -LiteralPath $app -File | Where-Object { $_.Extension -in @('.pdb', '.xml') } | Remove-Item -Force
43 [IO.File]::WriteAllText((Join-Path $resources 'client-only'), '')
44 [IO.File]::WriteAllText((Join-Path $app 'Cage.client-id'), 'io.github.lee-xeo.claude-cage-client')
45 [IO.File]::WriteAllText((Join-Path $app 'version.txt'), $version)
46 Invoke-BuildTool $node @('scripts/bundle-cloud-kit.mjs', $resources)
47 Invoke-BuildTool $node @('scripts/collect-app-licenses.mjs', (Join-Path $resources 'licenses'))
48 $assets = Get-Content -LiteralPath 'desktop/windows/obj/project.assets.json' -Raw | ConvertFrom-Json
49 $nuget = @($assets.packageFolders.PSObject.Properties.Name)[0]
50 $runtimeVersion = $dependencies.dotnet.runtimeVersion
51 $packs = @($assets.project.frameworks.PSObject.Properties.Value.downloadDependencies | Where-Object { $_.name -in @('Microsoft.NETCore.App.Runtime.win-x64', 'Microsoft.WindowsDesktop.App.Runtime.win-x64') })
52 if ($packs.Count -ne 2 -or @($packs | Where-Object { $_.version -ne "[$runtimeVersion, $runtimeVersion]" }).Count -ne 0) { throw 'Resolved .NET runtime differs from the repository pin.' }
53 $webviewVersion = ((Get-Content -LiteralPath 'desktop/windows/packages.lock.json' -Raw | ConvertFrom-Json).dependencies.PSObject.Properties.Value | ForEach-Object { $_.PSObject.Properties } | Where-Object { $_.Name -eq 'Microsoft.Web.WebView2' } | Select-Object -First 1).Value.resolved
54 foreach ($package in @("microsoft.netcore.app.runtime.win-x64/$runtimeVersion", "microsoft.windowsdesktop.app.runtime.win-x64/$runtimeVersion", "microsoft.web.webview2/$webviewVersion")) {
55 $source = Join-Path $nuget $package
56 $target = Join-Path $resources "licenses/nuget/$package"
57 New-Item -ItemType Directory -Path $target -Force | Out-Null
58 $notices = @(Get-ChildItem -LiteralPath $source -File | Where-Object { $_.Name -match '^(LICENSE|NOTICE|THIRD.?PARTY)' })
59 if ($notices.Count -eq 0) { throw "Missing runtime license: $package" }
60 $notices | Copy-Item -Destination $target
61 }
62 if ($IncludeWebViewRuntime) {
63 $runtime = Get-VerifiedDependency $dependencies.webview2 $DependencyCache
64 New-Item -ItemType Directory -Path (Join-Path $resources 'runtime') -Force | Out-Null
65 Copy-Item -LiteralPath $runtime -Destination (Join-Path $resources 'runtime/MicrosoftEdgeWebView2RuntimeInstallerX64.exe')
66 }
67 Copy-Item -LiteralPath 'LICENSE' -Destination (Join-Path $app 'LICENSE.txt')
68 [IO.File]::WriteAllText((Join-Path $app 'README.txt'), @'
69Cage 轻量远程客户端(未签名开发构建)
70
71运行 Cage.exe。需要 Windows 10/11 x64 与 Microsoft Edge WebView2 Runtime。
72.NET 运行时已随应用提供。没有 WebView2 时,可使用 -IncludeWebViewRuntime 构建包含已校验安装程序的包;构建不会安装该程序。
73本机只提供窗口、SSH 连接、输入和文件传递;项目、浏览器、终端与网络在云端 Cage 运行。
74默认连接配置目录为用户目录下的 .claude-cage/client;显式 CLAUDE_CAGE_CONFIG 配置保持有效。
75此目录为独立构建产物,不会安装、替换完整 Cage 或自动下载完整 Cage 更新。
76本构建未签名或发布。Windows 原生运行验收范围以项目测试报告为准。
77'@)
78 if ($IsWindows) {
79 Invoke-BuildTool (Join-Path $resources 'cage.exe') @('verify-web-assets')
80 Assert-WindowsWorkbench $app
81 }
82 Compress-Archive -Path $app -DestinationPath (Join-Path $result 'Cage-Client-windows-amd64.zip') -CompressionLevel Optimal
83 if (Test-Path -LiteralPath $destination) { throw 'Client output already exists; no files were replaced.' }
84 Move-Item -LiteralPath $result -Destination $destination
85 Write-Host "Built standalone client: $destination"
86} finally {
87 Pop-Location
88 $env:GOOS = $savedGoOS; $env:GOARCH = $savedGoArch; $env:CGO_ENABLED = $savedCGO
89 if (Test-Path -LiteralPath $stage) { Remove-Item -LiteralPath $stage -Recurse -Force }
90}