use serde_yaml::{Mapping, Value};
pub const PLATFORM_OWNED_SKILL_KEYS: [&str; 7] = [
"name",
"title",
"description",
"tags",
"category",
"display_category",
"hosts",
];
pub fn is_platform_owned_skill_key(key: &Value) -> bool {
key.as_str()
.is_some_and(|key| PLATFORM_OWNED_SKILL_KEYS.contains(&key))
}
pub fn render_passthrough_frontmatter(
frontmatter: Option<&Mapping>,
) -> Result<String, serde_yaml::Error> {
let Some(frontmatter) = frontmatter else {
return Ok(String::new());
};
let kept: Mapping = frontmatter
.iter()
.filter(|(key, _)| !is_platform_owned_skill_key(key))
.map(|(key, value)| (key.clone(), value.clone()))
.collect();
if kept.is_empty() {
return Ok(String::new());
}
serde_yaml::to_string(&kept)
}