新 Mac:从空机到可工作的恢复顺序
恢复原则
- 先身份,后配置:先恢复 GitHub 与秘密存储访问,再克隆私有仓。
- 先源码,后状态:恢复规则、脚本和配置;会话、日志、缓存、数据库不盲目搬运。
- 逐层验收:每完成一层就运行 doctor,不把“已克隆”当成“可工作”。
Gate 0:取得恢复入口
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git gh node@22
gh auth login
gh repo clone mykcs/fuhuo_20260419 ~/fuhuo_20260419
cd ~/fuhuo_20260419
bash scripts/recovery-doctor.sh 首次运行出现 FAIL/WARN 是预期结果;它就是待恢复清单。
Gate 1:shell 与基础开发工具
- 用 chezmoi 从私有
mykcs/dotfiles恢复 shell、Git 与常用工具配置。 - 安装 VS Code/Cursor、Claude Code、Codex、Kimi、Gemini 等实际使用的 CLI。
- 重新打开终端,确认 PATH、代理和 Git 身份来自新主机配置,而非旧缓存。
Gate 2:恢复 Agent harness 源码
gh repo clone mykcs/.agents ~/.agents
gh repo clone mykcs/.claude ~/.claude
gh repo clone mykcs/.codex ~/.codex
gh repo clone mykcs/myk-skills ~/.agents/skills
gh repo clone mykcs/.gemini ~/.gemini
gh repo clone mykcs/omc ~/.omc 核心职责
~/.agents:Claude、Codex、Kimi 共用指令的唯一源头。~/.claude/~/.codex:各自运行时配置、规则和记忆。~/.agents/skills:共享 skills 源码;Claude/Mavis 只通过 symlink 消费。~/.agents/profiles:Kimi Code 与 Mavis 的脱敏恢复模板。
bash ~/.agents/bin/compile-agent-instructions.sh --install
bash ~/.agents/bin/compile-agent-instructions.sh --check
bash scripts/recovery-doctor.sh Gate 3:只在本地恢复秘密
从密码管理器、macOS Keychain 或离线加密备份恢复:
- GitHub/SSH 凭据、API key、OAuth refresh token;
- Kimi/MiniMax provider key、Mavis channel identity;
- 云服务登录与设备绑定。
禁止:从 Git 仓库恢复 .aws 密钥、OAuth 文件、session、logs、数据库或浏览器状态。
Gate 4:恢复可选工具
按实际需要再恢复支持层;不要为了“目录齐全”复制不再使用的 runtime。
gh repo clone mykcs/.cursor ~/.cursor
gh repo clone mykcs/.antigravity ~/.antigravity
gh repo clone mykcs/.openclaw ~/.openclaw
gh repo clone mykcs/.happy ~/.happy
gh repo clone mykcs/.cc-switch ~/.cc-switch
gh repo clone mykcs/.agent-reach ~/.agent-reach .kimi-code、.minimax 与 .opencode 属于“重装后恢复脱敏配置”,不整目录克隆。
完成门槛
scripts/recovery-doctor.sh的关键项为 0 failures;- Claude/Codex/Kimi 指令投影检查通过;
- 每个实际使用的 CLI 能启动一个只读 smoke task;
- 随机选一个研究仓库完成 clone、测试与只读 GitHub 查询。