-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
47 lines (43 loc) · 2.03 KB
/
Copy pathsetup.ps1
File metadata and controls
47 lines (43 loc) · 2.03 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
# One-shot setup for Windows: install Ollama if missing, start server, run doctor.
# Usage: .\setup.ps1 (full setup: primary + stretch models)
# .\setup.ps1 -CoreOnly (primary models only - smallest download)
# .\setup.ps1 -Global (also write ~/.continue/config.yaml)
param(
[switch]$CoreOnly,
[switch]$Global
)
$ErrorActionPreference = 'Stop'
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-Error "Node.js is required (https://nodejs.org or: winget install OpenJS.NodeJS.LTS). Aborting."
}
$ollama = Get-Command ollama -ErrorAction SilentlyContinue
if (-not $ollama) {
$defaultPath = Join-Path $env:LOCALAPPDATA 'Programs\Ollama\ollama.exe'
if (Test-Path $defaultPath) {
$ollama = @{ Source = $defaultPath }
} else {
Write-Host "Ollama not found - installing via winget (per-user, no admin needed)..."
winget install -e --id Ollama.Ollama --silent --accept-package-agreements --accept-source-agreements
if ($LASTEXITCODE -ne 0) { Write-Error "winget install failed (exit $LASTEXITCODE). Install manually from https://ollama.com/download" }
if (-not (Test-Path $defaultPath)) { Write-Error "Ollama installed but not found at $defaultPath - open a new terminal and re-run." }
$ollama = @{ Source = $defaultPath }
}
}
# Start the server if it is not already up.
try {
Invoke-RestMethod 'http://127.0.0.1:11434/api/version' -TimeoutSec 3 | Out-Null
Write-Host "Ollama server already running."
} catch {
Write-Host "Starting Ollama server..."
Start-Process -FilePath $ollama.Source -ArgumentList 'serve' -WindowStyle Hidden
$deadline = (Get-Date).AddSeconds(30)
while ((Get-Date) -lt $deadline) {
Start-Sleep -Seconds 1
try { Invoke-RestMethod 'http://127.0.0.1:11434/api/version' -TimeoutSec 2 | Out-Null; break } catch {}
}
}
$doctorArgs = @('scripts/doctor.mjs', 'setup')
if ($CoreOnly) { $doctorArgs += '--core-only' }
if ($Global) { $doctorArgs += '--global' }
& node @doctorArgs
exit $LASTEXITCODE