hooks
Agent hooks, copied to ~/.claude/hooks/. install.sh registers them once in ~/.claude/settings.json and, if Codex is installed, in ~/.codex/hooks.json.
herdr-activity.sh
Runs on UserPromptSubmit and Stop (async, 60s timeout). It reads the session log (transcript_path from the hook input) and asks Haiku for a 5–10 word line, then stores it with hc label $HC_TERMINAL_ID kit.activity=…. The agents-activity mod shows it.
- Prompt submit: what the agent is doing now, starting with an -ing verb. The newest prompt comes from the hook input, because it may not be in the log yet. A short reply (
2,yes) is resolved against the agent's last message. That only worked reliably once the prompt to Haiku was ordered as it happened: the agent's message, then the user's reply. - Stop: what it just did, starting with a past-tense verb.
- Outside herdr-core terminals (no
HC_TERMINAL_ID) it exits immediately. The Haiku call runs without tools, settings, hooks, MCP or theHC_*variables, so it can't trigger itself. - Codex runs the same script, registered in
~/.codex/hooks.json. Codex's hook input has the samehook_event_name,transcript_pathandpromptfields. Its session log isresponse_itemmessages:input_textfor the user,output_textfor the agent. Codex adds wrappers such as<environment_context>,<user_instructions>and# AGENTS.md; these are skipped. Haiku writes the label for both agents. - Codex hook trust: Codex runs a new or changed hook only after the user trusts it in the Codex TUI (
/hooks). The trust is saved as atrusted_hashin~/.codex/config.toml. Never bypass it with--dangerously-bypass-hook-trust.
Test it by hand. It labels the current terminal:
jq -n --arg t <session.jsonl> '{hook_event_name:"UserPromptSubmit", transcript_path:$t, prompt:"2"}' | bash hooks/herdr-activity.sh
hc get $HC_TERMINAL_ID --json | jq -r '.labels["kit.activity"]'