Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·135 lines (117 loc) · 4.38 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·135 lines (117 loc) · 4.38 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
#!/usr/bin/env bash
# video-transcript skill 一行命令安装入口
#
# 用法:
# bash <(curl -fsSL https://raw.githubusercontent.com/Backtthefuture/video-transcript/main/bootstrap.sh)
#
# 流程: 拉取云端版 Skill → 检查本地依赖;夸克网盘 Skill 与授权单独安装
#
# 拉取顺序: git clone 暂存 → GitHub tarball;更新时保留本机配置和产物
set -euo pipefail
REPO="Backtthefuture/video-transcript"
SKILL="video-transcript"
TARGET="${VIDEO_TRANSCRIPT_TARGET:-$HOME/.claude/skills/$SKILL}"
C_BOLD='\033[1m'; C_GREEN='\033[32m'; C_YELLOW='\033[33m'; C_RED='\033[31m'; C_BLUE='\033[34m'; C_GRAY='\033[90m'; C_RESET='\033[0m'
say() { printf "${C_BLUE}▸${C_RESET} %s\n" "$1"; }
ok() { printf " ${C_GREEN}✓${C_RESET} %s\n" "$1"; }
warn() { printf " ${C_YELLOW}⚠${C_RESET} %s\n" "$1"; }
err() { printf " ${C_RED}✗${C_RESET} %s\n" "$1"; }
bar() { printf "${C_GRAY}═══════════════════════════════════════════════════════${C_RESET}\n"; }
# ── Codex 集成:检测到 ~/.codex/ 就注册 /video-transcript ──
register_codex() {
local codex_home="${CODEX_HOME:-$HOME/.codex}"
if [ ! -d "$codex_home" ]; then
printf " ${C_GRAY}ℹ${C_RESET} 未检测到 ~/.codex/,跳过 Codex 集成(只 Claude Code 可用)\n"
return 0
fi
mkdir -p "$codex_home/prompts"
cat > "$codex_home/prompts/video-transcript.md" <<PROMPT_EOF
Use the video-transcript skill at:
$TARGET/SKILL.md
Read that SKILL.md before acting and follow its current platform routing,
privacy boundaries, error handling, and output contract. Do not reproduce an
older workflow from this prompt. The user's request is:
\$ARGUMENTS
PROMPT_EOF
ok "已注册 Codex 命令 → $codex_home/prompts/video-transcript.md"
printf " ${C_GRAY} 在 Codex 里可用 /video-transcript <URL> 触发${C_RESET}\n"
}
bar
printf "${C_BOLD} 🎬 video-transcript skill 安装引导${C_RESET}\n"
bar
echo ""
case "$TARGET" in
""|/|"$HOME"|"$HOME/")
err "拒绝使用过宽的安装目标: $TARGET"
exit 1
;;
/*/video-transcript)
;;
*)
err "安装目标必须是以 /video-transcript 结尾的绝对路径: $TARGET"
exit 1
;;
esac
TARGET_PARENT=$(dirname "$TARGET")
mkdir -p "$TARGET_PARENT"
STAGE_ROOT=$(mktemp -d)
STAGE_TARGET="$STAGE_ROOT/video-transcript"
cleanup_stage(){ rm -rf "$STAGE_ROOT"; }
trap cleanup_stage EXIT
fetched=""
if command -v git >/dev/null 2>&1; then
say "暂存拉取 GitHub main..."
if git clone --depth=1 "https://github.com/$REPO.git" "$STAGE_TARGET" 2>&1; then
fetched="git"
fi
fi
if [ -z "$fetched" ]; then
say "git 不可用或拉取失败,改用 GitHub tarball..."
if curl -fsSL "https://github.com/$REPO/archive/refs/heads/main.tar.gz" | tar xz -C "$STAGE_ROOT" 2>&1; then
SKILL_FILE=$(find "$STAGE_ROOT" -maxdepth 2 -type f -name SKILL.md -print -quit)
SUBDIR="${SKILL_FILE:+$(dirname "$SKILL_FILE")}"
if [ -n "$SUBDIR" ] && [ -d "$SUBDIR" ]; then
STAGE_TARGET="$SUBDIR"
fetched="tarball"
fi
fi
fi
if [ -z "$fetched" ] || [ ! -f "$STAGE_TARGET/SKILL.md" ]; then
err "GitHub main 拉取失败!"
err "请手动 git clone 后跑: bash <skill-dir>/install.sh"
err " git clone https://github.com/$REPO ~/Downloads/video-transcript"
err " bash ~/Downloads/video-transcript/install.sh"
exit 1
fi
if ! command -v rsync >/dev/null 2>&1; then
err "缺少 rsync,无法安全保留已有 .env 与 outputs/"
exit 1
fi
if [ -d "$TARGET" ]; then
say "检测到已有安装,更新程序文件并保留 .env、outputs 和本地词表..."
else
say "安装到 $TARGET ..."
mkdir -p "$TARGET"
fi
rsync -a \
--exclude='.git/' \
--exclude='.env' \
--exclude='.env.local' \
--exclude='outputs/' \
--exclude='__pycache__/' \
--exclude='.podcast_glossary.json' \
"$STAGE_TARGET/" "$TARGET/"
ok "程序文件已同步到 $TARGET"
echo ""
say "检查云端版 Skill 的本地依赖..."
echo ""
if command -v python3 >/dev/null 2>&1; then
if ! python3 "$TARGET/scripts/transcript.py" --doctor; then
warn "仍有依赖未就绪。请阅读 $TARGET/README.md 并按需运行 bash $TARGET/install.sh"
fi
else
warn "未找到 Python 3.9+。请先安装,再运行 Skill 的 --doctor。"
fi
echo ""
register_codex
ok "Skill 文件已安装。云端授权与实际取稿需在目标机器上另行验证。"