fix(cli): keep unrelated AGENTS.md content intact on remove - #3185
Open
L4XB wants to merge 1 commit into
Open
Conversation
uninstallRule cut the Context7 section and then collapsed every run of three or more newlines in the whole file, and stripped leading newlines. That silently rewrote the user's own content: blank lines inside fenced code blocks and the spacing between their sections were changed by a command that should only remove what setup added. Normalize only the seam left by the removed section (at most one blank line between the surrounding content, single trailing newline) and leave everything else byte for byte as it was.
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.
Summary
ctx7 removefor the append-style rule files (AGENTS.md,GEMINI.md) cut the<!-- context7 -->section and then ran.replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "")on the whole file. That silently rewrote content the CLI never added: two blank lines inside a fenced code block were collapsed, and the spacing between the user's own sections changed.This PR normalizes only the seam left by the removed section (at most one blank line between the surrounding content, a single trailing newline) and leaves everything else byte for byte as it was. The section lookup itself is unchanged.
Before / after for
## Team notesare collapsedTests
Two cases added to
packages/cli/src/__tests__/remove.test.ts: the file above is compared withtoBeagainst the expected byte-identical result, and a trailing section removal keeps the preceding content (including trailing spaces on the user's lines).Changeset:
ctx7patch.