skills

package
v0.263.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

skills

What - the Agent Skills capability: discovering SKILL.md folders, searching the remote catalog, and installing or removing skills. Why - skills are instructions the agent loads only when relevant, so they need discovery, precedence and a safe install path rather than a hardcoded prompt. How - skills.go implements the agent's skills port, catalog.go fetches the remote registry index, and infer skills drives both.

How it plugs in

  • Scanning order, highest precedence first: .infer/skills/, then .agents/skills/, then ~/.infer/skills/, then the enabled plugins' skills.
  • infer skills list still discovers skills when the feature is disabled.
  • The agent's prompt builder reads skills through the skills port in internal/agent/domain, and the Skill tool in internal/tools loads a SKILL.md body by name over the same port.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupDynamic

func CleanupDynamic() error

CleanupDynamic removes all dynamically downloaded skills from the temporary skills directory. Called after the session ends.

func ExpandShorthand

func ExpandShorthand(input, repository string) string

ExpandShorthand expands "<skill>" and "<org>/<skill>" into GitHub tree URLs in the configured "<owner>/<repo>" skills repository. The two-segment form swaps only the owner, so a renamed fork stays reachable. Anything else, URLs included, is returned unchanged.

func LoadSkillMetadata

func LoadSkillMetadata(skillDir, dirName string, scope agentdomain.SkillScope, pluginName string) (*agentdomain.Skill, *agentdomain.SkillLoadError)

LoadSkillMetadata reads <skillDir>/SKILL.md, parses frontmatter, validates the fields, and returns the populated agentdomain.Skill. Returns (nil, nil) when the directory has no SKILL.md, (nil, err) when SKILL.md is invalid. pluginName is set only for plugin-scoped skills.

func SeedBuiltins

func SeedBuiltins(destDir string, overwrite bool) error

SeedBuiltins writes each embedded skill under destDir, the user-scope skills directory, mirroring the embedded tree. A file is written only when absent unless overwrite is set, so user edits survive a re-run of `infer init`.

func SkillTreeURL

func SkillTreeURL(repository, skill string) string

SkillTreeURL returns the GitHub tree URL of skill inside the given "<owner>/<repo>" skills repository. It is the single place the skills-repo layout (<ref>/<subdir>/<skill>) is encoded.

func SplitFrontmatter added in v0.214.0

func SplitFrontmatter(data []byte) (string, string, error)

