-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.ps1
More file actions
89 lines (77 loc) · 2.91 KB
/
Copy pathuninstall.ps1
File metadata and controls
89 lines (77 loc) · 2.91 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
# OpenClaw Guardian Safety Agent — Uninstall Script (Windows)
# Usage: .\uninstall.ps1 -OpenClawRoot C:\path\to\openclaw
param(
[Parameter(Mandatory=$true)]
[string]$OpenClawRoot
)
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$OpenClawRoot = Resolve-Path $OpenClawRoot
if (-not (Test-Path "$OpenClawRoot\package.json")) {
Write-Error "Error: $OpenClawRoot does not look like an OpenClaw repo"
exit 1
}
Write-Host "=== OpenClaw Guardian Safety Agent - Uninstall ===" -ForegroundColor Cyan
Write-Host "Target: $OpenClawRoot"
Write-Host ""
# --- Step 1: Remove new files ---
Write-Host "[1/2] Removing guardian files..." -ForegroundColor Yellow
$NewFiles = @(
"src\security\guardian-types.ts",
"src\security\guardian-agent.ts",
"src\security\guardian-audit.ts",
"src\security\guardian-risk.ts",
"src\security\guardian-agent.test.ts",
"src\security\guardian-audit.test.ts",
"src\security\guardian-config.test.ts",
"src\security\guardian-hook.test.ts",
"src\security\guardian-risk.test.ts",
"src\security\guardian-scenario.test.ts"
)
foreach ($f in $NewFiles) {
$target = Join-Path $OpenClawRoot $f
if (Test-Path $target) {
Remove-Item $target -Force
Write-Host " - $f" -ForegroundColor Red
}
# Restore backup if exists.
if (Test-Path "$target.bak") {
Move-Item "$target.bak" $target -Force
Write-Host " Restored $f from backup" -ForegroundColor Green
}
}
# --- Step 2: Revert patches ---
Write-Host ""
Write-Host "[2/2] Reverting patches on modified files..." -ForegroundColor Yellow
$PatchFile = Join-Path $ScriptDir "patches\modified-files.patch"
$ModifiedFiles = @(
"src\agents\pi-tools.before-tool-call.ts",
"src\agents\pi-tools.ts",
"src\agents\pi-embedded-runner\run\attempt.ts",
"src\config\types.openclaw.ts",
"src\plugins\registry.ts",
"src\plugins\tools.ts",
"src\plugins\types.ts"
)
if (-not (Test-Path $PatchFile)) {
Write-Host " Warning: Patch file not found. Cannot auto-revert." -ForegroundColor DarkYellow
$fileList = ($ModifiedFiles -join " ")
Write-Host " Try: cd $OpenClawRoot; git checkout -- $fileList" -ForegroundColor DarkYellow
} else {
Push-Location $OpenClawRoot
try {
git apply --check -R $PatchFile 2>$null
if ($LASTEXITCODE -eq 0) {
git apply -R $PatchFile
Write-Host " Reverted via git apply -R" -ForegroundColor Green
} else {
Write-Host " Warning: Could not cleanly revert patches." -ForegroundColor DarkYellow
Write-Host " Try manually: git checkout -- $($ModifiedFiles -join ' ')" -ForegroundColor DarkYellow
}
} finally {
Pop-Location
}
}
Write-Host ""
Write-Host "=== Uninstall complete ===" -ForegroundColor Green
Write-Host "Don't forget to remove the 'safety' key from your openclaw.json config." -ForegroundColor Cyan