#!/usr/bin/env bash
# bin/docker-entrypoint - run 2dph tools inside the container.
#
#   brain                 shell (default)
#   brain search <q>      bin/kb/search
#   brain index           bin/kb/index
#   brain watch <dir>     watchdog re-indexer (bin/kb/watch)
#   brain serve           async Go HTTP server (bin/serve)
#   brain extract         bin/facts/extract (docker×compose pairing)
#   brain audit           bin/facts/audit
#
# Usage comment starts at line 2 (self-describing convention).
set -euo pipefail

CMD="${1:-shell}"
shift || true

case "$CMD" in
  shell) exec bash ;;
  search) exec "$KB_PY" /app/bin/kb/search "$@" ;;
  index) exec "$KB_PY" /app/bin/kb/index "$@" ;;
  watch) exec /app/bin/watch "$@" ;;
  serve) exec /app/bin/serve "$@" ;;
  extract) exec "$KB_PY" /app/bin/facts/extract "$@" ;;
  audit) exec "$KB_PY" /app/bin/facts/audit "$@" ;;
  *) echo "unknown command: $CMD" >&2; exit 2 ;;
esac
