Skip to content

fix: YAML-quote frontmatter description values#96

Open
douglance wants to merge 2 commits intowevm:mainfrom
douglance:fix/yaml-quote-description
Open

fix: YAML-quote frontmatter description values#96
douglance wants to merge 2 commits intowevm:mainfrom
douglance:fix/yaml-quote-description

Conversation

@douglance
Copy link
Copy Markdown

@douglance douglance commented Mar 26, 2026

Summary

  • Frontmatter description was built via string concatenation, which produces invalid YAML when the value contains colon-space sequences (e.g. "Use key: value for precision")
  • Replaced manual string building in Skill.ts with yamlStringify() from the yaml package (already a dependency) — handles all YAML quoting edge cases correctly
  • Replaced naive regex extraction in Cli.ts index.json generation with yamlParse() for correct roundtripping
  • Added regression test for colon-space in descriptions

Before (broken)

description: Search items. Use key: value for precision. Run `app --help` for usage details.

YAML parsers interpret key: value as a nested mapping → parse error.

After (correct)

description: "Search items. Use key: value for precision. Run `app --help` for usage details."

The yaml library quotes only when necessary and handles all edge cases (escaped quotes, special characters, etc.).

Test plan

  • All 815 existing tests pass (no snapshot changes needed — yaml library output matches original for safe values)
  • Added new test: YAML-quotes description containing colon-space

Description values containing colons, backticks, and other YAML-special
characters (e.g. "Run `app ping --help` for usage details.") break
frontmatter parsing when left unquoted. This adds a `yamlQuote()` helper
that wraps the value in double quotes when it contains any character that
needs escaping, and strips quotes when reading the description back in
index.json generation.
The frontmatter description was built via string concatenation, which
produces invalid YAML when the value contains colon-space sequences
(e.g. "Use key: value"). Instead of hand-rolling quoting logic, use the
`yaml` package (already a dependency) to serialize frontmatter and parse
it back in index.json generation. This handles all YAML edge cases
correctly.
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