(data []byte, name, dir string, agentHostIDs []string, scope string)
| 389 | } |
| 390 | |
| 391 | func parseInstalledSkill(data []byte, name, dir string, agentHostIDs []string, scope string) (listedSkill, bool) { |
| 392 | s := listedSkill{ |
| 393 | skillName: name, |
| 394 | agentHostIDs: agentHostIDs, |
| 395 | scope: scope, |
| 396 | path: dir, |
| 397 | } |
| 398 | |
| 399 | result, err := frontmatter.Parse(string(data)) |
| 400 | if err != nil { |
| 401 | return s, false |
| 402 | } |
| 403 | |
| 404 | meta := result.Metadata.Meta |
| 405 | if meta == nil { |
| 406 | return s, false |
| 407 | } |
| 408 | installMetadata := hasInstallMetadata(meta) |
| 409 | |
| 410 | if sourcePath, _ := meta["github-path"].(string); sourcePath != "" { |
| 411 | if skillName := skillNameFromSourcePath(sourcePath); skillName != "" { |
| 412 | s.skillName = skillName |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | if repoURL, _ := meta["github-repo"].(string); repoURL != "" { |
| 417 | s.sourceURL = repoURL |
| 418 | s.source = repoURL |
| 419 | if repo, parseErr := source.ParseRepoURL(repoURL); parseErr == nil { |
| 420 | s.source = ghrepo.FullName(repo) |
| 421 | s.sourceURL = source.BuildRepoURL(repo.RepoHost(), repo.RepoOwner(), repo.RepoName()) |
| 422 | } |
| 423 | } else if localPath, _ := meta["local-path"].(string); localPath != "" { |
| 424 | s.sourceURL = localPath |
| 425 | s.source = localPath |
| 426 | } |
| 427 | |
| 428 | if ref, _ := meta["github-ref"].(string); ref != "" { |
| 429 | s.version = discovery.ShortRef(ref) |
| 430 | } |
| 431 | if pinnedRef, _ := meta["github-pinned"].(string); pinnedRef != "" { |
| 432 | s.pinned = true |
| 433 | if s.version == "" { |
| 434 | s.version = pinnedRef |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | return s, installMetadata |
| 439 | } |
| 440 | |
| 441 | func hasInstallMetadata(meta map[string]any) bool { |
| 442 | for _, key := range []string{"github-repo", "github-ref", "github-tree-sha", "github-path", "github-pinned", "local-path"} { |
no test coverage detected