run 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. # Generic runner for skill scripts
  3. # Searches personal superpowers first, then core plugin
  4. #
  5. # Usage: scripts/run <skill-relative-path> [args...]
  6. # Example: scripts/run skills/collaboration/remembering-conversations/tool/search-conversations "query"
  7. set -euo pipefail
  8. if [[ $# -eq 0 ]]; then
  9. cat <<'EOF'
  10. Usage: scripts/run <skill-relative-path> [args...]
  11. Runs scripts from skills, checking personal superpowers first, then core.
  12. Examples:
  13. scripts/run skills/collaboration/remembering-conversations/tool/search-conversations "query"
  14. scripts/run skills/getting-started/list-skills
  15. scripts/run skills/getting-started/skills-search "pattern"
  16. The script will be found at:
  17. 1. ~/.config/superpowers/<skill-relative-path> (personal, if exists)
  18. 2. ${CLAUDE_PLUGIN_ROOT}/<skill-relative-path> (core plugin)
  19. EOF
  20. exit 1
  21. fi
  22. # Get the script path to run
  23. SCRIPT_PATH="$1"
  24. shift # Remove script path from args, leaving remaining args
  25. # Determine directories
  26. PERSONAL_SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}"
  27. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  28. PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
  29. # Try personal superpowers first
  30. PERSONAL_SCRIPT="${PERSONAL_SUPERPOWERS_DIR}/${SCRIPT_PATH}"
  31. if [[ -x "$PERSONAL_SCRIPT" ]]; then
  32. exec "$PERSONAL_SCRIPT" "$@"
  33. fi
  34. # Fall back to core plugin
  35. CORE_SCRIPT="${PLUGIN_ROOT}/${SCRIPT_PATH}"
  36. if [[ -x "$CORE_SCRIPT" ]]; then
  37. exec "$CORE_SCRIPT" "$@"
  38. fi
  39. # Not found
  40. echo "Error: Script not found: $SCRIPT_PATH" >&2
  41. echo "" >&2
  42. echo "Searched:" >&2
  43. echo " $PERSONAL_SCRIPT (personal)" >&2
  44. echo " $CORE_SCRIPT (core)" >&2
  45. exit 1