MCPcopy Index your code
hub / github.com/cli/cli / parseInstalledSkill

Function parseInstalledSkill

pkg/cmd/skills/list/list.go:397–445  ·  view source on GitHub ↗
(data []byte, name, dir string, agentHostIDs []string, scope string)

Source from the content-addressed store, hash-verified

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

Callers 1

scanInstalledSkillsFunction · 0.70

Calls 10

ParseFunction · 0.92
ParseRepoURLFunction · 0.92
FullNameFunction · 0.92
BuildRepoURLFunction · 0.92
ShortRefFunction · 0.92
hasInstallMetadataFunction · 0.85
skillNameFromSourcePathFunction · 0.85
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65

Tested by

no test coverage detected