-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
101 lines (91 loc) · 3.64 KB
/
install.ps1
File metadata and controls
101 lines (91 loc) · 3.64 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
# OpenClaw Skill Security Scoring Patch Installer (Windows PowerShell)
# Usage: cd <openclaw-repo-root>; .\<path-to>\install.ps1
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$PatchDir = $ScriptDir
# Verify we're in an openclaw repo
if (-not (Test-Path "package.json")) {
Write-Error "ERROR: Run this script from the openclaw repository root."
exit 1
}
$pkgContent = Get-Content "package.json" -Raw
if ($pkgContent -notmatch '"openclaw"') {
Write-Error "ERROR: Run this script from the openclaw repository root."
exit 1
}
Write-Host "=== OpenClaw Skill Security Scoring Patch Installer ===" -ForegroundColor Cyan
Write-Host ""
# Step 1: Copy new files
Write-Host "[1/3] Copying new files..." -ForegroundColor Yellow
Copy-Item "$PatchDir\new-files\src\agents\skills\security-score.ts" "src\agents\skills\security-score.ts" -Force
Write-Host " Copied: src\agents\skills\security-score.ts"
Copy-Item "$PatchDir\new-files\src\agents\skills\security-score.test.ts" "src\agents\skills\security-score.test.ts" -Force
Write-Host " Copied: src\agents\skills\security-score.test.ts"
Copy-Item "$PatchDir\new-files\src\config\config.skills-security.test.ts" "src\config\config.skills-security.test.ts" -Force
Write-Host " Copied: src\config\config.skills-security.test.ts"
Write-Host ""
# Step 2: Apply patch
Write-Host "[2/3] Applying patch to existing files..." -ForegroundColor Yellow
$patchFile = "$PatchDir\patches\skill-security-scoring.patch"
$checkResult = git apply --check $patchFile 2>&1
if ($LASTEXITCODE -eq 0) {
git apply $patchFile
Write-Host "Patch applied successfully." -ForegroundColor Green
} else {
Write-Host "WARNING: git apply --check failed. Trying with --3way merge..." -ForegroundColor Yellow
git apply --3way $patchFile
if ($LASTEXITCODE -eq 0) {
Write-Host "Patch applied with 3-way merge." -ForegroundColor Green
} else {
Write-Error @"
ERROR: Patch failed. You may need to apply manually.
Patch file: $patchFile
Modified files:
- src/agents/skills/types.ts
- src/config/types.skills.ts
- src/config/zod-schema.ts
- src/agents/skills-install.ts
- src/cli/skills-cli.ts
"@
exit 1
}
}
Write-Host ""
# Step 3: Verify
Write-Host "[3/3] Verifying installation..." -ForegroundColor Yellow
$missing = 0
$files = @(
"src\agents\skills\security-score.ts",
"src\agents\skills\security-score.test.ts",
"src\config\config.skills-security.test.ts"
)
foreach ($f in $files) {
if (Test-Path $f) {
Write-Host " OK: $f" -ForegroundColor Green
} else {
Write-Host " MISSING: $f" -ForegroundColor Red
$missing = 1
}
}
if ($missing -eq 1) {
Write-Host ""
Write-Warning "Some files are missing. Check the output above."
exit 1
}
Write-Host ""
Write-Host "=== Installation complete ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "Configuration (add to your openclaw config):" -ForegroundColor White
Write-Host " skills:"
Write-Host " security:"
Write-Host " warnThreshold: 60 # Score >= 60 shows warning"
Write-Host " blockThreshold: 85 # Score >= 85 blocks installation"
Write-Host ""
Write-Host "CLI commands:" -ForegroundColor White
Write-Host " openclaw skills audit # Audit all skills"
Write-Host " openclaw skills audit --verbose # Show per-dimension details"
Write-Host " openclaw skills audit --skill foo # Audit a specific skill"
Write-Host " openclaw skills audit --no-cache # Force re-scoring"
Write-Host ""
Write-Host "Run tests:" -ForegroundColor White
Write-Host " npx vitest run src/agents/skills/security-score.test.ts src/config/config.skills-security.test.ts"