#!/usr/bin/env bash # Reinstall both plugins from local checkouts, so edits to either take effect. # # Uninstall and install rather than update: `claude plugin update` compares # version strings, and a checkout being edited does not bump one, so it reports # the plugin already current and leaves the old copy in place. An install # copies the files as they are now. # # Both plugins are wanted together and are separate on purpose. One says who an # agent is; this one says what it can do here. Neither knows about the other, # which is why installing one without the other is a sensible thing to do and # this script does not stop you. set -euo pipefail cd "$(dirname "$0")/.." HERE="$(pwd)" # Where a sibling checkout is, from here. # # `..` is not it when this runs inside a worktree: that is # `.claude/worktrees`, not the directory the checkouts are in. The common git # directory belongs to the main checkout however this was invoked, so its # parent is what siblings sit beside. sibling() { local common common="$(git rev-parse --git-common-dir 2>/dev/null)" || { echo "../$1"; return; } echo "$(cd "$common/../.." && pwd)/$1" } say() { printf '\033[1m%s\033[0m\n' "$*"; } # The other plugin's checkout. Beside this one by default, since that is where # a machine working on both keeps them. DIDBOT_CLAUDE="${DIDBOT_CLAUDE:-$(sibling didbot-claude)}" if ! command -v claude >/dev/null 2>&1; then say "no \`claude\` on PATH" echo " This installs plugins into a Claude Code install, and there is not one here." exit 1 fi # `@`, where the marketplace is the name in that # repository's own .claude-plugin/marketplace.json. reinstall() { local name="$1" marketplace="$2" path="$3" if [ ! -f "$path/.claude-plugin/marketplace.json" ]; then say "no marketplace at $path" echo " Expected $path/.claude-plugin/marketplace.json." echo " Set DIDBOT_CLAUDE to that checkout if it is somewhere else." return 1 fi say "$name@$marketplace <- $path" # Order matters: a marketplace cannot be replaced while something it # provides is installed from it. claude plugin uninstall "$name@$marketplace" >/dev/null 2>&1 || true claude plugin marketplace remove "$marketplace" >/dev/null 2>&1 || true claude plugin marketplace add "$path" claude plugin install "$name@$marketplace" } reinstall didbot didbot "$DIDBOT_CLAUDE" reinstall vibescrobble vibescrobble "$HERE" echo say "start a new session" echo " Hooks are read when a session starts, so anything already running is" echo " still on the copy it was started with."