#!/usr/bin/env bash # Re-vendor upstream Agent Skills from github.com/google/skills at a pinned commit. # # Usage: scripts/sync-vendored-skills.sh [<40-char commit sha>] # # Replaces skills/vendor/google/ wholesale, then rewrites SHA256SUMS and VENDOR.md. # Never edit vendored files by hand: review the upstream diff, then re-run this script. set -euo pipefail REPO="google/skills" DEFAULT_COMMIT="81a31a6e4300425598a69fd96c8e843c947ae308" COMMIT="${1:-$DEFAULT_COMMIT}" SKILLS=( google-cloud-solution-architecture google-cloud-waf-security google-cloud-waf-reliability google-cloud-waf-cost-optimization google-cloud-waf-operational-excellence google-cloud-waf-performance-optimization google-cloud-waf-sustainability ) if [[ ! "$COMMIT" =~ ^[0-9a-f]{40}$ ]]; then echo "error: commit must be a full 40-character sha, got '$COMMIT'" >&2 exit 1 fi ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DEST="$ROOT/skills/vendor/google" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT echo "Fetching $REPO@$COMMIT" curl -fsSL "https://codeload.github.com/$REPO/tar.gz/$COMMIT" | tar -xz -C "$TMP" SRC="$TMP/skills-$COMMIT" [[ -d "$SRC" ]] || { echo "error: unexpected archive layout in $TMP" >&2; exit 1; } rm -rf "$DEST" mkdir -p "$DEST" for skill in "${SKILLS[@]}"; do [[ -f "$SRC/skills/cloud/$skill/SKILL.md" ]] || { echo "error: $skill not found upstream" >&2; exit 1; } cp -R "$SRC/skills/cloud/$skill" "$DEST/$skill" done cp "$SRC/LICENSE" "$DEST/LICENSE" ( cd "$DEST" find . -type f ! -name SHA256SUMS ! -name VENDOR.md | sed 's#^\./##' | LC_ALL=C sort \ | while IFS= read -r file; do sha256sum "$file"; done > SHA256SUMS ) { echo "# Vendored Agent Skills: google/skills" echo echo "Unmodified copies of upstream Agent Skills. Do not edit these files; re-run" echo "\`scripts/sync-vendored-skills.sh \` and review the diff instead (ADR-0002)." echo echo "- Source: https://github.com/$REPO" echo "- Commit: \`$COMMIT\`" echo "- Synced: $(date -u +%Y-%m-%d)" echo "- Licence: Apache License 2.0, see \`LICENSE\`" echo "- Integrity: \`SHA256SUMS\` lists every vendored file; \`tests/test_vendored_skills.py\` verifies it." echo echo "## Skills" echo for skill in "${SKILLS[@]}"; do echo "- \`$skill\` (upstream \`skills/cloud/$skill\`)" done } > "$DEST/VENDOR.md" echo "Vendored ${#SKILLS[@]} skills into ${DEST#"$ROOT"/}"