skill

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package skill provides skill management for GenCode. Skills are markdown-based prompts that can be invoked via slash commands or proactively by the model when active.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(cwd string) error

Initialize loads all skills and applies persisted states. This should be called at application startup.

Types

type InstalledPluginsData

type InstalledPluginsData struct {
	Version int                        `json:"version"`
	Plugins map[string][]PluginInstall `json:"plugins"`
}

InstalledPluginsData represents the installed_plugins.json structure.

type Loader

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

Loader handles loading skills from multiple directories.

func NewLoader

func NewLoader(cwd string) *Loader

NewLoader creates a new skill loader.

func (*Loader) LoadAll

func (l *Loader) LoadAll() (map[string]*Skill, error)

LoadAll loads all skills from all directories. Higher priority scopes override lower priority ones with the same name.

type PluginInstall

type PluginInstall struct {
	Scope       string `json:"scope"`       // "user" or "project"
	InstallPath string `json:"installPath"` // Full path to plugin
	Version     string `json:"version"`
}

PluginInstall represents a single plugin installation.

type Registry

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

Registry manages loaded skills and their states.

var DefaultRegistry *Registry

DefaultRegistry is the global skill registry instance.

func (*Registry) Count

func (r *Registry) Count() int

Count returns the total number of loaded skills.

func (*Registry) Get

func (r *Registry) Get(name string) (*Skill, bool)

Get returns a skill by name.

func (*Registry) GetActive

func (r *Registry) GetActive() []*Skill

GetActive returns all active skills (model-aware).

func (*Registry) GetAvailableSkillsPrompt

func (r *Registry) GetAvailableSkillsPrompt() string

GetAvailableSkillsPrompt generates the <available_skills> section for the system prompt. Only includes active skills (state = active).

func (*Registry) GetEnabled

func (r *Registry) GetEnabled() []*Skill

GetEnabled returns all enabled or active skills.

func (*Registry) GetSkillInvocationPrompt

func (r *Registry) GetSkillInvocationPrompt(name string) string

GetSkillInvocationPrompt returns the full skill content wrapped in XML for injection. The name should be the full name (namespace:name or just name).

func (*Registry) GetStatesAt

func (r *Registry) GetStatesAt(userLevel bool) map[string]SkillState

GetStatesAt returns skill states from the specified level.

func (*Registry) List

func (r *Registry) List() []*Skill

List returns all skills sorted by full name (namespace:name).

func (*Registry) SetState

func (r *Registry) SetState(name string, state SkillState, userLevel bool) error

SetState sets the state for a skill and persists it to the specified level. The name should be the full name (namespace:name or just name). If userLevel is true, saves to ~/.gen/skills.json, otherwise to .gen/skills.json.

type Skill

type Skill struct {
	// Frontmatter fields (parsed from YAML header)
	Name         string   `yaml:"name"`
	Namespace    string   `yaml:"namespace"` // Optional namespace (e.g., "git", "jira")
	Description  string   `yaml:"description"`
	AllowedTools []string `yaml:"allowed-tools"`
	ArgumentHint string   `yaml:"argument-hint"`

	// Runtime fields
	FilePath     string     // Full path to the skill file
	Scope        SkillScope // Where the skill was loaded from
	Instructions string     // Full markdown content (lazy loaded)
	State        SkillState // Current state (persisted separately)
	// contains filtered or unexported fields
}

Skill represents a loaded skill with metadata and instructions.

func (*Skill) FullName

func (s *Skill) FullName() string

FullName returns the namespaced skill name (namespace:name or just name).

func (*Skill) GetInstructions

func (s *Skill) GetInstructions() string

GetInstructions returns the full skill instructions, loading if needed.

func (*Skill) IsActive

func (s *Skill) IsActive() bool

IsActive returns true if the skill is active (model aware).

func (*Skill) IsEnabled

func (s *Skill) IsEnabled() bool

IsEnabled returns true if the skill is enabled or active.

type SkillScope

type SkillScope int

SkillScope represents where a skill was loaded from. Higher values have higher priority.

const (
	// ScopeClaudeUser is ~/.claude/skills/ (lowest priority, Claude compatibility)
	ScopeClaudeUser SkillScope = iota

	// ScopeUserPlugin is ~/.gen/plugins/*/skills/ (User plugins)
	ScopeUserPlugin

	// ScopeUser is ~/.gen/skills/ (GenCode user level)
	ScopeUser

	// ScopeClaudeProject is .claude/skills/ (Claude project compatibility)
	ScopeClaudeProject

	// ScopeProjectPlugin is .gen/plugins/*/skills/ (Project plugins)
	ScopeProjectPlugin

	// ScopeProject is .gen/skills/ (GenCode project level, highest priority)
	ScopeProject
)

func (SkillScope) String

func (s SkillScope) String() string

String returns the display name for the scope.

type SkillState

type SkillState string

SkillState represents the state of a skill. Three states control visibility and model awareness.

const (
	// StateDisable means the skill is hidden and not available.
	StateDisable SkillState = "disable"

	// StateEnable means the skill is visible as a slash command but the model
	// is not aware of it (user-invoked only).
	StateEnable SkillState = "enable"

	// StateActive means the skill metadata is included in the system prompt
	// and the model can invoke it proactively.
	StateActive SkillState = "active"
)

func (SkillState) Icon

func (s SkillState) Icon() string

StateIcon returns the display icon for the state.

func (SkillState) NextState

func (s SkillState) NextState() SkillState

NextState cycles through states: disable -> enable -> active -> disable.

type Store

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

Store handles persistence of skill states to a skills.json file.

func NewProjectStore

func NewProjectStore(cwd string) (*Store, error)

NewProjectStore creates a store for project-level settings (.gen/skills.json).

func NewStore

func NewStore(path string) (*Store, error)

NewStore creates a new store for skill state persistence at the given path.

func NewUserStore

func NewUserStore() (*Store, error)

NewUserStore creates a store for user-level settings (~/.gen/skills.json).

func (*Store) GetState

func (s *Store) GetState(name string) (SkillState, bool)

GetState returns the persisted state for a skill.

func (*Store) SetState

func (s *Store) SetState(name string, state SkillState) error

SetState sets and persists the state for a skill.

type StoreData

type StoreData struct {
	Skills map[string]SkillState `json:"skills"`
}

StoreData is the JSON structure for skills.json.

Jump to

Keyboard shortcuts

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