Documentation
¶
Overview ¶
Package core provides canonical types for AI assistant skill definitions.
Index ¶
- Constants
- Variables
- func AdapterNames() []string
- func Convert(data []byte, from, to string) ([]byte, error)
- func Register(adapter Adapter)
- func WriteCanonicalFile(skill *Skill, path string) error
- func WriteSkillsToDir(skills []*Skill, dir string, adapterName string) error
- type Adapter
- type MarshalError
- type ParseError
- type ReadError
- type Registry
- type Skill
- type WriteError
Constants ¶
const DefaultDirMode fs.FileMode = 0700
DefaultDirMode is the default permission for generated directories.
const DefaultFileMode fs.FileMode = 0600
DefaultFileMode is the default permission for generated files.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global adapter registry.
Functions ¶
func AdapterNames ¶
func AdapterNames() []string
AdapterNames returns adapter names from the default registry.
func WriteCanonicalFile ¶
WriteCanonicalFile writes a canonical skill.json file.
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 ¶
GetAdapter returns an adapter from the default registry.
type MarshalError ¶
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 ¶
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 Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages adapter registration and lookup.
func (*Registry) AdapterNames ¶
AdapterNames returns all registered adapter names sorted alphabetically.
func (*Registry) GetAdapter ¶
GetAdapter returns an adapter by name.
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 ParseSkillMarkdown ¶ added in v0.7.0
ParseSkillMarkdown parses a Markdown file with YAML frontmatter into a Skill.
func ReadCanonicalDir ¶
ReadCanonicalDir reads all skill files from a directory. Supports both: - Subdirectories with skill.json files - Direct .md files with YAML frontmatter
func ReadCanonicalFile ¶
ReadCanonicalFile reads a canonical skill file (JSON or Markdown with YAML frontmatter).
func (*Skill) AddDependency ¶
AddDependency adds a dependency to the skill.
func (*Skill) AddReference ¶
AddReference adds a reference document path to the skill.
func (*Skill) AddTrigger ¶
AddTrigger adds a trigger keyword to the skill.
type WriteError ¶
WriteError occurs when writing a file fails.
func (*WriteError) Error ¶
func (e *WriteError) Error() string
func (*WriteError) Unwrap ¶
func (e *WriteError) Unwrap() error