Documentation
¶
Overview ¶
Package skills implements discovery of Agent Skills. A skill is a folder containing a SKILL.md whose YAML frontmatter (name, description) is parsed at startup; the body is read lazily by the model via the Read tool.
The on-disk format intentionally matches the contract shared by the standard, so a folder authored for any of them drops in unchanged.
Index ¶
- func ExpandShorthand(input string) string
- func LoadSkillMetadata(skillDir, dirName string, scope domain.SkillScope, pluginName string) (*domain.Skill, *domain.SkillLoadError)
- func SeedBuiltins(destDir string, overwrite bool) error
- func Uninstall(name, destBase string) (string, error)
- type GitHubLocation
- type Installer
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandShorthand ¶ added in v0.109.1
ExpandShorthand turns shorthand install targets into full GitHub tree URLs. Accepted forms:
- "<skill>" → https://github.com/inference-gateway/skills/tree/main/skills/<skill>
- "<org>/<skill>" → https://github.com/<org>/skills/tree/main/skills/<skill>
- any http(s):// URL → returned unchanged
Anything else (3+ slash-separated segments, empty segments, etc.) is returned unchanged so ParseGitHubTreeURL produces its existing error.
func LoadSkillMetadata ¶ added in v0.134.0
func LoadSkillMetadata(skillDir, dirName string, scope domain.SkillScope, pluginName string) (*domain.Skill, *domain.SkillLoadError)
LoadSkillMetadata reads <skillDir>/SKILL.md, parses frontmatter, validates the fields, and returns the populated domain.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 ¶ added in v0.144.0
SeedBuiltins writes each embedded built-in skill under destDir, mirroring the embedded tree (destDir/<name>/SKILL.md, plus any helper files). A file is written only when it is absent, unless overwrite is set - so a user's edits to a seeded skill survive a re-run of `infer init` (seed-if-absent). destDir is the user-scope skills directory (~/.infer/skills), the same directory the loader reads user skills from.
func Uninstall ¶
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 GitHubLocation ¶
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 accepts URLs of the form
https://github.com/<owner>/<repo>/tree/<ref>/<path-to-skill>
Refs containing a literal "/" (e.g. "feature/foo" branches) are not supported; pass the URL of a tag or single-segment branch instead.
type Installer ¶
Installer downloads a skill folder from a GitHub repo into a local destination directory. When Token is non-empty its requests are authenticated, which raises the GitHub API rate limit from 60 to 5,000 requests/hour and allows access to private repositories the token can see.
func NewInstaller ¶
func NewInstaller() *Installer
NewInstaller returns an Installer pointed at github.com with a 30s HTTP timeout. The GitHub token is read from the environment (GITHUB_TOKEN, then GH_TOKEN); when neither is set requests are made unauthenticated. Tests substitute APIBase / RawBase to point at httptest.Server.
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>/<dirname>/, where dirname is the last path segment of the repo URL. Existing folders are rejected unless overwrite is true.
The downloaded folder is post-validated with LoadSkillMetadata - if frontmatter fails the spec checks, the folder is removed and the validation error is returned. There is never a half-installed state.
Returns the absolute path of the installed skill on success.
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 (*Service) Errors ¶
func (s *Service) Errors() []domain.SkillLoadError
Errors returns a defensive copy of validation failures from the last Load.
func (*Service) Get ¶ added in v0.117.0
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).