mirror of
https://github.com/obra/superpowers.git
synced 2026-04-24 10:29:03 +08:00
Add unified scripts system with find-skills and run
Consolidates skill discovery and adds generic runner for cross-platform compatibility. Changes: - Created scripts/find-skills: Unified tool (show all + filter by pattern) - Shows descriptions by default - Searches personal first, then core (shadowing) - Logs searches for gap analysis - Bash 3.2 compatible - Created scripts/run: Generic runner for any skill script - Searches personal superpowers first, then core - Enables running arbitrary skill scripts without CLAUDE_PLUGIN_ROOT env var - Example: scripts/run skills/collaboration/remembering-conversations/tool/search-conversations - Fixed bash 3.2 compatibility in list-skills, skills-search - Replaced associative arrays with newline-delimited lists - Works on macOS default bash (3.2) and Linux bash 4+ - Updated all documentation to reference scripts/find-skills - Removed redundant wrapper scripts This solves the CLAUDE_PLUGIN_ROOT environment variable issue - scripts can now be called from anywhere without needing the env var set.
This commit is contained in:
55
scripts/run
Executable file
55
scripts/run
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# Generic runner for skill scripts
|
||||
# Searches personal superpowers first, then core plugin
|
||||
#
|
||||
# Usage: scripts/run <skill-relative-path> [args...]
|
||||
# Example: scripts/run skills/collaboration/remembering-conversations/tool/search-conversations "query"
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat <<'EOF'
|
||||
Usage: scripts/run <skill-relative-path> [args...]
|
||||
|
||||
Runs scripts from skills, checking personal superpowers first, then core.
|
||||
|
||||
Examples:
|
||||
scripts/run skills/collaboration/remembering-conversations/tool/search-conversations "query"
|
||||
scripts/run skills/getting-started/list-skills
|
||||
scripts/run skills/getting-started/skills-search "pattern"
|
||||
|
||||
The script will be found at:
|
||||
1. ~/.config/superpowers/<skill-relative-path> (personal, if exists)
|
||||
2. ${CLAUDE_PLUGIN_ROOT}/<skill-relative-path> (core plugin)
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the script path to run
|
||||
SCRIPT_PATH="$1"
|
||||
shift # Remove script path from args, leaving remaining args
|
||||
|
||||
# Determine directories
|
||||
PERSONAL_SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# Try personal superpowers first
|
||||
PERSONAL_SCRIPT="${PERSONAL_SUPERPOWERS_DIR}/${SCRIPT_PATH}"
|
||||
if [[ -x "$PERSONAL_SCRIPT" ]]; then
|
||||
exec "$PERSONAL_SCRIPT" "$@"
|
||||
fi
|
||||
|
||||
# Fall back to core plugin
|
||||
CORE_SCRIPT="${PLUGIN_ROOT}/${SCRIPT_PATH}"
|
||||
if [[ -x "$CORE_SCRIPT" ]]; then
|
||||
exec "$CORE_SCRIPT" "$@"
|
||||
fi
|
||||
|
||||
# Not found
|
||||
echo "Error: Script not found: $SCRIPT_PATH" >&2
|
||||
echo "" >&2
|
||||
echo "Searched:" >&2
|
||||
echo " $PERSONAL_SCRIPT (personal)" >&2
|
||||
echo " $CORE_SCRIPT (core)" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user