[BUG] Hookify truncates regex patterns containing triple dashes
What's wrong?
Hookify splits frontmatter with content.split('---', 2). This treats --- inside a regex value as the closing delimiter, truncating the pattern and moving the rest of the frontmatter into the rule message.
For example, pattern: ^---$ is parsed as ^, so the rule silently matches the wrong text.
Expected behavior
Only a standalone, unindented --- line should close frontmatter. Dashes inside values should remain unchanged.
Steps to reproduce
from hookify.core.config_loader import extract_frontmatter
frontmatter, message = extract_frontmatter("""---
name: markdown-rule
event: file
pattern: ^---$
---
Detect Markdown separators.
""")
assert frontmatter["pattern"] == "^---$"
assert message == "Detect Markdown separators."
On current main (347b38e), the first assertion fails because the parsed pattern is ^.
Additional information
I searched existing issues and PRs for this case. PR #54873 also changes the hand-written parser, but it retains split('---', 2), so this delimiter bug remains there as well.
Environment: macOS, Python 3.14.2. The Claude CLI version is not involved; this reproduces directly against the Hookify plugin source.
3 Comments
I have a focused patch with four regression tests ready at zjncs/anthropics-claude-code@dba5dea:
https://github.com/zjncs/anthropics-claude-code/compare/main...fix-hookify-delimiter
The tests fail twice on current
main(^---$andfoo---bar) and pass 4/4 with the fix.compileallandgit diff --checkalso pass.GitHub currently rejects creating the upstream PR with
zjncs does not have the correct permissions to execute CreatePullRequest. If external PRs for this repository require approval, please let me know the supported path.I have a fix for this:
extract_frontmatternow treats only a line that is exactly---as the opening/closing marker, sopattern: ^---$parses intact. Checked with your repro, CRLF input, a body containing---, empty/unclosed frontmatter, and all shipped example rules (fails onmain, passes on the branch).Branch: https://github.com/Kaushik2210/claude-code/tree/fix/hookify-frontmatter-triple-dash
Compare: https://github.com/anthropics/claude-code/compare/main...Kaushik2210:claude-code:fix/hookify-frontmatter-triple-dash
I tried to open a PR but GitHub rejects
CreatePullRequestfor non-member accounts on this repo right now, so the fix is on my fork in case a maintainer wants to cherry-pick it or open the PR.A fix is in https://github.com/Faizankhan17623/claude-code/commit/ed29abf432b84499e9ce830849947aabcec272e0 (the repo takes PRs from collaborators only, so I can't open one).
extract_frontmatterinplugins/hookify/core/config_loader.pynow ends the frontmatter at the first line that is exactly---instead of splitting on the first---anywhere, so a pattern such asecho ---loads whole. Tested with that rule:echo --- hiis denied,echo hellopasses.