#!/bin/bash

# Comprehensive hook logger - logs stdin data (tool context) for each hook type
# Used for testing what data is available to each hook type
#
# Available Context (via stdin JSON):
# - Common: session_id, transcript_path, cwd, hook_event_name
# - Event-specific: tool_name, tool_input, prompt, message, etc.

LOG_FILE="/Users/psulin/organon/.claude/comprehensive-hook-log.jsonl"
HOOK_TYPE="${1:-unknown}"

# Get current timestamp in EST
TIMESTAMP=$(TZ='America/New_York' date '+%Y-%m-%d %H:%M:%S %Z')

# Read all stdin data
STDIN_DATA=$(cat)

# Create log entry
LOG_ENTRY=$(jq -n \
  --arg timestamp "$TIMESTAMP" \
  --arg hook_type "$HOOK_TYPE" \
  --arg stdin "$STDIN_DATA" \
  '{
    timestamp: $timestamp,
    hook_type: $hook_type,
    stdin: $stdin
  }')

# Append to log file
echo "$LOG_ENTRY" >> "$LOG_FILE"

# For hooks that need to pass through stdin, output it
echo "$STDIN_DATA"
