(path: &Path, root: &Map<String, Value>)
| 232 | } |
| 233 | |
| 234 | fn write_json_object(path: &Path, root: &Map<String, Value>) -> AgentResult<()> { |
| 235 | if let Some(parent) = path.parent() { |
| 236 | std::fs::create_dir_all(parent).map_err(|e| AgentError::ConfigError { |
| 237 | operation: "create directory".to_string(), |
| 238 | path: parent.to_path_buf(), |
| 239 | reason: e.to_string(), |
| 240 | })?; |
| 241 | } |
| 242 | let mut content = serde_json::to_string_pretty(root).map_err(|e| AgentError::ConfigError { |
| 243 | operation: "serialize".to_string(), |
| 244 | path: path.to_path_buf(), |
| 245 | reason: e.to_string(), |
| 246 | })?; |
| 247 | content.push('\n'); |
| 248 | std::fs::write(path, content).map_err(|e| AgentError::ConfigError { |
| 249 | operation: "write".to_string(), |
| 250 | path: path.to_path_buf(), |
| 251 | reason: e.to_string(), |
| 252 | }) |
| 253 | } |
| 254 | |
| 255 | /// Command-carrying keys across agent schemas: Claude/Codex/Cursor use |
| 256 | /// `command`; Copilot uses `bash`/`powershell`. |
no test coverage detected