MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / fetchResourceManifest

Method fetchResourceManifest

internal/metadata/refresh.go:461–488  ·  view source on GitHub ↗

fetchResourceManifest downloads the resource's source repo and reads its manifest, returning both the content and the manifest path relative to the repo root (e.g. "skills/foo/SKILL.md"). The relative path lets callers show users where the content came from. Failures return empty strings so callers

(item Item)

Source from the content-addressed store, hash-verified

459// degrade gracefully: install still creates the directory structure, and the
460// detail view still renders the indexed metadata without the manifest body.
461func (svc *Service) fetchResourceManifest(item Item) (content, manifestRel string) {
462 if item.RepoOwner == "" || item.RepoName == "" || item.ItemPath == "" {
463 return "", ""
464 }
465 dest := filepath.Join(pathutil.CacheDir(), "metadata-install", item.RepoOwner+"-"+item.RepoName)
466 _ = os.RemoveAll(dest)
467 defer os.RemoveAll(dest)
468
469 root, err := svc.fetcher.Fetch(item.RepoOwner, item.RepoName, item.RepoBranch, dest)
470 if err != nil {
471 return "", ""
472 }
473
474 target := filepath.Join(root, filepath.FromSlash(item.ItemPath))
475 info, err := os.Stat(target)
476 if err != nil {
477 return "", ""
478 }
479 manifest := target
480 if info.IsDir() {
481 manifest = filepath.Join(target, defaultManifest(item.Kind))
482 }
483 data, err := os.ReadFile(manifest)
484 if err != nil {
485 return "", ""
486 }
487 return string(data), relPath(root, manifest)
488}
489
490func defaultManifest(kind string) string {
491 switch kind {

Callers 2

DetailMethod · 0.95
fetchResourceContentMethod · 0.95

Calls 5

CacheDirFunction · 0.92
defaultManifestFunction · 0.85
relPathFunction · 0.85
ReadFileMethod · 0.80
FetchMethod · 0.65

Tested by

no test coverage detected