-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup.ps1
More file actions
90 lines (80 loc) · 3.11 KB
/
Copy pathsetup.ps1
File metadata and controls
90 lines (80 loc) · 3.11 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
<#
.SYNOPSIS
Evolving Lite - post-clone setup for Windows (PowerShell).
.DESCRIPTION
Cross-platform companion to setup.sh for users who do not run Git Bash.
hooks/hooks.json ships with ${CLAUDE_PLUGIN_ROOT} placeholders that Claude Code
substitutes itself, so this script only VALIDATES the file (it never rewrites
paths). Optionally provisions the Windows venv + kairn-ai, then runs the Doctor.
.PARAMETER SetupVenv
Also create ./venv (at the repo root, two levels up from the plugin) and
pip install kairn-ai into it. The kairn MCP server expects ./venv/Scripts/kairn.exe.
.EXAMPLE
powershell -ExecutionPolicy Bypass -File .\setup.ps1
powershell -ExecutionPolicy Bypass -File .\setup.ps1 -SetupVenv
#>
[CmdletBinding()]
param(
[switch]$SetupVenv
)
$ErrorActionPreference = 'Stop'
$PluginRoot = $PSScriptRoot
$HooksFile = Join-Path $PluginRoot 'hooks\hooks.json'
Write-Host "Evolving Lite setup (PowerShell)"
Write-Host "Plugin root: $PluginRoot"
if (-not (Test-Path $HooksFile)) {
Write-Error "hooks.json not found at $HooksFile"
exit 1
}
# Resolve a Python interpreter (python, then py launcher, then python3).
$Py = $null
foreach ($cand in @('python', 'py', 'python3')) {
$cmd = Get-Command $cand -ErrorAction SilentlyContinue
if ($cmd) { $Py = $cmd.Source; break }
}
if (-not $Py) {
Write-Error "No Python interpreter on PATH (need 3.10+)."
exit 1
}
# Validate hooks.json: parseable JSON, no merge markers, placeholder present.
$raw = Get-Content -Raw -Encoding UTF8 $HooksFile
if ($raw -match '<<<<<<<' -or $raw -match '>>>>>>>') {
Write-Error "hooks.json contains unresolved merge-conflict markers."
exit 1
}
try {
$null = $raw | ConvertFrom-Json
} catch {
Write-Error "hooks.json is not valid JSON: $_"
exit 1
}
if ($raw -notmatch '\$\{CLAUDE_PLUGIN_ROOT\}') {
Write-Warning "hooks.json has no `${CLAUDE_PLUGIN_ROOT}` placeholder; paths may be hardcoded."
} else {
Write-Host "hooks.json: valid JSON, portable placeholders present."
}
# Optional: provision the Windows venv + kairn-ai at the repo root.
$RepoRoot = (Resolve-Path (Join-Path $PluginRoot '..\..\..')).Path
$VenvDir = Join-Path $RepoRoot 'venv'
if ($SetupVenv) {
if (-not (Test-Path (Join-Path $VenvDir 'Scripts\python.exe'))) {
Write-Host "Creating venv at $VenvDir ..."
& $Py -m venv $VenvDir
}
$VenvPy = Join-Path $VenvDir 'Scripts\python.exe'
Write-Host "Installing kairn-ai into venv ..."
& $VenvPy -m pip install --quiet --upgrade pip
& $VenvPy -m pip install --quiet kairn-ai
& (Join-Path $VenvDir 'Scripts\kairn.exe') --version
} else {
Write-Host ""
Write-Host "Kairn (memory-layer prerequisite) not provisioned. To set it up:"
Write-Host " .\setup.ps1 -SetupVenv"
Write-Host "The kairn MCP server is configured to use .\venv\Scripts\kairn.exe."
}
# Run the Self-Star Doctor (re-runnable any time via /health). -X utf8 so the
# cp1252 console codec never breaks UTF-8 file reads or the board glyphs.
Write-Host ""
Write-Host "Running the Self-Star Doctor..."
$env:CLAUDE_PLUGIN_ROOT = $PluginRoot
& $Py -X utf8 (Join-Path $PluginRoot 'scripts\doctor.py')