parseInstalledSkill parses a SKILL.md file and returns an installedSkill.
(data []byte, name, dir string, host *registry.AgentHost, scope registry.Scope)
| 599 | |
| 600 | // parseInstalledSkill parses a SKILL.md file and returns an installedSkill. |
| 601 | func parseInstalledSkill(data []byte, name, dir string, host *registry.AgentHost, scope registry.Scope) (installedSkill, bool) { |
| 602 | result, err := frontmatter.Parse(string(data)) |
| 603 | if err != nil { |
| 604 | return installedSkill{ |
| 605 | name: name, |
| 606 | dir: dir, |
| 607 | host: host, |
| 608 | scope: scope, |
| 609 | metadataErr: fmt.Errorf("invalid SKILL.md: %w", err), |
| 610 | }, true |
| 611 | } |
| 612 | |
| 613 | s := installedSkill{ |
| 614 | name: name, |
| 615 | dir: dir, |
| 616 | host: host, |
| 617 | scope: scope, |
| 618 | } |
| 619 | |
| 620 | if result.Metadata.Meta != nil { |
| 621 | repoInfo, ok, repoErr := source.ParseMetadataRepo(result.Metadata.Meta) |
| 622 | if repoErr != nil { |
| 623 | s.metadataErr = repoErr |
| 624 | } else if ok { |
| 625 | if err := source.ValidateSupportedHost(repoInfo.RepoHost()); err != nil { |
| 626 | s.metadataErr = err |
| 627 | } else { |
| 628 | s.repoHost = repoInfo.RepoHost() |
| 629 | s.owner = repoInfo.RepoOwner() |
| 630 | s.repo = repoInfo.RepoName() |
| 631 | } |
| 632 | } |
| 633 | s.treeSHA, _ = result.Metadata.Meta["github-tree-sha"].(string) |
| 634 | s.pinned, _ = result.Metadata.Meta["github-pinned"].(string) |
| 635 | s.sourcePath, _ = result.Metadata.Meta["github-path"].(string) |
| 636 | } |
| 637 | |
| 638 | return s, true |
| 639 | } |
| 640 | |
| 641 | // promptForSkillOrigin asks the user for the source repository of a skill |
| 642 | // that has no GitHub metadata. |
no test coverage detected