| 368 | } |
| 369 | |
| 370 | fn read_hooks_file(path: &Path) -> AgentResult<CodexHooksFile> { |
| 371 | if !path.exists() { |
| 372 | return Ok(CodexHooksFile::default()); |
| 373 | } |
| 374 | let content = std::fs::read_to_string(path).map_err(|e| AgentError::ConfigError { |
| 375 | operation: "read".to_string(), |
| 376 | path: path.to_path_buf(), |
| 377 | reason: e.to_string(), |
| 378 | })?; |
| 379 | serde_json::from_str(&content).map_err(|e| AgentError::ConfigError { |
| 380 | operation: "parse".to_string(), |
| 381 | path: path.to_path_buf(), |
| 382 | reason: e.to_string(), |
| 383 | }) |
| 384 | } |
| 385 | |
| 386 | fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> { |
| 387 | if let Some(parent) = path.parent() { |