MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / read_settings

Method read_settings

atomic-agent/src/hooks/gemini_cli.rs:314–342  ·  view source on GitHub ↗

Read and parse the existing `.gemini/settings.json`, if it exists. Returns `(raw_settings, hooks)` where `raw_settings` preserves unknown fields and `hooks` is the parsed hooks section.

(
        settings_path: &Path,
    )

Source from the content-addressed store, hash-verified

312 /// Returns `(raw_settings, hooks)` where `raw_settings` preserves unknown
313 /// fields and `hooks` is the parsed hooks section.
314 fn read_settings(
315 settings_path: &Path,
316 ) -> AgentResult<(serde_json::Map<String, serde_json::Value>, GeminiHooks)> {
317 if !settings_path.exists() {
318 return Ok((serde_json::Map::new(), GeminiHooks::default()));
319 }
320
321 let content =
322 std::fs::read_to_string(settings_path).map_err(|e| AgentError::ConfigError {
323 operation: "read".to_string(),
324 path: settings_path.to_path_buf(),
325 reason: e.to_string(),
326 })?;
327
328 let raw: serde_json::Map<String, serde_json::Value> = serde_json::from_str(&content)
329 .map_err(|e| AgentError::ConfigError {
330 operation: "parse".to_string(),
331 path: settings_path.to_path_buf(),
332 reason: e.to_string(),
333 })?;
334
335 let hooks = if let Some(hooks_val) = raw.get("hooks") {
336 serde_json::from_value(hooks_val.clone()).unwrap_or_default()
337 } else {
338 GeminiHooks::default()
339 };
340
341 Ok((raw, hooks))
342 }
343
344 /// Write settings back to `.gemini/settings.json`.
345 fn write_settings(

Callers

nothing calls this directly

Calls 3

getMethod · 0.65
existsMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected