From fe8990103cd30056f08f7c5727d06c7d0bc4c25d Mon Sep 17 00:00:00 2001 From: yunyingk Date: Mon, 6 Apr 2026 00:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9Adetail=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=98=A0=E5=B0=84=E9=94=99=E8=AF=AF=EF=BC=8C=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=85=B3=E8=81=94=E8=A7=84=E5=88=99=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ekb_cli/commands/agent/detail.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ekb_cli/commands/agent/detail.py b/src/ekb_cli/commands/agent/detail.py index 51d477b..1bfe1dc 100644 --- a/src/ekb_cli/commands/agent/detail.py +++ b/src/ekb_cli/commands/agent/detail.py @@ -3,6 +3,7 @@ import typer from rich.console import Console from rich.panel import Panel +from rich.table import Table from rich import print as rprint from ekb_cli.api import get_client @@ -10,6 +11,7 @@ from ekb_cli.api.agent import get_agent console = Console() STATE_MAP = {0: "[green]启用[/green]", 1: "[red]禁用[/red]"} +MODE_MAP = {0: "全自动", 1: "半自动", 2: "辅助"} def cmd_detail(agent_id: str = typer.Argument(..., help="Agent ID")): @@ -23,7 +25,9 @@ def cmd_detail(agent_id: str = typer.Argument(..., help="Agent ID")): raise typer.Exit(1) state = STATE_MAP.get(d.get("state"), str(d.get("state", ""))) - mode = "自动" if d.get("mode") == 2 else str(d.get("mode", "")) + mode = MODE_MAP.get(d.get("mode"), str(d.get("mode", ""))) + if d.get("mode") == 1: + mode += f"(抽检 {d.get('samplingRate', 0)}%)" content = "\n".join([ f"[bold]ID[/bold] {d.get('id')}", @@ -44,3 +48,18 @@ def cmd_detail(agent_id: str = typer.Argument(..., help="Agent ID")): ]) console.print(Panel(content, title=f"[bold]{d.get('name')}[/bold]", expand=False)) + + # 关联规则列表 + rules = d.get("agentRule", []) + if rules: + table = Table(title="关联规则", show_lines=False) + table.add_column("编号", style="dim") + table.add_column("用途") + table.add_column("描述") + table.add_column("级别") + for r in rules: + level_style = "[red]严重[/red]" if r.get("level") == "严重" else "[yellow]一般[/yellow]" + table.add_row(r.get("code", ""), r.get("purpose", ""), r.get("description", ""), level_style) + console.print(table) + else: + rprint("[dim](未关联任何规则)[/dim]")