Skip to content

Feat/hook dispatcher default disabled - #93

Merged
minarc merged 3 commits into
mainfrom
feat/hook-dispatcher-default-disabled
Jul 9, 2026
Merged

minarc merged 3 commits into
mainfrom
feat/hook-dispatcher-default-disabled

Conversation

@minarc

@minarc minarc commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Centralized hook handling so multiple events now use one shared dispatcher.
    • Version information now appears in the app banner.
  • Bug Fixes

    • Simplified hook routing and reduced duplication across event handling.
    • Improved consistency between configured hooks and their data mapping.
  • Documentation

    • Updated the project structure and hook references in the README.
  • Tests

    • Added regression coverage to verify hook routing and data-mapping behavior.

minarc and others added 3 commits July 9, 2026 14:52
Most hooks were 6-13 line files that only picked a few fields off the input
and called runHook. Replace them with a single generic entrypoint
(scripts/hook.js <EventName>) plus a field-mapper table (lib/hook-registry.js);
hooks.json routes observation-only events through it. Hooks that need runHook
options or custom logic keep dedicated entrypoints (session_start, session_end,
stop, on_signin_result, user_prompt_expansion_signin).

- 20 thin hook files removed; adding an observation-only hook is now a one-line
  registry entry + a hooks.json line
- registry mappers keep the (input, ctx) buildData contract, so ctx-using hooks
  (e.g. SubagentStop's getTranscriptId) port unchanged
- hook.js exits non-zero on an unknown event name
- test/lib.test.js locks the registry <-> hooks.json contract (no missing/orphan
  mappers, event name == argv)
- README script tree updated

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoEUHYQTz1Tx61FcteE979
Version bump for the data-driven hook dispatcher refactor.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoEUHYQTz1Tx61FcteE979
brandLine now renders "SkillMeter v<version> · skillbench" (from PLUGIN_VERSION)
across the sign-in-required, telemetry-active, and welcome boxes. This surfaces
the version the current session's hooks actually loaded — a stale session
(older cached version than the installed one, which only updates on restart) is
now visible at a glance.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoEUHYQTz1Tx61FcteE979
@minarc
minarc merged commit df1f98d into main Jul 9, 2026
1 check was pending
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c0c8678-6caf-4f9c-b456-a03b1151af62

📥 Commits

Reviewing files that changed from the base of the PR and between d11b605 and b0a6ec8.

📒 Files selected for processing (27)
  • skillmeter/.claude-plugin/plugin.json
  • skillmeter/README.md
  • skillmeter/hooks/hooks.json
  • skillmeter/scripts/config_change.js
  • skillmeter/scripts/hook.js
  • skillmeter/scripts/instructions_loaded.js
  • skillmeter/scripts/lib/banner.js
  • skillmeter/scripts/lib/hook-registry.js
  • skillmeter/scripts/notification.js
  • skillmeter/scripts/permission_denied.js
  • skillmeter/scripts/permission_request.js
  • skillmeter/scripts/post_compact.js
  • skillmeter/scripts/post_tool_batch.js
  • skillmeter/scripts/post_tool_use.js
  • skillmeter/scripts/post_tool_use_failure.js
  • skillmeter/scripts/pre_compact.js
  • skillmeter/scripts/pre_tool_use.js
  • skillmeter/scripts/stop_failure.js
  • skillmeter/scripts/subagent_start.js
  • skillmeter/scripts/subagent_stop.js
  • skillmeter/scripts/task_completed.js
  • skillmeter/scripts/task_created.js
  • skillmeter/scripts/teammate_idle.js
  • skillmeter/scripts/user_prompt_submit.js
  • skillmeter/scripts/worktree_create.js
  • skillmeter/scripts/worktree_remove.js
  • skillmeter/test/lib.test.js

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

This PR replaces individual per-hook Node.js CLI scripts with a centralized scripts/hook.js dispatcher that resolves event mappers from a new scripts/lib/hook-registry.js. hooks/hooks.json is rewired to invoke hook.js <EventName> for all hook types. Obsolete per-hook scripts are removed, the banner now displays the plugin version, plugin version is bumped, README is updated, and consistency tests are added.

Changes

Hook Dispatch Centralization

Layer / File(s) Summary
Registry and dispatcher entrypoint
skillmeter/scripts/hook.js, skillmeter/scripts/lib/hook-registry.js
New hook.js CLI resolves an event-name mapper from a new registry module exporting field-mapper functions for each hook event, then invokes runHook.
hooks.json rewired to dispatcher
skillmeter/hooks/hooks.json
All 20 hook entries' command fields are changed to call node ${CLAUDE_PLUGIN_ROOT}/scripts/hook.js <EventName> instead of dedicated scripts.
Removal of obsolete per-hook scripts
skillmeter/scripts/{user_prompt_submit,pre_tool_use,post_tool_use,post_tool_batch,post_tool_use_failure,permission_request,permission_denied,notification,subagent_start,subagent_stop,teammate_idle,task_completed,task_created,instructions_loaded,config_change,worktree_create,worktree_remove,pre_compact,post_compact,stop_failure}.js
All previously separate per-event CLI scripts are deleted, their logic consolidated in the registry.
Registry/dispatch tests, docs, version, banner
skillmeter/test/lib.test.js, skillmeter/README.md, skillmeter/.claude-plugin/plugin.json, skillmeter/scripts/lib/banner.js
New tests cross-check dispatched events against registry mappers and verify mapper output shape/ctx handling; README project structure updated; plugin version bumped to 0.22.0; banner now shows SkillMeter v<version>.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant hooksJson as hooks.json
  participant hookJs as hook.js
  participant registry as hook-registry.js
  participant runHook as runHook

  hooksJson->>hookJs: invoke with event name
  hookJs->>registry: lookup mapper for event
  registry-->>hookJs: mapper function
  hookJs->>runHook: runHook(event, buildData)
  runHook-->>hookJs: resolve or reject
Loading

Possibly related PRs

Suggested reviewers: jhunlee-dev

Poem

One script becomes twenty, then twenty become one,
hook.js the dispatcher, its work never done.
Registry mappers hop into place,
while old scripts vanish without a trace.
🐇 v0.22.0 stamped on the banner bright—
this bunny hops off into the review night!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/hook-dispatcher-default-disabled

Comment @coderabbitai help to get the list of available commands.

@TheStarkor
TheStarkor deleted the feat/hook-dispatcher-default-disabled branch September 21, 2026 18:39
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.

2 participants