# xcode installer for Windows # irm https://xcode-cli.vercel.app/install.ps1 | iex $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" # Invoke-WebRequest is ~10x slower with the progress bar on try { [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 } catch {} [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13 $Base = if ($env:XCODE_UPDATE_URL) { $env:XCODE_UPDATE_URL.TrimEnd('/') } else { "https://xcode-cli.vercel.app" } $InstallDir = Join-Path $env:USERPROFILE ".xcode\bin" $Exe = Join-Path $InstallDir "xcode.exe" function Step($n, $text) { Write-Host " [$n/4] " -NoNewline -ForegroundColor DarkGray; Write-Host $text } function Fail($text) { Write-Host ""; Write-Host " x $text" -ForegroundColor Red; Write-Host ""; exit 1 } Write-Host "" Write-Host " ◆ xcode" -ForegroundColor Cyan -NoNewline Write-Host " AI coding agent for your terminal" -ForegroundColor DarkGray Write-Host "" if (-not [Environment]::Is64BitOperatingSystem) { Fail "xcode needs 64-bit Windows." } # 1. Which version? Step 1 "Checking the latest release..." try { $Manifest = Invoke-RestMethod -Uri "$Base/api/version" -UseBasicParsing -TimeoutSec 20 } catch { Fail "Could not reach $Base/api/version ($($_.Exception.Message))" } $Version = $Manifest.version $AssetPath = $Manifest.assets.'windows-x64' $Expected = $Manifest.sha256.'windows-x64' if (-not $Version -or -not $AssetPath) { Fail "The release manifest has no Windows build." } Write-Host " v$Version" -ForegroundColor Cyan # 2. Download and verify $Zip = Join-Path $env:TEMP "xcode-$Version-windows-x64.zip" $Url = if ($AssetPath -match '^https?://') { $AssetPath } else { "$Base$AssetPath" } $SizeMb = if ($Manifest.size.'windows-x64') { " ({0:N0} MB)" -f ($Manifest.size.'windows-x64' / 1MB) } else { "" } Step 2 "Downloading$SizeMb..." try { Invoke-WebRequest -Uri $Url -OutFile $Zip -UseBasicParsing -Headers @{ "Cache-Control" = "no-cache" } } catch { Fail "Download failed: $($_.Exception.Message)" } if ($Expected) { $Actual = (Get-FileHash -Path $Zip -Algorithm SHA256).Hash.ToLower() if ($Actual -ne $Expected.ToLower()) { Remove-Item $Zip -Force; Fail "Checksum mismatch, the download is corrupt or tampered. Please run the installer again." } Write-Host " checksum verified (SHA-256)" -ForegroundColor DarkGray } else { Remove-Item $Zip -Force; Fail "Security Error: Release manifest does not include a cryptographic SHA-256 checksum." } # 3. Install (a running xcode.exe can be renamed but not overwritten) Step 3 "Installing to $InstallDir" New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null if (Test-Path $Exe) { $Old = "$Exe.old" Remove-Item $Old -Force -ErrorAction SilentlyContinue if (Test-Path $Old) { $Old = "$Exe.$(Get-Date -Format yyyyMMddHHmmss).old" } Move-Item $Exe $Old -Force } $Unpack = Join-Path $env:TEMP "xcode-unpack-$([guid]::NewGuid().ToString('N'))" Expand-Archive -Path $Zip -DestinationPath $Unpack -Force $Fresh = Get-ChildItem -Path $Unpack -Recurse -Filter "xcode.exe" | Select-Object -First 1 if (-not $Fresh) { Fail "The archive does not contain xcode.exe." } Copy-Item $Fresh.FullName $Exe -Force Remove-Item $Unpack -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $Zip -Force -ErrorAction SilentlyContinue # 4. PATH Step 4 "Adding xcode to your PATH" $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") if (-not (($UserPath -split ';') -contains $InstallDir)) { [Environment]::SetEnvironmentVariable("Path", "$InstallDir;$UserPath", "User") Write-Host " added (new terminals pick it up)" -ForegroundColor DarkGray } else { Write-Host " already there" -ForegroundColor DarkGray } if (-not (($env:Path -split ';') -contains $InstallDir)) { $env:Path = "$InstallDir;$env:Path" } # 5. Windows Terminal Acrylic Transparency Optimization try { $WtSettings = Join-Path $env:LOCALAPPDATA "Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" if (Test-Path $WtSettings) { $RawJson = Get-Content $WtSettings -Raw -Encoding UTF8 $WtObj = ConvertFrom-Json $RawJson if ($WtObj.profiles -and $WtObj.profiles.defaults) { $NeedsUpdate = $false if (-not $WtObj.profiles.defaults.opacity -or $WtObj.profiles.defaults.opacity -gt 85) { $WtObj.profiles.defaults | Add-Member -NotePropertyName "opacity" -NotePropertyValue 75 -Force $NeedsUpdate = $true } if ($WtObj.profiles.defaults.useAcrylic -ne $true) { $WtObj.profiles.defaults | Add-Member -NotePropertyName "useAcrylic" -NotePropertyValue $true -Force $NeedsUpdate = $true } if ($NeedsUpdate) { $WtObj | ConvertTo-Json -Depth 32 | Set-Content $WtSettings -Encoding UTF8 Write-Host " Windows Terminal acrylic transparency enabled (75% opacity)" -ForegroundColor DarkGray } } } } catch {} $Installed = & $Exe --version 2>$null Write-Host "" Write-Host " ✓ xcode $Installed installed" -ForegroundColor Green Write-Host "" Write-Host " xcode " -NoNewline -ForegroundColor Cyan; Write-Host "start in the current folder" -ForegroundColor DarkGray Write-Host " xcode -p `"...`" " -NoNewline -ForegroundColor Cyan; Write-Host "one-shot answer, no UI" -ForegroundColor DarkGray Write-Host " /login /account " -NoNewline -ForegroundColor Cyan; Write-Host "sign in, switch accounts" -ForegroundColor DarkGray Write-Host " xcode upgrade " -NoNewline -ForegroundColor Cyan; Write-Host "update (also automatic)" -ForegroundColor DarkGray Write-Host ""