Repository navigation
Tell the user when Claude Code didn't load Leaf's hooks module - #5959
Merged
Merged
Conversation
`pnpm run check:hooks` now also runs `claude plugin validate .` from a pinned `@anthropic-ai/claude-code` (2.1.325), which reports what Claude Code would refuse before loading `hooks/claude-code.ts`. Nothing in CI asked Claude Code before: the module's tests run in a Node stand-in, and hooks/tsconfig.json leaves the module out because its declarations aren't on npm. #5907 read the route variables with `$.env.get(name)` in a loop. Claude Code refuses a module whose `$.env.get` takes anything but a string literal (2.1.305 already did), so since #5907 landed every session that loaded the module from a current install had no band, no turn-end clerk and no thread forks, with the refusal only in Claude Code's debug log. On main this check fails with that refusal; on #5947, which spells each name out, it passes. The package's postinstall copies its platform binary into place, so pnpm-workspace.yaml allows its build.
A new `newest-harnesses` job, on the daily schedule and on dispatch, installs `@anthropic-ai/claude-code@latest` and `@earendil-works/pi-coding-agent@latest` and runs `pnpm run check:hooks`. The pins move with Dependabot's weekly npm group, while a user's Claude Code updates itself as each release ships, so a release that refuses `hooks/claude-code.ts` or changes the API `hooks/pi.ts` uses now turns the daily run red for tend within a day. Rehearsed locally on this branch's tree with #5947's module: Claude Code 2.1.325 and Pi 1.5.2 installed, and the check passed.
…f its own Max asked for no new job. The daily scheduled `test` job now ends by installing the newest Claude Code and Pi and running `pnpm run check:hooks` again, after every step that reads `node_modules` has finished.
hooks/pi.ts depends on Pi's API, and the nightly scan read only Claude Code's and Codex's release notes.
Claude Code refuses a hooks module it can't validate and says so only in its debug log, so a session in which it refused `hooks/claude-code.ts` lost its band, its turn-end clerk and its thread forks, and the user saw only the band gone. The pages follower, which only the module starts, now records the Claude Code process it runs in. A Stop that ends the turn of a session holding a page, in a process no follower has recorded, prints a `systemMessage` naming what is off, the `claude plugin validate` command that says why, and `/reload-plugins` for after a fix; it records the process too, so the user hears it once per process. Tests mark the module as running for the sessions they hook, as they mark the hooks. On Claude Code 2.1.325 the module's processes have the Claude Code process as parent, the same pid a hook's CLAUDE_PID names, and Claude Code parses a Stop hook's `systemMessage` (both probed with a throwaway mod).
leaf-agent
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Claude Code didn't load Leaf's hooks module into a session holding a page, Leaf's Stop hook now tells the user, once per Claude Code process. Claude Code refuses a module it can't validate and reports the refusal only in its debug log. When it refused
hooks/claude-code.tsafter #5907, sessions lost their band, turn-end clerk and thread forks, and all Max saw was the band gone.The signal comes from the pages follower, which only the module starts: it now records the Claude Code process it runs in. A Stop that ends the turn of a session holding a page, in a process no follower has recorded, prints a
systemMessage. It says what is off, gives theclaude plugin validate <plugin root>command that says why, and suggests/reload-pluginsonce an update fixes it. The notice records the process too, so it shows once.To weigh: the notice prints only on a Stop that ends the turn, since a Stop that continues it already prints its own output. A turn that ends within about a second of its own first claim could warn wrongly, because the follower for that claim may not have started yet; the harness docstring says so.
Max asked for this after the missing band. On Claude Code 2.1.325, a throwaway mod showed that the module's processes have the Claude Code process as their parent, the pid a hook's
CLAUDE_PIDnames, and that Claude Code parses a Stop hook'ssystemMessage. Tests mark the module as running for the sessions they hook. The new test fails without the notice.test_hooks.py,test_stop_guard.pyandtest_forks.pypass.test_session_lifecycle.py's server-start tests flake under load with and without this change (3 runs each).