parseFrontmatter extracts name and description from a leading YAML frontmatter block delimited by "---" lines. It is intentionally minimal: only flat "key: value" pairs are supported, which covers SKILL.md/AGENT.md.
(content string)
| 219 | // frontmatter block delimited by "---" lines. It is intentionally minimal: |
| 220 | // only flat "key: value" pairs are supported, which covers SKILL.md/AGENT.md. |
| 221 | func parseFrontmatter(content string) (name, description string, ok bool) { |
| 222 | content = strings.ReplaceAll(content, "\r\n", "\n") |
| 223 | if !strings.HasPrefix(content, "---\n") { |
| 224 | return "", "", false |
| 225 | } |
| 226 | end := strings.Index(content[4:], "\n---") |
| 227 | if end < 0 { |
| 228 | return "", "", false |
| 229 | } |
| 230 | block := content[4 : 4+end] |
| 231 | for _, line := range strings.Split(block, "\n") { |
| 232 | key, value, found := strings.Cut(line, ":") |
| 233 | if !found { |
| 234 | continue |
| 235 | } |
| 236 | key = strings.TrimSpace(strings.ToLower(key)) |
| 237 | value = strings.TrimSpace(value) |
| 238 | value = strings.Trim(value, "\"'") |
| 239 | switch key { |
| 240 | case "name": |
| 241 | name = value |
| 242 | case "description": |
| 243 | description = value |
| 244 | } |
| 245 | } |
| 246 | return name, description, true |
| 247 | } |
| 248 | |
| 249 | // parsePluginJSON extracts name/description from a plugin.json manifest. |
| 250 | func parsePluginJSON(path, fallbackName string) (name, description string) { |
no outgoing calls