fastskill_core/validation/
frontmatter.rs1use crate::validation::result::ValidationResult;
4
5pub(crate) fn bounds(content: &str) -> (bool, bool) {
6 let lines: Vec<&str> = content.lines().collect();
7 let has_start = !lines.is_empty() && lines[0].trim().starts_with("---");
8 let has_end = has_start
9 && lines
10 .iter()
11 .enumerate()
12 .skip(1)
13 .any(|(_, line)| line.trim() == "---");
14 (has_start, has_end)
15}
16
17pub(crate) fn validate_content(content: &str, mut result: ValidationResult) -> ValidationResult {
18 let (has_start, has_end) = bounds(content);
19 if !has_start {
20 result = result.with_warning(
21 "yaml_frontmatter",
22 "SKILL.md should start with YAML frontmatter (---)",
23 );
24 } else if !has_end {
25 result = result.with_warning(
26 "yaml_frontmatter",
27 "YAML frontmatter should be properly closed with ---",
28 );
29 }
30 result
31}