doc-sync-tool
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese文档同步工具 (Doc Sync Tool)
Doc Sync Tool
功能说明
Feature Description
这个工具用于自动同步项目中的 AI Agent 配置文档,确保 、 和 三个文件内容保持一致。
Agents.mdclaude.mdgemini.mdThis tool is used to automatically sync AI Agent configuration documents in the project, ensuring that the content of the three files , and remains consistent.
Agents.mdclaude.mdgemini.md核心功能
Core Features
- 自动发现: 递归扫描当前目录下所有文件夹,查找这三个文档
- 智能同步: 发现任意一个文档时,自动创建/更新其余两个
- 文件监听: 实时监听文件变化,自动同步最新内容
- 手动触发: 支持命令行手动执行同步
- Auto Discovery: Recursively scan all folders in the current directory to find these three documents
- Intelligent Sync: When any one of the documents is found, automatically create/update the other two
- File Monitoring: Real-time monitoring of file changes, automatically sync the latest content
- Manual Trigger: Supports manual execution of sync via command line
使用场景
Usage Scenarios
- 在多个 AI Agent 之间共享相同的项目配置
- 自动保持不同 AI 的工作指令一致
- 避免手动维护多个相同文档的麻烦
- Share the same project configuration among multiple AI Agents
- Automatically keep work instructions consistent across different AIs
- Avoid the hassle of manually maintaining multiple identical documents
使用方法
Usage Methods
安装依赖
Install Dependencies
bash
cd /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool
pnpm installbash
cd /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool
pnpm install手动同步(单次执行)
Manual Sync (One-time Execution)
bash
undefinedbash
undefined在项目根目录执行
Execute in the project root directory
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/sync.js
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/sync.js
或者使用 npm script
Or use npm script
pnpm run sync
undefinedpnpm run sync
undefined自动监听(持续运行)
Auto Monitoring (Continuous Run)
bash
undefinedbash
undefined启动文件监听服务
Start the file monitoring service
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js
或者使用 npm script
Or use npm script
pnpm run watch
undefinedpnpm run watch
undefined后台运行(推荐)
Run in Background (Recommended)
bash
undefinedbash
undefined使用 PM2 在后台运行
Run in background using PM2
pm2 start /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js --name doc-sync
pm2 start /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js --name doc-sync
查看状态
Check status
pm2 status
pm2 status
停止服务
Stop service
pm2 stop doc-sync
undefinedpm2 stop doc-sync
undefined工作原理
Working Principle
- 扫描阶段: 递归遍历指定目录,查找 、
Agents.md、claude.md文件gemini.md - 分组阶段: 将同一文件夹下的这三个文件归为一组
- 同步阶段:
- 如果某组只有一个文件,复制内容创建其余两个
- 如果某组有多个文件,选择最新修改的作为源,同步到其他文件
- 监听阶段 (watch 模式): 持续监听文件变化,触发同步
- Scanning Phase: Recursively traverse the specified directory to find ,
Agents.md,claude.mdfilesgemini.md - Grouping Phase: Group these three files in the same folder into one group
- Sync Phase:
- If a group has only one file, copy its content to create the other two
- If a group has multiple files, select the most recently modified one as the source and sync to other files
- Monitoring Phase (watch mode): Continuously monitor file changes and trigger sync
配置选项
Configuration Options
可以在 中修改以下配置:
sync.jsjavascript
const CONFIG = {
targetFiles: ['Agents.md', 'claude.md', 'gemini.md'], // 目标文件列表
scanPath: process.cwd(), // 扫描路径(默认当前目录)
excludeDirs: ['node_modules', '.git', '.next', 'dist'] // 排除目录
};You can modify the following configurations in :
sync.jsjavascript
const CONFIG = {
targetFiles: ['Agents.md', 'claude.md', 'gemini.md'], // Target file list
scanPath: process.cwd(), // Scan path (current directory by default)
excludeDirs: ['node_modules', '.git', '.next', 'dist'] // Excluded directories
};注意事项
Notes
- 工具会自动跳过 、
node_modules、.git、.next等目录dist - 同步时会保留文件的原始格式和内容
- 建议在 Git 仓库中使用,方便追踪文件变化
- 监听模式会持续运行,建议使用 PM2 管理进程
- The tool will automatically skip directories such as ,
node_modules,.git,.nextdist - The original format and content of the files will be preserved during sync
- It is recommended to use in a Git repository for easy tracking of file changes
- The monitoring mode runs continuously, it is recommended to use PM2 to manage the process
故障排除
Troubleshooting
权限问题
Permission Issues
bash
chmod +x sync.js watch.jsbash
chmod +x sync.js watch.jsNode.js 版本要求
Node.js Version Requirement
需要 Node.js 14+ 版本
Node.js 14+ is required
依赖安装失败
Dependency Installation Failure
bash
rm -rf node_modules package-lock.json
pnpm installbash
rm -rf node_modules package-lock.json
pnpm install