#!/bin/bash # sync-all.sh — 将 .ai/ 下的 skills、protocols、agents 同步到各平台目录 # 新增或更新后运行此脚本即可同步到全部平台 # 用法: bash .ai/sync-all.sh set -e PLATFORMS=(".cursor" ".claude" ".github" ".kiro") # ── 1. Sync skills ────────────────────────────────────────────── SKILLS_SRC=".ai/skills" echo "=== Syncing skills from $SKILLS_SRC ===" skill_count=0 for skill_dir in "$SKILLS_SRC"/*/; do [ -d "$skill_dir" ] || continue skill=$(basename "$skill_dir") skill_md="$skill_dir/SKILL.md" [ -f "$skill_md" ] || continue for platform in "${PLATFORMS[@]}"; do target_dir="$platform/skills/$skill" mkdir -p "$target_dir" cp "$skill_md" "$target_dir/SKILL.md" done echo " ✓ skill: $skill" ((skill_count++)) done # ── 2. Sync protocols ────────────────────────────────────────── PROTOCOLS_SRC=".ai/protocols" echo "" echo "=== Syncing protocols from $PROTOCOLS_SRC ===" proto_count=0 if [ -d "$PROTOCOLS_SRC" ]; then for proto_file in "$PROTOCOLS_SRC"/*.md; do [ -f "$proto_file" ] || continue filename=$(basename "$proto_file") for platform in "${PLATFORMS[@]}"; do target_dir="$platform/protocols" mkdir -p "$target_dir" cp "$proto_file" "$target_dir/$filename" done echo " ✓ protocol: $filename" ((proto_count++)) done fi # ── 3. Sync agents ───────────────────────────────────────────── # .ai/agents/*.md → 各平台 agents/ 目录(跳过 .github,Copilot 兼容 Claude agents) AGENTS_SRC=".ai/agents" echo "" echo "=== Syncing agents from $AGENTS_SRC ===" agent_count=0 # 排除 .github(Copilot 直接使用 .claude/agents/) AGENT_PLATFORMS=(".cursor" ".claude" ".kiro") if [ -d "$AGENTS_SRC" ]; then for agent_file in "$AGENTS_SRC"/*.md; do [ -f "$agent_file" ] || continue base_name=$(basename "$agent_file" .md) for platform in "${AGENT_PLATFORMS[@]}"; do target_dir="$platform/agents" mkdir -p "$target_dir" cp "$agent_file" "$target_dir/${base_name}.md" done echo " ✓ agent: $base_name" ((agent_count++)) done fi # ── 4. Sync hooks ────────────────────────────────────────────── HOOKS_SRC=".ai/hooks" echo "" echo "=== Syncing hooks from $HOOKS_SRC ===" hook_count=0 if [ -d "$HOOKS_SRC" ]; then for hook_file in "$HOOKS_SRC"/*.md; do [ -f "$hook_file" ] || continue filename=$(basename "$hook_file") for platform in "${PLATFORMS[@]}"; do target_dir="$platform/hooks" mkdir -p "$target_dir" cp "$hook_file" "$target_dir/$filename" done echo " ✓ hook: $filename" ((hook_count++)) done fi # ── Summary ───────────────────────────────────────────────────── echo "" echo "Done. Synced to ${#PLATFORMS[@]} platforms:" echo " Skills: $skill_count" echo " Protocols: $proto_count" echo " Agents: $agent_count" echo " Hooks: $hook_count"