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

Method write_settings

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

Write settings back to `.gemini/settings.json`.

(
        settings_path: &Path,
        raw: &serde_json::Map<String, serde_json::Value>,
    )

Source from the content-addressed store, hash-verified

338
339 /// Write settings back to `.gemini/settings.json`.
340 fn write_settings(
341 settings_path: &Path,
342 raw: &serde_json::Map<String, serde_json::Value>,
343 ) -> AgentResult<()> {
344 // Ensure parent directory exists
345 if let Some(parent) = settings_path.parent() {
346 if !parent.exists() {
347 std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError {
348 operation: "create directory".to_string(),
349 path: parent.to_path_buf(),
350 reason: e.to_string(),
351 })?;
352 }
353 }
354
355 let content = serde_json::to_string_pretty(raw).map_err(|e| AgentError::ConfigError {
356 operation: "serialize".to_string(),
357 path: settings_path.to_path_buf(),
358 reason: e.to_string(),
359 })?;
360
361 std::fs::write(settings_path, content.as_bytes()).map_err(|e| AgentError::ConfigError {
362 operation: "write".to_string(),
363 path: settings_path.to_path_buf(),
364 reason: e.to_string(),
365 })?;
366
367 Ok(())
368 }
369
370 /// Install hooks into a settings file (project or global).
371 fn install_to(settings_path: &Path, force: bool) -> AgentResult<usize> {

Callers

nothing calls this directly

Calls 4

parentMethod · 0.80
writeFunction · 0.70
existsMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected