#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "${ROOT_DIR}" RECENT_COUNT="${1:-8}" print_section() { local section_title="$1" local next_section="$2" if [[ -f docs/90_current_state.md ]]; then if [[ -n "${next_section}" ]]; then awk "/^## ${section_title}\$/{flag=1} /^## ${next_section}\$/{flag=0} flag" docs/90_current_state.md else awk "/^## ${section_title}\$/{flag=1} flag" docs/90_current_state.md fi fi } echo "== Session Recovery ==" echo "repo: ${ROOT_DIR}" echo "branch: $(git rev-parse --abbrev-ref HEAD)" echo "head: $(git log -1 --pretty=format:'%h %s (%ci)')" echo echo "== Working Tree ==" git status --short echo echo "== Recent Commits (${RECENT_COUNT}) ==" git log --oneline --decorate -n "${RECENT_COUNT}" echo echo "== HEAD Commit Body ==" git show -s --format=%B HEAD echo echo "== HEAD Changed Files ==" git show --name-status --pretty=format: HEAD | sed '/^$/d' echo if [[ -f docs/90_current_state.md ]]; then echo "== docs/90_current_state.md ==" print_section "DONE" "NEXT" echo print_section "NEXT" "RISKS" echo print_section "RISKS" "CHANGED FILES" echo print_section "CHANGED FILES" "QUICK VERIFY" echo fi