11//! Parser for the `SKILL.md` frontmatter subset used by plugin and managed
2- //! skills.
2+ //! skills: fenced `key: value` scalars plus indented block values .
33
44use std:: collections:: BTreeMap ;
55
66use crate :: errors:: { Result , TraceDecayError } ;
77
8- /// One frontmatter value.
8+ /// One parsed frontmatter value.
99#[ derive( Debug , Clone , PartialEq , Eq ) ]
1010pub enum SkillFrontmatterValue {
11- /// Inline scalar with outer quotes stripped.
11+ /// Inline scalar with one level of YAML quotes stripped.
1212 Scalar ( String ) ,
1313 /// Trimmed block lines under a key with no inline value.
1414 Block ( Vec < String > ) ,
@@ -22,7 +22,7 @@ impl SkillFrontmatterValue {
2222 }
2323 }
2424
25- /// Returns unquoted `- item` block entries .
25+ /// Returns unquoted `- item` entries when every block line is a list item .
2626 pub fn as_list_items ( & self ) -> Option < Vec < String > > {
2727 match self {
2828 Self :: Scalar ( _) => None ,
@@ -42,7 +42,7 @@ impl SkillFrontmatterValue {
4242 }
4343}
4444
45- /// Parses the leading `---`-fenced frontmatter of a `SKILL.md` document .
45+ /// Parses leading `---`-fenced frontmatter, normalizing LF and CRLF input .
4646pub fn parse_skill_frontmatter ( contents : & str ) -> Result < BTreeMap < String , SkillFrontmatterValue > > {
4747 let mut lines = contents. lines ( ) ;
4848 if lines. next ( ) . map ( str:: trim_end) != Some ( "---" ) {
@@ -106,7 +106,7 @@ pub fn parse_skill_frontmatter(contents: &str) -> Result<BTreeMap<String, SkillF
106106 Ok ( fields)
107107}
108108
109- /// Strips one level of YAML quoting.
109+ /// Strips one level of YAML quoting, including YAML `''` single-quote escaping .
110110fn unquote_scalar ( value : & str ) -> String {
111111 if let Some ( inner) = value. strip_prefix ( '\'' ) . and_then ( |v| v. strip_suffix ( '\'' ) ) {
112112 inner. replace ( "''" , "'" )
0 commit comments