InjectGitHubMetadata adds GitHub tracking metadata to the spec-defined "metadata" map in frontmatter. Keys are prefixed with "github-" to avoid collisions with other tools' metadata. pinnedRef is the user's explicit --pin value; empty string means unpinned. skillPath is the skill's source path in th
(content string, host, owner, repo, ref, treeSHA, pinnedRef, skillPath string)
| 68 | // pinnedRef is the user's explicit --pin value; empty string means unpinned. |
| 69 | // skillPath is the skill's source path in the repo (e.g. "skills/author/my-skill"). |
| 70 | func InjectGitHubMetadata(content string, host, owner, repo, ref, treeSHA, pinnedRef, skillPath string) (string, error) { |
| 71 | result, err := Parse(content) |
| 72 | if err != nil { |
| 73 | return "", err |
| 74 | } |
| 75 | |
| 76 | if result.RawYAML == nil { |
| 77 | result.RawYAML = make(map[string]interface{}) |
| 78 | } |
| 79 | |
| 80 | meta, _ := result.RawYAML["metadata"].(map[string]interface{}) |
| 81 | if meta == nil { |
| 82 | meta = make(map[string]interface{}) |
| 83 | } |
| 84 | delete(meta, "github-owner") |
| 85 | meta["github-repo"] = source.BuildRepoURL(host, owner, repo) |
| 86 | meta["github-ref"] = ref |
| 87 | delete(meta, "github-sha") |
| 88 | meta["github-tree-sha"] = treeSHA |
| 89 | meta["github-path"] = skillPath |
| 90 | if pinnedRef != "" { |
| 91 | meta["github-pinned"] = pinnedRef |
| 92 | } else { |
| 93 | delete(meta, "github-pinned") |
| 94 | } |
| 95 | result.RawYAML["metadata"] = meta |
| 96 | |
| 97 | return Serialize(result.RawYAML, result.Body) |
| 98 | } |
| 99 | |
| 100 | // InjectLocalMetadata adds local-source tracking metadata to frontmatter. |
| 101 | // sourcePath is the absolute path to the source skill directory. |