v0.24.0 3dbf466

systemprompt_test.go RawHistoryFolder

1package agent
2
3import (
4	"strings"
5	"testing"
6	"time"
7)
8
9func TestBuildSystemPromptAlwaysIncludesFinalWritingGuidance(t *testing.T) {
10	for _, tt := range []struct {
11		name   string
12		custom string
13	}{
14		{name: "default"},
15		{name: "custom", custom: "custom identity"},
16	} {
17		t.Run(tt.name, func(t *testing.T) {
18			const conflictingAddendum = "Always use ceremonial language."
19			prompt := BuildSystemPrompt(SystemPromptOpts{
20				Custom: tt.custom,
21				Append: []string{conflictingAddendum},
22			})
23
24			if count := strings.Count(prompt, writingGuidance); count != 1 {
25				t.Fatalf("writing guidance count = %d, want 1:\n%s", count, prompt)
26			}
27			if strings.Index(prompt, writingGuidance) < strings.Index(prompt, conflictingAddendum) {
28				t.Fatalf("writing guidance must follow appended context:\n%s", prompt)
29			}
30			for _, want := range []string{
31				"medium, audience, and reader's immediate need",
32				"plain, precise language",
33				"verified facts",
34				"descriptive links, and accessibility",
35				"Do not manufacture slang, errors, hesitation",
36				"Revise silently",
37			} {
38				if !strings.Contains(prompt, want) {
39					t.Errorf("writing guidance missing %q:\n%s", want, prompt)
40				}
41			}
42		})
43	}
44}
45
46func TestBuildSystemPromptAddsCompactionHandoffToCustomPrompt(t *testing.T) {
47	prompt := BuildSystemPrompt(SystemPromptOpts{Custom: "custom identity"})
48	if !strings.Contains(prompt, "custom identity") {
49		t.Fatalf("custom prompt missing:\n%s", prompt)
50	}
51	if !strings.Contains(prompt, compactedSummaryHandoffInstruction) {
52		t.Fatalf("custom prompt missing compaction handoff:\n%s", prompt)
53	}
54	if count := strings.Count(prompt, compactedSummaryHandoffInstruction); count != 1 {
55		t.Fatalf("compaction handoff count = %d, want 1:\n%s", count, prompt)
56	}
57	for _, want := range []string{"most recent unresolved user request", "newer user request", "without waiting for the user to type \"continue\""} {
58		if !strings.Contains(prompt, want) {
59			t.Fatalf("compaction handoff missing %q:\n%s", want, prompt)
60		}
61	}
62}
63
64func TestBuildSystemPromptCustomOmitsBuiltInDocs(t *testing.T) {
65	got := BuildSystemPrompt(SystemPromptOpts{
66		CWD:        "/workspace",
67		Custom:     "Custom instructions",
68		Append:     []string{"Additional context"},
69		Now:        time.Date(2026, time.August, 6, 0, 0, 0, 0, time.UTC),
70		ZutDocsDir: "/zut/docs",
71	})
72
73	if strings.Contains(got, "Zut's own docs") || strings.Contains(got, "/zut/docs") {
74		t.Fatalf("custom prompt includes built-in docs guidance:\n%s", got)
75	}
76	for _, want := range []string{
77		"Custom instructions",
78		"Additional context",
79		"Current date: 2026-08-06",
80		"Current working directory: /workspace",
81	} {
82		if !strings.Contains(got, want) {
83			t.Errorf("custom prompt missing %q:\n%s", want, got)
84		}
85	}
86}
87
88func TestBuildSystemPromptDefaultIncludesBuiltInDocs(t *testing.T) {
89	got := BuildSystemPrompt(SystemPromptOpts{
90		CWD:        "/workspace",
91		Now:        time.Date(2026, time.August, 6, 0, 0, 0, 0, time.UTC),
92		ZutDocsDir: "/zut/docs",
93	})
94
95	if !strings.Contains(got, "Zut's own docs are installed under /zut/docs") {
96		t.Fatalf("default prompt missing built-in docs guidance:\n%s", got)
97	}
98}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close