|
| 1 | +# ArrowCode installer — Windows (PowerShell 5+ / PowerShell 7) |
| 2 | +# Usage: |
| 3 | +# irm https://raw.githubusercontent.com/YOUR_USER/arrowcode/main/install.ps1 | iex |
| 4 | +# .\install.ps1 |
| 5 | +# .\install.ps1 -Dir "$env:USERPROFILE\arrowcode" -Setup |
| 6 | + |
| 7 | +[CmdletBinding()] |
| 8 | +param( |
| 9 | + [string]$Dir = $(if ($env:ARROWCODE_DIR) { $env:ARROWCODE_DIR } else { Join-Path $env:USERPROFILE ".arrowcode-app" }), |
| 10 | + [string]$Repo = $(if ($env:ARROWCODE_REPO) { $env:ARROWCODE_REPO } else { "https://github.com/Chintanpatel24/arrowcode.git" }), |
| 11 | + [string]$Branch = $(if ($env:ARROWCODE_BRANCH) { $env:ARROWCODE_BRANCH } else { "main" }), |
| 12 | + [switch]$NoLink, |
| 13 | + [switch]$Setup, |
| 14 | + [switch]$Help |
| 15 | +) |
| 16 | + |
| 17 | +$ErrorActionPreference = "Stop" |
| 18 | +$Version = "1.0.0" |
| 19 | + |
| 20 | +function Show-Banner { |
| 21 | + Write-Host @" |
| 22 | +
|
| 23 | + █████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗ |
| 24 | + ██╔══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝ |
| 25 | + ███████║██████╔╝██████╔╝██║ ██║██║ █╗ ██║██║ ██║ ██║██║ ██║█████╗ |
| 26 | + ██╔══██║██╔══██╗██╔══██╗██║ ██║██║███╗██║██║ ██║ ██║██║ ██║██╔══╝ |
| 27 | + ██║ ██║██║ ██║██║ ██║╚██████╔╝╚███╔███╔╝╚██████╗╚██████╔╝██████╔╝███████╗ |
| 28 | + ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ |
| 29 | +
|
| 30 | + multi-agent swarm coding harness · plan → confirm → ship |
| 31 | +
|
| 32 | +"@ -ForegroundColor Cyan |
| 33 | +} |
| 34 | + |
| 35 | +function Write-Ok($msg) { Write-Host "[ok] $msg" -ForegroundColor Green } |
| 36 | +function Write-Info($msg) { Write-Host "==> $msg" -ForegroundColor Cyan } |
| 37 | +function Write-Err($msg) { Write-Host "[err] $msg" -ForegroundColor Red } |
| 38 | + |
| 39 | +if ($Help) { |
| 40 | + Write-Host @" |
| 41 | +ArrowCode installer v$Version |
| 42 | +
|
| 43 | + -Dir <path> Install directory |
| 44 | + -Repo <url> Git clone URL |
| 45 | + -Branch <name> Git branch (default main) |
| 46 | + -NoLink Skip user PATH shim |
| 47 | + -Setup Run interactive API setup after install |
| 48 | +"@ |
| 49 | + exit 0 |
| 50 | +} |
| 51 | + |
| 52 | +Show-Banner |
| 53 | +Write-Info "ArrowCode installer v$Version" |
| 54 | + |
| 55 | +# Bun |
| 56 | +$bun = Get-Command bun -ErrorAction SilentlyContinue |
| 57 | +if (-not $bun) { |
| 58 | + Write-Info "Installing Bun..." |
| 59 | + powershell -NoProfile -ExecutionPolicy Bypass -Command "irm bun.sh/install.ps1 | iex" |
| 60 | + $env:Path = "$env:USERPROFILE\.bun\bin;" + $env:Path |
| 61 | + $bun = Get-Command bun -ErrorAction SilentlyContinue |
| 62 | + if (-not $bun) { Write-Err "Bun install failed. See https://bun.sh"; exit 1 } |
| 63 | +} |
| 64 | +Write-Ok "Bun $(bun --version)" |
| 65 | + |
| 66 | +# Resolve local repo if script lives inside it |
| 67 | +$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path |
| 68 | +$LocalPkg = Join-Path $ScriptDir "package.json" |
| 69 | +if ((Test-Path $LocalPkg) -and -not $env:ARROWCODE_DIR) { |
| 70 | + $Dir = $ScriptDir |
| 71 | + Write-Info "Detected local repo — installing in-place: $Dir" |
| 72 | +} |
| 73 | + |
| 74 | +if (Test-Path (Join-Path $Dir ".git")) { |
| 75 | + Write-Info "Updating $Dir" |
| 76 | + Push-Location $Dir |
| 77 | + try { |
| 78 | + git fetch --depth 1 origin $Branch 2>$null |
| 79 | + git checkout $Branch 2>$null |
| 80 | + git pull --ff-only origin $Branch 2>$null |
| 81 | + } catch { Write-Info "git update skipped" } |
| 82 | + Pop-Location |
| 83 | +} elseif (Test-Path (Join-Path $Dir "package.json")) { |
| 84 | + Write-Info "Using existing $Dir" |
| 85 | +} else { |
| 86 | + Write-Info "Cloning $Repo → $Dir" |
| 87 | + $parent = Split-Path -Parent $Dir |
| 88 | + if ($parent -and -not (Test-Path $parent)) { New-Item -ItemType Directory -Path $parent | Out-Null } |
| 89 | + if (Get-Command git -ErrorAction SilentlyContinue) { |
| 90 | + try { |
| 91 | + git clone --depth 1 --branch $Branch $Repo $Dir |
| 92 | + } catch { |
| 93 | + if (Test-Path $LocalPkg) { |
| 94 | + Write-Info "Clone failed — copying local files" |
| 95 | + New-Item -ItemType Directory -Path $Dir -Force | Out-Null |
| 96 | + Copy-Item -Path (Join-Path $ScriptDir "*") -Destination $Dir -Recurse -Force |
| 97 | + Remove-Item -Recurse -Force (Join-Path $Dir "node_modules") -ErrorAction SilentlyContinue |
| 98 | + } else { throw } |
| 99 | + } |
| 100 | + } else { |
| 101 | + if (-not (Test-Path $LocalPkg)) { Write-Err "git not found"; exit 1 } |
| 102 | + New-Item -ItemType Directory -Path $Dir -Force | Out-Null |
| 103 | + Copy-Item -Path (Join-Path $ScriptDir "*") -Destination $Dir -Recurse -Force |
| 104 | + Remove-Item -Recurse -Force (Join-Path $Dir "node_modules") -ErrorAction SilentlyContinue |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +Set-Location $Dir |
| 109 | +Write-Info "bun install" |
| 110 | +bun install |
| 111 | +Write-Ok "Dependencies installed" |
| 112 | + |
| 113 | +$launcher = Join-Path $Dir "bin\arrowcode.cmd" |
| 114 | +@" |
| 115 | +@echo off |
| 116 | +setlocal |
| 117 | +set "ROOT=%~dp0.." |
| 118 | +bun "%ROOT%\src\index.ts" %* |
| 119 | +"@ | Set-Content -Path $launcher -Encoding ASCII |
| 120 | +Write-Ok "Wrote $launcher" |
| 121 | + |
| 122 | +Write-Info "Bootstrapping user home from defaults/ → ~/.arrowcode" |
| 123 | +bun run src/index.ts --init |
| 124 | +Write-Ok "User data ready (created only if missing)" |
| 125 | + |
| 126 | +if (-not $NoLink) { |
| 127 | + $shimDir = Join-Path $env:USERPROFILE ".local\bin" |
| 128 | + if (-not (Test-Path $shimDir)) { New-Item -ItemType Directory -Path $shimDir | Out-Null } |
| 129 | + $shim = Join-Path $shimDir "arrowcode.cmd" |
| 130 | + @" |
| 131 | +@echo off |
| 132 | +bun "$Dir\src\index.ts" %* |
| 133 | +"@ | Set-Content -Path $shim -Encoding ASCII |
| 134 | + $ac = Join-Path $shimDir "ac.cmd" |
| 135 | + Copy-Item $shim $ac -Force |
| 136 | + Write-Ok "Shims: $shim" |
| 137 | + $userPath = [Environment]::GetEnvironmentVariable("Path", "User") |
| 138 | + if ($userPath -notlike "*$shimDir*") { |
| 139 | + [Environment]::SetEnvironmentVariable("Path", "$shimDir;$userPath", "User") |
| 140 | + $env:Path = "$shimDir;" + $env:Path |
| 141 | + Write-Ok "Added $shimDir to user PATH (restart shell)" |
| 142 | + } |
| 143 | +} |
| 144 | + |
| 145 | +if ($Setup) { |
| 146 | + Write-Info "Running setup" |
| 147 | + bun run src/index.ts --setup |
| 148 | +} |
| 149 | + |
| 150 | +Write-Host "" |
| 151 | +Write-Host "────────────────────────────────────────────────────────────────" -ForegroundColor Cyan |
| 152 | +Write-Host " ArrowCode installed" -ForegroundColor Cyan |
| 153 | +Write-Host "────────────────────────────────────────────────────────────────" -ForegroundColor Cyan |
| 154 | +Write-Host " Location : $Dir" |
| 155 | +Write-Host " Run : arrowcode or bun $Dir\src\index.ts" |
| 156 | +Write-Host "" |
| 157 | +Write-Host " Next:" |
| 158 | +Write-Host " arrowcode --setup" |
| 159 | +Write-Host " cd your-project; arrowcode" |
| 160 | +Write-Host "" |
0 commit comments