v0.0.40 05d0df9

systemprompt.go RawHistoryFolder

1package agent
2
3import (
4	"fmt"
5	"strings"
6	"time"
7)
8
9// ToolSummary is a name+one-line description. Kept for backwards
10// compatibility with callers that still pass tool summaries in; the
11// built-in system prompt no longer lists tools by name, since the
12// tool schemas themselves already reach the model.
13type ToolSummary struct {
14	Name        string
15	Description string
16}
17
18// SystemPromptOpts configures BuildSystemPrompt.
19type SystemPromptOpts struct {
20	CWD    string
21	Tools  []ToolSummary
22	Custom string   // if set, replaces the default identity/guidelines sections
23	Append []string // extra text appended at the end
24	Now    time.Time
25}
26
27// BuildSystemPrompt constructs the system prompt.
28//
29// Design note: the prompt is intentionally tiny. Every byte here
30// is re-sent on every request (cached after the first, but still
31// counts toward cache-write on turn 1 and live context throughout).
32// We avoid:
33//
34//   - Listing the tool names and descriptions (the provider sends
35//     the tool schemas separately; duplicating them costs tokens
36//     for zero benefit, the model already sees the tools).
37//   - Repeating generic coding-assistant advice the frontier models
38//     already internalise ("always read before editing", "prefer
39//     minimal diffs", "don't apologize"). These were free tokens
40//     on older models; they are pure overhead now.
41//
42// Anything the user explicitly needs can still be added via
43// --system-prompt, --append-system-prompt, or $ZOT_HOME/SYSTEM.md.
44func BuildSystemPrompt(o SystemPromptOpts) string {
45	if o.Now.IsZero() {
46		o.Now = time.Now()
47	}
48	date := o.Now.Format("2006-01-02")
49	cwd := o.CWD
50	if cwd == "" {
51		cwd = "."
52	}
53
54	var sb strings.Builder
55
56	if o.Custom != "" {
57		sb.WriteString(o.Custom)
58	} else {
59		sb.WriteString(defaultIdentity)
60	}
61
62	for _, a := range o.Append {
63		if strings.TrimSpace(a) == "" {
64			continue
65		}
66		sb.WriteString("\n\n")
67		sb.WriteString(a)
68	}
69
70	fmt.Fprintf(&sb, "\n\nCurrent date: %s\nCurrent working directory: %s\n", date, cwd)
71	return sb.String()
72}
73
74const defaultIdentity = `You are zot, a lightweight terminal coding agent. Be concise, act on the user's request directly, and reply with a short summary when done.`

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 477

↑↓ moveenter openesc close