docs(config): document schema command and add schema test

This commit is contained in:
Chummy 2026-02-19 16:38:05 +08:00
parent 282fbe0e95
commit d33eadea75
3 changed files with 45 additions and 2 deletions

View file

@ -2,7 +2,7 @@
This reference is derived from the current CLI surface (`zeroclaw --help`). This reference is derived from the current CLI surface (`zeroclaw --help`).
Last verified: **February 18, 2026**. Last verified: **February 19, 2026**.
## Top-Level Commands ## Top-Level Commands
@ -22,6 +22,7 @@ Last verified: **February 18, 2026**.
| `integrations` | Inspect integration details | | `integrations` | Inspect integration details |
| `skills` | List/install/remove skills | | `skills` | List/install/remove skills |
| `migrate` | Import from external runtimes (currently OpenClaw) | | `migrate` | Import from external runtimes (currently OpenClaw) |
| `config` | Export machine-readable config schema |
| `hardware` | Discover and introspect USB hardware | | `hardware` | Discover and introspect USB hardware |
| `peripheral` | Configure and flash peripherals | | `peripheral` | Configure and flash peripherals |
@ -105,6 +106,12 @@ Runtime in-chat commands (Telegram/Discord while channel server is running):
- `zeroclaw migrate openclaw [--source <path>] [--dry-run]` - `zeroclaw migrate openclaw [--source <path>] [--dry-run]`
### `config`
- `zeroclaw config schema`
`config schema` prints a JSON Schema (draft 2020-12) for the full `config.toml` contract to stdout.
### `hardware` ### `hardware`
- `zeroclaw hardware discover` - `zeroclaw hardware discover`

View file

@ -2,12 +2,16 @@
This is a high-signal reference for common config sections and defaults. This is a high-signal reference for common config sections and defaults.
Last verified: **February 18, 2026**. Last verified: **February 19, 2026**.
Config file path: Config file path:
- `~/.zeroclaw/config.toml` - `~/.zeroclaw/config.toml`
Schema export command:
- `zeroclaw config schema` (prints JSON Schema draft 2020-12 to stdout)
## Core Keys ## Core Keys
| Key | Default | Notes | | Key | Default | Notes |

View file

@ -3104,6 +3104,38 @@ mod tests {
assert!(c.config_path.to_string_lossy().contains("config.toml")); assert!(c.config_path.to_string_lossy().contains("config.toml"));
} }
#[test]
fn config_schema_export_contains_expected_contract_shape() {
let schema = schemars::schema_for!(Config);
let schema_json = serde_json::to_value(&schema).expect("schema should serialize to json");
assert_eq!(
schema_json
.get("$schema")
.and_then(serde_json::Value::as_str),
Some("https://json-schema.org/draft/2020-12/schema")
);
let properties = schema_json
.get("properties")
.and_then(serde_json::Value::as_object)
.expect("schema should expose top-level properties");
assert!(properties.contains_key("default_provider"));
assert!(properties.contains_key("gateway"));
assert!(properties.contains_key("channels_config"));
assert!(!properties.contains_key("workspace_dir"));
assert!(!properties.contains_key("config_path"));
assert!(
schema_json
.get("$defs")
.and_then(serde_json::Value::as_object)
.is_some(),
"schema should include reusable type definitions"
);
}
#[test] #[test]
fn observability_config_default() { fn observability_config_default() {
let o = ObservabilityConfig::default(); let o = ObservabilityConfig::default();