-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall-skill.sh
More file actions
executable file
·108 lines (90 loc) · 2.14 KB
/
install-skill.sh
File metadata and controls
executable file
·108 lines (90 loc) · 2.14 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
#!/bin/sh
set -eu
REPO="${REPO:-Gladium-AI/flare-cli}"
REF="${REF:-main}"
SKILL_NAME="${SKILL_NAME:-flare-cli}"
SKILL_PATH="${SKILL_PATH:-skills/${SKILL_NAME}}"
INSTALL_TARGETS="${INSTALL_TARGETS:-claude,codex}"
CLAUDE_SKILLS_DIR="${CLAUDE_SKILLS_DIR:-$HOME/.claude/skills}"
CODEX_HOME_DEFAULT="${HOME}/.codex"
CODEX_HOME_DIR="${CODEX_HOME:-$CODEX_HOME_DEFAULT}"
CODEX_SKILLS_DIR="${CODEX_SKILLS_DIR:-${CODEX_HOME_DIR%/}/skills}"
download() {
url="$1"
out="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$out"
return
fi
if command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$out"
return
fi
echo "Error: curl or wget is required" >&2
exit 1
}
copy_skill() {
src="$1"
root="$2"
dst="${root%/}/${SKILL_NAME}"
mkdir -p "$root"
rm -rf "$dst"
cp -R "$src" "$dst"
printf 'Installed skill to %s\n' "$dst"
}
install_skill() {
src="$1"
if [ -n "${SKILLS_DIR:-}" ]; then
copy_skill "$src" "$SKILLS_DIR"
return
fi
installed=0
for target in $(printf '%s' "$INSTALL_TARGETS" | tr ',' ' '); do
case "$target" in
claude)
copy_skill "$src" "$CLAUDE_SKILLS_DIR"
installed=1
;;
codex)
copy_skill "$src" "$CODEX_SKILLS_DIR"
installed=1
;;
"")
;;
*)
echo "Error: unsupported install target '$target' (use claude,codex)" >&2
exit 1
;;
esac
done
if [ "$installed" -ne 1 ]; then
echo "Error: no install targets resolved" >&2
exit 1
fi
}
if [ -n "${SOURCE_DIR:-}" ]; then
src="${SOURCE_DIR%/}/${SKILL_PATH}"
if [ ! -d "$src" ]; then
echo "Error: skill directory not found at $src" >&2
exit 1
fi
install_skill "$src"
exit 0
fi
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT INT TERM
archive="$tmpdir/repo.tar.gz"
url="https://codeload.github.com/${REPO}/tar.gz/refs/heads/${REF}"
download "$url" "$archive"
tar -xzf "$archive" -C "$tmpdir"
root_dir="$(find "$tmpdir" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
if [ -z "$root_dir" ]; then
echo "Error: could not extract repository archive" >&2
exit 1
fi
src="${root_dir}/${SKILL_PATH}"
if [ ! -d "$src" ]; then
echo "Error: skill directory not found in downloaded archive: $src" >&2
exit 1
fi
install_skill "$src"