sync-dotfiles
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen to invoke
何时调用
- User says "sync dotfiles", "pull configs", "push configs", "check drift"
- After a session where permissions or hooks were modified
- On a new machine after cloning ai-env
- 用户说出“sync dotfiles”、“pull configs”、“push configs”、“check drift”时
- 在修改了权限或钩子的会话结束后
- 在新机器上克隆完ai-env之后
Subcommands
子命令
Map user intent to sync.sh subcommand:
| Intent | Command | What it does |
|---|---|---|
| "check what's different" | | Show drift between repo and home |
| "what's tracked" | | Show file registry |
| "capture my local changes" | | Home → repo (home wins) |
| "deploy repo configs" | | Repo → home (repo wins) |
| "install skills" | | Install skills via npx |
| "sync" (ambiguous) | Show diff first, then ask direction | Safe default |
将用户意图映射到sync.sh子命令:
| 意图 | 命令 | 功能 |
|---|---|---|
| “检查差异内容” | | 展示仓库和home目录之间的配置漂移 |
| “查看跟踪的文件” | | 展示文件注册表 |
| “保存我的本地变更” | | Home目录 → 仓库(以Home目录内容为准) |
| “部署仓库配置” | | 仓库 → Home目录(以仓库内容为准) |
| “安装skills” | | 通过npx安装skills |
| “sync”(意图不明确) | 先展示差异,再询问同步方向 | 安全默认选项 |
Running sync.sh
运行sync.sh
The sync script is bundled with this skill at (same directory as this SKILL.md).
Run it directly — the script discovers the ai-env repo automatically:
sync.shbash
/path/to/skill/sync.sh <subcommand>The script sets automatically via the discovery chain below. To override:
AI_ENV_ROOTbash
AI_ENV_ROOT=/custom/path/to/ai-env /path/to/skill/sync.sh push同步脚本与本skill绑定,位于(与本SKILL.md同目录)。
直接运行即可——脚本会自动发现ai-env仓库:
sync.shbash
/path/to/skill/sync.sh <subcommand>脚本会通过如下发现链自动设置。如需自定义覆盖:
AI_ENV_ROOTbash
AI_ENV_ROOT=/custom/path/to/ai-env /path/to/skill/sync.sh pushAI_ENV_ROOT discovery
AI_ENV_ROOT发现逻辑
The script discovers the ai-env repo (where lives) automatically:
dotfiles/- If is set and
$AI_ENV_ROOTexists: use that$AI_ENV_ROOT/dotfiles - If the script is inside an ai-env git repo (e.g., running from a symlink): use that repo root
- If exists: use that
~/projects/camacho/ai-env - Clone to a temp dir via GitHub
camacho/ai-env - If clone fails: error with instructions to set
AI_ENV_ROOT
脚本会自动发现ai-env仓库(所在的位置):
dotfiles/- 如果设置了且
$AI_ENV_ROOT存在:使用该路径$AI_ENV_ROOT/dotfiles - 如果脚本位于ai-env git仓库内部(例如从符号链接运行):使用该仓库根目录
- 如果存在:使用该路径
~/projects/camacho/ai-env - 通过GitHub将克隆到临时目录
camacho/ai-env - 如果克隆失败:抛出错误并提示设置
AI_ENV_ROOT
After pull
pull操作完成后
Show and offer to commit:
git diff dotfiles/chore: sync dotfiles展示并提供提交选项:
git diff dotfiles/chore: sync dotfilesAfter push
push操作完成后
Run to confirm, warn about any missing files.
sync.sh status运行确认结果,对所有缺失的文件发出警告。
sync.sh status