skill

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSkillEntrySize is the maximum size of a single tar entry in a skill layer.
	MaxSkillEntrySize = 10 * 1024 * 1024 // 10 MB
	// MaxSkillLayerSize is the maximum total size of all entries in a skill layer.
	MaxSkillLayerSize = 10 * 1024 * 1024 // 10 MB
)

Variables

This section is empty.

Functions

func DeriveSkillName

func DeriveSkillName(frontmatterName string, prompt artifact.Prompt, modelRef *registry.Reference) string

DeriveSkillName determines the skill directory name from a prompt entry and optional SKILL.md frontmatter name.

Priority:

  1. frontmatterName (from SKILL.md frontmatter "name" field)
  2. prompt.Name (from Kitfile)
  3. Parent directory name (for SKILL.md files or directory prompts)
  4. Fallback: repository name from modelRef

func DetectInstalledAgents

func DetectInstalledAgents() ([]string, error)

DetectInstalledAgents probes global config directories to find installed agents. Always checks global paths regardless of installation scope. Returns a sorted list of detected agent names. Agents with no detection probe (replit, universal) are silently skipped.

func GetGlobalSkillsDir

func GetGlobalSkillsDir(agentName string) (string, error)

GetGlobalSkillsDir returns the absolute global skills directory for the given agent.

func GetProjectSkillsDir

func GetProjectSkillsDir(agentName, projectDir string) (string, error)

GetProjectSkillsDir returns the absolute skills directory for the given agent within a project directory.

func IsValidAgentName

func IsValidAgentName(name string) bool

IsValidAgentName returns true if the name is a known agent.

func ValidAgentNames

func ValidAgentNames() []string

ValidAgentNames returns a sorted list of all valid agent names.

Types

type AgentConfig

type AgentConfig struct {
	Name             string
	DisplayName      string
	SkillsDir        string          // project-relative skills path (e.g., ".claude/skills")
	GlobalDetectDirs func() []string // returns dirs to probe for detection; first existing dir wins
	GlobalSkillsDir  func() string   // computes absolute global skills path
}

AgentConfig defines the directory layout and detection logic for a coding agent.

func GetAgentConfig

func GetAgentConfig(name string) (AgentConfig, error)

GetAgentConfig returns the configuration for the named agent.

type AgentInstallResult

type AgentInstallResult struct {
	Agent   string
	Path    string // resolved absolute path
	Skipped bool   // true if skipped due to IgnoreExisting or path dedup
	Err     error
}

AgentInstallResult records the outcome for a single agent.

type InstallResult

type InstallResult struct {
	SkillName string
	Prompt    artifact.Prompt
	Agents    []AgentInstallResult
}

InstallResult records the outcome of installing one skill across all agents.

func InstallSkill

func InstallSkill(entries []TarEntry, skillName string, prompt artifact.Prompt, opts *SkillInstallOptions) InstallResult

InstallSkill writes the buffered tar entries as a skill to each agent's skill directory. Does NOT fail-fast: attempts every agent, returns per-agent results.

func (InstallResult) Errors

func (r InstallResult) Errors() []AgentInstallResult

Errors returns all agent-level errors.

func (InstallResult) HasErrors

func (r InstallResult) HasErrors() bool

HasErrors returns true if any agent installation failed.

type SkillFrontmatter

type SkillFrontmatter struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	License     string `yaml:"license,omitempty"`
}

SkillFrontmatter represents the YAML frontmatter in a SKILL.md file.

func ParseSkillFrontmatter

func ParseSkillFrontmatter(data []byte) *SkillFrontmatter

ParseSkillFrontmatter extracts and parses YAML frontmatter from SKILL.md content. Returns nil if no valid frontmatter is found.

type SkillInstallOptions

type SkillInstallOptions struct {
	Agents         []string
	ProjectDir     string // if non-empty, install project-scoped; if empty, install globally
	Overwrite      bool
	IgnoreExisting bool
	ModelRef       *registry.Reference
}

SkillInstallOptions configures how skills are installed.

type TarEntry

type TarEntry struct {
	Header  *tar.Header
	Content []byte
}

TarEntry holds a single file from a tar archive.

func ReadSkillLayer

func ReadSkillLayer(tr *tar.Reader) (entries []TarEntry, isSkill bool, frontmatterName string, err error)

ReadSkillLayer reads all entries from a tar reader, buffers them, and determines whether the layer contains a SKILL.md file. Returns the buffered entries, whether it qualifies as a skill, and the frontmatter "name" if present.

Enforces that there are no symlinks/hardlinks and the size limits. The tar.Reader is fully consumed by this call.

Jump to

Keyboard shortcuts

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