Skip to content

fix(skills): match closing frontmatter delimiter on its own line#3739

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/skill-setup-frontmatter-dashes
Open

fix(skills): match closing frontmatter delimiter on its own line#3739
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/skill-setup-frontmatter-dashes

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

SkillsIntegration.setup parses each command template's frontmatter with raw.split("---", 2). A bare substring split stops at the first --- anywhere — including one embedded inside a value. A template whose description contains ---, e.g.

---
description: Separate sections with --- markers
name-marker: sentinel
---
Body of the command.

is mis-parsed three ways:

  • the description is truncated to Separate sections with (or dropped entirely, falling back to the generic Spec Kit: <name> workflow);
  • every frontmatter key after the embedded marker is silently lost;
  • the leftover frontmatter spills into the installed skill body.

Fix

Locate the closing --- on its own line (line-anchored scan) for both the description parse and the body strip, mirroring the hardened CommandRegistrar.parse_frontmatter scan.

  • The frontmatter block is parsed unstripped, so trailing newlines in literal (|) block scalars still survive.
  • The body slice keeps the newline after the marker, so output stays byte-for-byte identical to the old split("---", 2)[2] for well-formed templates (verified with a differential check across normal / empty-body / trailing-space cases).

Tests

Adds TestSkillFrontmatterEmbeddedDashes covering the dashed-description truncation and the frontmatter-spilled-into-body cases. Both fail on the pre-fix code and pass after. Full skills integration suite: 342 passed, 3 skipped, 0 failures.

SkillsIntegration.setup parsed each command template's frontmatter with
raw.split("---", 2). A bare substring split stops at the first `---`
*anywhere*, so a template whose description embeds `---` (e.g.
"Separate sections with --- markers") truncated the parsed frontmatter:
later keys were dropped, the description fell back to the generic default,
and the leftover frontmatter spilled into the skill body.

Scan for the closing `---` on its own line instead, for both the
description parse and the body strip. The frontmatter block is parsed
unstripped so trailing newlines in literal (|) block scalars still survive,
and the body slice keeps the newline after the marker so output stays
byte-for-byte identical to the old split for well-formed templates.

Adds regression tests covering the dashed-description truncation and the
frontmatter-spilled-into-body cases.
@Quratulain-bilal
Quratulain-bilal requested a review from mnriem as a code owner July 25, 2026 07:39
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.

1 participant