-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
143 lines (122 loc) · 6.98 KB
/
Copy pathsetup.ps1
File metadata and controls
143 lines (122 loc) · 6.98 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
# ─────────────────────────────────────────────────────────
# context-forge setup wizard (Windows PowerShell)
# ─────────────────────────────────────────────────────────
param()
function Write-Header($msg) { Write-Host "`n> $msg" -ForegroundColor Blue }
function Write-Ok($msg) { Write-Host " [OK] $msg" -ForegroundColor Green }
function Write-Warn($msg) { Write-Host " [!] $msg" -ForegroundColor Yellow }
function Write-Err($msg) { Write-Host " [X] $msg" -ForegroundColor Red }
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " context-forge setup " -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
# ─── Prerequisites ────────────────────────────────────────
Write-Header "Checking prerequisites"
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
Write-Err "Docker not found. Install Docker Desktop: https://docs.docker.com/desktop/windows/"
exit 1
}
Write-Ok "Docker found"
try {
docker compose version | Out-Null
Write-Ok "Docker Compose v2 found"
} catch {
Write-Err "Docker Compose v2 not found. Update Docker Desktop."
exit 1
}
# ─── .env ─────────────────────────────────────────────────
Write-Header "Environment configuration"
if (Test-Path ".env") {
Write-Warn ".env already exists, skipping creation"
} else {
Copy-Item ".env.example" ".env"
Write-Ok "Created .env from .env.example"
# Generate random Postgres password
$pgPass = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Guid]::NewGuid().ToString("N"))).Substring(0, 24)
(Get-Content ".env") -replace "changeme_strong_password", $pgPass | Set-Content ".env"
Write-Ok "Generated random Postgres password"
# Generate random first-run bootstrap token (the web onboarding wizard asks for it once)
$bootstrapToken = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Guid]::NewGuid().ToString("N") + [System.Guid]::NewGuid().ToString("N"))).Substring(0, 32)
(Get-Content ".env") -replace "change_this_bootstrap_token", $bootstrapToken | Set-Content ".env"
Write-Ok "Generated SETUP_BOOTSTRAP_TOKEN: $bootstrapToken"
Write-Warn "The web UI setup wizard will ask for this token (it stays in .env)"
# Guard GET /metrics by default; empty METRICS_TOKEN in .env to open it up
$metricsToken = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Guid]::NewGuid().ToString("N") + [System.Guid]::NewGuid().ToString("N"))).Substring(0, 32)
(Get-Content ".env") -replace '^METRICS_TOKEN=$', "METRICS_TOKEN=$metricsToken" | Set-Content ".env"
Write-Ok "Generated METRICS_TOKEN: $metricsToken"
Write-Host ""
Write-Host " Please edit .env and set:" -ForegroundColor Yellow
Write-Host " OPENAI_API_KEY (required for OpenAI embeddings)" -ForegroundColor Yellow
Write-Host " GITHUB_TOKEN (optional, for private GitHub repos)" -ForegroundColor Yellow
Write-Host " GITLAB_TOKEN (optional, for GitLab repos)" -ForegroundColor Yellow
Write-Host ""
$open = Read-Host " Open .env in Notepad? [Y/n]"
if ($open -eq "" -or $open -match "^[Yy]") {
notepad .env
Write-Host " Press Enter when done editing..." -ForegroundColor Cyan
Read-Host
}
}
# ─── context-forge.yml ────────────────────────────────────
Write-Header "Repository configuration"
if (Test-Path "context-forge.yml") {
Write-Warn "context-forge.yml already exists, skipping"
} else {
Copy-Item "context-forge.yml.example" "context-forge.yml"
Write-Ok "Created context-forge.yml from example"
Write-Warn "Edit context-forge.yml to add your repositories"
}
# ─── docker-compose.override.yml ──────────────────────────
Write-Header "Volume mounts for local repos"
if (Test-Path "docker-compose.override.yml") {
Write-Warn "docker-compose.override.yml already exists"
} else {
Copy-Item "docker-compose.override.yml.example" "docker-compose.override.yml"
Write-Ok "Created docker-compose.override.yml"
Write-Warn "Edit docker-compose.override.yml to mount your local repo paths (use forward slashes: C:/Users/...)"
}
# ─── Start services ───────────────────────────────────────
Write-Header "Starting context-forge"
Write-Host ""
$startNow = Read-Host " Start services now? [Y/n]"
if ($startNow -eq "" -or $startNow -match "^[Yy]") {
docker compose build --quiet
docker compose up -d
Write-Host ""
Write-Ok "Services started!"
Write-Host ""
Write-Host " Waiting for services to be ready..." -ForegroundColor Gray
Start-Sleep -Seconds 8
try {
$resp = Invoke-WebRequest -Uri "http://localhost:8000/api/health" -UseBasicParsing -TimeoutSec 5
Write-Ok "API is healthy"
} catch {
Write-Warn "API not yet ready - may still be initializing (check: docker compose logs context-forge)"
}
Write-Host ""
Write-Host " context-forge is running!" -ForegroundColor Green
Write-Host ""
Write-Host " --- Endpoints -----------------------------------" -ForegroundColor Cyan
Write-Host " | MCP server: http://localhost:4000/mcp |" -ForegroundColor Cyan
Write-Host " | REST API: http://localhost:8000/api |" -ForegroundColor Cyan
Write-Host " | Web UI: http://localhost:3000 |" -ForegroundColor Cyan
Write-Host " ------------------------------------------------" -ForegroundColor Cyan
} else {
Write-Host ""
Write-Host " Run manually with: docker compose up -d"
}
# ─── Agent connection ─────────────────────────────────────
Write-Host ""
Write-Header "Connect your AI agent"
Write-Host ""
Write-Host " Claude Code:" -ForegroundColor White
Write-Host " claude mcp add --transport http context-forge http://localhost:4000/mcp" -ForegroundColor Yellow
Write-Host ""
Write-Host " Cursor - add to .cursor\mcp.json:" -ForegroundColor White
Write-Host ' {"mcpServers": {"context-forge": {"url": "http://localhost:4000/mcp"}}}' -ForegroundColor Yellow
Write-Host ""
Write-Host " Copy system prompt to your project:" -ForegroundColor White
Write-Host " Copy-Item templates\CLAUDE.md C:\path\to\your\project\CLAUDE.md" -ForegroundColor Yellow
Write-Host ""
Write-Host " Full docs: docs\claude-code.md | docs\cursor.md | docs\codex.md" -ForegroundColor Gray
Write-Host ""