pub fn patch_frontmatter_fields(
skill_md: &str,
fields: &[(&str, &str)],
) -> StringExpand description
Insert or overwrite fields in a SKILL.md frontmatter block.
fields is an ordered list of (key, value) pairs. For each key, any existing
line key: ... in the frontmatter is removed, then all fields are inserted (in
the given order) immediately after the name: line — or at the end of the
frontmatter block if name: is absent. Returns skill_md unchanged if it does
not start with --- or has no closing --- delimiter.
Callers must pass distinct keys — duplicate keys in fields are not
deduplicated and produce duplicate key: value lines in the output.
§Examples
use zeph_common::text::patch_frontmatter_fields;
let md = "---\nname: foo\ndescription: Foo.\n---\n\n# Body\n";
let patched = patch_frontmatter_fields(md, &[("source", "generator"), ("parent_skill", "bar")]);
assert_eq!(
patched,
"---\nname: foo\nsource: generator\nparent_skill: bar\ndescription: Foo.\n---\n\n# Body\n"
);