Files
Tabish Bidiwale a32bb65d45 feat: add markdown parser CRLF fix proposal and update e2e plan
- Add comprehensive proposal for fixing CRLF parsing issues on Windows
- Update CLI path references from dist/cli.js to dist/cli/index.js
- Streamline e2e testing tasks based on refined approach
2025-09-25 14:40:17 +10:00

1.7 KiB

Update Markdown Parser CRLF Handling

Problem

Windows users report that openspec validate raises “Change must have a Why section” even when the section exists (see GitHub issue #77). The CLI currently splits markdown on \n and compares headers without stripping \r, so files saved with CRLF line endings keep a trailing carriage return in the header token. As a result the parser fails to detect ## Why/## What Changes, triggering false validation errors and breaking the workflow on Windows-default editors.

Solution

  • Normalize markdown content inside the parser so CRLF and lone-CR inputs are treated as \n before section detection, trimming any carriage returns from titles and content comparisons.
  • Reuse the normalized reader everywhere MarkdownParser is constructed to keep behavior consistent for validation, view, spec, and list flows.
  • Add regression coverage that reproduces the failure (unit test around parseChange and a CLI spawn/e2e test that writes a CRLF change then runs openspec validate).
  • Update the cli-validate spec to codify the expectation that required sections are recognized regardless of line-ending style.

Benefits

  • Restores correct validation behavior for Windows editors without requiring manual line-ending conversion.
  • Locks in the fix with targeted tests so future parser refactors keep cross-platform support.
  • Clarifies the spec so downstream work (e.g., cross-shell e2e plan) understands the non-negotiable behavior.

Risks

  • Low: parser normalization touches shared code paths that parse specs and changes; need to ensure no regressions in other command consumers (mitigated by existing parser tests plus the new CRLF fixtures).