Skip to content

feat: restructure hook output for subagent pipeline (DOJ-2436)#12

Open
lapc506 wants to merge 1 commit intomainfrom
andres/doj-2436-restructure-hook-output
Open

feat: restructure hook output for subagent pipeline (DOJ-2436)#12
lapc506 wants to merge 1 commit intomainfrom
andres/doj-2436-restructure-hook-output

Conversation

@lapc506
Copy link

@lapc506 lapc506 commented Mar 10, 2026

Summary

Implements Option 5 (Hybrid) from the ADR (docs/architecture/hook-subagent-spike.md):

  • Hooks write structured JSON to ~/.code-sensei/pending-lessons/ (one file per lesson — atomic, no race conditions)
  • additionalContext shortened from verbose teaching prompts (~100 tokens) to minimal delegation hints (~30 tokens): "use Task tool to invoke sensei agent"
  • session-stop.sh archives pending lessons to lessons-archive/ and cleans the queue
  • sensei.md updated with instructions for reading pending lessons when invoked via delegation
  • recap.md updated to drain pending lessons queue before generating session summary

Files changed

File Change
scripts/track-code-change.sh Write pending lesson + delegation hint
scripts/track-command.sh Write pending lesson + delegation hint
scripts/session-stop.sh Archive + cleanup pending lessons
agents/sensei.md Read pending lessons on delegation
commands/recap.md Drain pending lessons queue
tests/test-hooks.sh 16 regression tests (NEW)

Test plan

  • bash tests/test-hooks.sh — 16/16 tests pass
  • Hook stdout is valid JSON (| jq . passes)
  • additionalContext contains delegation hint, not teaching content
  • Pending lesson files are valid JSON with required fields
  • First encounter → micro-lesson + firstEncounter=true
  • Already-seen tech → inline-insight + firstEncounter=false
  • session-stop archives lessons and cleans queue
  • Archive file is valid JSONL
  • Manual: install plugin in Claude Code, make code changes, verify sensei delegation works

🤖 Generated with Claude Code

Implements Option 5 (Hybrid) from ADR hook-subagent-spike.md:

- Hook scripts now write structured JSON lessons to ~/.code-sensei/pending-lessons/
  (one file per lesson, atomic writes, no race conditions)
- additionalContext shortened from verbose teaching prompts to minimal
  delegation hints ("use Task tool to invoke sensei agent")
- session-stop.sh archives pending lessons to lessons-archive/ and cleans queue
- sensei agent updated to read pending lessons when invoked via delegation
- recap command updated to drain pending lessons queue
- 16 regression tests covering JSON validity, delegation hints, lesson
  creation, first-encounter detection, and session cleanup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lapc506 lapc506 self-assigned this Mar 10, 2026
@lapc506 lapc506 requested a review from dbejarano820 March 10, 2026 03:56
@lapc506 lapc506 marked this pull request as ready for review March 10, 2026 03:58
@dbejarano820
Copy link
Contributor

@greptileai review this again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants