Skip to content

feat(stop): surface end-of-turn reminders via additionalContext stdout#55

Open
JarrodAI wants to merge 1 commit into
cytostack:mainfrom
JarrodAI:feat/additionalcontext-stop-reminders
Open

feat(stop): surface end-of-turn reminders via additionalContext stdout#55
JarrodAI wants to merge 1 commit into
cytostack:mainfrom
JarrodAI:feat/additionalcontext-stop-reminders

Conversation

@JarrodAI

Copy link
Copy Markdown

Problem

The Stop hook's checkForMissingBugLogs and checkCerebrumFreshness functions currently write reminders to process.stderr. In Claude Code, stderr output from Stop hooks goes to the terminal only — it does not appear in Claude's next context window. This means the reminders are invisible to Claude and have no effect on its behaviour.

Solution

Claude Code provides a dedicated mechanism for Stop hooks to inject content into the AI's context: the additionalContext field in JSON stdout:

process.stdout.write(JSON.stringify({
  hookSpecificOutput: { hookEventName: "Stop", additionalContext }
}));

This PR switches the reminder functions from void (write to stderr) to string | null (return the message), collects all non-null reminders, and emits them as a single additionalContext payload. Claude sees them at the top of its next turn and can act on them immediately.

Changes

src/hooks/stop.ts

  • checkForMissingBugLogs: voidstring | null
  • checkCerebrumFreshness: voidstring | null
  • New checkSemanticSummaries: warns if files were modified but no semantic summary entry was written to memory.md today (requires countSemanticEntries below)
  • Collect reminders into an array, filter nulls, emit via additionalContext JSON stdout

src/hooks/shared.ts

  • New countSemanticEntries(wolfDir): reads memory.md and counts non-mechanical rows dated today — used by checkSemanticSummaries to detect whether Claude wrote a meaningful session summary

Why this matters

Before this change, reminders fired silently into the void. After this change, Claude receives something like:

⚠️ OpenWolf end-of-turn reminders:
• ACTION REQUIRED: Files edited 3+ times this session (MarketingView.tsx) but buglog.json was not updated. Log the bug fixes to .wolf/buglog.json now.
• ACTION REQUIRED: 4 files were modified this session but no semantic summary was written to memory.md.

…at the top of its very next turn, making it actually comply with the OpenWolf protocol.

Tested in production use on a large Next.js monorepo with Claude Code (Sonnet 4.6). Build passes cleanly: npm run build

🤖 Contributed by JarrodAI via Claude Code

The Stop hook's checkForMissingBugLogs and checkCerebrumFreshness
previously wrote reminders to process.stderr. In Claude Code, stderr
output from Stop hooks goes to the terminal only — it does NOT appear
in Claude's next context window.

Claude Code's hook system provides a dedicated mechanism for injecting
content into the AI's context: the `additionalContext` field in JSON
stdout. This commit switches to that approach:

- checkForMissingBugLogs: return string | null instead of void
- checkCerebrumFreshness: return string | null instead of void
- New checkSemanticSummaries: warns if files were modified but no
  semantic summary was written to memory.md today
- Collect all reminder strings, filter nulls, then emit a single
  process.stdout.write(JSON.stringify({ hookSpecificOutput:
  { hookEventName: "Stop", additionalContext } })) call

Also adds countSemanticEntries() to shared.ts to support the new check.

This change makes reminders actionable — Claude sees them at the top
of the next turn and can immediately log bugs or update cerebrum.md
rather than the reminder silently disappearing in terminal output.
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.

1 participant