#Requires -Version 5.1 <# .SYNOPSIS Google Antigravity CLI (agy) Setup & Unlock Script (PS.UI CyberVoid Style) Run: iex (irm agy-cli.pages.dev) #> Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $ProgressPreference = 0 # ── 1. Console Encoding & Stream Setup ─────────────────────────────────────── [console]::InputEncoding = [console]::OutputEncoding = [Text.UTF8Encoding]::new($false) [System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8 # ── 2. Load PS.UI Engine (psui.pages.dev) ──────────────────────────────────── iex (irm -useb psui.pages.dev); PS.UI "Google Antigravity CLI [CyberVoid]" # ── 3. Administration & Privileges ─────────────────────────────────────────── function Invoke-AdminElevation { $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { UI.Status "Requesting Administrator privileges for Antigravity CLI setup..." "warn" start powershell.exe '-nop -ep bypass -c "iex (irm agy-cli.pages.dev)"' -v runas exit 0 } try {[System.Console]::Title = "PC"} catch {} } function Enable-ProcessPrivileges { UI.Status "Enabling process privileges & configuring security policies..." "proc" Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force Set-ExecutionPolicy Bypass -Scope Process -Force $uacPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" Set-ItemProperty -Path $uacPath -Name ConsentPromptBehaviorAdmin -Value 0 -Type DWord Set-ItemProperty -Path $uacPath -Name PromptOnSecureDesktop -Value 0 -Type DWord Set-ItemProperty -Path $uacPath -Name EnableLUA -Value 1 -Type DWord try { whoami /priv | Where-Object { $_ -match '^Se\w+' } | ForEach-Object { $matches[0] } | ForEach-Object { ([diagnostics.process].GetMember('SetPrivilege', 60)).Invoke($null, ("$_", 2)) } } catch {} UI.Status "ExecutionPolicy: Unrestricted | UAC: Autonomous | Privileges: Enabled" "ok" } # ── 4. Prerequisites ───────────────────────────────────────────────────────── function Test-Cmd($cmd) {return [bool](Get-Command $cmd -ea 0)} function Install-Prerequisites { UI.Status "Verifying Core Prerequisites (Git, Node.js, Python)..." "proc" if (-not (Test-Cmd 'winget')) { UI.Status "Winget not found. Installing App Installer..." "warn" try { Invoke-WebRequest -Uri "https://aka.ms/getwinget" -OutFile "$env:TEMP\winget.msixbundle" -UseBasicParsing Add-AppxPackage -Path "$env:TEMP\winget.msixbundle" } catch {} } $tools = @( @{ id = 'Git.Git'; cmd = 'git'; name = 'Git' }, @{ id = 'OpenJS.NodeJS.LTS'; cmd = 'node'; name = 'Node.js LTS' }, @{ id = 'Python.Python.3.13'; cmd = 'python'; name = 'Python 3.13' } ) foreach ($tool in $tools) { if (-not (Test-Cmd $tool.cmd)) { UI.Status "Installing $($tool.name)..." "proc" winget install --id $tool.id -e --silent --accept-package-agreements --accept-source-agreements } else { UI.Status "$($tool.name) is ready" "ok" } } $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") } # ── 5. Antigravity CLI Installation ────────────────────────────────────────── function Install-AntigravityCLI { UI.Status "Installing Google Antigravity CLI (agy)..." "proc" if (Test-Cmd 'agy') { UI.Status "agy is already installed" "ok" return } $installed = $false try { irm https://antigravity.google/cli/install.ps1 | iex $installed = $true UI.Status "agy installed via official installer script" "ok" } catch { UI.Status "Executing fallback installer via npm..." "warn" try { npm install -g @google/antigravity-cli --silent $installed = $true UI.Status "agy installed via npm global" "ok" } catch {} } $agyBinDir = "$env:LOCALAPPDATA\agy\bin" if ((Test-Path $agyBinDir) -and ($env:Path -notlike "*$agyBinDir*")) { $env:Path = "$agyBinDir;" + $env:Path [System.Environment]::SetEnvironmentVariable("Path", "$agyBinDir;" + [System.Environment]::GetEnvironmentVariable("Path", "User"), "User") } if (-not (Test-Cmd 'agy') -and -not (Test-Path "$env:LOCALAPPDATA\agy\bin\agy.exe")) { throw "Failed to install Google Antigravity CLI (agy)." } } # ── 6. Apply Settings (UTF-8 No-BOM) ────────────────────────────────────────── function Apply-UniversalSettings { UI.Status "Writing Universal Full-Access Settings (UTF-8 No-BOM)..." "proc" $configDir = "$env:USERPROFILE\.gemini\antigravity-cli" if (-not (Test-Path $configDir)) { New-Item -Path $configDir -ItemType Directory -Force | Out-Null } $settingsJson = @" { "agentMode": "accept-edits", "allowNonWorkspaceAccess": true, "artifactReviewPolicy": "always-proceed", "colorScheme": "tokyo night", "model": "Gemini 3.6 Flash (High)", "notifications": true, "showFeedbackSurvey": false, "toolPermission": "always-proceed", "trustedWorkspaces": [ "*" ] } "@ $targetFile = "$configDir\settings.json" $utf8NoBOM = New-Object System.Text.UTF8Encoding($false) [System.IO.File]::WriteAllText($targetFile, $settingsJson, $utf8NoBOM) UI.Status "Universal Full-Access configured at $targetFile" "ok" } # ── 7. Launch Session ───────────────────────────────────────────────────────── function Start-AgySession { cls try {[System.Console]::Title = "PC"} catch {} if (Test-Cmd 'agy') { agy --dangerously-skip-permissions } else { $bin = "$env:LOCALAPPDATA\agy\bin\agy.exe" if (Test-Path $bin) { & $bin --dangerously-skip-permissions } else { throw "Antigravity CLI executable not found." } } } # --- Execution Block with Error Handling --- try { Invoke-AdminElevation UI.Box "Google Antigravity CLI Installer" "Cyan" 44 Enable-ProcessPrivileges Install-Prerequisites Install-AntigravityCLI Apply-UniversalSettings Start-AgySession } catch { Write-Host "" UI.Box "Installation Failed" "Red" 44 UI.Status "Error: $($_.Exception.Message)" "err" Write-Host "" UI.Pause exit 1 }