-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (91 loc) · 4.37 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·105 lines (91 loc) · 4.37 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
102
103
104
105
#!/usr/bin/env bash
# claude-sync — one-shot installer.
# Idempotent: safe to re-run; backs up your existing settings.json each time.
set -e
# ───────── Where things go ─────────
CLAUDE_DIR="$HOME/.claude"
SKILL_DIR="$CLAUDE_DIR/skills/prompt-quality-coaching"
SCRIPTS_DIR="$CLAUDE_DIR/scripts"
STATE_FILE="$CLAUDE_DIR/sync_state.json"
RES_FILE="$CLAUDE_DIR/sync_resources.json"
WRAPPER="$CLAUDE_DIR/statusline_with_sync.sh"
SETTINGS="$CLAUDE_DIR/settings.json"
# ───────── Pre-checks ─────────
if ! command -v jq >/dev/null 2>&1; then
echo "❌ jq is required. Install it (macOS: brew install jq; Debian: apt install jq) and re-run."
exit 1
fi
if [ ! -d "$CLAUDE_DIR" ]; then
echo "ℹ Creating $CLAUDE_DIR"
mkdir -p "$CLAUDE_DIR"
fi
mkdir -p "$SKILL_DIR" "$SCRIPTS_DIR"
# ───────── Resolve source dir (this script's location) ─────────
SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ───────── Copy skill ─────────
cp "$SRC/skills/prompt-quality-coaching/SKILL.md" "$SKILL_DIR/SKILL.md"
echo "✓ Skill installed: $SKILL_DIR/SKILL.md"
# ───────── Copy scripts ─────────
cp "$SRC/scripts/update_sync.sh" "$SCRIPTS_DIR/"
cp "$SRC/scripts/sync_report.sh" "$SCRIPTS_DIR/"
chmod +x "$SCRIPTS_DIR/update_sync.sh" "$SCRIPTS_DIR/sync_report.sh"
echo "✓ Scripts installed in $SCRIPTS_DIR"
# ───────── Copy resources catalog (don't overwrite if user customized it) ─────────
if [ -f "$RES_FILE" ]; then
echo "ℹ $RES_FILE already exists — keeping yours. Diff against the new template:"
diff -q "$RES_FILE" "$SRC/sync_resources.json" || true
else
cp "$SRC/sync_resources.json" "$RES_FILE"
echo "✓ Resources catalog seeded at $RES_FILE"
fi
# ───────── Init state if missing ─────────
if [ ! -f "$STATE_FILE" ]; then
cp "$SRC/sync_state.json.example" "$STATE_FILE"
echo "✓ Fresh sync_state.json initialized at 100%"
else
CURRENT=$(jq -r '.score' "$STATE_FILE" 2>/dev/null || echo "?")
echo "ℹ Existing sync_state.json kept (current score: ${CURRENT}%)"
fi
# ───────── Install statusline wrapper ─────────
cp "$SRC/statusline_with_sync.sh" "$WRAPPER"
chmod +x "$WRAPPER"
echo "✓ Statusline wrapper installed at $WRAPPER"
# ───────── Wire up settings.json (optional) ─────────
if [ -f "$SETTINGS" ]; then
BACKUP="$SETTINGS.bak.$(date +%Y%m%d-%H%M%S)"
cp "$SETTINGS" "$BACKUP"
echo "ℹ Backed up settings.json → $BACKUP"
CURRENT_CMD=$(jq -r '.statusLine.command // ""' "$SETTINGS")
if [ "$CURRENT_CMD" = "bash $WRAPPER" ]; then
echo "✓ statusLine already pointing to the wrapper"
else
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "Your current statusLine command is:"
echo " $CURRENT_CMD"
echo ""
echo "The wrapper expects to RUN your existing statusline first, then"
echo "append the Sync badge. Edit ~/.claude/statusline_with_sync.sh and"
echo "replace the line that calls your statusline with your real one,"
echo "OR just leave the default and the wrapper will skip the prefix."
echo ""
echo "To activate Sync in your statusline, set:"
echo " jq '.statusLine.command = \"bash $WRAPPER\"' $SETTINGS > /tmp/x \\"
echo " && mv /tmp/x $SETTINGS"
echo "═══════════════════════════════════════════════════════════════"
fi
else
echo "ℹ No settings.json found. To enable the Sync badge in your statusline:"
echo " echo '{\"statusLine\":{\"type\":\"command\",\"command\":\"bash $WRAPPER\"}}' > $SETTINGS"
fi
echo ""
echo "🎉 claude-sync installed."
echo ""
echo "Try it:"
echo " ~/.claude/scripts/sync_report.sh"
echo " ~/.claude/scripts/update_sync.sh clean \"first install\""
echo ""
echo "Skill is now discoverable by Claude. Trigger phrases:"
echo " • \"What is my sync?\" → current score"
echo " • \"Give me recommendations\" → study suggestions"
echo " • \"How did this session go?\" → session summary"