vfx-skills-draft/install.sh
2026-01-24 23:28:43 -07:00

169 lines
4.3 KiB
Bash

#!/bin/bash
# vfx-skills installer
# Symlinks VFX skills to your AI agent's skills directory
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_DIR="$SCRIPT_DIR/skills"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_header() {
echo ""
echo "vfx-skills installer"
echo "===================="
echo ""
}
detect_agents() {
local agents=()
if [ -d "$HOME/.claude" ]; then
agents+=("claude-code:$HOME/.claude/skills")
fi
if [ -d "$HOME/.config/opencode" ]; then
agents+=("opencode:$HOME/.config/opencode/skills")
fi
if [ -d "$HOME/.cursor" ]; then
agents+=("cursor:$HOME/.cursor/skills")
fi
if [ -d "$HOME/.gemini" ]; then
agents+=("gemini:$HOME/.gemini/skills")
fi
echo "${agents[@]}"
}
install_skills() {
local target_dir="$1"
local agent_name="$2"
echo -e "installing to ${GREEN}$agent_name${NC} ($target_dir)..."
# Create target directory if it doesn't exist
mkdir -p "$target_dir"
local installed=0
local skipped=0
for skill_dir in "$SKILLS_DIR"/*/; do
if [ -f "$skill_dir/SKILL.md" ]; then
skill_name=$(basename "$skill_dir")
target="$target_dir/$skill_name"
if [ -L "$target" ]; then
# Remove existing symlink
rm "$target"
elif [ -e "$target" ]; then
echo -e " ${YELLOW}skip${NC}: $skill_name (already exists, not a symlink)"
((skipped++))
continue
fi
ln -s "$skill_dir" "$target"
((installed++))
fi
done
echo -e " done: ${GREEN}$installed installed${NC}, $skipped skipped"
echo ""
}
# Parse arguments
TARGET_AGENT=""
LOCAL_INSTALL=false
while [[ $# -gt 0 ]]; do
case $1 in
--agent=*)
TARGET_AGENT="${1#*=}"
shift
;;
--local)
LOCAL_INSTALL=true
shift
;;
--help|-h)
echo "usage: ./install.sh [options]"
echo ""
echo "options:"
echo " --agent=NAME Install for specific agent (claude-code, opencode, cursor, gemini)"
echo " --local Install to current directory instead of global"
echo " --help Show this help"
exit 0
;;
*)
echo "unknown option: $1"
exit 1
;;
esac
done
print_header
# Check skills directory exists
if [ ! -d "$SKILLS_DIR" ]; then
echo -e "${RED}error${NC}: skills directory not found at $SKILLS_DIR"
exit 1
fi
# Count available skills
skill_count=$(find "$SKILLS_DIR" -maxdepth 2 -name "SKILL.md" | wc -l)
echo "found $skill_count skills"
if $LOCAL_INSTALL; then
# Install to current directory
echo "installing to current project..."
install_skills ".claude/skills" "local project"
else
# Detect and install to agents
if [ -n "$TARGET_AGENT" ]; then
case $TARGET_AGENT in
claude-code)
install_skills "$HOME/.claude/skills" "Claude Code"
;;
opencode)
install_skills "$HOME/.config/opencode/skills" "OpenCode"
;;
cursor)
install_skills "$HOME/.cursor/skills" "Cursor"
;;
gemini)
install_skills "$HOME/.gemini/skills" "Gemini CLI"
;;
*)
echo -e "${RED}error${NC}: unknown agent '$TARGET_AGENT'"
echo "available agents: claude-code, opencode, cursor, gemini"
exit 1
;;
esac
else
# Auto-detect agents
agents=$(detect_agents)
if [ -z "$agents" ]; then
# Default to claude-code if nothing detected
echo "no agents detected, defaulting to Claude Code..."
install_skills "$HOME/.claude/skills" "Claude Code"
else
for agent in $agents; do
name="${agent%%:*}"
path="${agent#*:}"
install_skills "$path" "$name"
done
fi
fi
fi
echo -e "${GREEN}installation complete!${NC}"
echo "restart your agent to load the new skills."
echo ""