skillfrontmatter

package
v0.17.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package skillfrontmatter parses only the required identity fields from SKILL.md YAML front matter. Additional fields remain opaque so callers can preserve and project their original bytes without imposing provider policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	// Keys lists the non-empty top-level keys in document order, including
	// unknown keys, which are tolerated at parse time.
	Keys []string
	// Name is the "name" field.
	Name Field
	// Description is the "description" field.
	Description Field
}

Document is the structural parse result of SKILL.md YAML front matter.

func Parse

func Parse(content string) (Document, error)

Parse parses SKILL.md YAML front-matter content into a Document. Empty or whitespace-only content yields an empty Document. Structural failures are returned as *Error.

type Error

type Error struct {
	// Kind classifies the failure.
	Kind ErrorKind
	// Detail is a human-readable description of the failure.
	Detail string
	// Key is the offending key name for KindDuplicateKey errors.
	Key string
	// Err is the underlying YAML error, if any.
	Err error
}

Error describes why front matter failed structural parsing.

func (*Error) Error

func (e *Error) Error() string

Error returns the human-readable failure detail.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying YAML error, if any.

type ErrorKind

type ErrorKind int

ErrorKind classifies a structural front-matter parse failure so consumers can wrap it in their own message conventions.

const (
	// KindSyntax reports YAML that could not be parsed at all.
	KindSyntax ErrorKind = iota + 1
	// KindType reports a structural or type violation: a non-mapping root,
	// a non-string scalar field, or a malformed metadata map.
	KindType
	// KindDuplicateKey reports a duplicate top-level or metadata key.
	KindDuplicateKey
)

type Field

type Field struct {
	// State reports whether the field was absent, null, or carried a value.
	State FieldState
	// Value is the raw string value; meaningful only when State is FieldValue.
	Value string
	// Multiline reports whether the value used a literal or folded block
	// scalar style. Consumers apply their own policy to this evidence.
	Multiline bool
}

Field is the structural parse result for one supported scalar field.

type FieldState

type FieldState int

FieldState reports whether a supported scalar field appeared in the front matter and, if so, whether it carried a value.

const (
	// FieldAbsent means the key did not appear in the front matter.
	FieldAbsent FieldState = iota
	// FieldNull means the key appeared with an explicit or implicit null value.
	FieldNull
	// FieldValue means the key appeared with a string value.
	FieldValue
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL