openmatrix 0.1.37 → 0.1.38

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.
@@ -58,6 +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('--brainstorm-answers <json>', '从 brainstorm 传递的答案 JSON')
61
62
  .action(async (input, options) => {
62
63
  const basePath = process.cwd();
63
64
  const omPath = path.join(basePath, '.openmatrix');
@@ -163,6 +164,24 @@ exports.startCommand = new commander_1.Command('start')
163
164
  }
164
165
  const parser = new task_parser_js_1.TaskParser();
165
166
  const parsedTask = parser.parse(taskContent);
167
+ // 解析 brainstorm 答案 (如果有)
168
+ let brainstormContext = {};
169
+ if (options.brainstormAnswers) {
170
+ try {
171
+ brainstormContext = JSON.parse(options.brainstormAnswers);
172
+ if (!options.json) {
173
+ console.log('\n🧠 使用 brainstorm 收集的信息:');
174
+ if (brainstormContext.answers) {
175
+ Object.entries(brainstormContext.answers).forEach(([key, value]) => {
176
+ console.log(` - ${key}: ${Array.isArray(value) ? value.join(', ') : value}`);
177
+ });
178
+ }
179
+ }
180
+ }
181
+ catch {
182
+ // 忽略解析错误
183
+ }
184
+ }
166
185
  if (!options.json) {
167
186
  console.log(`\n📋 任务: ${parsedTask.title}`);
168
187
  console.log(` 目标: ${parsedTask.goals.join(', ')}`);
@@ -172,7 +191,27 @@ exports.startCommand = new commander_1.Command('start')
172
191
  console.log('\n🔧 拆解任务...');
173
192
  }
174
193
  const planner = new task_planner_js_1.TaskPlanner();
175
- const subTasks = planner.breakdown(parsedTask, {});
194
+ // 构建 planner 上下文,包含 brainstorm 信息
195
+ // 注意: TaskPlanner.breakdown 需要 Record<string, string> 类型
196
+ const plannerContext = {};
197
+ if (brainstormContext.answers) {
198
+ plannerContext.brainstormAnswers = JSON.stringify(brainstormContext.answers);
199
+ }
200
+ if (brainstormContext.insights && brainstormContext.insights.length > 0) {
201
+ plannerContext.insights = brainstormContext.insights.join('; ');
202
+ }
203
+ if (brainstormContext.designNotes && brainstormContext.designNotes.length > 0) {
204
+ plannerContext.designNotes = brainstormContext.designNotes.join('; ');
205
+ }
206
+ // 添加技术栈信息
207
+ if (options.techStack) {
208
+ plannerContext.techStack = options.techStack;
209
+ }
210
+ // 添加质量级别
211
+ if (options.quality) {
212
+ plannerContext.qualityLevel = options.quality;
213
+ }
214
+ const subTasks = planner.breakdown(parsedTask, plannerContext);
176
215
  // 创建任务到状态管理器
177
216
  for (const subTask of subTasks) {
178
217
  await stateManager.createTask({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmatrix",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "AI Agent task orchestration system with Claude Code Skills integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,25 +51,44 @@ OpenMatrix 独立运行,使用自己的头脑风暴流程。
51
51
  }
52
52
  ```
53
53
 
54
- 2. **交互式问答**
54
+ 2. **交互式问答 (必须收集答案)**
55
+
56
+ **重要**: 必须收集所有答案,用于后续传递给 CLI。
55
57
 
56
58
  对每个问题使用 `AskUserQuestion` 进行提问:
57
59
 
58
60
  ```typescript
59
- AskUserQuestion({
60
- questions: [{
61
- question: questions[0].question,
62
- header: questions[0].header,
63
- options: questions[0].options,
64
- multiSelect: questions[0].multiSelect
65
- }]
66
- })
61
+ // 收集答案的对象
62
+ const collectedAnswers: Record<string, string | string[]> = {};
63
+ const collectedInsights: string[] = [];
64
+
65
+ // 对每个问题提问
66
+ for (const q of questions) {
67
+ const response = await AskUserQuestion({
68
+ questions: [{
69
+ question: q.question,
70
+ header: q.header,
71
+ options: q.options,
72
+ multiSelect: q.multiSelect
73
+ }]
74
+ });
75
+
76
+ // 记录答案
77
+ collectedAnswers[q.id] = response.answers[q.question] || response.answers['0'];
78
+
79
+ // 记录洞察 (根据答案推导)
80
+ if (q.id === 'core_objective') {
81
+ collectedInsights.push(`核心目标: ${collectedAnswers[q.id]}`);
82
+ }
83
+ // ... 其他洞察
84
+ }
67
85
  ```
68
86
 
69
87
  **收集回答并记录洞察**:
70
88
  - 每个回答后,思考其含义
71
89
  - 记录可能的设计决策
72
90
  - 识别潜在风险
91
+ - **必须保存到 session.answers 对象中**
73
92
 
74
93
  3. **深入追问** (可选)
75
94
 
@@ -134,28 +153,76 @@ OpenMatrix 独立运行,使用自己的头脑风暴流程。
134
153
  })
135
154
  ```
136
155
 
137
- 6. **自动执行 start**
156
+ 6. **保存答案并执行 start**
157
+
158
+ **关键步骤**: 必须将收集的答案保存到 CLI,然后再启动执行。
138
159
 
139
160
  如果用户选择"开始执行":
140
- - 调用 CLI 标记头脑风暴完成:
141
- ```bash
142
- openmatrix brainstorm --complete --json
143
- ```
144
- - **必须使用 Skill 工具调用 om:start**:
145
- ```typescript
146
- Skill({
147
- skill: "om:start",
148
- args: JSON.stringify({
149
- taskInput: session.taskInput,
150
- taskTitle: session.taskTitle,
151
- answers: session.answers,
152
- insights: session.insights,
153
- designNotes: session.designNotes
154
- })
155
- })
156
- ```
157
- - 将头脑风暴收集的洞察传递给 start
158
- - **不要直接执行任务**,必须通过 `/om:start` 启动
161
+
162
+ **步骤 1**: 构建结果 JSON (必须包含所有收集的答案):
163
+ ```typescript
164
+ const resultsJson = JSON.stringify({
165
+ answers: collectedAnswers, // 用户对每个问题的回答
166
+ insights: collectedInsights, // 推导出的洞察
167
+ designNotes: collectedNotes // 设计笔记
168
+ });
169
+ ```
170
+
171
+ **步骤 2**: 调用 CLI 保存结果并标记完成:
172
+ ```bash
173
+ # 必须传递 --results 参数,否则答案不会被保存!
174
+ openmatrix brainstorm --complete --results '$RESULTS_JSON' --json
175
+ ```
176
+
177
+ 实际执行示例:
178
+ ```bash
179
+ # 使用单引号包裹 JSON,避免 shell 解析问题
180
+ openmatrix brainstorm --complete --results '{"answers":{"core_objective":"实现新功能","user_value":"终端用户"},"insights":["核心目标是实现新功能"],"designNotes":[]}' --json
181
+ ```
182
+
183
+ **步骤 3**: 调用 CLI 启动任务执行:
184
+ ```bash
185
+ # 使用 --brainstorm-answers 参数传递收集的信息
186
+ openmatrix start "$TASK_INPUT" \
187
+ --title "$TASK_TITLE" \
188
+ --quality "$QUALITY_LEVEL" \
189
+ --mode "$MODE" \
190
+ --brainstorm-answers '$RESULTS_JSON' \
191
+ --json
192
+ ```
193
+
194
+ 实际执行示例:
195
+ ```bash
196
+ openmatrix start "实现用户登录功能" \
197
+ --title "用户登录功能" \
198
+ --quality balanced \
199
+ --mode auto \
200
+ --brainstorm-answers '{"answers":{"core_objective":"实现新功能","user_value":"终端用户"},"insights":["核心目标是实现新功能"],"designNotes":[]}' \
201
+ --json
202
+ ```
203
+
204
+ **步骤 4**: 读取 CLI 返回的 SubagentTask 列表并执行:
205
+ ```typescript
206
+ // CLI 返回 JSON 格式的任务列表
207
+ const result = JSON.parse(cliOutput);
208
+ if (result.status === 'continue' && result.subagentTasks.length > 0) {
209
+ // 使用 Agent 工具执行每个 SubagentTask
210
+ for (const task of result.subagentTasks) {
211
+ await Agent({
212
+ subagent_type: task.subagent_type,
213
+ description: task.description,
214
+ prompt: task.prompt,
215
+ isolation: task.isolation
216
+ });
217
+ }
218
+ }
219
+ ```
220
+
221
+ **注意事项**:
222
+ - 必须先调用 `--complete --results` 保存答案
223
+ - 然后调用 `openmatrix start` 并传递 `--brainstorm-answers`
224
+ - 最后读取返回的 SubagentTask 列表并执行
225
+ - 不要直接执行任务,必须通过 `/om:start` 启动
159
226
 
160
227
  </process>
161
228
 
package/skills/start.md CHANGED
@@ -74,6 +74,22 @@ description: 启动新的任务执行周期
74
74
  - 如果 `$ARGUMENTS` 是任务描述 → 直接使用
75
75
  - 如果无参数 → 使用 AskUserQuestion 询问用户要执行的任务
76
76
 
77
+ 6. **检查 brainstorm 会话 (重要)**
78
+
79
+ 检查 `.openmatrix/brainstorm/session.json` 是否存在:
80
+ - 如果存在且 `status === 'ready_to_start'`,读取收集的信息:
81
+ ```json
82
+ {
83
+ "taskInput": "任务描述",
84
+ "taskTitle": "任务标题",
85
+ "answers": { "core_objective": "...", ... },
86
+ "insights": ["洞察1", "洞察2"],
87
+ "designNotes": ["设计要点1"]
88
+ }
89
+ ```
90
+ - 将这些信息用于后续的任务分析和质量级别推荐
91
+ - **从 brainstorm 继承的答案可以跳过重复提问**
92
+
77
93
  ---
78
94
 
79
95
  ## Step 1: 展示理解 + 选择质量级别
@@ -139,11 +155,34 @@ AskUserQuestion({
139
155
 
140
156
  ## Step 2: 展示执行计划 + 执行模式
141
157
 
142
- **调用 CLI 拆解任务(传入任务描述):**
158
+ **调用 CLI 拆解任务(传入任务描述和质量配置):**
159
+
143
160
  ```bash
144
- openmatrix plan "$ARGUMENTS" --json
161
+ # 基本调用
162
+ openmatrix start "$TASK_INPUT" --quality "$QUALITY_LEVEL" --mode "$MODE" --json
163
+
164
+ # 如果有 brainstorm 信息,传递额外参数
165
+ openmatrix start "$TASK_INPUT" \
166
+ --quality "$QUALITY_LEVEL" \
167
+ --mode "$MODE" \
168
+ --title "$TASK_TITLE" \
169
+ --tech-stack "$TECH_STACK" \
170
+ --json
145
171
  ```
146
172
 
173
+ **参数说明:**
174
+ - `$TASK_INPUT`: 任务描述或文件路径
175
+ - `$QUALITY_LEVEL`: fast | balanced | strict
176
+ - `$MODE`: auto | confirm-key | confirm-all
177
+ - `$TASK_TITLE`: 从 brainstorm 继承的任务标题
178
+ - `$TECH_STACK`: 技术栈 (逗号分隔)
179
+
180
+ **重要**: CLI 会自动:
181
+ 1. 解析任务
182
+ 2. 拆解为子任务
183
+ 3. 创建任务文件到 `.openmatrix/tasks/`
184
+ 4. 返回待执行的 SubagentTask 列表
185
+
147
186
  **展示执行计划:**
148
187
  ```
149
188
  📋 执行计划