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

# gh-commit: AI-powered scoped git commits (mods for scopes, Claude ACP for messages)
# Install: gh extension install prdlk/gh-commit
# Requires: uv (https://docs.astral.sh/uv), the `mods` CLI (scope generation),
#           Node.js (for the Claude ACP bridge), and an authenticated `claude`
#           (https://docs.anthropic.com/en/docs/claude-code)

EXTENSION_DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT="${EXTENSION_DIR}/smartcommit.py"

if ! command -v uv &>/dev/null; then
  echo "error: 'uv' is required but not installed"
  echo "install: curl -LsSf https://astral.sh/uv/install.sh | sh"
  exit 1
fi

if ! command -v npx &>/dev/null; then
  echo "warning: 'npx' (Node.js) not found — the Claude ACP bridge needs it."
  echo "install Node.js, or set GH_COMMIT_ACP_CMD to a working ACP bridge command."
fi

exec uv run --script "${SCRIPT}" "$@"
