Commit Graph
2 Commits
Author SHA1 Message Date
gitea 19f6c02c2c 架构整改:收口分层边界、统一异常体系、规范文档约定
【止血】
- 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
2026-04-15 17:41:02 +08:00
gitea 475ce518f9 重构第2批:API 层加固 + 新增 service 层
api/__init__.py:
- EkbClient.get/post 捕获 HTTP 错误,转换为 AuthenticationError /
  ApiResponseError;识别快报 errorCode=401 结构
- get_client() 改为抛出 NotLoggedInError(原为 RuntimeError)
- 新增 close() 方法便于非 with 场景使用

新增 services/ 目录(业务逻辑层):
- auth_service.py:企业认证配置的增删查改,返回 CorpInfo dataclass
- agent_service.py:Agent CRUD + copy + 高阶组合查询 get_dedup_rules_across_agents
  AgentCreateInput / AgentUpdateInput dataclass 统一输入结构
- rule_service.py:Rule 查询(支持按编码/ID 查找)+ CRUD
- __init__.py:统一 re-export,上层只从此处导入
2026-04-14 11:06:06 +08:00