Skip to content

fix(next): keep line endings in files paramour init edits - #71

Merged
JasonPaff merged 2 commits into
mainfrom
jasonpaff/par-116-init-rewrites-an-unchanged-agents-section-in-crlf-files-and
Oct 2, 2026
Merged

JasonPaff merged 2 commits into
mainfrom
jasonpaff/par-116-init-rewrites-an-unchanged-agents-section-in-crlf-files-and

Conversation

@JasonPaff

Copy link
Copy Markdown
Owner

In the Cadence rc trial (PAR-3, Windows, core.autocrlf=true), paramour init reported "✔ updated paramour section in CLAUDE.md" for a section that hadn't changed. It also left the file with mixed CRLF and LF line endings. upsertAgentsSection compared the CRLF section with its LF snippet using ===. This is the same class of bug as #58, but in the files init edits rather than the generated artifact.

Change

  • New lineEnding(text) next to sameContent in emit.ts. It returns the line ending a user-owned file already uses.
  • Agents section: an existing section is compared with sameContent. Adding or updating it uses the file's line ending.
  • addPackageScript: the re-serialized package.json keeps the file's line ending.
  • next.config wrap: recast prints new nodes with LF and drops the final newline. The result now uses the source's line ending and keeps its final newline. The final newline was lost even for LF files.

Generated files (the artifact, skills) are unchanged and still write LF, as #58 decided.

Verification

  • New init.test.ts cases:
    • A CRLF checkout of the installed section is "already up to date" and stays byte-identical. This is the Cadence case.
    • Appending and updating in a CRLF AGENTS.md produce no bare LF.
    • A CRLF package.json stays CRLF.
  • New wrap-next-config.test.ts cases: CRLF is preserved, the final newline is kept, and no final newline is added when the source had none. These fail without the fix.
  • pnpm test packages/next: 546 passed, 1 skipped. Typecheck and lint are clean.
  • The locally built CLI on Cadence reports "CLAUDE.md paramour section already up to date — skipped", and CLAUDE.md stays CRLF.

Fixes PAR-116

🤖 Generated with Claude Code

In a CRLF checkout, init compared its LF agents snippet with the CRLF
section byte for byte, so it reported "updated" for an unchanged section
and wrote LF lines into a CRLF file. addPackageScript and the next.config
wrap had the same problem, rewriting CRLF files as LF, and recast also
dropped next.config's final newline.

Init now compares its section with line endings normalized (sameContent)
and writes every edit using the file's own line ending (lineEnding), and
the next.config wrap restores the source's final newline.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
paramour-docs Ready Ready Preview Oct 2, 2026 9:45pm UTC

@JasonPaff
JasonPaff merged commit 2e4a142 into main Oct 2, 2026
10 of 11 checks passed
@JasonPaff
JasonPaff deleted the jasonpaff/par-116-init-rewrites-an-unchanged-agents-section-in-crlf-files-and branch October 2, 2026 21:40

This branch was successfully deployed

1 active deployment
Preview — 67aeeee1 Deployed Oct 2, 2026 by vercel[bot]
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