feat: merge multiple hooks per event into single hook-dispatch process#18
Merged
Conversation
Resolves #6. Instead of spawning N separate `teamai <subcommand>` processes per Claude Code hook event, introduce a unified `teamai hook-dispatch <event>` command that reads STDIN once and fans out to all handlers internally. Key changes: - New dispatcher core (hook-dispatch.ts) with routing, isolation via Promise.allSettled, per-handler timeout, and output merging - Handler registry (hook-handlers.ts) wrapping existing subcommand logic - hooks.ts now emits 9 merged dispatch entries instead of 13 individual ones - Legacy hooks are auto-cleaned on next `teamai hooks inject` - Backward compatible: standalone subcommands (pull, track, etc.) unchanged Performance: lightweight events (prompt-submit) drop from ~1040ms to ~220ms by eliminating redundant Node.js cold starts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…format The E2E test file still expected the old 13-hook format. Updated to match the new 9-entry dispatch format (1 per event+matcher instead of N per event). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
teamai hook-dispatch <event>command that replaces N separate processes per hook event with a single processPromise.allSettled(isolation + per-handler timeout)teamai hooks injectnow emits 9 merged entries instead of 13 individual ones; legacy hooks are auto-cleanedCloses #6
Test plan
teamai hooks injectwrites correct format to settings.json (9 dispatch entries, 0 legacy)teamai hook-dispatch session-startsuccessfully runs pull + dashboard-report in one processteamai hook-dispatch stopruns update + contribute-check + dashboard-reportteamai hook-dispatch post-tool-use --matcher Bashruns auto-recall + dashboard-reportteamai hook-dispatch prompt-submitrecords slash command usage to usage.jsonlteamai pull,teamai track --stdinetc. still work independently🤖 Generated with Claude Code