openmatrix 0.1.39 → 0.1.40
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/package.json +1 -1
- package/skills/start.md +60 -0
package/package.json
CHANGED
package/skills/start.md
CHANGED
|
@@ -202,6 +202,66 @@ openmatrix start "$TASK_INPUT" \
|
|
|
202
202
|
3. 创建任务文件到 `.openmatrix/tasks/`
|
|
203
203
|
4. 返回待执行的 SubagentTask 列表
|
|
204
204
|
|
|
205
|
+
### 🚨 关键:必须读取并执行 CLI 返回的任务
|
|
206
|
+
|
|
207
|
+
**CLI 调用后会返回 JSON,必须解析并执行!**
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// 1. 调用 CLI (使用 Bash 工具)
|
|
211
|
+
const cliOutput = await Bash({
|
|
212
|
+
command: `openmatrix start "${taskInput}" --title "${taskTitle}" --quality ${quality} --mode ${mode} --json`,
|
|
213
|
+
description: "Start task and get subagent tasks"
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// 2. 解析 CLI 输出 (关键步骤!)
|
|
217
|
+
let result;
|
|
218
|
+
try {
|
|
219
|
+
result = JSON.parse(cliOutput);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
console.error("Failed to parse CLI output:", cliOutput);
|
|
222
|
+
throw new Error("CLI 返回了无效的 JSON");
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 3. 检查状态
|
|
226
|
+
if (result.status !== 'continue') {
|
|
227
|
+
console.log(`状态: ${result.status}`);
|
|
228
|
+
console.log(`消息: ${result.message}`);
|
|
229
|
+
// 如果是 waiting_approval,需要处理审批
|
|
230
|
+
// 如果是 completed,任务已完成
|
|
231
|
+
// 如果是 failed,需要重试
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 4. 获取 SubagentTask 列表 (关键!)
|
|
236
|
+
const subagentTasks = result.subagentTasks || [];
|
|
237
|
+
console.log(`获取到 ${subagentTasks.length} 个待执行任务`);
|
|
238
|
+
|
|
239
|
+
// 5. 执行每个 SubagentTask (关键!)
|
|
240
|
+
for (const task of subagentTasks) {
|
|
241
|
+
console.log(`\n📍 执行任务: ${task.description}`);
|
|
242
|
+
|
|
243
|
+
// 使用 Agent 工具执行
|
|
244
|
+
const agentResult = await Agent({
|
|
245
|
+
subagent_type: task.subagent_type, // 如 'general-purpose'
|
|
246
|
+
description: task.description, // 如 'develop: 实现登录功能'
|
|
247
|
+
prompt: task.prompt, // 完整的任务提示
|
|
248
|
+
isolation: task.isolation // 如 'worktree' 或 undefined
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// 标记任务完成
|
|
252
|
+
await Bash({
|
|
253
|
+
command: `openmatrix complete ${task.taskId} --${agentResult.success ? 'success' : 'failed'}`,
|
|
254
|
+
description: `Mark task ${task.taskId} as ${agentResult.success ? 'success' : 'failed'}`
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**常见错误:**
|
|
260
|
+
- ❌ 调用 CLI 后没有解析输出
|
|
261
|
+
- ❌ 解析后没有读取 `subagentTasks` 字段
|
|
262
|
+
- ❌ 读取后没有用 Agent 工具执行
|
|
263
|
+
- ❌ 执行后没有调用 `openmatrix complete`
|
|
264
|
+
|
|
205
265
|
---
|
|
206
266
|
|
|
207
267
|
**📍 Step 2 完成 → 下一步: Step 3 执行**
|