#!/usr/bin/env bash
# Snapshot the working tree (tracked + untracked, .gitignore respected) as a git tree object,
# through a temporary index: no commit, no ref, the real index untouched. Prints the tree id.
set -euo pipefail
root=$(git rev-parse --show-toplevel)
idx=$(mktemp)
cp "$root/.git/index" "$idx"
GIT_INDEX_FILE="$idx" git -C "$root" add -A -- . ':!src/variancelabs_mcp/app/static' >/dev/null 2>&1
GIT_INDEX_FILE="$idx" git -C "$root" write-tree
rm -f "$idx"
