openmatrix 0.1.84 → 0.1.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,4 +76,12 @@ export declare class TaskPlanner {
76
76
  private generateTaskId;
77
77
  private determinePriority;
78
78
  private estimateComplexity;
79
+ /**
80
+ * 分类目标类型
81
+ * - development: 需要编写代码的功能实现 → 拆分为实现+测试对
82
+ * - testing: 已明确是测试任务 → 单个测试任务
83
+ * - documentation: 文档编写 → 单个文档任务
84
+ * - other: 其他类型(配置、优化、部署等) → 单个任务
85
+ */
86
+ private classifyGoal;
79
87
  }
@@ -33,6 +33,14 @@ class TaskPlanner {
33
33
  const breakdowns = [];
34
34
  const seenTitles = new Set();
35
35
  const userContext = this.extractUserContext(answers);
36
+ // qualityConfig 中的 e2eTests 优先级高于 answers 中的推断
37
+ if (qualityConfig?.e2eTests) {
38
+ userContext.e2eTests = true;
39
+ // 如果 e2eType 未指定,从质量配置推断
40
+ if (!userContext.e2eType) {
41
+ userContext.e2eType = 'web';
42
+ }
43
+ }
36
44
  // 确定测试覆盖率
37
45
  const coverageTarget = this.getCoverageTarget(qualityConfig, userContext);
38
46
  // 构建全局上下文块(注入到每个子任务描述中,供 agent 参考)
@@ -65,7 +73,7 @@ ${globalContext}
65
73
  ]
66
74
  });
67
75
  }
68
- // 1. 为每个目标创建开发+测试任务(并行,只依赖设计任务)
76
+ // 1. 为每个目标创建任务(根据目标类型决定拆分策略)
69
77
  const devTaskIds = [];
70
78
  for (let i = 0; i < parsedTask.goals.length; i++) {
71
79
  const goal = parsedTask.goals[i];
@@ -74,46 +82,147 @@ ${globalContext}
74
82
  continue;
75
83
  }
76
84
  seenTitles.add(goal);
