skills

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package skills discovers agent skills in git repositories the way the portal backend's /agent-skills endpoint does: every SKILL.md in a GitHub repository is one skill, its frontmatter name and description describe it, and its directory is the kagent spec.skills.gitRefs entry (url + path + ref) an agent mounts. Results are cached per repository for a short time so a meta agent listing skills repeatedly does not exhaust GitHub's rate limit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Repositories are the configured skill repositories (github.com URLs).
	Repositories []string
	// APIURL is the GitHub API base (https://api.github.com; tests override).
	APIURL string
	// Token authenticates GitHub requests (private repositories, higher rate
	// limit); empty is anonymous.
	Token string
	// CacheTTL keeps a repository's result before it is re-read.
	CacheTTL time.Duration
	// HTTPClient overrides the client (tests).
	HTTPClient *http.Client
}

Config tunes the discoverer.

type Discoverer

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

Discoverer reads skills from GitHub with a per-repository cache.

func New

func New(cfg Config, log *slog.Logger) *Discoverer

New builds a discoverer.

func (*Discoverer) List

func (d *Discoverer) List(ctx context.Context, repository, ref string, refresh bool) (*Result, error)

List discovers skills. repository narrows to one repository (configured or not — any github.com URL is accepted); ref overrides the default branch; refresh bypasses the cache.

func (*Discoverer) Repositories

func (d *Discoverer) Repositories() []string

Repositories returns the configured repositories.

type Repository

type Repository struct {
	RepoURL string  `json:"repoUrl"`
	Ref     string  `json:"ref,omitempty"`
	Skills  []Skill `json:"skills"`
	// Truncated is true when GitHub capped the tree or a SKILL.md read failed:
	// some skills may be missing.
	Truncated bool `json:"truncated"`
	// Error is set when the repository could not be read at all.
	Error     string     `json:"error,omitempty"`
	FetchedAt *time.Time `json:"fetchedAt,omitempty"`
}

Repository is the discovery result of one configured repository.

type Result

type Result struct {
	Repositories []Repository `json:"repositories"`
	// Skills flattens every repository's skills (stable order).
	Skills []Skill `json:"skills"`
}

Result is what list_skills returns.

type Skill

type Skill struct {
	// Name is the frontmatter name, else the directory (or repository) name.
	Name string `json:"name"`
	// Description is the frontmatter description ("" when absent).
	Description string `json:"description"`
	// RepoURL is the canonical https://github.com/<owner>/<repo>.
	RepoURL string `json:"repoUrl"`
	// Path is the skill directory; "" at the repository root.
	Path string `json:"path"`
	// Ref is the git ref the skill was read from.
	Ref string `json:"ref"`
}

Skill is one discovered skill, shaped as the portal returns it.

func (Skill) GitRef

func (s Skill) GitRef() map[string]string

GitRef is the skill as a chart skills.gitRefs entry.

Jump to

Keyboard shortcuts

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