MCPcopy Index your code
hub / github.com/codeaashu/claude-code / convertPluginHooksToMatchers

Function convertPluginHooksToMatchers

src/utils/plugins/loadPluginHooks.ts:28–86  ·  view source on GitHub ↗

* Convert plugin hooks configuration to native matchers with plugin context

(
  plugin: LoadedPlugin,
)

Source from the content-addressed store, hash-verified

26 * Convert plugin hooks configuration to native matchers with plugin context
27 */
28function convertPluginHooksToMatchers(
29 plugin: LoadedPlugin,
30): Record<HookEvent, PluginHookMatcher[]> {
31 const pluginMatchers: Record<HookEvent, PluginHookMatcher[]> = {
32 PreToolUse: [],
33 PostToolUse: [],
34 PostToolUseFailure: [],
35 PermissionDenied: [],
36 Notification: [],
37 UserPromptSubmit: [],
38 SessionStart: [],
39 SessionEnd: [],
40 Stop: [],
41 StopFailure: [],
42 SubagentStart: [],
43 SubagentStop: [],
44 PreCompact: [],
45 PostCompact: [],
46 PermissionRequest: [],
47 Setup: [],
48 TeammateIdle: [],
49 TaskCreated: [],
50 TaskCompleted: [],
51 Elicitation: [],
52 ElicitationResult: [],
53 ConfigChange: [],
54 WorktreeCreate: [],
55 WorktreeRemove: [],
56 InstructionsLoaded: [],
57 CwdChanged: [],
58 FileChanged: [],
59 }
60
61 if (!plugin.hooksConfig) {
62 return pluginMatchers
63 }
64
65 // Process each hook event - pass through all hook types with plugin context
66 for (const [event, matchers] of Object.entries(plugin.hooksConfig)) {
67 const hookEvent = event as HookEvent
68 if (!pluginMatchers[hookEvent]) {
69 continue
70 }
71
72 for (const matcher of matchers) {
73 if (matcher.hooks.length > 0) {
74 pluginMatchers[hookEvent].push({
75 matcher: matcher.matcher,
76 hooks: matcher.hooks,
77 pluginRoot: plugin.path,
78 pluginName: plugin.name,
79 pluginId: plugin.source,
80 })
81 }
82 }
83 }
84
85 return pluginMatchers

Callers 1

loadPluginHooks.tsFile · 0.85

Calls 2

entriesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected