Protokoll #14484

ID14484
Zeitstempel2025-12-25 10:42:13.370913
Clientroot
IP
Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens1,180 (Input: 0, Output: 0)
Dauer105 ms
Request-Zeit
Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18
Response-Zeit-

Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22

Request

{
    "event": "PreToolUse",
    "tool_name": "Read",
    "tool_input": {
        "file_path": "\/var\/www\/tools\/ki-protokoll\/claude-hook\/hook_dispatcher.py"
    }
}

Response

{
    "tool_response": {
        "type": "text",
        "file": {
            "filePath": "\/var\/www\/tools\/ki-protokoll\/claude-hook\/hook_dispatcher.py",
            "content": "#!\/opt\/mcp-servers\/mcp-db\/venv\/bin\/python\n\"\"\"\nHook Dispatcher - Stabiler Einstiegspunkt für Claude Code Hooks.\n\nNIEMALS ÄNDERN. Änderungen an Regeln nur in quality\/*.py\n\nUsage:\n    hook_dispatcher.py pre   # PreToolUse (BLOCK)\n    hook_dispatcher.py post  # PostToolUse (WARN)\n\"\"\"\n\nimport json\nimport sys\nimport importlib.util\nimport os\nfrom pathlib import Path\n\n# DB-Password aus .env laden\nenv_path = Path(__file__).parent \/ \".env\"\nif env_path.exists():\n    with open(env_path) as f:\n        for line in f:\n            if \"=\" in line and not line.startswith(\"#\"):\n                key, value = line.strip().split(\"=\", 1)\n                os.environ[key] = value\n\n\ndef load_module(name: str):\n    \"\"\"Lädt ein Python-Modul dynamisch.\"\"\"\n    module_path = Path(__file__).parent \/ \"quality\" \/ f\"{name}.py\"\n    if not module_path.exists():\n        return None\n\n    spec = importlib.util.spec_from_file_location(name, module_path)\n    module = importlib.util.module_from_spec(spec)\n    spec.loader.exec_module(module)\n    return module\n\n\ndef main():\n    if len(sys.argv) < 2:\n        print(json.dumps({\"error\": \"Usage: hook_dispatcher.py pre|post\"}))\n        sys.exit(1)\n\n    mode = sys.argv[1]\n\n    # Hook-Input von stdin lesen\n    try:\n        hook_input = json.load(sys.stdin)\n    except json.JSONDecodeError:\n        print(json.dumps({\"allowed\": True}))  # Bei Fehler durchlassen\n        sys.exit(0)\n\n    # Tool-Daten extrahieren\n    tool_name = hook_input.get(\"tool_name\", \"\")\n    tool_input = hook_input.get(\"tool_input\", {})\n\n    # Nur für Write\/Edit auf PHP-Dateien\n    file_path = tool_input.get(\"file_path\", \"\")\n    content = tool_input.get(\"content\", \"\")\n\n    if not file_path.endswith(\".php\"):\n        # Nicht-PHP: durchlassen ohne Output (implizit allow)\n        sys.exit(0)\n\n    # Modul laden und ausführen\n    if mode == \"pre\":\n        module = load_module(\"pre_rules\")\n        if module and hasattr(module, \"check\"):\n            result = module.check(file_path, content)\n            if not result.get(\"allowed\", True):\n                # Task für Violation erstellen\n                try:\n                    task_creator = load_module(\"task_creator\")\n                    if task_creator:\n                        # Parse Rule-ID aus Message\n                        msg = result.get(\"message\", \"\")\n                        rule_id = \"UNKNOWN\"\n                        if \"[\" in msg and \"]\" in msg:\n                            rule_id = msg.split(\"[\")[1].split(\"]\")[0]\n                        task_creator.create_violation_task(\n                            file_path, rule_id, msg, \"block\"\n                        )\n                except Exception:\n                    pass  # Task-Erstellung darf Hook nicht crashen\n\n                # BLOCK: Korrektes Claude Code Format\n                output = {\n                    \"hookSpecificOutput\": {\n                        \"hookEventName\": \"PreToolUse\",\n                        \"permissionDecision\": \"deny\",\n                        \"permissionDecisionReason\": result.get(\"message\", \"Quality check failed\")\n                    }\n                }\n                print(json.dumps(output))\n        # Bei allow: kein Output nötig (implizit allow)\n\n    elif mode == \"post\":\n        module = load_module(\"post_rules\")\n        if module and hasattr(module, \"check\"):\n            result = module.check(file_path, content)\n            # Post-Hook gibt Warnungen aus, blockiert nicht\n            if result.get(\"warnings\"):\n                # Tasks für Warnungen erstellen\n                try:\n                    task_creator = load_module(\"task_creator\")\n                    if task_creator:\n                        task_creator.create_tasks_for_warnings(\n                            file_path, result[\"warnings\"]\n                        )\n                except Exception:\n                    pass  # Task-Erstellung darf Hook nicht crashen\n\n                for warning in result[\"warnings\"]:\n                    print(f\"[QUALITY] {warning}\", file=sys.stderr)\n        # Post-Hook blockiert nie\n\n    else:\n        print(json.dumps({\"error\": f\"Unknown mode: {mode}\"}))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()\n",
            "numLines": 125,
            "startLine": 1,
            "totalLines": 125
        }
    }
}
← Vorheriger Zur Liste Nächster →