Skip to main content

formatSpecFieldsYaml

@a16njs/models


@a16njs/models / formatSpecFieldsYaml

Function: formatSpecFieldsYaml()

formatSpecFieldsYaml(fields): string

Defined in: agentskills-io.ts:98

Render the optional AgentSkills.io spec fields as YAML frontmatter lines.

The inverse of extractSpecFields, and shared for the same reason: the four spec key names are spelled once, so a reader and a writer can never disagree about what a field is called on disk.

Returns lines ready to append inside an existing frontmatter block (each prefixed with a newline), or '' when the item carries none of the fields. Values are JSON-quoted because JSON string syntax is a subset of YAML's double-quoted scalar style — safe for colons, punctuation, and embedded quotes alike, and already how the plugins quote name and description.

Parameters​

fields​

AgentSkillSpecFields

The spec fields carried by the item being emitted

Returns​

string

YAML lines to append, or '' if there is nothing to write

Example​

formatSpecFieldsYaml({ license: 'MIT' })
// '\nlicense: "MIT"'