(path: &Path, root: &Map<String, Value>)
| 270 | } |
| 271 | |
| 272 | fn write_json_object(path: &Path, root: &Map<String, Value>) -> AgentResult<()> { |
| 273 | if let Some(parent) = path.parent() { |
| 274 | std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError { |
| 275 | operation: "create directory".to_string(), |
| 276 | path: parent.to_path_buf(), |
| 277 | reason: e.to_string(), |
| 278 | })?; |
| 279 | } |
| 280 | let mut content = serde_json::to_string_pretty(root).map_err(|e| AgentError::ConfigError { |
| 281 | operation: "serialize".to_string(), |
| 282 | path: path.to_path_buf(), |
| 283 | reason: e.to_string(), |
| 284 | })?; |
| 285 | content.push('\n'); |
| 286 | std::fs::write(path, content).map_err(|e| AgentError::ConfigError { |
| 287 | operation: "write".to_string(), |
| 288 | path: path.to_path_buf(), |
| 289 | reason: e.to_string(), |
| 290 | }) |
| 291 | } |
| 292 | |
| 293 | /// Command-carrying keys across agent schemas: Claude/Codex/Cursor use |
| 294 | /// `command`; Copilot uses `bash`/`powershell`. |
no test coverage detected