skill

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentLockfileVersion = 1

Variables

View Source
var ErrProjectNotFound = errors.New("no skills.json found in current directory or any parent")

Functions

func SaveLockfile

func SaveLockfile(path string, l *Lockfile) error

func SaveManifest

func SaveManifest(path string, m *Manifest) error

SaveManifest writes the manifest to path with indented JSON. The output is human-edited file material, so prettiness matters.

Types

type AddOptions

type AddOptions struct {
	AdditionalBasePaths []string
}

type Adder

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

func NewAdder

func NewAdder(r Registry, i *Installer, p *Project) *Adder

func (*Adder) Add

func (a *Adder) Add(ctx context.Context, ref string, opts AddOptions) (LockEntry, error)

Add adds a skill to the project, installs it, and persists both files. The ref must include a tag (e.g. ghcr.io/.../skill:1.0.0).

type CachedCollection

type CachedCollection struct {
	Ref       string    `json:"ref"`
	FetchedAt time.Time `json:"fetchedAt"`
	Index     oci.Index `json:"index"`
}

CachedCollection persists a fetched collection index for offline name lookup.

type CollectionInstaller added in v0.4.0

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

CollectionInstaller registers a collection on a project and installs every skill the collection index lists.

func NewCollectionInstaller added in v0.4.0

func NewCollectionInstaller(r Registry, a *Adder, p *Project) *CollectionInstaller

func (*CollectionInstaller) InstallAll added in v0.4.0

func (c *CollectionInstaller) InstallAll(ctx context.Context, alias, ref string) ([]LockEntry, error)

InstallAll fetches the collection index at ref, registers the collection on the project under alias (caching the index for later name lookups), and installs every skill the index lists. The index is fetched before skills.json is touched, so a bad ref leaves the project unchanged.

type CollectionPublisher

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

CollectionPublisher resolves each spec entry to a digest, builds an OCI Image Index, and pushes it to the registry.

func NewCollectionPublisher

func NewCollectionPublisher(r Registry) *CollectionPublisher

func (*CollectionPublisher) Publish

func (p *CollectionPublisher) Publish(
	ctx context.Context,
	spec *CollectionSpec,
	collectionRef string,
	force bool,
) (oci.Descriptor, error)

type CollectionSpec

type CollectionSpec struct {
	Name        string      `yaml:"name"`
	Description string      `yaml:"description"`
	License     string      `yaml:"license,omitempty"`
	Source      string      `yaml:"source,omitempty"`
	Skills      []SpecSkill `yaml:"skills"`
}

CollectionSpec is the YAML shape consumed by `intropy skills collection publish`.

type Extractor

type Extractor interface {
	Extract(ctx context.Context, layer io.Reader, dests []string) error
}

Extractor unpacks a skill's tar+gzip content layer to one or more destination directories. Implementations must:

  • reject path traversal via ".." in archive entries
  • reject symlinks
  • preserve POSIX permissions on regular files
  • create parent directories as needed

func NewTarGzExtractor

func NewTarGzExtractor() Extractor

type Installer

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

func NewInstaller

func NewInstaller(r Registry, e Extractor, p *Project) *Installer

func (*Installer) Install

func (i *Installer) Install(ctx context.Context, entry ManifestEntry) (LockEntry, error)

Install pulls a single skill, extracts it, and returns the lockfile entry that should be recorded. The caller is responsible for persisting the lockfile.

func (*Installer) Sync

func (i *Installer) Sync(ctx context.Context) error

Sync installs every skill declared in the manifest and writes the lockfile. On error mid-way, any partially-completed installs remain on disk and the lockfile is not updated.

type LockEntry

type LockEntry struct {
	Name            string     `json:"name"`
	Path            string     `json:"path"`
	AdditionalPaths []string   `json:"additionalPaths,omitempty"`
	Source          LockSource `json:"source"`
	InstalledAt     time.Time  `json:"installedAt"`
}

LockEntry is one resolved skill in the lockfile.

type LockSource

