MCPcopy Create free account
hub / github.com/astercloud/aster / parse

Method parse

pkg/skills/loader.go:50–74  ·  view source on GitHub ↗

parse 解析技能文件

(name, content string)

Source from the content-addressed store, hash-verified

48
49// parse 解析技能文件
50func (sl *SkillLoader) parse(name, content string) (*SkillDefinition, error) {
51 // 分割 YAML frontmatter 和 Markdown 内容
52 parts := strings.Split(content, "---")
53 if len(parts) < 3 {
54 return nil, errors.New("invalid skill format: missing YAML frontmatter")
55 }
56
57 skill := &SkillDefinition{
58 // Name 默认使用传入的 skillPath,稍后如果 YAML 中显式声明了 name 会覆盖。
59 Name: name,
60 Path: name,
61 BaseDir: sl.baseDir,
62 }
63
64 // 解析 YAML frontmatter
65 yamlContent := strings.TrimSpace(parts[1])
66 if err := sl.parseYAML(yamlContent, skill); err != nil {
67 return nil, fmt.Errorf("parse YAML: %w", err)
68 }
69
70 // 提取 Markdown 内容作为知识库
71 skill.KnowledgeBase = strings.TrimSpace(strings.Join(parts[2:], "---"))
72
73 return skill, nil
74}
75
76// parseYAML 解析 YAML 配置
77func (sl *SkillLoader) parseYAML(yamlContent string, skill *SkillDefinition) error {

Callers 12

LoadMethod · 0.95
useEventStreamFunction · 0.45
renderMarkdownFunction · 0.45
parseClientMessageFunction · 0.45
useLocalStorageFunction · 0.45
normalizeForJsonFunction · 0.45
handleSSEChunkFunction · 0.45
handleResponseMethod · 0.45
chatStreamMethod · 0.45
handleMessageMethod · 0.45
memory.test.tsFile · 0.45

Calls 2

parseYAMLMethod · 0.95
JoinMethod · 0.45

Tested by 1

normalizeForJsonFunction · 0.36