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

# gh-commit: AI-powered scoped git commits (mods CLI for scopes and messages)
# Install: gh extension install prdlk/gh-commit
# Requires: uv (https://docs.astral.sh/uv) and the `mods` CLI
#           (https://github.com/charmbracelet/mods)

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 mods &>/dev/null; then
  echo "warning: 'mods' not found — gh-commit uses it for scopes and commit messages."
  echo "install mods (https://github.com/charmbracelet/mods), or set GH_COMMIT_MODS_CMD."
fi

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