286 lines
6.6 KiB
Markdown
286 lines
6.6 KiB
Markdown
# OpenClaw多Agent系统启动指南
|
||
|
||
## 系统配置状态
|
||
|
||
### 已配置的Agent
|
||
| Agent名称 | 工作空间 | 状态 | 路由规则 |
|
||
|-----------|----------|------|----------|
|
||
| pm | D:\openclaw-multi-agent\roles\pm | ✅ 已配置 | 默认路由 |
|
||
| backend | D:\openclaw-multi-agent\roles\dev-backend | ✅ 已配置 | 无 |
|
||
| frontend | D:\openclaw-multi-agent\roles\dev-frontend | ✅ 已配置 | 无 |
|
||
| qa | D:\openclaw-multi-agent\roles\qa | ✅ 已配置 | 无 |
|
||
|
||
### 配置验证
|
||
```bash
|
||
# 查看所有已配置的agent
|
||
openclaw agents list
|
||
|
||
# 输出应显示4个agent:
|
||
# - pm (default)
|
||
# - backend
|
||
# - frontend
|
||
# - qa
|
||
```
|
||
|
||
## 启动方式
|
||
|
||
### 方式一:通过OpenClaw CLI与特定Agent交互
|
||
```bash
|
||
# 与产品经理交互
|
||
openclaw agent --agent pm --message "[PM] 查看当前任务"
|
||
|
||
# 与后端工程师交互
|
||
openclaw agent --agent backend --message "[BE] 查看分配的任务"
|
||
|
||
# 与前端工程师交互
|
||
openclaw agent --agent frontend --message "[FE] 查看设计稿"
|
||
|
||
# 与测试工程师交互
|
||
openclaw agent --agent qa --message "[QA] 查看待测试任务"
|
||
```
|
||
|
||
### 方式二:创建批处理文件快速启动
|
||
创建以下批处理文件:
|
||
|
||
**start-pm.bat**:
|
||
```batch
|
||
@echo off
|
||
echo 启动产品经理 (PM) Agent...
|
||
echo 使用方式: openclaw agent --agent pm --message "你的消息"
|
||
echo.
|
||
openclaw agent --agent pm --message "[PM] 系统已启动,等待指令..."
|
||
pause
|
||
```
|
||
|
||
**start-backend.bat**:
|
||
```batch
|
||
@echo off
|
||
echo 启动后端工程师 (Backend) Agent...
|
||
echo 使用方式: openclaw agent --agent backend --message "你的消息"
|
||
echo.
|
||
openclaw agent --agent backend --message "[BE] 系统已启动,等待指令..."
|
||
pause
|
||
```
|
||
|
||
### 方式三:使用消息路由(推荐)
|
||
配置消息路由规则,实现自动路由:
|
||
|
||
```bash
|
||
# 配置路由规则(示例)
|
||
openclaw agents bind pm --bind "webchat"
|
||
openclaw agents bind backend --bind "webchat:backend"
|
||
```
|
||
|
||
## 消息格式规范
|
||
|
||
### 标准消息格式
|
||
```
|
||
[角色前缀] 消息内容
|
||
```
|
||
|
||
### 角色前缀映射
|
||
| 前缀 | 对应Agent | 示例 |
|
||
|------|-----------|------|
|
||
| [PM] | pm | `[PM] 创建新任务:用户评论功能` |
|
||
| [BE] | backend | `[BE] 实现用户评论接口` |
|
||
| [FE] | frontend | `[FE] 开发评论页面` |
|
||
| [QA] | qa | `[QA] 测试评论功能` |
|
||
|
||
### 系统命令
|
||
| 命令 | 功能 | 示例 |
|
||
|------|------|------|
|
||
| [STATUS] | 查看系统状态 | `[STATUS] 查看所有任务状态` |
|
||
| [HELP] | 查看帮助 | `[HELP] 查看可用命令` |
|
||
| [ALL] | 广播消息 | `[ALL] 紧急会议通知` |
|
||
|
||
## 工作流程示例
|
||
|
||
### 示例1:创建新任务
|
||
```bash
|
||
# 1. PM创建任务
|
||
openclaw agent --agent pm --message "[PM] 创建新任务:用户评论功能"
|
||
|
||
# 2. PM分配任务给后端
|
||
openclaw agent --agent pm --message "[PM] 将评论功能任务分配给后端"
|
||
|
||
# 3. 后端开始开发
|
||
openclaw agent --agent backend --message "[BE] 开始开发评论接口"
|
||
|
||
# 4. 前端开始开发
|
||
openclaw agent --agent frontend --message "[FE] 开始开发评论页面"
|
||
|
||
# 5. QA测试
|
||
openclaw agent --agent qa --message "[QA] 测试评论功能"
|
||
|
||
# 6. PM验收
|
||
openclaw agent --agent pm --message "[PM] 验收评论功能"
|
||
```
|
||
|
||
### 示例2:查看项目状态
|
||
```bash
|
||
# 查看所有任务
|
||
openclaw agent --agent pm --message "[PM] 列出所有任务"
|
||
|
||
# 查看进行中任务
|
||
openclaw agent --agent pm --message "[PM] 查看进行中任务"
|
||
|
||
# 查看测试报告
|
||
openclaw agent --agent qa --message "[QA] 查看最新测试报告"
|
||
```
|
||
|
||
## 高级配置
|
||
|
||
### 自定义Agent配置
|
||
```bash
|
||
# 添加新Agent
|
||
openclaw agents add ui-design --workspace D:\openclaw-multi-agent\roles\ui-design --non-interactive
|
||
|
||
# 配置路由规则
|
||
openclaw agents bind ui-design --bind "webchat:ui"
|
||
|
||
# 设置自定义模型
|
||
openclaw config set agents.ui-design.model "gpt-4"
|
||
```
|
||
|
||
### 环境变量配置
|
||
```batch
|
||
# 设置默认Agent
|
||
set OPENCLAW_DEFAULT_AGENT=pm
|
||
|
||
# 设置工作空间
|
||
set OPENCLAW_WORKSPACE=D:\openclaw-multi-agent\roles\pm
|
||
|
||
# 设置日志级别
|
||
set OPENCLAW_LOG_LEVEL=info
|
||
```
|
||
|
||
## 故障排除
|
||
|
||
### 常见问题
|
||
|
||
#### 问题1:Agent未找到
|
||
**症状**: `Error: Agent "pm" not found`
|
||
**解决**:
|
||
```bash
|
||
# 检查Agent列表
|
||
openclaw agents list
|
||
|
||
# 如果不存在,重新添加
|
||
openclaw agents add pm --workspace D:\openclaw-multi-agent\roles\pm --non-interactive
|
||
```
|
||
|
||
#### 问题2:工作空间访问失败
|
||
**症状**: `Error: Workspace not accessible`
|
||
**解决**:
|
||
```bash
|
||
# 检查目录权限
|
||
dir D:\openclaw-multi-agent\roles\pm
|
||
|
||
# 修复权限
|
||
icacls D:\openclaw-multi-agent\roles\pm /grant Users:(OI)(CI)F
|
||
```
|
||
|
||
#### 问题3:消息路由失败
|
||
**症状**: 消息未发送到正确的Agent
|
||
**解决**:
|
||
```bash
|
||
# 检查路由绑定
|
||
openclaw agents bindings
|
||
|
||
# 重新绑定
|
||
openclaw agents bind pm --bind "webchat"
|
||
```
|
||
|
||
### 日志查看
|
||
```bash
|
||
# 查看OpenClaw日志
|
||
openclaw logs
|
||
|
||
# 查看特定Agent日志
|
||
openclaw logs --agent pm
|
||
|
||
# 查看详细日志
|
||
openclaw logs --level debug
|
||
```
|
||
|
||
## 性能优化
|
||
|
||
### 资源监控
|
||
```bash
|
||
# 查看Agent资源使用
|
||
openclaw status --agents
|
||
|
||
# 监控系统性能
|
||
openclaw system metrics
|
||
```
|
||
|
||
### 缓存配置
|
||
```bash
|
||
# 启用缓存
|
||
openclaw config set agents.pm.cache.enabled true
|
||
|
||
# 设置缓存大小
|
||
openclaw config set agents.pm.cache.size 1000
|
||
```
|
||
|
||
## 备份与恢复
|
||
|
||
### 配置备份
|
||
```bash
|
||
# 备份Agent配置
|
||
openclaw backup create --include-agents
|
||
|
||
# 恢复配置
|
||
openclaw backup restore backup-20260331.zip
|
||
```
|
||
|
||
### 工作空间备份
|
||
```bash
|
||
# 备份所有工作空间
|
||
xcopy D:\openclaw-multi-agent\roles D:\backup\openclaw-multi-agent\roles /E /I /H
|
||
|
||
# 备份共享目录
|
||
xcopy D:\openclaw-multi-agent\shared D:\backup\openclaw-multi-agent\shared /E /I /H
|
||
```
|
||
|
||
## 扩展指南
|
||
|
||
### 添加新角色
|
||
1. 创建角色目录:`mkdir roles\新角色`
|
||
2. 创建SOUL.md和USER.md
|
||
3. 添加Agent配置:`openclaw agents add 新角色 --workspace roles\新角色`
|
||
4. 配置路由规则:`openclaw agents bind 新角色 --bind "webchat:新角色"`
|
||
5. 测试新角色:`openclaw agent --agent 新角色 --message "测试消息"`
|
||
|
||
### 集成外部系统
|
||
1. **Git集成**: 配置Git工作流
|
||
2. **飞书集成**: 配置飞书机器人
|
||
3. **数据库集成**: 连接外部数据库
|
||
4. **API集成**: 调用外部API服务
|
||
|
||
## 最佳实践
|
||
|
||
### 消息规范
|
||
1. 始终使用角色前缀
|
||
2. 消息内容清晰明确
|
||
3. 包含必要的上下文信息
|
||
4. 使用标准命令格式
|
||
|
||
### 工作流程
|
||
1. PM作为入口点,协调所有工作
|
||
2. 开发完成后必须经过QA测试
|
||
3. 所有决策必须文档化
|
||
4. 定期备份重要数据
|
||
|
||
### 系统维护
|
||
1. 定期检查Agent状态
|
||
2. 监控系统资源使用
|
||
3. 及时更新OpenClaw版本
|
||
4. 定期清理临时文件
|
||
|
||
---
|
||
|
||
**指南版本**: v1.0
|
||
**更新日期**: 2026-03-31
|
||
**适用版本**: OpenClaw 2026.3.24+
|
||
**维护者**: 橙子(龙虾助手)🦞🍊 |