skill

package
v0.0.0-...-4b2b8ef Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkillFileName        = "SKILL.md"
	MaxNameLength        = 64
	MaxDescriptionLength = 1024
	MinDescriptionLength = 1
)

Variables

View Source
var (
	ErrMissingName        = errors.New("skill name is required")
	ErrMissingDescription = errors.New("skill description is required")
	ErrNameTooLong        = fmt.Errorf("skill name must not exceed %d characters", MaxNameLength)
	ErrDescriptionTooLong = fmt.Errorf("skill description must not exceed %d characters", MaxDescriptionLength)
	ErrInvalidNameFormat  = errors.New("skill name must be lowercase alphanumeric with hyphens only")
	ErrNameMismatch       = errors.New("skill name must match directory name")
	ErrNoFrontmatter      = errors.New("SKILL.md must contain YAML frontmatter delimited by ---")
)

Functions

This section is empty.

Types

type Discoverer

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

func NewDiscoverer

func NewDiscoverer(fs afero.Fs, userInfo shared.UserInfo) *Discoverer

func (*Discoverer) Discover

func (d *Discoverer) Discover(cwd string) ([]*Skill, error)

type DiscoveryPath

type DiscoveryPath struct {
	Pattern    string
	Scope      SkillScope
	IsRelative bool
}

func DefaultDiscoveryPaths

func DefaultDiscoveryPaths(userInfo shared.UserInfo) []DiscoveryPath

type GitProvider

type GitProvider string

GitProvider identifies the git hosting service.

const (
	GitProviderGitHub GitProvider = "github"
	GitProviderGitLab GitProvider = "gitlab"
)

type GitSource

type GitSource struct {
	Provider GitProvider `json:"provider"`
	CloneURL string      `json:"clone_url"`
	Path     string      `json:"path"`
	Ref      string      `json:"ref"`
	TreeHash string      `json:"tree_hash"`
}

GitSource represents a skill installed from a git repository.

type InstallOptions

type InstallOptions struct {
	Force      bool     // Overwrite existing skills
	SkillNames []string // Install only specific skill(s), empty means all
}

InstallOptions configures the installation behavior.

type InstalledSkill

type InstalledSkill struct {
	*Skill
	InstalledAt time.Time
	UpdatedAt   time.Time
	Git         *GitSource
	URL         *URLSource
}

InstalledSkill represents a skill with its installation metadata.

type LockEntry

type LockEntry struct {
	InstalledAt time.Time  `json:"installed_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
	Git         *GitSource `json:"git,omitempty"`
	URL         *URLSource `json:"url,omitempty"`
}

LockEntry represents a single skill entry in the lock file.

func (*LockEntry) IsLocal

func (e *LockEntry) IsLocal() bool

IsLocal returns true if the skill was manually installed (no remote source).

type LockFile

type LockFile struct {
	Version int                   `json:"version"`
	Skills  map[string]*LockEntry `json:"skills"`
}

LockFile represents the skills.lock.json file.

type Parser

type Parser struct{}

func NewParser

func NewParser() *Parser

func (*Parser) Parse

func (p *Parser) Parse(content []byte, location string) (*Skill, error)

func (*Parser) Validate

func (p *Parser) Validate(skill *Skill, dirPath string) error

type Skill

type Skill struct {
	Name        string     `yaml:"name"`
	Description string     `yaml:"description"`
	Location    string     `yaml:"-"`
	Scope       SkillScope `yaml:"-"`
}

type SkillManager

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

SkillManager handles skill installation, deletion, and updates.

func NewSkillManager

func NewSkillManager(fs afero.Fs, userInfo shared.UserInfo) *SkillManager

func (*SkillManager) Delete

func (i *SkillManager) Delete(name string) error

Delete removes an installed skill.

func (*SkillManager) Install

func (i *SkillManager) Install(ctx context.Context, source *Source, opts InstallOptions) ([]*InstalledSkill, error)

Install installs skills from the given source.

func (*SkillManager) List

func (i *SkillManager) List() ([]*InstalledSkill, error)

List returns all installed skills.

func (*SkillManager) Update

func (i *SkillManager) Update(ctx context.Context, name string) ([]*InstalledSkill, error)

Update updates installed skills to their latest versions.

type SkillScope

type SkillScope string
const (
	SkillScopeRepo   SkillScope = "repo"
	SkillScopeUser   SkillScope = "user"
	SkillScopeSystem SkillScope = "system"
)

type Source

type Source struct {
	Provider GitProvider
	CloneURL string
	Path     string // path within repo
	Ref      string // branch/tag, default "main"

	DirectURL string // direct URL to SKILL.md
}

Source is the parsed user input (used during install).

func ParseSource

func ParseSource(source string) (*Source, error)

ParseSource parses a source string into a SourceInfo. Supported formats: - owner/repo (GitHub shorthand) - owner/repo/path (GitHub shorthand with path) - github.com/owner/repo/tree/branch/path - gitlab.com/owner/repo/-/tree/branch/path - Direct URL ending in /SKILL.md

func (*Source) IsGit

func (s *Source) IsGit() bool

IsGit returns true if the source is a git repository.

func (*Source) IsURL

func (s *Source) IsURL() bool

IsURL returns true if the source is a direct URL.

type URLSource

type URLSource struct {
	URL string `json:"url"`
}

URLSource represents a skill installed from a direct URL.

Jump to

Keyboard shortcuts

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