openmatrix 0.1.99 → 0.2.1

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.
Files changed (35) hide show
  1. package/dist/agents/impl/coder-agent.js +42 -42
  2. package/dist/agents/impl/executor-agent.js +75 -75
  3. package/dist/agents/impl/planner-agent.js +63 -63
  4. package/dist/agents/impl/reviewer-agent.js +66 -66
  5. package/dist/agents/impl/tester-agent.js +56 -56
  6. package/dist/cli/commands/report.js +45 -45
  7. package/dist/cli/commands/start.js +163 -34
  8. package/dist/cli/commands/step.js +62 -35
  9. package/dist/orchestrator/ai-reviewer.d.ts +29 -1
  10. package/dist/orchestrator/ai-reviewer.js +312 -207
  11. package/dist/orchestrator/approval-manager.js +14 -13
  12. package/dist/orchestrator/executor.d.ts +10 -1
  13. package/dist/orchestrator/executor.js +56 -2
  14. package/dist/orchestrator/meeting-manager.js +32 -31
  15. package/dist/orchestrator/phase-executor.js +7 -5
  16. package/dist/orchestrator/scheduler.d.ts +8 -6
  17. package/dist/orchestrator/scheduler.js +53 -22
  18. package/dist/orchestrator/state-machine.js +2 -2
  19. package/dist/orchestrator/task-planner.d.ts +81 -2
  20. package/dist/orchestrator/task-planner.js +683 -122
  21. package/dist/storage/state-manager.d.ts +6 -0
  22. package/dist/storage/state-manager.js +28 -0
  23. package/package.json +55 -55
  24. package/scripts/build-check.js +19 -19
  25. package/scripts/install-skills.js +57 -57
  26. package/skills/approve.md +250 -250
  27. package/skills/auto.md +298 -298
  28. package/skills/meeting.md +324 -324
  29. package/skills/om.md +112 -112
  30. package/skills/openmatrix.md +112 -112
  31. package/skills/start.md +24 -1
  32. package/dist/cli/commands/upgrade.d.ts +0 -2
  33. package/dist/cli/commands/upgrade.js +0 -329
  34. package/dist/orchestrator/task-planner.old.d.ts +0 -87
  35. package/dist/orchestrator/task-planner.old.js +0 -444
