mirror of
https://github.com/domfelipe/agentpack-lite.git
synced 2026-08-07 04:16:39 +00:00
27 lines
1 KiB
PowerShell
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
|
|
}
|