#!/usr/bin/env bash
# Repo-specific hooks used by scripts/agent/*.sh for Mosaic Stack.

mosaic_hook_session_start() {
  echo "[mosaic-stack] Branch: $(git rev-parse --abbrev-ref HEAD)"
  echo "[mosaic-stack] Remotes:"
  git remote -v | sed 's/^/[mosaic-stack]   /'
  if command -v node >/dev/null 2>&1; then
    echo "[mosaic-stack] Node: $(node -v)"
  fi
  if command -v pnpm >/dev/null 2>&1; then
    echo "[mosaic-stack] pnpm: $(pnpm -v)"
  fi
}

mosaic_hook_critical() {
  echo "[mosaic-stack] Recent commits:"
  git log --oneline --decorate -n 5 | sed 's/^/[mosaic-stack]   /'
  echo "[mosaic-stack] Open TODO/FIXME markers (top 20):"
  rg -n "(TODO|FIXME|HACK|SECURITY)" apps packages plugins docs --glob '!**/node_modules/**' -S \
    | head -n 20 \
    | sed 's/^/[mosaic-stack]   /' \
    || true
}

mosaic_hook_session_end() {
  echo "[mosaic-stack] Working tree summary:"
  git status --short | sed 's/^/[mosaic-stack]   /' || true
}
