-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
133 lines (108 loc) · 4.79 KB
/
install.sh
File metadata and controls
133 lines (108 loc) · 4.79 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
# practice — install script
#
# Run from any project root. Copies the /init skill + templates into your
# project so Claude Code can scaffold the harness on your codebase.
#
# Usage:
# ./install.sh [--upgrade]
#
# Flags:
# --upgrade Overwrite existing .claude/skills/init/SKILL.md and templates.
# Use this when pulling a new practice version against a project
# that already ran /init at least once.
set -euo pipefail
PROJECT_ROOT="$(pwd)"
PRACTICE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UPGRADE=0
for arg in "$@"; do
case "$arg" in
--upgrade) UPGRADE=1 ;;
-h|--help)
sed -n '2,/^set -e/p' "${BASH_SOURCE[0]}" | sed 's/^# \?//'
exit 0
;;
*)
echo "✗ Unknown argument: $arg" >&2
exit 2
;;
esac
done
# ---------- Sanity checks ----------
if [ ! -d "$PROJECT_ROOT/.git" ]; then
echo "✗ Not a git repository. practice requires a git project." >&2
echo " Run 'git init' first, then re-run this installer." >&2
exit 1
fi
if [ ! -d "$PRACTICE_ROOT/.claude/skills/init" ] || [ ! -d "$PRACTICE_ROOT/templates" ]; then
echo "✗ practice install corrupt — expected $PRACTICE_ROOT/.claude/skills/init and $PRACTICE_ROOT/templates" >&2
exit 1
fi
if [ "$PROJECT_ROOT" = "$PRACTICE_ROOT" ]; then
echo "✗ Cannot install practice into itself." >&2
echo " Run install.sh from your target project's root, not from the practice repo." >&2
exit 1
fi
# ---------- Detect prior install ----------
if [ -d "$PROJECT_ROOT/.claude/skills/init" ] && [ "$UPGRADE" -eq 0 ]; then
echo "⚠ Existing practice install detected at .claude/skills/init/"
echo " Re-run with --upgrade to overwrite, or run /init mode: replan in Claude Code"
echo " to re-tune your specialist team without overwriting templates." >&2
exit 1
fi
# ---------- Working tree check ----------
if [ -n "$(git -C "$PROJECT_ROOT" status --porcelain 2>/dev/null)" ]; then
echo "⚠ Working tree is dirty. practice will create new files; commit or stash first."
echo " Continuing anyway in 5 seconds (Ctrl+C to abort)..."
sleep 5
fi
# ---------- Copy /init skill ----------
mkdir -p "$PROJECT_ROOT/.claude/skills/init"
cp "$PRACTICE_ROOT/.claude/skills/init/SKILL.md" "$PROJECT_ROOT/.claude/skills/init/SKILL.md"
echo "✓ Installed .claude/skills/init/SKILL.md"
# ---------- Make templates available to the init skill ----------
#
# The recommended install pattern clones practice INTO $PROJECT_ROOT/.practice/.
# In that case templates are already in place — no copy needed. We detect this
# via resolved-path equality and skip the cp (otherwise cp errors "same file"
# and aborts the script under set -e).
#
# When practice is cloned to a sibling/elsewhere, templates ARE copied into
# $PROJECT_ROOT/.practice/templates/ as the canonical cache the /init skill reads.
CACHE_DIR="$PROJECT_ROOT/.practice"
if [ "$PRACTICE_ROOT" = "$CACHE_DIR" ]; then
TEMPLATE_COUNT=$(find "$PRACTICE_ROOT/templates" -type f | wc -l | tr -d ' ')
echo "✓ Templates already in place at .practice/templates/ ($TEMPLATE_COUNT files, clone-in-place mode)"
else
mkdir -p "$CACHE_DIR"
cp -r "$PRACTICE_ROOT/templates/." "$CACHE_DIR/templates/"
TEMPLATE_COUNT=$(find "$CACHE_DIR/templates" -type f | wc -l | tr -d ' ')
echo "✓ Installed .practice/templates/ ($TEMPLATE_COUNT files)"
fi
# ---------- .gitignore the cache ----------
GITIGNORE="$PROJECT_ROOT/.gitignore"
if [ ! -f "$GITIGNORE" ] || ! grep -qE '^\.practice/?$' "$GITIGNORE"; then
echo "" >> "$GITIGNORE"
echo "# practice harness install cache (regenerated by ./install.sh --upgrade)" >> "$GITIGNORE"
echo ".practice/" >> "$GITIGNORE"
echo "✓ Added .practice/ to .gitignore"
fi
# ---------- Final guidance ----------
cat <<'EOF'
────────────────────────────────────────────────────────────────────────
practice installed.
Next step — in Claude Code, in your project root, run:
> /init
That will:
1. Read your project (stack, modules, domain hints)
2. Ask 5–7 targeted questions
3. Propose a tailored specialist team for your domain
4. After approval, scaffold the full harness (skills, agents, workflows,
planning folder, session log, commit-message convention)
5. Run a smoke test so you can verify the harness wires up
You're typically shipping verified work product within 10 minutes.
For a re-tune later: /init mode: replan
For a full rebuild: /init mode: fresh
For a snapshot any time: /supervisor mode: snapshot
────────────────────────────────────────────────────────────────────────
EOF