-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
74 lines (63 loc) · 2.34 KB
/
Copy pathuninstall.sh
File metadata and controls
74 lines (63 loc) · 2.34 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
#!/usr/bin/env bash
set -euo pipefail
# OpenClaw Guardian Safety Agent — Uninstall Script
# Usage: ./uninstall.sh /path/to/openclaw
if [ $# -lt 1 ]; then
echo "Usage: $0 <openclaw-root-dir>"
exit 1
fi
OPENCLAW_ROOT="$(cd "$1" && pwd)"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if [ ! -f "$OPENCLAW_ROOT/package.json" ]; then
echo "Error: $OPENCLAW_ROOT does not look like an OpenClaw repo"
exit 1
fi
echo "=== OpenClaw Guardian Safety Agent — Uninstall ==="
echo "Target: $OPENCLAW_ROOT"
echo ""
# --- Step 1: Remove new files ---
echo "[1/2] Removing guardian files..."
NEW_FILES=(
"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"
)
for f in "${NEW_FILES[@]}"; do
target="$OPENCLAW_ROOT/$f"
if [ -f "$target" ]; then
rm "$target"
echo " - $f"
fi
# Restore backup if exists.
if [ -f "$target.bak" ]; then
mv "$target.bak" "$target"
echo " Restored $f from backup"
fi
done
# --- Step 2: Revert patches ---
echo ""
echo "[2/2] Reverting patches on modified files..."
PATCH_FILE="$SCRIPT_DIR/patches/modified-files.patch"
if [ ! -f "$PATCH_FILE" ]; then
echo " Warning: Patch file not found. Cannot auto-revert modified files."
echo " You may need to run: cd $OPENCLAW_ROOT && git checkout -- 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"
else
cd "$OPENCLAW_ROOT"
if git apply --check -R "$PATCH_FILE" 2>/dev/null; then
git apply -R "$PATCH_FILE"
echo " Reverted via git apply -R"
else
echo " Warning: Could not cleanly revert patches."
echo " Try manually: cd $OPENCLAW_ROOT && git checkout -- 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"
fi
fi
echo ""
echo "=== Uninstall complete ==="
echo "Don't forget to remove the 'safety' key from your openclaw.json config."