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

src="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
target="${1:-$HOME/.workbuddy/skills}"
dest="$target/hardware-product-development"

mkdir -p "$dest"
cp -R "$src/SKILL.md" "$src/references" "$src/scripts" "$src/assets" "$dest/"

echo "Installed to $dest"

if [ -d "$src/hardware-copilot" ]; then
  dest2="$target/hardware-copilot"
  mkdir -p "$dest2"
  cp -R "$src/hardware-copilot/SKILL.md" "$dest2/"
  for d in references scripts templates; do
    [ -d "$src/hardware-copilot/$d" ] && cp -R "$src/hardware-copilot/$d" "$dest2/"
  done
  echo "Installed to $dest2"
fi

echo "Restart or reload your agent runtime to pick up the skill."