MCPcopy
hub / github.com/anthropics/claude-code / main

Function main

plugins/hookify/hooks/userpromptsubmit.py:30–54  ·  view source on GitHub ↗

Main entry point for UserPromptSubmit hook.

()

Source from the content-addressed store, hash-verified

28
29
30def main():
31 """Main entry point for UserPromptSubmit hook."""
32 try:
33 # Read input from stdin
34 input_data = json.load(sys.stdin)
35
36 # Load user prompt rules
37 rules = load_rules(event='prompt')
38
39 # Evaluate rules
40 engine = RuleEngine()
41 result = engine.evaluate_rules(rules, input_data)
42
43 # Always output JSON (even if empty)
44 print(json.dumps(result), file=sys.stdout)
45
46 except Exception as e:
47 error_output = {
48 "systemMessage": f"Hookify error: {str(e)}"
49 }
50 print(json.dumps(error_output), file=sys.stdout)
51
52 finally:
53 # ALWAYS exit 0
54 sys.exit(0)
55
56
57if __name__ == '__main__':

Callers 1

Calls 3

evaluate_rulesMethod · 0.95
load_rulesFunction · 0.90
RuleEngineClass · 0.90

Tested by

no test coverage detected