diff --git a/features/steps/plan_explain_steps.py b/features/steps/plan_explain_steps.py index 52f66681a..a7d8c6c19 100644 --- a/features/steps/plan_explain_steps.py +++ b/features/steps/plan_explain_steps.py @@ -402,7 +402,12 @@ def step_roots_no_children(context: Context) -> None: @then("the json tree output should be valid json") def step_tree_json_valid(context: Context) -> None: parsed = json.loads(context.pe_tree_json) - assert isinstance(parsed, list), "Expected a JSON array" + assert isinstance(parsed, dict), ( + f"Expected JSON envelope (dict), got {type(parsed).__name__}" + ) + _ENVELOPE_KEYS = {"command", "status", "exit_code", "data", "timing", "messages"} + missing = _ENVELOPE_KEYS - set(parsed.keys()) + assert not missing, f"Envelope missing required fields: {missing}" @then('the json tree output should contain "{text}"') diff --git a/src/cleveragents/cli/commands/plan.py b/src/cleveragents/cli/commands/plan.py index a91c9950b..430a41abb 100644 --- a/src/cleveragents/cli/commands/plan.py +++ b/src/cleveragents/cli/commands/plan.py @@ -4154,9 +4154,7 @@ def tree_decisions_cmd( if fmt in (OutputFormat.JSON, OutputFormat.YAML): console.print( - format_output( - tree_data, fmt, command="plan tree", status="ok", exit_code=0 - ) + format_output(tree_data, fmt, command="plan tree", status="ok", exit_code=0) ) elif fmt == OutputFormat.TABLE: # Flatten for table view