skill

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 16 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.

Documentation

Overview

Package skill renders and installs the agent skill embedded in the binary (skills/ytrack), stamped with the binary's version so an installed skill always describes the ytrack that installed it.

Index

Constants

View Source
const (
	StateCurrent = "current" // holds the skill at the running version
	StateStale   = "stale"   // holds the skill at another version
	StateMissing = "missing" // holds no ytrack skill (deleted or replaced)
)

Copy states.

View Source
const (
	SyncUpdated = "updated" // rewritten at the version
	SyncDropped = "dropped" // missing or replaced by something else; forgotten
	SyncManual  = "manual"  // a repository copy; left as it is
	SyncFailed  = "failed"  // could not be rewritten; still recorded
)

Sync outcomes.

View Source
const EntryFile = "SKILL.md"

EntryFile is the skill's entry point inside its directory.

View Source
const Name = "ytrack"

Name is the skill's name: its directory and its frontmatter name.

Variables

View Source
var ErrBusy = errors.New("another install is updating this skill directory")

ErrBusy reports that InstallNoWait found another install working on the directory and left it alone.

Functions

func DefaultDirs added in v0.6.0

func DefaultDirs() ([]string, error)

DefaultDirs returns the directories `ytrack skill install` writes without --dir: ~/.agents/skills, which Codex, Cursor, OpenCode and Pi read, and ~/.claude/skills, which Claude Code reads.

func Files

func Files() fs.FS

Files returns the embedded skill directory: SKILL.md and references/.

func HomeDirs added in v0.6.0

func HomeDirs() ([]string, error)

HomeDirs returns the home-level skills directories of the agents ytrack knows, in adoption order: ~/.agents/skills first, as `npx skills add` keeps its canonical copy there and links the others to it.

func Install

func Install(root, version string) (string, error)

Install writes the skill, stamped with version, to <root>/ytrack and returns that directory. root is created when missing. An existing <root>/ytrack is replaced only when its SKILL.md has "name: ytrack"; anything else there is refused with a *ForeignError and left untouched. A symlinked <root>/ytrack (as `npx skills add` makes) is followed and its target updated.

The new copy is written to a temporary sibling directory and renamed into place, so a failed install leaves the earlier skill as it was. Installs racing on one directory (two ytrack processes refreshing the same copy) all succeed and leave one complete copy and no temporary directories.

func InstallNoWait added in v0.6.0

func InstallNoWait(root, version string) (string, error)

InstallNoWait is Install for the background refresh, which must never delay a command: when another install holds the directory it returns ErrBusy at once and changes nothing.

func Lock added in v0.6.0

func Lock(wait time.Duration) (unlock func(), ok bool)

Lock takes the registry lock, waiting up to wait for another process to release it. It reports false at once when the lock cannot be made at all.

func Managed added in v0.6.0

func Managed(dir string) bool

Managed reports whether ytrack keeps the copy in skills directory dir at its own version: dir is one of HomeDirs, or under the home directory and not inside a git work tree. A copy in a repository is the repository's: it changes only through ytrack skill install --dir.

func RegistryPath added in v0.6.0

func RegistryPath() (string, error)

RegistryPath returns the registry file's path.

func Render

func Render(version string) ([]byte, error)

Render returns SKILL.md with metadata.version set to version.

func TryLock added in v0.6.0

func TryLock() (unlock func(), ok bool)

TryLock takes the registry lock without waiting. It reports false when another process holds it or the lock cannot be made (a read-only state directory); the caller then skips its work.

func Uninstall added in v0.6.0

func Uninstall(root string) (bool, error)

Uninstall removes <root>/ytrack: the symlink itself when it is one, else the directory, which must hold the ytrack skill; anything else there is refused with a *ForeignError and left untouched. It reports whether there was anything to remove.

Types

type Copy added in v0.6.0

