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

Method Build

pkg/agent/prompt_modules.go:62–107  ·  view source on GitHub ↗
(ctx *PromptContext)

Source from the content-addressed store, hash-verified

60 return len(ctx.Tools) > 0
61}
62func (m *ToolsManualModule) Build(ctx *PromptContext) (string, error) {
63 // 根据 Config 决定注入哪些工具
64 var toolsToInclude []string
65
66 if m.Config == nil || m.Config.Mode == "" || m.Config.Mode == "all" {
67 // 默认:所有工具(除了 Exclude)
68 for name := range ctx.Tools {
69 if m.Config != nil && contains(m.Config.Exclude, name) {
70 continue
71 }
72 toolsToInclude = append(toolsToInclude, name)
73 }
74 } else if m.Config.Mode == "listed" {
75 // 仅包含 Include 列表中的工具
76 if m.Config.Include != nil {
77 for _, name := range m.Config.Include {
78 if _, exists := ctx.Tools[name]; exists {
79 toolsToInclude = append(toolsToInclude, name)
80 }
81 }
82 }
83 }
84
85 if len(toolsToInclude) == 0 {
86 return "", nil
87 }
88
89 sort.Strings(toolsToInclude)
90
91 var lines []string
92 lines = append(lines, "## Tools Manual")
93 lines = append(lines, "")
94 lines = append(lines, "The following tools are available for your use. Use them when appropriate instead of doing everything in natural language.")
95 lines = append(lines, "")
96
97 for _, name := range toolsToInclude {
98 tool := ctx.Tools[name]
99 summary := tool.Description()
100 if summary == "" {
101 summary = "No detailed manual; infer from tool name and input schema."
102 }
103 lines = append(lines, fmt.Sprintf("- `%s`: %s", name, summary))
104 }
105
106 return strings.Join(lines, "\n"), nil
107}
108
109// SandboxModule 沙箱信息模块
110type SandboxModule struct{}

Callers

nothing calls this directly

Calls 3

containsFunction · 0.70
DescriptionMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected