-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
88 lines (79 loc) · 2.91 KB
/
install.sh
File metadata and controls
88 lines (79 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
#!/usr/bin/env bash
set -euo pipefail
# OpenClaw Skill Security Scoring Patch Installer
# Usage: cd <openclaw-repo-root> && bash <path-to>/install.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PATCH_DIR="$SCRIPT_DIR"
# Verify we're in an openclaw repo
if [ ! -f "package.json" ] || ! grep -q '"openclaw"' package.json 2>/dev/null; then
echo "ERROR: Run this script from the openclaw repository root."
echo "Usage: cd /path/to/openclaw && bash $0"
exit 1
fi
echo "=== OpenClaw Skill Security Scoring Patch Installer ==="
echo ""
# Step 1: Copy new files
echo "[1/3] Copying new files..."
cp -v "$PATCH_DIR/new-files/src/agents/skills/security-score.ts" "src/agents/skills/security-score.ts"
cp -v "$PATCH_DIR/new-files/src/agents/skills/security-score.test.ts" "src/agents/skills/security-score.test.ts"
cp -v "$PATCH_DIR/new-files/src/config/config.skills-security.test.ts" "src/config/config.skills-security.test.ts"
echo ""
# Step 2: Apply patch to existing files
echo "[2/3] Applying patch to existing files..."
if git apply --check "$PATCH_DIR/patches/skill-security-scoring.patch" 2>/dev/null; then
git apply "$PATCH_DIR/patches/skill-security-scoring.patch"
echo "Patch applied successfully."
else
echo "WARNING: git apply --check failed. Trying with --3way merge..."
if git apply --3way "$PATCH_DIR/patches/skill-security-scoring.patch"; then
echo "Patch applied with 3-way merge."
else
echo "ERROR: Patch failed. You may need to apply manually."
echo "Patch file: $PATCH_DIR/patches/skill-security-scoring.patch"
echo ""
echo "Modified files:"
echo " - src/agents/skills/types.ts"
echo " - src/config/types.skills.ts"
echo " - src/config/zod-schema.ts"
echo " - src/agents/skills-install.ts"
echo " - src/cli/skills-cli.ts"
exit 1
fi
fi
echo ""
# Step 3: Verify
echo "[3/3] Verifying installation..."
MISSING=0
for f in \
"src/agents/skills/security-score.ts" \
"src/agents/skills/security-score.test.ts" \
"src/config/config.skills-security.test.ts"; do
if [ ! -f "$f" ]; then
echo " MISSING: $f"
MISSING=1
else
echo " OK: $f"
fi
done
if [ $MISSING -eq 1 ]; then
echo ""
echo "WARNING: Some files are missing. Check the output above."
exit 1
fi
echo ""
echo "=== Installation complete ==="
echo ""
echo "Configuration (add to your openclaw config):"
echo " skills:"
echo " security:"
echo " warnThreshold: 60 # Score >= 60 shows warning"
echo " blockThreshold: 85 # Score >= 85 blocks installation"
echo ""
echo "CLI commands:"
echo " openclaw skills audit # Audit all skills"
echo " openclaw skills audit --verbose # Show per-dimension details"
echo " openclaw skills audit --skill foo # Audit a specific skill"
echo " openclaw skills audit --no-cache # Force re-scoring"
echo ""
echo "Run tests:"
echo " npx vitest run src/agents/skills/security-score.test.ts src/config/config.skills-security.test.ts"