openmatrix 0.1.47 → 0.1.49

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.
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const completeCommand: Command;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.completeCommand = void 0;
37
+ // src/cli/commands/complete.ts
38
+ const commander_1 = require("commander");
39
+ const state_manager_js_1 = require("../../storage/state-manager.js");
40
+ const approval_manager_js_1 = require("../../orchestrator/approval-manager.js");
41
+ const executor_js_1 = require("../../orchestrator/executor.js");
42
+ const path = __importStar(require("path"));
43
+ exports.completeCommand = new commander_1.Command('complete')
44
+ .description('标记任务完成或失败')
45
+ .argument('<taskId>', '任务 ID')
46
+ .option('--success', '标记为成功')
47
+ .option('--failed', '标记为失败')
48
+ .option('--error <message>', '错误信息')
49
+ .option('--output <text>', '执行输出')
50
+ .option('--json', 'JSON 输出')
51
+ .action(async (taskId, options) => {
52
+ const basePath = process.cwd();
53
+ const omPath = path.join(basePath, '.openmatrix');
54
+ const stateManager = new state_manager_js_1.StateManager(omPath);
55
+ await stateManager.initialize();
56
+ const state = await stateManager.getState();
57
+ // 构建执行器
58
+ const approvalManager = new approval_manager_js_1.ApprovalManager(stateManager);
59
+ const executor = new executor_js_1.OrchestratorExecutor(stateManager, approvalManager, {
60
+ maxConcurrent: state.config.maxConcurrentAgents,
61
+ taskTimeout: state.config.timeout * 1000
62
+ });
63
+ const success = options.success || !options.failed;
64
+ // 标记任务完成
65
+ await executor.completeTask(taskId, {
66
+ success,
67
+ output: options.output,
68
+ error: options.error
69
+ });
70
+ if (options.json) {
71
+ // 获取下一批可执行任务
72
+ const nextResult = await executor.step();
73
+ const updatedTask = await stateManager.getTask(taskId);
74
+ console.log(JSON.stringify({
75
+ status: success ? 'completed' : 'failed',
76
+ taskId,
77
+ taskStatus: updatedTask?.status,
78
+ nextBatch: {
79
+ status: nextResult.status,
80
+ subagentTasks: nextResult.subagentTasks.map(t => ({
81
+ subagent_type: t.subagent_type,
82
+ description: t.description,
83
+ prompt: t.prompt,
84
+ isolation: t.isolation,
85
+ taskId: t.taskId,
86
+ agentType: t.agentType,
87
+ timeout: t.timeout
88
+ })),
89
+ statistics: nextResult.statistics
90
+ }
91
+ }));
92
+ }
93
+ else {
94
+ const emoji = success ? '✅' : '❌';
95
+ console.log(`${emoji} 任务 ${taskId} ${success ? '完成' : '失败'}`);
96
+ if (!success && options.error) {
97
+ console.log(` 错误: ${options.error}`);
98
+ }
99
+ }
100
+ });
@@ -313,7 +313,8 @@ exports.startCommand = new commander_1.Command('start')
313
313
  timeout: subTask.estimatedComplexity === 'high' ? 300000 :
314
314
  subTask.estimatedComplexity === 'medium' ? 180000 : 120000,
315
315
  dependencies: subTask.dependencies,
316
- assignedAgent: subTask.assignedAgent
316
+ assignedAgent: subTask.assignedAgent,
317
+ id: subTask.taskId
317
318
  });
318
319
  }
