#!/usr/bin/env bash # Claude Code — SessionStart hook # # Injects recent request history into Claude's context at session start. # stdout is appended to Claude's context window. # # Input (stdin): JSON with fields: session_id, cwd, session_start_source set -euo pipefail INPUT=$(cat) CWD=$(echo "$INPUT" | jq -r '.cwd // "$PWD"') LOG_FILE="${CWD}/.claude/request-log.jsonl" if [ ! -f "$LOG_FILE" ] || [ ! -s "$LOG_FILE" ]; then exit 0 fi TOTAL=$(wc -l < "$LOG_FILE" | tr -d ' ') OPEN=$(jq -r 'select(.status == "open")' "$LOG_FILE" 2>/dev/null | jq -s 'length') echo "=== Forgejo Workflow: Session Context ===" echo "Request log: .claude/request-log.jsonl ($TOTAL total, $OPEN open PRs)" echo "" # Last 5 entries echo "Recent requests:" tail -5 "$LOG_FILE" | jq -r ' " [\(.timestamp[0:16])] \(.prompt | gsub("\n"; " ") | .[0:72])" + "\n branch: \(.branch)" + (if .pr_number then " | PR #\(.pr_number) (\(.status))" else " | no PR yet" end) ' 2>/dev/null || true echo "" echo "Run '.claude/scripts/show-history.sh' for full history." echo "=========================================" exit 0