-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·44 lines (37 loc) · 1.23 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.23 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
#!/usr/bin/env bash
# avoid-ai -- install script
# Copies plugin to ~/.claude/plugins/avoid-ai and registers it.
set -euo pipefail
PLUGIN_NAME="avoid-ai"
CLAUDE_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
PLUGIN_DIR="$CLAUDE_DIR/plugins/$PLUGIN_NAME"
SETTINGS="$CLAUDE_DIR/settings.json"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Installing $PLUGIN_NAME..."
# 1. Copy plugin files
mkdir -p "$PLUGIN_DIR"
cp -r "$SCRIPT_DIR/." "$PLUGIN_DIR/"
echo " Copied plugin to $PLUGIN_DIR"
# 2. Register in settings.json
if [ ! -f "$SETTINGS" ]; then
echo '{}' > "$SETTINGS"
fi
# Use node to safely merge plugin entry into settings JSON
node - <<EOF
const fs = require('fs');
const p = '$SETTINGS';
let s = {};
try { s = JSON.parse(fs.readFileSync(p, 'utf8')); } catch(e) {}
if (!s.plugins) s.plugins = [];
const already = s.plugins.some(pl => (typeof pl === 'string' ? pl : pl.path) === '$PLUGIN_DIR');
if (!already) {
s.plugins.push('$PLUGIN_DIR');
fs.writeFileSync(p, JSON.stringify(s, null, 2) + '\n', 'utf8');
console.log(' Registered plugin in ' + p);
} else {
console.log(' Plugin already registered in ' + p);
}
EOF
echo ""
echo "Done. Restart Claude Code to activate."
echo "First response will confirm with: avoid-ai: on"