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

Function read_settings

atomic-agent/src/hooks/claude_code/settings.rs:52–87  ·  view source on GitHub ↗
(
    settings_path: &Path,
)

Source from the content-addressed store, hash-verified

50}
51
52pub(crate) fn read_settings(
53 settings_path: &Path,
54) -> AgentResult<(serde_json::Map<String, serde_json::Value>, ClaudeHooks)> {
55 let data = match std::fs::read(settings_path) {
56 Ok(data) => data,
57 Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
58 return Ok((serde_json::Map::new(), ClaudeHooks::default()));
59 }
60 Err(e) => {
61 return Err(AgentError::ConfigError {
62 operation: "read".to_string(),
63 path: settings_path.to_path_buf(),
64 reason: e.to_string(),
65 });
66 }
67 };
68
69 let raw: serde_json::Map<String, serde_json::Value> =
70 serde_json::from_slice(&data).map_err(|e| AgentError::ConfigError {
71 operation: "parse".to_string(),
72 path: settings_path.to_path_buf(),
73 reason: e.to_string(),
74 })?;
75
76 let hooks = if let Some(hooks_val) = raw.get("hooks") {
77 serde_json::from_value(hooks_val.clone()).map_err(|e| AgentError::ConfigError {
78 operation: "parse hooks".to_string(),
79 path: settings_path.to_path_buf(),
80 reason: e.to_string(),
81 })?
82 } else {
83 ClaudeHooks::default()
84 };
85
86 Ok((raw, hooks))
87}
88
89pub(crate) fn write_settings(
90 settings_path: &Path,

Callers 8

install_toMethod · 0.85
uninstall_fromMethod · 0.85
is_installed_inMethod · 0.85
install_globalMethod · 0.85
uninstall_globalMethod · 0.85
is_installed_globalMethod · 0.85
installMethod · 0.85
uninstallMethod · 0.85

Calls 3

getMethod · 0.65
kindMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected