core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package core provides canonical types for AI assistant skill definitions.

Index

Constants

View Source
const DefaultDirMode fs.FileMode = 0700

DefaultDirMode is the default permission for generated directories.

View Source
const DefaultFileMode fs.FileMode = 0600

DefaultFileMode is the default permission for generated files.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the global adapter registry.

Functions

func AdapterNames

func AdapterNames() []string

AdapterNames returns adapter names from the default registry.

func Convert

func Convert(data []byte, from, to string) ([]byte, error)

Convert converts using the default registry.

func Register

func Register(adapter Adapter)

Register adds an adapter to the default registry.

func WriteCanonicalFile

func WriteCanonicalFile(skill *Skill, path string) error

WriteCanonicalFile writes a canonical skill.json file.

func WriteSkillsToDir

func WriteSkillsToDir(skills []*Skill, dir string, adapterName string) error

WriteSkillsToDir writes multiple skills to a directory using the specified adapter.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter identifier (e.g., "claude", "codex").
	Name() string

	// SkillFileName returns the skill definition filename (e.g., "SKILL.md").
	SkillFileName() string

	// DefaultDir returns the default directory name for skills.
	DefaultDir() string

	// Parse converts tool-specific bytes to canonical Skill.
	Parse(data []byte) (*Skill, error)

	// Marshal converts canonical Skill to tool-specific bytes.
	Marshal(skill *Skill) ([]byte, error)

	// ReadFile reads from path and returns canonical Skill.
	ReadFile(path string) (*Skill, error)

	// WriteFile writes canonical Skill to path.
	WriteFile(skill *Skill, path string) error

	// WriteSkillDir writes the complete skill directory structure.
	WriteSkillDir(skill *Skill, baseDir string) error
}

Adapter converts between canonical Skill and tool-specific formats.

func GetAdapter

func GetAdapter(name string) (Adapter, bool)

GetAdapter returns an adapter from the default registry.

type MarshalError

type MarshalError struct {
	Format string
	Err    error
}

MarshalError occurs when marshaling to tool-specific format fails.

func (*MarshalError) Error

func (e *MarshalError) Error() string

func (*MarshalError) Unwrap

func (e *MarshalError) Unwrap() error

type ParseError

type ParseError struct {
	Format string
	Path   string
	Err    error
}

ParseError occurs when parsing tool-specific format fails.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type ReadError

type ReadError struct {
	Path string
	Err  error
}

ReadError occurs when reading a file fails.

func (*ReadError) Error

func (e *ReadError) Error() string

func (*ReadError) Unwrap

func (e *ReadError) Unwrap() error

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages adapter registration and lookup.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new adapter registry.

func (*Registry) AdapterNames

func (r *Registry) AdapterNames() []string

AdapterNames returns all registered adapter names sorted alphabetically.

func (*Registry) Convert

func (r *Registry) Convert(data []byte, from, to string) ([]byte, error)

Convert converts skill data from one format to another.

func (*Registry) GetAdapter

func (r *Registry) GetAdapter(name string) (Adapter, bool)

GetAdapter returns an adapter by name.

func (*Registry) Register

func (r *Registry) Register(adapter Adapter)

Register adds an adapter to the registry.

type Skill

type Skill struct {
	// Metadata
	Name        string `json:"name"`
	Description string `json:"description"`

	// Content
	Instructions string `json:"instructions"` // The skill instructions/prompt

	// Resources - paths relative to skill directory
	Scripts    []string `json:"scripts,omitempty"`    // Executable scripts
	References []string `json:"references,omitempty"` // Reference documentation
	Assets     []string `json:"assets,omitempty"`     // Templates, config files

	// Invocation
	Triggers []string `json:"triggers,omitempty"` // Keywords that invoke this skill

	// Dependencies
	Dependencies []string `json:"dependencies,omitempty"` // Required CLI tools
}

Skill represents a canonical skill definition that can be converted to tool-specific formats (Claude, Codex).

func NewSkill

func NewSkill(name, description string) *Skill

NewSkill creates a new Skill with the given name and description.

func ReadCanonicalDir

func ReadCanonicalDir(dir string) ([]*Skill, error)

ReadCanonicalDir reads all skill.json files from subdirectories.

func ReadCanonicalFile

func ReadCanonicalFile(path string) (*Skill, error)

ReadCanonicalFile reads a canonical skill.json file.

func (*Skill) AddAsset

func (s *Skill) AddAsset(path string)

AddAsset adds an asset path to the skill.

func (*Skill) AddDependency

func (s *Skill) AddDependency(dep string)

AddDependency adds a dependency to the skill.

func (*Skill) AddReference

func (s *Skill) AddReference(path string)

AddReference adds a reference document path to the skill.

func (*Skill) AddScript

func (s *Skill) AddScript(path string)

AddScript adds a script path to the skill.

func (*Skill) AddTrigger

func (s *Skill) AddTrigger(keyword string)

AddTrigger adds a trigger keyword to the skill.

type WriteError

type WriteError struct {
	Path string
	Err  error
}

WriteError occurs when writing a file fails.

func (*WriteError) Error

func (e *WriteError) Error() string

func (*WriteError) Unwrap

func (e *WriteError) Unwrap() error

Jump to

Keyboard shortcuts

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