# ============================================================================== # SFI Coding Agent — Universal Installer for Windows (PowerShell) # Product: SFI Agent by Shah Fahad Inc. # URL: https://agent.shahfahadinc.com # Usage: irm https://agent.shahfahadinc.com/install.ps1 | iex # ============================================================================== $ErrorActionPreference = "Stop" Write-Host "" Write-Host "=====================================================================" -ForegroundColor Cyan Write-Host " šŸš€ SFI Agent — Windows Workstation Installer" -ForegroundColor Green Write-Host " Connecting ChatGPT, Claude Desktop, and Gemini to your PC" -ForegroundColor Gray Write-Host "=====================================================================" -ForegroundColor Cyan Write-Host "" $InstallDir = Join-Path $HOME ".sfi-agent" $BinDir = Join-Path $HOME "AppData\Local\Microsoft\WindowsApps" $RepoUrl = "https://github.com/ShahFahadIncCode/sfi-coding-agent.git" # 1. Check Git Write-Host "ā— Checking prerequisites..." -ForegroundColor Cyan $gitAvailable = Get-Command git -ErrorAction SilentlyContinue if (-not $gitAvailable) { Write-Host "⚠ Git was not found. Attempting installation via winget..." -ForegroundColor Yellow if (Get-Command winget -ErrorAction SilentlyContinue) { winget install --id Git.Git -e --source winget --accept-source-agreements --accept-package-agreements $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") } else { Write-Host "āœ– Git is required. Please download and install Git from https://git-scm.com/download/win" -ForegroundColor Red Exit 1 } } Write-Host "āœ” Git is ready: $((git --version))" -ForegroundColor Green # 2. Check Node.js $nodeAvailable = Get-Command node -ErrorAction SilentlyContinue if (-not $nodeAvailable) { Write-Host "⚠ Node.js was not found. Attempting installation via winget..." -ForegroundColor Yellow if (Get-Command winget -ErrorAction SilentlyContinue) { winget install --id OpenJS.NodeJS.LTS -e --source winget --accept-source-agreements --accept-package-agreements $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") } else { Write-Host "āœ– Node.js (LTS >= 18) is required. Please install from https://nodejs.org" -ForegroundColor Red Exit 1 } } Write-Host "āœ” Node.js is ready: $((node -v))" -ForegroundColor Green # 3. Check pnpm $pnpmAvailable = Get-Command pnpm -ErrorAction SilentlyContinue if (-not $pnpmAvailable) { Write-Host "ā— Installing pnpm package manager..." -ForegroundColor Cyan npm install -g pnpm } Write-Host "āœ” pnpm is ready: $((pnpm --version))" -ForegroundColor Green # 4. Clone or Update SFI Agent Repository if (-not (Test-Path $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } if (Test-Path (Join-Path $InstallDir ".git")) { Write-Host "`nā— Updating existing SFI Agent installation..." -ForegroundColor Cyan Set-Location $InstallDir git fetch origin main git reset --hard origin/main } else { Write-Host "`nā— Downloading SFI Agent repository into $InstallDir..." -ForegroundColor Cyan git clone $RepoUrl $InstallDir Set-Location $InstallDir } # 5. Install Dependencies & Build Write-Host "`nā— Installing workspace dependencies..." -ForegroundColor Cyan pnpm install --frozen-lockfile=false Write-Host "`nā— Compiling SFI MCP Gateway & Desktop Host..." -ForegroundColor Cyan pnpm --filter @sfi/mcp build pnpm --filter @sfi/desktop build # 6. Install cloudflared.exe if missing $cfAvailable = Get-Command cloudflared -ErrorAction SilentlyContinue $cfTarget = Join-Path $BinDir "cloudflared.exe" if (-not $cfAvailable -and -not (Test-Path $cfTarget)) { Write-Host "`nā— Downloading cloudflared for 1-click Quick Tunnels..." -ForegroundColor Cyan try { Invoke-WebRequest -Uri "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe" -OutFile $cfTarget Write-Host "āœ” cloudflared.exe installed to $cfTarget" -ForegroundColor Green } catch { Write-Host "⚠ Note: cloudflared download skipped: $($_.Exception.Message)" -ForegroundColor Yellow } } # 7. Create Global Command Wrappers (sfi-host.cmd and sfi-host.ps1) if (-not (Test-Path $BinDir)) { New-Item -ItemType Directory -Path $BinDir -Force | Out-Null } $cmdScript = @" @echo off node "$InstallDir\node_modules\tsx\dist\cli.mjs" "$InstallDir\apps\desktop\server.ts" %* "@ Set-Content -Path (Join-Path $BinDir "sfi-host.cmd") -Value $cmdScript $psScript = @" node "$InstallDir\node_modules\tsx\dist\cli.mjs" "$InstallDir\apps\desktop\server.ts" `$args "@ Set-Content -Path (Join-Path $BinDir "sfi-host.ps1") -Value $psScript Write-Host "" Write-Host "=====================================================================" -ForegroundColor Green Write-Host " āœ” SFI AGENT SUCCESSFULLY INSTALLED ON WINDOWS!" -ForegroundColor Green Write-Host "=====================================================================" -ForegroundColor Green Write-Host "" Write-Host " Available Commands:" -ForegroundColor White Write-Host " sfi-host --web Start the Web Host Control Center (http://localhost:5180)" -ForegroundColor Cyan Write-Host " sfi-host --sse Start the MCP SSE Gateway on port 3333" -ForegroundColor Cyan Write-Host " sfi-host --tunnel Start 1-click Cloudflare Quick Tunnel" -ForegroundColor Cyan Write-Host " sfi-host --help Show help menu" -ForegroundColor Cyan Write-Host "" Write-Host " Quick Start:" -ForegroundColor White Write-Host " Open a new PowerShell window and run: sfi-host --web" -ForegroundColor Green Write-Host ""