Repository navigation
cli: don't revert formatter-only changes in managed ai-files sections - #202
Open
CloudCorpRecords wants to merge 1 commit into
Open
CloudCorpRecords wants to merge 1 commit into
CloudCorpRecords wants to merge 1 commit into
Conversation
CloudCorpRecords
force-pushed
the
fix/ai-files-formatter-revert-201
branch
from
October 19, 2026 14:58
8f319d0 to
d4136d5
Compare
Fixes the AGENTS.md managed-section update loop where any formatter rewrap inside the section counted as a change and got rewritten back. The section is now compared whitespace-normalized before rewriting; genuine content updates still apply. Relates to convex#201 Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
CloudCorpRecords
force-pushed
the
fix/ai-files-formatter-revert-201
branch
from
October 20, 2026 21:21
d4136d5 to
8d15ad8
Compare
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.
Fixes the update loop reported in #201: with Prettier configured with proseWrap "always", an install step formats AGENTS.md, then ai-files update restores the original wrapping inside the managed section, so prettier --check fails again on the next run.
The root cause is in injectManagedSection (src/cli/lib/aiFiles/utils.ts): the rebuilt file was compared to disk byte-for-byte, so any formatter rewrap inside the convex-ai markers counted as a change and triggered a rewrite. The section between the markers is now compared whitespace-normalized against the template before deciding to rewrite. If the two differ only in whitespace and line breaks, the file is left untouched. Genuine content updates and real content drift are still replaced, the no-markers append path is unchanged, and because the fix lives in the shared helper, the CLAUDE.md managed section gets the same behavior.
Tests: new src/cli/lib/aiFiles/utils.test.ts with 5 cases covering a formatter-rewrapped section left alone (the #201 repro), a genuine content update still applying, real drift still being replaced by the template, appending when no markers exist, and no write when the section is identical. I verified the behavior by executing the function directly (the rewrapped case rewrote the file before this change and is a no-op after); the repo test suite will exercise it in CI here.
Prepared with AI assistance.