Component: crates/cli (format.rs) | Severity: Medium | Status: Reproduced
Beyond the quoting corruption (separate issue), format loses content in a committed file:
- A standalone comment directly above an entry is preserved only if the raw entry line matches the regenerated canonical line; any spacing difference (single spaces, tabs) breaks the match and the comment is deleted. Inline comments (
entry … # note) are always deleted.
- Lines with unknown first words - the SPEC's forward-compatibility mechanism ("old parsers warn and skip the line. No breakage") - are silently dropped, and the parse warnings that would have mentioned them are discarded by
cmd_format.
Where: crates/cli/src/commands/format.rs:85-106, :117-121 (comment matching keyed on raw line text), :182-185 (warnings discarded); serializer via :24-31.
Repro:
printf '# IMPORTANT: pinned on purpose\nlocal skill s skills/s.md\nfuturetype skill x extra\n' > Skillfile
skillfile format
cat Skillfile # comment gone (entry was single-spaced), futuretype line gone, no warning
Expected: format is a lossless reordering: comments stay attached to their entry, unknown lines are preserved verbatim (that is the documented compatibility contract), and discarded-anything is at least warned about.
Actual: silent deletion.
Fix sketch: key comment attachment on the PARSED entry identity (source line number) instead of raw text equality; carry unknown lines through to output in original order (e.g. append after the sections, or keep in place); print parse warnings.
Tests: unit in format.rs: single-spaced entry keeps its leading comment; unknown-first-word line survives round-trip; inline comment either preserved or produces a warning (pick contract, then pin it).
Component:
crates/cli(format.rs) | Severity: Medium | Status: ReproducedBeyond the quoting corruption (separate issue),
formatloses content in a committed file:entry … # note) are always deleted.cmd_format.Where:
crates/cli/src/commands/format.rs:85-106,:117-121(comment matching keyed on raw line text),:182-185(warnings discarded); serializer via:24-31.Repro:
Expected: format is a lossless reordering: comments stay attached to their entry, unknown lines are preserved verbatim (that is the documented compatibility contract), and discarded-anything is at least warned about.
Actual: silent deletion.
Fix sketch: key comment attachment on the PARSED entry identity (source line number) instead of raw text equality; carry unknown lines through to output in original order (e.g. append after the sections, or keep in place); print parse warnings.
Tests: unit in
format.rs: single-spaced entry keeps its leading comment; unknown-first-word line survives round-trip; inline comment either preserved or produces a warning (pick contract, then pin it).