# ============================================================================== # Antigravity CLI Setup & Environment Bootstrapper # Hosted at: https://download.cyberalarmsecurity.com/agy.ps1 # # Steps performed: # 1. Install PowerShell 7 (if not already installed) # 2. Install Google Antigravity CLI # 3. Configure default settings.json (always-proceed, auto mode, high verbosity) # ============================================================================== $ErrorActionPreference = "Stop" Set-StrictMode -Version Latest Write-Host "==========================================================" -ForegroundColor Cyan Write-Host " Starting Antigravity CLI & PowerShell 7 Setup" -ForegroundColor Cyan Write-Host "==========================================================" -ForegroundColor Cyan # ------------------------------------------------------------------------------ # Helper: Refresh process PATH from User and Machine registries # ------------------------------------------------------------------------------ function Update-SessionPath { $machinePath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) $userPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) $env:Path = "$userPath;$machinePath" } # ------------------------------------------------------------------------------ # 1. Install PowerShell 7 (pwsh) # ------------------------------------------------------------------------------ Write-Host "`n[1/3] Checking PowerShell 7 installation..." -ForegroundColor Yellow $pwshCmd = Get-Command pwsh.exe -ErrorAction SilentlyContinue if ($pwshCmd) { Write-Host "PowerShell 7 is already installed: $($pwshCmd.Source)" -ForegroundColor Green } else { Write-Host "PowerShell 7 not found. Installing PowerShell 7..." -ForegroundColor Yellow $installed = $false # Try winget if available $wingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue if ($wingetCmd) { Write-Host "Attempting install via winget..." -ForegroundColor Gray try { $wingetProcess = Start-Process -FilePath "winget.exe" ` -ArgumentList "install --id Microsoft.PowerShell --exact --silent --accept-package-agreements --accept-source-agreements" ` -Wait -PassThru -NoNewWindow if ($wingetProcess.ExitCode -eq 0) { $installed = $true Write-Host "PowerShell 7 successfully installed via winget." -ForegroundColor Green } } catch { Write-Warning "winget installation encountered an error: $_" } } # Fallback to official Microsoft install script if winget was not used or failed if (-not $installed) { Write-Host "Installing PowerShell 7 via Microsoft aka.ms/install-powershell.ps1..." -ForegroundColor Gray try { & ([scriptblock]::Create((Invoke-RestMethod "https://aka.ms/install-powershell.ps1"))) -AddToPath $installed = $true Write-Host "PowerShell 7 installed successfully." -ForegroundColor Green } catch { Write-Error "Failed to install PowerShell 7: $_" } } Update-SessionPath } # ------------------------------------------------------------------------------ # 2. Install Antigravity CLI # ------------------------------------------------------------------------------ Write-Host "`n[2/3] Installing / Updating Google Antigravity CLI..." -ForegroundColor Yellow try { & ([scriptblock]::Create((Invoke-RestMethod "https://antigravity.google/cli/install.ps1"))) Update-SessionPath Write-Host "Antigravity CLI installed successfully." -ForegroundColor Green } catch { Write-Error "Fatal: Failed to install Antigravity CLI: $_" exit 1 } # ------------------------------------------------------------------------------ # 3. Configure Default settings.json # ------------------------------------------------------------------------------ Write-Host "`n[3/3] Configuring Antigravity CLI default settings..." -ForegroundColor Yellow $settingsDir = Join-Path $env:USERPROFILE ".gemini\antigravity-cli" $settingsFile = Join-Path $settingsDir "settings.json" if (-not (Test-Path $settingsDir)) { New-Item -ItemType Directory -Path $settingsDir -Force | Out-Null } $desiredSettings = [ordered]@{ "verbosity" = "high" "toolPermission" = "always-proceed" "agentMode" = "auto" "allowNonWorkspaceAccess" = $true "model" = "Gemini 3.8 Flash (Medium)" } if (Test-Path $settingsFile) { try { $rawJson = Get-Content $settingsFile -Raw -Encoding UTF8 $existingConfig = $rawJson | ConvertFrom-Json # Apply desired settings while preserving existing (e.g. trustedWorkspaces) foreach ($key in $desiredSettings.Keys) { $existingConfig | Add-Member -NotePropertyName $key -NotePropertyValue $desiredSettings[$key] -Force } $mergedJson = $existingConfig | ConvertTo-Json -Depth 20 [System.IO.File]::WriteAllText($settingsFile, $mergedJson, [System.Text.Encoding]::UTF8) Write-Host "Updated existing settings at $settingsFile" -ForegroundColor Green } catch { Write-Warning "Could not parse existing settings.json. Overwriting with standard defaults." $defaultJson = $desiredSettings | ConvertTo-Json -Depth 20 [System.IO.File]::WriteAllText($settingsFile, $defaultJson, [System.Text.Encoding]::UTF8) } } else { $defaultJson = $desiredSettings | ConvertTo-Json -Depth 20 [System.IO.File]::WriteAllText($settingsFile, $defaultJson, [System.Text.Encoding]::UTF8) Write-Host "Created new settings file at $settingsFile" -ForegroundColor Green } Write-Host "`n==========================================================" -ForegroundColor Green Write-Host " Setup complete! You can now start using 'agy'." -ForegroundColor Green Write-Host "==========================================================" -ForegroundColor Green