- rule_service.py 新增 list_rules_cmd / get_rule_cmd / create_rule_cmd - services/__init__.py 导出以上三个 _cmd 函数 - commands/agent/ 下 8 个文件一律移除 `from ekb_cli.api import get_client`, 改为调用 services 层对应的 _cmd 函数(自管 client 生命周期) - 同步清理各文件中残留的局部 try/except EkbError,统一冒泡至全局 handler - 验证:commands/ 目录内已无任何 api 层直接引用
24 lines
841 B
Python
24 lines
841 B
Python
"""ekb agent copy <id>:复制智能审核 Agent(表现层)
|
||
|
||
不导入 api 层;通过 services.copy_agent_cmd 复制 Agent。
|
||
EkbError 由 CLI 入口全局 handler 统一处理,本层不 catch。
|
||
"""
|
||
|
||
import typer
|
||
from rich import print as rprint
|
||
|
||
from ekb_cli.services import copy_agent_cmd, MODE_DISPLAY
|
||
|
||
|
||
def cmd_copy(
|
||
agent_id: str = typer.Argument(..., help="要复制的 Agent ID"),
|
||
):
|
||
"""复制 Agent(新 Agent 名称为原名称加「(副本)」)"""
|
||
src, new = copy_agent_cmd(agent_id)
|
||
|
||
rprint("[green]✓ Agent 复制成功[/green]")
|
||
rprint(f" 原 Agent:[dim]{src.name}[/dim] → 新 Agent:[bold]{new.name}[/bold]")
|
||
rprint(f" 新 ID:[dim]{new.id}[/dim]")
|
||
rprint(f" 模式:{MODE_DISPLAY.get(new.mode, str(new.mode))}")
|
||
rprint(f" 关联规则数:{len(new.agentRule)}")
|