feat: add config apply patch command

This commit is contained in:
Peter Steinberger
2026-04-29 15:59:26 +01:00
parent 1e4a37fbfb
commit 48a01798b0
6 changed files with 848 additions and 180 deletions

View File

@@ -1,12 +1,12 @@
---
summary: "CLI reference for `openclaw config` (get/set/unset/file/schema/validate)"
summary: "CLI reference for `openclaw config` (get/set/apply/unset/file/schema/validate)"
read_when:
- You want to read or edit config non-interactively
title: "Config"
sidebarTitle: "Config"
---
Config helpers for non-interactive edits in `openclaw.json`: get/set/unset/file/schema/validate values by path and print the active config file. Run without a subcommand to open the configure wizard (same as `openclaw configure`).
Config helpers for non-interactive edits in `openclaw.json`: get/set/apply/unset/file/schema/validate values by path and print the active config file. Run without a subcommand to open the configure wizard (same as `openclaw configure`).
## Root options
@@ -31,6 +31,7 @@ openclaw config set agents.list[0].tools.exec.node "node-id-or-name"
openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN
openclaw config set secrets.providers.vaultfile --provider-source file --provider-path /etc/openclaw/secrets.json --provider-mode json
openclaw config apply --file ./openclaw.patch.json5 --dry-run
openclaw config unset plugins.entries.brave.config.webSearch.apiKey
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN --dry-run
openclaw config validate
@@ -165,6 +166,62 @@ SecretRef assignments are rejected on unsupported runtime-mutable surfaces (for
Batch parsing always uses the batch payload (`--batch-json`/`--batch-file`) as the source of truth. `--strict-json` / `--json` do not change batch parsing behavior.
## `config apply`
Use `config apply` when you want to paste or pipe a config-shaped patch instead of running many path-based `config set` commands. The input is a JSON5 object. Objects merge recursively, arrays and scalar values replace the target value, and `null` deletes the target path.
```bash
openclaw config apply --file ./openclaw.patch.json5 --dry-run
openclaw config apply --file ./openclaw.patch.json5
```
You can also pipe a patch over stdin, which is useful for remote setup scripts:
```bash
ssh openclaw-host 'openclaw config apply --stdin --dry-run' < ./openclaw.patch.json5
ssh openclaw-host 'openclaw config apply --stdin' < ./openclaw.patch.json5
```
Example patch:
```json5
{
channels: {
slack: {
enabled: true,
mode: "socket",
botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
appToken: { source: "env", provider: "default", id: "SLACK_APP_TOKEN" },
groupPolicy: "open",
requireMention: false,
},
discord: {
enabled: true,
token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
dmPolicy: "disabled",
dm: { enabled: false },
groupPolicy: "allowlist",
},
},
agents: {
defaults: {
model: { primary: "openai/gpt-5.5" },
models: {
"openai/gpt-5.5": { params: { fastMode: true } },
},
},
},
}
```
Use `--replace-path <path>` when one object or array must become exactly the provided value instead of being recursively patched:
```bash
openclaw config apply --file ./discord.patch.json5 --replace-path 'channels.discord.guilds["123"].channels'
```
`--dry-run` runs schema and SecretRef resolvability checks without writing. Exec-backed SecretRefs are skipped by default during dry-run; add `--allow-exec` when you intentionally want dry-run to execute provider commands.
JSON path/value mode remains supported for both SecretRefs and providers:
```bash