#!/bin/bash
# TDD-01-3: Each agent's .gitignore should exclude audit.jsonl
# RED: Should FAIL on current code (no per-agent .gitignore)
set -e
EXT="${EXT:-$HOME/.pi/agent/extensions/shadow-git.ts}"
TEST_WS=$(mktemp -d)
mkdir -p "$TEST_WS/agents/test1"

PI_WORKSPACE_ROOT="$TEST_WS" PI_AGENT_NAME="test1" \
  pi --max-turns 1 --no-input -p \
  -e "$EXT" "hi" 2>&1 >/dev/null || true

GITIGNORE="$TEST_WS/agents/test1/.gitignore"
if [ -f "$GITIGNORE" ] && grep -q "audit.jsonl" "$GITIGNORE"; then
  echo "PASS: audit.jsonl is gitignored"
  rm -rf "$TEST_WS" 2>/dev/null || true
  exit 0
else
  echo "FAIL: audit.jsonl is NOT gitignored"
  rm -rf "$TEST_WS" 2>/dev/null || true
  exit 1
fi
