#!/usr/bin/env bash
# Output the remote slug for the current git repo.
# Used by SKILL.md files to derive project-specific paths in ~/.gstack/projects/.
# The slug rule (owner-repo for 2-segment remotes, "<last-two>-<16 hex>" for
# 3+-segment nested-group remotes, #3003) is shared with bin/gstack-slug through
# bin/gstack-remote-identity.sh.
set -e
. "$(dirname "$0")/../../bin/gstack-remote-identity.sh" 2>/dev/null || { echo "$0: bin/gstack-remote-identity.sh is missing. fix: reinstall with ./setup or /gstack-upgrade" >&2; exit 1; }
URL=$(git remote get-url origin 2>/dev/null || true)
_gri_slug=""
if [ -n "$URL" ]; then
  gstack_remote_slug "$URL"
fi
if [ -n "$_gri_slug" ]; then
  echo "$_gri_slug"
else
  basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
fi
