Main entry point for UserPromptSubmit hook.
()
| 28 | |
| 29 | |
| 30 | def 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 | |
| 57 | if __name__ == '__main__': |
no test coverage detected