#!/usr/bin/env sh
# The `fauxcall` command for the Claude Code plugin (this directory is on PATH while the plugin is enabled).
#
# Runs the released package with uvx, pinned to the plugin's version so skills and engine always match.
# Development: FAUXCALL_SOURCE=/path/to/fauxcall/checkout runs that checkout instead.
set -eu
# The version is set in one place, the plugin manifest next to this script.
MANIFEST="$(cd "$(dirname "$0")/.." && pwd)/.claude-plugin/plugin.json"
FAUXCALL_VERSION="$(sed -n 's/^ *"version": *"\([^"]*\)".*/\1/p' "$MANIFEST" | head -n 1)"
if [ -z "${FAUXCALL_VERSION}" ]; then
  echo "fauxcall: no version in ${MANIFEST}" >&2
  exit 1
fi
if [ -n "${FAUXCALL_SOURCE:-}" ] && [ -d "${FAUXCALL_SOURCE}" ]; then
  exec uv run --quiet --project "${FAUXCALL_SOURCE}" fauxcall "$@"
fi
if ! command -v uvx >/dev/null 2>&1; then
  echo "fauxcall needs uv: https://docs.astral.sh/uv/getting-started/installation/" >&2
  exit 127
fi
exec uvx --quiet "fauxcall==${FAUXCALL_VERSION}" "$@"
