full-stack-bootstrap
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFull Stack Bootstrap
全栈引导设置
One-time bootstrap of the entire TTS + Telegram bot stack: Kokoro TTS engine (Apple Silicon MPS), Telegram bot via BotFather, secrets management, environment configuration, and shell symlinks.
Platform: macOS (Apple Silicon)
TTS + Telegram机器人全栈的一次性引导设置:Kokoro TTS引擎(Apple Silicon MPS)、通过BotFather创建Telegram机器人、密钥管理、环境配置及Shell符号链接。
平台: macOS(Apple Silicon)
When to Use This Skill
何时使用此技能
- First-time setup of the tts-telegram-sync plugin
- Reinstalling after a clean OS install or hardware migration
- Setting up a new machine with the full TTS + Telegram stack
- Recovering from a broken installation (run first)
kokoro-install.sh --uninstall
- 首次搭建tts-telegram-sync插件
- 干净安装系统或硬件迁移后重新安装
- 在新机器上搭建完整的TTS + Telegram栈
- 从损坏的安装中恢复(先运行)
kokoro-install.sh --uninstall
Requirements
前置要求
| Component | Required | Installation |
|---|---|---|
| Bun | Yes | |
| mise | Yes | |
| uv | Yes | |
| Python 3.13 | Yes | |
| Homebrew | Yes | Already installed on macOS dev machines |
| Apple Silicon (M1+) | Yes | Required for MPS acceleration |
| 组件 | 是否必需 | 安装方式 |
|---|---|---|
| Bun | 是 | |
| mise | 是 | |
| uv | 是 | |
| Python 3.13 | 是 | |
| Homebrew | 是 | macOS开发机器通常已预装 |
| Apple Silicon (M1+) | 是 | 必需用于MPS加速 |
Workflow Phases
工作流阶段
Phase 0: Preflight Check
阶段0:预检检查
Verify all prerequisites are installed and accessible:
bash
command -v bun # Bun runtime for TypeScript bot
command -v mise # Environment manager
command -v uv # Python package manager
uv python list | grep 3.13 # Python 3.13 availableIf any tool is missing, install via Homebrew (). Python 3.13 is installed via .
brew install <tool>uv python install 3.13验证所有前置工具已安装且可访问:
bash
command -v bun # TypeScript机器人的Bun运行时
command -v mise # 环境管理器
command -v uv # Python包管理器
uv python list | grep 3.13 # 确认Python 3.13可用如果缺少任何工具,通过Homebrew安装()。Python 3.13通过安装。
brew install <工具>uv python install 3.13Phase 1: Kokoro TTS Engine Install
阶段1:Kokoro TTS引擎安装
Run the bundled installer script:
bash
bash scripts/kokoro-install.sh --installThis performs:
- Creates venv at with Python 3.13 via uv
~/.local/share/kokoro/.venv - Installs PyPI deps (kokoro, misaki, torch, soundfile, numpy, transformers, huggingface_hub, loguru) -- versions pinned in
scripts/kokoro-install.sh - Copies from plugin bundle to
tts_generate.py~/.local/share/kokoro/ - Downloads Kokoro-82M model from HuggingFace ()
hexgrad/Kokoro-82M - Verifies Apple Silicon MPS is available via
torch.backends.mps.is_available() - Writes with kokoro, torch, and Python versions
version.json
运行捆绑的安装脚本:
bash
bash scripts/kokoro-install.sh --install此脚本将执行以下操作:
- 通过uv在创建基于Python 3.13的虚拟环境
~/.local/share/kokoro/.venv - 安装PyPI依赖(kokoro、misaki、torch、soundfile、numpy、transformers、huggingface_hub、loguru)——版本在中固定
scripts/kokoro-install.sh - 将插件包中的复制到
tts_generate.py~/.local/share/kokoro/ - 从HuggingFace下载Kokoro-82M模型()
hexgrad/Kokoro-82M - 通过验证Apple Silicon MPS是否可用
torch.backends.mps.is_available() - 写入包含kokoro、torch及Python版本的
version.json
Phase 2: BotFather Token Setup
阶段2:BotFather令牌设置
Guide the user through Telegram BotFather to create a bot token:
- Open Telegram, search for
@BotFather - Send , follow prompts (name + username)
/newbot - Copy the HTTP API token
- Verify token:
curl -s "https://api.telegram.org/bot<TOKEN>/getMe" | jq .ok - Get chat_id by sending a message to the bot, then:
curl -s "https://api.telegram.org/bot<TOKEN>/getUpdates" | jq '.result[0].message.chat.id'
If a token already exists at , verify it works and skip this phase.
~/.claude/.secrets/ccterrybot-telegram引导用户通过Telegram BotFather创建机器人令牌:
- 打开Telegram,搜索
@BotFather - 发送,按照提示操作(设置名称和用户名)
/newbot - 复制HTTP API令牌
- 验证令牌:
curl -s "https://api.telegram.org/bot<TOKEN>/getMe" | jq .ok - 向机器人发送消息,然后通过以下命令获取chat_id:
curl -s "https://api.telegram.org/bot<TOKEN>/getUpdates" | jq '.result[0].message.chat.id'
如果已存在令牌,验证其可用后可跳过此阶段。
~/.claude/.secrets/ccterrybot-telegramPhase 3: Secrets Storage
阶段3:密钥存储
Store the bot token securely:
bash
mkdir -p ~/.claude/.secrets
chmod 700 ~/.claude/.secrets
echo "BOT_TOKEN=<token>" > ~/.claude/.secrets/ccterrybot-telegram
echo "CHAT_ID=<chat_id>" >> ~/.claude/.secrets/ccterrybot-telegram
chmod 600 ~/.claude/.secrets/ccterrybot-telegramCreate (gitignored) in the bot directory to load secrets:
.mise.local.tomltoml
undefined安全存储机器人令牌:
bash
mkdir -p ~/.claude/.secrets
chmod 700 ~/.claude/.secrets
echo "BOT_TOKEN=<token>" > ~/.claude/.secrets/ccterrybot-telegram
echo "CHAT_ID=<chat_id>" >> ~/.claude/.secrets/ccterrybot-telegram
chmod 600 ~/.claude/.secrets/ccterrybot-telegram在机器人目录中创建.git忽略的以加载密钥:
.mise.local.tomltoml
undefined~/.claude/automation/claude-telegram-sync/.mise.local.toml
~/.claude/automation/claude-telegram-sync/.mise.local.toml
[env]
_.file = "{{env.HOME}}/.claude/.secrets/ccterrybot-telegram"
undefined[env]
_.file = "{{env.HOME}}/.claude/.secrets/ccterrybot-telegram"
undefinedPhase 4: Environment Configuration
阶段4:环境配置
Add Kokoro paths to :
mise.tomltoml
undefined将Kokoro路径添加到:
mise.tomltoml
undefinedIn ~/.claude/automation/claude-telegram-sync/mise.toml [env] section
在~/.claude/automation/claude-telegram-sync/mise.toml的[env]部分
KOKORO_VENV = "{{env.HOME}}/.local/share/kokoro/.venv"
KOKORO_SCRIPT = "{{env.HOME}}/.local/share/kokoro/tts_generate.py"
undefinedKOKORO_VENV = "{{env.HOME}}/.local/share/kokoro/.venv"
KOKORO_SCRIPT = "{{env.HOME}}/.local/share/kokoro/tts_generate.py"
undefinedPhase 5: Shell Symlinks
阶段5:Shell符号链接
Create symlinks in pointing to plugin shell scripts:
~/.local/bin/bash
mkdir -p ~/.local/bin
ln -sf <plugin>/scripts/tts_kokoro.sh ~/.local/bin/tts_kokoro.sh
ln -sf <plugin>/scripts/tts_read_clipboard.sh ~/.local/bin/tts_read_clipboard.sh
ln -sf <plugin>/scripts/tts_read_clipboard_wrapper.sh ~/.local/bin/tts_read_clipboard_wrapper.sh
ln -sf <plugin>/scripts/tts_speed_up.sh ~/.local/bin/tts_speed_up.sh
ln -sf <plugin>/scripts/tts_speed_down.sh ~/.local/bin/tts_speed_down.sh
ln -sf <plugin>/scripts/tts_speed_reset.sh ~/.local/bin/tts_speed_reset.sh在中创建指向插件Shell脚本的符号链接:
~/.local/bin/bash
mkdir -p ~/.local/bin
ln -sf <plugin>/scripts/tts_kokoro.sh ~/.local/bin/tts_kokoro.sh
ln -sf <plugin>/scripts/tts_read_clipboard.sh ~/.local/bin/tts_read_clipboard.sh
ln -sf <plugin>/scripts/tts_read_clipboard_wrapper.sh ~/.local/bin/tts_read_clipboard_wrapper.sh
ln -sf <plugin>/scripts/tts_speed_up.sh ~/.local/bin/tts_speed_up.sh
ln -sf <plugin>/scripts/tts_speed_down.sh ~/.local/bin/tts_speed_down.sh
ln -sf <plugin>/scripts/tts_speed_reset.sh ~/.local/bin/tts_speed_reset.shPhase 6: Verification
阶段6:验证
- Generate a test WAV and play it:
bash
~/.local/share/kokoro/.venv/bin/python ~/.local/share/kokoro/tts_generate.py \
--text "Hello, bootstrap complete." --voice af_heart --lang en-us --speed 1.0 --output /tmp/test-bootstrap.wav
afplay /tmp/test-bootstrap.wav
rm -f /tmp/test-bootstrap.wav- Verify bot responds to /status via Telegram API:
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getMe" | jq .ok- 生成测试WAV文件并播放:
bash
~/.local/share/kokoro/.venv/bin/python ~/.local/share/kokoro/tts_generate.py \
--text "Hello, bootstrap complete." --voice af_heart --lang en-us --speed 1.0 --output /tmp/test-bootstrap.wav
afplay /tmp/test-bootstrap.wav
rm -f /tmp/test-bootstrap.wav- 通过Telegram API验证机器人响应/status命令:
bash
curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getMe" | jq .okTodoWrite Task Templates
TodoWrite任务模板
Template: Full Stack Bootstrap
模板:全栈引导设置
1. [Preflight] Verify Bun installed
2. [Preflight] Verify mise installed
3. [Preflight] Verify uv installed
4. [Preflight] Verify Python 3.13 available via uv
5. [Kokoro] Run kokoro-install.sh --install
6. [Kokoro] Verify MPS acceleration
7. [BotFather] Guide BotFather token creation (or verify existing)
8. [Secrets] Store token in ~/.claude/.secrets/ccterrybot-telegram
9. [Secrets] Create .mise.local.toml with _.file reference to secrets
10. [Environment] Add KOKORO_VENV and KOKORO_SCRIPT to mise.toml
11. [Symlinks] Create ~/.local/bin/ symlinks for all TTS shell scripts
12. [Verify] Generate test WAV with Kokoro and play with afplay
13. [Verify] Check bot responds to /status via Telegram API1. [预检] 验证Bun已安装
2. [预检] 验证mise已安装
3. [预检] 验证uv已安装
4. [预检] 验证uv可获取Python 3.13
5. [Kokoro] 运行kokoro-install.sh --install
6. [Kokoro] 验证MPS加速可用
7. [BotFather] 引导创建BotFather令牌(或验证现有令牌)
8. [密钥] 将令牌存储到~/.claude/.secrets/ccterrybot-telegram
9. [密钥] 创建指向密钥文件的.mise.local.toml
10. [环境] 将KOKORO_VENV和KOKORO_SCRIPT添加到mise.toml
11. [符号链接] 为所有TTS Shell脚本在~/.local/bin/创建符号链接
12. [验证] 使用Kokoro生成测试WAV并通过afplay播放
13. [验证] 通过Telegram API检查机器人响应/status命令Post-Change Checklist
变更后检查清单
After modifying this skill:
- Verify passes all 8 checks
kokoro-install.sh --health - Confirm is gitignored
.mise.local.toml - Test symlinks resolve correctly ()
ls -la ~/.local/bin/tts_*.sh - Verify bot token works via API call
getMe - Run a full TTS round-trip: clipboard text to audio playback
- Update with change description
references/evolution-log.md
修改此技能后:
- 验证通过全部8项检查
kokoro-install.sh --health - 确认已被Git忽略
.mise.local.toml - 测试符号链接解析正确()
ls -la ~/.local/bin/tts_*.sh - 通过API调用验证机器人令牌可用
getMe - 运行完整的TTS往返测试:剪贴板文本转音频播放
- 在中更新变更说明
references/evolution-log.md
Troubleshooting
故障排除
| Issue | Cause | Solution |
|---|---|---|
| uv not found | Not installed | |
| Python 3.13 not available | Not installed via uv | |
| MPS not available | Not Apple Silicon | Requires M1 or newer Mac |
| Model download fails | Network issue or HuggingFace outage | Check internet connectivity, retry |
| BotFather token invalid | Typo or revoked token | Verify via |
| kokoro-install.sh permission denied | Script not executable | |
| Venv already exists | Previous partial install | Run |
| tts_generate.py not found | Bundle copy failed | Check |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| uv未找到 | 未安装 | |
| Python 3.13不可用 | 未通过uv安装 | |
| MPS不可用 | 非Apple Silicon设备 | 需要M1或更新型号的Mac |
| 模型下载失败 | 网络问题或HuggingFace服务中断 | 检查网络连接,重试下载 |
| BotFather令牌无效 | 输入错误或令牌已被撤销 | 通过 |
| kokoro-install.sh权限被拒绝 | 脚本无执行权限 | |
| 虚拟环境已存在 | 之前的安装未完成 | 先运行 |
| tts_generate.py未找到 | 包复制失败 | 检查插件目录中是否存在 |
Reference Documentation
参考文档
- Kokoro Bootstrap - Detailed venv setup, Python 3.13 via uv, torch + MPS, model download
- BotFather Guide - Step-by-step Telegram bot creation and token management
- Upstream Fork - hexgrad/kokoro fork provenance and tts_generate.py bundling rationale
- Evolution Log - Change history for this skill
- Kokoro引导设置 - 详细的虚拟环境设置、通过uv安装Python 3.13、torch + MPS、模型下载
- BotFather指南 - 分步创建Telegram机器人及令牌管理
- 上游分支 - hexgrad/kokoro分支来源及tts_generate.py捆绑理由
- 变更日志 - 此技能的变更历史