#!/usr/bin/env bash
# Auto-generated by nerftools: SessionStart hook.
#
# Greets the agent with a one-time reminder that the plugin is installed
# and what it covers. Appends a warning if the runtime bash is too old
# for the PreToolUse redirect hook to work.

set -uo pipefail

_PLUGIN_NAME="nerftools"
_PREFIX="nerf-"

_intro="The \`${_PLUGIN_NAME}\` plugin is installed. It provides safety-constrained wrappers for az, gh, git, kubectl, nx, and more. Prefer these wrappers over raw bash for commands they cover. Load the \`${_PLUGIN_NAME}\` skill for the full overview, or any \`${_PREFIX}<group>\` skill (e.g. \`nerf-az-account\`) for specific tools. A pre-bash redirect hook may prompt you to use a wrapper when one is available."

_msg="$_intro"
if [[ "${BASH_VERSINFO[0]:-0}" -lt 4 ]]; then
  _msg="${_msg}"$'\n\n'"Warning: the pre-bash redirect hook is disabled because this system's bash is too old (found ${BASH_VERSION:-unknown}; bash 4+ required). Tell the user to install a newer bash (\`brew install bash\` on macOS, or via the system package manager on Linux) to enable it. Generated wrapper scripts may also fail until bash is upgraded."
fi

# Emit JSON via jq when available; otherwise fall back to a static notice
# that at least tells someone how to fix things.
if command -v jq >/dev/null 2>&1; then
  jq -nc --arg m "$_msg" \
    '{hookSpecificOutput: {hookEventName: "SessionStart", additionalContext: $m}}'
else
  printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"nerftools: jq is required for nerftools hooks but is not installed. Tell the user to install jq."}}'
fi
