Repository navigation
fix(runtime): parse skill frontmatter as YAML - #59
Merged
Merged
Conversation
Skill frontmatter was scanned line by line, so a `metadata:` map with indented keys failed with `invalid frontmatter line` and the whole skill was dropped from the catalog. Real skill files carry structured metadata, so that silently hid them from the model. - Read frontmatter with serde_norway and keep only the typed `name` and `description` fields; unknown top-level keys are ignored on purpose. - Accept plain multi-line scalars, `|`/`>` blocks, quoted values, trailing comments, CRLF line endings, and a leading byte-order mark. - Normalize name and description in `SkillMetadata::new`, so the stable prefix and the CLI completion list share one single-line invariant instead of depending on the renderer. - Type loader failures as `FrontmatterError` and `SkillLoadWarningReason` instead of `String` messages. - Move frontmatter parsing into `skill/frontmatter.rs` and share `text::collapse_whitespace` with memory canonicalization. Verified with cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
SKILL.mdfrontmatter was scanned line by line, so anymetadata:map with indented keys producedinvalid frontmatter lineand the whole skill was dropped from the catalog with only a load warning. Skills that ship structured metadata were therefore invisible to the model.Real frontmatter that failed before, and now loads:
What changed
serde_norway. The frontmatter block is deserialized into a typed{ name, description }document; unknown top-level keys are ignored on purpose, sometadata,license, or tool-policy sections no longer hide a skill.|/>block scalars with-/+chomping, quoted values, trailing comments, CRLF line endings, and a leading byte-order mark all behave as their authors expect.SkillMetadata::newtrimsname, collapsesdescriptionwhitespace, and rejects control characters or line breaks; the stable prefix and the CLI completion list therefore share the same single-line invariant instead of relying on the renderer.FrontmatterErrorandSkillLoadWarningReasonreplaceStringmessages, andSkillLoadWarning::message()becomesreason()with aDisplayimplementation. The unusedSkillError::RootNotFoundvariant is removed.skill/frontmatter.rs(skill.rs 856 to 727 lines), following the existingcontext.rspluscontext/facade pattern.memory.rsandcontext/projection.rsnow use the sharedtext::collapse_whitespaceinstead of three copies of the samesplit_whitespace().collect().join(" ")conversion.Verification
cargo fmt --all --check- cleancargo clippy --all-targets --all-features -- -D warnings- cleancargo test --all- exit 0, 58 test targetstest result: ok, no failurescargo metadata --format-version 1 --no-deps- exit 0git diff --check- cleanFocused coverage added:
loads_skill_frontmatter_from_roots(nestedmetadata, multi-line description, BOM plus CRLF end to end),skips_invalid_skill_files_with_typed_warnings(four warnings asserted by path and reason),warns_about_duplicate_skill_names,normalizes_description_to_one_line,rejects_multi_line_names, plus parser tests for block scalars, comments, quoted values, and missing or null fields.Notes for review
serde_norway 0.9.42is a direct dependency ofmerry-runtimeonly, and bringsunsafe-libyaml-norway 0.2.15. The lockfile diff adds exactly those two packages with no version drift elsewhere. The workspaceunsafe_code = "forbid"lint still covers Merry's own code only.name: 123are read as text,description:holding a nested map stays a load warning, an empty block (---immediately followed by---) reports a missingname, and multi-document frontmatter is not supported.sample-toolanddemo-skillfiles.