Documentation
¶
Index ¶
- func IsGitHubURL(rawURL string) bool
- func RenderSkillMD(entry *SkillEntry) ([]byte, error)
- type Executor
- type FileSkillStore
- func (s *FileSkillStore) Activate(ctx context.Context, name string) error
- func (s *FileSkillStore) Delete(_ context.Context, name string) error
- func (s *FileSkillStore) EnsureDefaults(defaultFS fs.FS) error
- func (s *FileSkillStore) Get(_ context.Context, name string) (*SkillEntry, error)
- func (s *FileSkillStore) ListActive(_ context.Context) ([]SkillEntry, error)
- func (s *FileSkillStore) Save(_ context.Context, entry SkillEntry) error
- func (s *FileSkillStore) SaveResource(_ context.Context, skillName, relPath string, data []byte) error
- type GitHubRef
- type ImportConfig
- type ImportResult
- type Importer
- func (im *Importer) DiscoverSkills(ctx context.Context, ref *GitHubRef) ([]string, error)
- func (im *Importer) FetchFromURL(ctx context.Context, rawURL string) ([]byte, error)
- func (im *Importer) FetchSkillMD(ctx context.Context, ref *GitHubRef, skillName string) ([]byte, error)
- func (im *Importer) ImportFromRepo(ctx context.Context, ref *GitHubRef, store SkillStore, cfg ImportConfig) (*ImportResult, error)
- func (im *Importer) ImportSingle(ctx context.Context, raw []byte, sourceURL string, store SkillStore) (*SkillEntry, error)
- func (im *Importer) ImportSingleWithResources(ctx context.Context, ref *GitHubRef, skillName string, store SkillStore) (*SkillEntry, error)
- type Registry
- func (r *Registry) ActivateSkill(ctx context.Context, name string) error
- func (r *Registry) AllTools() []*agent.Tool
- func (r *Registry) CreateSkill(ctx context.Context, entry SkillEntry) error
- func (r *Registry) GetSkillTool(name string) (*agent.Tool, bool)
- func (r *Registry) ListActiveSkills(ctx context.Context) ([]SkillEntry, error)
- func (r *Registry) LoadSkills(ctx context.Context) error
- func (r *Registry) LoadedSkills() []*agent.Tool
- func (r *Registry) Store() SkillStore
- type SkillEntry
- func BuildCompositeSkill(name, description string, steps []SkillStep, params map[string]interface{}) SkillEntry
- func BuildInstructionSkill(name, description, content, source string) SkillEntry
- func BuildScriptSkill(name, description, script string, params map[string]interface{}) SkillEntry
- func BuildTemplateSkill(name, description, tmpl string, params map[string]interface{}) SkillEntry
- func ParseSkillMD(content []byte) (*SkillEntry, error)
- type SkillStatus
- type SkillStep
- type SkillStore
- type SkillType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGitHubURL ¶
IsGitHubURL returns true if the URL points to github.com.
func RenderSkillMD ¶
func RenderSkillMD(entry *SkillEntry) ([]byte, error)
RenderSkillMD renders a SkillEntry to SKILL.md format.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor safely executes skills.
func NewExecutor ¶
func NewExecutor(logger *zap.SugaredLogger) *Executor
NewExecutor creates a new skill executor.
func (*Executor) Execute ¶
func (e *Executor) Execute(ctx context.Context, skill SkillEntry, params map[string]interface{}) (interface{}, error)
Execute runs a skill with the given parameters.
func (*Executor) ValidateScript ¶
ValidateScript checks a script for dangerous patterns.
type FileSkillStore ¶
type FileSkillStore struct {
// contains filtered or unexported fields
}
FileSkillStore implements SkillStore using .lango/skills/<name>/SKILL.md files.
func NewFileSkillStore ¶
func NewFileSkillStore(dir string, logger *zap.SugaredLogger) *FileSkillStore
NewFileSkillStore creates a new file-based skill store rooted at dir.
func (*FileSkillStore) Activate ¶
func (s *FileSkillStore) Activate(ctx context.Context, name string) error
Activate sets a skill's status to active by rewriting its SKILL.md.
func (*FileSkillStore) Delete ¶
func (s *FileSkillStore) Delete(_ context.Context, name string) error
Delete removes a skill's directory entirely.
func (*FileSkillStore) EnsureDefaults ¶
func (s *FileSkillStore) EnsureDefaults(defaultFS fs.FS) error
EnsureDefaults deploys embedded default skills that don't already exist.
func (*FileSkillStore) Get ¶
func (s *FileSkillStore) Get(_ context.Context, name string) (*SkillEntry, error)
Get reads and parses a skill's SKILL.md file.
func (*FileSkillStore) ListActive ¶
func (s *FileSkillStore) ListActive(_ context.Context) ([]SkillEntry, error)
ListActive scans all skill directories and returns entries with status=active.
func (*FileSkillStore) Save ¶
func (s *FileSkillStore) Save(_ context.Context, entry SkillEntry) error
Save creates or overwrites a skill's SKILL.md file.
func (*FileSkillStore) SaveResource ¶
func (s *FileSkillStore) SaveResource(_ context.Context, skillName, relPath string, data []byte) error
SaveResource writes a resource file under a skill's directory.
type GitHubRef ¶
GitHubRef represents a parsed GitHub repository reference.
func ParseGitHubURL ¶
ParseGitHubURL parses a GitHub URL into owner, repo, branch, and path components. Supported formats:
type ImportConfig ¶
ImportConfig holds configuration for bulk import operations.
type ImportResult ¶
ImportResult summarises the outcome of a bulk import operation.
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
Importer fetches SKILL.md files from GitHub repositories or arbitrary URLs.
func NewImporter ¶
func NewImporter(logger *zap.SugaredLogger) *Importer
NewImporter creates a new skill importer.
func NewImporterWithClient ¶
func NewImporterWithClient(client *http.Client, logger *zap.SugaredLogger) *Importer
NewImporterWithClient creates an importer with a custom HTTP client (for testing).
func (*Importer) DiscoverSkills ¶
DiscoverSkills lists subdirectories at the given path in a GitHub repo. Each subdirectory is assumed to contain a SKILL.md file.
func (*Importer) FetchFromURL ¶
FetchFromURL fetches raw content from an arbitrary URL via HTTP GET.
func (*Importer) FetchSkillMD ¶
func (im *Importer) FetchSkillMD(ctx context.Context, ref *GitHubRef, skillName string) ([]byte, error)
FetchSkillMD fetches a SKILL.md file from a GitHub repo at {path}/{skillName}/SKILL.md.
func (*Importer) ImportFromRepo ¶
func (im *Importer) ImportFromRepo(ctx context.Context, ref *GitHubRef, store SkillStore, cfg ImportConfig) (*ImportResult, error)
ImportFromRepo discovers and imports all skills from a GitHub repository. Prefers git clone when available, falls back to GitHub HTTP API.
func (*Importer) ImportSingle ¶
func (im *Importer) ImportSingle(ctx context.Context, raw []byte, sourceURL string, store SkillStore) (*SkillEntry, error)
ImportSingle imports a single skill from raw SKILL.md content.
func (*Importer) ImportSingleWithResources ¶
func (im *Importer) ImportSingleWithResources(ctx context.Context, ref *GitHubRef, skillName string, store SkillStore) (*SkillEntry, error)
ImportSingleWithResources imports a single skill from a GitHub repo, including resource files.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages skill lifecycle and converts file-based skills to executable tools.
func NewRegistry ¶
func NewRegistry(store SkillStore, baseTools []*agent.Tool, logger *zap.SugaredLogger) *Registry
NewRegistry creates a new skill registry.
func (*Registry) ActivateSkill ¶
ActivateSkill activates a skill and reloads the skill tools.
func (*Registry) CreateSkill ¶
func (r *Registry) CreateSkill(ctx context.Context, entry SkillEntry) error
CreateSkill validates and saves a new skill.
func (*Registry) GetSkillTool ¶
GetSkillTool returns a specific loaded skill tool by name.
func (*Registry) ListActiveSkills ¶
func (r *Registry) ListActiveSkills(ctx context.Context) ([]SkillEntry, error)
ListActiveSkills returns all active skill entries from the store.
func (*Registry) LoadSkills ¶
LoadSkills loads active skills from the store and converts them to agent tools.
func (*Registry) LoadedSkills ¶
LoadedSkills returns only the dynamically loaded skill tools (no base tools).
func (*Registry) Store ¶
func (r *Registry) Store() SkillStore
Store returns the underlying SkillStore for direct access (e.g. by the importer).
type SkillEntry ¶
type SkillEntry struct {
Name string
Description string
Type SkillType
Definition map[string]interface{}
Parameters map[string]interface{}
Status SkillStatus
CreatedBy string
RequiresApproval bool
Source string // import source URL (empty for locally created)
AllowedTools []string // pre-approved tools (from "allowed-tools" frontmatter)
}
SkillEntry is the domain type for skill CRUD operations. Replaces the former knowledge.SkillEntry, removing usage tracking fields.
func BuildCompositeSkill ¶
func BuildCompositeSkill(name, description string, steps []SkillStep, params map[string]interface{}) SkillEntry
BuildCompositeSkill creates a SkillEntry for a multi-step tool chain.
func BuildInstructionSkill ¶
func BuildInstructionSkill(name, description, content, source string) SkillEntry
BuildInstructionSkill creates a SkillEntry for an instruction-based reference skill. Instruction skills are agent reference documents, not executable code.
func BuildScriptSkill ¶
func BuildScriptSkill(name, description, script string, params map[string]interface{}) SkillEntry
BuildScriptSkill creates a SkillEntry for a shell script.
func BuildTemplateSkill ¶
func BuildTemplateSkill(name, description, tmpl string, params map[string]interface{}) SkillEntry
BuildTemplateSkill creates a SkillEntry for a template-based skill.
func ParseSkillMD ¶
func ParseSkillMD(content []byte) (*SkillEntry, error)
ParseSkillMD parses a SKILL.md file into a SkillEntry. Format: YAML frontmatter (between --- delimiters) + markdown body with code blocks.
type SkillStatus ¶
type SkillStatus string
SkillStatus represents the lifecycle status of a skill.
const ( SkillStatusDraft SkillStatus = "draft" SkillStatusActive SkillStatus = "active" SkillStatusDisabled SkillStatus = "disabled" )
func (SkillStatus) Valid ¶
func (s SkillStatus) Valid() bool
Valid reports whether s is a known skill status.
func (SkillStatus) Values ¶
func (s SkillStatus) Values() []SkillStatus
Values returns all known skill statuses.
type SkillStore ¶
type SkillStore interface {
Save(ctx context.Context, entry SkillEntry) error
Get(ctx context.Context, name string) (*SkillEntry, error)
ListActive(ctx context.Context) ([]SkillEntry, error)
Activate(ctx context.Context, name string) error
Delete(ctx context.Context, name string) error
SaveResource(ctx context.Context, skillName, relPath string, data []byte) error
}
SkillStore defines the persistence interface for skills.