开发流水线编排系统
模块概述
版本: v3.0.0 状态: ✅ 已实现 IPC处理器: 15个 最后更新: 2026-03-05
AI 驱动的全生命周期开发流水线编排系统。支持 7 个阶段 (需求→架构→代码→测试→审查→部署→监控)、4 种项目模板、6 种部署策略和门禁审批机制。
核心特性
- 7 阶段流水线: 需求解析→架构设计→代码生成→测试→代码审查→部署→监控
- 4 种模板: feature / bugfix / refactor / security-audit
- 6 种部署策略: GIT_PR / DOCKER / NPM_PUBLISH / LOCAL / STAGING / custom
- 门禁审批: code-review 和 deploy 阶段支持审批门禁
- 工件管理: 每阶段产出工件自动收集和追踪
- 部署后监控: 自动健康检查和回滚触发
1. 架构设计
1.1 整体架构图
┌──────────────────────────────────────────────────────────────────┐
│ 前端 (Vue3) │
├──────────────────────────────────────────────────────────────────┤
│ Pinia Store: skill-pipeline.ts (204行) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌───────────────────┐ │
│ │ 流水线列表│ │ 阶段进度 │ │ 工件查看 │ │ 部署面板 │ │
│ └──────────┘ └──────────┘ └──────────┘ └───────────────────┘ │
└──────────────────────────────────────────────────────────────────┘
↕ IPC (15个通道)
┌──────────────────────────────────────────────────────────────────┐
│ 主进程 (Electron) │
├──────────────────────────────────────────────────────────────────┤
│ pipeline-ipc.js (374行) │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ PipelineOrchestrator (1,180行, extends EventEmitter) │ │
│ │ ┌──────────────────────────────────────────────────────┐ │ │
│ │ │ 7 Stages Pipeline │ │ │
│ │ │ requirement → architecture → code-generation → │ │ │
│ │ │ testing → code-review [GATE] → deploy [GATE] → │ │ │
│ │ │ monitoring │ │ │
│ │ └──────────────────────────────────────────────────────┘ │ │
│ │ ┌──────────────────┐ ┌──────────────────┐ │ │
│ │ │ 4 Templates │ │ Gate Approval │ │ │
│ │ │ feature/bugfix/ │ │ code-review/ │ │ │
│ │ │ refactor/audit │ │ deploy gates │ │ │
│ │ └──────────────────┘ └──────────────────┘ │ │
│ └────────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ DeployAgent (385行) │ PostDeployMonitor (386行) │ │
│ │ 6种部署策略 │ 部署后健康检查 │ │
│ │ GIT_PR/DOCKER/NPM/... │ 自动回滚触发 │ │
│ └────────────────────────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ SQLite Database (3 tables) │ │
│ └────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────┘1.2 流水线执行流程
createPipeline(template, config)
↓
┌──────────────────────────────────────────────────────┐
│ Stage 1: requirement-parsing │
│ 解析需求 → 输出: 结构化需求文档 │
├──────────────────────────────────────────────────────┤
│ Stage 2: architecture-design │
│ 架构设计 → 输出: 架构方案 + 文件列表 │
├──────────────────────────────────────────────────────┤
│ Stage 3: code-generation │
│ 代码生成 → 输出: 源代码文件 │
├──────────────────────────────────────────────────────┤
│ Stage 4: testing │
│ 测试生成与执行 → 输出: 测试报告 │
├──────────────────────────────────────────────────────┤
│ Stage 5: code-review [GATE] │
│ 代码审查 → 需审批通过 → 输出: 审查报告 │
├──────────────────────────────────────────────────────┤
│ Stage 6: deploy [GATE] │
│ 部署执行 → 需审批通过 → 输出: 部署结果 │
├──────────────────────────────────────────────────────┤
│ Stage 7: monitoring │
│ 部署后监控 → 输出: 健康报告 │
└──────────────────────────────────────────────────────┘
↓
Pipeline 完成 (completed / failed)1.3 核心组件
| 组件 | 文件 | 行数 | 说明 |
|---|---|---|---|
| PipelineOrchestrator | pipeline-orchestrator.js | 1,180 | 流水线编排引擎 |
| DeployAgent | deploy-agent.js | 385 | 6种部署策略 |
| PostDeployMonitor | post-deploy-monitor.js | 386 | 部署后监控 |
| Pipeline IPC | pipeline-ipc.js | 374 | 15个IPC处理器 |
| Pinia Store | skill-pipeline.ts | 204 | 前端状态管理 |
2. 核心模块
2.1 PipelineOrchestrator
javascript
class PipelineOrchestrator extends EventEmitter {
async initialize(database)
// 流水线管理
async createPipeline(template, config) // 创建流水线
async startPipeline(pipelineId) // 启动执行
async pausePipeline(pipelineId) // 暂停
async resumePipeline(pipelineId) // 恢复
async cancelPipeline(pipelineId) // 取消
async retryStage(pipelineId, stageIndex) // 重试阶段
// 门禁
async approveGate(pipelineId, stageIndex) // 通过门禁
async rejectGate(pipelineId, stageIndex, reason) // 拒绝门禁
// 查询
async getPipeline(pipelineId) // 获取流水线
async getAllPipelines(options?) // 列出流水线
async getStageArtifacts(pipelineId, stageIndex) // 获取工件
async getTemplates() // 获取模板列表 (Array)
// 配置
async configure(config) // 配置 (如 dryRun)
}createPipeline 返回值:
javascript
{
id: 'pipeline-xxx',
status: 'pending',
stages: [
{ name: 'requirement-parsing', status: 'pending' },
{ name: 'architecture-design', status: 'pending' },
// ...
]
}2.2 项目模板 (4种)
| 模板 | 阶段 | 说明 |
|---|---|---|
feature | 全部7阶段 | 新功能开发完整流程 |
bugfix | 需求→代码→测试→审查 | 跳过架构设计和部署 |
refactor | 架构→代码→测试→审查 | 重构专用 |
security-audit | 代码→测试→审查 | 安全审计 |
2.3 DeployAgent
javascript
class DeployAgent extends EventEmitter {
async initialize(deps)
// 部署
async deploy(config) // 执行部署
async configure(config) // 配置 (dryRun等)
async getDeployHistory(options?) // 部署历史
async rollback(deployId) // 回滚部署
}部署策略 (6种):
| 策略 | 说明 | 执行动作 |
|---|---|---|
GIT_PR | Git PR 部署 | 创建 PR → 合并 → 推送 |
DOCKER | Docker 部署 | 构建镜像 → 推送 → 部署 |
NPM_PUBLISH | NPM 发布 | 版本号更新 → npm publish |
LOCAL | 本地部署 | 本地构建 → 启动服务 |
STAGING | 预发布环境 | 部署到 staging → 验证 |
custom | 自定义 | 执行自定义脚本 |
2.4 PostDeployMonitor
javascript
class PostDeployMonitor extends EventEmitter {
async initialize(deps) // 初始化 (无db参数)
// 监控
async startMonitoring(deployId, config?) // 开始监控 (创建interval)
async stopMonitoring(deployId) // 停止监控
async getMonitorStatus(deployId) // 监控状态
async getHealthReport(deployId) // 健康报告
// 生命周期
async destroy() // 销毁 (清理interval)
}3. 数据模型
3.1 dev_pipelines
| 字段 | 类型 | 说明 |
|---|---|---|
| id | TEXT PK | 流水线ID |
| template | TEXT | 模板类型 |
| config | TEXT(JSON) | 流水线配置 |
| status | TEXT | 状态 (pending/running/paused/completed/failed/cancelled) |
| current_stage | INTEGER | 当前阶段索引 |
| result | TEXT(JSON) | 执行结果 |
| created_at | INTEGER | 创建时间 |
| updated_at | INTEGER | 更新时间 |
| completed_at | INTEGER | 完成时间 |
3.2 dev_pipeline_stages
| 字段 | 类型 | 说明 |
|---|---|---|
| id | TEXT PK | 阶段ID |
| pipeline_id | TEXT FK | 流水线ID |
| stage_index | INTEGER | 阶段序号 |
| name | TEXT | 阶段名称 |
| status | TEXT | 状态 (pending/running/completed/failed/skipped/gate-waiting) |
| gate_required | INTEGER | 是否需要门禁 |
| gate_approved | INTEGER | 门禁是否通过 |
| input | TEXT(JSON) | 输入数据 |
| output | TEXT(JSON) | 输出结果 |
| started_at | INTEGER | 开始时间 |
| completed_at | INTEGER | 完成时间 |
3.3 dev_pipeline_artifacts
| 字段 | 类型 | 说明 |
|---|---|---|
| id | TEXT PK | 工件ID |
| pipeline_id | TEXT FK | 流水线ID |
| stage_index | INTEGER | 阶段序号 |
| type | TEXT | 类型 (document/code/report/config) |
| name | TEXT | 工件名称 |
| content | TEXT | 工件内容 |
| metadata | TEXT(JSON) | 元数据 |
| created_at | INTEGER | 创建时间 |
4. IPC接口 (15个)
4.1 流水线管理 (6个)
| 通道 | 说明 | 参数 |
|---|---|---|
dev-pipeline:create | 创建流水线 | template, config |
dev-pipeline:start | 启动流水线 | pipelineId |
dev-pipeline:pause | 暂停流水线 | pipelineId |
dev-pipeline:resume | 恢复流水线 | pipelineId |
dev-pipeline:cancel | 取消流水线 | pipelineId |
dev-pipeline:retry-stage | 重试阶段 | pipelineId, stageIndex |
4.2 门禁审批 (2个)
| 通道 | 说明 | 参数 |
|---|---|---|
dev-pipeline:approve-gate | 通过门禁 | pipelineId, stageIndex |
dev-pipeline:reject-gate | 拒绝门禁 | pipelineId, stageIndex, reason |
4.3 查询 (4个)
| 通道 | 说明 | 参数 |
|---|---|---|
dev-pipeline:get-pipeline | 获取流水线 | pipelineId |
dev-pipeline:list-pipelines | 列出流水线 | options? |
dev-pipeline:get-artifacts | 获取工件 | pipelineId, stageIndex |
dev-pipeline:get-templates | 获取模板列表 | - |
4.4 部署 (3个)
| 通道 | 说明 | 参数 |
|---|---|---|
dev-pipeline:deploy | 执行部署 | config |
dev-pipeline:deploy-rollback | 回滚部署 | deployId |
dev-pipeline:monitor-status | 监控状态 | deployId |
5. 事件
| 事件 | 负载 | 说明 |
|---|---|---|
pipeline:created | 流水线创建 | |
pipeline:started | 流水线启动 | |
stage:started | 阶段开始 | |
stage:completed | 阶段完成 | |
stage:failed | 阶段失败 | |
gate:waiting | 等待门禁审批 | |
gate:approved | 门禁通过 | |
gate:rejected | 门禁拒绝 | |
deploy:started | 部署开始 | |
deploy:completed | 部署完成 | |
pipeline:completed | 流水线完成 |
6. 前端页面
6.1 Pinia Store: skill-pipeline.ts
typescript
interface PipelineState {
pipelines: Pipeline[];
currentPipeline: Pipeline | null;
templates: PipelineTemplate[];
loading: boolean;
}
// Actions
createPipeline(); // 创建流水线
startPipeline(); // 启动
approveGate(); // 审批门禁
fetchPipelines(); // 获取列表
getArtifacts(); // 获取工件7. 文件结构
desktop-app-vue/src/main/ai-engine/cowork/
├── pipeline-orchestrator.js # 流水线编排引擎 (1,180行)
├── deploy-agent.js # 6种部署策略 (385行)
├── post-deploy-monitor.js # 部署后监控 (386行)
└── pipeline-ipc.js # 15个IPC处理器 (374行)
desktop-app-vue/src/renderer/
└── stores/skill-pipeline.ts # 流水线状态管理 (204行)8. 相关文档
文档版本: 1.0 最后更新: 2026-03-05
