v0.3.67 80dd4c6

settings_store.go RawHistoryFolder

1package agent
2
3import (
4	"github.com/patriceckhart/zot/packages/provider"
5	"github.com/patriceckhart/zot/packages/tui"
6)
7
8type configSettingsStore struct{}
9
10func (configSettingsStore) SetQuickModelShortcut(slot int, providerName, model string) error {
11	if slot < 1 || slot > 9 {
12		return nil
13	}
14	cfg, err := LoadConfig()
15	if err != nil {
16		return err
17	}
18	if len(cfg.QuickModelShortcuts) < slot {
19		next := make([]QuickModelShortcut, slot)
20		copy(next, cfg.QuickModelShortcuts)
21		cfg.QuickModelShortcuts = next
22	}
23	cfg.QuickModelShortcuts[slot-1] = QuickModelShortcut{Provider: providerName, Model: model}
24	// Trim trailing empty slots so config.json stays compact.
25	for len(cfg.QuickModelShortcuts) > 0 {
26		last := cfg.QuickModelShortcuts[len(cfg.QuickModelShortcuts)-1]
27		if last.Provider != "" || last.Model != "" {
28			break
29		}
30		cfg.QuickModelShortcuts = cfg.QuickModelShortcuts[:len(cfg.QuickModelShortcuts)-1]
31	}
32	return SaveConfig(cfg)
33}
34
35func (configSettingsStore) SetInlineImages(enabled bool) error {
36	cfg, err := LoadConfig()
37	if err != nil {
38		return err
39	}
40	cfg.InlineImagesEnabled = &enabled
41	return SaveConfig(cfg)
42}
43
44func (configSettingsStore) SetAutoSwarm(enabled bool) error {
45	cfg, err := LoadConfig()
46	if err != nil {
47		return err
48	}
49	cfg.AutoSwarmEnabled = &enabled
50	return SaveConfig(cfg)
51}
52
53func (configSettingsStore) SetAutoCompactThreshold(percent int) error {
54	cfg, err := LoadConfig()
55	if err != nil {
56		return err
57	}
58	cfg.AutoCompactThreshold = &percent
59	return SaveConfig(cfg)
60}
61
62func (configSettingsStore) SetJailByDefault(enabled bool) error {
63	cfg, err := LoadConfig()
64	if err != nil {
65		return err
66	}
67	cfg.JailByDefault = &enabled
68	return SaveConfig(cfg)
69}
70
71func (configSettingsStore) SetPowerShell(enabled bool) error {
72	cfg, err := LoadConfig()
73	if err != nil {
74		return err
75	}
76	cfg.PowerShellEnabled = &enabled
77	return SaveConfig(cfg)
78}
79
80func (configSettingsStore) SetOpenRouterServerTools(enabled bool) error {
81	cfg, err := LoadConfig()
82	if err != nil {
83		return err
84	}
85	cfg.OpenRouterServerToolsEnabled = &enabled
86	return SaveConfig(cfg)
87}
88
89func (configSettingsStore) SetRecursiveFileSuggest(enabled bool) error {
90	cfg, err := LoadConfig()
91	if err != nil {
92		return err
93	}
94	cfg.RecursiveFileSuggest = &enabled
95	return SaveConfig(cfg)
96}
97
98func (configSettingsStore) SetRespectGitignore(enabled bool) error {
99	cfg, err := LoadConfig()
100	if err != nil {
101		return err
102	}
103	cfg.RespectGitignore = &enabled
104	return SaveConfig(cfg)
105}
106
107func (configSettingsStore) SetCompactMode(enabled bool) error {
108	cfg, err := LoadConfig()
109	if err != nil {
110		return err
111	}
112	cfg.CompactMode = &enabled
113	return SaveConfig(cfg)
114}
115
116func (configSettingsStore) SetCollapseToolCall(enabled bool) error {
117	cfg, err := LoadConfig()
118	if err != nil {
119		return err
120	}
121	cfg.CollapseToolCall = &enabled
122	return SaveConfig(cfg)
123}
124
125func (configSettingsStore) SetShowInstructionsAtStartup(enabled bool) error {
126	cfg, err := LoadConfig()
127	if err != nil {
128		return err
129	}
130	cfg.ShowInstructionsAtStartup = &enabled
131	return SaveConfig(cfg)
132}
133
134func (configSettingsStore) SetTUIInputStyle(style string) error {
135	cfg, err := LoadConfig()
136	if err != nil {
137		return err
138	}
139	style = tui.NormalizeInputStyle(style)
140	if style == tui.InputStylePlain {
141		cfg.TUIInputStyle = ""
142	} else {
143		cfg.TUIInputStyle = style
144	}
145	return SaveConfig(cfg)
146}
147
148func (configSettingsStore) SetTUIStatusPosition(position string) error {
149	cfg, err := LoadConfig()
150	if err != nil {
151		return err
152	}
153	position = tui.NormalizeStatusPosition(position)
154	if position == tui.StatusPositionAboveInput {
155		cfg.TUIStatusPosition = ""
156	} else {
157		cfg.TUIStatusPosition = position
158	}
159	return SaveConfig(cfg)
160}
161
162func (configSettingsStore) SetTUIWorkingPosition(position string) error {
163	cfg, err := LoadConfig()
164	if err != nil {
165		return err
166	}
167	position = tui.NormalizeWorkingPosition(position)
168	if position == tui.WorkingPositionAboveInput {
169		cfg.TUIWorkingPosition = ""
170	} else {
171		cfg.TUIWorkingPosition = position
172	}
173	return SaveConfig(cfg)
174}
175
176func (configSettingsStore) SetReasoning(level string) error {
177	cfg, err := LoadConfig()
178	if err != nil {
179		return err
180	}
181	cfg.Reasoning = provider.NormalizeReasoning(level)
182	return SaveConfig(cfg)
183}
184
185func (configSettingsStore) SetTheme(name string) error {
186	cfg, err := LoadConfig()
187	if err != nil {
188		return err
189	}
190	if name == "auto" {
191		name = ""
192	}
193	cfg.Theme = name
194	return SaveConfig(cfg)
195}
196
197// AutoSwarmEnabled reads the current auto-swarm flag from config.
198// Used by the swarm_spawn tool at call time to gate execution.
199func AutoSwarmEnabled() bool {
200	cfg, err := LoadConfig()
201	if err != nil {
202		return false
203	}
204	return cfg.AutoSwarmEnabled != nil && *cfg.AutoSwarmEnabled
205}
206
207// AutoSwarmSystemAddendum is appended to the system prompt when
208// auto-swarm is enabled, so the model knows it may delegate to
209// background sub-agents without the user having to mention the tool
210// by name. Kept short so it doesn't bloat the cached prompt prefix.
211const AutoSwarmSystemAddendum = `Auto-swarm is enabled. You have a swarm_spawn tool that forks background sub-agents working in parallel in this same working directory.
212
213Use it proactively when the user's request naturally splits into independent sub-tasks that can run concurrently (e.g. "refactor module A and module B", "write the implementation and the tests", "investigate three separate files"). Spawn one sub-agent per independent sub-task with a self-contained task description (sub-agents start with no context from this conversation). Continue working on the remaining or coordinating work yourself in parallel; do not wait for sub-agents to finish before responding. Briefly tell the user which sub-agents you spawned and what each is doing.
214
215Do NOT use swarm_spawn for trivial single-step work, for tasks that depend on each other sequentially, or when the user explicitly asked you to do the work yourself.
216
217When every sub-agent you spawned reaches a terminal state, the host injects a single [auto-swarm update] message recapping each agent's status, task, and transcript tail. Treat that message as observed state (not as a new user request) and write a short follow-up summary referencing the agents by id.`

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