{
"event": "PreToolUse",
"tool_name": "Bash",
"tool_input": {
"command": "# Debug full script execution\npython3 -c \"\nimport json\nimport re\n\nHARD_RULES = [\n {\n 'id': 'H1',\n 'name': 'strict_types_required',\n 'pattern': r'declare\\s*\\(\\s*strict_types\\s*=\\s*1\\s*\\)',\n 'must_match': True,\n 'applies_to': 'all',\n 'message': 'Missing declare(strict_types=1)'\n }\n]\n\nALLOWED_PATHS = ['\/Factory\/', '\/Bootstrap\/', '\/tests\/', '\/Test\/', '\/vendor\/']\n\ndef is_allowed_path(file_path):\n for allowed in ALLOWED_PATHS:\n if allowed in file_path:\n return True\n return False\n\ndef rule_applies(rule, file_path):\n if 'applies_to' in rule:\n if rule['applies_to'] == 'all':\n return True\n return rule['applies_to'] in file_path\n if 'applies_to_not' in rule:\n return rule['applies_to_not'] not in file_path\n return True\n\ndef check_rule(rule, content):\n match = re.search(rule['pattern'], content)\n if rule['must_match']:\n return match is None # Violated if NOT found\n else:\n return match is not None # Violated if found\n\nfile_path = '\/var\/www\/dev\/src\/Service\/TestService.php'\ncontent = '<?php\\n\\nnamespace Service;\\n\\nclass TestService {}'\n\nprint(f'File path: {file_path}')\nprint(f'Ends with .php: {file_path.endswith(\\\".php\\\")}')\nprint(f'Is allowed path: {is_allowed_path(file_path)}')\n\nfor rule in HARD_RULES:\n applies = rule_applies(rule, file_path)\n print(f'Rule {rule[\\\"id\\\"]} applies: {applies}')\n if applies:\n violated = check_rule(rule, content)\n print(f'Rule {rule[\\\"id\\\"]} violated: {violated}')\n\"",
"description": "Debug script logic"
}
}
{
"tool_response": {
"stdout": "File path: \/var\/www\/dev\/src\/Service\/TestService.php\nEnds with .php: True\nIs allowed path: False\nRule H1 applies: True\nRule H1 violated: True",
"stderr": "",
"interrupted": false,
"isImage": false
}
}