fix: normalize CRLF line endings in prompt file parser#11942
Open
majiayu000 wants to merge 3 commits intocontinuedev:mainfrom
Open
fix: normalize CRLF line endings in prompt file parser#11942majiayu000 wants to merge 3 commits intocontinuedev:mainfrom
majiayu000 wants to merge 3 commits intocontinuedev:mainfrom
Conversation
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>
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
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>
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
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\nto\nat the top ofparsePromptFile()before any splitting happens. This is the same pattern already used inpackages/config-yaml/src/markdown/markdownToRule.ts.Checklist
Tests
Added
core/promptFiles/parsePromptFile.test.tswith 7 test cases:<system>tag with CRLFAll 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.
\r\nto\nat the start ofparsePromptFile()before splitting on\n---\n.<system>parsing..test.tsfile to fix Prettier CI failure.Written for commit 89482b4. Summary will update on new commits.