Repository navigation
fix(frontmatter): preserve malformed skill metadata - #383
Conversation
The new guard is bypassed on the second parseI ran this branch end-to-end with the real CLI ( Root cause
Both matter because Repro 1 — malformed frontmatter, 1 skill → 2 tool dirsTeam repo
Only one warning is printed, so the user believes both copies were left alone. Repro 2 — cache aliasingTwo skills sharing the block Only This one predates the PR (it came in with #378), but it is what defeats the new guard, so it needs fixing here. Suggested fix (verified)- const parsed = matter(raw);
+ const parsed = matter(raw, {}); // any options object disables gray-matter's cache read+write
if (parsed.data === null || typeof parsed.data !== 'object' || Array.isArray(parsed.data)) {
return { data: {}, valid: false, body, raw };
}
- data = parsed.data as Record<string, unknown>;
+ data = { ...(parsed.data as Record<string, unknown>) };Rebuilt and re-ran both scenarios: repro 1 → both copies preserved, one warning each; repro 2 → all 4 deployments correctly completed. It also removes the unbounded Related: the new tests pass only because each fixture block is parsed exactly once per test file — Other findings
Valid frontmatter is still lossy —
Stale comment — Test gaps — the scalar test ( Docs — |
|
Thanks for the detailed repro — confirmed. I pushed a follow-up that addresses all of the reported correctness issues:
I also reran the reported scenarios directly: repeated malformed blocks stay unchanged, identical valid blocks complete independently, and comments/quoting are preserved. Full suite passes: 178 files / 2,494 tests; typecheck passes. |
…ect-validation fix(frontmatter): preserve malformed skill metadata
Fixes the malformed frontmatter regression introduced by #378.
Tests:
npm test -- --run,npm run typecheck