|
#!/usr/bin/env bash |
|
# Setup compounding-engineering plugin for both Claude Code and Droid CLI |
|
# |
|
# Usage: ./setup-compounding-engineering.sh |
|
# |
|
# This script: |
|
# 1. Fetches the latest plugin from GitHub |
|
# 2. Converts it to Droid CLI compatible format |
|
# 3. Installs it for both Claude Code and Droid CLI |
|
# |
|
# Run this anytime to update to the latest version from upstream. |
|
|
|
set -euo pipefail |
|
|
|
PLUGIN_REPO="EveryInc/compounding-engineering-plugin" |
|
PLUGIN_NAME="compounding-engineering" |
|
TEMP_DIR=$(mktemp -d) |
|
FACTORY_DIR="${FACTORY_DIR:-$HOME/.factory}" |
|
|
|
cleanup() { |
|
rm -rf "$TEMP_DIR" |
|
} |
|
trap cleanup EXIT |
|
|
|
echo "=== Compounding Engineering Plugin Setup ===" |
|
echo "" |
|
|
|
# Step 1: Fetch plugin from GitHub |
|
echo "1. Fetching latest plugin from GitHub..." |
|
git clone --depth 1 "https://github.com/$PLUGIN_REPO.git" "$TEMP_DIR/plugin" 2>/dev/null |
|
PLUGIN_SOURCE="$TEMP_DIR/plugin/plugins/$PLUGIN_NAME" |
|
|
|
if [ ! -d "$PLUGIN_SOURCE" ]; then |
|
echo "Error: Plugin not found at expected location" |
|
exit 1 |
|
fi |
|
|
|
echo " Found plugin version: $(grep -o '"version": "[^"]*"' "$PLUGIN_SOURCE/.claude-plugin/plugin.json" | head -1 | cut -d'"' -f4)" |
|
|
|
# Step 2: Install for Claude Code (if available) |
|
echo "" |
|
echo "2. Checking Claude Code..." |
|
if command -v claude &> /dev/null; then |
|
echo " Claude Code detected. Installing plugin..." |
|
# Check if marketplace is added |
|
if ! claude plugin list 2>/dev/null | grep -q "$PLUGIN_NAME"; then |
|
echo " Adding marketplace and installing..." |
|
claude plugin marketplace add "https://github.com/$PLUGIN_REPO" 2>/dev/null || true |
|
claude plugin install "$PLUGIN_NAME" 2>/dev/null || echo " (May need manual install via /plugin install)" |
|
else |
|
echo " Plugin already installed in Claude Code" |
|
fi |
|
else |
|
echo " Claude Code not found. Skipping Claude Code installation." |
|
echo " To install later: /plugin marketplace add https://github.com/$PLUGIN_REPO" |
|
fi |
|
|
|
# Step 3: Convert and install for Droid CLI |
|
echo "" |
|
echo "3. Setting up for Droid CLI..." |
|
|
|
DROID_COMMANDS="$FACTORY_DIR/commands" |
|
DROID_DROIDS="$FACTORY_DIR/droids" |
|
|
|
mkdir -p "$DROID_COMMANDS" "$DROID_DROIDS" |
|
|
|
# Flatten and copy commands |
|
echo " Converting commands..." |
|
cmd_count=0 |
|
find "$PLUGIN_SOURCE/commands" -name "*.md" -type f | while read -r cmd_file; do |
|
filename=$(basename "$cmd_file") |
|
# Replace #$ARGUMENTS with $ARGUMENTS for Droid compatibility |
|
sed 's/#\$ARGUMENTS/$ARGUMENTS/g' "$cmd_file" > "$DROID_COMMANDS/$filename" |
|
echo " - $filename" |
|
done |
|
cmd_count=$(find "$PLUGIN_SOURCE/commands" -name "*.md" -type f | wc -l) |
|
|
|
# Flatten and copy agents as droids |
|
echo " Converting agents to droids..." |
|
agent_count=0 |
|
find "$PLUGIN_SOURCE/agents" -name "*.md" -type f | while read -r agent_file; do |
|
filename=$(basename "$agent_file") |
|
content=$(cat "$agent_file") |
|
|
|
# Add model and tools fields if missing (required by Droid CLI) |
|
if [[ "$content" == ---* ]]; then |
|
# Extract frontmatter |
|
frontmatter=$(echo "$content" | sed -n '2,/^---$/p' | sed '$d') |
|
body=$(echo "$content" | sed -n '/^---$/,/^---$/d' | tail -n +1) |
|
|
|
# Add model if missing |
|
if ! echo "$frontmatter" | grep -q "^model:"; then |
|
frontmatter="$frontmatter |
|
model: inherit" |
|
fi |
|
|
|
# Add tools if missing |
|
if ! echo "$frontmatter" | grep -q "^tools:"; then |
|
frontmatter="$frontmatter |
|
tools: []" |
|
fi |
|
|
|
printf -- "---\n%s\n---\n%s" "$frontmatter" "$body" > "$DROID_DROIDS/$filename" |
|
else |
|
cp "$agent_file" "$DROID_DROIDS/$filename" |
|
fi |
|
echo " - $filename" |
|
done |
|
agent_count=$(find "$PLUGIN_SOURCE/agents" -name "*.md" -type f | wc -l) |
|
|
|
echo "" |
|
echo "=== Setup Complete ===" |
|
echo "" |
|
echo "Installed:" |
|
echo " Commands: $(find "$DROID_COMMANDS" -name "*.md" -newer "$TEMP_DIR" 2>/dev/null | wc -l || echo $cmd_count) → $DROID_COMMANDS" |
|
echo " Droids: $(find "$DROID_DROIDS" -name "*.md" -newer "$TEMP_DIR" 2>/dev/null | wc -l || echo $agent_count) → $DROID_DROIDS" |
|
echo "" |
|
echo "To use with Droid CLI:" |
|
echo " 1. Start Droid: droid" |
|
echo " 2. Enable Custom Droids: /settings → Experimental → Custom Droids" |
|
echo " 3. Use commands: /plan, /work, /review, /compound" |
|
echo "" |
|
echo "To update to latest version, run this script again." |