架构整改:收口分层边界、统一异常体系、规范文档约定
【止血】
- errors.py: NotLoggedInError.__init__ 增加可选 message 参数,修复
services/sealai/auth_service.py 中 raise NotLoggedInError(f"...") 导致
TypeError 的硬错误
【边界收口】
- services/sealai/auth_service.py: 新增 get_whoami(),封装 api.sealai.get_me,
消灭 commands/server 对 api 层的直接穿透
- commands/sealai/whoami.py: 改用 services.sealai.get_whoami(),去掉 api 层导入
- server/sealai_router.py /me: 改用 services.sealai.get_whoami(),去掉 api 层导入
- services/agent_service.py: 新增 list_agents_cmd 等 _cmd 系列便捷函数,
commands 层无需再 import get_client
- commands/agent/list.py: 改用 list_agents_cmd(),去掉对 api.get_client 的直接依赖
【Schema 归属】
- api/sealai/schemas.py: 新增「Server 请求模型」节,迁入 sealai_router.py 中
原有 6 个内联 BaseModel(RuleCreateRequest 等)
- server/sealai_router.py: 去掉所有内联 BaseModel 和 pydantic 导入,
改从 api/sealai/schemas 统一导入
【导出统一】
- services/__init__.py: 纳入 SealAI 子域的全部 service 函数,
消灭两套并行导出体系;补充模块 docstring
【工程纪律】
- commands/auth.py: 去掉 auth_use / auth_whoami 中的局部异常捕获,
统一由 CLI 入口全局 handler 处理
【文档规范】
- CLAUDE.md: 新增「文档规范」节,明确 {module}.readme.md / {module}.test.py /
README.{dirname}.md 命名约定及分层导入禁止规则
- 新建 README.commands.md / README.server.md / README.services.md /
services/sealai/README.sealai.md / api/sealai/README.sealai.md
This commit is contained in:
1 parent
1fc6c75f13
commit
19f6c02c2c
16 files changed
+463
-77
No files matched your search
@@ -0,0 +1,35 @@
|
||||
# commands/ — CLI 表现层
|
||||
|
||||
## 职责边界
|
||||
|
||||
- **只做 I/O 适配**:参数解析(typer)、交互式输入、rich 格式化输出。
|
||||
- **不做业务编排**:调用 `services.*` 完成,不直接调用 `api.*`。
|
||||
- **不做异常处理**:让 `EkbError` 自然冒泡至 CLI 入口(`__init__.py`)的全局 handler;
|
||||
命令内部**不应**局部 catch 再重新打印,以免造成双重输出或消息漂移。
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
commands/
|
||||
├── auth.py # ekb auth 命令组(企业认证管理)
|
||||
├── help.py # ekb commands(命令树速查)
|
||||
├── serve.py # ekb serve(启动 HTTP API Server)
|
||||
├── agent/ # ekb agent 命令组,见 README.agent.md / README.rule.md
|
||||
└── sealai/ # ekb sealai 命令组,见 README.sealai.md
|
||||
```
|
||||
|
||||
## 依赖约定
|
||||
|
||||
```
|
||||
commands/* → services/* ✅ 允许
|
||||
commands/* → api/* ❌ 禁止(边界穿透)
|
||||
```
|
||||
|
||||
## 新增命令流程
|
||||
|
||||
1. 在对应子目录新建 `{verb}.py`,只写展示逻辑
|
||||
2. 在 `{dir}/__init__.py` 注册到 typer app
|
||||
3. 在 `services/` 添加或复用业务函数
|
||||
4. 在 `server/` 对应 router 添加 HTTP 端点
|
||||
5. 更新 `help.py` 命令树
|
||||
6. 更新 `CLAUDE.md` 命令全图和接口对照表
|
||||
Reference in new issue
Block a user