Repository navigation
fix(ui): parse YAML block scalars in frontmatter - #1101
Conversation
Folded (>) and literal (|) values were stored as the bare indicator (e.g. ">-") with their body dropped, so multi-line skill descriptions rendered empty in the plan/annotate viewer.
|
Reviewed this today. Nice work, it held up against everything we threw at it: block scalars at the end of frontmatter, body lines containing colons or leading dashes, empty scalars, arrays following a scalar, the unsupported explicit-indent form falling back to old behavior instead of misparsing, and the realistic SKILL.md shape that motivated the fix. One gap: CRLF sources. The body lines were collected raw, so a file with Windows line endings left a literal carriage return embedded mid-value ("one two\r three"). Every other path in this parser trims lines before use, so this would have been the first place a \r could survive into parsed data. Since it was a two-line change I pushed it directly to your branch (maintainer edits were enabled) along with a regression test, to save a round trip: f0b8764. With that, this is ready. It will go out in the next release. Thanks for the contribution and the well-tested PR. |
Problem
extractFrontmatter(packages/ui/utils/parser.ts) is a line-basedkey: valueparser with no support for YAML block scalars. When a value is a folded (>) or literal (|) scalar, the parser stores the bare indicator as the value and silently drops the indented body.A document with:
parses to
description === ">-", so the description renders empty (just>-) in the plan/annotate viewer. This shows up in the wild because agent skillSKILL.mdfiles routinely fold their longdescriptionfield with>-.Fix
When the value after the colon matches a block-scalar indicator (
|/>with optional+/-chomping), consume the following lines indented deeper than the key as the value:>(folded) — adjacent non-empty lines join with a space; a run of N blank lines folds to N newlines|(literal) — newlines preservedExtracted three small private helpers (
indentWidth,dedentLines,foldScalarLines) plusparseBlockScalarto keepextractFrontmatterreadable. Plain single-line values and-arrays are unchanged.Obviously this isn't a comprehensive YAML extractor though so this just patches over this (one) issue (for now)
Tests
Added an
extractFrontmatter — block scalarssuite covering folded>-, folded>with a paragraph break, literal|, "doesn't swallow the next key", and a plain-value/array regression.bun test packages/ui/utils/parser.test.ts→ 126 pass, 0 failtsc --noEmit -p packages/ui/tsconfig.json→ cleanNo
node:imports added (keeps@plannotator/corebrowser-safe). UI bundle rebuild left to the maintainer.