Documentation
¶
Index ¶
- Constants
- Variables
- func SanitizeFileName(name string) string
- type Skill
- type SkillMeta
- type Store
- func (s *Store) Get(novelID int64, name string) (*Skill, bool)
- func (s *Store) ListMeta(novelID int64) []SkillMeta
- func (s *Store) ListMetaForCatalog(all []SkillMeta) []SkillMeta
- func (s *Store) ReloadNovel(novelID int64, novelSkillsDir string) error
- func (s *Store) ReloadUser(userSkillsDir string) error
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 ¶
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 ¶
LoadBuiltinSkills 从嵌入式文件系统解析内置 skill。
func ParseBytes ¶
ParseBytes 将一段 markdown 字节解析为 Skill。 可用于校验原始内容格式是否合法。
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 (*Store) ListMeta ¶
ListMeta 返回所有可用 skill 的元数据,按 name 去重(novel > user > builtin)。 每次调用自动刷新磁盘数据。
func (*Store) ListMetaForCatalog ¶
ListMetaForCatalog 返回只有 auto 模式的 skill 元数据,用于注入 LLM skill catalog。 manual 和 always 不出现在 catalog 中。 ListMetaForCatalog 从已有列表中过滤出 auto 模式的 skill,用于构建 skill catalog。
func (*Store) ReloadNovel ¶
ReloadNovel 重新扫描指定小说的 skill 目录。
func (*Store) ReloadUser ¶
ReloadUser 重新扫描用户级 skill 目录。
Click to show internal directories.
Click to hide internal directories.