77
- // 创建开发任务 所有开发任务并行,仅依赖设计任务
78
- const devTaskId = this.generateTaskId();
79
- devTaskIds.push(devTaskId);
80
- const acceptanceCriteria = this.generateAcceptanceCriteria(goal, userContext);
85
+ const goalType = this.classifyGoal(goal);
86
+ const deps = designTaskId ? [designTaskId] : [];
87
+ if (goalType === 'development') {
88
+ // 开发类目标: 拆分为实现 + 测试 对
89
+ const devTaskId = this.generateTaskId();
90
+ devTaskIds.push(devTaskId);
91
+ const acceptanceCriteria = this.generateAcceptanceCriteria(goal, userContext);
92
+ breakdowns.push({
93
+ taskId: devTaskId,
94
+ title: `实现: ${goal}`,
95
+ description: this.buildTaskDescription(goal, globalContext),
96
+ priority: this.determinePriority(i),
97
+ dependencies: deps,
98
+ estimatedComplexity: this.estimateComplexity(goal),
99
+ assignedAgent: 'coder',
100
+ phase: 'develop',
101
+ acceptanceCriteria,
102
+ testTaskId: undefined
103
+ });
104
+ // 配对的测试任务
105
+ const testTaskId = this.generateTaskId();
106
+ breakdowns.push({
107
+ taskId: testTaskId,
108
+ title: `测试: ${goal}`,
109
+ description: this.buildTestDescription(goal, devTaskId, coverageTarget, globalContext),
110
+ priority: this.determinePriority(i),
111
+ dependencies: [devTaskId],
112
+ estimatedComplexity: 'medium',
113
+ assignedAgent: 'tester',
114
+ phase: 'verify',
115
+ acceptanceCriteria: [
116
+ `单元测试覆盖率 >= ${coverageTarget}%`,
117
+ '边界情况已测试',
118
+ '异常处理已验证',
119
+ '所有测试通过'
120
+ ]
121
+ });
122
+ breakdowns[breakdowns.length - 2].testTaskId = testTaskId;
123
+ }
124
+ else if (goalType === 'testing') {
125
+ // 测试类目标: 直接创建单个测试任务
126
+ const taskId = this.generateTaskId();
127
+ breakdowns.push({
128
+ taskId,
129
+ title: goal,
130
+ description: `## 测试目标\n${goal}\n\n${globalContext}\n\n## 测试要求\n- 单元测试覆盖率 >= ${coverageTarget}%\n- 测试正常流程\n- 测试边界情况\n- 测试异常处理\n\n## 输出\n- 测试文件\n- 测试报告\n- 覆盖率报告`,
131
+ priority: this.determinePriority(i),
132
+ dependencies: deps,
133
+ estimatedComplexity: 'medium',
134
+ assignedAgent: 'tester',
135
+ phase: 'verify',
136
+ acceptanceCriteria: [
137
+ `测试覆盖率 >= ${coverageTarget}%`,
138
+ '边界情况已测试',
139
+ '所有测试通过',
140
+ '测试报告已生成'
141
+ ]
142
+ });
143
+ }
144
+ else if (goalType === 'documentation') {
145
+ // 文档类目标: 直接创建单个文档任务
146
+ const taskId = this.generateTaskId();
147
+ breakdowns.push({
148
+ taskId,
149
+ title: goal,
150
+ description: `## 文档目标\n${goal}\n\n${globalContext}\n\n## 输出要求\n- 文档内容完整\n- 格式清晰\n- 示例代码可运行`,
151
+ priority: this.determinePriority(i),
152
+ dependencies: deps,
153
+ estimatedComplexity: 'low',
154
+ assignedAgent: 'executor',
155
+ phase: 'accept',
156
+ acceptanceCriteria: [
157
+ '文档内容完整',
158
+ '格式规范',
159
+ '示例可运行'
160
+ ]
161
+ });
162
+ }
163
+ else {
164
+ // 其他类型(配置、优化等): 单个任务
165
+ const taskId = this.generateTaskId();
166
+ breakdowns.push({
167
+ taskId,
168
+ title: goal,
169
+ description: `## 目标\n${goal}\n\n${globalContext}\n\n## 输出要求\n- 完成目标\n- 验证结果正确`,
170
+ priority: this.determinePriority(i),
171
+ dependencies: deps,
172
+ estimatedComplexity: this.estimateComplexity(goal),
173
+ assignedAgent: 'coder',
174
+ phase: 'develop',
175
+ acceptanceCriteria: [
176
+ `目标 "${goal}" 已完成`,
177
+ '结果已验证'
178
+ ]
179
+ });
180
+ }
181
+ }
182
+ // 2. 系统集成任务 (将所有模块组装到入口文件)
183
+ let integrationTaskId;
184
+ if (devTaskIds.length > 1) {
185
+ integrationTaskId = this.generateTaskId();
81
186
  breakdowns.push({
82
- taskId: devTaskId,
83
- title: `实现: ${goal}`,
84
- description: this.buildTaskDescription(goal, globalContext),
85
- priority: this.determinePriority(i),
86
- // 并行: 所有开发任务只依赖设计任务(如果有),互不依赖
87
- dependencies: designTaskId ? [designTaskId] : [],
88
- estimatedComplexity: this.estimateComplexity(goal),
187
+ taskId: integrationTaskId,
188
+ title: '系统集成: 将所有模块组装到主入口,确保可运行',
189
+ description: `将前面所有模块连接到主入口文件(main.ts/index.ts),使应用可以完整运行
190
+
191
+ ${globalContext}
192
+
193
+ ## 集成要求
194
+ - 在主入口文件中实例化所有核心模块
195
+ - 将子系统连接到主循环(Game/App/Main)
196
+ - 确保模块间事件/数据流通
197
+ - 确保应用可以启动并正常运行(无运行时错误)
198
+
199
+ ## 已完成的模块
200
+ ${devTaskIds.map(id => `- ${id}: ${breakdowns.find(b => b.taskId === id)?.title || ''}`).join('\n')}
201
+
202
+ ## 输出
203
+ - 更新后的主入口文件
204
+ - 模块连接正确,应用可运行
205
+ - 启动后无运行时错误`,
206
+ priority: 'P0',
207
+ dependencies: devTaskIds, // 依赖所有开发任务完成
208
+ estimatedComplexity: 'high',
89
209
  assignedAgent: 'coder',
90
210
  phase: 'develop',
91
- acceptanceCriteria,
92
- testTaskId: undefined // 稍后关联
93
- });
94
- // 为每个开发任务创建配对的测试任务
95
- const testTaskId = this.generateTaskId();
96
- breakdowns.push({
97
- taskId: testTaskId,
98
- title: `测试: ${goal}`,
99
- description: this.buildTestDescription(goal, devTaskId, coverageTarget, globalContext),
100
- priority: this.determinePriority(i),
101
- dependencies: [devTaskId], // 测试依赖对应的开发任务
102
- estimatedComplexity: 'medium',
103
- assignedAgent: 'tester',
104
- phase: 'verify',
105
211
  acceptanceCriteria: [
106
- `单元测试覆盖率 >= ${coverageTarget}%`,
107
- '边界情况已测试',
108
- '异常处理已验证',
109
- '所有测试通过'
212
+ '主入口文件已更新',
213
+ '所有核心模块已实例化并连接',
214
+ '应用可以正常启动',
215
+ '无运行时错误',
216
+ '模块间通信正常'
110
217
  ]
111
218
  });
112
- // 关联测试任务 ID
113
- breakdowns[breakdowns.length - 2].testTaskId = testTaskId;
114
219
  }
