mirror of
https://github.com/anthropics/claude-code.git
synced 2026-05-17 15:23:16 +00:00
Add integration tests for multi-hook scenarios in hookify
Create comprehensive pytest integration test suite for the hookify plugin: - test_integration.py: Multi-hook evaluation, rule priority (blocking over warnings), condition AND logic, tool type field extraction, Stop/UserPromptSubmit events - test_rule_loading.py: YAML frontmatter parsing, rule file loading, event filtering - test_error_handling.py: Fault tolerance for missing files, invalid regex, malformed input Also fix a bug discovered through testing: MultiEdit field extraction now gracefully handles malformed edit entries (non-dict values in edits array). 68 tests covering: - Multiple rules combining messages - Blocking rules taking priority over warnings - Multiple conditions with AND logic - Different tool types (Bash, Write, Edit, MultiEdit) - Stop event transcript checking - UserPromptSubmit validation - Tool matcher filtering - Regex pattern matching and caching - Error handling and edge cases https://claude.ai/code/session_014B79JcfZHUaTfnThn3o3g2
This commit is contained in:
@@ -247,9 +247,13 @@ class RuleEngine:
|
||||
if field == 'file_path':
|
||||
return tool_input.get('file_path', '')
|
||||
elif field in ['new_text', 'content']:
|
||||
# Concatenate all edits
|
||||
# Concatenate all edits, handling malformed entries gracefully
|
||||
edits = tool_input.get('edits', [])
|
||||
return ' '.join(e.get('new_string', '') for e in edits)
|
||||
parts = []
|
||||
for e in edits:
|
||||
if isinstance(e, dict):
|
||||
parts.append(e.get('new_string', ''))
|
||||
return ' '.join(parts)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user