Skip to content

frontmatter: readers in internal/utils locate the delimiters under five different rules #449

Closed

Description

@runkids

Problem

internal/utils has several frontmatter readers, each locating the --- delimiters itself, under five different rules. The same SKILL.md can therefore yield a different name, or a different answer to "has frontmatter", depending on the entry point — for example sync (ParseSkillName) versus mcp serve (ParseFrontmatterMap).

Evidence (v0.25.0, aeaea40e)

Function Delimiter rule
ParseSkillName (frontmatter.go:16) TrimSpace == "---"; may be indented, need not be the first line; splits name: by hand, no YAML
extractFrontmatterRaw (:182) TrimSpace, line scan of the file
extractFrontmatterRawFromBytes (:155) byte-slice copy of the above
ParseFrontmatterMap (:218) must be the first line, exactly ---, must be closed
splitFrontmatterAndBody (frontmatter_write.go:102) TrimRight, column 0
ReadSkillBody (:301) HasPrefix(TrimSpace)

ParseFrontmatterList and ParseFrontmatterListFromBytes are whole-body copies. About 20 call sites exist outside the package.

The mcp serve fixes 64898e1, 78857ad, 69f7dfa and 76a49ad all landed on the strict reader; the lenient ones were not updated.

Proposed change

One function that locates frontmatter under an explicit strict or lenient policy, with every Parse* built on it. Add a test asserting that all entry points agree on the same input.

Risks

  • The lenient rules may exist for compatibility with users' existing files; unifying them changes discovery behaviour. This needs a decision before any code change.
  • Low-risk subset: merge only the two extractFrontmatterRaw* and the two ParseFrontmatterList* copies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions