Files
assist/.kiro/specs/architecture-evolution/tasks.md
Jeason 45badfee82 v2.0: 架构大版本升级
任务 3.2+3.3: 飞书入口迁移到 MessagePipeline
- feishu_bot.py 改用 pipeline.handle_message(去掉 30 行会话管理代码)
- feishu_longconn_service.py 改用 pipeline.handle_message(去掉 25 行)
- 各入口只负责协议适配,业务逻辑统一在 Pipeline

任务 5: 统一配置管理
- 新增 src/config/config_service.py(ConfigService 单例)
- 优先级:环境变量 > system_settings.json > 代码默认值
- 支持点号分隔的嵌套 key、自动类型转换

任务 8: 密码哈希升级
- SHA-256  bcrypt(User.set_password/check_password)
- AuthManager.hash_password/verify_password 同步升级
- 兼容旧密码:登录时检测 SHA-256 格式,验证通过后自动升级为 bcrypt
- auth_manager.secret_key 改为从环境变量读取

任务 9: 前端事件总线
- TSPDashboard 新增 on/off/emit 方法
- 模块间可通过事件通信,不再只靠直接读写共享状态

README.md 重写
- 功能概览、技术栈、快速开始、项目结构
- 架构要点、多租户、飞书机器人、环境变量
- 开发和部署说明
2026-04-08 08:53:43 +08:00

73 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 架构演进任务清单
## 概述
基于两轮架构审查发现的结构性问题,按优先级排列的演进任务。每个任务独立可交付,不依赖其他任务的完成。
## Tasks
- [-] 1. 引入 Repository 层,分离数据访问逻辑
- [x] 1.1 创建 `src/repositories/` 目录,为核心模型创建 Repository 类
- WorkOrderRepository: 封装工单的 CRUD + 按 tenant_id 过滤
- KnowledgeRepository: 封装知识库的 CRUD + 按 tenant_id 过滤
- ConversationRepository: 封装对话/会话的 CRUD + 按 tenant_id 过滤
- AlertRepository: 封装预警的 CRUD + 按 tenant_id 过滤
- [x] 1.2 将 blueprint 中的直接 DB 查询迁移到 Repository
- workorders.py 的 get_workorders → workorder_repo.list_workorders
- alerts.py 的 get_alerts → alert_repo.list_alerts, resolve → alert_repo.resolve
- [x] 1.3 在 Repository 基类中统一添加 tenant_id 过滤
- 所有查询方法自动附加 tenant_id 条件
- 写操作自动设置 tenant_id
- [x] 2. 统一 LLM 客户端
- [x] 2.1 将 `src/agent/llm_client.py` 的异步能力合并到 `src/core/llm_client.py`
- LLMClient 新增 async_generate / async_chat 方法(线程池包装同步调用)
- 统一超时、重试、token 统计逻辑
- [x] 2.2 让 agent_assistant.py 使用统一的 LLMClient
- agent_assistant 改用 self.llm_client = LLMClient()
- _extract_knowledge_from_content 改用 self.llm_client.async_generate
- [x] 2.3 统一 LLM 配置入口
- 所有 LLM 调用从 unified_config 读取配置
- [x] 3. 引入 MessagePipeline 统一消息处理
- [x] 3.1 创建 `src/dialogue/message_pipeline.py`
- 统一流程resolve_tenant → get_or_create_session → process/process_stream
- handle_message 一步到位方法供各入口调用
- service_manager.get_pipeline() 注册
- 各入口WebSocket、HTTP、飞书 bot、飞书长连接只负责协议适配
- [x] 3.2 重构飞书 bot/longconn 使用 Pipelinerealtime_chat 保持不变Pipeline 委托给它)
- [x] 3.3 重构飞书 bot/longconn 使用 Pipeline
- feishu_bot.py 改用 pipeline.handle_message去掉 30 行会话管理代码)
- feishu_longconn_service.py 改用 pipeline.handle_message去掉 25 行会话管理代码)
- [ ] 4. 引入 Alembic 数据库迁移(待做 — 需要改启动流程)
- [x] 5. 统一配置管理
- [x] 5.1 定义配置优先级:环境变量 > system_settings.json > 代码默认值
- [x] 5.2 创建 ConfigService 统一读写接口src/config/config_service.py
- [ ] 6. API 契约定义(待做 — 需要引入 Flask-RESTX
- [ ] 7. 会话状态迁移到 Redis待做 — 需要多实例部署时再做)
- [x] 8. 密码哈希升级
- [x] 8.1 SHA-256 → bcryptUser.set_password/check_password + AuthManager
- [x] 8.2 兼容旧密码:登录时检测旧 SHA-256 格式,自动升级为 bcrypt
- [x] 9. 前端状态管理优化
- [x] 9.1 引入事件总线on/off/emit 方法在 TSPDashboard 核心类中)
- [x] 10. 清理旧代码
- [x] 10.1 删除 src/web/static/js/core/ 目录(旧的未完成重构)
- [x] 10.2 删除 src/web/static/js/services/ 目录
- [x] 10.3 删除 src/web/static/js/components/ 目录
- [x] 10.4 删除 src/web/static/js/pages/ 目录
- [x] 10.5 清理 index.html、chat.html、chat_http.html 中对已删除 JS 的引用
## Notes
- 每个任务独立可交付,按 1 → 2 → 3 的顺序做收益最大
- 任务 4Alembic可以随时做不依赖其他任务
- 任务 7Redis 会话)只在需要多实例部署时才有必要
- 任务 8密码升级安全性高但影响面小可以穿插做