v0.2.52 4694534

systemprompt.go RawHistoryFolder

1package agent
2
3import (
4	"fmt"
5	"strings"
6	"time"
7)
8
9// ToolSummary is a name+one-line description. Kept as part of the
10// public opts type for backwards compatibility with callers that
11// still pass tool summaries in; the default prompt no longer lists
12// them because the provider already advertises tools in the request
13// body's tools[] array, so listing them again in prose is pure
14// duplication.
15type ToolSummary struct {
16	Name        string
17	Description string
18}
19
20// SystemPromptOpts configures BuildSystemPrompt.
21type SystemPromptOpts struct {
22	CWD        string
23	Tools      []ToolSummary
24	Custom     string   // if set, replaces the default identity entirely
25	Append     []string // extra text appended at the end
26	Now        time.Time
27	ZotDocsDir string
28}
29
30// BuildSystemPrompt constructs the system prompt.
31//
32// Design note: kept intentionally small. Every byte here is part of
33// the cached prefix on every request, so bloat is cumulatively
34// expensive. We ship only:
35//
36//   - A one-paragraph identity (who zot is, what the name means,
37//     what the TUI expects for output format).
38//   - The date + cwd footer so the model has current-context.
39//
40// Everything else (tool listing, operating guidelines, "don't run
41// sudo", "prefer edit over write", etc.) is left out because the
42// current-generation frontier models already internalise it, and
43// the tool schemas sent alongside the request carry each tool's
44// own description.
45//
46// Users who want extra biasing can use --system-prompt (replace),
47// --append-system-prompt (additive, repeatable), or drop a
48// SYSTEM.md in $ZOT_HOME that overrides the default identity.
49func BuildSystemPrompt(o SystemPromptOpts) string {
50	if o.Now.IsZero() {
51		o.Now = time.Now()
52	}
53	date := o.Now.Format("2006-01-02")
54	cwd := o.CWD
55	if cwd == "" {
56		cwd = "."
57	}
58
59	var sb strings.Builder
60
61	if o.Custom != "" {
62		sb.WriteString(o.Custom)
63	} else {
64		sb.WriteString(defaultIdentity)
65	}
66
67	if strings.TrimSpace(o.ZotDocsDir) != "" {
68		sb.WriteString("\n\nZot's own docs are installed under ")
69		sb.WriteString(o.ZotDocsDir)
70		sb.WriteString("; use the read tool there when you need details about zot RPC, extensions, skills, or built-in behaviour.")
71	}
72
73	for _, a := range o.Append {
74		if strings.TrimSpace(a) == "" {
75			continue
76		}
77		sb.WriteString("\n\n")
78		sb.WriteString(a)
79	}
80
81	fmt.Fprintf(&sb, "\n\nCurrent date: %s\nCurrent working directory: %s\n", date, cwd)
82	return sb.String()
83}
84
85const defaultIdentity = `You are an expert coding assistant operating inside zot, a coding agent harness. The name "zot" stands for "zero-overhead-tool"; if the user asks what zot means, answer exactly that.
86
87Your output renders in a TUI that understands markdown for prose and plain text for tool output. Use markdown freely, keep answers concise, and let tool calls speak for themselves rather than narrating them in prose before you invoke them. Act first, then summarise what you did.
88
89When changing file contents, prefer the edit tool for in-place changes and the write tool for creating or fully replacing files. Do not use bash with cat/echo/sed/tee redirections to mutate files; those changes render as opaque shell output while edit renders as a readable diff.`

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