Files
backnotprop__plannotator/scripts/install.sh
T
Michael Ramos 49c6575370 fix: restore both cache paths in install.sh
Keep clearing both ~/.cache/opencode and ~/.bun/install/cache paths
to match Windows behavior (belt and suspenders).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 10:13:26 -08:00

134 lines
4.0 KiB
Bash

#!/bin/bash
set -e
REPO="backnotprop/plannotator"
INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local}/bin"
case "$(uname -s)" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
*) echo "Unsupported OS. For Windows, run: irm https://plannotator.ai/install.ps1 | iex" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch="x64" ;;
arm64|aarch64) arch="arm64" ;;
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
platform="${os}-${arch}"
binary_name="plannotator-${platform}"
echo "Fetching latest version..."
latest_tag=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
if [ -z "$latest_tag" ]; then
echo "Failed to fetch latest version" >&2
exit 1
fi
echo "Installing plannotator ${latest_tag}..."
binary_url="https://github.com/${REPO}/releases/download/${latest_tag}/${binary_name}"
checksum_url="${binary_url}.sha256"
mkdir -p "$INSTALL_DIR"
tmp_file=$(mktemp)
curl -fsSL -o "$tmp_file" "$binary_url"
expected_checksum=$(curl -fsSL "$checksum_url" | cut -d' ' -f1)
if [ "$(uname -s)" = "Darwin" ]; then
actual_checksum=$(shasum -a 256 "$tmp_file" | cut -d' ' -f1)
else
actual_checksum=$(sha256sum "$tmp_file" | cut -d' ' -f1)
fi
if [ "$actual_checksum" != "$expected_checksum" ]; then
echo "Checksum verification failed!" >&2
rm -f "$tmp_file"
exit 1
fi
mv "$tmp_file" "$INSTALL_DIR/plannotator"
chmod +x "$INSTALL_DIR/plannotator"
echo ""
echo "plannotator ${latest_tag} installed to ${INSTALL_DIR}/plannotator"
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
echo ""
echo "${INSTALL_DIR} is not in your PATH. Add it with:"
echo ""
case "$SHELL" in
*/zsh) shell_config="~/.zshrc" ;;
*/bash) shell_config="~/.bashrc" ;;
*) shell_config="your shell config" ;;
esac
echo " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ${shell_config}"
echo " source ${shell_config}"
fi
# Clear any cached OpenCode plugin to force fresh download on next run
rm -rf "$HOME/.cache/opencode/node_modules/@plannotator" "$HOME/.bun/install/cache/@plannotator" 2>/dev/null || true
# Install /review slash command
CLAUDE_COMMANDS_DIR="$HOME/.claude/commands"
mkdir -p "$CLAUDE_COMMANDS_DIR"
cat > "$CLAUDE_COMMANDS_DIR/plannotator-review.md" << 'COMMAND_EOF'
---
description: Open interactive code review for current changes
allowed-tools: Bash(plannotator:*)
---
## Code Review Feedback
!`plannotator review`
## Your task
Address the code review feedback above. The user has reviewed your changes in the Plannotator UI and provided specific annotations and comments.
COMMAND_EOF
echo "Installed /plannotator-review command to ${CLAUDE_COMMANDS_DIR}/plannotator-review.md"
# Install OpenCode slash command
OPENCODE_COMMANDS_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opencode/command"
mkdir -p "$OPENCODE_COMMANDS_DIR"
cat > "$OPENCODE_COMMANDS_DIR/plannotator-review.md" << 'COMMAND_EOF'
---
description: Open interactive code review for current changes
---
The Plannotator Code Review has been triggered. Opening the review UI...
Acknowledge "Opening code review..." and wait for the user's feedback.
COMMAND_EOF
echo "Installed /plannotator-review command to ${OPENCODE_COMMANDS_DIR}/plannotator-review.md"
echo ""
echo "=========================================="
echo " OPENCODE USERS"
echo "=========================================="
echo ""
echo "Add the plugin to your opencode.json:"
echo ""
echo ' "plugin": ["@plannotator/opencode@latest"]'
echo ""
echo "Then restart OpenCode. The /plannotator-review command is ready!"
echo ""
echo "=========================================="
echo " CLAUDE CODE USERS: YOU'RE ALL SET!"
echo "=========================================="
echo ""
echo "Install the Claude Code plugin:"
echo " /plugin marketplace add backnotprop/plannotator"
echo " /plugin install plannotator@plannotator"
echo ""
echo "The /plannotator-review command is ready to use after you restart Claude Code!"