MCPcopy
hub / github.com/cli/cli / Serialize

Function Serialize

internal/skills/frontmatter/frontmatter.go:130–149  ·  view source on GitHub ↗

Serialize writes a frontmatter map and body back to a SKILL.md string.

(frontmatter map[string]interface{}, body string)

Source from the content-addressed store, hash-verified

128
129// Serialize writes a frontmatter map and body back to a SKILL.md string.
130func Serialize(frontmatter map[string]interface{}, body string) (string, error) {
131 var buf bytes.Buffer
132
133 yamlBytes, err := yaml.Marshal(frontmatter)
134 if err != nil {
135 return "", fmt.Errorf("failed to serialize frontmatter: %w", err)
136 }
137
138 buf.WriteString(delimiter + "\n")
139 buf.Write(yamlBytes)
140 buf.WriteString(delimiter + "\n")
141 if body != "" {
142 buf.WriteString(body)
143 if !strings.HasSuffix(body, "\n") {
144 buf.WriteString("\n")
145 }
146 }
147
148 return buf.String(), nil
149}

Callers 4

stripGitHubMetadataFunction · 0.92
InjectGitHubMetadataFunction · 0.85
InjectLocalMetadataFunction · 0.85
TestSerializeFunction · 0.85

Calls 3

ErrorfMethod · 0.65
WriteMethod · 0.65
StringMethod · 0.45

Tested by 1

TestSerializeFunction · 0.68