mirror of
https://github.com/mattpocock/skills.git
synced 2026-06-25 08:24:06 +00:00
Link skills into ~/.agents/skills as well as ~/.claude/skills
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c71fce0297
commit
74f0450b9c
1 changed files with 41 additions and 27 deletions
|
|
@ -1,38 +1,52 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Links all skills in the repository to ~/.claude/skills, so that
|
# Links all skills in the repository into the local skill directories used by
|
||||||
# they can be used by the local Claude CLI.
|
# each agent harness:
|
||||||
|
# - ~/.claude/skills — Claude Code
|
||||||
|
# - ~/.agents/skills — pi and other Agent-Skills-standard harnesses
|
||||||
|
# Each entry is a symlink into this repo, so a `git pull` is all that's needed
|
||||||
|
# to keep installed skills up to date.
|
||||||
|
|
||||||
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
DEST="$HOME/.claude/skills"
|
DESTS=("$HOME/.claude/skills" "$HOME/.agents/skills")
|
||||||
|
|
||||||
# If ~/.claude/skills is a symlink that resolves into this repo, we'd end up
|
# Collect the repo's skills once, link into every destination.
|
||||||
# writing the per-skill symlinks back into the repo's own skills/ tree. Detect
|
names=()
|
||||||
# and bail out instead of polluting the working copy.
|
srcs=()
|
||||||
if [ -L "$DEST" ]; then
|
|
||||||
resolved="$(readlink -f "$DEST")"
|
|
||||||
case "$resolved" in
|
|
||||||
"$REPO"|"$REPO"/*)
|
|
||||||
echo "error: $DEST is a symlink into this repo ($resolved)." >&2
|
|
||||||
echo "Remove it (rm \"$DEST\") and re-run; the script will recreate it as a real dir." >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$DEST"
|
|
||||||
|
|
||||||
find "$REPO/skills" -name SKILL.md -not -path '*/node_modules/*' -not -path '*/deprecated/*' -print0 |
|
|
||||||
while IFS= read -r -d '' skill_md; do
|
while IFS= read -r -d '' skill_md; do
|
||||||
src="$(dirname "$skill_md")"
|
src="$(dirname "$skill_md")"
|
||||||
name="$(basename "$src")"
|
names+=("$(basename "$src")")
|
||||||
target="$DEST/$name"
|
srcs+=("$src")
|
||||||
|
done < <(find "$REPO/skills" -name SKILL.md -not -path '*/node_modules/*' -not -path '*/deprecated/*' -print0)
|
||||||
|
|
||||||
if [ -e "$target" ] && [ ! -L "$target" ]; then
|
for DEST in "${DESTS[@]}"; do
|
||||||
rm -rf "$target"
|
# If $DEST is a symlink that resolves into this repo, we'd end up writing the
|
||||||
|
# per-skill symlinks back into the repo's own skills/ tree. Detect and bail
|
||||||
|
# out instead of polluting the working copy.
|
||||||
|
if [ -L "$DEST" ]; then
|
||||||
|
resolved="$(readlink -f "$DEST")"
|
||||||
|
case "$resolved" in
|
||||||
|
"$REPO"|"$REPO"/*)
|
||||||
|
echo "error: $DEST is a symlink into this repo ($resolved)." >&2
|
||||||
|
echo "Remove it (rm \"$DEST\") and re-run; the script will recreate it as a real dir." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sfn "$src" "$target"
|
mkdir -p "$DEST"
|
||||||
echo "linked $name -> $src"
|
|
||||||
|
for i in "${!names[@]}"; do
|
||||||
|
name="${names[$i]}"
|
||||||
|
src="${srcs[$i]}"
|
||||||
|
target="$DEST/$name"
|
||||||
|
|
||||||
|
if [ -e "$target" ] && [ ! -L "$target" ]; then
|
||||||
|
rm -rf "$target"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -sfn "$src" "$target"
|
||||||
|
echo "linked $name -> $src ($DEST)"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue