Repository navigation
fix: build-report reads files with Windows line endings - #15
Open
rafaelgaropaba83-gif wants to merge 1 commit into
Open
rafaelgaropaba83-gif wants to merge 1 commit into
rafaelgaropaba83-gif wants to merge 1 commit into
Conversation
A knowledge base checked out on Windows (git core.autocrlf) or written by Windows tools has CRLF line endings. The rule heading regex in renderRuleFile does not match a line ending in \r, so build-report and pack-kb crash with "object null is not iterable". The ClickUp example fails the same way when the repository is cloned on Windows. read() now normalizes CRLF and lone CR to LF, so every parser in the report sees the same text on every platform. A regression test writes a rule file and a screen file with CRLF and checks the rule card renders.
This branch has not been deployed
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
build-report.mjs(and sopack-kb.mjs) crashes on any knowledge base whose rule files end lines with CRLF:renderRuleFilesplits the file on\nand matches the heading with/^#{2,6}\s+(R-\d{3})\b\s*(.*)$/. On a CRLF file the line ends in\r, which.does not match, so the match returnsnull.CRLF files are the normal case on Windows: Git for Windows checks out with
core.autocrlf=true, and many Windows editors and scripts write CRLF. Reproduced on Windows 11, Node 22.17.0:node skills/reverse-engineering-saas/scripts/build-report.mjs examples/clickupon a fresh Windows clone ofmaincrashes with the error above.pack-kb.Fix
read()inbuild-report.mjsnormalizes\r\nand lone\rto\n, so every parser in the report sees the same text on every platform. One line; no behavior change for LF files.Test
New test
build-report reads files with Windows line endingswrites a rule file and a screen file with CRLF and checks that the rule card renders and that no\rreaches the page. It fails onmainwith the error above and passes with the fix.Full
tests/kb-scripts.test.mjson Windows: 27/27 pass when combined with the path-separator fix from #7 (or #14). Without it, the 10 failures are thecheck-kbpath issue those PRs address, not this change. #12 (Windows CI) would catch both.🤖 Generated with Claude Code