fix: normalize CRLF/CR line endings in all file readers#1
Open
ClaytonHunt wants to merge 1 commit intodisler:mainfrom
Open
fix: normalize CRLF/CR line endings in all file readers#1ClaytonHunt wants to merge 1 commit intodisler:mainfrom
ClaytonHunt wants to merge 1 commit intodisler:mainfrom
Conversation
Extensions that read .md agent files, YAML configs, and the
pi-orchestrator prompt use regex patterns and .split('\n') that
silently fail when files contain Windows CRLF or legacy Mac CR
line endings.
Add .replace(/\r\n/g, '\n').replace(/\r/g, '\n') immediately
after every readFileSync call, before any parsing happens.
Files affected and what they read:
- agent-chain.ts : parseAgentFile() .md files, agent-chain.yaml
- agent-team.ts : parseAgentFile() .md files, teams.yaml
- cross-agent.ts : scanCommands() .md files, scanAgents() .md files
- damage-control.ts : damage-control-rules.yaml
- pi-pi.ts : before_agent_start pi-orchestrator.md
- system-select.ts : scanAgents() .md files
Fixes silent breakage for Windows users where agents/teams/rules
fail to load without any error message.
There was a problem hiding this comment.
Pull request overview
Normalizes Windows CRLF/legacy CR line endings to LF immediately after reading agent/config files so existing frontmatter regexes and split("\n") parsing behave consistently across platforms (especially Windows).
Changes:
- Normalize line endings (
\r\n/\r) to\nafterreadFileSyncin each extension that parses agent markdown or YAML. - Apply the normalization at all relevant read sites (agent markdown scans/parsers, and YAML config reads).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/system-select.ts | Normalizes agent .md file contents before frontmatter parsing during directory scan. |
| extensions/pi-pi.ts | Normalizes expert agent .md files and pi-orchestrator.md before frontmatter/template parsing. |
| extensions/damage-control.ts | Normalizes .pi/damage-control-rules.yaml content prior to YAML parsing. |
| extensions/cross-agent.ts | Normalizes discovered command/agent .md content before frontmatter parsing. |
| extensions/agent-team.ts | Normalizes agent .md files and teams.yaml prior to frontmatter/teams parsing. |
| extensions/agent-chain.ts | Normalizes agent .md files and agent-chain.yaml prior to frontmatter/chain parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
All six extensions that read
.mdagent files or YAML configs use regex patterns like/^---\n…\n---\n/and.split("\n")to parse frontmatter and config. On Windows, files often have CRLF line endings — these patterns silently fail, so agents don't load, teams don't activate, and rules don't apply, with no error message to indicate why.Fix
Add
.replace(/\r\n/g, "\n").replace(/\r/g, "\n")immediately after everyreadFileSynccall, before any parsing occurs. This is a no-op for files that already use LF and only activates when CRLF or CR is present.Files changed
agent-chain.tsparseAgentFile(),agent-chain.yamlagent-team.tsparseAgentFile(),teams.yamlcross-agent.tsscanCommands(),scanAgents()damage-control.tsdamage-control-rules.yamlpi-pi.tsbefore_agent_start→pi-orchestrator.mdsystem-select.tsscanAgents()10 one-liner changes across 6 files. Completely non-breaking for all existing LF users.