Parse a markdown file as a command definition. Extracts YAML frontmatter and body content.
(path: &Path, base_dir: &Path)
| 707 | /// Parse a markdown file as a command definition. |
| 708 | /// Extracts YAML frontmatter and body content. |
| 709 | fn parse_markdown_command(path: &Path, base_dir: &Path) -> Option<(String, CommandConfig)> { |
| 710 | let content = fs::read_to_string(path).ok()?; |
| 711 | let (frontmatter, body) = split_frontmatter(&content); |
| 712 | |
| 713 | // Derive name from relative path |
| 714 | let name = derive_name_from_path(path, base_dir, &["command", "commands"]); |
| 715 | |
| 716 | let mut config = if let Some(fm) = frontmatter { |
| 717 | serde_json::from_value::<CommandConfig>(serde_yaml_frontmatter_to_json(&fm)) |
| 718 | .unwrap_or_default() |
| 719 | } else { |
| 720 | CommandConfig::default() |
| 721 | }; |
| 722 | |
| 723 | config.template = Some(body.trim().to_string()); |
| 724 | |
| 725 | Some((name, config)) |
| 726 | } |
| 727 | |
| 728 | /// Parse a markdown file as an agent definition. |
| 729 | fn parse_markdown_agent(path: &Path, base_dir: &Path) -> Option<(String, AgentConfig)> { |