Files
wehub-resource-sync b3a7f98e5a
CI / E2E Cloudflare (4/8) (push) Failing after 0s
CI / E2E Cloudflare (8/8) (push) Failing after 1s
CI / Lint (push) Failing after 1s
Auto Extract / Extract (push) Failing after 4s
CI / Version Check (push) Failing after 9s
CI / Integration Tests (push) Failing after 1s
CI / E2E tests (1/8) (push) Failing after 1s
CI / E2E tests (2/8) (push) Failing after 2s
CI / E2E tests (3/8) (push) Failing after 2s
CI / Browser Tests (push) Failing after 1s
CI / E2E tests (5/8) (push) Failing after 1s
CI / E2E Cloudflare (2/8) (push) Failing after 2s
CI / Typecheck (push) Failing after 1s
CI / Changeset Validation (push) Failing after 2s
CI / E2E Cloudflare (5/8) (push) Failing after 1s
CI / E2E Cloudflare (6/8) (push) Failing after 1s
CI / E2E Cloudflare (7/8) (push) Failing after 1s
CodeQL / Analyze (javascript-typescript) (push) Failing after 1s
Format / Format (push) Failing after 0s
CodeQL / Analyze (actions) (push) Failing after 4s
CI / E2E tests (4/8) (push) Failing after 1s
CI / E2E tests (6/8) (push) Failing after 1s
CI / E2E tests (7/8) (push) Failing after 2s
CI / E2E tests (8/8) (push) Failing after 1s
CI / E2E Cloudflare (1/8) (push) Failing after 1s
CI / E2E Cloudflare (3/8) (push) Failing after 2s
Preview Releases / Publish Preview (push) Failing after 0s
zizmor / Run zizmor (push) Failing after 1s
Release / Release (push) Failing after 2s
CI / Smoke Tests (push) Failing after 5m36s
CI / Tests (push) Failing after 6m36s
Release / Sync Templates (push) Has been skipped
CI / E2E Tests (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:23:53 +08:00

108 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
#
# Syncs agent skills and AGENTS.md into each template directory.
# Creates .claude/skills symlink and CLAUDE.md symlink for Claude Code compatibility.
#
# Usage: ./scripts/sync-template-skills.sh
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"
SKILLS_DIR="$ROOT_DIR/skills"
TEMPLATES_DIR="$ROOT_DIR/templates"
AGENTS_BASE="$SCRIPT_DIR/agents-base.md"
# Skills to sync into templates
SKILLS=(
"building-emdash-site"
"creating-plugins"
"emdash-cli"
)
sync_skills() {
local template_dir="$1"
local template_name="$(basename "$template_dir")"
local agents_dir="$template_dir/.agents/skills"
local claude_dir="$template_dir/.claude"
echo "Syncing skills -> $template_name"
for skill in "${SKILLS[@]}"; do
local src="$SKILLS_DIR/$skill"
local dest="$agents_dir/$skill"
if [[ ! -d "$src" ]]; then
echo " Skipping: $skill (not found in skills/)"
continue
fi
# Remove existing copy
if [[ -d "$dest" ]]; then
rm -rf "$dest"
fi
mkdir -p "$agents_dir"
cp -r "$src" "$dest"
echo " Copied: $skill"
done
# Create .claude/skills symlink
mkdir -p "$claude_dir"
local symlink="$claude_dir/skills"
if [[ -L "$symlink" ]]; then
rm "$symlink"
elif [[ -e "$symlink" ]]; then
rm -rf "$symlink"
fi
ln -s ../.agents/skills "$symlink"
echo " Linked: .claude/skills -> ../.agents/skills"
# Generate AGENTS.md = shared base + per-template body.
# Per-template body lives in AGENTS-template.md inside the template (or in the
# base variant for *-cloudflare templates, which don't carry their own body).
if [[ -f "$AGENTS_BASE" ]]; then
local template_body="$template_dir/AGENTS-template.md"
if [[ ! -f "$template_body" ]]; then
# Fall back to the base template body for *-cloudflare variants.
local base_name="${template_name%-cloudflare}"
if [[ "$base_name" != "$template_name" ]]; then
template_body="$TEMPLATES_DIR/$base_name/AGENTS-template.md"
fi
fi
if [[ -f "$template_body" ]]; then
cat "$AGENTS_BASE" > "$template_dir/AGENTS.md"
printf "\n" >> "$template_dir/AGENTS.md"
cat "$template_body" >> "$template_dir/AGENTS.md"
echo " Generated: AGENTS.md (base + $(basename "$(dirname "$template_body")")/AGENTS-template.md)"
else
cp "$AGENTS_BASE" "$template_dir/AGENTS.md"
echo " Generated: AGENTS.md (base only, no AGENTS-template.md)"
fi
# Create CLAUDE.md symlink
local claude_md="$template_dir/CLAUDE.md"
if [[ -L "$claude_md" ]]; then
rm "$claude_md"
elif [[ -f "$claude_md" ]]; then
rm "$claude_md"
fi
ln -s AGENTS.md "$claude_md"
echo " Linked: CLAUDE.md -> AGENTS.md"
fi
}
echo "Syncing agent skills to templates..."
echo ""
for template_dir in "$TEMPLATES_DIR"/*/; do
# Skip if not a directory
[[ -d "$template_dir" ]] || continue
sync_skills "$template_dir"
echo ""
done
echo "Done!"