fix(RepeatDetection): use stdout+exit 0 to inject warning as additionalContext
Summary
RepeatDetection.hook.ts (UserPromptSubmit hook) writes its warning to stderr and exits with code 2, which is the Claude Code hook block pattern — it prevents the user's prompt from being processed and surfaces the warning text to the user.
The desired behavior, per the hook's own docstring ("injects a high-priority WARNING into the model's context"), is the additionalContext pattern: write to stdout and exit with code 0. That signals Claude Code to inject the text into the model's context for the next turn, while letting the prompt proceed.
Bug observed
When the hook triggered on a repeated prompt:
- The user's repeated prompt was blocked (the user is the one repeating, so blocking them doesn't help).
- The "⚠️ REPEAT DETECTION" warning surfaced to the user instead of to the model.
- The model never received the signal it was supposed to use to re-read the message.
Fix
Two-line change in Releases/v5.0.0/.claude/hooks/RepeatDetection.hook.ts:
process.stderr.write(...)→process.stdout.write(...)process.exit(2)→process.exit(0)
Comments updated to reflect the corrected semantics. No other behavior changed; the detection logic, threshold (0.6 jaccard similarity), and warning text are unchanged.
Reference
Claude Code UserPromptSubmit hook contract: stdout + exit 0 = additionalContext injected for the model; stderr + exit 2 = block + surface to user. The latter is intended for security/policy violations where the prompt should not proceed.
Great callout! I opened #1291 for this as well.