MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / matching

Method matching

src/hooks/manager.ts:42–56  ·  view source on GitHub ↗

Returns all hooks for an event (after matcher filtering when toolName is supplied).

(event: HookEvent, toolName?: string)

Source from the content-addressed store, hash-verified

40
41 /** Returns all hooks for an event (after matcher filtering when toolName is supplied). */
42 matching(event: HookEvent, toolName?: string): HookConfig[] {
43 const all = this.cfg[event] ?? [];
44 if (!toolName || (event !== 'PreToolUse' && event !== 'PostToolUse')) {
45 return all;
46 }
47 return all.filter(h => {
48 if (!h.matcher) return true;
49 try {
50 return new RegExp(h.matcher).test(toolName);
51 } catch {
52 // Invalid regex → literal substring match (forgiving)
53 return toolName.includes(h.matcher);
54 }
55 });
56 }
57
58 /** Convenience: how many hooks would dispatch for this event/tool combination. */
59 countMatching(event: HookEvent, toolName?: string): number {

Callers 3

countMatchingMethod · 0.95
dispatchMethod · 0.95
hooks.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected