(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func 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 | |
| 106 | func TestPromptBuilder_TodoReminder(t *testing.T) { |
| 107 | deps := setupPromptTestDeps(t) |
nothing calls this directly
no test coverage detected