Skip to content

fix: normalize CRLF line endings in prompt file parser#11942

Open
majiayu000 wants to merge 3 commits intocontinuedev:mainfrom
majiayu000:fix/issue-11876-crlf-prompt-file-parsing
Open

fix: normalize CRLF line endings in prompt file parser#11942
majiayu000 wants to merge 3 commits intocontinuedev:mainfrom
majiayu000:fix/issue-11876-crlf-prompt-file-parsing

Conversation

@majiayu000
Copy link
Copy Markdown

@majiayu000 majiayu000 commented Mar 28, 2026

Description

Fixes #11876

parsePromptFile() splits on "\n---\n" to separate frontmatter from the prompt body. When the file has CRLF line endings (common on Windows), this split fails because the separator is actually "\r\n---\r\n". The frontmatter doesn't get parsed, so the slash command name and description fall back to the filename instead of the values in the YAML block.

Fixed by normalizing \r\n to \n at the top of parsePromptFile() before any splitting happens. This is the same pattern already used in packages/config-yaml/src/markdown/markdownToRule.ts.

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Tests

Added core/promptFiles/parsePromptFile.test.ts with 7 test cases:

  • LF content (baseline)
  • CRLF content (the bug)
  • Mixed line endings
  • No frontmatter fallback
  • <system> tag with CRLF
  • Default version
  • Explicit version in frontmatter

All pass with NODE_OPTIONS=--experimental-vm-modules npx jest promptFiles/parsePromptFile.test.ts.


Summary by cubic

Normalize CRLF line endings in the prompt file parser so frontmatter parses on Windows. This makes the command name, description, and system message come from YAML instead of the filename.

  • Bug Fixes
    • Normalize \r\n to \n at the start of parsePromptFile() before splitting on \n---\n.
    • Add Vitest tests for LF/CRLF, no-frontmatter fallback, and <system> parsing.
    • Remove a duplicate .test.ts file to fix Prettier CI failure.

Written for commit 89482b4. Summary will update on new commits.

Strip \r\n to \n at the start of parsePromptFile() so the
frontmatter separator split works on Windows-style line endings.

Signed-off-by: majiayu000 <1835304752@qq.com>
Signed-off-by: majiayu000 <1835304752@qq.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

The .test.ts file duplicated the .vitest.ts tests and did not
match project conventions, causing the prettier CI check to fail.

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 marked this pull request as ready for review March 28, 2026 02:30
@majiayu000 majiayu000 requested a review from a team as a code owner March 28, 2026 02:30
@majiayu000 majiayu000 requested review from sestinj and removed request for a team March 28, 2026 02:30
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 28, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@majiayu000
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Continue fails to parse prompts.md file when EOL sequence is CRLF

1 participant