Skip to content

cli: don't revert formatter-only changes in managed ai-files sections - #202

Open
CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/ai-files-formatter-revert-201
Open

CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/ai-files-formatter-revert-201

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

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.

@CloudCorpRecords
CloudCorpRecords force-pushed the fix/ai-files-formatter-revert-201 branch from 8f319d0 to d4136d5 Compare October 19, 2026 14:58
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
CloudCorpRecords force-pushed the fix/ai-files-formatter-revert-201 branch from d4136d5 to 8d15ad8 Compare October 20, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant