hookify: _extract_field returns wrong key for Write tool on new_text field

Resolved 💬 3 comments Opened Apr 15, 2026 by adelaidasofia Closed Apr 18, 2026

Bug

In plugins/hookify/core/rule_engine.py, the _extract_field method (line 239) handles the new_text field for file events by returning tool_input.get('new_string', ''). This works for the Edit tool, but the Write tool uses content as its key, not new_string.

Any hookify rule using field: new_text with event: file silently fails to match on Write tool operations. It only works on Edit.

Reproduction

  1. Create a hookify rule with event: file and field: new_text
  2. Trigger a Write tool call
  3. The rule never matches because tool_input.get('new_string', '') returns empty string for Write inputs

Fix

Line 239 should check both keys:

return tool_input.get('new_string') or tool_input.get('content', '')

This makes new_text work as a universal "new content being written" field for both Write and Edit tools.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