openmatrix 0.2.6 → 0.2.8

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.
@@ -82,7 +82,6 @@ class AgentRunner {
82
82
  const subagentType = this.mapAgentType(task.assignedAgent);
83
83
  const prompt = await this.buildExecutionPrompt(task);
84
84
  const needsIsolation = this.needsIsolation(task);
85
- console.log(`🤖 Preparing ${task.assignedAgent} subagent for task ${task.id}`);
86
85
  return {
87
86
  subagent_type: subagentType,
88
87
  description: `${task.assignedAgent}: ${task.title.slice(0, 50)}`,
@@ -4,6 +4,7 @@ exports.analyzeCommand = void 0;
4
4
  // src/cli/commands/analyze.ts
5
5
  const commander_1 = require("commander");
6
6
  const smart_question_analyzer_js_1 = require("../../orchestrator/smart-question-analyzer.js");
7
+ const logger_js_1 = require("../../utils/logger.js");
7
8
  exports.analyzeCommand = new commander_1.Command('analyze')
8
9
  .description('智能分析任务,推断配置,返回需要确认的问题列表')
9
10
  .argument('[task]', '任务描述')
@@ -12,14 +13,14 @@ exports.analyzeCommand = new commander_1.Command('analyze')
12
13
  const analyzer = new smart_question_analyzer_js_1.SmartQuestionAnalyzer(process.cwd());
13
14
  if (!task) {
14
15
  if (options.json) {
15
- console.log(JSON.stringify({
16
+ logger_js_1.logger.info(JSON.stringify({
16
17
  status: 'error',
17
18
  message: '请提供任务描述'
18
19
  }));
19
20
  }
20
21
  else {
21
- console.log('❌ 请提供任务描述');
22
- console.log(' 用法: openmatrix analyze "实现用户登录功能"');
22
+ logger_js_1.logger.info('❌ 请提供任务描述');
23
+ logger_js_1.logger.info(' 用法: openmatrix analyze "实现用户登录功能"');
23
24
  }
24
25
  return;
25
26
  }
@@ -28,22 +29,22 @@ exports.analyzeCommand = new commander_1.Command('analyze')
28
29
  if (options.json) {
29
30
  // 输出 JSON 格式 (供 Skill 解析)
30
31
  const output = result;
31
- console.log(JSON.stringify(output, null, 2));
32
+ logger_js_1.logger.info(JSON.stringify(output, null, 2));
32
33
  }
33
34
  else {
34
35
  // 输出人类可读格式
35
- console.log('\n' + analyzer.generateSummary(result));
36
+ logger_js_1.logger.info('\n' + analyzer.generateSummary(result));
36
37
  }
37
38
  }
38
39
  catch (error) {
39
40
  if (options.json) {
40
- console.log(JSON.stringify({
41
+ logger_js_1.logger.info(JSON.stringify({
41
42
  status: 'error',
42
43
  message: error instanceof Error ? error.message : '分析失败'
43
44
  }));
44
45
  }
45
46
  else {
46
- console.log('❌ 分析失败:', error instanceof Error ? error.message : '未知错误');
47
+ logger_js_1.logger.info('❌ 分析失败: ' + (error instanceof Error ? error.message : '未知错误'));
47
48
  }
48
49
  }
49
50
  });
@@ -5,6 +5,7 @@ exports.approveCommand = void 0;
5
5
  const commander_1 = require("commander");
6
6
  const state_manager_js_1 = require("../../storage/state-manager.js");
7
7
  const approval_manager_js_1 = require("../../orchestrator/approval-manager.js");
8
+ const logger_js_1 = require("../../utils/logger.js");
8
9
  exports.approveCommand = new commander_1.Command('approve')
9
10
  .description('审批待处理项')
10
11
  .argument('[approvalId]', '审批ID')
@@ -22,18 +23,18 @@ exports.approveCommand = new commander_1.Command('approve')
22
23
  const pendingApprovals = await approvalManager.getPendingApprovals();
23
24
  if (pendingApprovals.length === 0) {
24
25
  if (options.json) {
25
- console.log(JSON.stringify({ status: 'empty', pending: [] }));
26
+ logger_js_1.logger.info(JSON.stringify({ status: 'empty', pending: [] }));
26
27
  }
27
28
  else {
28
- console.log('✅ 没有待处理的审批');
29
+ logger_js_1.logger.info('✅ 没有待处理的审批');
29
30
  }
30
31
  return;
31
32
  }
32
33
  if (options.json) {
33
- console.log(JSON.stringify({ status: 'pending', pending: pendingApprovals }));
34
+ logger_js_1.logger.info(JSON.stringify({ status: 'pending', pending: pendingApprovals }));
34
35
  }
35
36
  else {
36
- console.log('📋 待处理审批:\n');
37
+ logger_js_1.logger.info('📋 待处理审批:\n');
37
38
  pendingApprovals.forEach((approval, i) => {
38
39
  const typeEmoji = {
39
40
  plan: '📋',
@@ -43,44 +44,44 @@ exports.approveCommand = new commander_1.Command('approve')
43
44
  custom: '📝'
44
45
  };
45
46
  const emoji = typeEmoji[approval.type] || '📝';
46
- console.log(` [${i + 1}] ${emoji} ${approval.id}: ${approval.title}`);
47
- console.log(` 类型: ${approval.type} | 任务: ${approval.taskId}`);
47
+ logger_js_1.logger.info(` [${i + 1}] ${emoji} ${approval.id}: ${approval.title}`);
48
+ logger_js_1.logger.info(` 类型: ${approval.type} | 任务: ${approval.taskId}`);
48
49
  });
49
- console.log('\n💡 使用 openmatrix approve <ID> 处理审批');
50
+ logger_js_1.logger.info('\n💡 使用 openmatrix approve <ID> 处理审批');
50
51
  }
51
52
  return;
52
53
  }
53
54
  // 获取审批
54
55
  const approval = await approvalManager.getApproval(approvalId);
55
56
  if (!approval) {
56
- console.log(`❌ 审批 ${approvalId} 不存在`);
57
+ logger_js_1.logger.info(`❌ 审批 ${approvalId} 不存在`);
57
58
  return;
58
59
  }
59
60
  if (approval.status !== 'pending') {
60
- console.log(`❌ 审批 ${approvalId} 已处理`);
61
- console.log(` 状态: ${approval.status}`);
62
- console.log(` 决策: ${approval.decision}`);
61
+ logger_js_1.logger.info(`❌ 审批 ${approvalId} 已处理`);
62
+ logger_js_1.logger.info(` 状态: ${approval.status}`);
63
+ logger_js_1.logger.info(` 决策: ${approval.decision}`);
63
64
  return;
64
65
  }
65
66
  // 如果没有提供决策,显示审批内容
66
67
  if (!options.decision) {
67
- console.log(`\n📋 审批详情\n`);
68
- console.log(`ID: ${approval.id}`);
69
- console.log(`类型: ${approval.type}`);
70
- console.log(`任务: ${approval.taskId}`);
71
- console.log(`\n${approval.content}\n`);
72
- console.log('选项:');
68
+ logger_js_1.logger.info(`\n📋 审批详情\n`);
69
+ logger_js_1.logger.info(`ID: ${approval.id}`);
70
+ logger_js_1.logger.info(`类型: ${approval.type}`);
71
+ logger_js_1.logger.info(`任务: ${approval.taskId}`);
72
+ logger_js_1.logger.info(`\n${approval.content}\n`);
73
+ logger_js_1.logger.info('选项:');
73
74
  approval.options.forEach(opt => {
74
- console.log(` ${opt.key}: ${opt.label}`);
75
+ logger_js_1.logger.info(` ${opt.key}: ${opt.label}`);
75
76
  });
76
- console.log('\n💡 使用 openmatrix approve <ID> -d <decision>');
77
+ logger_js_1.logger.info('\n💡 使用 openmatrix approve <ID> -d <decision>');
77
78
  return;
78
79
  }
79
80
  // 处理决策
80
81
  const validDecisions = ['approve', 'modify', 'reject'];
81
82
  if (!validDecisions.includes(options.decision)) {
82
- console.log(`❌ 无效决策: ${options.decision}`);
83
- console.log(` 有效选项: ${validDecisions.join(', ')}`);
83
+ logger_js_1.logger.info(`❌ 无效决策: ${options.decision}`);
84
+ logger_js_1.logger.info(` 有效选项: ${validDecisions.join(', ')}`);
84
85
  return;
85
86
  }
86
87
  await approvalManager.processDecision({
@@ -91,8 +92,8 @@ exports.approveCommand = new commander_1.Command('approve')
91
92
  decidedAt: new Date().toISOString()
92
93
  });
93
94
  const statusEmoji = options.decision === 'approve' ? '✅' : '❌';
94
- console.log(`\n${statusEmoji} 审批已处理: ${options.decision}`);
95
+ logger_js_1.logger.info(`\n${statusEmoji} 审批已处理: ${options.decision}`);
95
96
  if (options.decision === 'approve') {
96
- console.log('\n💡 使用 /om:resume 继续执行任务');
97
+ logger_js_1.logger.info('\n💡 使用 /om:resume 继续执行任务');
97
98
  }
98
99
  });
@@ -1,2 +1,117 @@
1
1
  import { Command } from 'commander';
2
+ /**
3
+ * CLI 选项接口
4
+ */
5
+ export interface BrainstormOptions {
6
+ json?: boolean;
7
+ complete?: boolean;
8
+ results?: string;
9
+ }
10
+ /**
11
+ * 头脑风暴问题类型
12
+ */
13
+ interface BrainstormQuestion {
14
+ id: string;
15
+ question: string;
16
+ header: string;
17
+ options: Array<{
18
+ label: string;
19
+ description: string;
20
+ }>;
21
+ multiSelect: boolean;
22
+ why: string;
23
+ }
24
+ /**
25
+ * 头脑风暴阶段结果
26
+ */
27
+ export interface BrainstormResult {
28
+ status: 'brainstorming' | 'ready_to_start';
29
+ taskInput: string;
30
+ taskTitle: string;
31
+ questions: BrainstormQuestion[];
32
+ answers: Record<string, string | string[]>;
33
+ insights: string[];
34
+ designNotes: string[];
35
+ /** 如果检测到垂直领域,建议进入 research */
36
+ suggestResearch?: string;
37
+ }
2
38
  export declare const brainstormCommand: Command;
39
+ /**
40
+ * 处理 --complete 模式:标记头脑风暴完成,输出 start 所需信息
41
+ */
42
+ export declare function handleCompleteMode(brainstormPath: string, options: BrainstormOptions): Promise<void>;
43
+ /**
44
+ * 合并外部传入的结果到已有会话
45
+ */
46
+ export declare function mergeSessionResults(session: BrainstormResult, resultsJson?: string): void;
47
+ /**
48
+ * 输出 complete 模式的结果
49
+ */
50
+ export declare function outputCompleteResult(session: BrainstormResult, jsonMode?: boolean): void;
51
+ /**
52
+ * 输出会话未找到的错误信息
53
+ */
54
+ export declare function outputSessionNotFound(jsonMode?: boolean): void;
55
+ /**
56
+ * 从输入参数或文件加载任务内容,返回 null 表示加载失败(已输出错误)
57
+ */
58
+ export declare function loadTaskContent(input: string | undefined, basePath: string, options: BrainstormOptions): Promise<string | null>;
59
+ /**
60
+ * 从默认 TASK.md 文件加载任务内容
61
+ */
62
+ export declare function loadTaskFromDefaultFile(basePath: string, jsonMode?: boolean): Promise<string | null>;
63
+ /**
64
+ * 从用户指定的 .md 文件加载任务内容
65
+ */
66
+ export declare function loadTaskFromSpecifiedFile(filePath: string, displayName: string, jsonMode?: boolean): Promise<string | null>;
67
+ /**
68
+ * 从任务内容中提取标题
69
+ */
70
+ export declare function extractTaskTitle(taskContent: string): string;
71
+ /**
72
+ * 创建新的头脑风暴会话并输出
73
+ */
74
+ export declare function createNewSession(taskContent: string, basePath: string, brainstormPath: string, options: BrainstormOptions): Promise<void>;
75
+ /**
76
+ * 输出新头脑风暴会话的信息
77
+ */
78
+ export declare function outputNewSession(taskTitle: string, questions: BrainstormQuestion[], domainDetection: {
79
+ isVertical: boolean;
80
+ domain: string;
81
+ }, jsonMode?: boolean): void;
82
+ /**
83
+ * JSON 模式输出新会话信息
84
+ */
85
+ export declare function outputNewSessionJson(taskTitle: string, questions: BrainstormQuestion[], domainDetection: {
86
+ isVertical: boolean;
87
+ domain: string;
88
+ }): void;
89
+ /**
90
+ * 文本模式输出新会话信息
91
+ */
92
+ export declare function outputNewSessionText(taskTitle: string, questions: BrainstormQuestion[], domainDetection: {
93
+ isVertical: boolean;
94
+ domain: string;
95
+ }): void;
96
+ /**
97
+ * 构建智能问题会话:解析任务 → 分析推断 → 生成问题
98
+ */
99
+ export declare function buildSmartQuestionSession(taskContent: string, basePath: string): Promise<import("../../orchestrator/interactive-question-generator.js").QuestionSession>;
100
+ /**
101
+ * 将智能会话问题转换为 BrainstormQuestion[] 格式
102
+ */
103
+ export declare function convertToBrainstormQuestions(session: {
104
+ questions: Array<{
105
+ id: string;
106
+ question: string;
107
+ category: string;
108
+ options?: Array<{
109
+ label: string;
110
+ description?: string;
111
+ }>;
112
+ type: string;
113
+ priority?: number;
114
+ }>;
115
+ skippedQuestionIds?: string[];
116
+ }): BrainstormQuestion[];
117
+ export {};