Help us shape the future of Go! Take the 2026 Go Developer Survey

skill

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeAuto   = "auto"   // 出现在 skill catalog,AI 可自主 invoke,用户也可 / 触发
	ModeManual = "manual" // 不出现在 catalog,仅用户 / 手动触发
	ModeAlways = "always" // 不出现在 catalog,会话开头注入 system 消息,常驻生效
)

Mode 常量。

Variables

View Source
var BuiltinFS embed.FS

Functions

func SanitizeFileName

func SanitizeFileName(name string) string

SanitizeFileName removes characters that are illegal in file names, trims whitespace, and returns a default value if the result is empty.

Types

type Skill

type Skill struct {
	Name        string `json:"name" yaml:"name"`
	Description string `json:"description" yaml:"description"`
	Category    string `json:"category" yaml:"category"` // 分类,未来可基于不同分类组合实现 skill 矩阵
	Mode        string `json:"mode" yaml:"mode"`
	Author      string `json:"author" yaml:"author"`
	Version     int    `json:"version" yaml:"version"`
	Content     string `json:"content" yaml:"-"`
	RawContent  string `json:"raw_content,omitempty" yaml:"-"` // 原始 markdown 全文(含 YAML frontmatter)
}

Skill 是一个完整的 skill 定义,包含元数据和正文内容。

func LoadBuiltinSkills

func LoadBuiltinSkills(logger *slog.Logger) ([]Skill, error)

LoadBuiltinSkills 从嵌入式文件系统解析内置 skill。

func ParseBytes

func ParseBytes(data []byte, defaultAuthor string) (*Skill, error)

ParseBytes 将一段 markdown 字节解析为 Skill。 可用于校验原始内容格式是否合法。

func ParseFS

func ParseFS(fsys fs.FS, name string) (*Skill, error)

ParseFS 从 fs.FS 中读取并解析一个 skill markdown 文件。

func ParseFile

func ParseFile(path string) (*Skill, error)

ParseFile 读取并解析一个 skill markdown 文件。

func (*Skill) Meta

func (s *Skill) Meta(source string) SkillMeta

Meta 返回去除正文的元数据视图。

type SkillMeta

type SkillMeta struct {
	Name        string `json:"name"`        //name和description给llm其余的保留作为元数据
	Description string `json:"description"` //先写技能的简要介绍,再写何时invoke
	Category    string `json:"category"`    // 分类,未来可基于不同分类组合实现 skill 矩阵
	Mode        string `json:"mode"`
	Author      string `json:"author"`
	Version     int    `json:"version"`
	Source      string `json:"source"` // "builtin" | "user" | "novel"
}

SkillMeta 是去除了正文的 skill 元数据,用于列表展示。

type Store

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

Store 在内存中管理三层 skill(内置、用户、小说),支持热重载。

func NewStore

func NewStore(logger *slog.Logger, userSkillsDir string) (*Store, error)

NewStore 创建 Store 并初始加载内置和用户级 skill。

func (*Store) Get

func (s *Store) Get(novelID int64, name string) (*Skill, bool)

Get 按名称返回 skill(含 Content),同名时 novel > user > builtin。

func (*Store) ListMeta

func (s *Store) ListMeta(novelID int64) []SkillMeta

ListMeta 返回所有可用 skill 的元数据,按 name 去重(novel > user > builtin)。 每次调用自动刷新磁盘数据。

func (*Store) ListMetaForCatalog

func (s *Store) ListMetaForCatalog(all []SkillMeta) []SkillMeta

ListMetaForCatalog 返回只有 auto 模式的 skill 元数据,用于注入 LLM skill catalog。 manual 和 always 不出现在 catalog 中。 ListMetaForCatalog 从已有列表中过滤出 auto 模式的 skill,用于构建 skill catalog。

func (*Store) ReloadNovel

func (s *Store) ReloadNovel(novelID int64, novelSkillsDir string) error

ReloadNovel 重新扫描指定小说的 skill 目录。

func (*Store) ReloadUser

func (s *Store) ReloadUser(userSkillsDir string) error

ReloadUser 重新扫描用户级 skill 目录。

Directories

Path Synopsis
Package remote 提供远程 skill 市场功能。
Package remote 提供远程 skill 市场功能。

Jump to

Keyboard shortcuts

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