#!/bin/bash
# 装机.sh — 一条命令装齐"AI 创意生产线"的工具链（macOS）
# 装完还需手动做：① 登录 Claude Code / Codex  ② 各模型 API Key / 账号  ③ 下载本地模型
set -e

echo "==> 0. 前提：Xcode 命令行工具 + Homebrew"
xcode-select --install 2>/dev/null || true
command -v brew >/dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

echo "==> 1. 系统级工具（brew）"
brew install node python@3.11 ffmpeg whisper-cpp gh

echo "==> 2. 上线工具（Cloudflare）"
npm install -g wrangler

echo "==> 3. Python 媒体工具（pip）"
pip3 install --user edge-tts insightface onnxruntime opencv-python pillow requests numpy

cat <<'EOF'

==============================================
工具链装好了。接下来手动做这几步：

1) 大脑层 Agent：
   curl -fsSL https://claude.ai/install.sh | bash   # 装 Claude Code，再登录
   curl -fsSL https://chatgpt.com/codex/install.sh | sh  # 装 Codex，再 codex login

2) 视频/图像生成（如用火山方舟）：
   注册火山引擎方舟，拿 API Key，存成环境变量：
   export ARK_API_KEY=你的Key       # 别把 Key 写进代码/贴进对话

3) 本地转写模型（whisper）：
   mkdir -p ~/whisper模型
   curl -L -o ~/whisper模型/ggml-large-v3-turbo.bin \
     https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo.bin

4) 本地换脸模型（如需真人进 AI）：
   inswapper_128.onnx 放到持久目录 ~/models/（别放 /tmp）

5) 一键上线（如需发布网页）：
   gh auth login
   export CLOUDFLARE_API_TOKEN=你的token
   export CLOUDFLARE_ACCOUNT_ID=你的account_id
   然后用 脚本/一键上线.sh <项目名> <域名>

验证：
   claude --version ; codex --version
   ffmpeg -version ; whisper-cli --help ; wrangler --version
   python3 -c "import edge_tts, insightface, cv2, PIL, requests"
   edge-tts --voice zh-CN-XiaoxiaoNeural --text "测试" --write-media /tmp/t.mp3
==============================================
EOF
