openmatrix 0.2.5 → 0.2.7
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/agents/agent-runner.js +0 -1
- package/dist/cli/commands/analyze.js +8 -7
- package/dist/cli/commands/approve.js +24 -23
- package/dist/cli/commands/brainstorm.d.ts +115 -0
- package/dist/cli/commands/brainstorm.js +358 -255
- package/dist/cli/commands/check.d.ts +25 -0
- package/dist/cli/commands/check.js +69 -44
- package/dist/cli/commands/debug.d.ts +2 -0
- package/dist/cli/commands/debug.js +116 -0
- package/dist/cli/commands/install-skills.js +4 -4
- package/dist/cli/commands/report.d.ts +23 -0
- package/dist/cli/commands/report.js +1 -0
- package/dist/cli/commands/status.d.ts +8 -0
- package/dist/cli/commands/status.js +19 -18
- package/dist/cli/index.js +2 -0
- package/dist/orchestrator/context-collector.d.ts +23 -0
- package/dist/orchestrator/context-collector.js +168 -0
- package/dist/orchestrator/debug-manager.d.ts +52 -0
- package/dist/orchestrator/debug-manager.js +214 -0
- package/dist/orchestrator/debug-reporter.d.ts +25 -0
- package/dist/orchestrator/debug-reporter.js +167 -0
- package/dist/orchestrator/phase-executor.js +21 -0
- package/dist/orchestrator/problem-detector.d.ts +15 -0
- package/dist/orchestrator/problem-detector.js +51 -0
- package/dist/orchestrator/upgrade-detector.js +32 -12
- package/dist/storage/file-store.js +6 -3
- package/dist/types/index.d.ts +44 -0
- package/dist/utils/logger.d.ts +4 -4
- package/package.json +1 -1
- package/skills/auto.md +3 -1
- package/skills/debug.md +451 -0
- package/skills/om.md +2 -1
- package/skills/start.md +40 -2
|
@@ -1,2 +1,27 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { type UpgradeSuggestion, type ProjectType, type DetectionResult, type UpgradeCategory } from '../../orchestrator/upgrade-detector.js';
|
|
2
3
|
export declare const checkCommand: Command;
|
|
4
|
+
/**
|
|
5
|
+
* 显示项目基本信息
|
|
6
|
+
*/
|
|
7
|
+
export declare function displayProjectInfo(projectName: string, projectType: ProjectType, timestamp: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 显示检测摘要统计
|
|
10
|
+
*/
|
|
11
|
+
export declare function displaySummary(summary: DetectionResult['summary']): void;
|
|
12
|
+
/**
|
|
13
|
+
* 获取类别标签映射
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCategoryLabels(): Record<UpgradeCategory, string>;
|
|
16
|
+
/**
|
|
17
|
+
* 按优先级分组显示建议
|
|
18
|
+
*/
|
|
19
|
+
export declare function displaySuggestionsByPriority(suggestions: UpgradeSuggestion[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* 显示单个优先级组的建议
|
|
22
|
+
*/
|
|
23
|
+
export declare function displayPriorityGroup(items: UpgradeSuggestion[], label: string, color: (text: string) => string, icon: string, maxDisplay?: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* 显示操作提示
|
|
26
|
+
*/
|
|
27
|
+
export declare function displayHints(): void;
|
|
@@ -37,6 +37,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.checkCommand = void 0;
|
|
40
|
+
exports.displayProjectInfo = displayProjectInfo;
|
|
41
|
+
exports.displaySummary = displaySummary;
|
|
42
|
+
exports.getCategoryLabels = getCategoryLabels;
|
|
43
|
+
exports.displaySuggestionsByPriority = displaySuggestionsByPriority;
|
|
44
|
+
exports.displayPriorityGroup = displayPriorityGroup;
|
|
45
|
+
exports.displayHints = displayHints;
|
|
40
46
|
// src/cli/commands/check.ts
|
|
41
47
|
const commander_1 = require("commander");
|
|
42
48
|
const upgrade_detector_js_1 = require("../../orchestrator/upgrade-detector.js");
|
|
@@ -117,13 +123,43 @@ exports.checkCommand = new commander_1.Command('check')
|
|
|
117
123
|
*/
|
|
118
124
|
function displayResult(result) {
|
|
119
125
|
const { projectType, projectName, suggestions, summary } = result;
|
|
126
|
+
displayProjectInfo(projectName, projectType, result.timestamp);
|
|
127
|
+
displaySummary(summary);
|
|
128
|
+
if (suggestions.length === 0) {
|
|
129
|
+
console.log(chalk_1.default.green('✅ 未发现问题,项目状态良好!\n'));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
displaySuggestionsByPriority(suggestions);
|
|
133
|
+
displayHints();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 显示项目基本信息
|
|
137
|
+
*/
|
|
138
|
+
function displayProjectInfo(projectName, projectType, timestamp) {
|
|
120
139
|
console.log(chalk_1.default.bold(`📦 项目: ${projectName}`));
|
|
121
140
|
console.log(` 类型: ${formatProjectType(projectType)}`);
|
|
122
|
-
console.log(` 扫描时间: ${new Date(
|
|
123
|
-
|
|
141
|
+
console.log(` 扫描时间: ${new Date(timestamp).toLocaleString()}\n`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 显示检测摘要统计
|
|
145
|
+
*/
|
|
146
|
+
function displaySummary(summary) {
|
|
124
147
|
console.log(chalk_1.default.bold('📊 检测摘要'));
|
|
125
148
|
console.log('━'.repeat(42));
|
|
126
|
-
const categoryLabels =
|
|
149
|
+
const categoryLabels = getCategoryLabels();
|
|
150
|
+
for (const [cat, count] of Object.entries(summary.byCategory)) {
|
|
151
|
+
if (count > 0) {
|
|
152
|
+
console.log(` ${categoryLabels[cat]}: ${chalk_1.default.yellow(count)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
console.log(`\n 总计: ${chalk_1.default.bold(summary.total)} 个建议`);
|
|
156
|
+
console.log(` 可自动修复: ${chalk_1.default.green(summary.autoFixable)} 个\n`);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 获取类别标签映射
|
|
160
|
+
*/
|
|
161
|
+
function getCategoryLabels() {
|
|
162
|
+
return {
|
|
127
163
|
bug: '🐛 代码缺陷',
|
|
128
164
|
quality: '🔧 代码质量',
|
|
129
165
|
capability: '📦 缺失能力',
|
|
@@ -135,53 +171,42 @@ function displayResult(result) {
|
|
|
135
171
|
skill: '⚡ Skill 问题',
|
|
136
172
|
agent: '🧠 Agent 配置'
|
|
137
173
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
console.log(`\n 总计: ${chalk_1.default.bold(summary.total)} 个建议`);
|
|
144
|
-
console.log(` 可自动修复: ${chalk_1.default.green(summary.autoFixable)} 个\n`);
|
|
145
|
-
if (suggestions.length === 0) {
|
|
146
|
-
console.log(chalk_1.default.green('✅ 未发现问题,项目状态良好!\n'));
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
// 详细建议
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 按优先级分组显示建议
|
|
177
|
+
*/
|
|
178
|
+
function displaySuggestionsByPriority(suggestions) {
|
|
150
179
|
console.log(chalk_1.default.bold('📋 改进建议'));
|
|
151
180
|
console.log('━'.repeat(42) + '\n');
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
const groups = [
|
|
182
|
+
{ items: suggestions.filter(s => s.priority === 'critical'), label: '关键问题', color: chalk_1.default.red.bold, icon: '🚨' },
|
|
183
|
+
{ items: suggestions.filter(s => s.priority === 'high'), label: '高优先级', color: chalk_1.default.yellow.bold, icon: '⚠️' },
|
|
184
|
+
{ items: suggestions.filter(s => s.priority === 'medium'), label: '中优先级', color: chalk_1.default.blue.bold, icon: '📋' },
|
|
185
|
+
{ items: suggestions.filter(s => s.priority === 'low'), label: '低优先级', color: chalk_1.default.gray.bold, icon: '💡', maxDisplay: 10 },
|
|
186
|
+
];
|
|
187
|
+
for (const group of groups) {
|
|
188
|
+
if (group.items.length > 0) {
|
|
189
|
+
displayPriorityGroup(group.items, group.label, group.color, group.icon, group.maxDisplay);
|
|
161
190
|
}
|
|
162
191
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 显示单个优先级组的建议
|
|
195
|
+
*/
|
|
196
|
+
function displayPriorityGroup(items, label, color, icon, maxDisplay) {
|
|
197
|
+
const displayItems = maxDisplay ? items.slice(0, maxDisplay) : items;
|
|
198
|
+
console.log(color(`${icon} ${label}:\n`));
|
|
199
|
+
for (const s of displayItems) {
|
|
200
|
+
displaySuggestion(s);
|
|
168
201
|
}
|
|
169
|
-
if (
|
|
170
|
-
console.log(chalk_1.default.
|
|
171
|
-
for (const s of medium) {
|
|
172
|
-
displaySuggestion(s);
|
|
173
|
-
}
|
|
202
|
+
if (maxDisplay && items.length > maxDisplay) {
|
|
203
|
+
console.log(chalk_1.default.gray(` ... 还有 ${items.length - maxDisplay} 个低优先级建议\n`));
|
|
174
204
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (low.length > 10) {
|
|
181
|
-
console.log(chalk_1.default.gray(` ... 还有 ${low.length - 10} 个低优先级建议\n`));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// 提示
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 显示操作提示
|
|
208
|
+
*/
|
|
209
|
+
function displayHints() {
|
|
185
210
|
console.log(chalk_1.default.gray('━'.repeat(42)));
|
|
186
211
|
console.log(chalk_1.default.gray('💡 提示:'));
|
|
187
212
|
console.log(chalk_1.default.gray(' --interactive 交互式选择改进项'));
|
|
@@ -0,0 +1,116 @@
|
|
|
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.debugCommand = void 0;
|
|
37
|
+
// src/cli/commands/debug.ts
|
|
38
|
+
const commander_1 = require("commander");
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const debug_manager_js_1 = require("../../orchestrator/debug-manager.js");
|
|
41
|
+
exports.debugCommand = new commander_1.Command('debug')
|
|
42
|
+
.description('系统化调试 - 诊断并修复问题')
|
|
43
|
+
.argument('[description]', '问题描述')
|
|
44
|
+
.option('--task <taskId>', '调试指定的失败任务')
|
|
45
|
+
.option('--diagnose-only', '仅诊断,不执行修复')
|
|
46
|
+
.option('--json', '输出 JSON 格式')
|
|
47
|
+
.option('--list', '列出最近的调试会话')
|
|
48
|
+
.action(async (description, options) => {
|
|
49
|
+
const basePath = process.cwd();
|
|
50
|
+
const omPath = `${basePath}/.openmatrix`;
|
|
51
|
+
// 初始化 .openmatrix 目录(如果不存在)
|
|
52
|
+
if (!fs.existsSync(omPath)) {
|
|
53
|
+
console.log('❌ .openmatrix 目录不存在,请先运行: openmatrix start --init-only');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const debugManager = new debug_manager_js_1.DebugManager(omPath);
|
|
57
|
+
// 列出最近的调试会话
|
|
58
|
+
if (options.list) {
|
|
59
|
+
const sessions = debugManager.listRecent();
|
|
60
|
+
if (sessions.length === 0) {
|
|
61
|
+
console.log('📋 没有调试记录');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log('📋 最近的调试会话:\n');
|
|
65
|
+
sessions.forEach(s => {
|
|
66
|
+
console.log(` ${s.id} ${s.status} ${s.description}`);
|
|
67
|
+
console.log(` ${s.createdAt}`);
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// 如果没有描述也没有任务 ID,提示用户
|
|
72
|
+
if (!description && !options.task) {
|
|
73
|
+
console.log('🔍 系统化调试 - 诊断并修复问题\n');
|
|
74
|
+
console.log('用法:');
|
|
75
|
+
console.log(' openmatrix debug <问题描述> 描述问题开始调试');
|
|
76
|
+
console.log(' openmatrix debug --task TASK-XXX 调试指定失败任务');
|
|
77
|
+
console.log(' openmatrix debug --diagnose-only 仅诊断不修复');
|
|
78
|
+
console.log(' openmatrix debug --list 列出最近调试记录');
|
|
79
|
+
console.log(' openmatrix debug --json 输出 JSON 格式\n');
|
|
80
|
+
console.log('示例:');
|
|
81
|
+
console.log(' openmatrix debug "API 返回 500 错误"');
|
|
82
|
+
console.log(' openmatrix debug --task TASK-003');
|
|
83
|
+
console.log(' openmatrix debug "测试失败" --diagnose-only');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// 初始化调试会话
|
|
87
|
+
const result = await debugManager.initialize({
|
|
88
|
+
description,
|
|
89
|
+
taskId: options.task,
|
|
90
|
+
diagnoseOnly: options.diagnoseOnly
|
|
91
|
+
});
|
|
92
|
+
if (options.json) {
|
|
93
|
+
console.log(JSON.stringify(result, null, 2));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// 展示诊断信息
|
|
97
|
+
console.log('\n🔍 调试会话已初始化');
|
|
98
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
99
|
+
console.log(`会话 ID: ${result.sessionId}`);
|
|
100
|
+
console.log(`状态: ${result.status}`);
|
|
101
|
+
console.log(`问题类型: ${result.problemType}`);
|
|
102
|
+
console.log(`问题描述: ${result.report.description}`);
|
|
103
|
+
if (result.report.relatedTaskId) {
|
|
104
|
+
console.log(`关联任务: ${result.report.relatedTaskId}`);
|
|
105
|
+
}
|
|
106
|
+
if (result.report.errorInfo?.message) {
|
|
107
|
+
console.log(`错误信息: ${result.report.errorInfo.message}`);
|
|
108
|
+
}
|
|
109
|
+
if (result.report.relatedFiles && result.report.relatedFiles.length > 0) {
|
|
110
|
+
console.log(`相关文件: ${result.report.relatedFiles.join(', ')}`);
|
|
111
|
+
}
|
|
112
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
113
|
+
console.log('\n💡 下一步:');
|
|
114
|
+
console.log(' 使用 /om:debug 进入系统化调试流程');
|
|
115
|
+
console.log(' 或使用 openmatrix debug --list 查看所有调试记录');
|
|
116
|
+
});
|
|
@@ -62,7 +62,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
62
62
|
}
|
|
63
63
|
catch (err) {
|
|
64
64
|
console.error('❌ Cannot create directory:', commandsDir);
|
|
65
|
-
console.error(' Error:', err.message);
|
|
65
|
+
console.error(' Error:', err instanceof Error ? err.message : String(err));
|
|
66
66
|
process.exit(1);
|
|
67
67
|
}
|
|
68
68
|
// Get skill files (excluding om.md and openmatrix.md which are handled separately)
|
|
@@ -92,7 +92,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
92
92
|
installed++;
|
|
93
93
|
}
|
|
94
94
|
catch (err) {
|
|
95
|
-
console.log(` ❌ Failed: ${file} (${err.message})`);
|
|
95
|
+
console.log(` ❌ Failed: ${file} (${err instanceof Error ? err.message : String(err)})`);
|
|
96
96
|
failed++;
|
|
97
97
|
}
|
|
98
98
|
});
|
|
@@ -112,7 +112,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
catch (err) {
|
|
115
|
-
console.log(` ❌ Failed: om.md (${err.message})`);
|
|
115
|
+
console.log(` ❌ Failed: om.md (${err instanceof Error ? err.message : String(err)})`);
|
|
116
116
|
failed++;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -132,7 +132,7 @@ exports.installSkillsCommand = new commander_1.Command('install-skills')
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
catch (err) {
|
|
135
|
-
console.log(` ❌ Failed: openmatrix.md (${err.message})`);
|
|
135
|
+
console.log(` ❌ Failed: openmatrix.md (${err instanceof Error ? err.message : String(err)})`);
|
|
136
136
|
failed++;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -1,2 +1,25 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import type { GlobalState, Task, Approval } from '../../types/index.js';
|
|
2
3
|
export declare const reportCommand: Command;
|
|
4
|
+
export interface TaskStats {
|
|
5
|
+
total: number;
|
|
6
|
+
completed: number;
|
|
7
|
+
failed: number;
|
|
8
|
+
inProgress: number;
|
|
9
|
+
pending: number;
|
|
10
|
+
blocked: number;
|
|
11
|
+
}
|
|
12
|
+
export interface EfficiencyData {
|
|
13
|
+
totalDuration: number;
|
|
14
|
+
agentCalls: number;
|
|
15
|
+
retryCount: number;
|
|
16
|
+
parallelism: number;
|
|
17
|
+
targetParallelism: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ReportOptions {
|
|
20
|
+
format: string;
|
|
21
|
+
output?: string;
|
|
22
|
+
efficiency?: boolean;
|
|
23
|
+
graph?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function generateMarkdownReport(state: GlobalState, tasks: Task[], approvals: Approval[], stats: TaskStats, efficiency: EfficiencyData, options: ReportOptions): string;
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.reportCommand = void 0;
|
|
37
|
+
exports.generateMarkdownReport = generateMarkdownReport;
|
|
37
38
|
// src/cli/commands/report.ts
|
|
38
39
|
const commander_1 = require("commander");
|
|
39
40
|
const state_manager_js_1 = require("../../storage/state-manager.js");
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
export declare const statusCommand: Command;
|
|
3
|
+
/**
|
|
4
|
+
* 格式化状态显示
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatStatus(status: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 获取状态颜色函数
|
|
9
|
+
*/
|
|
10
|
+
export declare function getStatusColor(status: string): (text: string) => string;
|
|
@@ -37,6 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.statusCommand = void 0;
|
|
40
|
+
exports.formatStatus = formatStatus;
|
|
41
|
+
exports.getStatusColor = getStatusColor;
|
|
40
42
|
const commander_1 = require("commander");
|
|
41
43
|
const state_manager_js_1 = require("../../storage/state-manager.js");
|
|
42
44
|
const progress_reporter_js_1 = require("../../utils/progress-reporter.js");
|
|
@@ -197,29 +199,28 @@ async function runWatchMode(manager, reporter, options) {
|
|
|
197
199
|
* 格式化状态显示
|
|
198
200
|
*/
|
|
199
201
|
function formatStatus(status) {
|
|
200
|
-
const
|
|
201
|
-
initialized:
|
|
202
|
-
running:
|
|
203
|
-
paused:
|
|
204
|
-
completed:
|
|
205
|
-
failed:
|
|
202
|
+
const colorMap = {
|
|
203
|
+
initialized: chalk_1.default.gray,
|
|
204
|
+
running: chalk_1.default.green,
|
|
205
|
+
paused: chalk_1.default.yellow,
|
|
206
|
+
completed: chalk_1.default.green,
|
|
207
|
+
failed: chalk_1.default.red
|
|
206
208
|
};
|
|
207
|
-
const
|
|
208
|
-
return
|
|
209
|
+
const colorFn = colorMap[status] || chalk_1.default.white;
|
|
210
|
+
return colorFn(status);
|
|
209
211
|
}
|
|
210
212
|
/**
|
|
211
213
|
* 获取状态颜色函数
|
|
212
214
|
*/
|
|
213
215
|
function getStatusColor(status) {
|
|
214
|
-
const
|
|
215
|
-
completed:
|
|
216
|
-
in_progress:
|
|
217
|
-
failed:
|
|
218
|
-
blocked:
|
|
219
|
-
pending:
|
|
220
|
-
verify:
|
|
221
|
-
accept:
|
|
216
|
+
const colorMap = {
|
|
217
|
+
completed: chalk_1.default.green,
|
|
218
|
+
in_progress: chalk_1.default.blue,
|
|
219
|
+
failed: chalk_1.default.red,
|
|
220
|
+
blocked: chalk_1.default.red,
|
|
221
|
+
pending: chalk_1.default.gray,
|
|
222
|
+
verify: chalk_1.default.yellow,
|
|
223
|
+
accept: chalk_1.default.cyan
|
|
222
224
|
};
|
|
223
|
-
|
|
224
|
-
return chalk_1.default[color];
|
|
225
|
+
return colorMap[status] || chalk_1.default.white;
|
|
225
226
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const check_gitignore_js_1 = require("./commands/check-gitignore.js");
|
|
|
51
51
|
const analyze_js_1 = require("./commands/analyze.js");
|
|
52
52
|
const brainstorm_js_1 = require("./commands/brainstorm.js");
|
|
53
53
|
const research_js_1 = require("./commands/research.js");
|
|
54
|
+
const debug_js_1 = require("./commands/debug.js");
|
|
54
55
|
const complete_js_1 = require("./commands/complete.js");
|
|
55
56
|
const step_js_1 = require("./commands/step.js");
|
|
56
57
|
// 读取 package.json 版本
|
|
@@ -85,5 +86,6 @@ program.addCommand(check_gitignore_js_1.checkGitignoreCommand);
|
|
|
85
86
|
program.addCommand(analyze_js_1.analyzeCommand);
|
|
86
87
|
program.addCommand(brainstorm_js_1.brainstormCommand);
|
|
87
88
|
program.addCommand(research_js_1.researchCommand);
|
|
89
|
+
program.addCommand(debug_js_1.debugCommand);
|
|
88
90
|
// 默认帮助
|
|
89
91
|
program.parse();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DebugContext {
|
|
2
|
+
state?: Record<string, unknown>;
|
|
3
|
+
task?: Record<string, unknown>;
|
|
4
|
+
logs?: string;
|
|
5
|
+
errorStack?: string;
|
|
6
|
+
projectFiles?: string[];
|
|
7
|
+
envInfo?: Record<string, unknown>;
|
|
8
|
+
configFiles?: string[];
|
|
9
|
+
cliLogs?: string;
|
|
10
|
+
systemState?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 根据问题类型收集上下文信息
|
|
14
|
+
*/
|
|
15
|
+
export declare class ContextCollector {
|
|
16
|
+
private basePath;
|
|
17
|
+
constructor(basePath: string);
|
|
18
|
+
collectForTaskFailure(taskId: string): Promise<DebugContext>;
|
|
19
|
+
collectForProjectBug(): Promise<DebugContext>;
|
|
20
|
+
collectForEnvironment(): Promise<DebugContext>;
|
|
21
|
+
collectForSystemBug(): Promise<DebugContext>;
|
|
22
|
+
private scanFiles;
|
|
23
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
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.ContextCollector = void 0;
|
|
37
|
+
// src/orchestrator/context-collector.ts
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* 根据问题类型收集上下文信息
|
|
42
|
+
*/
|
|
43
|
+
class ContextCollector {
|
|
44
|
+
basePath;
|
|
45
|
+
constructor(basePath) {
|
|
46
|
+
this.basePath = basePath;
|
|
47
|
+
}
|
|
48
|
+
async collectForTaskFailure(taskId) {
|
|
49
|
+
const context = {};
|
|
50
|
+
// 读取全局状态
|
|
51
|
+
const statePath = path.join(this.basePath, 'state.json');
|
|
52
|
+
if (fs.existsSync(statePath)) {
|
|
53
|
+
try {
|
|
54
|
+
context.state = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
|
|
55
|
+
}
|
|
56
|
+
catch { /* ignore */ }
|
|
57
|
+
}
|
|
58
|
+
// 读取任务文件
|
|
59
|
+
const taskPath = path.join(this.basePath, 'tasks', `${taskId}.json`);
|
|
60
|
+
if (fs.existsSync(taskPath)) {
|
|
61
|
+
try {
|
|
62
|
+
context.task = JSON.parse(fs.readFileSync(taskPath, 'utf-8'));
|
|
63
|
+
}
|
|
64
|
+
catch { /* ignore */ }
|
|
65
|
+
}
|
|
66
|
+
// 读取日志
|
|
67
|
+
const logPath = path.join(this.basePath, 'logs');
|
|
68
|
+
if (fs.existsSync(logPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const files = fs.readdirSync(logPath);
|
|
71
|
+
const logs = files
|
|
72
|
+
.filter(f => f.endsWith('.log') || f.includes(taskId))
|
|
73
|
+
.map(f => fs.readFileSync(path.join(logPath, f), 'utf-8'))
|
|
74
|
+
.join('\n---\n');
|
|
75
|
+
if (logs)
|
|
76
|
+
context.logs = logs;
|
|
77
|
+
}
|
|
78
|
+
catch { /* ignore */ }
|
|
79
|
+
}
|
|
80
|
+
return context;
|
|
81
|
+
}
|
|
82
|
+
async collectForProjectBug() {
|
|
83
|
+
const context = {};
|
|
84
|
+
// 扫描项目关键文件
|
|
85
|
+
const projectRoot = path.resolve(this.basePath, '..');
|
|
86
|
+
const scanDirs = ['src', 'lib', 'app', 'server', 'api', 'controllers', 'routes'];
|
|
87
|
+
const projectFiles = [];
|
|
88
|
+
for (const dir of scanDirs) {
|
|
89
|
+
const fullPath = path.join(projectRoot, dir);
|
|
90
|
+
if (fs.existsSync(fullPath)) {
|
|
91
|
+
const files = this.scanFiles(fullPath, ['.ts', '.js', '.tsx', '.jsx'], 2);
|
|
92
|
+
projectFiles.push(...files);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (projectFiles.length > 0) {
|
|
96
|
+
context.projectFiles = projectFiles.slice(0, 50);
|
|
97
|
+
}
|
|
98
|
+
return context;
|
|
99
|
+
}
|
|
100
|
+
async collectForEnvironment() {
|
|
101
|
+
const context = {};
|
|
102
|
+
// 收集环境信息
|
|
103
|
+
const envInfo = {
|
|
104
|
+
nodeVersion: process.version,
|
|
105
|
+
platform: process.platform,
|
|
106
|
+
cwd: process.cwd(),
|
|
107
|
+
envVars: Object.keys(process.env).slice(0, 20)
|
|
108
|
+
};
|
|
109
|
+
context.envInfo = envInfo;
|
|
110
|
+
// 扫描配置文件
|
|
111
|
+
const projectRoot = path.resolve(this.basePath, '..');
|
|
112
|
+
const configFiles = [
|
|
113
|
+
'package.json',
|
|
114
|
+
'tsconfig.json',
|
|
115
|
+
'.env',
|
|
116
|
+
'.env.local',
|
|
117
|
+
'config.json',
|
|
118
|
+
'webpack.config.js',
|
|
119
|
+
'vite.config.ts',
|
|
120
|
+
'.openmatrix/state.json'
|
|
121
|
+
];
|
|
122
|
+
const found = [];
|
|
123
|
+
for (const file of configFiles) {
|
|
124
|
+
const fullPath = path.join(projectRoot, file);
|
|
125
|
+
if (fs.existsSync(fullPath)) {
|
|
126
|
+
found.push(file);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (found.length > 0) {
|
|
130
|
+
context.configFiles = found;
|
|
131
|
+
}
|
|
132
|
+
return context;
|
|
133
|
+
}
|
|
134
|
+
async collectForSystemBug() {
|
|
135
|
+
const context = {};
|
|
136
|
+
// 读取系统状态
|
|
137
|
+
const statePath = path.join(this.basePath, 'state.json');
|
|
138
|
+
if (fs.existsSync(statePath)) {
|
|
139
|
+
try {
|
|
140
|
+
context.systemState = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
|
|
141
|
+
}
|
|
142
|
+
catch { /* ignore */ }
|
|
143
|
+
}
|
|
144
|
+
return context;
|
|
145
|
+
}
|
|
146
|
+
scanFiles(dir, extensions, maxDepth, currentDepth = 0) {
|
|
147
|
+
if (currentDepth > maxDepth)
|
|
148
|
+
return [];
|
|
149
|
+
const results = [];
|
|
150
|
+
try {
|
|
151
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
152
|
+
for (const entry of entries) {
|
|
153
|
+
const fullPath = path.join(dir, entry.name);
|
|
154
|
+
if (entry.isDirectory()) {
|
|
155
|
+
if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
156
|
+
results.push(...this.scanFiles(fullPath, extensions, maxDepth, currentDepth + 1));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else if (extensions.some(ext => entry.name.endsWith(ext))) {
|
|
160
|
+
results.push(fullPath.replace(process.cwd() + path.sep, ''));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch { /* ignore */ }
|
|
165
|
+
return results;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.ContextCollector = ContextCollector;
|