#!/bin/sh
# bullpen-gc — prune bullpen scratch files that have outlived their life.
# Scoped STRICTLY to the two scratch dirs (top-level files only); it never
# touches room.jsonl, COUNTER, or any subdirectory. Age overridable via env.
set -eu
ART=/var/lib/bullpen/artifacts       # @callboy fetched-page dumps
HANDS=/var/lib/bullpen/hands         # @callboy tool-hands file writes
ART_DAYS=${BULLPEN_ART_DAYS:-14}
HANDS_DAYS=${BULLPEN_HANDS_DAYS:-7}

prune() {   # $1=dir  $2=days
    [ -d "$1" ] || return 0
    find "$1" -maxdepth 1 -type f -mtime +"$2" -print -delete
}

echo "bullpen-gc: artifacts >${ART_DAYS}d, hands >${HANDS_DAYS}d"
prune "$ART"   "$ART_DAYS"
prune "$HANDS" "$HANDS_DAYS"
