Skip to content

开发流水线编排系统

模块概述

版本: 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 核心组件

组件文件行数说明
PipelineOrchestratorpipeline-orchestrator.js1,180流水线编排引擎
DeployAgentdeploy-agent.js3856种部署策略
PostDeployMonitorpost-deploy-monitor.js386部署后监控
Pipeline IPCpipeline-ipc.js37415个IPC处理器
Pinia Storeskill-pipeline.ts204前端状态管理

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_PRGit PR 部署创建 PR → 合并 → 推送
DOCKERDocker 部署构建镜像 → 推送 → 部署
NPM_PUBLISHNPM 发布版本号更新 → 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

字段类型说明
idTEXT PK流水线ID
templateTEXT模板类型
configTEXT(JSON)流水线配置
statusTEXT状态 (pending/running/paused/completed/failed/cancelled)
current_stageINTEGER当前阶段索引
resultTEXT(JSON)执行结果
created_atINTEGER创建时间
updated_atINTEGER更新时间
completed_atINTEGER完成时间

3.2 dev_pipeline_stages

字段类型说明
idTEXT PK阶段ID
pipeline_idTEXT FK流水线ID
stage_indexINTEGER阶段序号
nameTEXT阶段名称
statusTEXT状态 (pending/running/completed/failed/skipped/gate-waiting)
gate_requiredINTEGER是否需要门禁
gate_approvedINTEGER门禁是否通过
inputTEXT(JSON)输入数据
outputTEXT(JSON)输出结果
started_atINTEGER开始时间
completed_atINTEGER完成时间

3.3 dev_pipeline_artifacts

字段类型说明
idTEXT PK工件ID
pipeline_idTEXT FK流水线ID
stage_indexINTEGER阶段序号
typeTEXT类型 (document/code/report/config)
nameTEXT工件名称
contentTEXT工件内容
metadataTEXT(JSON)元数据
created_atINTEGER创建时间

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

基于 MIT 许可发布