SuperAPI AI Directory

doc-sync-tool

General & other

View repository

Updated 10-16 09:34

About this skill

Documentation Sync Tool (Doc Sync Tool)

Function Description

This tool is used to automatically synchronize the AI Agent configuration documents in the project, ensuring that Agents.md、claude.md and gemini.md three files maintain consistent content.

Core Features

  1. Automatic Discovery: Recursively scan all folders under the current directory to find these three documents
  2. Intelligent Sync: When any one document is found, automatically create/update the other two
  3. File Monitoring: Monitor file changes in real time and automatically synchronize the latest content
  4. Manual Trigger: Supports manual command-line execution of synchronization

Use Cases

  • Share the same project configuration among multiple AI Agents
  • Automatically keep the work instructions of different AIs consistent
  • Avoid the hassle of manually maintaining multiple identical documents

Usage

Install Dependencies

cd /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool
pnpm install

Manual Sync (single execution)

# 在项目根目录执行
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/sync.js

# 或者使用 npm script
pnpm run sync

Automatic Monitoring (continuous running)

# 启动文件监听服务
node /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js

# 或者使用 npm script
pnpm run watch

Run in the Background (recommended)

# 使用 PM2 在后台运行
pm2 start /Users/ben/Downloads/go\ to\ wild/auto-website-system/_skills/doc-sync-tool/watch.js --name doc-sync

# 查看状态
pm2 status

# 停止服务
pm2 stop doc-sync

How It Works

  1. Scanning Phase: Recursively traverse the specified directory to find Agents.md、claude.md、gemini.md files
  2. Grouping Phase: Group these three files in the same folder together
  3. Synchronization 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 synchronize it to the other files
  4. Monitoring Phase (watch mode): Continuously monitor file changes and trigger synchronization

Configuration Options

You can modify the following configurations in sync.js :

const CONFIG = {
  targetFiles: ['Agents.md', 'claude.md', 'gemini.md'],  // 目标文件列表
  scanPath: process.cwd(),                                // 扫描路径(默认当前目录)
  excludeDirs: ['node_modules', '.git', '.next', 'dist'] // 排除目录
};

Notes

  • The tool will automatically skip directories such as node_modules、.git、.next、dist etc. directory
  • During synchronization, the original format and content of the files are preserved
  • It is recommended to use it in a Git repository to facilitate tracking file changes
  • Monitoring mode runs continuously; it is recommended to use PM2 to manage the process

Troubleshooting

Permission Issues

chmod +x sync.js watch.js

Node.js Version Requirements

Requires Node.js 14+

Dependency Installation Failure

rm -rf node_modules package-lock.json
pnpm install