#!/usr/bin/env bash
# adom-screensaver installer (runs in the Adom container, Linux/WSL2).
# Installs the operate skills + stages the PREBUILT, SIGNED Windows binaries so the skill can deploy
# them to the user's Windows laptop over the adom-desktop relay. Does NOT touch Windows, and does NOT
# run anything here, this is a Windows-only app. (Source + build live on the private adom-screensaver-dev page.)
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"

# Main operate skill (root SKILL.md).
mkdir -p "$HOME/.claude/skills/adom-screensaver"
cp -f "$HERE/SKILL.md" "$HOME/.claude/skills/adom-screensaver/SKILL.md"
echo "[adom-screensaver] skill -> adom-screensaver"

# Operate sub-skills: adom-screensaver-billboard, -wake, -rationale (NOT -build; that's on -dev).
if [ -d "$HERE/skills" ]; then
  for d in "$HERE/skills"/*/; do
    [ -f "$d/SKILL.md" ] || continue
    name="$(basename "$d")"
    mkdir -p "$HOME/.claude/skills/$name"
    cp -f "$d/SKILL.md" "$HOME/.claude/skills/$name/SKILL.md"
    echo "[adom-screensaver] skill -> $name"
  done
fi

# Stage the PREBUILT signed Windows binaries (the .scr + helper + WebView2 DLLs + html + assets) so
# the skill can push them straight to the laptop, no compiler involved.
ASSETS="$HOME/.adom-screensaver"
mkdir -p "$ASSETS"
cp -rf "$HERE/dist/win/"* "$ASSETS/" 2>/dev/null || true
echo "[adom-screensaver] prebuilt signed binaries -> $ASSETS"
echo "[adom-screensaver] This is a WINDOWS app, nothing was installed on this container."
echo "[adom-screensaver] next: ask Claude, \"set up the Adom screensaver on my Windows laptop\""