319
320
  // 确定执行模式
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare const stepCommand: Command;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.stepCommand = void 0;
37
+ // src/cli/commands/step.ts
38
+ const commander_1 = require("commander");
39
+ const state_manager_js_1 = require("../../storage/state-manager.js");
40
+ const approval_manager_js_1 = require("../../orchestrator/approval-manager.js");
41
+ const executor_js_1 = require("../../orchestrator/executor.js");
42
+ const path = __importStar(require("path"));
43
+ exports.stepCommand = new commander_1.Command('step')
44
+ .description('获取下一批可执行任务')
45
+ .option('--json', 'JSON 输出')
46
+ .action(async (options) => {
47
+ const basePath = process.cwd();
48
+ const omPath = path.join(basePath, '.openmatrix');
49
+ const stateManager = new state_manager_js_1.StateManager(omPath);
50
+ await stateManager.initialize();
51
+ const state = await stateManager.getState();
52
+ if (state.status !== 'running') {
53
+ if (options.json) {
54
+ console.log(JSON.stringify({
55
+ status: 'error',
56
+ message: '没有正在执行的任务',
57
+ currentState: state.status
58
+ }));
59
+ }
60
+ else {
61
+ console.log('⚠️ 没有正在执行的任务');
62
+ console.log(` 当前状态: ${state.status}`);
63
+ }
64
+ return;
65
+ }
66
+ const approvalManager = new approval_manager_js_1.ApprovalManager(stateManager);
67
+ const executor = new executor_js_1.OrchestratorExecutor(stateManager, approvalManager, {
68
+ maxConcurrent: state.config.maxConcurrentAgents,
69
+ taskTimeout: state.config.timeout * 1000
70
+ });
71
+ const phaseExecutor = executor.getPhaseExecutor();
72
+ if (phaseExecutor) {
73
+ phaseExecutor.setRunId(state.runId);
74
+ }
75
+ const result = await executor.step();
76
+ if (options.json) {
77
+ console.log(JSON.stringify({
78
+ status: result.status,
79
+ message: result.message,
80
+ statistics: result.statistics,
81
+ subagentTasks: result.subagentTasks.map(t => ({
82
+ subagent_type: t.subagent_type,
83
+ description: t.description,
84
+ prompt: t.prompt,
85
+ isolation: t.isolation,
86
+ taskId: t.taskId,
87
+ agentType: t.agentType,
88
+ timeout: t.timeout
89
+ }))
90
+ }));
91
+ }
92
+ else {
93
+ console.log(`状态: ${result.status}`);
94
+ console.log(`消息: ${result.message}`);
95
+ if (result.subagentTasks.length > 0) {
96
+ console.log(`\n📋 待执行任务 (${result.subagentTasks.length}):`);
97
+ result.subagentTasks.forEach((t, i) => {
98
+ console.log(` ${i + 1}. [${t.agentType}] ${t.description.slice(0, 60)}`);
99
+ });
100
+ }
101
+ }
102
+ });
package/dist/cli/index.js CHANGED
@@ -15,6 +15,8 @@ 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");
18
20
  const program = new commander_1.Command();
19
21
  program
20
22
  .name('openmatrix')
@@ -34,5 +36,7 @@ program.addCommand(check_js_1.checkCommand);
34
36
  program.addCommand(check_gitignore_js_1.checkGitignoreCommand);
35
37
  program.addCommand(analyze_js_1.analyzeCommand);
36
38
  program.addCommand(brainstorm_js_1.brainstormCommand);
39
+ program.addCommand(complete_js_1.completeCommand);
40
+ program.addCommand(step_js_1.stepCommand);
37
41
  // 默认帮助
38
42
  program.parse();
@@ -13,6 +13,7 @@ export declare class StateManager {
13
13
  timeout: number;
14
14
  dependencies: string[];
15
15
  assignedAgent: string;
16
+ id?: string;
16
17
  }): Promise<Task>;
17
18
  getTask(taskId: string): Promise<Task | null>;
18
19
  updateTask(taskId: string, updates: Partial<Task>): Promise<void>;
@@ -53,7 +53,7 @@ class StateManager {
53
53
  this.stateCache = newState;
54
54
  }
55
55
  async createTask(input) {
56
- const taskId = this.generateTaskId();
56
+ const taskId = input.id || this.generateTaskId();
57
57
  const now = new Date().toISOString();
58
58
  const task = {
59
59
  id: taskId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmatrix",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
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",
package/skills/start.md CHANGED
@@ -77,14 +77,33 @@ CLI 返回 SubagentTask 列表。展示任务摘要后立即进入 Step 3。
77
77
 
78
78
  **从此步骤开始,除非遇到风险操作或 Meeting,不得暂停询问用户。**
79
79
 
80
+ **从 Step 2 CLI 返回的 subagentTasks 开始执行。每完成一个任务后必须调用 complete + step 获取下一批:**
81
+
80
82
  ```
81
- while (有待执行任务) {
82
- 1. Agent 工具执行 SubagentTask
83
- 2. openmatrix complete <taskId> --success/--failed
84
- 3. Git 自动提交
83
+ // Step 2 返回的 subagentTasks 直接执行
84
+ for (const task of subagentTasks) {
85
+ 1. Agent 工具执行 task
86
+ 2. openmatrix complete <taskId> --success --json
87
+ // complete 返回 nextBatch.subagentTasks,如果有新任务继续执行
88
+ }
89
+
90
+ // 如果 complete 返回了新任务,继续执行
91
+ while (nextBatch.subagentTasks.length > 0) {
92
+ for (const task of nextBatch.subagentTasks) {
93
+ 1. Agent 工具执行 task
94
+ 2. openmatrix complete <taskId> --success --json
95
+ // 更新 nextBatch
96
+ }
85
97
  }
98
+
99
+ // 或者在任意时刻调用 openmatrix step --json 获取下一批
86
100
  ```
87
101
 
102
+ **关键命令:**
103
+ - `openmatrix complete <taskId> --success --json` — 标记完成并返回下一批任务
104
+ - `openmatrix complete <taskId> --failed --error "原因" --json` — 标记失败
105
+ - `openmatrix step --json` — 手动获取下一批可执行任务
106
+
88
107
  - **失败任务**: 自动跳过并记录,执行结束后统一提示
89
108
  - **阻塞任务**: 记录到 Meeting,暂停用 AskUserQuestion 处理
90
109