openmatrix 0.2.29 → 0.2.31
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.
- package/dist/cli/commands/install-skills.js +19 -0
- package/dist/cli/commands/start.js +13 -2
- package/dist/orchestrator/executor.js +19 -8
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/scripts/install-skills.js +28 -0
- package/skills/SKILL.md +54 -0
- package/skills/start.md +86 -8
|
@@ -146,6 +146,25 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
// Install SKILL.md for MatrixCode (skill package manifest)
|
|
150
|
+
if (target.name === 'MatrixCode') {
|
|
151
|
+
const skillManifestSrc = path.join(skillsDir, 'SKILL.md');
|
|
152
|
+
const skillManifestDest = path.join(target.dir, 'SKILL.md');
|
|
153
|
+
if (fs.existsSync(skillManifestSrc)) {
|
|
154
|
+
try {
|
|
155
|
+
if (fs.existsSync(skillManifestDest) && !options.force) {
|
|
156
|
+
skipped++;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
fs.copyFileSync(skillManifestSrc, skillManifestDest);
|
|
160
|
+
installed++;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
failed++;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
149
168
|
console.log(` ✅ Installed: ${installed}`);
|
|
150
169
|
console.log(` ⏭️ Skipped: ${skipped}`);
|
|
151
170
|
if (failed > 0) {
|
|
@@ -61,6 +61,8 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
61
61
|
.option('--e2e-tests', '启用 E2E 测试')
|
|
62
62
|
.option('--e2e-type <type>', 'E2E 测试类型 (web|visual)')
|
|
63
63
|
.option('--research-context <path>', '研究上下文 JSON 路径 (来自 /om:research 的 context.json)')
|
|
64
|
+
.option('--parallel', '多 Agent 并行执行 (推荐,速度快)')
|
|
65
|
+
.option('--single-agent', '单 Agent 串行执行 (上下文连贯)')
|
|
64
66
|
.action(async (input, options) => {
|
|
65
67
|
const basePath = process.cwd();
|
|
66
68
|
const omPath = path.join(basePath, '.openmatrix');
|
|
@@ -326,13 +328,19 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
|
|
|
326
328
|
// 解析执行模式
|
|
327
329
|
const executionMode = tasksInput.mode || options.mode || 'confirm-key';
|
|
328
330
|
const approvalPoints = resolveApprovalPoints(executionMode);
|
|
331
|
+
// 解析 Agent 执行模式
|
|
332
|
+
const agentMode = options.singleAgent ? 'single' : 'parallel';
|
|
333
|
+
// 更新 maxConcurrentAgents(单 Agent = 1,多 Agent = 3)
|
|
334
|
+
const maxConcurrent = agentMode === 'single' ? 1 : 3;
|
|
329
335
|
await stateManager.updateState({
|
|
330
336
|
status: 'running',
|
|
331
337
|
currentPhase: 'execution',
|
|
332
338
|
config: {
|
|
333
339
|
...state.config,
|
|
334
340
|
approvalPoints: approvalPoints,
|
|
335
|
-
quality: qualityConfig
|
|
341
|
+
quality: qualityConfig,
|
|
342
|
+
agentMode,
|
|
343
|
+
maxConcurrentAgents: maxConcurrent
|
|
336
344
|
}
|
|
337
345
|
});
|
|
338
346
|
// 创建审批请求(如果有审批点)
|
|
@@ -394,7 +402,9 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
|
|
|
394
402
|
title: resolvedInput.title,
|
|
395
403
|
description: resolvedInput.description,
|
|
396
404
|
quality: qualityLevel,
|
|
397
|
-
domain: researchContext?.domain
|
|
405
|
+
domain: researchContext?.domain,
|
|
406
|
+
agentMode,
|
|
407
|
+
maxConcurrent
|
|
398
408
|
}
|
|
399
409
|
}));
|
|
400
410
|
}
|
|
@@ -402,6 +412,7 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
|
|
|
402
412
|
console.log(`\n📋 ${resolvedInput.title} - ${subTasks.length} 个子任务已创建`);
|
|
403
413
|
console.log(`🎯 执行模式:${executionMode}`);
|
|
404
414
|
console.log(` 质量级别:${qualityLevel}`);
|
|
415
|
+
console.log(` Agent 模式:${agentMode === 'parallel' ? '多 Agent 并行' : '单 Agent 串行'}`);
|
|
405
416
|
console.log('\n🚀 等待 Skill 执行任务...');
|
|
406
417
|
console.log(' 使用 /om:status 查看进度');
|
|
407
418
|
}
|
|
@@ -39,14 +39,7 @@ class OrchestratorExecutor {
|
|
|
39
39
|
...config
|
|
40
40
|
};
|
|
41
41
|
this._configReady = this.loadConfigFromState(stateManager);
|
|
42
|
-
|
|
43
|
-
maxConcurrentTasks: this.config.maxConcurrent,
|
|
44
|
-
taskTimeout: this.config.taskTimeout
|
|
45
|
-
});
|
|
46
|
-
this.agentRunner = new agent_runner_js_1.AgentRunner(stateManager, approvalManager, {
|
|
47
|
-
maxConcurrent: this.config.maxConcurrent,
|
|
48
|
-
taskTimeout: this.config.taskTimeout
|
|
49
|
-
});
|
|
42
|
+
// scheduler 和 agentRunner 在 loadConfigFromState 中根据 state.config 初始化
|
|
50
43
|
this.stateMachine = new state_machine_js_1.StateMachine();
|
|
51
44
|
this.phaseExecutor = new phase_executor_js_1.PhaseExecutor(stateManager, approvalManager);
|
|
52
45
|
this.retryManager = new retry_manager_js_1.RetryManager();
|
|
@@ -64,10 +57,28 @@ class OrchestratorExecutor {
|
|
|
64
57
|
if (state.config?.taskTimeout) {
|
|
65
58
|
this.config.taskTimeout = state.config.taskTimeout;
|
|
66
59
|
}
|
|
60
|
+
// 只有在 state.config 中有明确的 agentMode 时才更新并发数
|
|
61
|
+
// 否则使用传入的 config.maxConcurrent
|
|
62
|
+
if (state.config?.agentMode === 'single') {
|
|
63
|
+
this.config.maxConcurrent = 1;
|
|
64
|
+
}
|
|
65
|
+
else if (state.config?.maxConcurrentAgents && state.config?.maxConcurrentAgents !== 3) {
|
|
66
|
+
// 只有当 maxConcurrentAgents 不是默认值 3 时才更新
|
|
67
|
+
this.config.maxConcurrent = state.config.maxConcurrentAgents;
|
|
68
|
+
}
|
|
67
69
|
}
|
|
68
70
|
catch {
|
|
69
71
|
// use default config
|
|
70
72
|
}
|
|
73
|
+
// 初始化 scheduler 和 agentRunner(使用最终配置)
|
|
74
|
+
this.scheduler = new scheduler_js_1.Scheduler(this.stateManager, {
|
|
75
|
+
maxConcurrentTasks: this.config.maxConcurrent,
|
|
76
|
+
taskTimeout: this.config.taskTimeout
|
|
77
|
+
});
|
|
78
|
+
this.agentRunner = new agent_runner_js_1.AgentRunner(this.stateManager, this.approvalManager, {
|
|
79
|
+
maxConcurrent: this.config.maxConcurrent,
|
|
80
|
+
taskTimeout: this.config.taskTimeout
|
|
81
|
+
});
|
|
71
82
|
}
|
|
72
83
|
/**
|
|
73
84
|
* 执行一步 - 返回待执行的 Subagent 任务
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -16,10 +16,12 @@ const targets = [
|
|
|
16
16
|
{
|
|
17
17
|
name: 'Claude Code',
|
|
18
18
|
dir: path.join(os.homedir(), '.claude', 'commands', 'om'),
|
|
19
|
+
isClaudeCode: true,
|
|
19
20
|
},
|
|
20
21
|
{
|
|
21
22
|
name: 'OpenCode',
|
|
22
23
|
dir: path.join(os.homedir(), '.config', 'opencode', 'commands', 'om'),
|
|
24
|
+
isClaudeCode: false,
|
|
23
25
|
},
|
|
24
26
|
];
|
|
25
27
|
|
|
@@ -33,6 +35,7 @@ if (fs.existsSync(matrixDir)) {
|
|
|
33
35
|
targets.push({
|
|
34
36
|
name: 'MatrixCode',
|
|
35
37
|
dir: matrixSkillsDir,
|
|
38
|
+
isMatrixCode: true,
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -62,6 +65,31 @@ for (const target of targets) {
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
// For Claude Code: install om.md and openmatrix.md to parent directory
|
|
69
|
+
if (target.isClaudeCode) {
|
|
70
|
+
const claudeCommandsDir = path.join(os.homedir(), '.claude', 'commands');
|
|
71
|
+
const omSrc = path.join(skillsDir, 'om.md');
|
|
72
|
+
const omDest = path.join(claudeCommandsDir, 'om.md');
|
|
73
|
+
if (fs.existsSync(omSrc)) {
|
|
74
|
+
try {
|
|
75
|
+
fs.copyFileSync(omSrc, omDest);
|
|
76
|
+
installed++;
|
|
77
|
+
} catch (copyErr) {
|
|
78
|
+
console.log(` ⚠️ Skipped: om.md (${copyErr.message})`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const autoSrc = path.join(skillsDir, 'openmatrix.md');
|
|
82
|
+
const autoDest = path.join(claudeCommandsDir, 'openmatrix.md');
|
|
83
|
+
if (fs.existsSync(autoSrc)) {
|
|
84
|
+
try {
|
|
85
|
+
fs.copyFileSync(autoSrc, autoDest);
|
|
86
|
+
installed++;
|
|
87
|
+
} catch (copyErr) {
|
|
88
|
+
console.log(` ⚠️ Skipped: openmatrix.md (${copyErr.message})`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
65
93
|
console.log(`✅ ${target.name}: ${installed} skills installed to ${target.dir}`);
|
|
66
94
|
} catch (err) {
|
|
67
95
|
console.log(`⚠️ ${target.name}: skipped (${err.message})`);
|
package/skills/SKILL.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: om
|
|
3
|
+
description: "OpenMatrix - AI Agent 任务编排系统,自动化测试生成,覆盖率 >80%。提供 /om 命令族:/om:start、/om:feature、/om:brainstorm、/om:auto、/om:debug 等。"
|
|
4
|
+
priority: critical
|
|
5
|
+
always_load: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# OpenMatrix Skills Package
|
|
9
|
+
|
|
10
|
+
你的代码没测试?OpenMatrix 自动帮你补,覆盖率 >80%
|
|
11
|
+
|
|
12
|
+
## 可用 Skills
|
|
13
|
+
|
|
14
|
+
| Skill | 描述 | 用途 |
|
|
15
|
+
|-------|------|------|
|
|
16
|
+
| `/om` | 默认入口 | AI 推荐路由,用户确认后执行 |
|
|
17
|
+
| `/om:start` | 标准流程 | 完整追踪,质量门禁,任务明确可直接执行 |
|
|
18
|
+
| `/om:feature` | 小需求流程 | 2-5 个任务块,轻量追踪,适合单一改动点 |
|
|
19
|
+
| `/om:brainstorm` | 澄清/设计 | 先澄清不明确点或设计方案,再执行 |
|
|
20
|
+
| `/om:auto` | 全自动执行 | 零交互,无审批,适合批量任务 |
|
|
21
|
+
| `/om:debug` | 系统化调试 | 问题诊断,根因分析 |
|
|
22
|
+
| `/om:status` | 查看状态 | 任务执行进度 |
|
|
23
|
+
| `/om:meeting` | 处理阻塞 | 处理 blocked 任务 |
|
|
24
|
+
| `/om:report` | 生成报告 | 执行报告生成 |
|
|
25
|
+
| `/om:resume` | 恢复任务 | 恢复中断的任务 |
|
|
26
|
+
| `/om:research` | 领域调研 | 技术方案调研 |
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
/om 实现用户登录功能
|
|
32
|
+
|
|
33
|
+
# AI 分析任务 → 推荐路由 → 用户确认 → 执行
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 质量门禁
|
|
37
|
+
|
|
38
|
+
| 模式 | TDD | 覆盖率 | Lint | 安全扫描 |
|
|
39
|
+
|------|:---:|:------:|:----:|:--------:|
|
|
40
|
+
| 严格模式 | Y | >80% | Y | Y |
|
|
41
|
+
| 平衡模式 | N | >60% | Y | Y |
|
|
42
|
+
| 快速模式 | N | 无 | N | N |
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g openmatrix
|
|
48
|
+
openmatrix install-skills
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 文档
|
|
52
|
+
|
|
53
|
+
- GitHub: https://github.com/bigfish1913/openmatrix
|
|
54
|
+
- NPM: https://www.npmjs.com/package/openmatrix
|
package/skills/start.md
CHANGED
|
@@ -286,6 +286,70 @@ AskUserQuestion: `header: "E2E 测试"`, `multiSelect: false`
|
|
|
286
286
|
| `视觉验证` | 需要浏览器可视化验证,可检查页面样式和布局 |
|
|
287
287
|
| `不需要` | 仅进行单元测试和集成测试,节省时间 |
|
|
288
288
|
|
|
289
|
+
#### 5.3 Agent 执行模式(所有任务类型都需要选择)
|
|
290
|
+
|
|
291
|
+
**Agent 执行模式决定任务如何分配和执行,是影响效率的关键决策。**
|
|
292
|
+
|
|
293
|
+
AskUserQuestion: `header: "Agent 模式"`, `multiSelect: false`
|
|
294
|
+
|
|
295
|
+
**question:** 选择 Agent 执行模式(决定任务如何分配和执行)
|
|
296
|
+
|
|
297
|
+
| label | description |
|
|
298
|
+
|-------|-------------|
|
|
299
|
+
| `多 Agent 并行 (推荐)` | 多个 Agent 同时执行独立任务,速度快,适合任务边界清晰的项目 |
|
|
300
|
+
| `单 Agent 串行` | 一个 Agent 顺序执行所有任务,上下文连贯,适合复杂依赖任务 |
|
|
301
|
+
|
|
302
|
+
**两种模式的详细对比:**
|
|
303
|
+
|
|
304
|
+
| 特性 | 多 Agent 并行 | 单 Agent 串行 |
|
|
305
|
+
|-----|--------------|--------------|
|
|
306
|
+
| **执行速度** | ⚡ 快(并行执行) | 🐢 慢(顺序执行) |
|
|
307
|
+
| **上下文连贯性** | ⚠️ 可能不连贯 | ✅ 完全连贯 |
|
|
308
|
+
| **决策一致性** | ⚠️ 各 Agent 可能不同 | ✅ 单一决策者 |
|
|
309
|
+
| **任务独立性** | ✅ 失败不影响其他 | ❌ 一个失败可能阻塞后续 |
|
|
310
|
+
| **内存占用** | ⚠️ 较高(多个进程) | ✅ 较低(单进程) |
|
|
311
|
+
| **依赖处理** | ⚠️ 需要等待依赖完成 | ✅ 自动处理依赖 |
|
|
312
|
+
| **调试难度** | ⚠️ 多 Agent 日志分散 | ✅ 单一日志流 |
|
|
313
|
+
| **适用场景** | 任务边界清晰、无复杂依赖 | 任务间强依赖、需要全局视角 |
|
|
314
|
+
|
|
315
|
+
**推荐选择指南:**
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
任务特点判断流程:
|
|
319
|
+
|
|
320
|
+
┌─────────────────────────────────────┐
|
|
321
|
+
│ 任务之间是否有强依赖关系? │
|
|
322
|
+
│ (例如: 任务B 需要 任务A 的产出) │
|
|
323
|
+
└──────────────┬──────────────────────┘
|
|
324
|
+
│
|
|
325
|
+
┌──────┴──────┐
|
|
326
|
+
│ │
|
|
327
|
+
有依赖 无依赖
|
|
328
|
+
│ │
|
|
329
|
+
▼ ▼
|
|
330
|
+
单 Agent 多 Agent
|
|
331
|
+
串行模式 并行模式
|
|
332
|
+
│ │
|
|
333
|
+
│ │
|
|
334
|
+
┌────┴────┐ ┌────┴────┐
|
|
335
|
+
│ │ │ │
|
|
336
|
+
│ 上下文 │ │ 速度快 │
|
|
337
|
+
│ 连贯 │ │ 效率高 │
|
|
338
|
+
│ 决策一致 │ │ 独立性 │
|
|
339
|
+
└──────────┘ └──────────┘
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**典型场景推荐:**
|
|
343
|
+
|
|
344
|
+
| 场景 | 推荐 | 理由 |
|
|
345
|
+
|-----|------|------|
|
|
346
|
+
| 重构模块结构 | 单 Agent | 需要全局视角,任务间强关联 |
|
|
347
|
+
| 添加多个独立 API | 多 Agent | 任务独立,并行效率高 |
|
|
348
|
+
| 实现完整功能流程 | 单 Agent | 有上下文依赖,需要连贯决策 |
|
|
349
|
+
| 批量修复多个 bug | 多 Agent | 各 bug 独立,可并行 |
|
|
350
|
+
| 从零搭建系统 | 单 Agent | 架构决策需要一致性 |
|
|
351
|
+
| 添加多个测试文件 | 多 Agent | 测试文件独立,并行快 |
|
|
352
|
+
|
|
289
353
|
#### 执行模式自动推断
|
|
290
354
|
|
|
291
355
|
**执行模式不再通过问答选择,而是根据质量等级自动推断:**
|
|
@@ -336,7 +400,7 @@ Goals:
|
|
|
336
400
|
|
|
337
401
|
**CLI 自动从当前 runId 目录读取 tasks-input.json 和 plan.md。**
|
|
338
402
|
|
|
339
|
-
|
|
403
|
+
**根据质量等级和 Agent 模式自动设置执行参数:**
|
|
340
404
|
|
|
341
405
|
| 质量等级 | CLI 参数 | 执行方式 |
|
|
342
406
|
|---------|---------|---------|
|
|
@@ -344,29 +408,43 @@ Goals:
|
|
|
344
408
|
| 平衡模式 | `--quality balanced --mode auto` | 先开发后测试 |
|
|
345
409
|
| 快速模式 | `--quality fast --mode auto` | 直接开发 |
|
|
346
410
|
|
|
347
|
-
|
|
411
|
+
| Agent 模式 | CLI 参数 | 执行方式 |
|
|
412
|
+
|-----------|---------|---------|
|
|
413
|
+
| 多 Agent 并行 | `--parallel` | 多个 Agent 同时执行 |
|
|
414
|
+
| 单 Agent 串行 | `--single-agent` | 一个 Agent 顺序执行 |
|
|
415
|
+
|
|
416
|
+
**开发任务**(有质量等级 + Agent 模式选择):
|
|
417
|
+
|
|
348
418
|
```bash
|
|
349
|
-
|
|
419
|
+
# 多 Agent 并行模式(默认推荐)
|
|
420
|
+
openmatrix start --tasks-json @tasks-input.json --quality <质量等级> --mode auto --parallel --json
|
|
421
|
+
|
|
422
|
+
# 单 Agent 串行模式
|
|
423
|
+
openmatrix start --tasks-json @tasks-input.json --quality <质量等级> --mode auto --single-agent --json
|
|
350
424
|
```
|
|
351
425
|
|
|
352
426
|
如果存在研究上下文(`.openmatrix/{runId}/research/context.json`),增加 `--research-context` 参数:
|
|
353
427
|
```bash
|
|
354
|
-
openmatrix start --tasks-json @tasks-input.json --research-context @research/context.json --quality <质量等级> --mode auto --json
|
|
428
|
+
openmatrix start --tasks-json @tasks-input.json --research-context @research/context.json --quality <质量等级> --mode auto --parallel --json
|
|
355
429
|
```
|
|
356
430
|
|
|
357
431
|
如果启用了 E2E 测试(功能测试),加上 `--e2e-tests`:
|
|
358
432
|
```bash
|
|
359
|
-
openmatrix start --tasks-json @tasks-input.json --quality strict --mode auto --e2e-tests --json
|
|
433
|
+
openmatrix start --tasks-json @tasks-input.json --quality strict --mode auto --parallel --e2e-tests --json
|
|
360
434
|
```
|
|
361
435
|
|
|
362
436
|
如果选择了视觉验证,加上 `--e2e-tests --e2e-type visual`:
|
|
363
437
|
```bash
|
|
364
|
-
openmatrix start --tasks-json @tasks-input.json --quality strict --mode auto --e2e-tests --e2e-type visual --json
|
|
438
|
+
openmatrix start --tasks-json @tasks-input.json --quality strict --mode auto --parallel --e2e-tests --e2e-type visual --json
|
|
365
439
|
```
|
|
366
440
|
|
|
367
|
-
|
|
441
|
+
**非开发任务**(无质量等级,但需要 Agent 模式选择):
|
|
368
442
|
```bash
|
|
369
|
-
|
|
443
|
+
# 多 Agent 并行模式
|
|
444
|
+
openmatrix start --tasks-json @tasks-input.json --mode auto --parallel --json
|
|
445
|
+
|
|
446
|
+
# 单 Agent 串行模式
|
|
447
|
+
openmatrix start --tasks-json @tasks-input.json --mode auto --single-agent --json
|
|
370
448
|
```
|
|
371
449
|
|
|
372
450
|
**注意**: `@tasks-input.json` 表示 CLI 自动从当前 runId 目录读取。CLI 会自动检测 `current.json` 定位 runId。
|