Skip to content

fix(cli): support CRLF and UTF-8 BOM in markdown frontmatter#2095

Closed
echoVic wants to merge 5 commits intoQwenLM:mainfrom
echoVic:fix/windows-frontmatter-parsing
Closed

fix(cli): support CRLF and UTF-8 BOM in markdown frontmatter#2095
echoVic wants to merge 5 commits intoQwenLM:mainfrom
echoVic:fix/windows-frontmatter-parsing

Conversation

@echoVic
Copy link
Copy Markdown
Contributor

@echoVic echoVic commented Mar 4, 2026

Fixes #2053

On Windows, markdown command files often use CRLF line endings and may have UTF-8 BOM. The previous regex only matched LF line endings, causing frontmatter parsing to fail.

Changes

  • packages/cli/src/services/markdown-command-parser.ts: Added BOM removal and updated regex for CRLF
  • packages/cli/src/services/markdown-command-parser.test.ts: Added Windows test cases

Testing

  • 13 tests pass including 3 new Windows-specific test cases

echoVic added 5 commits March 2, 2026 17:07
…ol args

Fixes QwenLM#2032

The model sometimes adds spaces between Chinese characters and numbers in file paths,
causing file read failures (e.g., '测试 1 文件.txt' instead of '测试1文件.txt').

This fix sanitizes tool arguments by removing such spaces before processing.

Changes:
- Added sanitizeToolArgs() function in turn.ts and subagent.ts
- Applied sanitization to all tool arguments before creating ToolCallRequestInfo
Fixes QwenLM#2004

When users type '@' in large projects, the file crawler scans the entire
project directory which can cause OOM crashes if there are too many files.

This fix adds a maxFiles limit (default 100,000) to the crawler to prevent
memory issues. When the limit is exceeded, a warning is shown and only
the first N files are used.

Changes:
- Added maxFiles option to CrawlOptions interface
- Added file count check and limit in crawl() function
- Shows warning when project has too many files
…mpatibility

Fixes QwenLM#2058

On Windows, files typically use CRLF (\r\n) line endings, but the model may
provide edit strings with CRLF that don't match the normalized file content.

This fix normalizes both old_string and new_string to use LF line endings
before processing, ensuring consistent matching on all platforms.
…tter

Fixes QwenLM#2053

On Windows, markdown command files often use CRLF line endings and may have
UTF-8 BOM. The previous regex only matched LF line endings, causing
frontmatter parsing to fail.

Changes:
- Remove UTF-8 BOM before parsing
- Update regex to support both LF and CRLF line endings
- Add test cases for Windows scenarios

Tested:
- CRLF line endings
- UTF-8 BOM
- Combined CRLF + UTF-8 BOM
Fixes QwenLM#2054

When tools array is empty, the DashScope API returns error about tools being too short.

Changes:
- Filter out empty tools arrays in addDashScopeCacheControl
- Exclude tools from request spread to avoid overriding processed tools
- Only include tools param when array has items

Tested with 43 tests including new cases for empty and non-empty tools.
@tanzhenxin
Copy link
Copy Markdown
Collaborator

@echoVic Thanks for your contribution! This PR has been addressed in #2078 and merged already, close it for now.

@tanzhenxin tanzhenxin closed this Mar 6, 2026
@tanzhenxin tanzhenxin self-assigned this Mar 6, 2026
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.

Windows: Markdown frontmatter not parsed when file uses CRLF or UTF-8 BOM (description not displayed)

2 participants