#!/usr/bin/env bash
# Copy the harness source tree into a fresh directory for tests that need a
# standalone engine checkout.
#
# The working tree carries multi-gigabyte run state and live task worktrees, and
# sandbox residue (.tmpjail-work/work) is mode 0000, which makes tar exit
# non-zero. Neither belongs in an engine snapshot.
repo_snapshot() {
  local src="$1" dest="$2"
  mkdir -p "$dest"
  (
    cd "$src"
    tar \
      --exclude=.git \
      --exclude=.worktrees \
      --exclude='.wt-*' \
      --exclude=tmp \
      --exclude=runstate \
      --exclude=node_modules \
      --exclude=.harness \
      --exclude=.tmpjail-work \
      --exclude='*.sock' \
      -cf - .
  ) | tar -C "$dest" -xf -
}
