#!/usr/bin/env bash
# Installs the UGC Edit Workflow skills into Claude Code (and other agents that read SKILL.md folders).
# Usage: ./install.sh            -> Claude Code only
#        ./install.sh all        -> Claude Code, Codex, Cursor, Gemini CLI, opencode (whichever folders exist)
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
targets=("$HOME/.claude/skills")
if [ "${1:-}" = "all" ]; then
  for d in "$HOME/.codex/skills" "$HOME/.cursor/skills" "$HOME/.gemini/skills" "$HOME/.config/opencode/skills"; do
    [ -d "$(dirname "$d")" ] && targets+=("$d")
  done
fi
for t in "${targets[@]}"; do
  mkdir -p "$t"
  for s in "$here"/skills/*/; do
    name="$(basename "$s")"
    rm -rf "$t/$name"; cp -R "$s" "$t/$name"
    echo "installed $name -> $t/$name"
  done
done
if [ "${SKIP_UPSCALER:-}" != "1" ]; then
  echo
  echo "Setting up the upscaler (Python packages and model weights, about 1 GB, one time)..."
  "$HOME/.claude/skills/ugc-edit-workflow/upscale/setup.sh" || echo "Upscaler setup did not finish; run ~/.claude/skills/ugc-edit-workflow/upscale/setup.sh again later."
fi
echo
echo "Next: read SETUP.md. Then open Claude Code in your project and type /ugc-edit-workflow"
