fix(cline): stop unrelated prose from suppressing the hook command note - #4150
Open
jawwad-ali wants to merge 1 commit into
Open
fix(cline): stop unrelated prose from suppressing the hook command note#4150jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
`ClineIntegration._inject_hook_command_note` guarded idempotency with a whole-document substring scan -- `if "replace dots" in content: return content` -- instead of the per-instruction check the shared `SkillsIntegration._inject_hook_command_note` helper uses (base.py:1637-1642), which compares only the line immediately above each match. Two consequences, both verified on main: A. unrelated prose -> note injected? False (base: True) B. two hook sections, one already noted -> notes: 1 (want 2) (a) Any command or extension markdown whose prose happens to contain the phrase "replace dots" loses the note entirely, so the generated workflow tells the agent to emit `/speckit.git.commit` -- a dotted command Cline never registers, since Cline installs `speckit-git-commit.md`. (b) A document with one already-noted hook section never gets a note on a second, un-noted one -- exactly what the base helper was changed to handle. Also aligns the capture group with the base helper: `^([ \t]*)` rather than `^(\s*)`. Because `\s` matches newlines the captured "indent" could swallow a preceding blank line, which was then re-emitted between the note and the instruction: '## Hooks\n\n <note>\n\n - For each executable hook, ...' The per-instruction check cannot line up until this is fixed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
ClineIntegration._inject_hook_command_noteguards idempotency with a whole-document substring scan:The shared
SkillsIntegration._inject_hook_command_notehelper (base.py:1637-1642) instead compares only the line immediately above each match:Cline never picked up that change.
Reproduction on current
main(a) Any command or extension markdown whose prose happens to contain the phrase "replace dots" — e.g.
"When normalizing table names, replace dots with underscores."— loses the note entirely. The generated workflow then tells the agent to emit/speckit.git.commit, a dotted command Cline never registers (Cline installsspeckit-git-commit.md). The note exists precisely to prevent that.(b) A document with one already-noted hook section never gets a note on a second, un-noted one — exactly the case the base helper was changed to handle.
(c) Secondary: cline's regex captures indentation with
^(\s*)where the base uses^([ \t]*). Because\smatches newlines, the captured "indent" can swallow a preceding blank line, which is then re-emitted between the note and the instruction. The per-instruction check cannot line up until this is fixed, so both belong in one change.Fix
Adopt the base helper's per-instruction check and its
[ \t]*capture. After the fix:Verification
tests/integrationsscope: 18 failed, 2627 passed — identical to the clean-mainbaseline's 18 (all Windows symlink-privilege), plus my 3 new tests.uvx ruff@0.15.0 check src tests→ cleanNo breaking change. Content that already has the note above every instruction is returned byte-identical; only documents that were previously missing a note now gain one.
Written with assistance from Claude Code. Bug found, reproduced, and verified by me on current
main.