[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
1#!/bin/bash
2
3SOURCE_DIR="$HOME/dev/src/ccpm/ccpm"
4CLAUDE_DIR=".claude"
5
6function show_help {
7 echo "Usage: ccpm [init|update|help]"
8 echo ""
9 echo " init - Install CCPM into the current project"
10 echo " update - Refresh symlinks (e.g. after source adds new files)"
11 echo " help - Show this message"
12}
13
14function ensure_symlink {
15 local link_path="$1"
16 local target="$2"
17
18 if [ -L "$link_path" ]; then
19 rm "$link_path"
20 elif [ -e "$link_path" ]; then
21 echo " Skipping $link_path (already exists)"
22 return
23 fi
24 ln -s "$target" "$link_path"
25}
26
27function init_project {
28 if [ ! -d "$SOURCE_DIR" ]; then
29 echo "Error: Source not found at $SOURCE_DIR"
30 exit 1
31 fi
32
33 echo "Installing CCPM..."
34
35 # Symlink ccpm/ at project root (commands reference "ccpm/scripts/pm/...")
36 ensure_symlink "ccpm" "$SOURCE_DIR"
37 echo " Linked ccpm/ -> $SOURCE_DIR"
38
39 # Create .claude/ and data directories
40 mkdir -p "$CLAUDE_DIR/commands"
41 mkdir -p "$CLAUDE_DIR/context"
42 mkdir -p "$CLAUDE_DIR/epics"
43 mkdir -p "$CLAUDE_DIR/prds"
44
45 # Symlink command subdirectories (pm, context, testing)
46 for dir in ccpm/commands/*/; do
47 local name
48 name=$(basename "$dir")
49 ensure_symlink "$CLAUDE_DIR/commands/$name" "../../ccpm/commands/$name"
50 done
51
52 # Symlink individual command files (prompt.md, re-init.md, etc.)
53 for file in ccpm/commands/*.md; do
54 local name
55 name=$(basename "$file")
56 ensure_symlink "$CLAUDE_DIR/commands/$name" "../../ccpm/commands/$name"
57 done
58 echo " Linked commands into $CLAUDE_DIR/commands/"
59
60 # Symlink agents, rules, hooks
61 for dir in agents rules hooks; do
62 if [ -d "ccpm/$dir" ]; then
63 ensure_symlink "$CLAUDE_DIR/$dir" "../ccpm/$dir"
64 echo " Linked $dir/"
65 fi
66 done
67
68 # Add ccpm to .gitignore
69 if ! grep -q "^ccpm$" .gitignore 2>/dev/null; then
70 echo "ccpm" >> .gitignore
71 echo " Added ccpm to .gitignore"
72 fi
73
74 echo ""
75 echo "Done. Run /pm:init inside Claude Code to finish setup."
76}
77
78case "$1" in
79 init)
80 init_project
81 ;;
82 update)
83 init_project
84 ;;
85 *)
86 show_help
87 ;;
88esac