feat(hookify): add not_regex_match operator and value key support #18419
+51
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two features to hookify that enable more expressive rules:
not_regex_matchoperator — Negated regex matching for exclusion patternsvaluekey in conditions — Alternative topatternfor semantic clarity with non-regex operatorsBoth features are backward-compatible and minimal in scope.
Problem
1. No way to exclude files with regex
Users need rules like "match .tsx files BUT NOT test/story files":
The existing
not_containsdoes literal substring matching. There's no way to do regex negation.2. Semantic confusion with
patternkeyFor operators like
containsandequals,patternis misleading since these aren't regex:Users intuitively try
valueand it silently fails.Solution
1. Add
not_regex_matchoperator (2 lines)2. Support
valueas alias (1 line change)Files Changed
plugins/hookify/core/rule_engine.pynot_regex_matchoperatorplugins/hookify/core/config_loader.pyvaluekeyplugins/hookify/README.mdplugins/hookify/skills/writing-rules/SKILL.mdplugins/hookify/examples/exclude-test-files.local.mdnot_regex_matchUsage Example
Test Plan
Backward Compatibility
Fully backward compatible - existing rules work unchanged.