#!/usr/bin/env bash
# Fresh-session naming experiment — 2026-09-11. Each call is a cold `claude -p` from /tmp
# (no CLAUDE.md, no memory, no project). Output: results.jsonl {prompt_id, model, rep, name}.
set -u
OUT=/home/benslinuxbox/cockpit/naming-experiment/results.jsonl
cd /tmp/claude-1000/naming-lab
declare -A P
P[quietfail]="I'm building a small command-line linter that finds scripts, cron jobs and CI steps that log an error but still exit 0."
P[claude-pet]="I'm building a small desktop pet — a little companion window that reacts in real time to what my Claude Code session is doing."
P[groundskeeper]="I'm building a read-only tool that walks my home directory and every project in it, and reports what is alive and what is rotting. It never fixes or deletes anything."
P[hearth]="I'm building a communication hub for several AI agents that live on the same machine — they register, post updates, and share presence with each other."
P[samehand]="I'm building a tool that measures how much of a repository's commit history was written by the same AI model, using only countable text features and a control from the same repo."
P[recipe]="I'm building a command-line tool that turns a photo of a handwritten recipe into a shopping list."
SUFFIX=" Suggest one name for the project. Reply with only the name, lowercase, nothing else."
MODELS="claude-haiku-4-5-20251001 claude-sonnet-5 claude-opus-5 claude-fable-5-1"
job() { local pid=$1 model=$2 rep=$3
  name=$(timeout 120 claude -p --model "$model" --output-format text "${P[$pid]}$SUFFIX" 2>/dev/null | grep -v "SessionEnd hook" | tr -d '\r' | head -1 | tr -cd 'a-zA-Z0-9._ -' | tr 'A-Z' 'a-z')
  printf '{"prompt_id":"%s","model":"%s","rep":%s,"name":"%s"}\n' "$pid" "$model" "$rep" "$name" >> "$OUT"
}
export -f job; export OUT SUFFIX; export -A P 2>/dev/null
: > "$OUT"
for rep in 1 2 3 4 5; do for m in $MODELS; do for pid in "${!P[@]}"; do
  job "$pid" "$m" "$rep" &
  while [ "$(jobs -rp | wc -l)" -ge 8 ]; do sleep 1; done
done; done; done
wait
echo "done: $(wc -l < "$OUT") rows"
