openmatrix 0.2.4 → 0.2.6

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.
@@ -0,0 +1,167 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DebugReporter = void 0;
37
+ // src/orchestrator/debug-reporter.ts
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ /**
41
+ * 生成和保存诊断报告
42
+ */
43
+ class DebugReporter {
44
+ debugDir;
45
+ constructor(basePath) {
46
+ this.debugDir = path.join(basePath, 'debug');
47
+ this.ensureDir();
48
+ }
49
+ /**
50
+ * 生成诊断报告文件
51
+ */
52
+ async generateReport(session) {
53
+ const report = session.report;
54
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
55
+ const fileName = `${report.id}-report-${timestamp}.md`;
56
+ const filePath = path.join(this.debugDir, fileName);
57
+ const content = this.formatReport(session);
58
+ fs.writeFileSync(filePath, content, 'utf-8');
59
+ return filePath;
60
+ }
61
+ /**
62
+ * 格式化报告内容为 Markdown
63
+ */
64
+ formatReport(session) {
65
+ const { report, fixResult, verifyResult } = session;
66
+ let md = `# Debug Report\n\n`;
67
+ md += `**会话 ID**: ${session.id}\n`;
68
+ md += `**日期**: ${session.createdAt}\n`;
69
+ md += `**状态**: ${session.status}\n`;
70
+ if (session.completedAt) {
71
+ md += `**完成时间**: ${session.completedAt}\n`;
72
+ }
73
+ md += `\n---\n\n`;
74
+ // 问题描述
75
+ md += `## 问题描述\n\n${report.description}\n\n`;
76
+ // 问题类型
77
+ md += `## 问题类型\n\n\`${report.problemType}\`\n\n`;
78
+ if (report.relatedTaskId) {
79
+ md += `**关联任务**: ${report.relatedTaskId}\n\n`;
80
+ }
81
+ // 诊断结果
82
+ md += `## 诊断结果\n\n`;
83
+ md += `### 根因\n\n${report.rootCause}\n\n`;
84
+ if (report.errorInfo) {
85
+ md += `### 错误信息\n\n`;
86
+ md += `\`\`\`\n${report.errorInfo.message}\n\`\`\`\n\n`;
87
+ if (report.errorInfo.stack) {
88
+ md += `### 错误栈\n\n\`\`\`\n${report.errorInfo.stack}\n\`\`\`\n\n`;
89
+ }
90
+ }
91
+ // 影响范围
92
+ if (report.impactScope.length > 0) {
93
+ md += `### 影响范围\n\n`;
94
+ report.impactScope.forEach((item) => { md += `- ${item}\n`; });
95
+ md += `\n`;
96
+ }
97
+ // 相关文件
98
+ if (report.relatedFiles && report.relatedFiles.length > 0) {
99
+ md += `### 相关文件\n\n`;
100
+ report.relatedFiles.forEach((file) => { md += `- \`${file}\`\n`; });
101
+ md += `\n`;
102
+ }
103
+ // 修复建议
104
+ md += `## 修复建议\n\n${report.suggestedFix}\n\n`;
105
+ // 修复操作
106
+ if (fixResult) {
107
+ md += `## 修复操作\n\n`;
108
+ if (fixResult.success) {
109
+ md += `✅ 修复成功\n\n`;
110
+ }
111
+ else {
112
+ md += `❌ 修复未完全生效\n\n`;
113
+ }
114
+ if (fixResult.modifiedFiles.length > 0) {
115
+ md += `### 修改文件\n\n`;
116
+ fixResult.modifiedFiles.forEach((file) => { md += `- \`${file}\`\n`; });
117
+ md += `\n`;
118
+ }
119
+ if (fixResult.operations.length > 0) {
120
+ md += `### 执行操作\n\n`;
121
+ fixResult.operations.forEach((op) => { md += `- ${op}\n`; });
122
+ md += `\n`;
123
+ }
124
+ }
125
+ // 验证结果
126
+ if (verifyResult) {
127
+ md += `## 验证结果\n\n`;
128
+ if (verifyResult.passed) {
129
+ md += `✅ 验证通过\n\n`;
130
+ }
131
+ else {
132
+ md += `❌ 验证未通过\n\n`;
133
+ }
134
+ md += `${verifyResult.details}\n\n`;
135
+ }
136
+ // 重试信息
137
+ if (session.retryCount > 0) {
138
+ md += `## 重试信息\n\n已尝试 ${session.retryCount} 次修复\n\n`;
139
+ if (session.retryCount >= 3) {
140
+ md += `⚠️ **已尝试 3 次以上修复,建议暂停并质疑架构**\n\n`;
141
+ }
142
+ }
143
+ return md;
144
+ }
145
+ /**
146
+ * 列出所有诊断报告
147
+ */
148
+ listReports() {
149
+ if (!fs.existsSync(this.debugDir))
150
+ return [];
151
+ const files = fs.readdirSync(this.debugDir)
152
+ .filter(f => f.endsWith('-report.md') || f.includes('-report-'))
153
+ .sort()
154
+ .reverse();
155
+ return files.map(f => ({
156
+ id: f.split('-')[0],
157
+ path: path.join(this.debugDir, f),
158
+ createdAt: f
159
+ }));
160
+ }
161
+ ensureDir() {
162
+ if (!fs.existsSync(this.debugDir)) {
163
+ fs.mkdirSync(this.debugDir, { recursive: true });
164
+ }
165
+ }
166
+ }
167
+ exports.DebugReporter = DebugReporter;
@@ -0,0 +1,15 @@
1
+ import type { ProblemType } from '../types/index.js';
2
+ export interface ProblemDetectionConfig {
3
+ description?: string;
4
+ taskId?: string;
5
+ taskError?: string | null;
6
+ }
7
+ /**
8
+ * 判断问题类型的检测器
9
+ */
10
+ export declare class ProblemDetector {
11
+ /**
12
+ * 根据配置判断问题类型
13
+ */
14
+ detect(config: ProblemDetectionConfig): Promise<ProblemType>;
15
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProblemDetector = void 0;
4
+ /**
5
+ * 判断问题类型的检测器
6
+ */
7
+ class ProblemDetector {
8
+ /**
9
+ * 根据配置判断问题类型
10
+ */
11
+ async detect(config) {
12
+ // 有任务 ID 且任务失败
13
+ if (config.taskId && config.taskError) {
14
+ return 'task_failure';
15
+ }
16
+ // 根据描述判断
17
+ if (config.description) {
18
+ const desc = config.description.toLowerCase();
19
+ // 环境相关关键词
20
+ const envKeywords = [
21
+ '依赖', '安装', '环境', '配置', 'npm install', 'node_modules',
22
+ 'env', 'environment', 'dependency', 'install', 'config',
23
+ 'path', '版本', 'version', '权限', 'permission'
24
+ ];
25
+ // 项目代码相关关键词
26
+ const projectKeywords = [
27
+ '接口', 'api', '函数', 'function', '返回', 'response',
28
+ '数据', 'data', '逻辑', 'logic', '页面', 'page',
29
+ '组件', 'component', '样式', 'style', '渲染', 'render'
30
+ ];
31
+ // 系统/OpenMatrix 相关关键词
32
+ const systemKeywords = [
33
+ 'openmatrix', 'cli', '命令', 'command', '状态', 'state',
34
+ '任务', 'task', '编排', 'orchestrat', 'agent', '技能', 'skill'
35
+ ];
36
+ const hasEnvKeyword = envKeywords.some(kw => desc.includes(kw));
37
+ const hasProjectKeyword = projectKeywords.some(kw => desc.includes(kw));
38
+ const hasSystemKeyword = systemKeywords.some(kw => desc.includes(kw));
39
+ // 优先级:环境 > 项目 > 系统
40
+ if (hasEnvKeyword)
41
+ return 'environment';
42
+ if (hasProjectKeyword)
43
+ return 'project_bug';
44
+ if (hasSystemKeyword)
45
+ return 'system_bug';
46
+ }
47
+ // 默认:系统 bug
48
+ return 'system_bug';
49
+ }
50
+ }
51
+ exports.ProblemDetector = ProblemDetector;
@@ -267,3 +267,47 @@ export interface ResearchSession {
267
267
  createdAt: string;
268
268
  completedAt?: string;
269
269
  }
270
+ /** 问题类型 */
271
+ export type ProblemType = 'task_failure' | 'project_bug' | 'system_bug' | 'environment';
272
+ /** 诊断报告 */
273
+ export interface DiagnosisReport {
274
+ id: string;
275
+ problemType: ProblemType;
276
+ trigger: 'explicit' | 'auto';
277
+ description: string;
278
+ errorInfo?: {
279
+ message: string;
280
+ stack?: string;
281
+ timestamp: string;
282
+ };
283
+ relatedTaskId?: string;
284
+ relatedFiles?: string[];
285
+ rootCause: string;
286
+ impactScope: string[];
287
+ suggestedFix: string;
288
+ diagnosedAt: string;
289
+ diagnosisDuration?: number;
290
+ }
291
+ /** 调试会话状态 */
292
+ export type DebugStatus = 'initialized' | 'diagnosing' | 'awaiting_fix' | 'fixing' | 'verifying' | 'completed' | 'cancelled';
293
+ /** 调试会话 */
294
+ export interface DebugSession {
295
+ id: string;
296
+ status: DebugStatus;
297
+ report: DiagnosisReport;
298
+ fixDecision?: 'approve' | 'skip' | 'manual';
299
+ fixResult?: {
300
+ success: boolean;
301
+ operations: string[];
302
+ modifiedFiles: string[];
303
+ output: string;
304
+ };
305
+ verifyResult?: {
306
+ passed: boolean;
307
+ details: string;
308
+ };
309
+ retryCount: number;
310
+ createdAt: string;
311
+ updatedAt: string;
312
+ completedAt?: string;
313
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmatrix",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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",
package/skills/approve.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: om:approve
3
- description: 审批待处理项(包括计划、合并、部署、Meeting)
3
+ description: "Use when handling pending approvals including plan review, merge confirmation, deploy approval, and blocked task decisions during OpenMatrix execution. Triggers on: 审批, approve, 批准, plan review, merge conflict resolution, deploy confirmation, 阻塞处理, technical decision, pending approval, waiting for approval, 待确认."
4
4
  ---
5
5
 
6
6
  <NO-OTHER-SKILLS>
package/skills/auto.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: om:auto
3
- description: 全自动执行任务指令 - AI 拆分,无阻塞,bypass permissions
3
+ description: "Use when the user wants fully automated task execution with zero manual approvals. Triggers on: 全自动, 无人值守, hands-free, non-stop, don't ask me, 直接执行, skip all confirmations, batch refactor, large migration, bulk changes. Use for multi-task execution where the user doesn't want to be interrupted at any approval point (plan/merge/deploy)."
4
4
  ---
5
5
 
6
6
  <NOTE>
@@ -9,7 +9,9 @@ description: 全自动执行任务指令 - AI 拆分,无阻塞,bypass permis
9
9
  - **`/om:auto`** 是一个 **Skill 指令**,为 Agent 无障碍执行准备
10
10
  - **「全自动执行」**是 `/om:start` 中用户选择的 **执行模式选项**
11
11
 
12
- **关键区别**:`/om/auto` 不创建 Meeting 记录,直接跳过阻塞任务。
12
+ **关键区别**:`/om:auto` 不创建 Meeting 记录,直接跳过阻塞任务。
13
+
14
+ **相关技能**: `/om:start` (交互式) | `/om:status` (状态查看) | `/om:report` (报告)
13
15
  </NOTE>
14
16
 
15
17
  <NO-OTHER-SKILLS>
@@ -283,16 +285,21 @@ $ARGUMENTS
283
285
  ## 执行流程
284
286
 
285
287
  ```
286
- Step 1: 初始化 .openmatrix
287
-
288
- Step 2: AI 提取 goals + 生成 plan
289
-
290
- Step 3: 写入 tasks-input.json
291
-
292
- Step 4: openmatrix start --tasks-json ← 必须执行
293
-
294
- Step 5: 读取 subagentTasks
295
-
296
- Step 6: Agent 逐个执行 ← 只有这里写代码
288
+ Step 1: 初始化 .openmatrix → Step 2: 提取 goals + plan → Step 3: 写入 tasks-input.json
289
+ → Step 4: openmatrix start --tasks-json (必须) → Step 5: 读取 subagentTasks
290
+ Step 6: Agent 逐个执行 (只有这里写代码)
291
+ ```
292
+
293
+ ## Git 提交格式
294
+
297
295
  ```
296
+ <type>(TASK-XXX): 简短描述
297
+
298
+ 改动点1 / 改动点2
299
+ 影响范围: 模块名
300
+ 文件改动: 文件1, 文件2
301
+ Co-Authored-By: OpenMatrix https://github.com/bigfish1913/openmatrix
302
+ ```
303
+
304
+ type: feat/fix/test/refactor/docs。禁止 emoji。
298
305
  </notes>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: om:brainstorm
3
- description: 头脑风暴 - 深入探索需求和设计,提出多种方案,确认后再执行任务
3
+ description: "Use when the user wants to explore requirements, design alternatives, or validate ideas before implementation. Triggers on: 头脑风暴, 设计方案, 需求分析, 技术选型, architecture design, 'how should I build', multi-module features, new projects from scratch, unclear requirements, complex system design. Use even if the user just says 'implement X' and the task involves multiple modules or unclear requirements — brainstorm first, don't jump straight to coding."
4
4
  ---
5
5
 
6
6
  <NO-OTHER-SKILLS>
@@ -9,6 +9,8 @@ description: 头脑风暴 - 深入探索需求和设计,提出多种方案,
9
9
  - ❌ superpowers:* → 全部被 OpenMatrix 替代
10
10
  - ❌ gsd:* → 全部被 OpenMatrix 替代
11
11
  - ❌ 任何其他任务编排相关的技能
12
+
13
+ **相关技能**: `/om:research` (领域调研) | `/om:start` (任务执行) | `/om:auto` (全自动)
12
14
  </NO-OTHER-SKILLS>
13
15
 
14
16
  <HARD-GATE>