skill-run 1.7 KB

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