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 ¶
- func Initialize(cwd string) error
- type InstalledPluginsData
- type Loader
- type PluginInstall
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) FindByPartialName(name string) *Skill
- func (r *Registry) Get(name string) (*Skill, bool)
- func (r *Registry) GetActive() []*Skill
- func (r *Registry) GetAvailableSkillsPrompt() string
- func (r *Registry) GetEnabled() []*Skill
- func (r *Registry) GetSkillInvocationPrompt(name string) string
- func (r *Registry) GetStatesAt(userLevel bool) map[string]SkillState
- func (r *Registry) List() []*Skill
- func (r *Registry) SetState(name string, state SkillState, userLevel bool) error
- type Skill
- func (s *Skill) FullName() string
- func (s *Skill) GetAssetPath(name string) string
- func (s *Skill) GetInstructions() string
- func (s *Skill) GetReferencePath(name string) string
- func (s *Skill) GetScriptPath(name string) string
- func (s *Skill) HasResources() bool
- func (s *Skill) IsActive() bool
- func (s *Skill) IsEnabled() bool
- type SkillScope
- type SkillState
- type Store
- type StoreData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
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.
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) FindByPartialName ¶ added in v1.2.0
FindByPartialName finds a skill by partial name match. It tries exact match first, then checks if name is a suffix (e.g., "commit" matches "git:commit").
func (*Registry) GetAvailableSkillsPrompt ¶
GetAvailableSkillsPrompt generates the available skills section for the system prompt. Only includes active skills (state = active). Uses progressive loading: only name + description are included here. Full instructions are loaded when the Skill tool is invoked. Returns content wrapped in <available-skills> XML tags for consistency.
func (*Registry) GetEnabled ¶
GetEnabled returns all enabled or active skills.
func (*Registry) GetSkillInvocationPrompt ¶
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) 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
SkillDir string // Directory containing the skill
Scope SkillScope // Where the skill was loaded from
Instructions string // Full markdown content (lazy loaded)
State SkillState // Current state (persisted separately)
// Resource directories (Agent Skills spec)
Scripts []string // Files in scripts/ directory
References []string // Files in references/ directory
Assets []string // Files in assets/ directory
// contains filtered or unexported fields
}
Skill represents a loaded skill with metadata and instructions.
func (*Skill) GetAssetPath ¶ added in v1.2.0
GetAssetPath returns the full path to an asset file.
func (*Skill) GetInstructions ¶
GetInstructions returns the full skill instructions, loading if needed.
func (*Skill) GetReferencePath ¶ added in v1.2.0
GetReferencePath returns the full path to a reference file.
func (*Skill) GetScriptPath ¶ added in v1.2.0
GetScriptPath returns the full path to a script file.
func (*Skill) HasResources ¶ added in v1.2.0
HasResources returns true if the skill has any bundled resources.
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 ¶
NewProjectStore creates a store for project-level settings (.gen/skills.json).
func NewUserStore ¶
NewUserStore creates a store for user-level settings (~/.gen/skills.json).
type StoreData ¶
type StoreData struct {
Skills map[string]SkillState `json:"skills"`
}
StoreData is the JSON structure for skills.json.