sync-dotfiles

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When 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:
IntentCommandWhat it does
"check what's different"
sync.sh diff
Show drift between repo and home
"what's tracked"
sync.sh status
Show file registry
"capture my local changes"
sync.sh pull
Home → repo (home wins)
"deploy repo configs"
sync.sh push
Repo → home (repo wins)
"install skills"
sync.sh skills-push
Install skills via npx
"sync" (ambiguous)Show diff first, then ask directionSafe default
将用户意图映射到sync.sh子命令:
意图命令功能
“检查差异内容”
sync.sh diff
展示仓库和home目录之间的配置漂移
“查看跟踪的文件”
sync.sh status
展示文件注册表
“保存我的本地变更”
sync.sh pull
Home目录 → 仓库(以Home目录内容为准)
“部署仓库配置”
sync.sh push
仓库 → Home目录(以仓库内容为准)
“安装skills”
sync.sh skills-push
通过npx安装skills
“sync”(意图不明确)先展示差异,再询问同步方向安全默认选项

Running sync.sh

运行sync.sh

The sync script is bundled with this skill at
sync.sh
(same directory as this SKILL.md). Run it directly — the script discovers the ai-env repo automatically:
bash
/path/to/skill/sync.sh <subcommand>
The script sets
AI_ENV_ROOT
automatically via the discovery chain below. To override:
bash
AI_ENV_ROOT=/custom/path/to/ai-env /path/to/skill/sync.sh push
同步脚本与本skill绑定,位于
sync.sh
(与本SKILL.md同目录)。 直接运行即可——脚本会自动发现ai-env仓库:
bash
/path/to/skill/sync.sh <subcommand>
脚本会通过如下发现链自动设置
AI_ENV_ROOT
。如需自定义覆盖:
bash
AI_ENV_ROOT=/custom/path/to/ai-env /path/to/skill/sync.sh push

AI_ENV_ROOT discovery

AI_ENV_ROOT发现逻辑

The script discovers the ai-env repo (where
dotfiles/
lives) automatically:
  1. If
    $AI_ENV_ROOT
    is set and
    $AI_ENV_ROOT/dotfiles
    exists: use that
  2. If the script is inside an ai-env git repo (e.g., running from a symlink): use that repo root
  3. If
    ~/projects/camacho/ai-env
    exists: use that
  4. Clone
    camacho/ai-env
    to a temp dir via GitHub
  5. If clone fails: error with instructions to set
    AI_ENV_ROOT
脚本会自动发现ai-env仓库(
dotfiles/
所在的位置):
  1. 如果设置了
    $AI_ENV_ROOT
    $AI_ENV_ROOT/dotfiles
    存在:使用该路径
  2. 如果脚本位于ai-env git仓库内部(例如从符号链接运行):使用该仓库根目录
  3. 如果
    ~/projects/camacho/ai-env
    存在:使用该路径
  4. 通过GitHub将
    camacho/ai-env
    克隆到临时目录
  5. 如果克隆失败:抛出错误并提示设置
    AI_ENV_ROOT

After pull

pull操作完成后

Show
git diff dotfiles/
and offer to commit:
chore: sync dotfiles
展示
git diff dotfiles/
并提供提交选项:
chore: sync dotfiles

After push

push操作完成后

Run
sync.sh status
to confirm, warn about any missing files.
运行
sync.sh status
确认结果,对所有缺失的文件发出警告。