批量收口 commands/agent/* 边界:全部改用 _cmd 便捷函数
- 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 层直接引用
This commit is contained in:
1 parent
19f6c02c2c
commit
c87dfa52a5
10 files changed
+123
-122
No files matched your search
@@ -1,24 +1,20 @@
|
||||
"""ekb agent copy <id>:复制智能审核 Agent(表现层)"""
|
||||
"""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.api import get_client
|
||||
from ekb_cli.services import copy_agent, MODE_DISPLAY
|
||||
from ekb_cli.services import copy_agent_cmd, MODE_DISPLAY
|
||||
|
||||
|
||||
def cmd_copy(
|
||||
agent_id: str = typer.Argument(..., help="要复制的 Agent ID"),
|
||||
):
|
||||
"""复制 Agent(新 Agent 名称为原名称加「(副本)」)"""
|
||||
from ekb_cli.errors import EkbError
|
||||
|
||||
try:
|
||||
with get_client() as client:
|
||||
src, new = copy_agent(client, agent_id)
|
||||
except EkbError as e:
|
||||
rprint(f"[red]{e.message}[/red]")
|
||||
raise typer.Exit(1)
|
||||
src, new = copy_agent_cmd(agent_id)
|
||||
|
||||
rprint("[green]✓ Agent 复制成功[/green]")
|
||||
rprint(f" 原 Agent:[dim]{src.name}[/dim] → 新 Agent:[bold]{new.name}[/bold]")
|
||||
|
||||
Reference in new issue
Block a user