<# .SYNOPSIS GyanDoot v2.0 — Windows Installer (PowerShell) .DESCRIPTION Installs GyanDoot AI Agent on Windows 10/11 via PowerShell. Requires: Rust (auto-installed), Git Bash recommended. #> $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" Write-Host "" Write-Host "╔═══════════════════════════════════════╗" -ForegroundColor Cyan Write-Host "║ GyanDoot v2.0 — Windows Installer ║" -ForegroundColor Cyan Write-Host "╚═══════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" # ── Helper functions ───────────────────────────────────────────────────── function Write-OK($msg) { Write-Host " [OK] $msg" -ForegroundColor Green } function Write-Info($msg) { Write-Host " [..] $msg" -ForegroundColor Cyan } function Write-Warn($msg) { Write-Host " [!] $msg" -ForegroundColor Yellow } function Write-Err($msg) { Write-Host " [ERR] $msg" -ForegroundColor Red } # ── Detect OS Architecture ─────────────────────────────────────────────── $arch = (Get-WmiObject Win32_Processor).Architecture $archName = switch ($arch) { 0 { "x86" } 9 { "x64" } 12 { "arm64" } default { "unknown" } } Write-Info "Detected: Windows / $archName" # ── Check if running in PowerShell only ────────────────────────────────── Write-Warn "For best results, use Git Bash and run: install.bat" Write-Warn "PowerShell support is limited on Windows." # ── Check / Install Rust ───────────────────────────────────────────────── Write-Info "Checking Rust..." $haveRust = $false try { $rustVer = cargo --version 2>$null if ($rustVer) { Write-OK "Rust already installed ($rustVer)" $haveRust = $true } } catch { } if (-not $haveRust) { Write-Info "Rust not found. Installing Rust..." $rustupUrl = "https://win.rustup.rs" $rustupPath = "$env:TEMP\rustup-init.exe" try { Invoke-WebRequest -Uri $rustupUrl -OutFile $rustupPath -UseBasicParsing Start-Process -FilePath $rustupPath -ArgumentList "-y" -Wait -NoNewWindow # Reload PATH $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") Write-OK "Rust installed" } catch { Write-Err "Failed to install Rust: $_" Write-Warn "Download manually from: https://rustup.rs" exit 1 } } # ── Check Node.js ──────────────────────────────────────────────────────── Write-Info "Checking Node.js..." try { $nodeVer = node --version 2>$null if ($nodeVer) { Write-OK "Node.js $nodeVer" } else { throw "not found" } } catch { Write-Warn "Node.js not found (required for browser features)" Write-Warn "Download from: https://nodejs.org (v20+)" Write-Warn "Or run: winget install OpenJS.NodeJS" } # ── Determine script directory ────────────────────────────────────────── $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition $projectRoot = Resolve-Path "$scriptDir/.." # ── Build ──────────────────────────────────────────────────────────────── Write-Info "Building GyanDoot release (this may take a few minutes)..." Set-Location $projectRoot try { $buildOutput = cargo build --release 2>&1 if ($LASTEXITCODE -ne 0) { throw $buildOutput } Write-OK "Build complete" } catch { Write-Err "Build failed: $_" exit 1 } # ── Install binary ────────────────────────────────────────────────────── $installDir = "$env:USERPROFILE\.cargo\bin" if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null } Copy-Item -Path "$projectRoot\target\release\gyandoot.exe" -Destination "$installDir\gyandoot.exe" -Force Write-OK "Installed to $installDir\gyandoot.exe" # ── Check PATH ────────────────────────────────────────────────────────── $paths = $env:Path -split ';' if ($paths -notcontains $installDir) { Write-Warn "$installDir is not in your PATH!" Write-Warn "Run this to add it permanently:" Write-Host ' [Environment]::SetEnvironmentVariable("Path", "$env:USERPROFILE\.cargo\bin;$env:Path", "User")' -ForegroundColor Gray } # ── Verify ─────────────────────────────────────────────────────────────── try { $helpOutput = & "$installDir\gyandoot.exe" --help 2>&1 Write-OK "GyanDoot installed successfully!" -ForegroundColor Green } catch { Write-Warn "Verification failed: $_" } # ── Optional: Camoufox ─────────────────────────────────────────────────── Write-Host "" Write-Host "────────────────────────────────────────────" -ForegroundColor Yellow Write-Host " Optional: Install Camoufox Browser?" -ForegroundColor Yellow Write-Host " Required for: web_search, web_browse tools" -ForegroundColor Yellow Write-Host "────────────────────────────────────────────" -ForegroundColor Yellow $installCamoufox = Read-Host "Install Camoufox? [y/N]" if ($installCamoufox -eq "y") { Write-Info "Installing camoufox-browser npm package..." npm install -g camoufox-browser@0.1.0 2>$null Write-Info "Downloading Camoufox browser binary (~311MB)..." npx --yes camoufox-js@0.11.0 fetch 2>$null Write-OK "Camoufox browser installed" } # ── Done ───────────────────────────────────────────────────────────────── Write-Host "" Write-Host "╔═══════════════════════════════════════╗" -ForegroundColor Green Write-Host "║ GyanDoot v2.0 installed! ║" -ForegroundColor Green Write-Host "╚═══════════════════════════════════════╝" -ForegroundColor Green Write-Host "" Write-Host " Quick start:" -ForegroundColor Gray Write-Host " gyandoot --help" -ForegroundColor White Write-Host " gyandoot setup" -ForegroundColor White Write-Host " gyandoot run" -ForegroundColor White Write-Host "" Read-Host "Press Enter to exit"