agentpack-lite/install.ps1
2026-08-03 17:19:08 -03:00

27 lines
1 KiB
PowerShell

param(
[switch]$DryRun,
[string]$Target = "AGENTS.md",
[string]$SourceUrl = "https://agentpacks.domhubs.com.br/api/lite/agents"
)
$ErrorActionPreference = "Stop"
$ExpectedSha256 = "03d2b7d8258ca271bf84f3afa9e72dfde7accdf55b1f800ffca9a84976e59b79"
if (Test-Path -LiteralPath $Target -PathType Leaf) {
throw "Arquivo existente; nada foi sobrescrito: $Target"
}
$temporary = Join-Path ([System.IO.Path]::GetTempPath()) ("agentpack-lite-" + [guid]::NewGuid().ToString("N") + ".md")
try {
Invoke-WebRequest -Uri $SourceUrl -OutFile $temporary -UseBasicParsing
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $temporary).Hash.ToLowerInvariant()
if ($actual -ne $ExpectedSha256) { throw "Falha de integridade: SHA-256 inesperado ($actual)." }
if ($DryRun) {
Write-Output "OK: instalaria $Target (SHA-256 $actual)"
} else {
Copy-Item -LiteralPath $temporary -Destination $Target
Write-Output "AgentPack Lite instalado em $Target"
}
} finally {
Remove-Item -LiteralPath $temporary -Force -ErrorAction SilentlyContinue
}