| 417 | } |
| 418 | |
| 419 | fn read_hooks_file(path: &Path) -> AgentResult<CodexHooksFile> { |
| 420 | if !path.exists() { |
| 421 | return Ok(CodexHooksFile::default()); |
| 422 | } |
| 423 | let content = std::fs::read_to_string(path).map_err(|e| AgentError::ConfigError { |
| 424 | operation: "read".to_string(), |
| 425 | path: path.to_path_buf(), |
| 426 | reason: e.to_string(), |
| 427 | })?; |
| 428 | serde_json::from_str(&content).map_err(|e| AgentError::ConfigError { |
| 429 | operation: "parse".to_string(), |
| 430 | path: path.to_path_buf(), |
| 431 | reason: e.to_string(), |
| 432 | }) |
| 433 | } |
| 434 | |
| 435 | fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> { |
| 436 | if let Some(parent) = path.parent() { |