-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·110 lines (97 loc) · 2.21 KB
/
install.sh
File metadata and controls
executable file
·110 lines (97 loc) · 2.21 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
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Install big-project-orchestrator into a repo or user skills directory.
Usage:
bash install.sh --repo /path/to/repo
bash install.sh --user
bash install.sh --target /absolute/path/to/skills/dir
Options:
--repo PATH Install into PATH/<skills-dir>/big-project-orchestrator
--user Install into the detected personal skills dir
--target PATH Install directly into PATH/big-project-orchestrator
--force Overwrite an existing installation
EOF
}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FORCE=0
MODE=""
DEST_BASE=""
SKILLS_SUFFIX=""
detect_user_skills_base() {
if [[ -n "${CODEX_HOME:-}" ]]; then
printf '%s\n' "${CODEX_HOME%/}/skills"
return
fi
if [[ -d "${HOME}/.codex/skills" ]]; then
printf '%s\n' "${HOME}/.codex/skills"
return
fi
if [[ -d "${HOME}/.agents/skills" ]]; then
printf '%s\n' "${HOME}/.agents/skills"
return
fi
printf '%s\n' "${HOME}/.codex/skills"
}
detect_repo_skills_suffix() {
local user_base
user_base="$(detect_user_skills_base)"
case "$user_base" in
*/.agents/skills) printf '.agents/skills\n' ;;
*) printf '.codex/skills\n' ;;
esac
}
while [[ $# -gt 0 ]]; do
case "$1" in
--repo)
MODE="repo"
DEST_BASE="$2"
shift 2
;;
--user)
MODE="user"
DEST_BASE="$(detect_user_skills_base)"
shift
;;
--target)
MODE="target"
DEST_BASE="$2"
shift 2
;;
--force)
FORCE=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
if [[ -z "$MODE" ]]; then
usage >&2
exit 1
fi
if [[ "$MODE" == "repo" ]]; then
SKILLS_SUFFIX="$(detect_repo_skills_suffix)"
DEST_BASE="${DEST_BASE%/}/${SKILLS_SUFFIX}"
fi
DEST="${DEST_BASE%/}/big-project-orchestrator"
mkdir -p "$DEST_BASE"
if [[ -e "$DEST" ]]; then
if [[ "$FORCE" -ne 1 ]]; then
echo "Destination already exists: $DEST" >&2
echo "Re-run with --force to overwrite." >&2
exit 1
fi
rm -rf "$DEST"
fi
cp -R "$SCRIPT_DIR" "$DEST"
echo "Installed to: $DEST"
echo "Restart Codex if the skill does not appear immediately."