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

Function write_hooks_file

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

Source from the content-addressed store, hash-verified

384}
385
386fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> {
387 if let Some(parent) = path.parent() {
388 std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError {
389 operation: "create directory".to_string(),
390 path: parent.to_path_buf(),
391 reason: e.to_string(),
392 })?;
393 }
394 let content = serde_json::to_string_pretty(config).map_err(|e| AgentError::ConfigError {
395 operation: "serialize".to_string(),
396 path: path.to_path_buf(),
397 reason: e.to_string(),
398 })?;
399 std::fs::write(path, content).map_err(|e| AgentError::ConfigError {
400 operation: "write".to_string(),
401 path: path.to_path_buf(),
402 reason: e.to_string(),
403 })
404}
405
406fn hooks_file_has_atomic_hooks(path: &Path) -> bool {
407 std::fs::read_to_string(path)

Callers 3

install_hooks_atFunction · 0.85
uninstall_hooks_atFunction · 0.85

Calls 2

writeFunction · 0.85
parentMethod · 0.80

Tested by 1