{
"event": "PreToolUse",
"tool_name": "Bash",
"tool_input": {
"command": "PYTHONPATH=\/var\/www\/mcp-servers .\/venv\/bin\/python -c \"\nimport yaml\nfrom validators import ContractValidator, ScopeResolver, RuleEvaluator\n\n# Test with simpler patterns\nyaml_content = '''\ncontract:\n name: test-htmx-validation\n version: \\\"1.0\\\"\n scope:\n paths:\n - \\\"\/src\/View\/**\/*.php\\\"\n excludes:\n - \\\"**\/layout.php\\\"\n rules:\n - id: no-fetch\n check_type: forbidden_pattern\n patterns:\n - \\\"fetch(\\\"\n - \\\"XMLHttpRequest\\\"\n in_files: \\\"**\/*.php\\\"\n severity: major\n description: \\\"Use HTMX instead of fetch()\\\"\n - id: line-limit\n check_type: line_count\n max_lines: 300\n in_files: \\\"**\/*.php\\\"\n severity: major\n description: \\\"Files should be under 300 lines\\\"\n'''\n\ncontract_data = yaml.safe_load(yaml_content)\nprint('Testing: forbidden_pattern + line_count rules')\n\nvalidator = ContractValidator(contract_data)\nresult = validator.validate()\n\nprint(f'\\\\n=== Validation Result ===')\nprint(f'Contract: {result.contract}')\nprint(f'Outcome: {result.outcome}')\nprint(f'Critical: {result.critical}, Major: {result.major}, Minor: {result.minor}')\nprint(f'Total Findings: {len(result.findings)}')\n\n# Group findings by factor\nby_factor = {}\nfor f in result.findings:\n t = f.get('factor', 'unknown')\n by_factor[t] = by_factor.get(t, 0) + 1\nprint(f'\\\\nFindings by factor: {by_factor}')\n\n# Show sample findings\nprint('\\\\nSample findings:')\nfor f in result.findings[:5]:\n file = f.get('file', '?').replace('\/var\/www\/dev.campus.systemische-tools.de\/', '')\n print(f' - [{f.get(\\\"type\\\")}] {file}: {f.get(\\\"message\\\", \\\"\\\")[:60]}')\n\"\n",
"description": "Test validator with fixed YAML"
}
}
{
"tool_response": {
"stdout": "Testing: forbidden_pattern + line_count rules\n\n=== Validation Result ===\nContract: test-htmx-validation\nOutcome: revision_required\nCritical: 0, Major: 8, Minor: 0\nTotal Findings: 8\n\nFindings by factor: {'line_count': 4, 'forbidden_pattern': 4}\n\nSample findings:\n - [major] src\/View\/content-pipeline\/show.php: File has 313 lines (max: 300)\n - [major] src\/View\/docs\/code-graph-global.php: Forbidden pattern found: 'fetch('\n - [major] src\/View\/docs\/code-graph-global.php: File has 320 lines (max: 300)\n - [major] src\/View\/docs\/code-graph.php: Forbidden pattern found: 'fetch('\n - [major] src\/View\/content-pipeline\/run-status.php: Forbidden pattern found: 'fetch('",
"stderr": "",
"interrupted": false,
"isImage": false
}
}