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")