Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·104 lines (88 loc) · 2.75 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·104 lines (88 loc) · 2.75 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
#!/usr/bin/env bash
set -euo pipefail
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
skills_cli_version="1.5.22"
minimum_node_version="22.20.0"
usage() {
cat >&2 <<EOF
Usage:
${0##*/} Install into the current project
${0##*/} --project <project-dir> Install into the specified project (relative or absolute)
${0##*/} --global Install for the current user
${0##*/} -h | --help Show this help
EOF
}
mode="project"
project_root="${PWD}"
case "$#" in
0)
;;
1)
case "$1" in
--global)
mode="global"
;;
-h|--help)
usage
exit 0
;;
*)
usage
exit 2
;;
esac
;;
2)
if [[ "$1" == "--project" ]]; then
project_root="$2"
else
usage
exit 2
fi
;;
*)
usage
exit 2
;;
esac
command -v node >/dev/null 2>&1 || {
printf 'Error: Node.js %s or newer is required.\n' "$minimum_node_version" >&2
exit 1
}
node_version="$(node --version 2>/dev/null || true)"
node_version="${node_version#v}"
IFS=. read -r node_major node_minor node_patch <<< "$node_version"
node_patch="${node_patch%%-*}"
if [[ ! "$node_major" =~ ^[0-9]+$ || ! "$node_minor" =~ ^[0-9]+$ || ! "$node_patch" =~ ^[0-9]+$ ]]; then
printf 'Error: unable to determine the installed Node.js version.\n' >&2
exit 1
fi
if (( node_major < 22 || (node_major == 22 && node_minor < 20) )); then
printf 'Error: Node.js %s or newer is required; found %s.\n' "$minimum_node_version" "$node_version" >&2
exit 1
fi
command -v npx >/dev/null 2>&1 || {
printf 'Error: npx is required to install through the skills.sh CLI.\n' >&2
exit 1
}
if ! compgen -G "${script_dir}/*/SKILL.md" >/dev/null; then
printf 'Error: no direct child Skill directories were found in %s.\n' "${script_dir}" >&2
exit 1
fi
if [[ "$mode" == "global" ]]; then
printf 'Installing local Skills for the current user through the skills.sh CLI...\n'
exec npx --yes "skills@${skills_cli_version}" add "${script_dir}" --skill '*' --agent codex --global --yes --copy
fi
if [[ ! -d "$project_root" ]]; then
printf 'Error: project directory does not exist: %s\n' "$project_root" >&2
exit 1
fi
project_root="$(cd -- "$project_root" && pwd -P)"
if [[ "$project_root" == "$script_dir" || "$project_root" == "${script_dir}/"* ]]; then
printf 'Error: refusing to install the Skill into its source directory or a descendant.\n' >&2
printf 'Run this script from a target project or use --project <project-dir>.\n' >&2
exit 1
fi
printf 'Installing local Skills into project %s through the skills.sh CLI...\n' "$project_root"
cd -- "$project_root"
exec npx --yes "skills@${skills_cli_version}" add "${script_dir}" --skill '*' --agent codex --yes --copy