parser

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SkillSourceBuiltin = "builtin"

Variables

This section is empty.

Functions

func GetCodeLanguage

func GetCodeLanguage(filename string) string

GetCodeLanguage determines the programming language from file extension

func IsCodeFile

func IsCodeFile(ext string) bool

IsCodeFile checks if a file extension is a code file

func ParseYAMLFrontmatter

func ParseYAMLFrontmatter(content string) (map[string]interface{}, string, error)

ParseYAMLFrontmatter extracts YAML frontmatter from markdown content Returns the frontmatter map and the remaining content

func ReadSkillFiles

func ReadSkillFiles(skillDir string) (map[string]string, error)

ReadSkillFiles reads all relevant files from a skill directory

Types

type HermesParser

type HermesParser struct{}

HermesParser parses Hermes format skills

func NewHermesParser

func NewHermesParser() *HermesParser

NewHermesParser creates a new Hermes parser

func (*HermesParser) Parse

func (p *HermesParser) Parse(skillDir string) (*HermesSkill, error)

Parse parses a Hermes format skill from a directory

func (*HermesParser) ParseAgentsSkillsIO

func (p *HermesParser) ParseAgentsSkillsIO(skillDir string) (*HermesSkill, error)

ParseAgentsSkillsIO parses skills from agentskills.io format This is similar to Hermes but with slight field differences

func (*HermesParser) ParseFromFiles

func (p *HermesParser) ParseFromFiles(files map[string]string) (*HermesSkill, error)

ParseFromFiles parses skill data from a map of files

type HermesSkill

type HermesSkill struct {
	Name              string
	Description       string
	Version           string
	Author            string
	License           string
	Tags              []string
	Tools             []string
	Category          string
	TriggerConditions []string
	Steps             []string
	Content           string
	CodeFiles         map[string]string // filename -> content
	CodeLanguage      string
	SourcePath        string
	Metadata          map[string]interface{}
}

HermesSkill represents a Hermes format skill

func (*HermesSkill) GetPrimaryCode

func (s *HermesSkill) GetPrimaryCode() (string, string)

GetPrimaryCode returns the primary code file content

func (*HermesSkill) ToSkill

func (s *HermesSkill) ToSkill() *Skill

ToSkill converts HermesSkill to the unified Skill type This allows HermesSkill to be used as an intermediate parsing format

func (*HermesSkill) Validate

func (s *HermesSkill) Validate() error

Validate checks if the skill has all required fields

type OpenClawParser

type OpenClawParser struct{}

OpenClawParser parses OpenClaw format skills

func NewOpenClawParser

func NewOpenClawParser() *OpenClawParser

NewOpenClawParser creates a new OpenClaw parser

func (*OpenClawParser) Parse

func (p *OpenClawParser) Parse(skillDir string) (*OpenClawSkill, error)

Parse parses an OpenClaw format skill from a directory

func (*OpenClawParser) ParseFromFiles

func (p *OpenClawParser) ParseFromFiles(files map[string]string) (*OpenClawSkill, error)

ParseFromFiles parses skill data from a map of files

type OpenClawSkill

type OpenClawSkill struct {
	Name              string
	Description       string
	Version           string
	Author            string
	License           string
	Tags              []string
	Tools             []string
	TriggerConditions []string
	Steps             []string
	Content           string
	CodeFiles         map[string]string // filename -> content
	CodeLanguage      string
	SourcePath        string
}

OpenClawSkill represents an OpenClaw format skill

func (*OpenClawSkill) GetPrimaryCode

func (s *OpenClawSkill) GetPrimaryCode() (string, string)

GetPrimaryCode returns the primary code file content

func (*OpenClawSkill) Validate

func (s *OpenClawSkill) Validate() error

Validate checks if the skill has all required fields

type ParseResult

type ParseResult struct {
	Format         SkillFormat
	Name           string
	Data           map[string]interface{}
	Content        string
	CodeFiles      map[string]string // filename -> content
	RawFrontmatter string
}

ParseResult holds the result of parsing a skill

type Parser

type Parser struct {
	HermesParser   *HermesParser
	OpenClawParser *OpenClawParser
}

Parser is a unified parser that can detect and parse different skill formats

func NewParser

func NewParser() *Parser

NewParser creates a new unified parser

func (*Parser) Parse

func (p *Parser) Parse(skillDir string) (*ParseResult, error)

Parse parses a skill from a directory, auto-detecting the format

type Skill

type Skill struct {
	SkillMeta SkillMeta
	Tools     []string
	Content   string
	Metadata  map[string]interface{}
}

Skill represents a unified skill type

type SkillFormat

type SkillFormat string

SkillFormat represents the format type of a skill

const (
	FormatOpenClaw SkillFormat = "openclaw"
	FormatHermes   SkillFormat = "hermes"
	FormatMagic    SkillFormat = "magic"
	FormatUnknown  SkillFormat = "unknown"
)

func DetectFormat

func DetectFormat(skillDir string) (SkillFormat, error)

DetectFormat detects the skill format from a directory

type SkillMeta

type SkillMeta struct {
	Name        string
	Description string
	Version     string
	Author      string
	License     string
	Tags        []string
	Category    string
	Source      string
}

SkillMeta defines metadata for a skill

Jump to

Keyboard shortcuts

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