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

Function demonstrateBasicRecipe

examples/recipe/main.go:37–102  ·  view source on GitHub ↗

演示基础 Recipe

(tmpDir string)

Source from the content-addressed store, hash-verified

35
36// 演示基础 Recipe
37func demonstrateBasicRecipe(tmpDir string) {
38 fmt.Println("\n📋 基础 Recipe")
39 fmt.Println(repeatStr("-", 50))
40
41 // 创建一个简单的 Recipe YAML
42 yamlContent := `
43version: "1.0"
44title: Code Review Assistant
45description: 帮助进行代码审查的 AI 助手
46instructions: |
47 你是一个专业的代码审查助手。你的职责是:
48 1. 分析代码质量
49 2. 发现潜在问题
50 3. 提供改进建议
51
52 请遵循以下原则:
53 - 友好但专业的语气
54 - 给出具体的代码示例
55 - 解释为什么某些做法更好
56
57prompt: 请审查我的代码,指出潜在的问题和改进建议。
58
59tools:
60 - Read
61 - List
62 - Search
63 - Bash
64
65activities:
66 - 审查这个文件的代码质量
67 - 检查是否有安全漏洞
68 - 优化性能瓶颈
69 - 检查测试覆盖率
70
71author:
72 name: Aster Team
73 url: https://github.com/astercloud/aster
74`
75
76 // 保存 YAML 文件
77 yamlPath := filepath.Join(tmpDir, "code-review.yaml")
78 if err := os.WriteFile(yamlPath, []byte(yamlContent), 0644); err != nil {
79 log.Fatalf("写入 YAML 失败: %v", err)
80 }
81 fmt.Printf(" ✓ 创建 Recipe 文件: %s\n", yamlPath)
82
83 // 加载 Recipe
84 r, err := recipe.LoadFromFile(yamlPath)
85 if err != nil {
86 log.Fatalf("加载 Recipe 失败: %v", err)
87 }
88
89 fmt.Printf("\n 📖 Recipe 信息:\n")
90 fmt.Printf(" 标题: %s\n", r.Title)
91 fmt.Printf(" 版本: %s\n", r.Version)
92 fmt.Printf(" 描述: %s\n", r.Description)
93 fmt.Printf(" 工具: %v\n", r.Tools)
94 fmt.Printf(" 活动建议: %d 条\n", len(r.Activities))

Callers 1

mainFunction · 0.85

Calls 5

LoadFromFileFunction · 0.92
PrintfMethod · 0.80
repeatStrFunction · 0.70
ValidateMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected