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

Method read_settings

atomic-agent/src/hooks/gemini_cli.rs:309–337  ·  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

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