Skip to content

feat: merge multiple hooks per event into single hook-dispatch process#18

Merged
jeff-r2026 merged 2 commits into
masterfrom
worktree-feat+hook-dispatch
May 22, 2026
Merged

feat: merge multiple hooks per event into single hook-dispatch process#18
jeff-r2026 merged 2 commits into
masterfrom
worktree-feat+hook-dispatch

Conversation

@jeff-r2026
Copy link
Copy Markdown
Collaborator

Summary

  • Introduces unified teamai hook-dispatch <event> command that replaces N separate processes per hook event with a single process
  • Dispatcher reads STDIN once, fans out to all matching handlers via Promise.allSettled (isolation + per-handler timeout)
  • teamai hooks inject now emits 9 merged entries instead of 13 individual ones; legacy hooks are auto-cleaned
  • Lightweight events (prompt-submit) go from ~1040ms → ~220ms by eliminating redundant Node.js cold starts

Closes #6

Test plan

  • Unit tests: 32 new tests covering dispatcher routing, isolation, timeout, output merging, handler registry, and injection format
  • All 973 existing tests pass (53 test files)
  • TypeScript compiles with zero errors
  • E2E: teamai hooks inject writes correct format to settings.json (9 dispatch entries, 0 legacy)
  • E2E: teamai hook-dispatch session-start successfully runs pull + dashboard-report in one process
  • E2E: teamai hook-dispatch stop runs update + contribute-check + dashboard-report
  • E2E: teamai hook-dispatch post-tool-use --matcher Bash runs auto-recall + dashboard-report
  • E2E: teamai hook-dispatch prompt-submit records slash command usage to usage.jsonl
  • E2E: Dashboard events.jsonl receives all event types correctly
  • Backward compat: standalone teamai pull, teamai track --stdin etc. still work independently

🤖 Generated with Claude Code

jeff-r2026 and others added 2 commits May 22, 2026 11:14
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>
@jeff-r2026 jeff-r2026 merged commit 692ea73 into master May 22, 2026
7 checks passed
@jeff-r2026 jeff-r2026 deleted the worktree-feat+hook-dispatch branch May 22, 2026 03:30
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