Skip to content

fix(windows): resolve silent failures caused by CRLF line endings (#1868) - #1890

Merged
DennisYu07 merged 4 commits into
QwenLM:mainfrom
Aayushyaash:fix/windows-crlf-parsing
Mar 6, 2026
Merged

DennisYu07 merged 4 commits into
QwenLM:mainfrom
Aayushyaash:fix/windows-crlf-parsing

Conversation

@Aayushyaash

Copy link
Copy Markdown
Contributor

TLDR

Fixes a critical bug on Windows where subagents, skills, and Claude-converted plugins were silently ignored due to CRLF (\r\n) line endings. Standardizes text normalization across all core managers.

Crucially, this fix also resolves issues where agents downloaded from the Claude marketplace (e.g., via qwen extensions install) were not being detected after installation inside Windows.

Dive Deeper

The root cause was that several key parsers used strict regex patterns expecting only \n newlines, causing files saved with CRLF (common in Windows editors like Notepad or VS Code or any other external editor with CRLF enabled) to fail to load silently.

Solution: Unified Normalization Layer

Moved from a fragmented approach with duplicate logic and unprotected entry points to a unified, "Normalize-First" architecture. Inspired from original Skill Manager & Skill Load pre-normalization solution.

Logic Flow: Before vs After

┌─────────────────────────────────────────────────────────────────────────────┐
│                         BEFORE THE FIX (Original Code)                      │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  1. subagent-manager.ts (BROKEN - NO NORMALIZATION)                         │
│     read file → content.match(frontmatterRegex) → parseYaml                 │
│                                    ↓                                        │
│                            ❌ FAILS ON WINDOWS                              │
│                                                                             │
│  2. skill-manager.ts / skill-load.ts (DUPLICATE CODE)                       │
│     read file → normalizeSkillFileContent() → regex → parseYaml             │
│              └─────────── duplicated logic ──────────────┘                  │
│                                                                             │
│  3. claude-converter.ts (BROKEN - NO NORMALIZATION)                         │
│     read file → content.match(frontmatterRegex) → parseYaml                 │
│                                    ↓                                        │
│                            ❌ FAILS ON WINDOWS                              │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│                          AFTER THE FIX (Current Code)                       │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  NEW: textUtils.ts - Centralized normalizeContent()                         │
│       └── strips UTF-8 BOM, converts \r\n → \n, converts \r → \n            │
│                                                                             │
│  1. subagent-manager.ts                                                     │
│     read file → normalizeContent() → regex → parseYaml ✅                   │
│                                                                             │
│  2. skill-manager.ts / skill-load.ts                                        │
│     read file → normalizeContent() → regex → parseYaml ✅                   │
│              └──────── removed duplicates ─────────┘                        │
│                                                                             │
│  3. claude-converter.ts                                                     │
│     read file → normalizeContent() → regex → parseYaml ✅                   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Changes Made:

  • Global Utility: Added normalizeContent in packages/core/src/utils/textUtils.ts (strips BOM, converts CRLF/CR to LF).
  • Subagent Manager: Integrated normalization in parseSubagentContent (subagent-manager.ts).
  • Skill Manager & Skill Load: Replaced redundant local logic with the global utility for better maintainability.
  • Claude Converter: Fixed agent file extraction and standardized test folder naming (src-agents) to avoid resource collection conflicts.
  • Tests: Added CRLF integration tests in subagent-manager.test.ts, textUtils.test.ts, and claude-converter.test.ts.

Reviewer Test Plan

  1. Verify Subagent Loading: Create a subagent on Windows using an external editor (Notepad), save it, and ensure it is detected by qwen-code.
  2. Verify Skill Loading: Verify that skills authored with CRLF continue to load correctly.
  3. Verify Claude Conversion: Run the new test case should successfully convert agent files with Windows CRLF endings.
  4. Automated Tests: Run npm run test to ensure no regressions in the 3680+ existing tests.

Testing Matrix

🍏 🪟 🐧
npm run - ✅ -
npx - ✅ -

Tested on Windows 11.

Visual Proof

Before Fix: Marketplace agents missing on Windows

image

After Fix: Marketplace agents successfully detected

image

Linked issues / bugs

Fixes #1868

…rsing

# Conflicts:
#	packages/core/src/utils/textUtils.test.ts
#	packages/core/src/utils/textUtils.ts
@Aayushyaash

Copy link
Copy Markdown
Contributor Author

Hi! I noticed that #2078 was recently merged, which addresses a similar CRLF issue for markdown commands. I've just updated this PR with main to resolve the resulting merge conflicts. This PR provides the comprehensive, centralized normalizeContent fix that covers Subagents, Skills, and the Claude-converter as well, ensuring we don't hit this issue in other areas on Windows.

@DennisYu07
DennisYu07 merged commit 88e5c4a into QwenLM:main Mar 6, 2026
13 checks passed
@Aayushyaash
Aayushyaash deleted the fix/windows-crlf-parsing branch March 9, 2026 10:03
xaelistic pushed a commit to xaelistic/qwen-code that referenced this pull request Jun 7, 2026
fix(windows): resolve silent failures caused by CRLF line endings (QwenLM#1868)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Sub-agents created outside qwen-code /agent create are not detected on Windows

4 participants