Skip to content

fix: normalize CRLF/CR line endings in all file readers#1

Open
ClaytonHunt wants to merge 1 commit intodisler:mainfrom
ClaytonHunt:fix/normalize-line-endings
Open

fix: normalize CRLF/CR line endings in all file readers#1
ClaytonHunt wants to merge 1 commit intodisler:mainfrom
ClaytonHunt:fix/normalize-line-endings

Conversation

@ClaytonHunt
Copy link
Copy Markdown

Problem

All six extensions that read .md agent 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 every readFileSync call, 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

File Read site
agent-chain.ts parseAgentFile(), agent-chain.yaml
agent-team.ts parseAgentFile(), teams.yaml
cross-agent.ts scanCommands(), scanAgents()
damage-control.ts damage-control-rules.yaml
pi-pi.ts before_agent_startpi-orchestrator.md
system-select.ts scanAgents()

10 one-liner changes across 6 files. Completely non-breaking for all existing LF users.

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.
Copilot AI review requested due to automatic review settings February 23, 2026 16:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 \n after readFileSync in 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.

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.

3 participants