| 119 | } |
| 120 | |
| 121 | fn parse_skill_file(path: &Path) -> Option<SkillInfo> { |
| 122 | let raw = fs::read_to_string(path).ok()?; |
| 123 | let normalized = raw.replace("\r\n", "\n"); |
| 124 | let mut lines = normalized.lines(); |
| 125 | |
| 126 | if lines.next()?.trim() != "---" { |
| 127 | return None; |
| 128 | } |
| 129 | |
| 130 | let mut frontmatter_lines = Vec::new(); |
| 131 | let mut closed = false; |
| 132 | for line in lines.by_ref() { |
| 133 | if line.trim() == "---" { |
| 134 | closed = true; |
| 135 | break; |
| 136 | } |
| 137 | frontmatter_lines.push(line); |
| 138 | } |
| 139 | if !closed { |
| 140 | return None; |
| 141 | } |
| 142 | |
| 143 | let frontmatter = frontmatter_lines.join("\n"); |
| 144 | let content = lines.collect::<Vec<_>>().join("\n"); |
| 145 | let name = parse_frontmatter_value(&frontmatter, "name")?; |
| 146 | let description = parse_frontmatter_value(&frontmatter, "description")?; |
| 147 | |
| 148 | Some(SkillInfo { |
| 149 | name, |
| 150 | description, |
| 151 | content: content.trim().to_string(), |
| 152 | location: path.to_path_buf(), |
| 153 | }) |
| 154 | } |
| 155 | |
| 156 | fn scan_skill_root(root: &Path) -> Vec<SkillInfo> { |
| 157 | if !root.exists() || !root.is_dir() { |