MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / validateSettings

Function validateSettings

cli/src/utils/settings.ts:84–122  ·  view source on GitHub ↗
(parsed: unknown)

Source from the content-addressed store, hash-verified

82 * Validate and sanitize settings from file
83 */
84const validateSettings = (parsed: unknown): Settings => {
85 if (typeof parsed !== 'object' || parsed === null) {
86 return {}
87 }
88
89 const settings: Settings = {}
90 const obj = parsed as Record<string, unknown>
91
92 // Validate mode; migrate the previously-saved 'FREE' value to 'LITE'.
93 if (typeof obj.mode === 'string') {
94 const normalized = obj.mode === 'FREE' ? 'LITE' : obj.mode
95 if (AGENT_MODES.includes(normalized as AgentMode)) {
96 settings.mode = normalized as AgentMode
97 }
98 }
99
100 // Validate adsEnabled
101 if (typeof obj.adsEnabled === 'boolean') {
102 settings.adsEnabled = obj.adsEnabled
103 }
104
105 // Validate freebuffModel — drop unknown ids so a removed model doesn't
106 // strand the user on a non-existent queue.
107 if (typeof obj.freebuffModel === 'string' && isFreebuffModelId(obj.freebuffModel)) {
108 settings.freebuffModel = obj.freebuffModel
109 }
110
111 // Validate alwaysUseALaCarte (legacy)
112 if (typeof obj.alwaysUseALaCarte === 'boolean') {
113 settings.alwaysUseALaCarte = obj.alwaysUseALaCarte
114 }
115
116 // Validate fallbackToALaCarte (legacy)
117 if (typeof obj.fallbackToALaCarte === 'boolean') {
118 settings.fallbackToALaCarte = obj.fallbackToALaCarte
119 }
120
121 return settings
122}
123
124/**
125 * Save settings to file system (merges with existing settings)

Callers 1

loadSettingsFunction · 0.85

Calls 1

isFreebuffModelIdFunction · 0.90

Tested by

no test coverage detected