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,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const debugCommand: Command;
@@ -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
+ });
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;
@@ -0,0 +1,52 @@
1
+ import type { DebugSession, DiagnosisReport, ProblemType } from '../types/index.js';
2
+ export interface DebugConfig {
3
+ description?: string;
4
+ taskId?: string;
5
+ diagnoseOnly?: boolean;
6
+ }
7
+ export interface DebugInitResult {
8
+ sessionId: string;
9
+ status: string;
10
+ problemType: ProblemType;
11
+ report: Partial<DiagnosisReport>;
12
+ }
13
+ /**
14
+ * 调试管理器 - 协调整个调试流程
15
+ */
16
+ export declare class DebugManager {
17
+ private omPath;
18
+ private detector;
19
+ private collector;
20
+ private reporter;
21
+ constructor(omPath: string);
22
+ /**
23
+ * 初始化调试会话
24
+ */
25
+ initialize(config: DebugConfig): Promise<DebugInitResult>;
26
+ /**
27
+ * 获取会话
28
+ */
29
+ getSession(sessionId: string): DebugSession | null;
30
+ /**
31
+ * 更新会话
32
+ */
33
+ updateSession(sessionId: string, updates: Partial<DebugSession>): void;
34
+ /**
35
+ * 完成会话
36
+ */
37
+ completeSession(sessionId: string): Promise<string | null>;
38
+ /**
39
+ * 列出最近的调试会话
40
+ */
41
+ listRecent(): {
42
+ id: string;
43
+ status: string;
44
+ description: string;
45
+ createdAt: string;
46
+ }[];
47
+ private collectContext;
48
+ private getTaskError;
49
+ private saveSession;
50
+ private getSessionPath;
51
+ private generateSessionId;
52
+ }
@@ -0,0 +1,214 @@
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.DebugManager = void 0;
37
+ // src/orchestrator/debug-manager.ts
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const problem_detector_js_1 = require("./problem-detector.js");
41
+ const context_collector_js_1 = require("./context-collector.js");
42
+ const debug_reporter_js_1 = require("./debug-reporter.js");
43
+ /**
44
+ * 调试管理器 - 协调整个调试流程
45
+ */
46
+ class DebugManager {
47
+ omPath;
48
+ detector;
49
+ collector;
50
+ reporter;
51
+ constructor(omPath) {
52
+ this.omPath = omPath;
53
+ this.detector = new problem_detector_js_1.ProblemDetector();
54
+ this.collector = new context_collector_js_1.ContextCollector(omPath);
55
+ this.reporter = new debug_reporter_js_1.DebugReporter(omPath);
56
+ }
57
+ /**
58
+ * 初始化调试会话
59
+ */
60
+ async initialize(config) {
61
+ // 如果有任务 ID,尝试读取任务信息
62
+ let taskError = null;
63
+ if (config.taskId) {
64
+ taskError = await this.getTaskError(config.taskId);
65
+ }
66
+ // 判断问题类型
67
+ const problemType = await this.detector.detect({
68
+ description: config.description,
69
+ taskId: config.taskId,
70
+ taskError
71
+ });
72
+ // 收集上下文
73
+ const context = await this.collectContext(problemType, config);
74
+ // 创建会话
75
+ const sessionId = this.generateSessionId();
76
+ const session = {
77
+ id: sessionId,
78
+ status: config.diagnoseOnly ? 'initialized' : 'diagnosing',
79
+ report: {
80
+ id: sessionId,
81
+ problemType,
82
+ trigger: config.taskId ? 'auto' : 'explicit',
83
+ description: config.description || `调试任务 ${config.taskId}`,
84
+ relatedTaskId: config.taskId,
85
+ errorInfo: taskError ? {
86
+ message: taskError,
87
+ timestamp: new Date().toISOString()
88
+ } : undefined,
89
+ relatedFiles: context.projectFiles || [],
90
+ rootCause: '', // 由 Skill 阶段 Agent 填充
91
+ impactScope: [],
92
+ suggestedFix: '', // 由 Skill 阶段 Agent 填充
93
+ diagnosedAt: new Date().toISOString()
94
+ },
95
+ retryCount: 0,
96
+ createdAt: new Date().toISOString(),
97
+ updatedAt: new Date().toISOString()
98
+ };
99
+ // 持久化会话
100
+ this.saveSession(session);
101
+ return {
102
+ sessionId,
103
+ status: session.status,
104
+ problemType,
105
+ report: {
106
+ description: session.report.description,
107
+ relatedTaskId: session.report.relatedTaskId,
108
+ relatedFiles: session.report.relatedFiles,
109
+ errorInfo: session.report.errorInfo
110
+ }
111
+ };
112
+ }
113
+ /**
114
+ * 获取会话
115
+ */
116
+ getSession(sessionId) {
117
+ const sessionPath = this.getSessionPath(sessionId);
118
+ if (!fs.existsSync(sessionPath))
119
+ return null;
120
+ try {
121
+ return JSON.parse(fs.readFileSync(sessionPath, 'utf-8'));
122
+ }
123
+ catch {
124
+ return null;
125
+ }
126
+ }
127
+ /**
128
+ * 更新会话
129
+ */
130
+ updateSession(sessionId, updates) {
131
+ const session = this.getSession(sessionId);
132
+ if (!session)
133
+ return;
134
+ Object.assign(session, updates, { updatedAt: new Date().toISOString() });
135
+ this.saveSession(session);
136
+ }
137
+ /**
138
+ * 完成会话
139
+ */
140
+ async completeSession(sessionId) {
141
+ const session = this.getSession(sessionId);
142
+ if (!session)
143
+ return null;
144
+ session.status = 'completed';
145
+ session.completedAt = new Date().toISOString();
146
+ this.saveSession(session);
147
+ return await this.reporter.generateReport(session);
148
+ }
149
+ /**
150
+ * 列出最近的调试会话
151
+ */
152
+ listRecent() {
153
+ const debugDir = path.join(this.omPath, 'debug');
154
+ if (!fs.existsSync(debugDir))
155
+ return [];
156
+ const files = fs.readdirSync(debugDir)
157
+ .filter(f => f.endsWith('.json') && f.startsWith('DEBUG-'))
158
+ .sort()
159
+ .reverse()
160
+ .slice(0, 10);
161
+ return files.map(f => {
162
+ const session = JSON.parse(fs.readFileSync(path.join(debugDir, f), 'utf-8'));
163
+ return {
164
+ id: session.id,
165
+ status: session.status,
166
+ description: session.report.description,
167
+ createdAt: session.createdAt
168
+ };
169
+ });
170
+ }
171
+ async collectContext(problemType, config) {
172
+ switch (problemType) {
173
+ case 'task_failure':
174
+ return config.taskId ? await this.collector.collectForTaskFailure(config.taskId) : {};
175
+ case 'project_bug':
176
+ return await this.collector.collectForProjectBug();
177
+ case 'environment':
178
+ return await this.collector.collectForEnvironment();
179
+ case 'system_bug':
180
+ return await this.collector.collectForSystemBug();
181
+ default:
182
+ return {};
183
+ }
184
+ }
185
+ async getTaskError(taskId) {
186
+ const taskPath = path.join(this.omPath, 'tasks', `${taskId}.json`);
187
+ if (!fs.existsSync(taskPath))
188
+ return null;
189
+ try {
190
+ const task = JSON.parse(fs.readFileSync(taskPath, 'utf-8'));
191
+ return task.error || null;
192
+ }
193
+ catch {
194
+ return null;
195
+ }
196
+ }
197
+ saveSession(session) {
198
+ const debugDir = path.join(this.omPath, 'debug');
199
+ if (!fs.existsSync(debugDir)) {
200
+ fs.mkdirSync(debugDir, { recursive: true });
201
+ }
202
+ const sessionPath = this.getSessionPath(session.id);
203
+ fs.writeFileSync(sessionPath, JSON.stringify(session, null, 2), 'utf-8');
204
+ }
205
+ getSessionPath(sessionId) {
206
+ return path.join(this.omPath, 'debug', `${sessionId}.json`);
207
+ }
208
+ generateSessionId() {
209
+ const timestamp = Date.now().toString(36).toUpperCase();
210
+ const random = Math.random().toString(36).substring(2, 5).toUpperCase();
211
+ return `DEBUG-${timestamp}${random}`;
212
+ }
213
+ }
214
+ exports.DebugManager = DebugManager;
@@ -0,0 +1,25 @@
1
+ import type { DebugSession } from '../types/index.js';
2
+ /**
3
+ * 生成和保存诊断报告
4
+ */
5
+ export declare class DebugReporter {
6
+ private debugDir;
7
+ constructor(basePath: string);
8
+ /**
9
+ * 生成诊断报告文件
10
+ */
11
+ generateReport(session: DebugSession): Promise<string>;
12
+ /**
13
+ * 格式化报告内容为 Markdown
14
+ */
15
+ private formatReport;
16
+ /**
17
+ * 列出所有诊断报告
18
+ */
19
+ listReports(): {
20
+ id: string;
21
+ path: string;
22
+ createdAt: string;
23
+ }[];
24
+ private ensureDir;
25
+ }