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) SetCompactMode(enabled bool) error {
69 cfg, err := LoadConfig()
70 if err != nil {
71 return err
72 }
73 cfg.CompactMode = &enabled
74 return SaveConfig(cfg)
75}
76
77func (configSettingsStore) SetReasoning(level string) error {
78 cfg, err := LoadConfig()
79 if err != nil {
80 return err
81 }
82 cfg.Reasoning = provider.NormalizeReasoning(level)
83 return SaveConfig(cfg)
84}
85
86func (configSettingsStore) SetTheme(name string) error {
87 cfg, err := LoadConfig()
88 if err != nil {
89 return err
90 }
91 if name == "auto" {
92 name = ""
93 }
94 cfg.Theme = name
95 return SaveConfig(cfg)
96}
97
98// AutoSwarmEnabled reads the current auto-swarm flag from config.
99// Used by the swarm_spawn tool at call time to gate execution.
100func AutoSwarmEnabled() bool {
101 cfg, err := LoadConfig()
102 if err != nil {
103 return false
104 }
105 return cfg.AutoSwarmEnabled != nil && *cfg.AutoSwarmEnabled
106}
107
108// AutoSwarmSystemAddendum is appended to the system prompt when
109// auto-swarm is enabled, so the model knows it may delegate to
110// background sub-agents without the user having to mention the tool
111// by name. Kept short so it doesn't bloat the cached prompt prefix.
112const AutoSwarmSystemAddendum = `Auto-swarm is enabled. You have a swarm_spawn tool that forks background sub-agents working in parallel in this same working directory.
113
114Use 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.
115
116Do 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.
117
118When 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.`