SplitFrontmatter extracts the YAML block delimited by `---` lines at the top of the file, returning the raw YAML block and the Markdown body after it. Shared with the Markdown subagent definitions (.infer/agents/*.md), which have their own frontmatter schema.

func Uninstall

func Uninstall(name, destBase string) (string, error)

Uninstall removes the skill folder named `name` from `destBase`. The name must match the on-disk skill-name regex (lowercase letters, digits and hyphens) so callers can't smuggle in path-traversal payloads like `../`. Returns an error if the folder doesn't exist or isn't a directory.

Types

type CatalogClient

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

CatalogClient fetches skill metadata from the centralized skills registry. It implements progressive discovery: only the index (name + description) is fetched up front. The full skill body is downloaded only on activation.

func NewCatalogClient

func NewCatalogClient(cfg *config.Config) *CatalogClient

NewCatalogClient returns a CatalogClient for the configured skills repository. Both the index and the skill bodies come from that one repo, so agent.skills.repository is the only knob needed to point the CLI at a fork.

func (*CatalogClient) DownloadSkill

func (c *CatalogClient) DownloadSkill(ctx context.Context, name string) (string, error)

DownloadSkill fetches the full skill folder from the catalog and writes it to the dynamic skills directory. Returns the path to the downloaded SKILL.md.

func (*CatalogClient) Index

func (c *CatalogClient) Index(ctx context.Context) []catalogEntry

Index fetches the catalog index (name + description for every published skill) and caches it for the process lifetime. Returns nil on any failure - the catalog is best-effort, never fatal. No body download.

func (*CatalogClient) Lookup

func (c *CatalogClient) Lookup(ctx context.Context, name string) (*catalogEntry, bool)

Lookup queries the catalog index for a skill with the given name. Returns the entry metadata and true on success, or false when the skill is not found.

func (*CatalogClient) Release

func (c *CatalogClient) Release() (release, updated string)

Release returns the catalog's published release version and update timestamp as of the last Index fetch. Both are empty when the catalog has not been fetched or does not publish them. Individual skills carry no version of their own - the catalog is versioned as a whole.

func (*CatalogClient) ResolveInstallURL

func (c *CatalogClient) ResolveInstallURL(ctx context.Context, input string) (string, bool)

ResolveInstallURL maps a bare catalog skill name to the GitHub tree URL in its catalog source. ok is false for inputs that already carry a location, with a "/" or ":", and for names the catalog does not list.

func (*CatalogClient) Search

func (c *CatalogClient) Search(ctx context.Context, query string, limit int) []agentdomain.Skill

Search returns catalog matches for query, best first, capped at limit, and the head of the index for an empty query. Names are fuzzy-matched first, then descriptions by substring, since fuzzy matching prose is meaningless. It runs locally because catalog.json has no server-side query.

type GitHubLocation

type GitHubLocation struct {
	Owner string
	Repo  string
	Ref   string
	Path  string
}

GitHubLocation identifies a directory inside a public GitHub repository, parsed out of a /tree/<ref>/<path> URL.

func ParseGitHubTreeURL

func ParseGitHubTreeURL(rawURL string) (*GitHubLocation, error)

ParseGitHubTreeURL parses https://github.com/<owner>/<repo>/tree/<ref>/<path>. Refs containing "/" are not supported, so pass a tag or a single-segment branch instead.

type Installer

type Installer struct {
	Client     *http.Client
	APIBase    string
	RawBase    string
	Token      string
	Repository string
}

Installer downloads a skill folder from a GitHub repo into a local directory. A Token raises the rate limit and reaches private repos. Repository is the "<owner>/<repo>" shorthand targets resolve against, or config.DefaultSkillsRepository when empty.

func NewInstaller

func NewInstaller(repository string) *Installer

NewInstaller returns an Installer for github.com that resolves shorthand against repository, or config.DefaultSkillsRepository when empty. It authenticates with github.Token when set. Tests point APIBase and RawBase at an httptest.Server.

func (*Installer) DownloadFile added in v0.207.0

func (i *Installer) DownloadFile(ctx context.Context, loc *GitHubLocation, repoPath, outPath string) error

DownloadFile writes the raw content of repoPath at loc.Ref to outPath.

func (*Installer) FetchTree added in v0.207.0

func (i *Installer) FetchTree(ctx context.Context, loc *GitHubLocation) ([]TreeEntry, error)

FetchTree lists every path of the repository at loc.Ref (loc.Path is ignored). A truncated listing is an error so callers never install a partial tree.

func (*Installer) InstallFromGitHub

func (i *Installer) InstallFromGitHub(ctx context.Context, rawURL, destBase string, overwrite bool) (string, error)

InstallFromGitHub downloads the skill folder at rawURL into <destBase>/<last segment>/ and returns its absolute path. Existing folders are rejected unless overwrite is set. The download is staged and validated first, so a failed install leaves an existing skill as it was.

type Service

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

Service discovers SKILL.md files and exposes the parsed metadata. Loading is gated by config.AgentSkillsConfig - when disabled the scan is skipped entirely so there is zero token / IO cost.

func New

func New(cfg *config.Config) *Service

New returns a Service bound to cfg. Call Load to populate the skill list.

func (*Service) CleanupDynamic

func (s *Service) CleanupDynamic(_ context.Context) error

CleanupDynamic removes dynamically downloaded skills from disk. When cleanup is enabled in config, this removes all skills that were fetched from the catalog during this session. No-op when discovery is disabled or cleanup is explicitly turned off.

func (*Service) Discover

func (s *Service) Discover(ctx context.Context, name string) (agentdomain.Skill, bool)

Discover resolves a skill by name, downloading the body of a metadata-only catalog entry. Skills already on disk are returned as-is, so it is the safe replacement for Get when activating. It returns false for unknown names, or catalog-only names while discovery is disabled.

func (*Service) Errors

func (s *Service) Errors() []agentdomain.SkillLoadError

Errors returns a defensive copy of validation failures from the last Load.

func (*Service) Get

func (s *Service) Get(name string) (agentdomain.Skill, bool)

Get returns the loaded skill with the given name. Lookup is exact (names are validated to the lowercase `[a-z0-9-]+` charset at load time).

func (*Service) List

func (s *Service) List() []agentdomain.Skill

List returns a defensive copy of the loaded skills.

func (*Service) Load

func (s *Service) Load(ctx context.Context) error

Load scans both project and user-global skill directories, parses frontmatter, validates each skill, and populates the in-memory list. When skills are disabled in config the call is a no-op and returns nil.

type TreeEntry added in v0.207.0

type TreeEntry struct {
	Path string `json:"path"`
	Type string `json:"type"`
}

TreeEntry is one path in a GitHub git tree listing.

Jump to

Keyboard shortcuts

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