skills

package
v0.7.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFrontmatter = errors.New("invalid frontmatter format")

Functions

func BuildSkillPrompt

func BuildSkillPrompt(ctx context.Context) string

BuildSkillPrompt builds a system prompt string from all available skills.

It loads from local (.dscli/skills) and global (~/.dscli/skills) stores, merging with local priority. Two injection strategies:

  1. auto_inject skills: full content injected directly, no LLM fetch needed
  2. manual skills: name/description list only, LLM fetches via skill_by_name

Use skill_search tool for keyword-based discovery of manual skills. Store loading errors are gracefully degraded to empty stores so that skill failures never block conversation.

func FormatSkillMD added in v0.7.5

func FormatSkillMD(skill *Skill) (string, error)

FormatSkillMD 生成带 frontmatter 的 SKILL.md 内容,用于 skill_create 工具。 只序列化 frontmatter 必要字段(name, description, keywords, auto_inject), 正文部分直接拼接。

func LoadSkills

func LoadSkills(dir string) (skills map[string]Skill)

func ParseSkill

func ParseSkill(path string, skill *Skill) error

ParseSkill 解析指定路径的 SKILL.md 文件,填充 skill 对象。 path 必须是 SKILL.md 文件的完整路径。

func Query

func Query(q string) (string, error)

func SetAutoInject

func SetAutoInject(name string, autoInject bool, global bool) error

SetAutoInject 设置技能的 auto_inject 属性。 优先修改本地 store;若指定了 global 则修改全局 store。

func SkillFiles

func SkillFiles(dir string) (skillFiles []string)

SkillFiles returns all skill files (SKILL.md) under `dir`. It walks the directory tree recursively and returns absolute paths.

func Use

func Use(name string) (content string, err error)

Types

type Resource

type Resource struct {
	Name        string `yaml:"name,omitzero"`
	Description string `yaml:"description,omitzero"`
	Path        string `yaml:"path,omitzero"`
}

type Skill

type Skill struct {
	Name        string     `yaml:"name,omitzero"`
	Description string     `yaml:"description,omitzero"`
	Path        string     `yaml:"path,omitzero"`    // 技能根目录
	Content     string     `yaml:"content,omitzero"` // SKILL.md 正文
	Keywords    []string   `yaml:"keywords,omitzero"`
	Scripts     []Resource `yaml:"scripts,omitzero"`
	References  []Resource `yaml:"references,omitzero"`
	Templates   []Resource `yaml:"templates,omitzero"`
	Examples    []Resource `yaml:"examples,omitzero"`    // 示例文件
	AutoInject  bool       `yaml:"auto_inject,omitzero"` // 自动注入到对话上下文,无需 LLM 主动获取
	Source      string     `yaml:"-"`                    // "local" 或 "global",由加载侧注入
}

func (*Skill) FormatFull

func (skill *Skill) FormatFull() string

FormatFull 格式化技能的完整信息,供 LLM 使用。 包含:摘要、正文、资源列表(仅路径和描述,不含内容,LLM 按需读取)。

func (*Skill) Summary

func (skill *Skill) Summary() string

type SkillInfo

type SkillInfo struct {
	Name       string `json:"name"`
	Scope      string `json:"scope"`       // "local" 或 "global"
	AutoInject bool   `json:"auto_inject"` // 是否自动注入到对话上下文
}

SkillInfo 包含技能的基本信息和作用域

func ListAll

func ListAll() ([]SkillInfo, error)

ListAll 返回所有技能(本地和全局)的列表

type Store

type Store struct {
	Skills   map[string]Skill    `yaml:"skills,omitzero"`
	Keywords map[string][]string `yaml:"keywords,omitzero"`
	// contains filtered or unexported fields
}

func GlobalStore

func GlobalStore() (*Store, error)

func LocalStore

func LocalStore() (*Store, error)

func NewSkillStore

func NewSkillStore(dir string, source string) (*Store, error)

func (*Store) List

func (store *Store) List() []string

List 返回存储中的所有技能名称

func (*Store) Load

func (store *Store) Load() (err error)

func (*Store) Query

func (store *Store) Query(query string) (matched map[string]Skill)

func (*Store) Save

func (store *Store) Save() error

func (*Store) SetAutoInject

func (store *Store) SetAutoInject(name string, autoInject bool) error

SetAutoInject 设置指定技能的 auto_inject 属性并保存。

func (*Store) Use

func (store *Store) Use(name string) (content string, err error)

Source Files

  • skill.go
  • store.go

Jump to

Keyboard shortcuts

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