Skip to content

fix(hookify): make file rules match Write tool content#24321

Open
ashwingopalsamy wants to merge 1 commit intoanthropics:mainfrom
ashwingopalsamy:main
Open

fix(hookify): make file rules match Write tool content#24321
ashwingopalsamy wants to merge 1 commit intoanthropics:mainfrom
ashwingopalsamy:main

Conversation

@ashwingopalsamy
Copy link

@ashwingopalsamy ashwingopalsamy commented Feb 9, 2026

Summary

Fixes hookify file-rule matching so rules targeting new_text (including legacy event: file + pattern) also match Write tool payloads.

Before this change, Write operations used tool_input.content, but new_text resolution only looked at new_string, so file rules could miss new-file writes.

Changes

  • For Write/Edit, content / new_text / new_string now resolve consistently from:
    • new_string (Edit), (or)
    • content (Write).

Test Plan

  • Sanity check:
    • File rule with pattern: console\.log\( matches:
      • Write input using tool_input.content
      • Edit input using tool_input.new_string
    • Negative control with non-matching content returns no match.
Screenshot 2026-02-09 at 08 47 26

Risk

Low. Change is limited to Write/Edit field mapping for file-rule evaluation and does not alter unrelated hook events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant