-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-skills.sh
More file actions
executable file
·65 lines (56 loc) · 1.95 KB
/
Copy pathsync-skills.sh
File metadata and controls
executable file
·65 lines (56 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
#
# Mirror the canonical skills into each agent's namespaced directory.
#
# Canonical skills live in .agents/skills/<name>/ (read directly by Gemini CLI and
# opencode). Claude Code reads .claude/skills/ and Codex CLI reads .codex/skills/,
# so we keep real copies there. Real copies (not symlinks) are used because Libra
# does not track symlinks and because copies survive Windows clones and zip downloads.
#
# Usage:
# scripts/sync-skills.sh # mirror canonical -> .claude/skills + .codex/skills
# scripts/sync-skills.sh --check # exit non-zero if any mirror is out of date (for CI)
#
# Run this after editing anything under .agents/skills/, before committing.
set -euo pipefail
repo_root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$repo_root"
src=".agents/skills"
tools=(claude codex)
check_only=false
[ "${1:-}" = "--check" ] && check_only=true
[ -d "$src" ] || { echo "error: no $src directory found" >&2; exit 1; }
drift=0
for tool in "${tools[@]}"; do
dest=".${tool}/skills"
mkdir -p "$dest"
# Remove mirrored skills whose canonical source is gone.
for d in "$dest"/*/; do
[ -d "$d" ] || continue
name="$(basename "$d")"
if [ ! -d "$src/$name" ]; then
if $check_only; then echo "drift: $dest/$name has no canonical source"; drift=1
else rm -rf "$dest/$name"; echo "removed stale $dest/$name"; fi
fi
done
# Mirror each canonical skill.
for skill in "$src"/*/; do
[ -d "$skill" ] || continue
name="$(basename "$skill")"
if $check_only; then
if ! diff -rq "$skill" "$dest/$name" >/dev/null 2>&1; then
echo "drift: $dest/$name differs from $src/$name"; drift=1
fi
else
rm -rf "$dest/$name"
cp -R "$skill" "$dest/$name"
echo "synced $dest/$name"
fi
done
done
if $check_only && [ "$drift" -ne 0 ]; then
echo "skills are out of sync — run scripts/sync-skills.sh" >&2
exit 1
fi
$check_only && echo "all agent skill mirrors are up to date"
exit 0