fix(integrations): cline hook note collapses onto instruction at EOF#3263
Merged
Conversation
The hook-note injection regex matches the line terminator via (\r\n|\n|$), so the captured eol group is empty when the instruction is the final line of a file with no trailing newline. The cline integration emitted the note with that empty eol, mashing the note text and the instruction onto a single line. Default eol to '\n', matching the agy integration twin which already guards this case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an edge case in the Cline integration’s hook-note injection where, if the hook instruction is the final line of a file with no trailing newline, the injected note text could collapse onto the instruction line. The change mirrors the existing behavior used in sibling integrations by defaulting the captured end-of-line to "\n" when the regex match occurs via $.
Changes:
- Update
ClineIntegration._inject_hook_command_note()to useeol = m.group(3) or "\n"so injected content never concatenates onto the instruction line at EOF. - Add a regression test covering injection when the input content has no trailing newline.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/integrations/cline/__init__.py |
Defaults the matched EOL to "\n" when empty to prevent note/instruction line collapse at EOF. |
tests/integrations/test_integration_cline.py |
Adds a regression test ensuring the instruction remains on its own line when the file has no trailing newline. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Low
Collaborator
|
Thank you! |
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.
Description
ClineIntegration._inject_hook_command_note()inserts a dot-to-hyphen note before the hook-output instruction. Its regex matches the line terminator with an alternation that includes$:r"(?m)^(\s*)(- For each executable hook, output the following[^\r\n]*)(\r\n|\n|$)"When the instruction is the final line of a file with no trailing newline, the third group (
eol) captures the empty string. The integration then emits:so the note text and the instruction are concatenated onto a single line (e.g.
...replace dots with hyphens.- For each executable hook...).The sibling
agyintegration already guards this exact case witheol = m.group(3) or "\n"and an explanatory comment —clineis the lone outlier.Fix
Default
eolto"\n"when empty, mirroring theagytwin verbatim (same one-line guard + comment).Testing
test_cline_hook_instruction_injection_no_trailing_newline: feeds the instruction with no trailing newline and asserts the instruction stays on its own line ("\n- For each executable hook..."). Fails before (note mashed onto the instruction), passes after.uvx ruff checkclean; the two cline hook-injection tests pass.AI Disclosure
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI spotted the
agy-vs-clineparity gap; I confirmed the empty-eolcollapse, verified the fail-before/pass-after test, and reviewed the diff before submitting.