fix(hooks): remove --stdin routing split that bypassed handler registry#179
Merged
jeff-r2026 merged 2 commits intoJul 10, 2026
Merged
Conversation
The --stdin flag on hook-dispatch was used to route calls to local-agent.ts instead of hookDispatchCli, silently dropping all existing handlers (pull, update, contribute-check, mr-hint, dashboard-report, track, todowrite-hint). Additionally, for init --http users both statusReportHandler and localAgentHandler hit the same /api/local-agent/report + /sync endpoints, causing double requests and double command consumption on session-start and prompt-submit. Fix: - Remove --stdin from getDispatchCommand (restores v0.17.2 compat) - Remove --stdin routing fork in index.ts (all calls go through hookDispatchCli's unified handler registry) - Register local-agent report/sync as a new handler in the registry so HTTP reporting and workspace binding prompts still work - Remove statusReportSessionHandler and statusReportMessageHandler from the registry (replaced by localAgentHandler to avoid double report/sync) - Delete dead code: hookDispatch(), readStdin(), hookEventName() in local-agent.ts, and the two dead handler definitions + constant in hook-handlers.ts - Keep --stdin as a no-op option for forward compat with hooks already written to disk - Add regression test asserting exactly one HTTP reporter per event Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
status-report.ts has no import chain after removing its handlers from the registry. Its HTTP report/sync/ack functionality is fully covered by local-agent.ts. Each CLI version ships as a self-contained bundle so removal has no cross-version compatibility impact. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e0dd30d to
dd44c18
Compare
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.
Summary
--stdinflag fromgetDispatchCommand— restores v0.17.2 backward-compatible hook command format--stdinrouting fork inindex.ts— allhook-dispatchcalls now go throughhookDispatchCli's unified handler registry--stdinas a no-op option declaration for forward compat with hooks already written to diskRoot Cause
PR #152 introduced a
--stdinflag that splithook-dispatchinto two mutually exclusive paths:--stdinpresent →local-agent.tshookDispatch()(only does HTTP report/sync)--stdinabsent →hookDispatchCli()(full handler registry: pull, update, contribute-check, mr-hint, etc.)Simultaneously,
getDispatchCommandwas changed to emit--stdinin all hook commands. This means after upgrade, every hook goes through the local-agent path and silently drops all existing handlers:updateHandler,contributeCheckHandler,mrHintHandler,pullHandler,dashboardReportHandler,trackHandler,todowriteHintHandler.Additionally, downgrading to v0.17.2 after upgrade causes
--stdinto be rejected as an unknown option → all hooks fail silently (swallowed by2>/dev/null || true).Fix
builtin-hooks.ts—getDispatchCommandno longer emits--stdinindex.ts— unified code path: always callshookDispatchClihook-handlers.ts— newlocalAgentHandlerregistered on all 4 eventslocal-agent.ts— exportsreportAndSyncFromHookadapter for the handlerCompatibility
--stdinunknown option → silent failure--stdinon disk--stdinaccepted as no-op, still worksTest plan
npx tsc --noEmit— no new type errorsnpx vitest run— hooks-golden (4), hooks (40), hook-handlers (12), contribute-check (33), mr-hint (13) all passnpm run build— clean buildteamai init --force, verify settings.json hooks do NOT contain--stdinteamai pullon a machine with old--stdinhooks, verify reconcile upgrades them cleanly🤖 Generated with Claude Code