Skip to content

Agent config read/write module (JSON, JSONC, YAML) #432

Description

@ajianaz

Part of #430.

Task

Implement config read/write module for agent configuration files.

Supported Formats

  1. JSONserde_json with preserve-order + comments support
  2. JSONC (JSON with comments) — strip // and /* */ before parse
  3. YAMLserde_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions