feat: add zeroclaw config schema for JSON Schema export
Add a `config schema` subcommand that dumps the full configuration schema as JSON Schema (draft 2020-12) to stdout. This enables downstream consumers (like PankoAgent) to programmatically validate configs, generate forms, and stay in sync with zeroclaw's evolving config surface without hand-maintaining copies of the schema. - Add schemars 1.2 dependency and derive JsonSchema on all config structs/enums (schema.rs, policy.rs, email_channel.rs) - Add `Config` subcommand group with `Schema` sub-command - Output is valid JSON Schema with $defs for all 56 config types
This commit is contained in:
parent
d44dc5a048
commit
996f66b6a7
6 changed files with 156 additions and 63 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -242,6 +242,18 @@ enum Commands {
|
|||
#[command(subcommand)]
|
||||
peripheral_command: zeroclaw::PeripheralCommands,
|
||||
},
|
||||
|
||||
/// Manage configuration
|
||||
Config {
|
||||
#[command(subcommand)]
|
||||
config_command: ConfigCommands,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum ConfigCommands {
|
||||
/// Dump the full configuration JSON Schema to stdout
|
||||
Schema,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
|
|
@ -766,6 +778,18 @@ async fn main() -> Result<()> {
|
|||
Commands::Peripheral { peripheral_command } => {
|
||||
peripherals::handle_command(peripheral_command.clone(), &config)
|
||||
}
|
||||
|
||||
Commands::Config { config_command } => match config_command {
|
||||
ConfigCommands::Schema => {
|
||||
let schema = schemars::schema_for!(config::Config);
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&schema)
|
||||
.expect("failed to serialize JSON Schema")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue