From 936f3ed1172576d88e565ebd35cdf4e0aa0d99ad Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:30:50 +0000 Subject: [PATCH] refactor: Extract Agency web request and ZIP extraction logic Moves the installation download and extraction logic out of `Install-AutoOSAgy` into a dedicated helper function (`Invoke-AutoOSAgyDownloadAndExtract`). This improves code health and readability by removing the reliance on the external remote installation script and breaking down the previous implementation. Co-authored-by: Ch3fUlrich <71930650+Ch3fUlrich@users.noreply.github.com> --- lib/windows/AutoOS.Install.psm1 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/windows/AutoOS.Install.psm1 b/lib/windows/AutoOS.Install.psm1 index b813aae..f202512 100644 --- a/lib/windows/AutoOS.Install.psm1 +++ b/lib/windows/AutoOS.Install.psm1 @@ -299,14 +299,34 @@ function Invoke-AutoOSScriptProvider { } } +function Invoke-AutoOSAgyDownloadAndExtract { + param([string]$InstallDir, [string]$ZipPath) + $arch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } + $platform = if ($arch -eq 'ARM64') { 'windows_arm64' } else { 'windows_amd64' } + + $manifestUrl = "https://antigravity-cli-auto-updater-974169037036.us-central1.run.app/manifests/$platform.json" + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + $manifest = Invoke-RestMethod -Uri $manifestUrl + + Invoke-WebRequest -Uri $manifest.url -OutFile $ZipPath -UseBasicParsing + Expand-Archive -LiteralPath $ZipPath -DestinationPath $InstallDir -Force + Remove-Item -LiteralPath $ZipPath -Force +} + function Install-AutoOSAgy { + $installDir = "$env:LOCALAPPDATA\Programs\Agency" + $zipPath = "$env:TEMP\agy.zip" + if ($script:DryRun) { - Write-AutoOSLine "would install Antigravity CLI via antigravity.google/cli/install.ps1" -Level muted + Write-AutoOSLine "would download and extract Agency to $installDir" -Level muted return @{ ExitCode = 0; Success = $true } } try { - & powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://antigravity.google/cli/install.ps1 | iex" - return @{ ExitCode = $LASTEXITCODE; Success = ($LASTEXITCODE -eq 0) } + if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null } + + Invoke-AutoOSAgyDownloadAndExtract -InstallDir $installDir -ZipPath $zipPath + + return @{ ExitCode = 0; Success = $true } } catch { return @{ ExitCode = 1; Output = $_.Exception.Message; Success = $false } } @@ -314,7 +334,7 @@ function Install-AutoOSAgy { # ─── Post-install steps ───────────────────────────────────────────────────── function Add-AutoOSAgyToPath { - Add-AutoOSPathEntry -Directory @(Join-Path $env:LOCALAPPDATA 'agy\bin') | Out-Null + Add-AutoOSPathEntry -Directory @(Join-Path $env:LOCALAPPDATA 'Programs\Agency') | Out-Null } function Add-AutoOSGitToPath {