更新 CLAUDE.md 文档,添加前端 API 层和工作流自动编排相关信息

This commit is contained in:
Claude Code
2026-03-12 13:35:52 +08:00
parent 1719d1f1f9
commit 0b82a8d570

View File

@@ -31,6 +31,9 @@ npm run test:ui # 运行 Playwright 测试UI 模式)
- [WorkflowPage.tsx](frontend/src/pages/WorkflowPage.tsx) - 工作流
- [SettingsPage.tsx](frontend/src/pages/SettingsPage.tsx) - 配置
**前端 API 层**
- [api.ts](frontend/src/lib/api.ts) - 封装所有后端 API 调用
### 后端Python + FastAPI
```bash
@@ -49,6 +52,9 @@ python -m app.main
# 运行所有服务测试
python test_all_services.py
# 运行 API 集成测试
python test_api_integration.py
```
**后端 CLI 命令**(在 `backend/` 目录下执行):
@@ -133,6 +139,9 @@ python cli.py human urgent-tasks # 查看紧急
│ - HeartbeatService 心跳检测 │
│ - AgentRegistry Agent 注册 │
│ - RoleAllocator AI 角色分配 │
│ - WorkflowOrchestrator 自动工作流驱动 │
│ - CLIInvoker CLI 工具调用 │
│ - LLMService LLM API 路由 │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
@@ -197,6 +206,46 @@ status = scheduler.wait_for_meeting(agent_id, meeting_id)
| qa | 1.2 | 测试用例、自动化测试 |
| developer | 1.0 | 编码实现 |
### 4. AI Provider 系统
支持多种 AI 调用方式(优先级从高到低):
1. **CLI 工具**(本地安装):
- `claude` - Claude Code CLI
- `kimi` - Kimi CLI
- `opencode` - OpenCode CLI
2. **LLM API**(环境变量配置):
- `ANTHROPIC_API_KEY` - Claude API
- `OPENAI_API_KEY` - OpenAI API
- `DEEPSEEK_API_KEY` - DeepSeek API
- `GOOGLE_API_KEY` - Google Gemini API
CLI 调用实现见 [cli_invoker.py](backend/app/services/cli_invoker.py)Provider API 见 [providers.py](backend/app/routers/providers.py)。
### 5. 工作流自动编排
[WorkflowOrchestrator](backend/app/services/workflow_orchestrator.py) 自动驱动工作流执行:
```python
# 启动自动编排
orchestrator = get_workflow_orchestrator()
run = await orchestrator.start_workflow("dinner-decision.yaml")
# 编排器自动:
# 1. 加载工作流定义
# 2. 逐个节点执行meeting/execution
# 3. 调用 Agent 对应的 CLI/API 生成发言
# 4. 记录讨论内容
# 5. 生成会议共识
# 6. 流转到下一个节点
```
API 端点:
- `POST /api/orchestrator/start` - 启动工作流编排
- `GET /api/orchestrator/runs` - 列出所有运行
- `GET /api/orchestrator/runs/{run_id}` - 获取运行详情
## 前端样式系统
### 颜色体系
@@ -231,12 +280,16 @@ status = scheduler.wait_for_meeting(agent_id, meeting_id)
| MeetingRecorder | [meeting_recorder.py](backend/app/services/meeting_recorder.py) | 会议记录、讨论、共识 |
| ResourceManager | [resource_manager.py](backend/app/services/resource_manager.py) | 资源协调、任务执行 |
| WorkflowEngine | [workflow_engine.py](backend/app/services/workflow_engine.py) | YAML 工作流加载与执行 |
| WorkflowOrchestrator | [workflow_orchestrator.py](backend/app/services/workflow_orchestrator.py) | 自动驱动工作流执行 |
| RoleAllocator | [role_allocator.py](backend/app/services/role_allocator.py) | AI 驱动的角色分配 |
| HumanInputService | [human_input.py](backend/app/services/human_input.py) | 人类参与者输入管理 |
| CLIInvoker | [cli_invoker.py](backend/app/services/cli_invoker.py) | 调用本地 CLI 工具 |
| LLMService | [llm_service.py](backend/app/services/llm_service.py) | LLM API 路由与调用 |
### 路由层(`backend/app/routers/`
- [agents.py](backend/app/routers/agents.py) - Agent 管理 API
- [agents_control.py](backend/app/routers/agents_control.py) - Agent 控制 API启动/停止)
- [locks.py](backend/app/routers/locks.py) - 文件锁 API
- [meetings.py](backend/app/routers/meetings.py) - 会议 API
- [heartbeats.py](backend/app/routers/heartbeats.py) - 心跳 API
@@ -244,6 +297,9 @@ status = scheduler.wait_for_meeting(agent_id, meeting_id)
- [resources.py](backend/app/routers/resources.py) - 资源 API
- [roles.py](backend/app/routers/roles.py) - 角色 API
- [humans.py](backend/app/routers/humans.py) - 人类输入 API
- [websocket.py](backend/app/routers/websocket.py) - WebSocket 实时通信
- [orchestrator.py](backend/app/routers/orchestrator.py) - 工作流编排 API
- [providers.py](backend/app/routers/providers.py) - AI Provider 查询 API
## API 接口
@@ -254,9 +310,13 @@ status = scheduler.wait_for_meeting(agent_id, meeting_id)
- `GET /api/agents` - Agent 列表
- `GET /api/locks` - 文件锁状态
- `GET /api/heartbeats` - 心跳状态
- `GET /api/providers` - 可用 AI ProviderCLI + API
- `GET /api/providers/models` - 可用模型列表
- `POST /api/meetings/create` - 创建会议
- `GET /api/meetings/:id` - 会议详情
- `POST /api/workflows/load` - 加载工作流
- `POST /api/orchestrator/start` - 启动自动工作流编排
- `GET /api/orchestrator/runs/:id` - 获取编排运行状态
详见 `docs/api-reference.md`
@@ -290,6 +350,13 @@ python test_all_services.py
- WorkflowEngine - 工作流引擎
- RoleAllocator - 角色分配
运行 API 集成测试:
```bash
cd backend
python test_api_integration.py
```
### 前端测试
Playwright E2E 测试配置在 [playwright.config.ts](frontend/playwright.config.ts)
@@ -317,7 +384,14 @@ npm run test:ui # 运行测试UI 模式)
```python
from app.services.storage import get_storage
from app.services.file_lock import get_file_lock_service
from app.services.workflow_orchestrator import get_workflow_orchestrator
# ...
storage = get_storage() # 自动初始化并缓存
```
### 添加新的 AI Provider
1. **CLI 工具**:在 [cli_invoker.py](backend/app/services/cli_invoker.py) 的 `CLI_REGISTRY` 中添加映射
2. **API Provider**:在 [providers.py](backend/app/routers/providers.py) 的 `API_PROVIDERS` 中添加配置
3. **模型映射**:在 `_build_command()` 中实现 CLI 特定的参数构造