#!/bin/bash # install.sh — install the ralph-workplan skill into Claude Code's plugin system # # Usage: # ./install.sh # install # ./install.sh --uninstall # remove set -euo pipefail PLUGIN_NAME="ralph-workplan" REPO_DIR="$(cd "$(dirname "$0")" && pwd)" PLUGINS_DIR="${HOME}/.claude/plugins" INSTALL_PATH="${PLUGINS_DIR}/cache/local/${PLUGIN_NAME}" REGISTRY="${PLUGINS_DIR}/installed_plugins.json" # ── Uninstall ────────────────────────────────────────────────────────────────── if [[ "${1:-}" == "--uninstall" ]]; then if [[ -d "$INSTALL_PATH" ]]; then rm -rf "$INSTALL_PATH" echo "Removed: $INSTALL_PATH" fi # Remove from installed_plugins.json if [[ -f "$REGISTRY" ]]; then python3 - "$REGISTRY" "$PLUGIN_NAME" <<'PY' import json, sys path, name = sys.argv[1], sys.argv[2] d = json.load(open(path)) d.setdefault("plugins", {}).pop(name, None) json.dump(d, open(path, "w"), indent=2) print(f"Removed '{name}' from {path}") PY fi echo "✅ Uninstalled: $PLUGIN_NAME" echo " Restart Claude Code to apply." exit 0 fi # ── Install ──────────────────────────────────────────────────────────────────── mkdir -p "${INSTALL_PATH}/commands" mkdir -p "${INSTALL_PATH}/scripts" # Skill file goes in commands/ — that's where Claude Code looks cp "${REPO_DIR}/plugin/ralph-workplan.md" "${INSTALL_PATH}/commands/ralph-workplan.md" cp "${REPO_DIR}/plugin/scripts/check-done.sh" "${INSTALL_PATH}/scripts/check-done.sh" cp "${REPO_DIR}/plugin/scripts/setup.sh" "${INSTALL_PATH}/scripts/setup.sh" chmod +x "${INSTALL_PATH}/scripts/check-done.sh" chmod +x "${INSTALL_PATH}/scripts/setup.sh" # Register in installed_plugins.json so Claude Code discovers the plugin python3 - "$REGISTRY" "$PLUGIN_NAME" "$INSTALL_PATH" <<'PY' import json, sys path, name, install_path = sys.argv[1], sys.argv[2], sys.argv[3] try: d = json.load(open(path)) except (FileNotFoundError, json.JSONDecodeError): d = {"version": 2, "plugins": {}} d.setdefault("plugins", {})[name] = [{"scope": "user", "installPath": install_path}] json.dump(d, open(path, "w"), indent=2) PY echo "✅ Installed: $PLUGIN_NAME" echo " Path: $INSTALL_PATH" echo " Skill: /ralph-workplan [--max-iterations N]" echo "" echo " Restart Claude Code for the skill to appear."