-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinstall-ring.ps1
More file actions
224 lines (187 loc) · 7.75 KB
/
install-ring.ps1
File metadata and controls
224 lines (187 loc) · 7.75 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<#
.SYNOPSIS
Ring Multi-Platform Installer (PowerShell)
.DESCRIPTION
Installs Ring skills to Claude Code, Codex, Factory AI, Cursor, Cline, and/or OpenCode.
Multi-platform installer wrapper for the Python-based Ring installer.
.NOTES
Requires: PowerShell 5.1 or later, Python 3.x
Execution Policy: This script requires RemoteSigned or Bypass execution policy.
Set execution policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Or run with bypass:
powershell -ExecutionPolicy Bypass -File install-ring.ps1
.EXAMPLE
.\install-ring.ps1
Interactive installation with platform selection
.EXAMPLE
.\install-ring.ps1 install --platforms claude
Direct installation to Claude Code
.EXAMPLE
.\install-ring.ps1 update
Update existing installation
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# Warn on overly-permissive execution policy
$currentPolicy = Get-ExecutionPolicy -Scope CurrentUser
if ($currentPolicy -eq "Unrestricted") {
Write-Host "Warning: Running with Unrestricted execution policy. Consider 'Set-ExecutionPolicy -Scope CurrentUser RemoteSigned'." -ForegroundColor Yellow
}
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$RingRoot = Split-Path -Parent $ScriptDir
# Ensure local installer package is importable
if ($env:PYTHONPATH) {
$env:PYTHONPATH = "$RingRoot/installer;$env:PYTHONPATH"
} else {
$env:PYTHONPATH = "$RingRoot/installer"
}
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "Ring Multi-Platform Installer" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Cyan
Write-Host ""
# Detect Python
function Find-Python {
$pythonCmds = @("python3", "python", "py -3")
foreach ($cmd in $pythonCmds) {
try {
$parts = $cmd -split " "
$exe = $parts[0]
$args = if ($parts.Length -gt 1) { $parts[1..($parts.Length-1)] } else { @() }
$version = & $exe @args --version 2>&1
if ($version -match "Python 3") {
return $cmd
}
} catch {
continue
}
}
return $null
}
$PythonCmd = Find-Python
if (-not $PythonCmd) {
Write-Host "Error: Python 3 is required but not found." -ForegroundColor Red
Write-Host ""
Write-Host "Install Python 3:"
Write-Host " Windows: https://python.org/downloads/"
Write-Host " Or: winget install Python.Python.3.12"
exit 1
}
$parts = $PythonCmd -split " "
$pythonExe = $parts[0]
$pythonArgs = if ($parts.Length -gt 1) { $parts[1..($parts.Length-1)] } else { @() }
$version = & $pythonExe @pythonArgs --version 2>&1
Write-Host "Found Python: $version" -ForegroundColor Green
Write-Host ""
# Check if running with arguments (non-interactive mode)
if ($args.Count -gt 0) {
try {
Set-Location $RingRoot
& $pythonExe @pythonArgs -m installer.ring_installer @args
exit $LASTEXITCODE
} catch {
Write-Host "Error: $_" -ForegroundColor Red
exit 1
}
}
# Interactive mode - platform selection
Write-Host "Select platforms to install Ring:"
Write-Host ""
Write-Host " 1) Claude Code (recommended, native format)" -ForegroundColor Blue
Write-Host " 2) Codex (native format)" -ForegroundColor Blue
Write-Host " 3) Factory AI (droids, transformed)" -ForegroundColor Blue
Write-Host " 4) Cursor (skills/agents/commands)" -ForegroundColor Blue
Write-Host " 5) Cline (prompts, transformed)" -ForegroundColor Blue
Write-Host " 6) OpenCode (native format)" -ForegroundColor Blue
Write-Host " 7) All supported platforms" -ForegroundColor Blue
Write-Host " 8) Auto-detect and install" -ForegroundColor Blue
Write-Host ""
$choices = Read-Host "Enter choice(s) separated by comma (e.g., 1,2,3) [default: 8]"
# Default to auto-detect
if ([string]::IsNullOrWhiteSpace($choices)) {
$choices = "8"
}
# Validate input - only allow digits 1-8, commas, and whitespace
if ($choices -notmatch '^[1-8,\s]*$') {
Write-Host "Error: Invalid input. Please enter numbers 1-8 separated by commas." -ForegroundColor Red
exit 1
}
# Parse choices - split by comma and check for exact matches
$platforms = @()
$choiceList = $choices -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
# Check for conflicting options (auto-detect with specific platforms)
$hasAuto = ($choiceList -contains "7") -or ($choiceList -contains "8")
$hasSpecific = ($choiceList -contains "1") -or ($choiceList -contains "2") -or ($choiceList -contains "3") -or ($choiceList -contains "4") -or ($choiceList -contains "5") -or ($choiceList -contains "6")
if ($hasAuto -and $hasSpecific) {
Write-Host "Note: Auto/all selected - ignoring specific platform selections." -ForegroundColor Yellow
}
if ($choiceList -contains "1") { $platforms += "claude" }
if ($choiceList -contains "2") { $platforms += "codex" }
if ($choiceList -contains "3") { $platforms += "factory" }
if ($choiceList -contains "4") { $platforms += "cursor" }
if ($choiceList -contains "5") { $platforms += "cline" }
if ($choiceList -contains "6") { $platforms += "opencode" }
if ($choiceList -contains "7") { $platforms = @("claude", "codex", "factory", "cursor", "cline", "opencode") }
if ($choiceList -contains "8") { $platforms = @("auto") }
if ($platforms.Count -eq 0) {
Write-Host "Error: No valid platforms selected." -ForegroundColor Red
exit 1
}
$platformString = $platforms -join ","
Write-Host ""
Write-Host "Installing to: $platformString" -ForegroundColor Green
Write-Host ""
# Additional options
$verbose = Read-Host "Enable verbose output? (y/N)"
$dryRun = Read-Host "Perform dry-run first? (y/N)"
$extraArgs = @()
if ($verbose -match "^[Yy]$") {
$extraArgs += "--verbose"
}
# Run dry-run if requested
try {
if ($dryRun -match "^[Yy]$") {
Write-Host ""
Write-Host "=== Dry Run ===" -ForegroundColor Yellow
Set-Location $RingRoot
& $pythonExe @pythonArgs -m installer.ring_installer install --platforms $platformString --dry-run @extraArgs
if ($LASTEXITCODE -ne 0) {
throw "Dry-run failed with exit code $LASTEXITCODE"
}
Write-Host ""
$proceed = Read-Host "Proceed with actual installation? (Y/n)"
if ($proceed -match "^[Nn]$") {
Write-Host "Installation cancelled."
exit 0
}
}
# Run actual installation
Write-Host ""
Write-Host "=== Installing ===" -ForegroundColor Green
Set-Location $RingRoot
& $pythonExe @pythonArgs -m installer.ring_installer install --platforms $platformString @extraArgs
if ($LASTEXITCODE -ne 0) {
throw "Installation failed with exit code $LASTEXITCODE"
}
Write-Host ""
Write-Host "================================================" -ForegroundColor Green
Write-Host "Installation Complete!" -ForegroundColor Green
Write-Host "================================================" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:"
Write-Host " 1. Restart your AI tool or start a new session"
Write-Host " 2. Skills will auto-load (Claude Code) or be available as configured"
Write-Host ""
Write-Host "Commands:"
Write-Host " .\installer\install-ring.ps1 # Interactive install"
Write-Host " .\installer\install-ring.ps1 --platforms claude # Direct install"
Write-Host " .\installer\install-ring.ps1 update # Update installation"
Write-Host " .\installer\install-ring.ps1 list # List installed"
Write-Host ""
} catch {
Write-Host ""
Write-Host "Error: $_" -ForegroundColor Red
Write-Host ""
Write-Host "Installation failed. Please check the error message above." -ForegroundColor Red
exit 1
}