Part of #430.
Task
Implement config read/write module for agent configuration files.
Supported Formats
- JSON —
serde_json with preserve-order + comments support
- JSONC (JSON with comments) — strip
// and /* */ before parse
- YAML —
serde_yaml
API
mod agent_config {
fn read_config(path: &Path, format: Format) -> Result<AgentConfig>;
fn write_config(path: &Path, format: Format, config: &AgentConfig) -> Result<()>;
fn has_cora_entry(config: &AgentConfig) -> bool;
fn add_cora_entry(config: &mut AgentConfig, binary_path: &str) -> Result<()>;
fn remove_cora_entry(config: &mut AgentConfig) -> Result<()>;
}
Edge Cases
- File has BOM → strip before parse
- File has trailing comma in JSON → tolerant parse
- File permissions → return clear error
- File does not exist → create with just Cora entry
- Existing
mcpServers key → merge into it
- No
mcpServers key → create it
Acceptance
- Round-trip: read → add entry → write → read → verify entry present
- No data loss: existing MCP servers preserved
- JSONC comments preserved (if using serde_json with preserve)
Est: 2-3 days
Part of #430.
Task
Implement config read/write module for agent configuration files.
Supported Formats
serde_jsonwith preserve-order + comments support//and/* */before parseserde_yamlAPI
Edge Cases
mcpServerskey → merge into itmcpServerskey → create itAcceptance
Est: 2-3 days