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