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

Function TestPromptBuilder_CodeAssistant

pkg/agent/prompt_builder_test.go:59–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestPromptBuilder_CodeAssistant(t *testing.T) {
60 deps := setupPromptTestDeps(t)
61
62 // 注册代码助手模板
63 deps.TemplateRegistry.Register(&types.AgentTemplateDefinition{
64 ID: "code-assistant",
65 SystemPrompt: "You are a professional code assistant.",
66 Tools: []any{"Read", "Write"},
67 })
68
69 config := &types.AgentConfig{
70 TemplateID: "code-assistant",
71 ModelConfig: &types.ModelConfig{
72 Provider: "anthropic",
73 Model: "claude-sonnet-4-5",
74 APIKey: "test-key",
75 },
76 Sandbox: &types.SandboxConfig{
77 Kind: types.SandboxKindMock,
78 WorkDir: "/tmp/test",
79 },
80 Metadata: map[string]any{
81 "agent_type": "code_assistant",
82 },
83 }
84
85 ag, err := Create(context.Background(), config, deps)
86 if err != nil {
87 t.Fatalf("Failed to create agent: %v", err)
88 }
89 defer func() { _ = ag.Close() }()
90
91 // 获取 System Prompt
92 systemPrompt := ag.GetSystemPrompt()
93
94 // 验证代码引用规范存在
95 if !strings.Contains(systemPrompt, "## Code References") {
96 t.Error("Code assistant should have code reference guidelines")
97 }
98
99 if !strings.Contains(systemPrompt, "file_path:line_number") {
100 t.Error("Code assistant should mention file_path:line_number format")
101 }
102
103 t.Logf("Code Assistant System Prompt:\n%s", systemPrompt)
104}
105
106func TestPromptBuilder_TodoReminder(t *testing.T) {
107 deps := setupPromptTestDeps(t)

Callers

nothing calls this directly

Calls 6

setupPromptTestDepsFunction · 0.85
CreateFunction · 0.85
RegisterMethod · 0.65
CloseMethod · 0.65
GetSystemPromptMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected