111 lines
3.6 KiB
Bash
111 lines
3.6 KiB
Bash
|
|
#!/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/agents/ 使用 .agent.md 后缀(Copilot 要求)
|
|||
|
|
# 其他平台使用 .md 后缀
|
|||
|
|
AGENTS_SRC=".ai/agents"
|
|||
|
|
echo ""
|
|||
|
|
echo "=== Syncing agents from $AGENTS_SRC ==="
|
|||
|
|
agent_count=0
|
|||
|
|
|
|||
|
|
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 "${PLATFORMS[@]}"; do
|
|||
|
|
target_dir="$platform/agents"
|
|||
|
|
mkdir -p "$target_dir"
|
|||
|
|
if [ "$platform" = ".github" ]; then
|
|||
|
|
cp "$agent_file" "$target_dir/${base_name}.agent.md"
|
|||
|
|
else
|
|||
|
|
cp "$agent_file" "$target_dir/${base_name}.md"
|
|||
|
|
fi
|
|||
|
|
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"
|