type LockSource struct {
	Registry   string `json:"registry"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
	Digest     string `json:"digest"`
	Ref        string `json:"ref"`
}

type Lockfile

type Lockfile struct {
	LockfileVersion int         `json:"lockfileVersion"`
	GeneratedAt     time.Time   `json:"generatedAt"`
	Skills          []LockEntry `json:"skills"`
}

Lockfile is the root of skills.lock.json (§7.3).

func LoadLockfile

func LoadLockfile(path string) (*Lockfile, error)

type Manifest

type Manifest struct {
	Collections []ManifestCollection `json:"collections,omitempty"`
	Skills      []ManifestEntry      `json:"skills"`
}

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads and parses skills.json from path.

func (*Manifest) Validate

func (m *Manifest) Validate() error

type ManifestCollection

type ManifestCollection struct {
	Name string `json:"name"`
	Ref  string `json:"ref"`
}

type ManifestEntry

type ManifestEntry struct {
	Name                string   `json:"name"`
	Source              string   `json:"source"`
	Version             string   `json:"version,omitempty"`
	AdditionalBasePaths []string `json:"additionalBasePaths,omitempty"`
}

§6.3

type Project

type Project struct {
	Root string
}

func FindProject

func FindProject(startDir string) (*Project, error)

FindProject walks up from startDir looking for skills.json. Returns ErrProjectNotFound if no manifest is found before reaching the filesystem root.

func (*Project) AdditionalDirs

func (p *Project) AdditionalDirs(entry ManifestEntry) []string

AdditionalDirs returns the absolute paths from a manifest entry's additionalBasePaths, with skill name appended to each. Returns an empty slice if the entry has no additionalBasePaths.

func (*Project) AdditionalRelPaths

func (p *Project) AdditionalRelPaths(entry ManifestEntry) []string

func (*Project) CollectionCacheDir

func (p *Project) CollectionCacheDir() string

CollectionCacheDir returns the directory where collection caches are stored.

func (*Project) CollectionCachePath

func (p *Project) CollectionCachePath(name string) string

CollectionCachePath returns the cache file path for a named collection.

func (*Project) LoadCollectionCache

func (p *Project) LoadCollectionCache(name string) (*CachedCollection, error)

LoadCollectionCache reads and parses the cache file for a collection alias. Returns an os.ErrNotExist-wrapping error if the cache hasn't been fetched yet.

func (*Project) LoadLockfile

func (p *Project) LoadLockfile() (*Lockfile, error)

LoadLockfile reads and parses skills.lock.json from the project root. Returns an empty lockfile (not an error) if the file doesn't exist yet.

func (*Project) LoadManifest

func (p *Project) LoadManifest() (*Manifest, error)

LoadManifest reads and parses skills.json from the project root.

func (*Project) LockfilePath

func (p *Project) LockfilePath() string

LockfilePath returns the absolute path to skills.lock.json.

func (*Project) ManifestPath

func (p *Project) ManifestPath() string

ManifestPath returns the absolute path to skills.json.

func (*Project) SaveCollectionCache

func (p *Project) SaveCollectionCache(name string, c *CachedCollection) error

SaveCollectionCache persists the cache file for a collection alias, creating the cache directory if needed.

func (*Project) SaveLockfile

func (p *Project) SaveLockfile(l *Lockfile) error

SaveLockfile writes the lockfile to skills.lock.json at the project root.

func (*Project) SaveManifest

func (p *Project) SaveManifest(m *Manifest) error

SaveManifest writes the manifest to skills.json at the project root.

func (*Project) SkillDir

func (p *Project) SkillDir(name string) string

SkillDir returns the canonical install directory for a named skill: <root>/.agents/skills/<name>.

func (*Project) SkillRelPath

func (p *Project) SkillRelPath(name string) string

SkillRelPath returns the install directory relative to the project root, in forward-slash form. This is the value to write to the lockfile.

func (*Project) SkillsDir

func (p *Project) SkillsDir() string

SkillsDir returns the canonical install directory: <root>/.agents/skills. Per §9 of the spec.

type Registry

type Registry interface {
	Pull(ctx context.Context, ref string) (oci.Artifact, error)
	PullIndex(ctx context.Context, ref string) (oci.Index, error)
	Resolve(ctx context.Context, ref string) (oci.Descriptor, error)
	Push(ctx context.Context, ref string, art oci.Artifact) (oci.Descriptor, error)
	PushIndex(ctx context.Context, ref string, idx oci.Index) (oci.Descriptor, error)
}

type SkillResolution

type SkillResolution struct {
	Collection string
	Entry      oci.IndexEntry
}

SkillResolution is the result of looking up a skill name across registered collections.

func ResolveSkillName

func ResolveSkillName(p *Project, name, collectionAlias string) (SkillResolution, error)

ResolveSkillName searches every registered collection's cache for a skill matching name. If collectionAlias is non-empty, only that collection is considered. Returns an error if zero or multiple matches are found.

type SpecSkill

type SpecSkill struct {
	Ref string `yaml:"ref"`
}

type UpdateResult

type UpdateResult struct {
	Name       string
	OldVersion string
	NewVersion string
	Changed    bool
}

UpdateResult describes the outcome of a single skill update.

type Updater

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

func NewUpdater

func NewUpdater(r Registry, i *Installer, p *Project) *Updater

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, name string) (UpdateResult, error)

Update reconciles a single installed skill against the ref pinned by the registered collections' cached indexes. If the resolved ref matches the manifest entry already, returns Changed=false and leaves disk untouched. Otherwise pulls the new content, replaces .agents/skills/<name>, and rewrites skills.json and skills.lock.json.

Refresh the relevant collection first (via `intropy skills collection update`) if you want to pick up changes the registry has since published.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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