1package agent
2
3import (
4 "strings"
5 "testing"
6 "time"
7)
8
9func TestBuildSystemPromptCustomOmitsBuiltInDocs(t *testing.T) {
10 got := BuildSystemPrompt(SystemPromptOpts{
11 CWD: "/workspace",
12 Custom: "Custom instructions",
13 Append: []string{"Additional context"},
14 Now: time.Date(2026, time.August, 6, 0, 0, 0, 0, time.UTC),
15 ZotDocsDir: "/zot/docs",
16 })
17
18 if strings.Contains(got, "Zot's own docs") || strings.Contains(got, "/zot/docs") {
19 t.Fatalf("custom prompt includes built-in docs guidance:\n%s", got)
20 }
21 for _, want := range []string{
22 "Custom instructions",
23 "Additional context",
24 "Current date: 2026-08-06",
25 "Current working directory: /workspace",
26 } {
27 if !strings.Contains(got, want) {
28 t.Errorf("custom prompt missing %q:\n%s", want, got)
29 }
30 }
31}
32
33func TestBuildSystemPromptPlatform(t *testing.T) {
34 for _, tc := range []struct {
35 goos string
36 wantHint bool
37 wantLabel string
38 }{
39 {"windows", true, "Platform: windows/amd64"},
40 {"linux", false, "Platform: linux/amd64"},
41 {"darwin", false, "Platform: darwin/amd64"},
42 } {
43 got := BuildSystemPrompt(SystemPromptOpts{CWD: "/w", GOOS: tc.goos, GOARCH: "amd64"})
44 if !strings.Contains(got, tc.wantLabel) {
45 t.Errorf("%s: missing %q:\n%s", tc.goos, tc.wantLabel, got)
46 }
47 if strings.Contains(got, "cmd.exe /C") != tc.wantHint {
48 t.Errorf("%s: windows shell hint present=%v, want %v", tc.goos, !tc.wantHint, tc.wantHint)
49 }
50 }
51}
52
53func TestBuildSystemPromptDefaultIncludesBuiltInDocs(t *testing.T) {
54 got := BuildSystemPrompt(SystemPromptOpts{
55 CWD: "/workspace",
56 Now: time.Date(2026, time.August, 6, 0, 0, 0, 0, time.UTC),
57 ZotDocsDir: "/zot/docs",
58 })
59
60 if !strings.Contains(got, "Zot's own docs are installed under /zot/docs") {
61 t.Fatalf("default prompt missing built-in docs guidance:\n%s", got)
62 }
63}