skills

package
v0.0.202 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildVariables

func BuildVariables(skill *Skill, userInput string, args map[string]string, stdin string) map[string]string

BuildVariables constructs the variable map for substitution.

func ReadStdin

func ReadStdin() string

ReadStdin reads all available stdin if it's being piped.

func RenderBody

func RenderBody(skill *Skill, userInput string, args map[string]string, stdin string) string

RenderBody applies variable substitution to the skill body and handles defaults.

func SkillDirectoryPaths

func SkillDirectoryPaths() []string

SkillDirectoryPaths returns the list of directories that will be scanned for skills. Useful for debugging and the `skills list` command.

func SubstituteVariables

func SubstituteVariables(body string, vars map[string]string) string

SubstituteVariables replaces ${...} placeholders in the skill body. Handles both ${KEY} and ${KEY:-default} forms.

Types

type ExecuteOptions

type ExecuteOptions struct {
	UserInput string            // User-provided input text
	Args      map[string]string // Named argument substitutions
	Stdin     string            // Content from STDIN
	Model     string            // Model override (overrides skill's model)
}

ExecuteOptions holds options for executing a skill.

type ExecuteResult

type ExecuteResult struct {
	RenderedBody string // The skill body after variable substitution
	Model        string // The resolved model to use
}

ExecuteResult holds the result of executing a skill.

func Prepare

func Prepare(skill *Skill, opts ExecuteOptions) (*ExecuteResult, error)

Prepare resolves a skill into its rendered body and model, ready for execution. It does not actually call an LLM - that is handled by the processor.

type Index

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

Index holds a mapping of skill names to their metadata and paths.

func NewIndex

func NewIndex() *Index

NewIndex creates a new empty skill index.

func (*Index) All

func (idx *Index) All() []*Skill

All returns all skills sorted by name.

func (*Index) Count

func (idx *Index) Count() int

Count returns the number of indexed skills.

func (*Index) Get

func (idx *Index) Get(name string) *Skill

Get returns a skill by name, or nil if not found.

func (*Index) Load

func (idx *Index) Load() error

Load scans all skill directories and builds the index. Skills from higher-priority directories override lower-priority ones. Priority order: user (~/.comanda/skills/) > project (.comanda/skills/) > bundled.

type Skill

type Skill struct {
	// Frontmatter fields
	Name          string   `yaml:"name"`
	Description   string   `yaml:"description"`
	WhenToUse     string   `yaml:"when_to_use"`
	Model         string   `yaml:"model"`
	AllowedTools  []string `yaml:"allowed-tools"`
	Arguments     []string `yaml:"arguments"`
	ArgumentHint  string   `yaml:"argument-hint"`
	Version       string   `yaml:"version"`
	Effort        string   `yaml:"effort"`
	Context       string   `yaml:"context"`
	Paths         []string `yaml:"paths"`
	UserInvocable *bool    `yaml:"user-invocable"`

	// Computed fields (not from YAML)
	Body     string `yaml:"-"` // Markdown body after frontmatter
	FilePath string `yaml:"-"` // Absolute path to the skill file
	Source   string `yaml:"-"` // "user", "project", or "bundled"
	Dir      string `yaml:"-"` // Directory containing the skill file
}

Skill represents a parsed skill file with frontmatter and body content.

func LoadSkill

func LoadSkill(path string) (*Skill, error)

LoadSkill reads and parses a skill file from disk.

func ParseSkill

func ParseSkill(content string) (*Skill, error)

ParseSkill parses a skill from its raw content (frontmatter + body).

func (*Skill) DisplayName

func (s *Skill) DisplayName() string

DisplayName returns the skill's display name, falling back to filename.

func (*Skill) IsUserInvocable

func (s *Skill) IsUserInvocable() bool

IsUserInvocable returns whether this skill can be invoked directly by users. Defaults to true if not specified.

Jump to

Keyboard shortcuts

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