skills/bin/use-skills.sh
dan 90e72f1095 fix(use-skills): prevent stderr from corrupting symlink targets
Remove 2>&1 from nix build capture. When repo is dirty, nix emits
warnings to stderr which were being merged into $out and used as
symlink targets, creating broken symlinks like:

  orch -> warning: Git tree '...' is dirty\n/nix/store/...

Now stderr goes to terminal, only stdout (store path) captured.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 12:42:26 -08:00

53 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# 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
# use_skills worklog web-search
#
# Or with manifest file:
# source ~/proj/skills/bin/use-skills.sh
# load_skills_from_manifest
set -euo pipefail
# 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 --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}"
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
}