Documentation
¶
Overview ¶
Package skillreg installs skills from registries (spec_skills_013 SK-90..SK-96): a registry is a URL serving a JSON index of skills, each a .zip archive pinned by its SHA-256, as the Castor skills registry or anyone else can serve it. The registries the user added, and the skills installed from them, are kept in ~/.blitz/skill-registries.toml; a registry's token is kept in the system keychain. Installed skills are ordinary skill folders (~/.blitz/skills/<name>, or a project's .agents/skills/<name>), loaded as any other, skills.policy and all.
Index ¶
- Constants
- Variables
- type Entry
- type Found
- type Index
- type Installed
- type Registry
- type Store
- func (s *Store) Add(ctx context.Context, name, rawURL, token string) (*Index, error)
- func (s *Store) HasToken(name string) bool
- func (s *Store) Install(ctx context.Context, ref, projectDir string) (Installed, error)
- func (s *Store) Installed() ([]Installed, error)
- func (s *Store) Registries() ([]Registry, error)
- func (s *Store) Remove(name string) error
- func (s *Store) Search(ctx context.Context, query string) ([]Found, error)
- func (s *Store) Uninstall(name, projectDir string) (Installed, error)
- func (s *Store) Update(ctx context.Context, names ...string) ([]Installed, error)
Constants ¶
const IndexVersion = 1
IndexVersion is the index format this package reads.
Variables ¶
var ( ErrNoRegistry = errors.New("no such registry") ErrNotOffered = errors.New("no registry offers that skill") ErrAmbiguous = errors.New("several registries offer that skill") ErrHash = errors.New("the archive doesn't match the hash the registry gives") ErrNotInstalled = errors.New("not installed from a registry") ErrExists = errors.New("a skill of that name is already there") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version"`
// ArchiveURL is the skill's .zip: absolute, or relative to the index.
ArchiveURL string `json:"archive_url"`
// SHA256 is the archive's hash, hex; an archive that doesn't match is
// refused.
SHA256 string `json:"sha256"`
// CastorID is the skill's id in the Castor registry, when it has one.
CastorID string `json:"castor_id,omitempty"`
}
Entry is a skill a registry offers.
type Index ¶
type Index struct {
Version int `json:"version"`
Name string `json:"name"`
Skills []Entry `json:"skills"`
}
Index is what a registry serves.
type Installed ¶
type Installed struct {
Name string `toml:"name"`
Registry string `toml:"registry"`
Version string `toml:"version"`
SHA256 string `toml:"sha256"`
Dir string `toml:"dir"` // the skill's folder
Time time.Time `toml:"time"`
}
Installed is a skill installed from a registry.
type Store ¶
type Store struct {
// File holds the registries and the install records.
File string
// UserSkills is where a skill for the user goes.
UserSkills string
// Secrets keeps registries' tokens.
Secrets secrets.Store
// Client fetches indexes and archives (default: one with a timeout).
Client *http.Client
}
Store is the user's registries and the skills installed from them.
func (*Store) Add ¶
Add checks the index at rawURL and remembers the registry as name (the index's own name when empty), with token for it (kept in the keychain; "" for none). It replaces a registry of the same name.
func (*Store) Install ¶
Install fetches the skill ref names ("registry/name", or a name one registry offers), checks its archive's hash, and installs it for the user, or in the project at projectDir (.agents/skills) when that isn't "". It replaces a skill it installed before, never one it didn't.
func (*Store) Registries ¶
Registries are those the user added, by name.
func (*Store) Search ¶
Search returns the skills whose name or description has every word of query (all of them for ""), from every registry; a registry that can't be read is reported in err while the others' hits still come back.