skill

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SkillCallerKey skillCallKey = "skill_caller"

Variables

This section is empty.

Functions

This section is empty.

Types

type Skill

type Skill struct {
	// frontmatter 字段
	Name          string         `yaml:"name"`        // 必填,max 64 字符
	Description   string         `yaml:"description"` // 必填,max 1024 字符
	License       string         `yaml:"license"`
	Compatibility string         `yaml:"compatibility"`
	AllowedTools  []string       `yaml:"allowed-tools"`
	Metadata      map[string]any `yaml:"metadata"`
	Parameters    map[string]any `yaml:"parameters"`
	Category      string         `yaml:"category"`
	Tags          []string       `yaml:"tags"`
	Timeout       time.Duration  `yaml:"timeout"`

	// 指令正文(不含 frontmatter)
	Body string `yaml:"-"`

	// 运行时字段
	Path    string `yaml:"-"`
	EnvVars []string
}

Skill Agent Skill 定义

func ParseSkillMarkdown

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

ParseSkillMarkdown 解析 Skill Markdown 文档 Skill 现在只支持指令型:frontmatter 定义元数据,正文作为指令内容返回

func (*Skill) IsValid

func (s *Skill) IsValid() error

IsValid 校验必填字段

func (*Skill) ToToolMetadata

func (s *Skill) ToToolMetadata() tools.ToolMetadata

ToToolMetadata 转换为工具元数据

type SkillFrontmatter

type SkillFrontmatter struct {
	Name          string         `yaml:"name"`
	Description   string         `yaml:"description"`
	License       string         `yaml:"license"`
	Compatibility string         `yaml:"compatibility"`
	AllowedTools  string         `yaml:"allowed-tools"`
	Metadata      map[string]any `yaml:"metadata"`
	Parameters    map[string]any `yaml:"parameters"`
	// 自定义扩展
	Category string   `yaml:"category"`
	Tags     []string `yaml:"tags"`
	Timeout  int      `yaml:"timeout"`  // 秒
	EnvVars  string   `yaml:"env_vars"` // 空格分隔的环境变量名
}

SkillFrontmatter 对应 SKILL.md 的 YAML frontmatter

type SkillLoader

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

SkillLoader Skill 加载器

func NewSkillLoader

func NewSkillLoader(registry *SkillRegistry, toolRegistry *tools.ToolRegistry) *SkillLoader

NewSkillLoader 创建 Skill 加载器

func (*SkillLoader) LoadFromDir

func (sl *SkillLoader) LoadFromDir(dir string) error

LoadFromDir 从目录加载标准 Skill 目录结构

func (*SkillLoader) LoadFromFile

func (sl *SkillLoader) LoadFromFile(path string) error

LoadFromFile 从 Markdown 文件加载 Skill

func (*SkillLoader) LoadFromString

func (sl *SkillLoader) LoadFromString(content string) error

LoadFromString 从字符串加载 Skill

func (*SkillLoader) Register

func (sl *SkillLoader) Register(skill Skill) error

Register 注册 Skill 为 Agent 可调用的工具

func (*SkillLoader) Unload

func (sl *SkillLoader) Unload(name string) error

Unload 注销 Skill

type SkillRegistry

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

SkillRegistry Skill 注册表

func NewSkillRegistry

func NewSkillRegistry() *SkillRegistry

NewSkillRegistry 创建 Skill 注册表

func (*SkillRegistry) Get

func (sr *SkillRegistry) Get(name string) (*Skill, bool)

Get 获取 Skill

func (*SkillRegistry) List

func (sr *SkillRegistry) List() []*Skill

List 列出所有 Skill

func (*SkillRegistry) Names

func (sr *SkillRegistry) Names() []string

Names 返回所有 Skill 名称(排序后)

func (*SkillRegistry) Register

func (sr *SkillRegistry) Register(skill *Skill)

Register 注册 Skill

func (*SkillRegistry) Remove

func (sr *SkillRegistry) Remove(name string)

Remove 移除 Skill

Jump to

Keyboard shortcuts

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