Skills are now deployed globally via Home Manager. Per-repo loading added 1-2s delay on every cd and was 100% redundant with global deployment. Script retained for backward compatibility but will be removed. Closes skills-y7h4
86 lines
2.8 KiB
Bash
Executable file
86 lines
2.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# DEPRECATED: Per-repo skill loading is no longer recommended.
|
|
#
|
|
# Skills are now deployed globally via Home Manager (dotfiles/home/claude.nix).
|
|
# This eliminates the 1-2 second delay on every `cd` caused by nix build calls.
|
|
#
|
|
# If you have a .skills file or source this script in .envrc, you can safely
|
|
# remove those lines. All skills are available globally at ~/.claude/skills/,
|
|
# ~/.codex/skills/, etc.
|
|
#
|
|
# This script remains for backward compatibility but will be removed in a
|
|
# future update. See: https://github.com/dan/skills/issues/y7h4
|
|
#
|
|
# --- LEGACY DOCUMENTATION ---
|
|
# Helper for per-repo skill deployment via direnv
|
|
# Source this from your .envrc or copy the functions
|
|
#
|
|
# Usage in .envrc:
|
|
# source ~/proj/skills/bin/use-skills.sh
|
|
# export CODEX_HOME="$PWD/.codex" # Optional: per-repo Codex skills
|
|
# use_skills worklog web-search
|
|
#
|
|
# Or with manifest file:
|
|
# source ~/proj/skills/bin/use-skills.sh
|
|
# load_skills_from_manifest
|
|
|
|
set -euo pipefail
|
|
|
|
# Default to per-repo Codex skills unless overridden by the caller.
|
|
export CODEX_HOME="${CODEX_HOME:-$PWD/.codex}"
|
|
export GEMINI_HOME="${GEMINI_HOME:-$PWD/.gemini}"
|
|
|
|
# Ensure global auth is available in per-repo CODEX_HOME to prevent login resets
|
|
if [[ -n "${CODEX_HOME:-}" && -f "$HOME/.codex/auth.json" ]]; then
|
|
mkdir -p "$CODEX_HOME"
|
|
# Check before linking to avoid unnecessary unlink+link on every direnv trigger
|
|
[[ -e "$CODEX_HOME/auth.json" ]] || ln -sf "$HOME/.codex/auth.json" "$CODEX_HOME/auth.json"
|
|
fi
|
|
|
|
# Default repo - uses local git, override with SKILLS_REPO for remote
|
|
SKILLS_REPO="${SKILLS_REPO:-git+file://$HOME/proj/skills}"
|
|
|
|
# Install a single skill via nix build + symlink
|
|
use_skill() {
|
|
local skill="$1"
|
|
local out
|
|
|
|
out=$(nix build --option warn-dirty false --print-out-paths --no-link "${SKILLS_REPO}#${skill}") || {
|
|
echo "use_skill: failed to build ${skill}" >&2
|
|
return 1
|
|
}
|
|
|
|
mkdir -p .claude/skills .opencode/skills
|
|
ln -sfn "$out" ".claude/skills/${skill}"
|
|
ln -sfn "$out" ".opencode/skills/${skill}"
|
|
if [[ -n "${CODEX_HOME:-}" ]]; then
|
|
mkdir -p "${CODEX_HOME}/skills"
|
|
ln -sfn "$out" "${CODEX_HOME}/skills/${skill}"
|
|
fi
|
|
if [[ -n "${GEMINI_HOME:-}" ]]; then
|
|
mkdir -p "${GEMINI_HOME}/skills"
|
|
ln -sfn "$out" "${GEMINI_HOME}/skills/${skill}"
|
|
fi
|
|
echo "use_skill: ${skill}"
|
|
}
|
|
|
|
# Install multiple skills
|
|
use_skills() {
|
|
for skill in "$@"; do
|
|
use_skill "$skill" || return 1
|
|
done
|
|
}
|
|
|
|
# Load skills from .skills manifest file
|
|
load_skills_from_manifest() {
|
|
[[ ! -f .skills ]] && return 0
|
|
while IFS= read -r skill || [[ -n "$skill" ]]; do
|
|
# Skip empty lines and comments
|
|
[[ -z "$skill" || "$skill" =~ ^[[:space:]]*# ]] && continue
|
|
# Strip inline comments and whitespace
|
|
skill="${skill%%#*}"
|
|
skill="${skill// /}"
|
|
[[ -n "$skill" ]] && { use_skill "$skill" || return 1; }
|
|
done < .skills
|
|
}
|