forked from d8ahazard/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
85 lines (72 loc) · 1.96 KB
/
setup.ps1
File metadata and controls
85 lines (72 loc) · 1.96 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
$ErrorActionPreference = "Stop"
function Write-Section($text) {
Write-Host ""
Write-Host "== $text =="
}
function Read-SecretPlain($prompt) {
$secure = Read-Host -Prompt $prompt -AsSecureString
if (-not $secure) { return "" }
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try { return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) }
}
Write-Section "Overmind setup (Windows)"
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $repoRoot
Write-Section "Python virtual environment"
$pythonCmd = $null
try {
& py -3 --version | Out-Null
$pythonCmd = "py -3"
} catch {
$pythonCmd = "python"
}
if (-not (Test-Path ".venv")) {
Write-Host "Creating .venv..."
& $pythonCmd -m venv .venv
}
Write-Host "Activating .venv..."
. .\.venv\Scripts\Activate.ps1
Write-Section "Install backend dependencies"
python -m pip install --upgrade pip
pip install -r requirements.txt
Write-Section "Build UI"
if (Test-Path "ui/package.json") {
Push-Location ui
if (Test-Path "package-lock.json") {
npm ci
} else {
npm install
}
npm run build
Pop-Location
}
Write-Section "Configure API keys"
$providers = @(
"OPENAI_API_KEY",
"ANTHROPIC_API_KEY",
"GROQ_API_KEY",
"GEMINI_API_KEY"
)
$setVars = @{}
foreach ($name in $providers) {
$answer = Read-Host -Prompt "Set $name? (y/N)"
if ($answer -match "^[Yy]") {
$value = Read-SecretPlain "Enter $name"
if ($value) {
$env:$name = $value
$setVars[$name] = $value
}
}
}
$persist = Read-Host -Prompt "Persist these variables for your user profile? (y/N)"
if ($persist -match "^[Yy]") {
foreach ($kv in $setVars.GetEnumerator()) {
setx $kv.Key $kv.Value | Out-Null
}
Write-Host "Saved. Restart your shell to pick up persisted variables."
}
Write-Section "Done"
Write-Host "To run:"
Write-Host " .\\.venv\\Scripts\\Activate.ps1"
Write-Host " python -m app --self"