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

# Generates a long-lived Claude Code OAuth token (opens your browser to
# authorize), then prints the GitHub page where to paste it as a secret.

echo "Running 'claude setup-token' — copy the sk-ant-oat01-... token it prints:"
echo
claude setup-token

# Turn git@github.com:owner/repo.git or https://github.com/owner/repo.git
# into https://github.com/owner/repo
origin=$(git remote get-url origin)
repo=$(echo "$origin" | sed -E 's#^git@github\.com:#https://github.com/#; s#\.git$##')

echo
echo "Paste the token as a new secret named CLAUDE_CODE_OAUTH_TOKEN here:"
echo "  $repo/settings/secrets/actions/new"
