#!/usr/bin/env bash
set -euo pipefail
command -v jq >/dev/null || { echo "jq required"; exit 127; }

TOOL="$1"
FILE="tool_calls.jsonl"

COUNT=$(jq -s "[.[] | select(.tool == \"$TOOL\")] | length" "$FILE" 2>/dev/null || echo 0)

if [ "$COUNT" -gt 0 ]; then
    echo "PASS: $TOOL called $COUNT time(s)"
    exit 0
else
    echo "FAIL: $TOOL never called"
    exit 1
fi
