| 403 | } |
| 404 | |
| 405 | fn read_hooks_file(path: &Path) -> AgentResult<CodexHooksFile> { |
| 406 | if !path.exists() { |
| 407 | return Ok(CodexHooksFile::default()); |
| 408 | } |
| 409 | let content = std::fs::read_to_string(path).map_err(|e| AgentError::ConfigError { |
| 410 | operation: "read".to_string(), |
| 411 | path: path.to_path_buf(), |
| 412 | reason: e.to_string(), |
| 413 | })?; |
| 414 | serde_json::from_str(&content).map_err(|e| AgentError::ConfigError { |
| 415 | operation: "parse".to_string(), |
| 416 | path: path.to_path_buf(), |
| 417 | reason: e.to_string(), |
| 418 | }) |
| 419 | } |
| 420 | |
| 421 | fn write_hooks_file(path: &Path, config: &CodexHooksFile) -> AgentResult<()> { |
| 422 | if let Some(parent) = path.parent() { |