-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup.ps1
More file actions
116 lines (100 loc) · 4.38 KB
/
setup.ps1
File metadata and controls
116 lines (100 loc) · 4.38 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
# OpenClaw Optimization Setup Script (Windows)
# Run: powershell -ExecutionPolicy Bypass -File setup.ps1
$ErrorActionPreference = "Continue"
$Workspace = if ($env:OPENCLAW_WORKSPACE) { $env:OPENCLAW_WORKSPACE } else { "$env:USERPROFILE\.openclaw\workspace" }
$Config = "$env:USERPROFILE\.openclaw\openclaw.json"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " OpenClaw Optimization Setup" -ForegroundColor Cyan
Write-Host " By Terp AI Labs (@OnlyTerp)" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host ""
# Step 1: Backup
Write-Host "[1/5] Backing up config..." -ForegroundColor Yellow
if (Test-Path $Config) {
Copy-Item $Config "$Config.bak" -Force
Write-Host " OK Backed up to $Config.bak" -ForegroundColor Green
} else {
Write-Host " WARN No config found — skipping backup" -ForegroundColor DarkYellow
}
# Step 2: Create vault structure
Write-Host "[2/5] Creating vault directory structure..." -ForegroundColor Yellow
$dirs = @("vault\projects","vault\people","vault\decisions","vault\lessons","vault\reference","vault\research","memory")
foreach ($d in $dirs) {
New-Item -ItemType Directory -Path "$Workspace\$d" -Force | Out-Null
}
Write-Host " OK vault/ and memory/ directories created" -ForegroundColor Green
# Step 3: Install template files
Write-Host "[3/5] Installing optimized workspace files..." -ForegroundColor Yellow
function Install-Template {
param($FileName, $MaxKB)
$target = "$Workspace\$FileName"
$source = "$ScriptDir\templates\$FileName"
if (-not (Test-Path $target)) {
Copy-Item $source $target
Write-Host " OK Created $FileName" -ForegroundColor Green
} else {
$size = (Get-Item $target).Length
$maxBytes = $MaxKB * 1024
if ($size -gt $maxBytes) {
Copy-Item $target "$target.pre-optimize" -Force
Copy-Item $source $target -Force
$sizeKB = [math]::Round($size/1024)
Write-Host " OK Optimized $FileName (was ${sizeKB}KB, backed up)" -ForegroundColor Green
} else {
Write-Host " SKIP $FileName already under ${MaxKB}KB" -ForegroundColor DarkGray
}
}
}
Install-Template "SOUL.md" 2
Install-Template "AGENTS.md" 3
Install-Template "MEMORY.md" 4
Install-Template "TOOLS.md" 2
# Step 4: Ollama
Write-Host "[4/5] Setting up Ollama + nomic-embed-text..." -ForegroundColor Yellow
$ollamaPath = Get-Command ollama -ErrorAction SilentlyContinue
if ($ollamaPath) {
Write-Host " OK Ollama already installed" -ForegroundColor Green
} else {
Write-Host " Installing Ollama..." -ForegroundColor Yellow
winget install Ollama.Ollama --accept-package-agreements --accept-source-agreements 2>$null
Write-Host " OK Ollama installed (restart terminal to use)" -ForegroundColor Green
}
$models = ollama list 2>$null
if ($models -match "nomic-embed-text") {
Write-Host " OK nomic-embed-text already available" -ForegroundColor Green
} else {
Write-Host " Pulling nomic-embed-text (300MB)..." -ForegroundColor Yellow
ollama pull nomic-embed-text
Write-Host " OK nomic-embed-text ready" -ForegroundColor Green
}
# Step 5: Verify
Write-Host "[5/5] Verifying setup..." -ForegroundColor Yellow
Write-Host ""
$totalSize = 0
foreach ($f in @("SOUL.md","AGENTS.md","MEMORY.md","TOOLS.md")) {
$path = "$Workspace\$f"
if (Test-Path $path) {
$size = (Get-Item $path).Length
$totalSize += $size
Write-Host " $f`: $size bytes"
}
}
Write-Host " --------------------"
$totalKB = [math]::Round($totalSize/1024)
Write-Host " Total context: $totalSize bytes (${totalKB}KB)"
Write-Host ""
if ($totalSize -lt 8192) {
Write-Host " OK Context under 8KB — you're optimized!" -ForegroundColor Green
} else {
Write-Host " WARN Context over 8KB — consider trimming further" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " Setup complete!" -ForegroundColor Green
Write-Host ""
Write-Host " Next steps:"
Write-Host " 1. Restart gateway: openclaw gateway stop; openclaw gateway start"
Write-Host " 2. Move detailed docs from MEMORY.md to vault/ files"
Write-Host " 3. Test: ask your bot about a past project"
Write-Host "==========================================" -ForegroundColor Cyan