-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·176 lines (158 loc) · 4.92 KB
/
install.sh
File metadata and controls
executable file
·176 lines (158 loc) · 4.92 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
# Install script for claude-code-md
# Downloads and installs agents, skills, commands, and docs from GitHub to a project's .claude/ folder
set -e
# GitHub repository configuration
REPO_OWNER="BenjaminFont"
REPO_NAME="claude-code-md"
BRANCH="main"
INSTALL_AGENTS=true
INSTALL_COMMANDS=true
INSTALL_SKILLS=true
INSTALL_DOCS=true
# Parse flags
while [[ $# -gt 0 ]]; do
case $1 in
--agents-only)
INSTALL_COMMANDS=false
INSTALL_SKILLS=false
INSTALL_DOCS=false
shift
;;
--commands-only)
INSTALL_AGENTS=false
INSTALL_SKILLS=false
INSTALL_DOCS=false
shift
;;
--skills-only)
INSTALL_AGENTS=false
INSTALL_COMMANDS=false
INSTALL_DOCS=false
shift
;;
--docs-only)
INSTALL_AGENTS=false
INSTALL_COMMANDS=false
INSTALL_SKILLS=false
shift
;;
-h|--help)
echo "Usage: install.sh [OPTIONS] <target-dir>"
echo ""
echo "Install claude-code-md agents, skills, commands, and docs from GitHub to a project."
echo ""
echo "Options:"
echo " --agents-only Only install agents"
echo " --skills-only Only install skills"
echo " --commands-only Only install commands"
echo " --docs-only Only install docs"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " # Install everything"
echo " curl -fsSL https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/install.sh | bash -s -- /path/to/project"
echo ""
echo " # Only agents"
echo " curl -fsSL https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/install.sh | bash -s -- --agents-only /path/to/project"
echo ""
echo " # Only skills"
echo " curl -fsSL https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/install.sh | bash -s -- --skills-only /path/to/project"
echo ""
echo " # Only commands"
echo " curl -fsSL https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/install.sh | bash -s -- --commands-only /path/to/project"
exit 0
;;
*)
TARGET_DIR="$1"
shift
;;
esac
done
# Validate target directory
if [ -z "$TARGET_DIR" ]; then
echo "Error: No target directory specified"
echo "Usage: curl -fsSL <script-url> | bash -s -- [--agents-only|--commands-only] <target-dir>"
exit 1
fi
# Resolve to absolute path
TARGET_DIR="$(cd "$TARGET_DIR" 2>/dev/null && pwd)" || {
echo "Error: Target directory does not exist: $TARGET_DIR"
exit 1
}
# Create temp directory for download
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
echo "Downloading from GitHub..."
# Download repository as tarball
TARBALL_URL="https://github.com/$REPO_OWNER/$REPO_NAME/archive/refs/heads/$BRANCH.tar.gz"
curl -fsSL "$TARBALL_URL" | tar -xz -C "$TMP_DIR"
# The extracted folder is named repo-branch
EXTRACT_DIR="$TMP_DIR/$REPO_NAME-$BRANCH"
if [ ! -d "$EXTRACT_DIR" ]; then
echo "Error: Failed to download repository"
exit 1
fi
# Create .claude directory if needed
mkdir -p "$TARGET_DIR/.claude"
# Install agents
if [ "$INSTALL_AGENTS" = true ]; then
if [ -d "$EXTRACT_DIR/agents" ]; then
echo "Installing agents..."
cp -r "$EXTRACT_DIR/agents" "$TARGET_DIR/.claude/"
for file in "$EXTRACT_DIR/agents"/*.md; do
[ -f "$file" ] && echo " - $(basename "$file")"
done
echo "Installed agents"
else
echo "Warning: No agents directory found in repository"
fi
fi
# Install skills
if [ "$INSTALL_SKILLS" = true ]; then
if [ -d "$EXTRACT_DIR/skills" ]; then
echo "Installing skills..."
cp -r "$EXTRACT_DIR/skills" "$TARGET_DIR/.claude/"
for dir in "$EXTRACT_DIR/skills"/*/; do
[ -d "$dir" ] && echo " - $(basename "$dir")/SKILL.md"
done
echo "Installed skills"
else
echo "Warning: No skills directory found in repository"
fi
fi
# Install commands
if [ "$INSTALL_COMMANDS" = true ]; then
if [ -d "$EXTRACT_DIR/commands" ]; then
echo "Installing commands..."
cp -r "$EXTRACT_DIR/commands" "$TARGET_DIR/.claude/"
# List top-level command files
for file in "$EXTRACT_DIR/commands"/*.md; do
[ -f "$file" ] && echo " - $(basename "$file")"
done
# List workflow files
if [ -d "$EXTRACT_DIR/commands/workflow" ]; then
for file in "$EXTRACT_DIR/commands/workflow"/*.md; do
[ -f "$file" ] && echo " - workflow/$(basename "$file")"
done
fi
echo "Installed commands"
else
echo "Warning: No commands directory found in repository"
fi
fi
# Install docs
if [ "$INSTALL_DOCS" = true ]; then
if [ -d "$EXTRACT_DIR/docs" ]; then
echo "Installing docs..."
cp -r "$EXTRACT_DIR/docs" "$TARGET_DIR/.claude/"
for file in "$EXTRACT_DIR/docs"/*.md; do
[ -f "$file" ] && echo " - $(basename "$file")"
done
echo "Installed docs"
else
echo "Warning: No docs directory found in repository"
fi
fi
echo ""
echo "Done! Installed to $TARGET_DIR/.claude/"