#!/usr/bin/env bash # Event-logging hook: appends a timestamped snapshot of every COYOTE_* env var # to a log file, so you can see exactly which events fire and what context # each one carries. # # Env vars read: # COYOTE_HOOK_LOG log file to append to (default: /tmp/coyote-hooks.log) # COYOTE_* everything coyote sets for the event is dumped verbatim # # Secrets (COYOTE_SECRET_*) are excluded from the snapshot; widening the grep # filter below opts into logging them. # # Wire it up under `hooks:` in your config.yaml (any event works): # hooks: # tool.completed: # - name: log-events # command: ./hooks/log-events.sh # # A relative command path like ./hooks/log-events.sh resolves against the # coyote config directory for global hooks, so this works with the default # hooks dir. # # See https://github.com/Dark-Alex-17/coyote/wiki/Hooks for the full list of # events and env vars. Hooks are fire-and-forget: this script never fails # loudly, and coyote ignores its exit code either way. set -u log_file="${COYOTE_HOOK_LOG:-/tmp/coyote-hooks.log}" # The default lives in shared /tmp: refuse to append through a symlink someone # else planted there. Point COYOTE_HOOK_LOG at a private path to avoid the # shared directory entirely. [ -L "$log_file" ] && exit 0 umask 077 { echo "=== $(date '+%Y-%m-%dT%H:%M:%S%z') ${COYOTE_EVENT:-unknown}" env | grep '^COYOTE_' | grep -v '^COYOTE_SECRET_' | sort echo } >> "$log_file" 2> /dev/null || true