feat(hooks): unified Hook Matcher DSL for hook filtering#704
Merged
Cai-Tang-www merged 3 commits intoJun 1, 2026
Conversation
feat(hooks): add unified Hook Matcher DSL with tool_name/tool_name_regex/arguments_contains Introduce a match field on hook items that supports three matcher dimensions (AND within fields, OR across values). Matcher filtering is applied at the executor scheduling layer — non-matching hooks are skipped without affecting existing block/failure semantics. Includes backward-compatible bridging of the legacy warn_on_tool_call params, plus a migration notification when old and new parameters coexist. - New matcher types and compiler in internal/runtime/hooks/matcher.go - Executor integration to skip non-matching hooks before running handlers - tool_arguments_preview (sanitized + truncated) added to before_tool_call metadata - Config validation for match syntax and hook-point capability constraints - Backward-compatible warn_on_tool_call bridging with deprecation notification - Updated design docs and example configs Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> @
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
refactor(hooks): remove warn_on_tool_call backward compat, reject unknown match fields - Remove legacy warn_on_tool_call bridging: params.tool_name/tool_names no longer route through matcher; handler only reads "message" param. - Reject unknown match keys at CompileHookMatcher level instead of silently ignoring, preventing misconfigured hooks from running unfiltered. - Strip MatcherMigrationWarning from HookSpec, emitMatcherMigrationWarning, and all migration-notification infrastructure. - Remove ~140 lines of compat helpers across config and runtime packages. - Raise hooks package coverage to 95.9% with new matcher edge-case tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> @
Collaborator
Author
|
/review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@
概要
match字段,支持三种匹配维度:tool_name、tool_name_regex、arguments_containstool_arguments_preview(脱敏 + 截断)注入到before_tool_callmetadata,同时继续剥离tool_arguments原文warn_on_tool_call参数做向后兼容桥接,旧新参数共存时发送迁移提示match语法关键文件
测试计划
@