settings_store.go RawHistoryFolder
1package agent
2
3import "github.com/patriceckhart/zot/packages/provider"
4
5type configSettingsStore struct{}
6
7func (configSettingsStore) SetQuickModelShortcut(slot int, providerName, model string) error {
8 if slot < 1 || slot > 9 {
9 return nil
10 }
11 cfg, err := LoadConfig()
12 if err != nil {
13 return err
14 }
15 if len(cfg.QuickModelShortcuts) < slot {
16 next := make([]QuickModelShortcut, slot)
17 copy(next, cfg.QuickModelShortcuts)
18 cfg.QuickModelShortcuts = next
19 }
20 cfg.QuickModelShortcuts[slot-1] = QuickModelShortcut{Provider: providerName, Model: model}
21 // Trim trailing empty slots so config.json stays compact.
22 for len(cfg.QuickModelShortcuts) > 0 {
23 last := cfg.QuickModelShortcuts[len(cfg.QuickModelShortcuts)-1]
24 if last.Provider != "" || last.Model != "" {
25 break
26 }
27 cfg.QuickModelShortcuts = cfg.QuickModelShortcuts[:len(cfg.QuickModelShortcuts)-1]
28 }
29 return SaveConfig(cfg)
30}
31
32func (configSettingsStore) SetInlineImages(enabled bool) error {
33 cfg, err := LoadConfig()
34 if err != nil {
35 return err
36 }
37 cfg.InlineImagesEnabled = &enabled
38 return SaveConfig(cfg)
39}
40
41func (configSettingsStore) SetAutoSwarm(enabled bool) error {
42 cfg, err := LoadConfig()
43 if err != nil {
44 return err
45 }
46 cfg.AutoSwarmEnabled = &enabled
47 return SaveConfig(cfg)
48}
49
50func (configSettingsStore) SetRecursiveFileSuggest(enabled bool) error {
51 cfg, err := LoadConfig()
52 if err != nil {
53 return err
54 }
55 cfg.RecursiveFileSuggest = &enabled
56 return SaveConfig(cfg)
57}
58
59func (configSettingsStore) SetRespectGitignore(enabled bool) error {
60 cfg, err := LoadConfig()
61 if err != nil {
62 return err
63 }
64 cfg.RespectGitignore = &enabled
65 return SaveConfig(cfg)
66}
67
68func (configSettingsStore) SetReasoning(level string) error {
69 cfg, err := LoadConfig()
70 if err != nil {
71 return err
72 }
73 cfg.Reasoning = provider.NormalizeReasoning(level)
74 return SaveConfig(cfg)
75}
76
77func (configSettingsStore) SetTheme(name string) error {
78 cfg, err := LoadConfig()
79 if err != nil {
80 return err
81 }
82 if name == "auto" {
83 name = ""
84 }
85 cfg.Theme = name
86 return SaveConfig(cfg)
87}
88
89// AutoSwarmEnabled reads the current auto-swarm flag from config.
90// Used by the swarm_spawn tool at call time to gate execution.
91func AutoSwarmEnabled() bool {
92 cfg, err := LoadConfig()
93 if err != nil {
94 return false
95 }
96 return cfg.AutoSwarmEnabled != nil && *cfg.AutoSwarmEnabled
97}
98
99// AutoSwarmSystemAddendum is appended to the system prompt when
100// auto-swarm is enabled, so the model knows it may delegate to
101// background sub-agents without the user having to mention the tool
102// by name. Kept short so it doesn't bloat the cached prompt prefix.
103const AutoSwarmSystemAddendum = `Auto-swarm is enabled. You have a swarm_spawn tool that forks background sub-agents working in parallel in this same working directory.
104
105Use 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.
106
107Do 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.
108
109When 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.`