#!/usr/bin/env bash
# Install the pup USER skillpack: the main `pup` skill + its focused user sub-skills.
# Per the Bridge SDK a pkg ships ONLY user skills; all skills listed here are user-facing.
# The DEV + PUBLISH maintainer skills are source-only (repo dev-skills/ + publish-skills/,
# NOT in package.json files[], never installed here). The bridge RUNTIME isn't here either
# — it ships in Adom Desktop + as the Releases zip. The AD CLI + core skills arrive via
# this pkg's dependencies:{ "adom/adom-desktop": "^1.9.x" } at `pkg install` time.
set -e
PKG_DIR="$(cd "$(dirname "$0")" && pwd)"

deploy_into() {
  local BASE="$1"
  install_skill() { mkdir -p "$BASE/$1"; cp "$PKG_DIR/$2" "$BASE/$1/SKILL.md"; }
  # main user skill. SKILL.md lives at the repo ROOT (required by the registry), but it
  # installs as `pup` — the skill directory name is the slug the loader surfaces, and it
  # MUST equal the SKILL.md `name:` field. Every other skill on a machine follows that
  # (adom-desktop-fusion, adom-desktop-kicad, ... and all four pup sub-skills); this one
  # installed as the REPO name while declaring `name: pup`, so a `pkg install` surfaced the
  # start-here skill under a slug that contradicted its own frontmatter, its trigger words,
  # and every cross-reference in the sub-skills. Repo name != skill name; don't re-conflate.
  rm -rf "$BASE/adom-desktop-puppeteer-bridge"   # drop the pre-1.9.86 mis-slugged copy
  install_skill pup SKILL.md
  # focused user sub-skills
  install_skill pup-windows-sessions-tabs  skills/pup-windows-sessions-tabs/SKILL.md
  install_skill pup-screenshots-recording  skills/pup-screenshots-recording/SKILL.md
  install_skill pup-browsers-and-chrome    skills/pup-browsers-and-chrome/SKILL.md
  install_skill pup-adom-wiki              skills/pup-adom-wiki/SKILL.md
  install_skill pup-vendor-login          skills/pup-vendor-login/SKILL.md
  echo "  -> $BASE (pup + 4 sub-skills)"
}

echo "Installing adom-desktop-puppeteer-bridge skills:"
deploy_into "$HOME/.claude/skills"                          # Claude Code
[ -d "$HOME/.codex" ] && deploy_into "$HOME/.codex/skills"  # Codex (if present)
echo "Done. The pup skill calls the adom-desktop CLI; if the bridge isn't installed on Adom Desktop it self-installs on first use."
