openmatrix 0.1.49 → 0.1.51
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/agents/agent-runner.d.ts +1 -26
- package/dist/cli/commands/analyze.js +3 -4
- package/dist/cli/commands/brainstorm.js +52 -74
- package/dist/cli/commands/meeting.js +55 -13
- package/dist/cli/commands/start.js +243 -224
- package/dist/cli/index.js +0 -4
- package/dist/orchestrator/executor.d.ts +2 -1
- package/dist/orchestrator/phase-executor.d.ts +2 -1
- 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 +22 -8
- package/dist/orchestrator/task-parser.js +118 -31
- package/dist/orchestrator/task-planner.d.ts +39 -12
- package/dist/orchestrator/task-planner.js +290 -171
- package/dist/storage/state-manager.d.ts +0 -1
- package/dist/storage/state-manager.js +10 -10
- package/package.json +55 -56
- package/skills/approve.md +10 -10
- package/skills/auto.md +117 -21
- package/skills/brainstorm.md +238 -105
- package/skills/check.md +199 -199
- package/skills/meeting.md +3 -1
- package/skills/openmatrix.md +190 -175
- package/skills/start.md +666 -171
|
@@ -58,7 +58,7 @@ 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('--
|
|
61
|
+
.option('--tasks-json <json>', 'AI 已拆分的任务 JSON (跳过自动解析)')
|
|
62
62
|
.action(async (input, options) => {
|
|
63
63
|
const basePath = process.cwd();
|
|
64
64
|
const omPath = path.join(basePath, '.openmatrix');
|
|
@@ -102,247 +102,284 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
102
102
|
}
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
//
|
|
106
|
-
|
|
105
|
+
// ============================
|
|
106
|
+
// 路径 A: AI 已拆分 (--tasks-json)
|
|
107
|
+
// ============================
|
|
108
|
+
if (options.tasksJson) {
|
|
109
|
+
await handleTasksJson(options, stateManager, state, omPath);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// ============================
|
|
113
|
+
// 路径 B: 自动解析 (fallback)
|
|
114
|
+
// ============================
|
|
115
|
+
await handleAutoParse(input, options, stateManager, state);
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* 处理 AI 解析的任务 (--tasks-json)
|
|
119
|
+
* AI 提供 ParsedTask 格式的结构化数据,仍由 TaskPlanner 做拆分
|
|
120
|
+
*/
|
|
121
|
+
async function handleTasksJson(options, stateManager, state, omPath) {
|
|
122
|
+
let tasksInput;
|
|
107
123
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
124
|
+
// 支持 @file 语法读取文件
|
|
125
|
+
let jsonStr = options.tasksJson;
|
|
126
|
+
if (jsonStr.startsWith('@')) {
|
|
127
|
+
jsonStr = await fs.readFile(jsonStr.slice(1), 'utf-8');
|
|
128
|
+
}
|
|
129
|
+
tasksInput = JSON.parse(jsonStr);
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
if (options.json) {
|
|
133
|
+
console.log(JSON.stringify({
|
|
134
|
+
status: 'error',
|
|
135
|
+
message: `--tasks-json 解析失败: ${e instanceof Error ? e.message : e}`
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.log(`❌ --tasks-json 解析失败: ${e instanceof Error ? e.message : e}`);
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!tasksInput.goals || tasksInput.goals.length === 0) {
|
|
144
|
+
if (options.json) {
|
|
145
|
+
console.log(JSON.stringify({ status: 'error', message: '--tasks-json 中 goals 为空' }));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
console.log('❌ --tasks-json 中 goals 为空');
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// 保存 AI 生成的执行计划
|
|
153
|
+
if (tasksInput.plan) {
|
|
154
|
+
await fs.writeFile(path.join(omPath, 'plan.md'), tasksInput.plan, 'utf-8');
|
|
155
|
+
}
|
|
156
|
+
// 构建 ParsedTask
|
|
157
|
+
const parsedTask = {
|
|
158
|
+
title: tasksInput.title,
|
|
159
|
+
description: tasksInput.description || '',
|
|
160
|
+
goals: tasksInput.goals,
|
|
161
|
+
constraints: tasksInput.constraints || [],
|
|
162
|
+
deliverables: tasksInput.deliverables || [],
|
|
163
|
+
rawContent: ''
|
|
164
|
+
};
|
|
165
|
+
// 解析质量配置
|
|
166
|
+
const qualityLevel = tasksInput.quality || options.quality || 'balanced';
|
|
167
|
+
const qualityConfig = index_js_1.QUALITY_PRESETS[qualityLevel.toLowerCase()] || index_js_1.QUALITY_PRESETS.balanced;
|
|
168
|
+
if (!options.json) {
|
|
169
|
+
console.log(`\n📋 任务: ${parsedTask.title}`);
|
|
170
|
+
console.log(` 目标: ${parsedTask.goals.join(', ')}`);
|
|
171
|
+
console.log('\n🔧 拆解任务...');
|
|
172
|
+
}
|
|
173
|
+
// 使用 TaskPlanner 拆分(保持原有拆分逻辑)
|
|
174
|
+
const answers = tasksInput.answers || {};
|
|
175
|
+
const planner = new task_planner_js_1.TaskPlanner();
|
|
176
|
+
const subTasks = planner.breakdown(parsedTask, answers, qualityConfig, tasksInput.plan);
|
|
177
|
+
// 创建任务到状态管理器,并建立 ID 映射
|
|
178
|
+
// TaskPlanner 生成的 taskId 和 StateManager 创建的 id 不同,
|
|
179
|
+
// 需要映射后才能正确设置 dependencies
|
|
180
|
+
const taskIdMap = new Map();
|
|
181
|
+
for (const task of subTasks) {
|
|
182
|
+
const created = await stateManager.createTask({
|
|
183
|
+
title: task.title,
|
|
184
|
+
description: task.description,
|
|
185
|
+
priority: task.priority,
|
|
186
|
+
timeout: task.estimatedComplexity === 'high' ? 300000 :
|
|
187
|
+
task.estimatedComplexity === 'medium' ? 180000 : 120000,
|
|
188
|
+
dependencies: [], // 先创建,稍后更新依赖
|
|
189
|
+
assignedAgent: task.assignedAgent
|
|
190
|
+
});
|
|
191
|
+
taskIdMap.set(task.taskId, created.id);
|
|
192
|
+
}
|
|
193
|
+
// 映射并更新依赖关系
|
|
194
|
+
for (const task of subTasks) {
|
|
195
|
+
const actualId = taskIdMap.get(task.taskId);
|
|
196
|
+
const resolvedDeps = task.dependencies
|
|
197
|
+
.map(dep => taskIdMap.get(dep))
|
|
198
|
+
.filter((id) => id !== undefined);
|
|
199
|
+
if (resolvedDeps.length > 0) {
|
|
200
|
+
await stateManager.updateTask(actualId, { dependencies: resolvedDeps });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// 解析执行模式
|
|
204
|
+
const executionMode = tasksInput.mode || options.mode || 'confirm-key';
|
|
205
|
+
const approvalPoints = resolveApprovalPoints(executionMode);
|
|
206
|
+
await stateManager.updateState({
|
|
207
|
+
status: 'running',
|
|
208
|
+
currentPhase: 'execution',
|
|
209
|
+
config: {
|
|
210
|
+
...state.config,
|
|
211
|
+
approvalPoints: approvalPoints,
|
|
212
|
+
quality: qualityConfig
|
|
147
213
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
214
|
+
});
|
|
215
|
+
// 创建审批请求(如果有审批点)
|
|
216
|
+
const approvalManager = new approval_manager_js_1.ApprovalManager(stateManager);
|
|
217
|
+
if (approvalPoints.includes('plan')) {
|
|
218
|
+
const approval = await approvalManager.createPlanApproval('plan-approval', `# 执行计划\n\n${subTasks.map((t, i) => `${i + 1}. ${t.title} (${t.assignedAgent})`).join('\n')}`);
|
|
219
|
+
await stateManager.updateState({ status: 'paused' });
|
|
220
|
+
if (options.json) {
|
|
221
|
+
console.log(JSON.stringify({
|
|
222
|
+
status: 'waiting_approval',
|
|
223
|
+
approvalId: approval.id,
|
|
224
|
+
approvalType: 'plan',
|
|
225
|
+
message: '等待计划审批',
|
|
226
|
+
tasks: subTasks.map((t, i) => ({
|
|
227
|
+
index: i + 1,
|
|
228
|
+
title: t.title,
|
|
229
|
+
priority: t.priority,
|
|
230
|
+
assignedAgent: t.assignedAgent
|
|
231
|
+
})),
|
|
232
|
+
taskInfo: {
|
|
233
|
+
title: tasksInput.title,
|
|
234
|
+
description: tasksInput.description,
|
|
235
|
+
quality: qualityLevel
|
|
159
236
|
}
|
|
160
|
-
}
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
console.log(`\n📋 ${tasksInput.title} - ${subTasks.length} 个子任务:\n`);
|
|
241
|
+
subTasks.forEach((task, i) => {
|
|
242
|
+
console.log(` ${i + 1}. ${task.title} (${task.priority}, ${task.assignedAgent})`);
|
|
243
|
+
});
|
|
244
|
+
console.log(`\n🎯 执行模式: ${executionMode}`);
|
|
245
|
+
console.log(`⏸️ 等待计划审批 (ID: ${approval.id})`);
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// 无审批点,直接开始执行
|
|
250
|
+
const executor = new executor_js_1.OrchestratorExecutor(stateManager, approvalManager, {
|
|
251
|
+
maxConcurrent: state.config.maxConcurrentAgents,
|
|
252
|
+
taskTimeout: state.config.timeout * 1000
|
|
253
|
+
});
|
|
254
|
+
const phaseExecutor = executor.getPhaseExecutor();
|
|
255
|
+
if (phaseExecutor) {
|
|
256
|
+
phaseExecutor.setRunId(state.runId);
|
|
257
|
+
if (executionMode === 'auto') {
|
|
258
|
+
phaseExecutor.setAutoMode(true);
|
|
161
259
|
}
|
|
162
260
|
}
|
|
163
|
-
|
|
164
|
-
|
|
261
|
+
const result = await executor.step();
|
|
262
|
+
if (options.json) {
|
|
263
|
+
console.log(JSON.stringify({
|
|
264
|
+
status: result.status,
|
|
265
|
+
message: result.message,
|
|
266
|
+
statistics: result.statistics,
|
|
267
|
+
subagentTasks: result.subagentTasks.map(t => ({
|
|
268
|
+
subagent_type: t.subagent_type,
|
|
269
|
+
description: t.description,
|
|
270
|
+
prompt: t.prompt,
|
|
271
|
+
isolation: t.isolation,
|
|
272
|
+
taskId: t.taskId,
|
|
273
|
+
agentType: t.agentType,
|
|
274
|
+
timeout: t.timeout
|
|
275
|
+
})),
|
|
276
|
+
taskInfo: {
|
|
277
|
+
title: tasksInput.title,
|
|
278
|
+
description: tasksInput.description,
|
|
279
|
+
quality: qualityLevel
|
|
280
|
+
}
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
console.log(`\n📋 ${tasksInput.title} - ${subTasks.length} 个子任务已创建`);
|
|
285
|
+
console.log(`🎯 执行模式: ${executionMode}`);
|
|
286
|
+
console.log(` 质量级别: ${qualityLevel}`);
|
|
287
|
+
console.log('\n🚀 开始执行...');
|
|
288
|
+
console.log(' 使用 /om:status 查看进度');
|
|
165
289
|
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* 处理自动解析 (fallback,无 AI 时使用)
|
|
293
|
+
*/
|
|
294
|
+
async function handleAutoParse(input, options, stateManager, state) {
|
|
166
295
|
// 构建任务内容
|
|
167
296
|
let taskContent = input;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
297
|
+
if (options.title || options.description) {
|
|
298
|
+
const title = options.title || '未命名任务';
|
|
299
|
+
const description = options.description || '';
|
|
300
|
+
const techStack = options.techStack ? `\n\n技术栈: ${options.techStack}` : '';
|
|
301
|
+
const docs = options.docs ? `\n文档要求: ${options.docs}` : '';
|
|
302
|
+
taskContent = `# ${title}\n\n${description}${techStack}${docs}`;
|
|
303
|
+
}
|
|
304
|
+
if (!taskContent) {
|
|
305
|
+
const defaultPath = path.join(process.cwd(), 'TASK.md');
|
|
171
306
|
try {
|
|
172
|
-
taskContent = await fs.readFile(
|
|
307
|
+
taskContent = await fs.readFile(defaultPath, 'utf-8');
|
|
173
308
|
if (!options.json) {
|
|
174
|
-
console.log(`📄 读取任务文件: ${
|
|
309
|
+
console.log(`📄 读取任务文件: ${defaultPath}`);
|
|
175
310
|
}
|
|
176
311
|
}
|
|
177
312
|
catch {
|
|
178
313
|
if (options.json) {
|
|
179
|
-
console.log(JSON.stringify({
|
|
180
|
-
status: 'error',
|
|
181
|
-
message: `无法读取文件: ${input}`
|
|
182
|
-
}));
|
|
314
|
+
console.log(JSON.stringify({ status: 'error', message: '请提供任务文件路径或描述' }));
|
|
183
315
|
}
|
|
184
316
|
else {
|
|
185
|
-
console.log(
|
|
317
|
+
console.log('❌ 请提供任务文件路径或描述');
|
|
186
318
|
}
|
|
187
319
|
return;
|
|
188
320
|
}
|
|
189
321
|
}
|
|
190
|
-
else if (
|
|
191
|
-
// 如果没有任务内容,尝试读取默认文件
|
|
192
|
-
const defaultPath = path.join(basePath, 'TASK.md');
|
|
322
|
+
else if (taskContent.endsWith('.md')) {
|
|
193
323
|
try {
|
|
194
|
-
taskContent = await fs.readFile(
|
|
195
|
-
if (!options.json) {
|
|
196
|
-
console.log(`📄 读取任务文件: ${defaultPath}`);
|
|
197
|
-
}
|
|
324
|
+
taskContent = await fs.readFile(taskContent, 'utf-8');
|
|
198
325
|
}
|
|
199
326
|
catch {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const title = options.title || '未命名任务';
|
|
203
|
-
const description = options.description || '';
|
|
204
|
-
const techStack = options.techStack ? `\n\n技术栈: ${options.techStack}` : '';
|
|
205
|
-
const docs = options.docs ? `\n文档要求: ${options.docs}` : '';
|
|
206
|
-
taskContent = `# ${title}\n\n${description}${techStack}${docs}`;
|
|
207
|
-
titleOverride = undefined; // 内容已包含标题,不需要覆盖
|
|
327
|
+
if (options.json) {
|
|
328
|
+
console.log(JSON.stringify({ status: 'error', message: `无法读取文件: ${input}` }));
|
|
208
329
|
}
|
|
209
330
|
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;
|
|
331
|
+
console.log(`❌ 无法读取文件: ${input}`);
|
|
245
332
|
}
|
|
333
|
+
return;
|
|
246
334
|
}
|
|
247
335
|
}
|
|
248
|
-
// 如果有标题覆盖,更新任务内容中的标题
|
|
249
|
-
if (titleOverride && taskContent) {
|
|
250
|
-
// 替换第一个 # 标题
|
|
251
|
-
taskContent = taskContent.replace(/^#\s+.+$/m, `# ${titleOverride}`);
|
|
252
|
-
}
|
|
253
|
-
// 解析任务
|
|
254
336
|
if (!options.json) {
|
|
255
337
|
console.log('\n🔍 解析任务...');
|
|
256
338
|
}
|
|
257
339
|
const parser = new task_parser_js_1.TaskParser();
|
|
258
340
|
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
341
|
if (!options.json) {
|
|
278
342
|
console.log(`\n📋 任务: ${parsedTask.title}`);
|
|
279
343
|
console.log(` 目标: ${parsedTask.goals.join(', ')}`);
|
|
280
344
|
}
|
|
281
|
-
// 拆解任务
|
|
282
345
|
if (!options.json) {
|
|
283
346
|
console.log('\n🔧 拆解任务...');
|
|
284
347
|
}
|
|
285
|
-
|
|
286
|
-
// 构建 planner 上下文,包含 brainstorm 信息
|
|
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
|
-
// 添加质量级别
|
|
348
|
+
let qualityConfig;
|
|
303
349
|
if (options.quality) {
|
|
304
|
-
|
|
350
|
+
const qualityLevel = options.quality.toLowerCase();
|
|
351
|
+
if (['strict', 'balanced', 'fast'].includes(qualityLevel)) {
|
|
352
|
+
qualityConfig = index_js_1.QUALITY_PRESETS[qualityLevel];
|
|
353
|
+
}
|
|
305
354
|
}
|
|
306
|
-
const
|
|
307
|
-
|
|
355
|
+
const planner = new task_planner_js_1.TaskPlanner();
|
|
356
|
+
const subTasks = planner.breakdown(parsedTask, {}, qualityConfig);
|
|
357
|
+
// 创建任务,并建立 TaskPlanner ID → StateManager ID 的映射
|
|
358
|
+
const taskIdMap = new Map();
|
|
308
359
|
for (const subTask of subTasks) {
|
|
309
|
-
await stateManager.createTask({
|
|
360
|
+
const created = await stateManager.createTask({
|
|
310
361
|
title: subTask.title,
|
|
311
362
|
description: subTask.description,
|
|
312
363
|
priority: subTask.priority,
|
|
313
364
|
timeout: subTask.estimatedComplexity === 'high' ? 300000 :
|
|
314
365
|
subTask.estimatedComplexity === 'medium' ? 180000 : 120000,
|
|
315
|
-
dependencies:
|
|
316
|
-
assignedAgent: subTask.assignedAgent
|
|
317
|
-
id: subTask.taskId
|
|
366
|
+
dependencies: [],
|
|
367
|
+
assignedAgent: subTask.assignedAgent
|
|
318
368
|
});
|
|
369
|
+
taskIdMap.set(subTask.taskId, created.id);
|
|
319
370
|
}
|
|
320
|
-
//
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
case 'confirm-key':
|
|
329
|
-
approvalPoints = ['plan', 'merge', 'deploy'];
|
|
330
|
-
break;
|
|
331
|
-
case 'auto':
|
|
332
|
-
approvalPoints = [];
|
|
333
|
-
break;
|
|
334
|
-
default:
|
|
335
|
-
approvalPoints = ['plan', 'merge'];
|
|
336
|
-
}
|
|
337
|
-
// 处理质量配置
|
|
338
|
-
let qualityConfig;
|
|
339
|
-
if (options.quality) {
|
|
340
|
-
const qualityLevel = options.quality.toLowerCase();
|
|
341
|
-
if (['strict', 'balanced', 'fast'].includes(qualityLevel)) {
|
|
342
|
-
qualityConfig = index_js_1.QUALITY_PRESETS[qualityLevel];
|
|
371
|
+
// 映射并更新依赖关系
|
|
372
|
+
for (const subTask of subTasks) {
|
|
373
|
+
const actualId = taskIdMap.get(subTask.taskId);
|
|
374
|
+
const resolvedDeps = subTask.dependencies
|
|
375
|
+
.map(dep => taskIdMap.get(dep))
|
|
376
|
+
.filter((id) => id !== undefined);
|
|
377
|
+
if (resolvedDeps.length > 0) {
|
|
378
|
+
await stateManager.updateTask(actualId, { dependencies: resolvedDeps });
|
|
343
379
|
}
|
|
344
380
|
}
|
|
345
|
-
|
|
381
|
+
const executionMode = options.mode || 'confirm-key';
|
|
382
|
+
const approvalPoints = resolveApprovalPoints(executionMode);
|
|
346
383
|
await stateManager.updateState({
|
|
347
384
|
status: 'running',
|
|
348
385
|
currentPhase: 'execution',
|
|
@@ -352,7 +389,6 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
352
389
|
quality: qualityConfig || state.config.quality
|
|
353
390
|
}
|
|
354
391
|
});
|
|
355
|
-
// 创建审批请求(如果有审批点)
|
|
356
392
|
const approvalManager = new approval_manager_js_1.ApprovalManager(stateManager);
|
|
357
393
|
if (approvalPoints.includes('plan')) {
|
|
358
394
|
const approval = await approvalManager.createPlanApproval('plan-approval', `# 执行计划\n\n${subTasks.map((t, i) => `${i + 1}. ${t.title}`).join('\n')}`);
|
|
@@ -363,12 +399,7 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
363
399
|
approvalId: approval.id,
|
|
364
400
|
approvalType: 'plan',
|
|
365
401
|
message: '等待计划审批',
|
|
366
|
-
tasks: subTasks.map((t, i) => ({
|
|
367
|
-
index: i + 1,
|
|
368
|
-
title: t.title,
|
|
369
|
-
priority: t.priority
|
|
370
|
-
})),
|
|
371
|
-
// 额外信息供 Skill 使用
|
|
402
|
+
tasks: subTasks.map((t, i) => ({ index: i + 1, title: t.title, priority: t.priority })),
|
|
372
403
|
taskInfo: {
|
|
373
404
|
title: options.title || parsedTask.title,
|
|
374
405
|
description: options.description,
|
|
@@ -384,25 +415,14 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
384
415
|
console.log(` ${i + 1}. ${task.title} (${task.priority})`);
|
|
385
416
|
});
|
|
386
417
|
console.log(`\n🎯 执行模式: ${executionMode}`);
|
|
387
|
-
console.log(
|
|
388
|
-
if (options.quality) {
|
|
389
|
-
console.log(` 质量级别: ${options.quality}`);
|
|
390
|
-
}
|
|
391
|
-
if (options.techStack) {
|
|
392
|
-
console.log(` 技术栈: ${options.techStack}`);
|
|
393
|
-
}
|
|
394
|
-
console.log(`\n⏸️ 等待计划审批`);
|
|
395
|
-
console.log(` 审批ID: ${approval.id}`);
|
|
396
|
-
console.log(` 使用 /om:approve ${approval.id} 审批`);
|
|
418
|
+
console.log(`⏸️ 等待计划审批 (ID: ${approval.id})`);
|
|
397
419
|
}
|
|
398
420
|
return;
|
|
399
421
|
}
|
|
400
|
-
// 创建执行器并获取第一批任务
|
|
401
422
|
const executor = new executor_js_1.OrchestratorExecutor(stateManager, approvalManager, {
|
|
402
423
|
maxConcurrent: state.config.maxConcurrentAgents,
|
|
403
424
|
taskTimeout: state.config.timeout * 1000
|
|
404
425
|
});
|
|
405
|
-
// 设置 PhaseExecutor 的自动模式和 RunId
|
|
406
426
|
const phaseExecutor = executor.getPhaseExecutor();
|
|
407
427
|
if (phaseExecutor) {
|
|
408
428
|
phaseExecutor.setRunId(state.runId);
|
|
@@ -412,7 +432,6 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
412
432
|
}
|
|
413
433
|
const result = await executor.step();
|
|
414
434
|
if (options.json) {
|
|
415
|
-
// JSON 输出供 Skill 解析
|
|
416
435
|
console.log(JSON.stringify({
|
|
417
436
|
status: result.status,
|
|
418
437
|
message: result.message,
|
|
@@ -426,7 +445,6 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
426
445
|
agentType: t.agentType,
|
|
427
446
|
timeout: t.timeout
|
|
428
447
|
})),
|
|
429
|
-
// 额外信息供 Skill 使用
|
|
430
448
|
taskInfo: {
|
|
431
449
|
title: options.title || parsedTask.title,
|
|
432
450
|
description: options.description,
|
|
@@ -437,19 +455,20 @@ exports.startCommand = new commander_1.Command('start')
|
|
|
437
455
|
}));
|
|
438
456
|
}
|
|
439
457
|
else {
|
|
440
|
-
console.log(`\n📋 生成 ${subTasks.length}
|
|
441
|
-
|
|
442
|
-
console.log(` ${i + 1}. ${task.title} (${task.priority})`);
|
|
443
|
-
});
|
|
444
|
-
console.log(`\n🎯 执行模式: ${executionMode}`);
|
|
445
|
-
console.log(` 审批点: ${approvalPoints.length > 0 ? approvalPoints.join(', ') : '无 (全自动)'}`);
|
|
446
|
-
if (options.quality) {
|
|
447
|
-
console.log(` 质量级别: ${options.quality}`);
|
|
448
|
-
}
|
|
449
|
-
if (options.techStack) {
|
|
450
|
-
console.log(` 技术栈: ${options.techStack}`);
|
|
451
|
-
}
|
|
458
|
+
console.log(`\n📋 生成 ${subTasks.length} 个子任务`);
|
|
459
|
+
console.log(`🎯 执行模式: ${executionMode}`);
|
|
452
460
|
console.log('\n🚀 开始执行...');
|
|
453
461
|
console.log(' 使用 /om:status 查看进度');
|
|
454
462
|
}
|
|
455
|
-
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* 根据执行模式解析审批点
|
|
466
|
+
*/
|
|
467
|
+
function resolveApprovalPoints(mode) {
|
|
468
|
+
switch (mode) {
|
|
469
|
+
case 'confirm-all': return ['plan', 'phase', 'merge', 'deploy'];
|
|
470
|
+
case 'confirm-key': return ['plan', 'merge', 'deploy'];
|
|
471
|
+
case 'auto': return [];
|
|
472
|
+
default: return ['plan', 'merge'];
|
|
473
|
+
}
|
|
474
|
+
}
|
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();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Scheduler } from './scheduler.js';
|
|
2
|
-
import { AgentRunner
|
|
2
|
+
import { AgentRunner } from '../agents/agent-runner.js';
|
|
3
|
+
import type { SubagentTask } from '../types/index.js';
|
|
3
4
|
import { StateManager } from '../storage/state-manager.js';
|
|
4
5
|
import { ApprovalManager } from './approval-manager.js';
|
|
5
6
|
import { PhaseExecutor } from './phase-executor.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StateManager } from '../storage/state-manager.js';
|
|
2
2
|
import { ApprovalManager } from './approval-manager.js';
|
|
3
|
-
import { AgentRunner, type
|
|
3
|
+
import { AgentRunner, type UserContext } from '../agents/agent-runner.js';
|
|
4
|
+
import type { SubagentTask } from '../types/index.js';
|
|
4
5
|
import { GitCommitManager } from './git-commit-manager.js';
|
|
5
6
|
import type { Task, QualityConfig, QualityReport } from '../types/index.js';
|
|
6
7
|
export type Phase = 'develop' | 'verify' | 'accept' | 'tdd';
|