diff --git a/scripts/install-cursor-agent-cli-windows.ps1 b/scripts/install-cursor-agent-cli-windows.ps1 new file mode 100644 index 00000000..545956ca --- /dev/null +++ b/scripts/install-cursor-agent-cli-windows.ps1 @@ -0,0 +1,47 @@ +param( + [string]$InstallUrl = "https://cursor.com/install?win32=true" +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = "Stop" + +# $IsWindows exists in PowerShell Core; fall back for Windows PowerShell 5.x. +$runningOnWindows = $false +if (Get-Variable -Name IsWindows -ErrorAction SilentlyContinue) { + $runningOnWindows = [bool]$IsWindows +} +else { + $runningOnWindows = $env:OS -eq "Windows_NT" +} + +if (-not $runningOnWindows) { + throw "This installer script is intended for Windows only." +} + +Write-Host "Installing Cursor Agent CLI from $InstallUrl ..." + +try { + # Cursor publishes an official PowerShell installer for Windows. + $installerScript = Invoke-RestMethod -Uri $InstallUrl -Method Get + if ([string]::IsNullOrWhiteSpace([string]$installerScript)) { + throw "Installer payload was empty." + } + Invoke-Expression $installerScript +} +catch { + throw "Cursor Agent CLI installation failed: $($_.Exception.Message)" +} + +# Refresh PATH in this process for immediate verification. +$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + + [System.Environment]::GetEnvironmentVariable("Path", "User") + +$agentCmd = Get-Command agent -ErrorAction SilentlyContinue +if (-not $agentCmd) { + Write-Warning "Install completed, but 'agent' was not found in PATH for this shell yet." + Write-Host "Open a new PowerShell window and run: agent --version" + exit 0 +} + +Write-Host "Installation complete." +& agent --version