feat: v0.2.0 — UserPromptSubmit hook integration (M2)#1
Conversation
Adds `role-x intake` subcommand + `scripts/role-x-intake-hook.sh` shell
wrapper that wire P17 into Claude Code's `UserPromptSubmit` event. Lens
selection now fires automatically on every substantive prompt — closes
the reasoning-enforcement gap from v0.1.0.
What lands:
- scripts/role-x-intake-hook.sh — graceful-fail shell wrapper
(skips silently when PyYAML missing, workspace has no roles/, or prompt
too short; always exit 0; never blocks the user's turn)
- scripts/role-x.py: new `intake` subcommand. Reads JSON from stdin
(Claude Code hook protocol) OR accepts --prompt/--workspace/--session
flags for testing. Snapshots git signals, scores roles/*.md, walks
extends: chain, decides augment/rewrite/decompose, emits structured
event to ~/.config/broomva/role/events.jsonl, prints intake context
to stdout (added to agent's working context).
- tests/test_role_x.py: 7 new tests (short-prompt carve-out, no-roles-dir
carve-out, keyword-match selection, event persistence, multi-domain
decompose escalation, _meta-only fallback, stdin JSON protocol).
Total: 13/13 passing.
- CHANGELOG.md: v0.2.0 entry.
- README.md: hook integration section + event schema + test recipe.
Workspace wiring lands in a separate PR on broomva/workspace
(.claude/settings.json + AGENTS.md hooks table + CLAUDE.md hooks table).
Event schema (now durable):
{
ts, event:"intake", session, prompt_digest:"sha256:…",
prompt_word_count, lenses_selected:[…], lenses_extended:[…],
mode:"augment"|"rewrite"|"decompose", mode_escalation_reason,
signals_matched:{paths, prompt_keywords, branch_patterns, linear_labels}
}
Verified end-to-end:
- 13/13 pytest pass (Python 3.12)
- Shell hook stdin → 4 keyword matches against rust-systems lens →
augment mode → 16-entry merged quality_bar → 4 context files →
event written to events.jsonl
This release ships the v0.2.0 contract; M4 (dream cycle) consumes the
event stream this lays down.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe PR implements v0.2.0's automatic intake hook: a Claude Code Changesv0.2.0 Intake Hook Integration
🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Ships v0.2.0 — the M2 milestone for role-x. Wires P17 intake into Claude Code's
UserPromptSubmitevent so lens selection fires automatically on every substantive prompt. Closes the reasoning-enforcement gap from v0.1.0.What lands
scripts/role-x-intake-hook.sh— graceful-fail shell wrapper (always exit 0; never blocks)scripts/role-x.py intake— new subcommand: signals → score → extends-chain → mode → event → contextCHANGELOG.mdv0.2.0 entryREADME.mdhook integration sectionEnd-to-end verified
Event persisted to
~/.config/broomva/role/events.jsonl:{"ts":"2026-05-14T01:40:55.150348+00:00","event":"intake","session":"smoke-test","prompt_digest":"sha256:47b024614f0b…","prompt_word_count":12,"lenses_selected":["rust-systems"],"lenses_extended":["rust-systems","_meta"],"mode":"augment","mode_escalation_reason":null,"signals_matched":{"paths":0,"prompt_keywords":2,"branch_patterns":0,"linear_labels":0}}Test plan
python3 -m pytest tests/ -v→ 13/13 pass"hi") → silent exit 0 (carve-out)roles/→ silent exit 0_metaonly, augment modeWorkspace wiring follow-up
Workspace
.claude/settings.jsonregistration of the new hook ships in a separate PR onbroomva/workspace:Carve-outs (silent exit 0)
roles/directory|| true)These ensure the hook never breaks a user turn — bstack invariant for safety shields and reasoning-supplements.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
intakesubcommand with lens selection, mode resolution, and structured event loggingDocumentation