-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-skills.sh
More file actions
executable file
·65 lines (53 loc) · 1.39 KB
/
sync-skills.sh
File metadata and controls
executable file
·65 lines (53 loc) · 1.39 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
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="https://github.com/render-oss/skills"
SKILLS_SUBDIR="skills"
PLUGIN_SKILLS_DIR="skills"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
while [[ $# -gt 0 ]]; do
case "$1" in
--repo)
REPO_URL="$2"
shift 2
;;
--subdir)
SKILLS_SUBDIR="$2"
shift 2
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
echo "Cloning $REPO_URL ..."
git clone --depth 1 --quiet "$REPO_URL" "$TMPDIR/skills-source"
SOURCE_DIR="$TMPDIR/skills-source/$SKILLS_SUBDIR"
TARGET_DIR="$REPO_ROOT/$PLUGIN_SKILLS_DIR"
if [[ ! -d "$SOURCE_DIR" ]]; then
echo "Skills subdirectory '$SKILLS_SUBDIR' not found in $REPO_URL." >&2
exit 1
fi
SKILLS=()
for dir in "$SOURCE_DIR"/*/; do
if [[ -f "$dir/SKILL.md" ]]; then
SKILLS+=("$(basename "$dir")")
fi
done
if [[ ${#SKILLS[@]} -eq 0 ]]; then
echo "No skills found in $REPO_URL (no directories with SKILL.md)." >&2
exit 1
fi
echo "Found ${#SKILLS[@]} skills: ${SKILLS[*]}"
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"
for skill in "${SKILLS[@]}"; do
cp -R "$SOURCE_DIR/$skill" "$TARGET_DIR/$skill"
file_count="$(find "$TARGET_DIR/$skill" -type f | wc -l | tr -d ' ')"
echo " $skill ($file_count files)"
done
echo ""
echo "Synced ${#SKILLS[@]} skills into $PLUGIN_SKILLS_DIR/"