# check-task-version.sh — confirm the installed `task` binary matches the version
# this skill is pinned to (read from the "Pinned to" line in SKILL.md).
# Exit codes: 0 match, 1 mismatch, 2 cannot determine (task missing or no pin).
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_MD="$SELF_DIR/../SKILL.md"
PINNED="$(grep -oE 'Task v[0-9]+\.[0-9]+\.[0-9]+' "$SKILL_MD" 2>/dev/null | head -1 | sed 's/Task v//')"
if ! command -v task >/dev/null 2>&1; then
echo "WARN go-task is not installed — install it with: brew install go-task" >&2
INSTALLED="$(task --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)"
if [ -z "$PINNED" ]; then
echo "WARN could not read a pinned 'Task vX.Y.Z' from SKILL.md" >&2
if [ "$PINNED" = "$INSTALLED" ]; then
echo "PASS task v$INSTALLED matches the skill pin (v$PINNED)"
echo "WARN skill is pinned to task v$PINNED but installed is v$INSTALLED" >&2
echo " reconcile by updating the skill from taskfile.dev/docs/changelog and bumping the" >&2
echo " 'Pinned to' line, or run: brew upgrade go-task" >&2