-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-skills-unix.sh
More file actions
55 lines (41 loc) · 1.45 KB
/
install-skills-unix.sh
File metadata and controls
55 lines (41 loc) · 1.45 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
#!/usr/bin/env bash
set -euo pipefail
SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare -a DEST_BASES=("${HOME}/.agents")
for DEST_BASE in "${DEST_BASES[@]}"; do
SKILLS_DEST="$DEST_BASE/skills"
PROMPTS_DEST="$DEST_BASE/prompts"
mkdir -p "$SKILLS_DEST" "$PROMPTS_DEST"
# Copy skills
TMP_SKILLS="$(mktemp)"
find "$SOURCE_ROOT" -type d -name ".*" -prune -o -type f -name "SKILL.md" -print > "$TMP_SKILLS"
SKILLS_COPIED=0
while IFS= read -r skill_file; do
skill_dir="$(dirname "$skill_file")"
skill_name="$(basename "$skill_dir")"
target_dir="$SKILLS_DEST/$skill_name"
if [ "$skill_dir" = "$target_dir" ]; then
continue
fi
rm -rf "$target_dir"
cp -R "$skill_dir" "$target_dir"
SKILLS_COPIED=$((SKILLS_COPIED + 1))
done < "$TMP_SKILLS"
rm -f "$TMP_SKILLS"
# Copy prompts
TMP_PROMPTS="$(mktemp)"
find "$SOURCE_ROOT" -type d -name ".*" -prune -o -type f -name "*.prompt.md" -print > "$TMP_PROMPTS"
PROMPTS_COPIED=0
while IFS= read -r prompt_file; do
prompt_name="$(basename "$prompt_file")"
target_file="$PROMPTS_DEST/$prompt_name"
if [ "$(dirname "$prompt_file")" = "$PROMPTS_DEST" ]; then
continue
fi
cp "$prompt_file" "$target_file"
PROMPTS_COPIED=$((PROMPTS_COPIED + 1))
done < "$TMP_PROMPTS"
rm -f "$TMP_PROMPTS"
echo "Copied $SKILLS_COPIED skill(s) to $SKILLS_DEST"
echo "Copied $PROMPTS_COPIED prompt(s) to $PROMPTS_DEST"
done