Skip to content

fix: parseAnatomy tolerates CRLF line endings (fixes #50)#51

Open
albertomenache wants to merge 1 commit into
cytostack:mainfrom
albertomenache:fix/parse-anatomy-crlf
Open

fix: parseAnatomy tolerates CRLF line endings (fixes #50)#51
albertomenache wants to merge 1 commit into
cytostack:mainfrom
albertomenache:fix/parse-anatomy-crlf

Conversation

@albertomenache

Copy link
Copy Markdown

Fixes #50.

parseAnatomy split on plain "\n", so with CRLF line endings (e.g. git core.autocrlf=true rewriting .wolf/anatomy.md on checkout — a common Windows default) every entry line ends in \r and the $-anchored entry regex matches nothing. The post-write hook's parse→rewrite cycle then drops every entry, truncating anatomy.md to an empty skeleton ("Files: 1 tracked", sections kept, entries gone).

This PR changes the split to /\r?\n/ in both parseAnatomy copies (src/hooks/shared.ts and src/scanner/anatomy-scanner.ts). serializeAnatomy already writes LF, so one pass renormalizes a poisoned file; no other behavior changes.

Verified against the live failure: with the patched parser, driving the post-write hook on a CRLF-converted anatomy.md preserves 161/161 entries (pre-patch it collapsed to 1). Full repro steps in #50.

With CRLF endings (e.g. git core.autocrlf=true rewriting .wolf/anatomy.md
on checkout), every entry line ends in \r and the $-anchored entry regex
matches nothing, so the post-write hook's parse-then-rewrite cycle drops
every entry and truncates anatomy.md to an empty skeleton. Split on
/\r?\n/ in both parseAnatomy copies; serializeAnatomy already writes LF,
so one pass renormalizes a poisoned file.
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.

parseAnatomy drops every entry on CRLF line endings - post-write hook then truncates anatomy.md to an empty skeleton (Windows + git autocrlf)

1 participant