#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${PACKSHOT_SKILL_BASE_URL:-https://packshot-skill.pages.dev}"
DEST="${PI_SKILLS_DIR:-$HOME/.pi/agent/skills}/packshot"

mkdir -p "$DEST/scripts"

curl -fsSL "$BASE_URL/skill/SKILL.md" -o "$DEST/SKILL.md"
for script in \
  generate-packshot.py \
  generate-packshot-variants.py \
  benchmark-packshot-size.py \
  create-linkedin-packshot-layout.py
 do
  curl -fsSL "$BASE_URL/skill/scripts/$script" -o "$DEST/scripts/$script"
  chmod +x "$DEST/scripts/$script"
done

cat <<MSG
Packshot skill installed to:
  $DEST

Next steps:
  1. Restart your agent session so it discovers the skill.
  2. Store your Gemini API key if needed:
     security add-generic-password -a "\$USER" -s gemini-api-key -w "YOUR_GEMINI_API_KEY" -U

Try it from a project with a packshot-spec.json:
  uv run ~/.pi/agent/skills/packshot/scripts/generate-packshot.py brands/my-brand/packshots/my-product --size 4K --tag 4k
MSG