type Copy struct {
	Dir     string // the skills directory
	Path    string // Dir/ytrack
	Version string // metadata.version of its SKILL.md; empty when missing
	State   string // StateCurrent, StateStale or StateMissing
	// Managed reports whether ytrack keeps the copy at its version (see
	// Managed); a copy in a repository is updated by hand.
	Managed bool
}

Copy is a recorded skill copy as found on disk.

func Inspect added in v0.6.0

func Inspect(dir, version string) Copy

Inspect returns the copy in the recorded directory dir, compared with version.

type ForeignError

type ForeignError struct{ Dir string }

ForeignError reports a skill directory that Install will not replace because it does not hold the ytrack skill.

func (*ForeignError) Error

func (e *ForeignError) Error() string

type Meta

type Meta struct {
	Name        string            `yaml:"name"`
	Description string            `yaml:"description"`
	Metadata    map[string]string `yaml:"metadata"`
}

Meta is the SKILL.md frontmatter.

func ParseMeta

func ParseMeta(b []byte) (Meta, error)

ParseMeta reads the frontmatter of a SKILL.md.

type Registry added in v0.6.0

type Registry struct {
	// Synced is the version of the last sync that rewrote every copy.
	Synced string `yaml:"synced,omitempty"`
	// Dirs are absolute skills directories; each holds <dir>/ytrack.
	Dirs []string `yaml:"dirs"`
	// contains filtered or unexported fields
}

Registry is the list of skills directories holding a copy of the skill that ytrack installed or adopted, and the version every copy it keeps up to date was last synced to.

func OpenRegistry added in v0.6.0

func OpenRegistry() (*Registry, error)

OpenRegistry reads the registry. While the file does not exist yet, the registry adopts every home-level directory (HomeDirs) that holds the ytrack skill already, never one holding anything else, stamped Synced with the newest version among them; Save then creates the file.

func (*Registry) Clone added in v0.6.0

func (r *Registry) Clone() *Registry

Clone returns a copy of r for a later Equal.

func (*Registry) Copies added in v0.6.0

func (r *Registry) Copies(version string) []Copy

Copies inspects every recorded copy.

func (*Registry) Dirty added in v0.6.0

func (r *Registry) Dirty() bool

Dirty reports whether the registry holds anything its file does not: copies adopted while the file did not exist yet.

func (*Registry) Equal added in v0.6.0

func (r *Registry) Equal(o *Registry) bool

Equal reports whether two registries record the same thing.

func (*Registry) Forget added in v0.6.0

func (r *Registry) Forget(dir string) bool

Forget removes dir, made absolute, and reports whether it was recorded.

func (*Registry) Record added in v0.6.0

func (r *Registry) Record(dir string) bool

Record adds the skills directory dir, made absolute, and reports whether the registry changed. Directories whose ytrack copy is the same one (one copy symlinked into several directories, as `npx skills add` does) are recorded once; the directory holding the copy itself is preferred over one holding a link to it.

func (*Registry) Save added in v0.6.0

func (r *Registry) Save() error

Save writes the registry: to a temporary file renamed into place, so a concurrent reader sees the old file or the new one, never a torn one.

func (*Registry) Sync added in v0.6.0

func (r *Registry) Sync(version string) ([]SyncResult, bool)

Sync rewrites every managed copy at version and forgets every recorded directory whose copy is gone or holds something else: a missing copy is never re-created. Copies in repositories are left alone. When every managed copy was rewritten, Synced becomes version. It reports what it did per directory, and whether it all succeeded. The caller saves the registry.

func (*Registry) SyncNoWait added in v0.6.0

func (r *Registry) SyncNoWait(version string) ([]SyncResult, bool)

SyncNoWait is Sync for the background refresh: a copy another install is updating is skipped (SyncFailed with ErrBusy, so Synced stays and the next run retries) instead of waited for.

type SyncResult added in v0.6.0

type SyncResult struct {
	Copy
	Action string
	Err    error
}

SyncResult is what Sync did with one recorded directory.

Jump to

Keyboard shortcuts

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