-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathsetup
More file actions
executable file
·150 lines (136 loc) · 5.55 KB
/
Copy pathsetup
File metadata and controls
executable file
·150 lines (136 loc) · 5.55 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env bash
# heygen-skills setup — first-time installation for Claude Code and OpenClaw users.
# Idempotent: safe to run multiple times.
set -euo pipefail
# ─── Colors (degrade gracefully) ─────────────────────────────
if [ -t 1 ] && command -v tput &>/dev/null && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]; then
GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) RED=$(tput setaf 1) BOLD=$(tput bold) RESET=$(tput sgr0)
else
GREEN="" YELLOW="" RED="" BOLD="" RESET=""
fi
ok() { echo "${GREEN}✓${RESET} $1"; }
warn() { echo "${YELLOW}!${RESET} $1"; }
err() { echo "${RED}✗${RESET} $1"; }
# ─── Locate repo root ────────────────────────────────────────
SKILL_DIR="$(cd "$(dirname "$0")" && pwd)"
if [ ! -f "$SKILL_DIR/SKILL.md" ]; then
err "Cannot find SKILL.md — run this script from the heygen-skills repo root."
exit 1
fi
# ─── Parse flags ────────────────────────────────────────────
HOST_OVERRIDE=""
while [ $# -gt 0 ]; do
case "$1" in
--host)
shift
if [ $# -eq 0 ]; then
err "--host requires a value: claude or openclaw"
exit 1
fi
case "$1" in
claude|claude-code) HOST_OVERRIDE="claude-code" ;;
openclaw) HOST_OVERRIDE="openclaw" ;;
*)
err "Unknown host agent: $1 (expected: claude or openclaw)"
exit 1
;;
esac
shift
;;
--host=*)
val="${1#--host=}"
case "$val" in
claude|claude-code) HOST_OVERRIDE="claude-code" ;;
openclaw) HOST_OVERRIDE="openclaw" ;;
*)
err "Unknown host agent: $val (expected: claude or openclaw)"
exit 1
;;
esac
shift
;;
*)
warn "Unknown flag: $1"
shift
;;
esac
done
# ─── Detect host agent ───────────────────────────────────────
# Priority: 1) --host flag, 2) script path, 3) directory existence fallback
AGENT="unknown"
SKILLS_DIR=""
if [ -n "$HOST_OVERRIDE" ]; then
# Explicit --host flag takes highest priority
AGENT="$HOST_OVERRIDE"
elif [[ "$SKILL_DIR" == *"/.openclaw/workspace/skills/"* ]]; then
AGENT="openclaw"
elif [[ "$SKILL_DIR" == *"/.claude/skills/"* ]]; then
AGENT="claude-code"
elif [ -d "$HOME/.openclaw" ] && [ -d "$HOME/.claude" ]; then
# Both installed — path was ambiguous, warn and ask for --host
warn "Both Claude Code and OpenClaw detected. Cannot auto-detect host agent."
warn "Re-run with: ./setup --host claude OR ./setup --host openclaw"
elif [ -d "$HOME/.claude" ]; then
AGENT="claude-code"
elif [ -d "$HOME/.openclaw" ]; then
AGENT="openclaw"
fi
# Set skills directory based on detected agent
case "$AGENT" in
claude-code) SKILLS_DIR="$HOME/.claude/skills" ;;
openclaw) SKILLS_DIR="$HOME/.openclaw/workspace/skills" ;;
esac
echo ""
echo "${BOLD}HeyGen Skills Setup${RESET}"
echo "─────────────────────────────"
if [ "$AGENT" = "unknown" ]; then
warn "Could not detect Claude Code or OpenClaw. See INSTALL.md for manual setup."
else
ok "Detected host agent: ${BOLD}${AGENT}${RESET}"
fi
# ─── Create skill symlinks ───────────────────────────────────
SKILLS=(heygen-avatar heygen-video)
if [ -n "$SKILLS_DIR" ]; then
INSTALL_DIR="$SKILLS_DIR/heygen-skills"
mkdir -p "$INSTALL_DIR"
for skill in "${SKILLS[@]}"; do
src="$SKILL_DIR/$skill/SKILL.md"
[ ! -f "$src" ] && { warn "Skipping $skill — SKILL.md not found"; continue; }
mkdir -p "$INSTALL_DIR/$skill" "$SKILLS_DIR/$skill"
ln -sf "$src" "$INSTALL_DIR/$skill/SKILL.md"
ln -sf "$src" "$SKILLS_DIR/$skill/SKILL.md"
done
ln -sf "$SKILL_DIR/SKILL.md" "$INSTALL_DIR/SKILL.md"
[ -d "$SKILL_DIR/references" ] && ln -sfn "$SKILL_DIR/references" "$INSTALL_DIR/references"
ok "Skill symlinks created in ${SKILLS_DIR}"
for skill in "${SKILLS[@]}"; do echo " ${skill}/SKILL.md"; done
fi
# ─── Auth guidance ───────────────────────────────────────────
echo ""
echo "${BOLD}Auth:${RESET}"
echo " The skills prefer HeyGen Remote MCP (OAuth, no API key needed)."
echo " If MCP isn't connected, install and use the HeyGen CLI:"
echo " ${BOLD}curl -fsSL https://static.heygen.ai/cli/install.sh | bash${RESET}"
echo " ${BOLD}heygen auth login${RESET} # or: export HEYGEN_API_KEY=<your-key>"
echo " ${BOLD}heygen auth status${RESET} # verify"
if command -v heygen &>/dev/null; then
HEYGEN_VERSION="$(heygen --version 2>/dev/null | head -n1 || echo 'unknown')"
ok "heygen CLI detected: ${HEYGEN_VERSION}"
if heygen auth status &>/dev/null; then
ok "heygen auth OK"
else
warn "heygen not authenticated — run: heygen auth login (or export HEYGEN_API_KEY=<key>)"
fi
else
warn "heygen CLI not found on PATH (optional — only needed if MCP isn't connected)"
fi
# ─── Summary ─────────────────────────────────────────────────
echo ""
echo "${BOLD}Installed skills:${RESET}"
for skill in "${SKILLS[@]}"; do
echo " - $skill"
done
echo ""
echo "${BOLD}Next step:${RESET}"
echo " Ask your agent: \"Create my HeyGen avatar\""
echo ""