#!/usr/bin/env bash
# Like pkg, restricted to a pathspec: pkgp BASE_TREE HEAD_TREE LABEL PATHSPEC...
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
base=$1; head=$2; label=$3; shift 3
out="$here/review-$label.diff"
{
  echo "# Review package: tree $base .. tree $head, paths: $* (working-tree snapshots; nothing is committed in this repo per CLAUDE.md)"
  echo
  echo "## Files changed"
  git diff --stat "$base" "$head" -- "$@"
  echo
  echo "## Diff"
  git diff -U10 "$base" "$head" -- "$@"
} > "$out"
echo "wrote $out: $(wc -c < "$out" | tr -d ' ') bytes"