115
- // 2. 代码审查任务 (仅在有开发任务时创建)
220
+ // 3. 代码审查任务 (仅在有开发任务时创建)
116
221
  if (devTaskIds.length > 0) {
222
+ // 审查依赖所有开发任务 + 系统集成任务(如果有)
223
+ const reviewDeps = integrationTaskId
224
+ ? [...devTaskIds, integrationTaskId]
225
+ : [...devTaskIds];
117
226
  breakdowns.push({
118
227
  taskId: this.generateTaskId(),
119
228
  title: '代码审查',
@@ -130,7 +239,7 @@ ${devTaskIds.map(id => `- ${id}`).join('\n')}
130
239
  - 性能
131
240
  - 最佳实践`,
132
241
  priority: 'P1',
133
- dependencies: devTaskIds, // 审查依赖所有开发任务完成
242
+ dependencies: reviewDeps,
134
243
  estimatedComplexity: 'medium',
135
244
  assignedAgent: 'reviewer',
136
245
  phase: 'verify',
@@ -144,6 +253,9 @@ ${devTaskIds.map(id => `- ${id}`).join('\n')}
144
253
  }
145
254
  // 3. 集成测试任务 (如果有多个交付物)
146
255
  if (parsedTask.deliverables.length > 1) {
256
+ const integrationTestDeps = integrationTaskId
257
+ ? [...devTaskIds, integrationTaskId]
258
+ : [...devTaskIds];
147
259
  breakdowns.push({
148
260
  taskId: this.generateTaskId(),
149
261
  title: '集成测试',
@@ -156,7 +268,7 @@ ${globalContext}
156
268
  - 端到端流程
157
269
  - 数据流验证`,
158
270
  priority: 'P1',
159
- dependencies: devTaskIds,
271
+ dependencies: integrationTestDeps,
160
272
  estimatedComplexity: 'medium',
161
273
  assignedAgent: 'tester',
162
274
  phase: 'verify',
@@ -471,5 +583,48 @@ ${typeConfig.runCommand}
471
583
  return 'low';
472
584
  return 'medium';
473
585
  }
586
+ /**
587
+ * 分类目标类型
588
+ * - development: 需要编写代码的功能实现 → 拆分为实现+测试对
589
+ * - testing: 已明确是测试任务 → 单个测试任务
590
+ * - documentation: 文档编写 → 单个文档任务
591
+ * - other: 其他类型(配置、优化、部署等) → 单个任务
592
+ */
593
+ classifyGoal(goal) {
594
+ const g = goal.toLowerCase();
595
+ // 测试类关键词
596
+ const testKeywords = [
597
+ '测试', 'test', 'testing', 'tdd', 'e2e', 'e2e测试',
598
+ '单元测试', '集成测试', '端到端', '覆盖率', 'coverage',
599
+ 'vitest', 'jest', 'mocha', 'playwright', 'cypress',
600
+ ];
601
+ if (testKeywords.some(kw => g.includes(kw))) {
602
+ return 'testing';
603
+ }
604
+ // 文档类关键词
605
+ const docKeywords = [
606
+ '文档', 'document', 'documentation', 'readme', '说明',
607
+ '指南', 'guide', 'tutorial', 'api文档',
608
+ ];
609
+ if (docKeywords.some(kw => g.includes(kw))) {
610
+ return 'documentation';
611
+ }
612
+ // 非开发类关键词(配置、部署等)
613
+ const nonDevKeywords = [
614
+ '配置', 'config', 'deploy', '部署', 'ci/cd', '发布',
615
+ 'release', '优化', '监控', 'monitor', '日志',
616
+ ];
617
+ // 如果只包含非开发关键词而不包含开发关键词,归为 other
618
+ const devKeywords = [
619
+ '实现', '开发', '编写', '创建', '构建', '添加', '修复',
620
+ 'implement', 'develop', 'build', 'create', 'add', 'fix',
621
+ '功能', 'feature', '模块', '组件', 'component', '系统',
622
+ ];
623
+ if (nonDevKeywords.some(kw => g.includes(kw)) && !devKeywords.some(kw => g.includes(kw))) {
624
+ return 'other';
625
+ }
626
+ // 默认为开发类
627
+ return 'development';
628
+ }
474
629
  }
475
630
  exports.TaskPlanner = TaskPlanner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmatrix",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
4
4
  "description": "AI Agent task orchestration system with Claude Code Skills integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",