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

Function write_hooks_file

atomic-agent/src/hooks/codex.rs:435–453  ·  view source on GitHub ↗
(path: &Path, config: &CodexHooksFile)

Source from the content-addressed store, hash-verified

433}
434
435fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> {
436 if let Some(parent) = path.parent() {
437 std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError {
438 operation: "create directory".to_string(),
439 path: parent.to_path_buf(),
440 reason: e.to_string(),
441 })?;
442 }
443 let content = serde_json::to_string_pretty(config).map_err(|e| AgentError::ConfigError {
444 operation: "serialize".to_string(),
445 path: path.to_path_buf(),
446 reason: e.to_string(),
447 })?;
448 std::fs::write(path, content).map_err(|e| AgentError::ConfigError {
449 operation: "write".to_string(),
450 path: path.to_path_buf(),
451 reason: e.to_string(),
452 })
453}
454
455fn hooks_file_has_current_atomic_hooks(path: &Path) -> bool {
456 let Ok(config) = read_hooks_file(path) else {

Calls 2

writeFunction · 0.85
parentMethod · 0.80