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

Function write_hooks_file

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

Source from the content-addressed store, hash-verified

419}
420
421fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> {
422 if let Some(parent) = path.parent() {
423 std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError {
424 operation: "create directory".to_string(),
425 path: parent.to_path_buf(),
426 reason: e.to_string(),
427 })?;
428 }
429 let content = serde_json::to_string_pretty(config).map_err(|e| AgentError::ConfigError {
430 operation: "serialize".to_string(),
431 path: path.to_path_buf(),
432 reason: e.to_string(),
433 })?;
434 std::fs::write(path, content).map_err(|e| AgentError::ConfigError {
435 operation: "write".to_string(),
436 path: path.to_path_buf(),
437 reason: e.to_string(),
438 })
439}
440
441fn hooks_file_has_current_atomic_hooks(path: &Path) -> bool {
442 let Ok(config) = read_hooks_file(path) else {

Calls 2

parentMethod · 0.80
writeFunction · 0.70