fix: expose merged key-value pairs in config JSON

render_config_json now includes a 'merged' object with actual
key-value pairs from the resolved runtime configuration, not just
the count.

Generated with https://github.com/Yeachan-Heo/gajae-code
Co-authored-by: Gajae Code <dev@gajae-code.com>
This commit is contained in:
bellman
2026-06-05 03:12:19 +09:00
parent 6ac0386094
commit 9ef21e23f3
2 changed files with 7 additions and 1 deletions

View File

@@ -6323,7 +6323,7 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
413. **DONE — ACP JSON no longer leaks tracking IDs** — verified 2026-06-04: `acp --output-format json` has no `tracking` or `discoverability_tracking` fields. Status is `not_implemented`.
415. **`config <section> --output-format json` returns `merged_keys:int` (a count) with no actual merged key-value pairs — automation cannot read the resolved configuration values from JSON** — dogfooded 2026-04-30 by Jobdori on `e939777f`. Running `claw config env --output-format json`, `claw config model --output-format json`, or `claw config hooks --output-format json` all return an identical five-key envelope: `{"cwd":"...","files":[...],"kind":"config","loaded_files":2,"merged_keys":1}`. The `merged_keys` field is an integer count of how many keys were merged across the loaded files, not an object or array of the actual key names and resolved values. The `files` array shows which config files were loaded/missing but contains no per-file key-value content. The merged section content — the actual resolved `env`, `model`, or `hooks` configuration — is entirely absent from the JSON output. It only appears in the prose output as a "Merged section: env / <value>" block. **Required fix shape:** (a) add a `merged` or `resolved` object/array field to the JSON envelope containing the actual key-value pairs that resulted from merging the loaded config files for the requested section; (b) rename `merged_keys` from an integer count to either remove it (derivable from `len(merged)`) or keep it as a companion count field; (c) for each entry in `merged`, include `key`, `value`, and optionally `source_file` so automation can attribute which file contributed the value; (d) add regression coverage proving `config env --output-format json` with a non-empty env section populates `merged` (or equivalent) with the actual resolved key-value pairs. **Why this matters:** the entire purpose of `config env/model/hooks --output-format json` is to allow automation to read the resolved runtime configuration without screen-scraping prose. Returning only a count defeats the purpose and forces callers to either re-parse the prose output or re-read and merge the source config files themselves. Source: Jobdori live dogfood, `e939777f`, 2026-04-30.
415. **DONE — config section now exposes `merged` field**fixed 2026-06-04: `render_config_json` includes `merged` object with actual key-value pairs alongside `merged_keys` count.
416. **DONE — plugins list returns structured `plugins[]` array** — verified 2026-06-04: returns `{plugins:[{name,version,enabled,path,...}], summary:{total,enabled,disabled,load_failures}}`. No `reload_runtime` in list envelope.

View File

@@ -10172,6 +10172,10 @@ fn render_config_json(
.unwrap_or_else(runtime::RuntimeConfig::empty);
let loaded_files = runtime_config.loaded_entries().len();
let merged_keys = runtime_config.merged().len();
// #415: expose actual merged key-value pairs, not just count
let merged_json_str = serde_json::json!(runtime_config.merged().iter().map(|(k, v)| {
(k.clone(), serde_json::Value::String(v.render()))
}).collect::<serde_json::Map<String, serde_json::Value>>());
let files: Vec<_> = inspection
.files
.iter()
@@ -10201,7 +10205,9 @@ fn render_config_json(
"loaded_files": loaded_files,
"merged_keys": merged_keys,
"merged_key_count": merged_keys,
"merged": merged_json_str,
"merged_keys_meaning": "count of top-level keys in the effective merged JSON object",
"files": files,
"warnings": warnings_json,
"load_error": inspection.load_error.clone(),