#!/bin/bash
# adompkg install hook for adom-shotlog: place the binary, deploy the main skill +
# completions via the binary's own `install`, then deploy every bundled sub-skill.
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
DEST="$HOME/.claude/skills"

mkdir -p "$HOME/.local/bin"
cp "$HERE/bin/adom-shotlog" "$HOME/.local/bin/adom-shotlog"
chmod +x "$HOME/.local/bin/adom-shotlog"
ln -sf "$HOME/.local/bin/adom-shotlog" "$HOME/.local/bin/shotlog"   # back-compat alias
echo "OK: adom-shotlog binary at ~/.local/bin/adom-shotlog (alias: shotlog)"

# main SKILL.md + bash completions + alias
"$HOME/.local/bin/adom-shotlog" install || true

# Bundled USER sub-skills - listed EXPLICITLY (the publish linter rejects a glob).
# (dev-skills/ and publish-skills/ are source-only per the wiki three-tier layout.)
install_skill() { mkdir -p "$DEST/$1"; cp "$HERE/$2" "$DEST/$1/SKILL.md"; echo "OK: skill $1"; }
install_skill adom-shotlog-surfacing     skills/adom-shotlog-surfacing/SKILL.md
install_skill adom-shotlog-child-windows skills/adom-shotlog-child-windows/SKILL.md

echo "OK: adom-shotlog installed. Run 'adom-shotlog serve &' then 'adom-shotlog open -c my-project'."