openmatrix 0.2.31 → 0.2.34
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/README.md +154 -154
- package/dist/cli/commands/approve.js +35 -1
- package/dist/cli/commands/auto.js +2 -2
- package/dist/cli/commands/check-gitignore.js +34 -30
- package/dist/cli/commands/check.js +1 -1
- package/dist/cli/commands/complete.js +35 -7
- package/dist/cli/commands/debug.js +2 -1
- package/dist/cli/commands/deploy.js +1 -1
- package/dist/cli/commands/install-skills.js +3 -0
- package/dist/cli/commands/meeting.js +37 -1
- package/dist/cli/commands/report.js +1 -1
- package/dist/cli/commands/resume.js +35 -1
- package/dist/cli/commands/retry.js +130 -56
- package/dist/cli/commands/start.js +1 -1
- package/dist/cli/commands/status.js +32 -29
- package/dist/cli/commands/step.js +4 -1
- package/dist/orchestrator/ai-reviewer.d.ts +5 -0
- package/dist/orchestrator/ai-reviewer.js +9 -2
- package/dist/orchestrator/context-collector.js +17 -5
- package/dist/orchestrator/executor.d.ts +8 -0
- package/dist/orchestrator/executor.js +24 -5
- package/dist/orchestrator/phase-executor.d.ts +4 -0
- package/dist/orchestrator/phase-executor.js +21 -4
- package/dist/storage/file-store.js +8 -0
- package/dist/storage/state-manager.js +52 -19
- package/dist/test/generator.js +113 -113
- package/dist/utils/error-handler.d.ts +18 -0
- package/dist/utils/error-handler.js +32 -0
- package/dist/utils/worktree-sync.js +24 -3
- package/package.json +61 -61
- package/skills/auto.md +410 -413
- package/skills/brainstorm.md +19 -12
- package/skills/debug.md +694 -691
- package/skills/deploy.md +658 -658
- package/skills/feature.md +713 -686
- package/skills/{SKILL.md → openmatrix-overview.md} +52 -53
- package/skills/plan.md +298 -296
- package/skills/report.md +9 -5
- package/skills/resume.md +292 -287
- package/skills/start.md +32 -20
- package/skills/status.md +5 -4
- package/skills/test.md +875 -875
- package/dist/agents/base-agent.d.ts +0 -46
- package/dist/agents/base-agent.js +0 -17
- package/dist/cli/commands/analyze.d.ts +0 -2
- package/dist/cli/commands/analyze.js +0 -50
- package/dist/orchestrator/smart-question-analyzer.d.ts +0 -90
- package/dist/orchestrator/smart-question-analyzer.js +0 -512
package/README.md
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
# OpenMatrix
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
**你的代码没测试?OpenMatrix 自动帮你补,覆盖率 >80%**
|
|
6
|
-
|
|
7
|
-
*自动化 ≠ 牺牲质量 | 高质量 ≠ 手动操作*
|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/openmatrix)
|
|
10
|
-
[](https://www.npmjs.com/package/openmatrix)
|
|
11
|
-
[](https://github.com/bigfish1913/openmatrix/stargazers)
|
|
12
|
-
[](https://opensource.org/licenses/MIT)
|
|
13
|
-
[](https://claude.ai/code)
|
|
14
|
-
|
|
15
|
-
**[中文](README.md)** | **[English](README_EN.md)**
|
|
16
|
-
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 30秒演示
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
/om 实现用户登录功能
|
|
25
|
-
|
|
26
|
-
# 自动启动任务编排 → 选择质量级别 → 全自动执行 → 质量门禁 → AI验收 → 完成
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
> `/om` 是 `/om:start` 的快捷方式。直接输入任务描述即可自动触发。
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## 三种质量模式
|
|
34
|
-
|
|
35
|
-
| 模式 | 覆盖率 | 测试 | Lint | 安全 | 适用场景 |
|
|
36
|
-
|:----:|:------:|:----:|:----:|:----:|---------|
|
|
37
|
-
| **strict** | >80% | TDD 先写测试 | 严格 | npm audit | 生产代码 |
|
|
38
|
-
| **balanced** | >60% | 后补测试 | 标准 | npm audit | 日常开发 |
|
|
39
|
-
| **fast** | >20% | 可选 | 无 | 无 | 快速原型 |
|
|
40
|
-
|
|
41
|
-
> E2E 测试可选(Playwright/Cypress/Appium)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## 快速开始
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# 安装
|
|
49
|
-
npm install -g openmatrix
|
|
50
|
-
|
|
51
|
-
# 验证
|
|
52
|
-
openmatrix --version
|
|
53
|
-
|
|
54
|
-
# 使用
|
|
55
|
-
/om 实现用户登录
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## 核心命令
|
|
61
|
-
|
|
62
|
-
| 命令 | 用途 |
|
|
63
|
-
|------|------|
|
|
64
|
-
| `/om` | 默认入口 - 直接输入任务描述 |
|
|
65
|
-
| `/om:test` | 自动补测试 - 给现有代码补充测试 |
|
|
66
|
-
| `/om:debug` | 系统化调试 - 四阶段根因分析 + 自动修复 |
|
|
67
|
-
| `/om:feature` | 轻量小需求 - 快速迭代,无完整任务追踪 |
|
|
68
|
-
| `/om:brainstorm` | 头脑风暴 - 先探索需求和设计 |
|
|
69
|
-
| `/om:auto` | 全自动执行 - 无阻塞、无确认、适合 CI/CD |
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 七道质量门禁
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
Gate 1: 编译检查 npm run build → 必须通过
|
|
77
|
-
Gate 2: 测试运行 npm test → 必须通过
|
|
78
|
-
Gate 3: 覆盖率检查 >20%/60%/80% → 可配置
|
|
79
|
-
Gate 4: Lint 检查 无 error → 可配置
|
|
80
|
-
Gate 5: 安全扫描 npm audit → 无高危漏洞
|
|
81
|
-
Gate 6: E2E 测试 Playwright 等 → 可选
|
|
82
|
-
Gate 7: 验收标准 用户定义 → 必须全部满足
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## 与 superpowers 配合
|
|
88
|
-
|
|
89
|
-
OpenMatrix 自动执行任务 + superpowers 提供额外技能 = 完美组合
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
# superpowers 写代码,OpenMatrix 保证质量
|
|
93
|
-
/om 实现用户登录 # 自动 TDD + 质量门禁 + AI 验收
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## 详细文档
|
|
99
|
-
|
|
100
|
-
| 文档 | 内容 |
|
|
101
|
-
|------|------|
|
|
102
|
-
| [执行流程图](docs/FLOW.md) | 完整流程图和阶段说明 |
|
|
103
|
-
| [开发路线图](docs/ROADMAP.md) | 功能规划和进度 |
|
|
104
|
-
| [系统架构](docs/ARCHITECTURE.md) | 核心组件和设计 |
|
|
105
|
-
| [术语对照表](docs/TERMINOLOGY.md) | 中英文术语对照 |
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## 常见问题
|
|
110
|
-
|
|
111
|
-
**Q: 哪种质量级别适合我?**
|
|
112
|
-
|
|
113
|
-
| 场景 | 推荐模式 |
|
|
114
|
-
|------|---------|
|
|
115
|
-
| 生产代码、核心功能 | strict |
|
|
116
|
-
| 日常功能开发 | balanced |
|
|
117
|
-
| 快速原型、POC | fast |
|
|
118
|
-
|
|
119
|
-
**Q: Meeting 是什么?**
|
|
120
|
-
|
|
121
|
-
A: 遇到阻塞时创建记录,但**不停止执行**。最后用 `/om:meeting` 统一处理所有阻塞。
|
|
122
|
-
|
|
123
|
-
**Q: 支持哪些语言?**
|
|
124
|
-
|
|
125
|
-
A: 原生支持 TypeScript/JavaScript、Python、Go、Java、Rust 等所有主流语言。
|
|
126
|
-
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
## 配置示例
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
{
|
|
133
|
-
"quality": {
|
|
134
|
-
"tdd": false,
|
|
135
|
-
"minCoverage": 60,
|
|
136
|
-
"strictLint": true,
|
|
137
|
-
"securityScan": true,
|
|
138
|
-
"e2eTests": false
|
|
139
|
-
},
|
|
140
|
-
"approvalPoints": ["plan", "merge"],
|
|
141
|
-
"agents": { "maxConcurrent": 3 }
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
<div align="center">
|
|
148
|
-
|
|
149
|
-
**如果觉得有用,请给个 Star!**
|
|
150
|
-
|
|
151
|
-
[](https://star-history.com/#/bigfish1913/openmatrix&Date)
|
|
152
|
-
|
|
153
|
-
MIT | Made by [bigfish1913](https://github.com/bigfish1913)
|
|
154
|
-
|
|
1
|
+
# OpenMatrix
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
**你的代码没测试?OpenMatrix 自动帮你补,覆盖率 >80%**
|
|
6
|
+
|
|
7
|
+
*自动化 ≠ 牺牲质量 | 高质量 ≠ 手动操作*
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/openmatrix)
|
|
10
|
+
[](https://www.npmjs.com/package/openmatrix)
|
|
11
|
+
[](https://github.com/bigfish1913/openmatrix/stargazers)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
[](https://claude.ai/code)
|
|
14
|
+
|
|
15
|
+
**[中文](README.md)** | **[English](README_EN.md)**
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 30秒演示
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
/om 实现用户登录功能
|
|
25
|
+
|
|
26
|
+
# 自动启动任务编排 → 选择质量级别 → 全自动执行 → 质量门禁 → AI验收 → 完成
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> `/om` 是 `/om:start` 的快捷方式。直接输入任务描述即可自动触发。
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 三种质量模式
|
|
34
|
+
|
|
35
|
+
| 模式 | 覆盖率 | 测试 | Lint | 安全 | 适用场景 |
|
|
36
|
+
|:----:|:------:|:----:|:----:|:----:|---------|
|
|
37
|
+
| **strict** | >80% | TDD 先写测试 | 严格 | npm audit | 生产代码 |
|
|
38
|
+
| **balanced** | >60% | 后补测试 | 标准 | npm audit | 日常开发 |
|
|
39
|
+
| **fast** | >20% | 可选 | 无 | 无 | 快速原型 |
|
|
40
|
+
|
|
41
|
+
> E2E 测试可选(Playwright/Cypress/Appium)
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 快速开始
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# 安装
|
|
49
|
+
npm install -g openmatrix
|
|
50
|
+
|
|
51
|
+
# 验证
|
|
52
|
+
openmatrix --version
|
|
53
|
+
|
|
54
|
+
# 使用
|
|
55
|
+
/om 实现用户登录
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 核心命令
|
|
61
|
+
|
|
62
|
+
| 命令 | 用途 |
|
|
63
|
+
|------|------|
|
|
64
|
+
| `/om` | 默认入口 - 直接输入任务描述 |
|
|
65
|
+
| `/om:test` | 自动补测试 - 给现有代码补充测试 |
|
|
66
|
+
| `/om:debug` | 系统化调试 - 四阶段根因分析 + 自动修复 |
|
|
67
|
+
| `/om:feature` | 轻量小需求 - 快速迭代,无完整任务追踪 |
|
|
68
|
+
| `/om:brainstorm` | 头脑风暴 - 先探索需求和设计 |
|
|
69
|
+
| `/om:auto` | 全自动执行 - 无阻塞、无确认、适合 CI/CD |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 七道质量门禁
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Gate 1: 编译检查 npm run build → 必须通过
|
|
77
|
+
Gate 2: 测试运行 npm test → 必须通过
|
|
78
|
+
Gate 3: 覆盖率检查 >20%/60%/80% → 可配置
|
|
79
|
+
Gate 4: Lint 检查 无 error → 可配置
|
|
80
|
+
Gate 5: 安全扫描 npm audit → 无高危漏洞
|
|
81
|
+
Gate 6: E2E 测试 Playwright 等 → 可选
|
|
82
|
+
Gate 7: 验收标准 用户定义 → 必须全部满足
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 与 superpowers 配合
|
|
88
|
+
|
|
89
|
+
OpenMatrix 自动执行任务 + superpowers 提供额外技能 = 完美组合
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# superpowers 写代码,OpenMatrix 保证质量
|
|
93
|
+
/om 实现用户登录 # 自动 TDD + 质量门禁 + AI 验收
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 详细文档
|
|
99
|
+
|
|
100
|
+
| 文档 | 内容 |
|
|
101
|
+
|------|------|
|
|
102
|
+
| [执行流程图](docs/FLOW.md) | 完整流程图和阶段说明 |
|
|
103
|
+
| [开发路线图](docs/ROADMAP.md) | 功能规划和进度 |
|
|
104
|
+
| [系统架构](docs/ARCHITECTURE.md) | 核心组件和设计 |
|
|
105
|
+
| [术语对照表](docs/TERMINOLOGY.md) | 中英文术语对照 |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 常见问题
|
|
110
|
+
|
|
111
|
+
**Q: 哪种质量级别适合我?**
|
|
112
|
+
|
|
113
|
+
| 场景 | 推荐模式 |
|
|
114
|
+
|------|---------|
|
|
115
|
+
| 生产代码、核心功能 | strict |
|
|
116
|
+
| 日常功能开发 | balanced |
|
|
117
|
+
| 快速原型、POC | fast |
|
|
118
|
+
|
|
119
|
+
**Q: Meeting 是什么?**
|
|
120
|
+
|
|
121
|
+
A: 遇到阻塞时创建记录,但**不停止执行**。最后用 `/om:meeting` 统一处理所有阻塞。
|
|
122
|
+
|
|
123
|
+
**Q: 支持哪些语言?**
|
|
124
|
+
|
|
125
|
+
A: 原生支持 TypeScript/JavaScript、Python、Go、Java、Rust 等所有主流语言。
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 配置示例
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"quality": {
|
|
134
|
+
"tdd": false,
|
|
135
|
+
"minCoverage": 60,
|
|
136
|
+
"strictLint": true,
|
|
137
|
+
"securityScan": true,
|
|
138
|
+
"e2eTests": false
|
|
139
|
+
},
|
|
140
|
+
"approvalPoints": ["plan", "merge"],
|
|
141
|
+
"agents": { "maxConcurrent": 3 }
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
<div align="center">
|
|
148
|
+
|
|
149
|
+
**如果觉得有用,请给个 Star!**
|
|
150
|
+
|
|
151
|
+
[](https://star-history.com/#/bigfish1913/openmatrix&Date)
|
|
152
|
+
|
|
153
|
+
MIT | Made by [bigfish1913](https://github.com/bigfish1913)
|
|
154
|
+
|
|
155
155
|
</div>
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.approveCommand = void 0;
|
|
4
37
|
// src/cli/commands/approve.ts
|
|
@@ -6,6 +39,7 @@ const commander_1 = require("commander");
|
|
|
6
39
|
const state_manager_js_1 = require("../../storage/state-manager.js");
|
|
7
40
|
const approval_manager_js_1 = require("../../orchestrator/approval-manager.js");
|
|
8
41
|
const logger_js_1 = require("../../utils/logger.js");
|
|
42
|
+
const path = __importStar(require("path"));
|
|
9
43
|
exports.approveCommand = new commander_1.Command('approve')
|
|
10
44
|
.description('审批待处理项')
|
|
11
45
|
.argument('[approvalId]', '审批ID')
|
|
@@ -14,7 +48,7 @@ exports.approveCommand = new commander_1.Command('approve')
|
|
|
14
48
|
.option('--json', '输出 JSON 格式 (供 Skill 解析)')
|
|
15
49
|
.action(async (approvalId, options) => {
|
|
16
50
|
const basePath = process.cwd();
|
|
17
|
-
const omPath =
|
|
51
|
+
const omPath = path.join(basePath, '.openmatrix');
|
|
18
52
|
const stateManager = new state_manager_js_1.StateManager(omPath);
|
|
19
53
|
await stateManager.initialize();
|
|
20
54
|
const approvalManager = new approval_manager_js_1.ApprovalManager(stateManager);
|
|
@@ -49,7 +49,7 @@ const path = __importStar(require("path"));
|
|
|
49
49
|
exports.autoCommand = new commander_1.Command('auto')
|
|
50
50
|
.description('全自动执行任务 - 无阻塞,bypass permissions')
|
|
51
51
|
.argument('[input]', '任务文件路径或描述')
|
|
52
|
-
.option('-q, --quality <level>', '质量级别 (strict|balanced|fast)', '
|
|
52
|
+
.option('-q, --quality <level>', '质量级别 (strict|balanced|fast)', 'balanced')
|
|
53
53
|
.option('--json', '输出 JSON 格式 (供 Skill 解析)')
|
|
54
54
|
.action(async (input, options) => {
|
|
55
55
|
const basePath = process.cwd();
|
|
@@ -207,7 +207,7 @@ exports.autoCommand = new commander_1.Command('auto')
|
|
|
207
207
|
// 设置自动模式和 RunId
|
|
208
208
|
const phaseExecutor = executor.getPhaseExecutor();
|
|
209
209
|
if (phaseExecutor) {
|
|
210
|
-
|
|
210
|
+
executor.setRunId(state.runId);
|
|
211
211
|
phaseExecutor.setAutoMode(true);
|
|
212
212
|
}
|
|
213
213
|
const result = await executor.step();
|
|
@@ -42,6 +42,23 @@ const commander_1 = require("commander");
|
|
|
42
42
|
const fs = __importStar(require("fs/promises"));
|
|
43
43
|
const path = __importStar(require("path"));
|
|
44
44
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
/**
|
|
46
|
+
* 安全检查文件是否存在(只捕获 ENOENT,其他错误抛出)
|
|
47
|
+
*/
|
|
48
|
+
async function safeFileExists(filePath) {
|
|
49
|
+
try {
|
|
50
|
+
await fs.access(filePath);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const nodeError = error;
|
|
55
|
+
if (nodeError.code === 'ENOENT') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// 其他错误(权限、磁盘等)应该抛出
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
45
62
|
/**
|
|
46
63
|
* 项目类型对应的 gitignore 条目
|
|
47
64
|
*/
|
|
@@ -145,41 +162,27 @@ async function detectProjectType(projectRoot) {
|
|
|
145
162
|
// 不是 Node.js 项目
|
|
146
163
|
}
|
|
147
164
|
// 检查 Python
|
|
148
|
-
|
|
149
|
-
await fs.access(path.join(projectRoot, 'pyproject.toml'));
|
|
165
|
+
if (await safeFileExists(path.join(projectRoot, 'pyproject.toml'))) {
|
|
150
166
|
types.push('python');
|
|
151
167
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
await fs.access(path.join(projectRoot, 'requirements.txt'));
|
|
155
|
-
if (!types.includes('python'))
|
|
156
|
-
types.push('python');
|
|
168
|
+
if (await safeFileExists(path.join(projectRoot, 'requirements.txt')) && !types.includes('python')) {
|
|
169
|
+
types.push('python');
|
|
157
170
|
}
|
|
158
|
-
catch { }
|
|
159
171
|
// 检查 Java
|
|
160
|
-
|
|
161
|
-
await fs.access(path.join(projectRoot, 'pom.xml'));
|
|
172
|
+
if (await safeFileExists(path.join(projectRoot, 'pom.xml'))) {
|
|
162
173
|
types.push('java');
|
|
163
174
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
await fs.access(path.join(projectRoot, 'build.gradle'));
|
|
167
|
-
if (!types.includes('java'))
|
|
168
|
-
types.push('java');
|
|
175
|
+
if (await safeFileExists(path.join(projectRoot, 'build.gradle')) && !types.includes('java')) {
|
|
176
|
+
types.push('java');
|
|
169
177
|
}
|
|
170
|
-
catch { }
|
|
171
178
|
// 检查 Go
|
|
172
|
-
|
|
173
|
-
await fs.access(path.join(projectRoot, 'go.mod'));
|
|
179
|
+
if (await safeFileExists(path.join(projectRoot, 'go.mod'))) {
|
|
174
180
|
types.push('go');
|
|
175
181
|
}
|
|
176
|
-
catch { }
|
|
177
182
|
// 检查 Rust
|
|
178
|
-
|
|
179
|
-
await fs.access(path.join(projectRoot, 'Cargo.toml'));
|
|
183
|
+
if (await safeFileExists(path.join(projectRoot, 'Cargo.toml'))) {
|
|
180
184
|
types.push('rust');
|
|
181
185
|
}
|
|
182
|
-
catch { }
|
|
183
186
|
// 检查 .NET
|
|
184
187
|
try {
|
|
185
188
|
const files = await fs.readdir(projectRoot);
|
|
@@ -187,19 +190,20 @@ async function detectProjectType(projectRoot) {
|
|
|
187
190
|
types.push('dotnet');
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
|
-
catch {
|
|
193
|
+
catch (error) {
|
|
194
|
+
const nodeError = error;
|
|
195
|
+
if (nodeError.code !== 'ENOENT') {
|
|
196
|
+
throw error; // 非 ENOENT 错误应该抛出
|
|
197
|
+
}
|
|
198
|
+
}
|
|
191
199
|
// 检查 PHP
|
|
192
|
-
|
|
193
|
-
await fs.access(path.join(projectRoot, 'composer.json'));
|
|
200
|
+
if (await safeFileExists(path.join(projectRoot, 'composer.json'))) {
|
|
194
201
|
types.push('php');
|
|
195
202
|
}
|
|
196
|
-
catch { }
|
|
197
203
|
// 检查 Dart
|
|
198
|
-
|
|
199
|
-
await fs.access(path.join(projectRoot, 'pubspec.yaml'));
|
|
204
|
+
if (await safeFileExists(path.join(projectRoot, 'pubspec.yaml'))) {
|
|
200
205
|
types.push('dart');
|
|
201
206
|
}
|
|
202
|
-
catch { }
|
|
203
207
|
// 始终添加通用条目
|
|
204
208
|
types.push('common');
|
|
205
209
|
return types;
|
|
@@ -306,7 +310,7 @@ exports.checkGitignoreCommand = new commander_1.Command('check-gitignore')
|
|
|
306
310
|
}
|
|
307
311
|
catch (error) {
|
|
308
312
|
if (options.json) {
|
|
309
|
-
console.log(JSON.stringify({ error: String(error) }));
|
|
313
|
+
console.log(JSON.stringify({ status: 'error', message: String(error) }));
|
|
310
314
|
}
|
|
311
315
|
else {
|
|
312
316
|
console.error(chalk_1.default.red('❌ 检查失败:'), error);
|
|
@@ -110,7 +110,7 @@ exports.checkCommand = new commander_1.Command('check')
|
|
|
110
110
|
}
|
|
111
111
|
catch (error) {
|
|
112
112
|
if (options.json) {
|
|
113
|
-
console.log(JSON.stringify({ error: String(error) }));
|
|
113
|
+
console.log(JSON.stringify({ status: 'error', message: String(error) }));
|
|
114
114
|
}
|
|
115
115
|
else {
|
|
116
116
|
console.error(chalk_1.default.red('\n❌ 检测失败:'), error);
|
|
@@ -58,7 +58,7 @@ exports.completeCommand = new commander_1.Command('complete')
|
|
|
58
58
|
// 1. 读取任务
|
|
59
59
|
const task = await stateManager.getTask(taskId);
|
|
60
60
|
if (!task) {
|
|
61
|
-
console.log(JSON.stringify({ error: `任务 ${taskId} 不存在` }));
|
|
61
|
+
console.log(JSON.stringify({ status: 'error', message: `任务 ${taskId} 不存在` }));
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const isSuccess = !options.failed;
|
|
@@ -104,15 +104,18 @@ exports.completeCommand = new commander_1.Command('complete')
|
|
|
104
104
|
currentPhase: allDone ? 'completed' : 'execution',
|
|
105
105
|
...(allDone ? { completedAt: now } : {})
|
|
106
106
|
});
|
|
107
|
-
// 5. 追加写入全局 context.md (Agent Memory)
|
|
107
|
+
// 5. 追加写入全局 context.md (Agent Memory) + 写入 artifacts/result.md
|
|
108
108
|
if (isSuccess) {
|
|
109
109
|
// 读取 current.json 获取当前 runId,context.md 写入运行目录
|
|
110
110
|
let contextDir = omPath;
|
|
111
|
+
let runId = '';
|
|
111
112
|
try {
|
|
112
113
|
const currentJson = await fs.readFile(path.join(omPath, 'current.json'), 'utf-8');
|
|
113
|
-
const { runId } = JSON.parse(currentJson);
|
|
114
|
-
if (
|
|
114
|
+
const { runId: currentRunId } = JSON.parse(currentJson);
|
|
115
|
+
if (currentRunId) {
|
|
116
|
+
runId = currentRunId;
|
|
115
117
|
contextDir = path.join(omPath, runId);
|
|
118
|
+
}
|
|
116
119
|
}
|
|
117
120
|
catch {
|
|
118
121
|
// fallback to omPath
|
|
@@ -135,6 +138,31 @@ exports.completeCommand = new commander_1.Command('complete')
|
|
|
135
138
|
// 记录错误但不影响主流程
|
|
136
139
|
(0, error_handler_js_1.logError)(error, { operation: 'appendContextMd', file: contextFile, taskId });
|
|
137
140
|
}
|
|
141
|
+
// 5b. 写入 artifacts/result.md (解决 artifacts 为空的问题)
|
|
142
|
+
if (runId) {
|
|
143
|
+
const artifactsDir = path.join(omPath, runId, 'tasks', taskId, 'artifacts');
|
|
144
|
+
const resultFile = path.join(artifactsDir, 'result.md');
|
|
145
|
+
const resultContent = `# 任务执行结果
|
|
146
|
+
|
|
147
|
+
## 任务信息
|
|
148
|
+
- ID: ${taskId}
|
|
149
|
+
- 标题: ${task.title}
|
|
150
|
+
- 完成时间: ${timestamp}
|
|
151
|
+
|
|
152
|
+
## 执行摘要
|
|
153
|
+
${summary}
|
|
154
|
+
|
|
155
|
+
## 状态
|
|
156
|
+
✅ 已完成
|
|
157
|
+
`;
|
|
158
|
+
try {
|
|
159
|
+
await fs.mkdir(artifactsDir, { recursive: true });
|
|
160
|
+
await fs.writeFile(resultFile, resultContent, 'utf-8');
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
(0, error_handler_js_1.logError)(error, { operation: 'writeArtifactsResult', file: resultFile, taskId });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
138
166
|
}
|
|
139
167
|
// 6. Git 自动提交
|
|
140
168
|
if (isSuccess) {
|
|
@@ -150,15 +178,15 @@ exports.completeCommand = new commander_1.Command('complete')
|
|
|
150
178
|
impactScope: []
|
|
151
179
|
});
|
|
152
180
|
if (commitResult.success) {
|
|
153
|
-
console.
|
|
181
|
+
console.log(`✅ Git 提交成功: ${commitResult.commitHash}`);
|
|
154
182
|
}
|
|
155
183
|
else {
|
|
156
184
|
const reason = commitResult.message || commitResult.error || 'Unknown reason';
|
|
157
|
-
console.
|
|
185
|
+
console.log(`⚠️ Git 提交跳过: ${reason}`);
|
|
158
186
|
}
|
|
159
187
|
}
|
|
160
188
|
catch (error) {
|
|
161
|
-
console.error(
|
|
189
|
+
console.error(`❌ Git 提交失败: ${error}`); // 真正的错误用 console.error
|
|
162
190
|
}
|
|
163
191
|
}
|
|
164
192
|
// 6. 输出结果
|
|
@@ -37,6 +37,7 @@ exports.debugCommand = void 0;
|
|
|
37
37
|
// src/cli/commands/debug.ts
|
|
38
38
|
const commander_1 = require("commander");
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
40
41
|
const debug_manager_js_1 = require("../../orchestrator/debug-manager.js");
|
|
41
42
|
exports.debugCommand = new commander_1.Command('debug')
|
|
42
43
|
.description('系统化调试 - 诊断并修复问题')
|
|
@@ -47,7 +48,7 @@ exports.debugCommand = new commander_1.Command('debug')
|
|
|
47
48
|
.option('--list', '列出最近的调试会话')
|
|
48
49
|
.action(async (description, options) => {
|
|
49
50
|
const basePath = process.cwd();
|
|
50
|
-
const omPath =
|
|
51
|
+
const omPath = path.join(basePath, '.openmatrix');
|
|
51
52
|
// 初始化 .openmatrix 目录(如果不存在)
|
|
52
53
|
if (!fs.existsSync(omPath)) {
|
|
53
54
|
console.log('❌ .openmatrix 目录不存在,请先运行: openmatrix start --init-only');
|
|
@@ -64,7 +64,7 @@ exports.deployCommand = new commander_1.Command('deploy')
|
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
66
|
if (options.json) {
|
|
67
|
-
console.log(JSON.stringify({ error: String(error) }));
|
|
67
|
+
console.log(JSON.stringify({ status: 'error', message: String(error) }));
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
console.error(chalk_1.default.red('\n❌ 检测失败:'), error);
|
|
@@ -125,6 +125,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
catch (err) {
|
|
128
|
+
console.log(` ❌ Failed: om.md (${err instanceof Error ? err.message : String(err)})`);
|
|
128
129
|
failed++;
|
|
129
130
|
}
|
|
130
131
|
}
|
|
@@ -142,6 +143,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
catch (err) {
|
|
146
|
+
console.log(` ❌ Failed: om.md (${err instanceof Error ? err.message : String(err)})`);
|
|
145
147
|
failed++;
|
|
146
148
|
}
|
|
147
149
|
}
|
|
@@ -161,6 +163,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
catch (err) {
|
|
166
|
+
console.log(` ❌ Failed: om.md (${err instanceof Error ? err.message : String(err)})`);
|
|
164
167
|
failed++;
|
|
165
168
|
}
|
|
166
169
|
}
|