@@ -1,444 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskPlanner = void 0;
4
- /**
5
- * TaskPlanner - 任务拆解器
6
- *
7
- * 增强版特性:
8
- * 1. 更细粒度的任务拆分 (每个目标拆分为设计+实现+测试)
9
- * 2. 测试任务配对 (每个开发任务自动生成对应测试任务)
10
- * 3. 验收标准注入 (从用户回答中提取)
11
- * 4. 用户上下文注入 (将用户回答注入任务描述)
12
- * 5. 依赖关系分析 (自动分析任务间依赖)
13
- */
14
- class TaskPlanner {
15
- userAnswers;
16
- constructor(userAnswers) {
17
- this.userAnswers = userAnswers || {};
18
- }
19
- /**
20
- * 设置用户回答
21
- */
22
- setUserAnswers(answers) {
23
- this.userAnswers = answers;
24
- }
25
- /**
26
- * Break down a parsed task into sub-tasks
27
- *
28
- * 增强版: 生成更细粒度的任务,包含设计、开发、测试配对
29
- */
30
- breakdown(parsedTask, answers) {
31
- const breakdowns = [];
32
- const seenTitles = new Set();
33
- const userContext = this.extractUserContext(answers);
34
- // 0. 设计阶段任务
35
- if (parsedTask.goals.length > 1) {
36
- breakdowns.push({
37
- taskId: this.generateTaskId(),
38
- title: '架构设计和任务规划',
39
- description: `分析需求,设计整体架构,规划实现方案
40
-
41
- ## 用户需求
42
- ${userContext.objective || '未指定'}
43
-
44
- ## 技术栈
45
- ${userContext.techStack?.join(', ') || '未指定'}
46
-
47
- ## 输出
48
- - 架构设计文档
49
- - 接口定义
50
- - 任务依赖图`,
51
- priority: 'P0',
52
- dependencies: [],
53
- estimatedComplexity: 'high',
54
- assignedAgent: 'planner',
55
- phase: 'design',
56
- acceptanceCriteria: [
57
- '架构设计文档完整',
58
- '所有模块接口已定义',
59
- '依赖关系明确',
60
- '技术方案可行'
61
- ]
62
- });
63
- }
64
- // 1. 为每个目标创建细粒度任务
65
- const devTaskIds = [];
66
- for (let i = 0; i < parsedTask.goals.length; i++) {
67
- const goal = parsedTask.goals[i];
68
- // 跳过重复项
69
- if (seenTitles.has(goal)) {
70
- continue;
71
- }
72
- seenTitles.add(goal);
73
- // 创建开发任务
74
- const devTaskId = this.generateTaskId();
75
- devTaskIds.push(devTaskId);
76
- const acceptanceCriteria = this.generateAcceptanceCriteria(goal, userContext);
77
- breakdowns.push({
78
- taskId: devTaskId,
79
- title: `实现: ${goal}`,
80
- description: this.buildTaskDescription(goal, userContext, answers),
81
- priority: this.determinePriority(i),
82
- dependencies: i === 0 && parsedTask.goals.length > 1
83
- ? [breakdowns[0].taskId] // 依赖设计任务
84
- : (i > 0 ? [devTaskIds[i - 1]] : []), // 依赖前一个开发任务
85
- estimatedComplexity: this.estimateComplexity(goal),
86
- assignedAgent: 'coder',
87
- phase: 'develop',
88
- acceptanceCriteria,
89
- testTaskId: undefined // 稍后关联
90
- });
91
- // 为每个开发任务创建配对的测试任务
92
- const testTaskId = this.generateTaskId();
93
- breakdowns.push({
94
- taskId: testTaskId,
95
- title: `测试: ${goal}`,
96
- description: this.buildTestDescription(goal, devTaskId, userContext),
97
- priority: this.determinePriority(i),
98
- dependencies: [devTaskId], // 测试依赖开发任务
99
- estimatedComplexity: 'medium',
100
- assignedAgent: 'tester',
101
- phase: 'verify',
102
- acceptanceCriteria: [
103
- `单元测试覆盖率 >= ${userContext.testCoverage || '60%'}`,
104
- '边界情况已测试',
105
- '异常处理已验证',
106
- '所有测试通过'
107
- ]
108
- });
109
- // 关联测试任务 ID
110
- breakdowns[breakdowns.length - 2].testTaskId = testTaskId;
111
- }
112
- // 2. 代码审查任务 (仅在有开发任务时创建)
113
- if (devTaskIds.length > 0) {
114
- breakdowns.push({
115
- taskId: this.generateTaskId(),
116
- title: '代码审查',
117
- description: `对所有开发任务进行代码审查
118
-
119
- ## 审查范围
120
- ${devTaskIds.map(id => `- ${id}`).join('\n')}
121
-
122
- ## 审查要点
123
- - 代码质量
124
- - 安全性
125
- - 性能
126
- - 最佳实践`,
127
- priority: 'P1',
128
- dependencies: devTaskIds,
129
- estimatedComplexity: 'medium',
130
- assignedAgent: 'reviewer',
131
- phase: 'verify',
132
- acceptanceCriteria: [
133
- '无严重代码问题',
134
- '无安全隐患',
135
- '代码符合规范',
136
- '审查报告已生成'
137
- ]
138
- });
139
- }
140
- // 3. 集成测试任务 (如果有多个交付物)
141
- if (parsedTask.deliverables.length > 1) {
142
- breakdowns.push({
143
- taskId: this.generateTaskId(),
144
- title: '集成测试',
145
- description: `验证所有交付物正确集成
146
-
147
- ## 交付物
148
- ${parsedTask.deliverables.map(d => `- ${d}`).join('\n')}
149
-
150
- ## 测试范围
151
- - 模块间接口
152
- - 端到端流程
153
- - 数据流验证`,
154
- priority: 'P1',
155
- dependencies: devTaskIds,
156
- estimatedComplexity: 'medium',
157
- assignedAgent: 'tester',
158
- phase: 'verify',
159
- acceptanceCriteria: [
160
- '所有模块正确集成',
161
- '端到端流程通过',
162
- '接口兼容性验证',
163
- '集成测试报告完整'
164
- ]
165
- });
166
- }
167
- // 4. E2E 测试任务 (如果启用,作为 verify 阶段的一部分)
168
- if (userContext.e2eTests) {
169
- const e2eTaskId = this.generateTaskId();
170
- const e2eType = userContext.e2eType || 'web';
171
- // E2E 测试依赖所有开发任务和单元测试任务
172
- const allTestDependencies = [...devTaskIds];
173
- breakdowns.forEach(b => {
174
- if (b.phase === 'verify' && b.title.startsWith('测试:')) {
175
- allTestDependencies.push(b.taskId);
176
- }
177
- });
178
- breakdowns.push({
179
- taskId: e2eTaskId,
180
- title: '端到端(E2E)测试',
181
- description: this.buildE2ETestDescription(e2eType, parsedTask, userContext),
182
- priority: 'P0', // E2E 测试是关键任务
183
- dependencies: allTestDependencies, // 依赖所有开发任务和单元测试
184
- estimatedComplexity: 'high',
185
- assignedAgent: 'tester',
186
- phase: 'verify',
187
- acceptanceCriteria: [
188
- '所有 E2E 测试用例通过',
189
- '关键用户流程验证完成',
190
- '跨浏览器/设备兼容性验证',
191
- 'E2E 测试报告已生成',
192
- '无阻塞级别的缺陷'
193
- ]
194
- });
195
- }
196
- // 5. 文档任务 (如果需要)
197
- if (userContext.documentationLevel && userContext.documentationLevel !== '无需文档') {
198
- breakdowns.push({
199
- taskId: this.generateTaskId(),
200
- title: '文档编写',
201
- description: `编写项目文档
202
-
203
- ## 文档级别
204
- ${userContext.documentationLevel}
205
-
206
- ## 文档内容
207
- - README 更新
208
- - API 文档
209
- - 使用说明`,
210
- priority: 'P2',
211
- dependencies: devTaskIds,
212
- estimatedComplexity: 'low',
213
- assignedAgent: 'executor',
214
- phase: 'accept',
215
- acceptanceCriteria: [
216
- 'README 已更新',
217
- 'API 文档完整',
218
- '使用说明清晰'
219
- ]
220
- });
221
- }
222
- return breakdowns;
223
- }
224
- /**
225
- * 提取用户上下文
226
- */
227
- extractUserContext(answers) {
228
- const e2eAnswer = answers['E2E测试'] || answers['e2eTests'] || answers['e2e'];
229
- const e2eTypeAnswer = answers['E2E类型'] || answers['e2eType'];
230
- return {
231
- objective: answers['目标'] || answers['objective'],
232
- techStack: this.parseArrayAnswer(answers['技术栈'] || answers['techStack']),
233
- testCoverage: answers['测试'] || answers['testCoverage'],
234
- documentationLevel: answers['文档'] || answers['documentationLevel'],
235
- e2eTests: e2eAnswer === 'true' || e2eAnswer === '✅ 启用 E2E 测试' || e2eAnswer === '是',
236
- e2eType: e2eTypeAnswer || 'web',
237
- additionalContext: answers
238
- };
239
- }
240
- /**
241
- * 解析数组类型的回答
242
- */
243
- parseArrayAnswer(answer) {
244
- if (!answer)
245
- return [];
246
- // 处理逗号分隔或换行分隔的答案
247
- return answer.split(/[,,\n]/).map(s => s.trim()).filter(Boolean);
248
- }
249
- /**
250
- * 构建任务描述 (注入用户上下文)
251
- */
252
- buildTaskDescription(goal, userContext, answers) {
253
- const parts = [];
254
- parts.push(`## 任务目标\n${goal}\n`);
255
- if (userContext.objective) {
256
- parts.push(`## 整体目标\n${userContext.objective}\n`);
257
- }
258
- if (userContext.techStack && userContext.techStack.length > 0) {
259
- parts.push(`## 技术栈要求\n${userContext.techStack.map(t => `- ${t}`).join('\n')}\n`);
260
- }
261
- // 注入所有用户回答
262
- const relevantAnswers = Object.entries(answers).filter(([key]) => !['目标', '技术栈', '测试', '文档', 'objective', 'techStack', 'testCoverage', 'documentationLevel'].includes(key));
263
- if (relevantAnswers.length > 0) {
264
- parts.push(`## 其他要求\n${relevantAnswers.map(([k, v]) => `- ${k}: ${v}`).join('\n')}\n`);
265
- }
266
- parts.push(`## 输出要求
267
- - 完成功能实现
268
- - 代码可编译
269
- - 遵循项目规范
270
- - 添加必要注释`);
271
- return parts.join('\n');
272
- }
273
- /**
274
- * 构建测试任务描述
275
- */
276
- buildTestDescription(goal, devTaskId, userContext) {
277
- const coverage = this.parseCoverage(userContext.testCoverage || '60%');
278
- return `## 测试目标
279
- 为 "${goal}" 编写测试用例
280
-
281
- ## 关联开发任务
282
- ${devTaskId}
283
-
284
- ## 测试要求
285
- - 单元测试覆盖率 >= ${coverage}%
286
- - 测试正常流程
287
- - 测试边界情况
288
- - 测试异常处理
289
-
290
- ## 测试文件
291
- - 创建 \`.test.ts\` 或 \`.spec.ts\` 文件
292
- - 放置在与源文件相同目录或 \`tests/\` 目录
293
-
294
- ## 输出
295
- - 测试文件
296
- - 测试报告
297
- - 覆盖率报告`;
298
- }
299
- /**
300
- * 构建 E2E 测试任务描述
301
- */
302
- buildE2ETestDescription(e2eType, parsedTask, userContext) {
303
- const typeConfig = this.getE2ETypeConfig(e2eType);
304
- return `## E2E 测试目标
305
- 执行完整的端到端测试,验证关键用户流程
306
-
307
- ## 应用类型
308
- ${typeConfig.description}
309
-
310
- ## 测试框架
311
- ${typeConfig.frameworks.map(f => `- ${f}`).join('\n')}
312
-
313
- ## 测试范围
314
- ${parsedTask.goals.map((g, i) => `${i + 1}. ${g}`).join('\n')}
315
-
316
- ## 关键用户流程
317
- 根据应用功能,测试以下流程:
318
- ${this.generateUserFlows(parsedTask, e2eType)}
319
-
320
- ## 测试环境
321
- ${typeConfig.environments.map(e => `- ${e}`).join('\n')}
322
-
323
- ## 测试要求
324
- 1. **关键路径覆盖**: 所有核心用户流程必须有 E2E 测试
325
- 2. **断言完整**: 每个测试步骤必须有明确的断言
326
- 3. **等待策略**: 使用合理的等待机制,避免硬编码延迟
327
- 4. **数据隔离**: 测试数据独立,不影响其他测试
328
- 5. **清理机制**: 测试后清理创建的数据
329
-
330
- ## 输出要求
331
- - E2E 测试文件 (tests/e2e/*.spec.ts)
332
- - 测试执行报告
333
- - 截图/录像 (失败时)
334
- - 测试覆盖率报告 (如有)
335
-
336
- ## 运行命令
337
- \`\`\`bash
338
- ${typeConfig.runCommand}
339
- \`\`\`
340
-
341
- ## 验收标准
342
- - [ ] 所有 E2E 测试用例通过
343
- - [ ] 关键用户流程验证完成
344
- - [ ] 跨浏览器/设备兼容性验证
345
- - [ ] E2E 测试报告已生成
346
- - [ ] 无阻塞级别的缺陷`;
347
- }
348
- /**
349
- * 获取 E2E 测试类型配置
350
- */
351
- getE2ETypeConfig(type) {
352
- const configs = {
353
- web: {
354
- description: 'Web 应用 (浏览器)',
355
- frameworks: ['Playwright (推荐)', 'Cypress', 'Selenium WebDriver', 'Puppeteer'],
356
- environments: ['Chrome', 'Firefox', 'Safari', 'Edge', 'Mobile Viewports'],
357
- runCommand: 'npx playwright test --reporter=html'
358
- },
359
- mobile: {
360
- description: '移动应用 (iOS/Android)',
361
- frameworks: ['Appium', 'Detox (React Native)', 'XCUITest (iOS)', 'Espresso (Android)'],
362
- environments: ['iOS Simulator', 'Android Emulator', 'Real Devices'],
363
- runCommand: 'npx appium --base-path /wd/hub && npm run test:e2e'
364
- },
365
- gui: {
366
- description: 'GUI 桌面应用 (Electron/Native)',
367
- frameworks: ['Playwright for Electron', 'Spectron (Electron)', 'Robot Framework', 'PyAutoGUI'],
368
- environments: ['Windows', 'macOS', 'Linux'],
369
- runCommand: 'npm run test:e2e'
370
- }
371
- };
372
- return configs[type];
373
- }
374
- /**
375
- * 生成用户流程测试用例
376
- */
377
- generateUserFlows(parsedTask, type) {
378
- const flows = [];
379
- const goals = parsedTask.goals;
380
- // 根据目标生成用户流程
381
- goals.forEach((goal, i) => {
382
- flows.push(`\n### 流程 ${i + 1}: ${goal}`);
383
- flows.push('```gherkin');
384
- flows.push(`Feature: ${goal}`);
385
- flows.push('');
386
- flows.push(' Scenario: 正常流程');
387
- flows.push(` Given 用户已启动应用`);
388
- flows.push(` When 用户执行 "${goal}" 操作`);
389
- flows.push(` Then 操作成功完成`);
390
- flows.push('```');
391
- });
392
- return flows.join('\n');
393
- }
394
- /**
395
- * 解析覆盖率数值
396
- */
397
- parseCoverage(coverageStr) {
398
- const match = coverageStr.match(/(\d+)/);
399
- return match ? parseInt(match[1], 10) : 60;
400
- }
401
- /**
402
- * 生成验收标准
403
- */
404
- generateAcceptanceCriteria(goal, userContext) {
405
- const criteria = [
406
- `功能 "${goal}" 已实现`,
407
- '代码可编译,无错误',
408
- '代码符合项目规范',
409
- '必要的注释已添加'
410
- ];
411
- if (userContext.testCoverage) {
412
- criteria.push(`测试覆盖率 >= ${userContext.testCoverage}`);
413
- }
414
- if (userContext.techStack?.length) {
415
- criteria.push(`使用指定技术栈: ${userContext.techStack.join(', ')}`);
416
- }
417
- criteria.push('无安全隐患');
418
- criteria.push('边界情况已处理');
419
- return criteria;
420
- }
421
- generateTaskId() {
422
- const timestamp = Date.now().toString(36).toUpperCase();
423
- const rand = Math.random().toString(36).slice(2, 4).toUpperCase();
424
- return `TASK-${timestamp}${rand}`;
425
- }
426
- determinePriority(goalIndex) {
427
- // First goal is highest priority
428
- if (goalIndex === 0)
429
- return 'P1';
430
- return 'P2';
431
- }
432
- estimateComplexity(goal) {
433
- if (goal.includes('测试'))
434
- return 'medium';
435
- if (goal.includes('实现') || goal.includes('开发'))
436
- return 'medium';
437
- if (goal.includes('设计') || goal.includes('研究'))
438
- return 'high';
439
- if (goal.includes('文档') || goal.includes('说明'))
440
- return 'low';
441
- return 'medium';
442
- }
443
- }
444
- exports.TaskPlanner = TaskPlanner;