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