forked from avibe-bot/avibe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
299 lines (250 loc) · 8.95 KB
/
Copy pathinstall.ps1
File metadata and controls
299 lines (250 loc) · 8.95 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# Vibe Remote Installation Script for Windows
# Usage: irm https://raw.githubusercontent.com/cyhhao/vibe-remote/master/install.ps1 | iex
#
# Prerequisites: None! uv will be installed automatically and manages Python for you.
$ErrorActionPreference = "Stop"
# Configuration
$REPO = "cyhhao/vibe-remote"
$PACKAGE_NAME = "vibe-remote"
$TSINGHUA_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple"
function Write-Banner {
Write-Host @"
__ __ _ _ ____ _
\ \ / /(_)| |__ ___ | _ \ ___ _ __ ___ ___ | |_ ___
\ \ / / | || '_ \ / _ \ | |_) |/ _ \| '_ `` _ \ / _ \| __|/ _ \
\ V / | || |_) || __/ | _ <| __/| | | | | | (_) | |_| __/
\_/ |_||_.__/ \___| |_| \_\\___||_| |_| |_|\___/ \__|\___|
"@ -ForegroundColor Blue
Write-Host "Local-first agent runtime for Slack" -ForegroundColor Green
Write-Host ""
}
function Write-Info {
param([string]$Message)
Write-Host "[INFO] " -ForegroundColor Blue -NoNewline
Write-Host $Message
}
function Write-Success {
param([string]$Message)
Write-Host "[OK] " -ForegroundColor Green -NoNewline
Write-Host $Message
}
function Write-Warning {
param([string]$Message)
Write-Host "[WARN] " -ForegroundColor Yellow -NoNewline
Write-Host $Message
}
function Write-Error {
param([string]$Message)
Write-Host "[ERROR] " -ForegroundColor Red -NoNewline
Write-Host $Message
exit 1
}
function Test-Command {
param([string]$Command)
$null = Get-Command $Command -ErrorAction SilentlyContinue
return $?
}
function Install-Uv {
if (Test-Command "uv") {
Write-Success "uv is already installed"
return
}
Write-Info "Installing uv (will also manage Python automatically)..."
try {
irm https://astral.sh/uv/install.ps1 | iex
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
if (Test-Command "uv") {
Write-Success "uv installed successfully"
} else {
# Check common locations
$uvPath = "$env:USERPROFILE\.local\bin\uv.exe"
if (Test-Path $uvPath) {
$env:Path += ";$env:USERPROFILE\.local\bin"
Write-Success "uv installed successfully"
} else {
throw "uv not found after installation"
}
}
} catch {
Write-Error "Failed to install uv. Please install it manually: https://docs.astral.sh/uv/"
}
}
function Invoke-NativeCommand {
param(
[string]$FilePath,
[string[]]$Arguments
)
$stdoutPath = [System.IO.Path]::GetTempFileName()
$stderrPath = [System.IO.Path]::GetTempFileName()
try {
$process = Start-Process -FilePath $FilePath `
-ArgumentList $Arguments `
-RedirectStandardOutput $stdoutPath `
-RedirectStandardError $stderrPath `
-NoNewWindow `
-Wait `
-PassThru `
-ErrorAction Stop
$stdout = if (Test-Path $stdoutPath) { [System.IO.File]::ReadAllText($stdoutPath) } else { "" }
$stderr = if (Test-Path $stderrPath) { [System.IO.File]::ReadAllText($stderrPath) } else { "" }
$capturedOutput = @()
foreach ($streamOutput in @($stdout, $stderr)) {
$trimmedOutput = $streamOutput.Trim()
if ($trimmedOutput) {
$capturedOutput += $trimmedOutput
}
}
return @{
Success = ($process.ExitCode -eq 0)
ExitCode = $process.ExitCode
Output = ($capturedOutput -join [System.Environment]::NewLine).Trim()
}
} catch {
$capturedOutput = @()
foreach ($path in @($stdoutPath, $stderrPath)) {
if (Test-Path $path) {
$streamOutput = [System.IO.File]::ReadAllText($path).Trim()
if ($streamOutput) {
$capturedOutput += $streamOutput
}
}
}
$errorText = ($_ | Out-String).Trim()
if ($errorText) {
$capturedOutput += $errorText
}
return @{
Success = $false
ExitCode = 1
Output = ($capturedOutput -join [System.Environment]::NewLine).Trim()
}
} finally {
foreach ($path in @($stdoutPath, $stderrPath)) {
if (Test-Path $path) {
Remove-Item $path -Force -ErrorAction SilentlyContinue
}
}
}
}
function Invoke-UvToolInstallAttempt {
param([string[]]$Arguments)
return Invoke-NativeCommand -FilePath "uv" -Arguments (@("tool", "install") + $Arguments)
}
function Install-Vibe {
Write-Info "Installing vibe-remote (Python will be downloaded automatically if needed)..."
$customPackageSpec = $env:VIBE_INSTALL_PACKAGE_SPEC
if ($customPackageSpec) {
Write-Info "Trying custom package spec..."
$result = Invoke-UvToolInstallAttempt -Arguments @($customPackageSpec, "--force")
if ($result.Success) {
Write-Success "vibe-remote installed successfully (from custom package spec)"
return
}
$failureMessage = "Failed to install vibe-remote from custom package spec"
if ($result.ExitCode -ne $null) {
$failureMessage += " (exit code $($result.ExitCode))"
}
if ($result.Output) {
$failureMessage += ":`n$($result.Output)"
}
Write-Error $failureMessage
}
$attempts = @(
@{
Name = "PyPI"
Arguments = @($PACKAGE_NAME, "--force", "--refresh")
},
@{
Name = "Tsinghua mirror"
Arguments = @($PACKAGE_NAME, "--force", "--refresh", "--index-url", $TSINGHUA_INDEX_URL)
},
@{
Name = "GitHub"
Arguments = @("git+https://github.com/$REPO.git", "--force")
}
)
$failures = @()
foreach ($attempt in $attempts) {
Write-Info "Trying $($attempt.Name)..."
$result = Invoke-UvToolInstallAttempt -Arguments $attempt.Arguments
if ($result.Success) {
Write-Success "vibe-remote installed successfully (from $($attempt.Name))"
return
}
$failureMessage = "- $($attempt.Name) failed"
if ($result.ExitCode -ne $null) {
$failureMessage += " (exit code $($result.ExitCode))"
}
if ($result.Output) {
$failureMessage += ":`n$($result.Output)"
}
$failures += $failureMessage
}
Write-Error "Failed to install vibe-remote from all sources.`n$($failures -join "`n`n")"
}
function Test-Installation {
Write-Info "Verifying installation..."
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
$env:Path += ";$env:USERPROFILE\.local\bin"
if (Test-Command "vibe") {
Write-Success "vibe command is available"
Write-Host ""
& vibe --help
return $true
}
# Check common install locations
$vibeLocations = @(
"$env:USERPROFILE\.local\bin\vibe.exe"
)
foreach ($loc in $vibeLocations) {
if (Test-Path $loc) {
Write-Warning "vibe installed at $loc but not in PATH"
Write-Host ""
Write-Host "Add this directory to your PATH:" -ForegroundColor Yellow
Write-Host " $(Split-Path $loc)"
Write-Host ""
return $true
}
}
Write-Error "Installation verification failed. vibe command not found."
}
function Write-NextSteps {
Write-Host ""
Write-Host "Installation complete!" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Blue
Write-Host " 1. Run 'vibe' to start the setup wizard"
Write-Host " 2. Configure your Slack app tokens in the web UI"
Write-Host " 3. Enable channels and start chatting with AI agents"
Write-Host ""
Write-Host "Quick commands:" -ForegroundColor Blue
Write-Host " vibe - Start Vibe Remote (service + web UI)"
Write-Host " vibe status - Check service status"
Write-Host " vibe stop - Stop all services"
Write-Host " vibe doctor - Run diagnostics"
Write-Host ""
Write-Host "Uninstall:" -ForegroundColor Blue
Write-Host " uv tool uninstall vibe-remote"
Write-Host " Remove-Item -Recurse ~\.vibe_remote # remove config and data"
Write-Host ""
Write-Host "Documentation:" -ForegroundColor Blue
Write-Host " https://github.com/$REPO#readme"
Write-Host ""
}
# Main installation flow
function Main {
Write-Banner
Write-Info "Detected OS: Windows"
# Install uv (which manages Python automatically)
Install-Uv
# Install vibe-remote
Install-Vibe
# Verify
Test-Installation
# Done
Write-NextSteps
}
# Run main
Main