openmatrix 0.1.49 → 0.1.50
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 +4 -8
- package/dist/cli/commands/analyze.js +3 -4
- package/dist/cli/commands/brainstorm.js +52 -74
- package/dist/cli/commands/start.js +31 -163
- package/dist/cli/index.js +0 -4
- package/dist/orchestrator/smart-question-analyzer.d.ts +0 -38
- package/dist/orchestrator/smart-question-analyzer.js +7 -257
- package/dist/orchestrator/task-parser.d.ts +0 -8
- package/dist/orchestrator/task-parser.js +9 -22
- package/dist/orchestrator/task-planner.d.ts +45 -10
- package/dist/orchestrator/task-planner.js +282 -188
- package/dist/storage/state-manager.d.ts +0 -1
- package/dist/storage/state-manager.js +1 -1
- package/package.json +55 -56
- package/skills/brainstorm.md +238 -105
- package/skills/check.md +199 -199
- package/skills/openmatrix.md +190 -175
- package/skills/start.md +626 -171
package/README.md
CHANGED
|
@@ -45,25 +45,21 @@
|
|
|
45
45
|
| 用户输入 | 触发原因 |
|
|
46
46
|
|---------|---------|
|
|
47
47
|
| `实现用户登录功能` | 功能开发 |
|
|
48
|
-
| `登录页面报错了` | Bug 修复
|
|
49
|
-
| `修复下这个脚本` | 包含"修复" |
|
|
48
|
+
| `登录页面报错了` | Bug 修复 |
|
|
50
49
|
| `性能太慢需要优化` | 性能优化 |
|
|
51
50
|
| `写个单元测试` | 测试相关 |
|
|
52
|
-
|
|
|
53
|
-
| `弄个API接口` | 包含"弄" |
|
|
54
|
-
| `整个配置文件` | 包含"整" |
|
|
51
|
+
| `做个完整的用户系统` | 多组件任务 |
|
|
55
52
|
| `从零搭建一个后台` | 多步骤项目 |
|
|
53
|
+
| `前端+后端+数据库` | 全栈工作 |
|
|
56
54
|
|
|
57
55
|
**关键词触发:**
|
|
58
56
|
- `实现...` / `添加...` / `修复...` / `优化...` / `测试...`
|
|
59
|
-
- `帮我...` / `搞个...` / `弄个...` / `整个...` / `写个...`
|
|
60
57
|
- `支持...` / `需要...` / `想要...` / `要做...`
|
|
61
58
|
- `implement...` / `add...` / `fix...` / `build...`
|
|
62
59
|
- 任务文档路径: `docs/task.md`
|
|
63
|
-
- 问题诊断: `报错了` / `不工作了` / `太慢了` (隐含修复意图)
|
|
64
60
|
|
|
65
61
|
**不触发的情况:**
|
|
66
|
-
- 问问题: "
|
|
62
|
+
- 问问题: "怎么实现登录?" / "如何配置?"
|
|
67
63
|
- 查信息: "显示配置" / "列出文件"
|
|
68
64
|
- 导航: "打开目录" / "进入文件夹"
|
|
69
65
|
|
|
@@ -7,8 +7,7 @@ const smart_question_analyzer_js_1 = require("../../orchestrator/smart-question-
|
|
|
7
7
|
exports.analyzeCommand = new commander_1.Command('analyze')
|
|
8
8
|
.description('智能分析任务,推断配置,返回需要确认的问题列表')
|
|
9
9
|
.argument('[task]', '任务描述')
|
|
10
|
-
.option('--json', '输出 JSON
|
|
11
|
-
.option('--markdown', '输出 Markdown 格式(默认)')
|
|
10
|
+
.option('--json', '输出 JSON 格式')
|
|
12
11
|
.action(async (task, options) => {
|
|
13
12
|
const analyzer = new smart_question_analyzer_js_1.SmartQuestionAnalyzer(process.cwd());
|
|
14
13
|
if (!task) {
|
|
@@ -32,8 +31,8 @@ exports.analyzeCommand = new commander_1.Command('analyze')
|
|
|
32
31
|
console.log(JSON.stringify(output, null, 2));
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
35
|
-
//
|
|
36
|
-
console.log('\n' + analyzer.
|
|
34
|
+
// 输出人类可读格式
|
|
35
|
+
console.log('\n' + analyzer.generateSummary(result));
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
catch (error) {
|
|
@@ -79,12 +79,6 @@ exports.brainstormCommand = new commander_1.Command('brainstorm')
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
await fs.writeFile(brainstormPath, JSON.stringify(session, null, 2));
|
|
82
|
-
// 构建下一个步骤的命令
|
|
83
|
-
const brainstormAnswers = JSON.stringify({
|
|
84
|
-
answers: session.answers,
|
|
85
|
-
insights: session.insights,
|
|
86
|
-
designNotes: session.designNotes
|
|
87
|
-
});
|
|
88
82
|
if (options.json) {
|
|
89
83
|
console.log(JSON.stringify({
|
|
90
84
|
status: 'ready_to_start',
|
|
@@ -94,23 +88,7 @@ exports.brainstormCommand = new commander_1.Command('brainstorm')
|
|
|
94
88
|
answers: session.answers,
|
|
95
89
|
insights: session.insights,
|
|
96
90
|
designNotes: session.designNotes,
|
|
97
|
-
|
|
98
|
-
nextStep: {
|
|
99
|
-
required: true,
|
|
100
|
-
description: '必须调用此命令开始任务执行',
|
|
101
|
-
command: 'openmatrix',
|
|
102
|
-
args: ['start', session.taskInput.slice(0, 100)],
|
|
103
|
-
options: {
|
|
104
|
-
'brainstorm-answers': brainstormAnswers
|
|
105
|
-
},
|
|
106
|
-
hint: '使用 /om:start 开始执行任务'
|
|
107
|
-
},
|
|
108
|
-
// 强制执行标记 - Agent 必须执行 nextStep
|
|
109
|
-
_meta: {
|
|
110
|
-
requiresAction: true,
|
|
111
|
-
actionType: 'cli_command',
|
|
112
|
-
blocking: true
|
|
113
|
-
}
|
|
91
|
+
hint: '使用 /om:start 开始执行任务'
|
|
114
92
|
}));
|
|
115
93
|
}
|
|
116
94
|
else {
|
|
@@ -238,71 +216,71 @@ exports.brainstormCommand = new commander_1.Command('brainstorm')
|
|
|
238
216
|
});
|
|
239
217
|
/**
|
|
240
218
|
* 根据任务内容生成头脑风暴问题
|
|
241
|
-
*
|
|
242
|
-
* 基于"底层逻辑"方法论,不使用固定模板
|
|
243
219
|
*/
|
|
244
220
|
function generateBrainstormQuestions(taskContent, taskTitle) {
|
|
245
221
|
const questions = [];
|
|
246
|
-
|
|
247
|
-
// 1
|
|
222
|
+
const content = taskContent.toLowerCase();
|
|
223
|
+
// 问题 1: 核心目标
|
|
248
224
|
questions.push({
|
|
249
225
|
id: 'core_objective',
|
|
250
226
|
question: '这个任务的核心目标是什么?想要解决什么问题?',
|
|
251
227
|
header: '核心目标',
|
|
252
228
|
options: [
|
|
253
|
-
{ label: '
|
|
254
|
-
{ label: '
|
|
255
|
-
{ label: '
|
|
256
|
-
{ label: '
|
|
229
|
+
{ label: '实现新功能', description: '添加新的功能特性,扩展系统能力' },
|
|
230
|
+
{ label: '修复问题', description: '修复 Bug 或解决已知问题' },
|
|
231
|
+
{ label: '重构优化', description: '改进代码结构、性能或可维护性' },
|
|
232
|
+
{ label: '技术探索', description: '探索新技术方案,验证可行性' }
|
|
257
233
|
],
|
|
258
234
|
multiSelect: false,
|
|
259
|
-
why: '
|
|
235
|
+
why: '明确核心目标有助于选择正确的实现策略和质量标准'
|
|
260
236
|
});
|
|
261
|
-
// 2
|
|
237
|
+
// 问题 2: 用户价值
|
|
262
238
|
questions.push({
|
|
263
239
|
id: 'user_value',
|
|
264
|
-
question: '
|
|
240
|
+
question: '这个任务为用户带来什么价值?最终用户是谁?',
|
|
265
241
|
header: '用户价值',
|
|
266
242
|
options: [
|
|
267
|
-
{ label: '
|
|
268
|
-
{ label: '
|
|
269
|
-
{ label: '
|
|
270
|
-
{ label: '
|
|
243
|
+
{ label: '开发者', description: '主要用户是开发者,需要清晰的 API 和文档' },
|
|
244
|
+
{ label: '终端用户', description: '主要用户是终端用户,需要良好的用户体验' },
|
|
245
|
+
{ label: '运维人员', description: '主要用户是运维,需要稳定性和可观测性' },
|
|
246
|
+
{ label: '内部团队', description: '主要用户是内部团队,需要高效协作支持' }
|
|
271
247
|
],
|
|
272
248
|
multiSelect: false,
|
|
273
|
-
why: '
|
|
249
|
+
why: '了解目标用户有助于设计合适的接口和交互方式'
|
|
274
250
|
});
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
251
|
+
// 问题 3: 实现复杂度 - 如果任务内容包含复杂关键词
|
|
252
|
+
if (content.includes('架构') || content.includes('系统') || content.includes('集成') || content.includes('多个')) {
|
|
253
|
+
questions.push({
|
|
254
|
+
id: 'complexity',
|
|
255
|
+
question: '这个任务的实现复杂度如何?需要哪些关键组件?',
|
|
256
|
+
header: '复杂度',
|
|
257
|
+
options: [
|
|
258
|
+
{ label: '简单', description: '单一功能,少量代码修改' },
|
|
259
|
+
{ label: '中等', description: '需要多个组件协作,有依赖关系' },
|
|
260
|
+
{ label: '复杂', description: '涉及架构调整,需要仔细规划' },
|
|
261
|
+
{ label: '非常复杂', description: '大型重构或新系统,需要分阶段实施' }
|
|
262
|
+
],
|
|
263
|
+
multiSelect: false,
|
|
264
|
+
why: '复杂度评估有助于决定是否需要分阶段实施和额外的设计审查'
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
// 问题 4: 技术约束 - 如果涉及技术选型
|
|
268
|
+
if (content.includes('技术') || content.includes('框架') || content.includes('库')) {
|
|
269
|
+
questions.push({
|
|
270
|
+
id: 'tech_constraints',
|
|
271
|
+
question: '有哪些技术约束或偏好?需要使用/避免什么技术?',
|
|
272
|
+
header: '技术约束',
|
|
273
|
+
options: [
|
|
274
|
+
{ label: '使用现有技术栈', description: '复用项目已有的技术选择' },
|
|
275
|
+
{ label: '引入新技术', description: '需要引入新的库或框架' },
|
|
276
|
+
{ label: '保持技术中立', description: '不引入新依赖,使用原生方案' },
|
|
277
|
+
{ label: '需要技术调研', description: '技术选型不确定,需要先调研' }
|
|
278
|
+
],
|
|
279
|
+
multiSelect: false,
|
|
280
|
+
why: '技术约束影响实现方案和后续维护成本'
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// 问题 5: 风险评估
|
|
306
284
|
questions.push({
|
|
307
285
|
id: 'risks',
|
|
308
286
|
question: '这个任务可能面临哪些风险或挑战?',
|
|
@@ -316,7 +294,7 @@ function generateBrainstormQuestions(taskContent, taskTitle) {
|
|
|
316
294
|
multiSelect: true,
|
|
317
295
|
why: '识别风险有助于提前规划应对策略'
|
|
318
296
|
});
|
|
319
|
-
// 6
|
|
297
|
+
// 问题 6: 验收标准
|
|
320
298
|
questions.push({
|
|
321
299
|
id: 'acceptance',
|
|
322
300
|
question: '如何判断任务完成?有哪些验收标准?',
|
|
@@ -330,15 +308,15 @@ function generateBrainstormQuestions(taskContent, taskTitle) {
|
|
|
330
308
|
multiSelect: true,
|
|
331
309
|
why: '明确的验收标准有助于判断任务完成度'
|
|
332
310
|
});
|
|
333
|
-
// 7
|
|
311
|
+
// 问题 7: 实现优先级
|
|
334
312
|
questions.push({
|
|
335
313
|
id: 'priority',
|
|
336
|
-
question: '
|
|
314
|
+
question: '这个任务的优先级如何?是否需要 MVP 版本?',
|
|
337
315
|
header: '优先级',
|
|
338
316
|
options: [
|
|
339
317
|
{ label: '高优先级', description: '需要尽快完成,影响其他工作' },
|
|
340
318
|
{ label: '中优先级', description: '计划内任务,按正常节奏推进' },
|
|
341
|
-
{ label: '低优先级', description: '
|
|
319
|
+
{ label: '低优先级', description: '可延后处理,有更重要的任务' },
|
|
342
320
|
{ label: '需要 MVP', description: '先实现最小可用版本,再迭代' }
|
|
343
321
|
],
|
|
344
322
|
multiSelect: false,
|
|
@@ -58,7 +58,6 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
58
58
|
.option('-q, --quality <level>', '质量级别 (strict|balanced|fast)')
|
|
59
59
|
.option('-t, --tech-stack <stack>', '技术栈 (逗号分隔,如 "TypeScript,Vue.js,PostgreSQL")')
|
|
60
60
|
.option('--docs <level>', '文档级别 (full|basic|minimal|none)')
|
|
61
|
-
.option('--brainstorm-answers <json>', '从 brainstorm 传递的答案 JSON')
|
|
62
61
|
.action(async (input, options) => {
|
|
63
62
|
const basePath = process.cwd();
|
|
64
63
|
const omPath = path.join(basePath, '.openmatrix');
|
|
@@ -102,178 +101,68 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
102
101
|
}
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
|
-
// 检查 brainstorm 状态 (状态校验)
|
|
106
|
-
const brainstormPath = path.join(omPath, 'brainstorm', 'session.json');
|
|
107
|
-
try {
|
|
108
|
-
const brainstormContent = await fs.readFile(brainstormPath, 'utf-8');
|
|
109
|
-
const brainstormSession = JSON.parse(brainstormContent);
|
|
110
|
-
if (brainstormSession.status === 'brainstorming') {
|
|
111
|
-
// 检查是否有未回答的问题
|
|
112
|
-
const answeredCount = Object.keys(brainstormSession.answers || {}).length;
|
|
113
|
-
const totalQuestions = brainstormSession.questions?.length || 0;
|
|
114
|
-
if (answeredCount < totalQuestions && !options.brainstormAnswers) {
|
|
115
|
-
// brainstorm 未完成,且没有传递答案
|
|
116
|
-
if (options.json) {
|
|
117
|
-
console.log(JSON.stringify({
|
|
118
|
-
status: 'error',
|
|
119
|
-
code: 'BRAINSTORM_INCOMPLETE',
|
|
120
|
-
message: '头脑风暴未完成',
|
|
121
|
-
details: {
|
|
122
|
-
taskTitle: brainstormSession.taskTitle,
|
|
123
|
-
answeredCount,
|
|
124
|
-
totalQuestions,
|
|
125
|
-
missingQuestions: brainstormSession.questions
|
|
126
|
-
?.filter((q) => !brainstormSession.answers?.[q.id])
|
|
127
|
-
?.map((q) => ({ question: q.question, header: q.header })) || []
|
|
128
|
-
},
|
|
129
|
-
hint: '请先完成头脑风暴: /om:brainstorm,或传递 --brainstorm-answers 参数'
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
console.log('⚠️ 头脑风暴未完成!');
|
|
134
|
-
console.log(` 任务: ${brainstormSession.taskTitle}`);
|
|
135
|
-
console.log(` 进度: ${answeredCount}/${totalQuestions} 问题已回答`);
|
|
136
|
-
console.log('\n 未回答的问题:');
|
|
137
|
-
brainstormSession.questions
|
|
138
|
-
?.filter((q) => !brainstormSession.answers?.[q.id])
|
|
139
|
-
?.forEach((q, i) => {
|
|
140
|
-
console.log(` ${i + 1}. [${q.header}] ${q.question}`);
|
|
141
|
-
});
|
|
142
|
-
console.log('\n 💡 请先完成头脑风暴: /om:brainstorm');
|
|
143
|
-
console.log(' 或传递 --brainstorm-answers 参数跳过此检查');
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else if (brainstormSession.status === 'ready_to_start' || brainstormSession.status === 'completed') {
|
|
149
|
-
// 头脑风暴已完成,自动使用保存的答案(如果没有显式传递)
|
|
150
|
-
if (!options.brainstormAnswers && brainstormSession.answers) {
|
|
151
|
-
// 自动使用保存的 brainstorm 答案
|
|
152
|
-
options.brainstormAnswers = JSON.stringify({
|
|
153
|
-
answers: brainstormSession.answers,
|
|
154
|
-
insights: brainstormSession.insights || [],
|
|
155
|
-
designNotes: brainstormSession.designNotes || []
|
|
156
|
-
});
|
|
157
|
-
if (!options.json) {
|
|
158
|
-
console.log('📋 自动使用已完成的头脑风暴结果');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
// brainstorm 文件不存在,继续执行
|
|
165
|
-
}
|
|
166
104
|
// 构建任务内容
|
|
167
105
|
let taskContent = input;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
106
|
+
// 如果提供了 --title 和 --description,构建任务内容
|
|
107
|
+
if (options.title || options.description) {
|
|
108
|
+
const title = options.title || '未命名任务';
|
|
109
|
+
const description = options.description || '';
|
|
110
|
+
const techStack = options.techStack ? `\n\n技术栈: ${options.techStack}` : '';
|
|
111
|
+
const docs = options.docs ? `\n文档要求: ${options.docs}` : '';
|
|
112
|
+
taskContent = `# ${title}\n\n${description}${techStack}${docs}`;
|
|
113
|
+
}
|
|
114
|
+
// 如果没有任务内容,尝试读取默认文件
|
|
115
|
+
if (!taskContent) {
|
|
116
|
+
const defaultPath = path.join(basePath, 'TASK.md');
|
|
171
117
|
try {
|
|
172
|
-
taskContent = await fs.readFile(
|
|
118
|
+
taskContent = await fs.readFile(defaultPath, 'utf-8');
|
|
173
119
|
if (!options.json) {
|
|
174
|
-
console.log(`📄 读取任务文件: ${
|
|
120
|
+
console.log(`📄 读取任务文件: ${defaultPath}`);
|
|
175
121
|
}
|
|
176
122
|
}
|
|
177
123
|
catch {
|
|
178
124
|
if (options.json) {
|
|
179
125
|
console.log(JSON.stringify({
|
|
180
126
|
status: 'error',
|
|
181
|
-
message:
|
|
127
|
+
message: '请提供任务文件路径或描述'
|
|
182
128
|
}));
|
|
183
129
|
}
|
|
184
130
|
else {
|
|
185
|
-
console.log(
|
|
131
|
+
console.log('❌ 请提供任务文件路径或描述');
|
|
132
|
+
console.log(' 用法: openmatrix start <task.md>');
|
|
133
|
+
console.log(' 或创建 TASK.md 文件');
|
|
134
|
+
console.log(' 或使用 --title 和 --description 选项');
|
|
186
135
|
}
|
|
187
136
|
return;
|
|
188
137
|
}
|
|
189
138
|
}
|
|
190
|
-
else if (
|
|
191
|
-
//
|
|
192
|
-
const defaultPath = path.join(basePath, 'TASK.md');
|
|
139
|
+
else if (taskContent.endsWith('.md')) {
|
|
140
|
+
// 读取文件
|
|
193
141
|
try {
|
|
194
|
-
taskContent = await fs.readFile(
|
|
142
|
+
taskContent = await fs.readFile(taskContent, 'utf-8');
|
|
195
143
|
if (!options.json) {
|
|
196
|
-
console.log(`📄 读取任务文件: ${
|
|
144
|
+
console.log(`📄 读取任务文件: ${input}`);
|
|
197
145
|
}
|
|
198
146
|
}
|
|
199
147
|
catch {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const docs = options.docs ? `\n文档要求: ${options.docs}` : '';
|
|
206
|
-
taskContent = `# ${title}\n\n${description}${techStack}${docs}`;
|
|
207
|
-
titleOverride = undefined; // 内容已包含标题,不需要覆盖
|
|
148
|
+
if (options.json) {
|
|
149
|
+
console.log(JSON.stringify({
|
|
150
|
+
status: 'error',
|
|
151
|
+
message: `无法读取文件: ${input}`
|
|
152
|
+
}));
|
|
208
153
|
}
|
|
209
154
|
else {
|
|
210
|
-
|
|
211
|
-
console.log(JSON.stringify({
|
|
212
|
-
status: 'error',
|
|
213
|
-
message: '请提供任务文件路径或描述'
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
console.log('❌ 请提供任务文件路径或描述');
|
|
218
|
-
console.log(' 用法: openmatrix start <task.md>');
|
|
219
|
-
console.log(' 或创建 TASK.md 文件');
|
|
220
|
-
console.log(' 或使用 --title 和 --description 选项');
|
|
221
|
-
}
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
else if (!taskContent.endsWith('.md') && !taskContent.includes('\n')) {
|
|
227
|
-
// 如果输入是单行文本,可能是文件路径或简短描述
|
|
228
|
-
// 检查是否是文件
|
|
229
|
-
const possiblePath = path.join(basePath, taskContent);
|
|
230
|
-
try {
|
|
231
|
-
taskContent = await fs.readFile(possiblePath, 'utf-8');
|
|
232
|
-
if (!options.json) {
|
|
233
|
-
console.log(`📄 读取任务文件: ${possiblePath}`);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
// 不是文件,作为描述处理
|
|
238
|
-
if (options.title || options.description) {
|
|
239
|
-
const title = options.title || '未命名任务';
|
|
240
|
-
const description = options.description || taskContent;
|
|
241
|
-
const techStack = options.techStack ? `\n\n技术栈: ${options.techStack}` : '';
|
|
242
|
-
const docs = options.docs ? `\n文档要求: ${options.docs}` : '';
|
|
243
|
-
taskContent = `# ${title}\n\n${description}${techStack}${docs}`;
|
|
244
|
-
titleOverride = undefined;
|
|
155
|
+
console.log(`❌ 无法读取文件: ${input}`);
|
|
245
156
|
}
|
|
157
|
+
return;
|
|
246
158
|
}
|
|
247
159
|
}
|
|
248
|
-
// 如果有标题覆盖,更新任务内容中的标题
|
|
249
|
-
if (titleOverride && taskContent) {
|
|
250
|
-
// 替换第一个 # 标题
|
|
251
|
-
taskContent = taskContent.replace(/^#\s+.+$/m, `# ${titleOverride}`);
|
|
252
|
-
}
|
|
253
160
|
// 解析任务
|
|
254
161
|
if (!options.json) {
|
|
255
162
|
console.log('\n🔍 解析任务...');
|
|
256
163
|
}
|
|
257
164
|
const parser = new task_parser_js_1.TaskParser();
|
|
258
165
|
const parsedTask = parser.parse(taskContent);
|
|
259
|
-
// 解析 brainstorm 答案 (如果有)
|
|
260
|
-
let brainstormContext = {};
|
|
261
|
-
if (options.brainstormAnswers) {
|
|
262
|
-
try {
|
|
263
|
-
brainstormContext = JSON.parse(options.brainstormAnswers);
|
|
264
|
-
if (!options.json) {
|
|
265
|
-
console.log('\n🧠 使用 brainstorm 收集的信息:');
|
|
266
|
-
if (brainstormContext.answers) {
|
|
267
|
-
Object.entries(brainstormContext.answers).forEach(([key, value]) => {
|
|
268
|
-
console.log(` - ${key}: ${Array.isArray(value) ? value.join(', ') : value}`);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
catch {
|
|
274
|
-
// 忽略解析错误
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
166
|
if (!options.json) {
|
|
278
167
|
console.log(`\n📋 任务: ${parsedTask.title}`);
|
|
279
168
|
console.log(` 目标: ${parsedTask.goals.join(', ')}`);
|
|
@@ -283,27 +172,7 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
283
172
|
console.log('\n🔧 拆解任务...');
|
|
284
173
|
}
|
|
285
174
|
const planner = new task_planner_js_1.TaskPlanner();
|
|
286
|
-
|
|
287
|
-
// 注意: TaskPlanner.breakdown 需要 Record<string, string> 类型
|
|
288
|
-
const plannerContext = {};
|
|
289
|
-
if (brainstormContext.answers) {
|
|
290
|
-
plannerContext.brainstormAnswers = JSON.stringify(brainstormContext.answers);
|
|
291
|
-
}
|
|
292
|
-
if (brainstormContext.insights && brainstormContext.insights.length > 0) {
|
|
293
|
-
plannerContext.insights = brainstormContext.insights.join('; ');
|
|
294
|
-
}
|
|
295
|
-
if (brainstormContext.designNotes && brainstormContext.designNotes.length > 0) {
|
|
296
|
-
plannerContext.designNotes = brainstormContext.designNotes.join('; ');
|
|
297
|
-
}
|
|
298
|
-
// 添加技术栈信息
|
|
299
|
-
if (options.techStack) {
|
|
300
|
-
plannerContext.techStack = options.techStack;
|
|
301
|
-
}
|
|
302
|
-
// 添加质量级别
|
|
303
|
-
if (options.quality) {
|
|
304
|
-
plannerContext.qualityLevel = options.quality;
|
|
305
|
-
}
|
|
306
|
-
const subTasks = planner.breakdown(parsedTask, plannerContext);
|
|
175
|
+
const subTasks = planner.breakdown(parsedTask, {});
|
|
307
176
|
// 创建任务到状态管理器
|
|
308
177
|
for (const subTask of subTasks) {
|
|
309
178
|
await stateManager.createTask({
|
|
@@ -313,8 +182,7 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
313
182
|
timeout: subTask.estimatedComplexity === 'high' ? 300000 :
|
|
314
183
|
subTask.estimatedComplexity === 'medium' ? 180000 : 120000,
|
|
315
184
|
dependencies: subTask.dependencies,
|
|
316
|
-
assignedAgent: subTask.assignedAgent
|
|
317
|
-
id: subTask.taskId
|
|
185
|
+
assignedAgent: subTask.assignedAgent
|
|
318
186
|
});
|
|
319
187
|
}
|
|
320
188
|
// 确定执行模式
|
package/dist/cli/index.js
CHANGED
|
@@ -15,8 +15,6 @@ const check_js_1 = require("./commands/check.js");
|
|
|
15
15
|
const check_gitignore_js_1 = require("./commands/check-gitignore.js");
|
|
16
16
|
const analyze_js_1 = require("./commands/analyze.js");
|
|
17
17
|
const brainstorm_js_1 = require("./commands/brainstorm.js");
|
|
18
|
-
const complete_js_1 = require("./commands/complete.js");
|
|
19
|
-
const step_js_1 = require("./commands/step.js");
|
|
20
18
|
const program = new commander_1.Command();
|
|
21
19
|
program
|
|
22
20
|
.name('openmatrix')
|
|
@@ -36,7 +34,5 @@ program.addCommand(check_js_1.checkCommand);
|
|
|
36
34
|
program.addCommand(check_gitignore_js_1.checkGitignoreCommand);
|
|
37
35
|
program.addCommand(analyze_js_1.analyzeCommand);
|
|
38
36
|
program.addCommand(brainstorm_js_1.brainstormCommand);
|
|
39
|
-
program.addCommand(complete_js_1.completeCommand);
|
|
40
|
-
program.addCommand(step_js_1.stepCommand);
|
|
41
37
|
// 默认帮助
|
|
42
38
|
program.parse();
|
|
@@ -20,24 +20,10 @@ export interface ProjectContext {
|
|
|
20
20
|
packageManager: 'npm' | 'yarn' | 'pnpm' | 'pip' | 'go-mod' | 'cargo' | 'unknown';
|
|
21
21
|
dependencies: Record<string, string>;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* 任务理解
|
|
25
|
-
*/
|
|
26
|
-
export interface TaskUnderstanding {
|
|
27
|
-
taskType: 'feature' | 'bugfix' | 'refactor' | 'docs' | 'test' | 'config' | 'unknown';
|
|
28
|
-
taskTypeLabel: string;
|
|
29
|
-
scope: string[];
|
|
30
|
-
scopeLabel: string;
|
|
31
|
-
complexity: 'simple' | 'medium' | 'complex';
|
|
32
|
-
complexityLabel: string;
|
|
33
|
-
estimatedCommits: string;
|
|
34
|
-
suggestions: string[];
|
|
35
|
-
}
|
|
36
23
|
/**
|
|
37
24
|
* 分析结果
|
|
38
25
|
*/
|
|
39
26
|
export interface AnalysisResult {
|
|
40
|
-
understanding: TaskUnderstanding;
|
|
41
27
|
inferences: QuestionInference[];
|
|
42
28
|
questionsToAsk: string[];
|
|
43
29
|
skippedQuestions: string[];
|
|
@@ -65,26 +51,6 @@ export declare class SmartQuestionAnalyzer {
|
|
|
65
51
|
* 获取项目上下文
|
|
66
52
|
*/
|
|
67
53
|
getProjectContext(): Promise<ProjectContext>;
|
|
68
|
-
/**
|
|
69
|
-
* 分析任务理解
|
|
70
|
-
*/
|
|
71
|
-
private analyzeTaskUnderstanding;
|
|
72
|
-
/**
|
|
73
|
-
* 检测任务类型
|
|
74
|
-
*/
|
|
75
|
-
private detectTaskType;
|
|
76
|
-
/**
|
|
77
|
-
* 检测影响范围
|
|
78
|
-
*/
|
|
79
|
-
private detectScope;
|
|
80
|
-
/**
|
|
81
|
-
* 检测复杂度
|
|
82
|
-
*/
|
|
83
|
-
private detectComplexity;
|
|
84
|
-
/**
|
|
85
|
-
* 生成建议
|
|
86
|
-
*/
|
|
87
|
-
private generateSuggestions;
|
|
88
54
|
/**
|
|
89
55
|
* 推断问题答案
|
|
90
56
|
*/
|
|
@@ -113,8 +79,4 @@ export declare class SmartQuestionAnalyzer {
|
|
|
113
79
|
* 生成推断摘要
|
|
114
80
|
*/
|
|
115
81
|
generateSummary(result: AnalysisResult): string;
|
|
116
|
-
/**
|
|
117
|
-
* 生成 Markdown 格式输出
|
|
118
|
-
*/
|
|
119
|
-
generateMarkdown(result: AnalysisResult): string;
|
|
120
82
|
}
|