# SKYNET Windows 11 developer setup. Run from a normal PowerShell window. # Packages come only from the Windows Package Manager and Microsoft Store. [CmdletBinding()] param() $ErrorActionPreference = 'Stop' if ($PSVersionTable.PSEdition -ne 'Desktop' -and $PSVersionTable.PSEdition -ne 'Core') { throw 'PowerShell is required.' } if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT -or [Environment]::OSVersion.Version.Build -lt 22000) { throw 'This installer requires Windows 11.' } if (-not (Get-Command winget.exe -ErrorAction SilentlyContinue)) { throw 'Windows Package Manager (winget) is unavailable. Install or update App Installer from Microsoft Store, then rerun.' } function Install-Package { param( [Parameter(Mandatory)] [string] $Id, [Parameter(Mandatory)] [ValidateSet('winget', 'msstore')] [string] $Source, [switch] $Force ) Write-Host "Installing $Id from $Source..." if ($Force) { & winget.exe install --id $Id --exact --source $Source --accept-source-agreements --accept-package-agreements --force } else { & winget.exe install --id $Id --exact --source $Source --accept-source-agreements --accept-package-agreements } if ($LASTEXITCODE -ne 0) { throw "winget failed to install $Id (exit code $LASTEXITCODE)." } } # The current ChatGPT desktop app uses the OpenAI.Codex package identity. function Get-ChatGPTPackage { Get-AppxPackage -Name 'OpenAI.Codex' -ErrorAction SilentlyContinue | Sort-Object { [version]$_.Version } -Descending | Select-Object -First 1 } function Assert-ChatGPTInstalled { param([Parameter(Mandatory)] $Package) if ($Package.Status -ne 'Ok') { throw "ChatGPT is registered, but Windows reports package status '$($Package.Status)'." } $manifest = Get-AppxPackageManifest -Package $Package.PackageFullName $installedExecutable = @($manifest.Package.Applications.Application) | ForEach-Object { $_.Executable } | Where-Object { $_ -and (Test-Path (Join-Path $Package.InstallLocation $_)) } | Select-Object -First 1 if (-not $installedExecutable) { throw 'ChatGPT package registration has no installed executable. Installation did not complete.' } Write-Host "ChatGPT desktop verified: $($Package.Name) $($Package.Version)" } # Install and verify the desktop app first so later optional tooling cannot mask a failure. Write-Host 'Installing or repairing the current ChatGPT desktop app; Windows may request administrator approval.' try { Install-Package -Id '9PLM9XGG6VKS' -Source 'msstore' -Force } catch { throw "$($_.Exception.Message) Rerun PowerShell as Administrator and try again." } $chatGPTPackage = Get-ChatGPTPackage if (-not $chatGPTPackage) { throw 'WinGet completed without registering ChatGPT for the current Windows user. Sign out and back in, then rerun this installer.' } Assert-ChatGPTInstalled -Package $chatGPTPackage if (-not (Get-Command git.exe -ErrorAction SilentlyContinue)) { Install-Package -Id 'Git.Git' -Source 'winget' } # WinGet's Codex package downloads the OpenAI release and validates its manifest hash. if (-not (Get-Command codex.exe -ErrorAction SilentlyContinue)) { Install-Package -Id 'OpenAI.Codex' -Source 'winget' } # Windows Terminal is included on most Windows 11 installations. if (-not (Get-Command wt.exe -ErrorAction SilentlyContinue) -and -not (Get-AppxPackage -Name 'Microsoft.WindowsTerminal' -ErrorAction SilentlyContinue)) { Install-Package -Id 'Microsoft.WindowsTerminal' -Source 'winget' } $emacsChoice = Read-Host 'Install GNU Emacs? [y/N]' if ($emacsChoice -match '^(?i:y|yes)$') { Install-Package -Id 'GNU.Emacs' -Source 'winget' } Write-Host 'Package setup complete. Open a new terminal and run codex --version to verify the CLI command.' Write-Host 'If codex is not found there, check Windows Settings > Apps > Advanced app settings > App execution aliases, then rerun this installer.' Write-Host 'Launch ChatGPT from Start and sign in to use the desktop app with Codex.'