You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.7 KiB
62 lines
2.7 KiB
$ErrorActionPreference = "Stop"
|
|
|
|
$projectRoot = $PSScriptRoot
|
|
$venvPython = Join-Path $projectRoot ".venv\Scripts\python.exe"
|
|
Set-Location -LiteralPath $projectRoot
|
|
|
|
if (Get-Process -Name "MultiClawAgent" -ErrorAction SilentlyContinue) {
|
|
throw "请先退出正在运行的 MultiClawAgent,再执行编译。"
|
|
}
|
|
|
|
# A local rebuild replaces the whole dist folder. Preserve the user's portable
|
|
# settings so a developer build does not unexpectedly erase pairing or LLM
|
|
# endpoint preferences. Secrets remain in Windows Credential Manager.
|
|
$existingConfig = Join-Path $projectRoot "dist\MultiClawAgent\config\agent-config.json"
|
|
$preservedConfig = $null
|
|
if (Test-Path -LiteralPath $existingConfig) {
|
|
$preservedConfig = Join-Path ([System.IO.Path]::GetTempPath()) ("MultiClawAgent-config-" + [guid]::NewGuid() + ".json")
|
|
Copy-Item -LiteralPath $existingConfig -Destination $preservedConfig -Force
|
|
}
|
|
|
|
if (-not (Test-Path -LiteralPath $venvPython)) {
|
|
python -m venv (Join-Path $projectRoot ".venv")
|
|
}
|
|
|
|
& $venvPython -m pip install --disable-pip-version-check -e ".[dev]"
|
|
& $venvPython -m PyInstaller `
|
|
--noconfirm `
|
|
--clean `
|
|
--windowed `
|
|
--name "MultiClawAgent" `
|
|
--paths "src" `
|
|
--hidden-import "keyring.backends.Windows" `
|
|
--hidden-import "pystray._win32" `
|
|
--copy-metadata "keyring" `
|
|
--distpath "dist" `
|
|
--workpath "build" `
|
|
"app.py"
|
|
|
|
$configTarget = Join-Path $projectRoot "dist\MultiClawAgent\config"
|
|
Copy-Item -LiteralPath (Join-Path $projectRoot "config") -Destination $configTarget -Recurse -Force
|
|
if ($preservedConfig -and (Test-Path -LiteralPath $preservedConfig)) {
|
|
Copy-Item -LiteralPath $preservedConfig -Destination (Join-Path $configTarget "agent-config.json") -Force
|
|
Remove-Item -LiteralPath $preservedConfig -Force
|
|
}
|
|
|
|
# Older preview builds exposed local LLM fields. The production design keeps
|
|
# provider configuration under controller control, so remove those obsolete
|
|
# portable settings while retaining the pairing and display-name preferences.
|
|
$packagedConfig = Join-Path $configTarget "agent-config.json"
|
|
$configObject = Get-Content -LiteralPath $packagedConfig -Raw | ConvertFrom-Json
|
|
$configObject.PSObject.Properties.Remove("llm_base_url")
|
|
$configObject.PSObject.Properties.Remove("llm_model")
|
|
$configObject | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $packagedConfig -Encoding utf8
|
|
|
|
# PyInstaller's build folder is an intermediate cache, not a distributable
|
|
# application. Remove it so users only see the complete package in dist.
|
|
$buildTarget = Join-Path $projectRoot "build\MultiClawAgent"
|
|
if (Test-Path -LiteralPath $buildTarget) {
|
|
Remove-Item -LiteralPath $buildTarget -Recurse -Force
|
|
}
|
|
|
|
Write-Host "编译完成:$(Join-Path $projectRoot 'dist\MultiClawAgent\MultiClawAgent.exe')"
|
|
|