From c7caa20edd80a0072ac53cd39f866c211a63124d Mon Sep 17 00:00:00 2001 From: CleverThis Date: Mon, 1 Jun 2026 00:12:43 -0400 Subject: [PATCH] fix(cli): wire context_set to spec-aligned rendering helpers The PR added build_context_set_payload / render_context_set_plain / render_context_set_rich in cleveragents.cli.rendering.project_context_set but context_set never called them: rich output rendered a single "Context Policy Updated" panel and json/yaml/plain went through format_output(data, output_format) with no envelope kwargs. The five BDD scenarios validating the spec envelope therefore failed. Replace the tail of context_set so rich emits the four spec panels (Context Policy / Limits / Summarization / Other Views) plus the "checkmark Context policy updated" line, plain calls render_context_set_plain directly, and json/yaml flow through format_output with command="project context set", status="ok", exit_code=0, and messages=[{level: ok, text: "Context policy updated"}]. ISSUES CLOSED: #6319 --- .../cli/commands/project_context.py | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/cleveragents/cli/commands/project_context.py b/src/cleveragents/cli/commands/project_context.py index 27e7e4f23..304de2741 100644 --- a/src/cleveragents/cli/commands/project_context.py +++ b/src/cleveragents/cli/commands/project_context.py @@ -779,20 +779,45 @@ def context_set( }, ) - data = _policy_to_dict(policy) - data["acms_config"] = acms - if output_format.lower() == OutputFormat.RICH: - console.print( - Panel( - f"[green]✓[/green] Context policy " - f"'{view}' view updated for " - f"project '{project}'.", - title="Context Policy Updated", - expand=False, - ) - ) + from cleveragents.cli.rendering.project_context_set import ( + build_context_set_payload, + render_context_set_plain, + render_context_set_rich, + ) + + payload = build_context_set_payload( + project=project, + view=view, + policy=policy, + acms=acms, + default_limits={ + "hot_max_tokens": _DEFAULT_HOT_MAX_TOKENS, + "warm_max_decisions": _DEFAULT_WARM_MAX_DECISIONS, + "cold_max_decisions": _DEFAULT_COLD_MAX_DECISIONS, + "query_limit": None, + }, + ) + + success_message = "Context policy updated" + fmt_lower = output_format.lower() + + if fmt_lower == OutputFormat.RICH.value: + for panel in render_context_set_rich(payload): + console.print(panel) + console.print(f"[green]\u2713[/green] {success_message}") + elif fmt_lower == OutputFormat.PLAIN.value: + console.print(render_context_set_plain(payload, success_message)) else: - console.print(format_output(data, output_format)) + rendered = format_output( + payload, + output_format, + command="project context set", + status="ok", + exit_code=0, + messages=[{"level": "ok", "text": success_message}], + ) + if rendered: + console.print(rendered) @app.command(name="show")