/**
 * Pull the move out of a model reply.
 *
 * Mirrors `envs/wordle_five/wordle_five/protocol.py`: the first bracketed
 * alphabetic token, lowercased, and deliberately no length or dictionary check
 * — so "guessed a six-letter word" and "produced no guess at all" stay
 * different things in the metrics rather than collapsing into one.
 */
const BRACKETED = /\[([A-Za-z]+)\]/;

export function parseGuess(reply: string | null | undefined): string | null {
  if (!reply) return null;
  const match = BRACKETED.exec(reply);
  return match ? match[1]!.toLowerCase() : null;
}
