openmatrix 0.1.54 → 0.1.56
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/dist/agents/agent-runner.d.ts +6 -0
- package/dist/agents/agent-runner.js +78 -1
- package/dist/cli/commands/complete.js +55 -48
- package/dist/cli/commands/step.js +61 -47
- package/dist/cli/index.js +4 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/skills/auto.md +51 -16
- package/skills/start.md +48 -14
|
@@ -67,6 +67,12 @@ export declare class AgentRunner {
|
|
|
67
67
|
* 构建完整的执行提示词
|
|
68
68
|
*/
|
|
69
69
|
buildExecutionPrompt(task: Task): string;
|
|
70
|
+
/**
|
|
71
|
+
* 构建累积上下文 - 从已完成任务中提取共享信息
|
|
72
|
+
*
|
|
73
|
+
* 读取所有已完成任务的 context.md,为当前 Agent 提供前序 Agent 的决策和知识
|
|
74
|
+
*/
|
|
75
|
+
private buildAccumulatedContext;
|
|
70
76
|
/**
|
|
71
77
|
* 构建阶段上下文
|
|
72
78
|
*/
|
|
@@ -1,6 +1,41 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.AgentRunner = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
4
39
|
/**
|
|
5
40
|
* AgentRunner - 使用 Subagent 执行任务
|
|
6
41
|
*
|
|
@@ -101,6 +136,7 @@ class AgentRunner {
|
|
|
101
136
|
buildExecutionPrompt(task) {
|
|
102
137
|
const agentPrompt = this.buildAgentPrompt(task);
|
|
103
138
|
const phaseContext = this.buildPhaseContext(task);
|
|
139
|
+
const accumulatedContext = this.buildAccumulatedContext(task);
|
|
104
140
|
return `# 任务执行
|
|
105
141
|
|
|
106
142
|
## 任务信息
|
|
@@ -118,6 +154,8 @@ ${task.dependencies.length > 0
|
|
|
118
154
|
? task.dependencies.map(d => `- ${d}`).join('\n')
|
|
119
155
|
: '无依赖'}
|
|
120
156
|
|
|
157
|
+
${accumulatedContext}
|
|
158
|
+
|
|
121
159
|
---
|
|
122
160
|
|
|
123
161
|
${agentPrompt.context}
|
|
@@ -130,8 +168,47 @@ ${agentPrompt.instructions}
|
|
|
130
168
|
|
|
131
169
|
1. 完成任务后,更新任务状态文件: \`.openmatrix/tasks/${task.id}/task.json\`
|
|
132
170
|
2. 将执行结果写入: \`.openmatrix/tasks/${task.id}/artifacts/result.md\`
|
|
133
|
-
3.
|
|
171
|
+
3. 将上下文摘要写入: \`.openmatrix/tasks/${task.id}/context.md\` (供后续 Agent 读取)
|
|
172
|
+
4. 如需审批,创建审批请求: \`.openmatrix/approvals/\` 目录
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 构建累积上下文 - 从已完成任务中提取共享信息
|
|
177
|
+
*
|
|
178
|
+
* 读取所有已完成任务的 context.md,为当前 Agent 提供前序 Agent 的决策和知识
|
|
179
|
+
*/
|
|
180
|
+
buildAccumulatedContext(currentTask) {
|
|
181
|
+
const omPath = path.join(process.cwd(), '.openmatrix');
|
|
182
|
+
const tasksDir = path.join(omPath, 'tasks');
|
|
183
|
+
try {
|
|
184
|
+
if (!fs.existsSync(tasksDir))
|
|
185
|
+
return '';
|
|
186
|
+
const contextParts = [];
|
|
187
|
+
// 读取所有已完成任务的 context.md
|
|
188
|
+
const taskDirs = fs.readdirSync(tasksDir).filter(name => name.startsWith('TASK-'));
|
|
189
|
+
for (const taskId of taskDirs) {
|
|
190
|
+
const contextFile = path.join(tasksDir, taskId, 'context.md');
|
|
191
|
+
if (fs.existsSync(contextFile)) {
|
|
192
|
+
const content = fs.readFileSync(contextFile, 'utf-8').trim();
|
|
193
|
+
if (content) {
|
|
194
|
+
contextParts.push(`### ${taskId}\n${content}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (contextParts.length === 0)
|
|
199
|
+
return '';
|
|
200
|
+
return `
|
|
201
|
+
## 前序 Agent 共享上下文 (Agent Memory)
|
|
202
|
+
|
|
203
|
+
以下是之前执行的 Agent 留下的上下文信息,包含它们的决策、发现和注意事项。
|
|
204
|
+
你应该基于这些信息来工作,避免重复犯错或与已有决策冲突。
|
|
205
|
+
|
|
206
|
+
${contextParts.join('\n\n')}
|
|
134
207
|
`;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
135
212
|
}
|
|
136
213
|
/**
|
|
137
214
|
* 构建阶段上下文
|
|
@@ -37,64 +37,71 @@ exports.completeCommand = void 0;
|
|
|
37
37
|
// src/cli/commands/complete.ts
|
|
38
38
|
const commander_1 = require("commander");
|
|
39
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
40
|
const path = __importStar(require("path"));
|
|
43
41
|
exports.completeCommand = new commander_1.Command('complete')
|
|
44
|
-
.description('
|
|
45
|
-
.argument('<taskId>', '任务
|
|
46
|
-
.option('--success', '
|
|
42
|
+
.description('标记任务完成并更新全局统计')
|
|
43
|
+
.argument('<taskId>', '任务ID (如 TASK-001)')
|
|
44
|
+
.option('--success', '标记为成功完成 (默认)', true)
|
|
47
45
|
.option('--failed', '标记为失败')
|
|
48
|
-
.option('--
|
|
49
|
-
.option('--
|
|
50
|
-
.option('--json', 'JSON 输出')
|
|
46
|
+
.option('--output <text>', '执行结果摘要')
|
|
47
|
+
.option('--error <text>', '错误信息 (失败时)')
|
|
51
48
|
.action(async (taskId, options) => {
|
|
52
49
|
const basePath = process.cwd();
|
|
53
50
|
const omPath = path.join(basePath, '.openmatrix');
|
|
54
51
|
const stateManager = new state_manager_js_1.StateManager(omPath);
|
|
55
52
|
await stateManager.initialize();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
53
|
+
// 1. 读取任务
|
|
54
|
+
const task = await stateManager.getTask(taskId);
|
|
55
|
+
if (!task) {
|
|
56
|
+
console.log(JSON.stringify({ error: `任务 ${taskId} 不存在` }));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const isSuccess = !options.failed;
|
|
60
|
+
const now = new Date().toISOString();
|
|
61
|
+
if (isSuccess) {
|
|
62
|
+
// 2a. 标记任务完成 - 更新所有阶段
|
|
63
|
+
await stateManager.updateTask(taskId, {
|
|
64
|
+
status: 'completed',
|
|
65
|
+
phases: {
|
|
66
|
+
develop: { status: 'completed', duration: 0, completedAt: now },
|
|
67
|
+
verify: { status: 'completed', duration: 0, completedAt: now },
|
|
68
|
+
accept: { status: 'completed', duration: 0, completedAt: now }
|
|
90
69
|
}
|
|
91
|
-
})
|
|
70
|
+
});
|
|
92
71
|
}
|
|
93
72
|
else {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
73
|
+
// 2b. 标记任务失败
|
|
74
|
+
await stateManager.updateTask(taskId, {
|
|
75
|
+
status: 'failed',
|
|
76
|
+
error: options.error || 'Task failed'
|
|
77
|
+
});
|
|
99
78
|
}
|
|
79
|
+
// 3. 重新计算全局统计(从实际任务文件统计,避免累积误差)
|
|
80
|
+
const allTasks = await stateManager.listTasks();
|
|
81
|
+
const stats = {
|
|
82
|
+
totalTasks: allTasks.length,
|
|
83
|
+
completed: allTasks.filter(t => t.status === 'completed').length,
|
|
84
|
+
inProgress: allTasks.filter(t => t.status === 'in_progress').length,
|
|
85
|
+
failed: allTasks.filter(t => t.status === 'failed').length,
|
|
86
|
+
pending: allTasks.filter(t => t.status === 'pending' || t.status === 'scheduled').length
|
|
87
|
+
};
|
|
88
|
+
// 4. 更新全局状态
|
|
89
|
+
const allDone = stats.completed + stats.failed === stats.totalTasks;
|
|
90
|
+
await stateManager.updateState({
|
|
91
|
+
statistics: stats,
|
|
92
|
+
status: allDone ? 'completed' : 'running',
|
|
93
|
+
currentPhase: allDone ? 'completed' : 'execution',
|
|
94
|
+
...(allDone ? { completedAt: now } : {})
|
|
95
|
+
});
|
|
96
|
+
// 5. 输出结果
|
|
97
|
+
const result = {
|
|
98
|
+
taskId,
|
|
99
|
+
status: isSuccess ? 'completed' : 'failed',
|
|
100
|
+
statistics: stats,
|
|
101
|
+
allDone,
|
|
102
|
+
message: isSuccess
|
|
103
|
+
? `${taskId} 完成 (${stats.completed}/${stats.totalTasks})`
|
|
104
|
+
: `${taskId} 失败: ${options.error || 'Unknown error'}`
|
|
105
|
+
};
|
|
106
|
+
console.log(JSON.stringify(result, null, 2));
|
|
100
107
|
});
|
|
@@ -35,68 +35,82 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.stepCommand = void 0;
|
|
37
37
|
// src/cli/commands/step.ts
|
|
38
|
+
// 循环状态持久化 - 防止上下文压缩导致循环丢失
|
|
38
39
|
const commander_1 = require("commander");
|
|
39
40
|
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
41
|
const path = __importStar(require("path"));
|
|
43
42
|
exports.stepCommand = new commander_1.Command('step')
|
|
44
|
-
.description('
|
|
45
|
-
.option('--json', 'JSON
|
|
43
|
+
.description('获取下一个待执行任务(持久化循环状态)')
|
|
44
|
+
.option('--json', '输出 JSON 格式')
|
|
46
45
|
.action(async (options) => {
|
|
47
46
|
const basePath = process.cwd();
|
|
48
47
|
const omPath = path.join(basePath, '.openmatrix');
|
|
49
48
|
const stateManager = new state_manager_js_1.StateManager(omPath);
|
|
50
49
|
await stateManager.initialize();
|
|
51
50
|
const state = await stateManager.getState();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
status: 'error',
|
|
56
|
-
message: '没有正在执行的任务',
|
|
57
|
-
currentState: state.status
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log('⚠️ 没有正在执行的任务');
|
|
62
|
-
console.log(` 当前状态: ${state.status}`);
|
|
63
|
-
}
|
|
51
|
+
// 检查是否已完成
|
|
52
|
+
if (state.status === 'completed') {
|
|
53
|
+
console.log(JSON.stringify({ status: 'done', message: '所有任务已完成' }));
|
|
64
54
|
return;
|
|
65
55
|
}
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
// 获取所有任务
|
|
57
|
+
const allTasks = await stateManager.listTasks();
|
|
58
|
+
const nextTask = allTasks.find(t => t.status === 'pending' ||
|
|
59
|
+
t.status === 'scheduled' ||
|
|
60
|
+
t.status === 'in_progress');
|
|
61
|
+
if (!nextTask) {
|
|
62
|
+
// 所有任务都完成了或被阻塞
|
|
63
|
+
const completed = allTasks.filter(t => t.status === 'completed').length;
|
|
64
|
+
const total = allTasks.length;
|
|
65
|
+
// 自动更新统计
|
|
66
|
+
const stats = {
|
|
67
|
+
totalTasks: total,
|
|
68
|
+
completed: completed,
|
|
69
|
+
inProgress: allTasks.filter(t => t.status === 'in_progress').length,
|
|
70
|
+
failed: allTasks.filter(t => t.status === 'failed').length,
|
|
71
|
+
pending: allTasks.filter(t => t.status === 'pending').length
|
|
72
|
+
};
|
|
73
|
+
const allDone = completed + stats.failed === total;
|
|
74
|
+
await stateManager.updateState({
|
|
75
|
+
statistics: stats,
|
|
76
|
+
status: allDone ? 'completed' : 'running',
|
|
77
|
+
currentPhase: allDone ? 'completed' : 'execution'
|
|
78
|
+
});
|
|
77
79
|
console.log(JSON.stringify({
|
|
78
|
-
status:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
}))
|
|
80
|
+
status: allDone ? 'done' : 'blocked',
|
|
81
|
+
statistics: stats,
|
|
82
|
+
message: allDone
|
|
83
|
+
? `所有任务已完成 (${completed}/${total})`
|
|
84
|
+
: `没有可执行任务 (${completed}/${total} 完成, ${stats.failed} 失败, ${stats.pending} 等待)`
|
|
90
85
|
}));
|
|
86
|
+
return;
|
|
91
87
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
// 输出下一个任务信息
|
|
89
|
+
const result = {
|
|
90
|
+
status: 'next',
|
|
91
|
+
task: {
|
|
92
|
+
id: nextTask.id,
|
|
93
|
+
title: nextTask.title,
|
|
94
|
+
description: nextTask.description,
|
|
95
|
+
status: nextTask.status,
|
|
96
|
+
assignedAgent: nextTask.assignedAgent,
|
|
97
|
+
dependencies: nextTask.dependencies,
|
|
98
|
+
acceptanceCriteria: nextTask.acceptanceCriteria
|
|
99
|
+
},
|
|
100
|
+
statistics: {
|
|
101
|
+
total: allTasks.length,
|
|
102
|
+
completed: allTasks.filter(t => t.status === 'completed').length,
|
|
103
|
+
remaining: allTasks.filter(t => t.status === 'pending' ||
|
|
104
|
+
t.status === 'scheduled' ||
|
|
105
|
+
t.status === 'in_progress').length,
|
|
106
|
+
failed: allTasks.filter(t => t.status === 'failed').length
|
|
100
107
|
}
|
|
108
|
+
};
|
|
109
|
+
if (options.json) {
|
|
110
|
+
console.log(JSON.stringify(result, null, 2));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
console.log(`📌 下一个任务: ${nextTask.id} - ${nextTask.title}`);
|
|
114
|
+
console.log(` 进度: ${result.statistics.completed}/${result.statistics.total} 完成, ${result.statistics.remaining} 剩余`);
|
|
101
115
|
}
|
|
102
116
|
});
|
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')
|
|
@@ -29,6 +31,8 @@ program.addCommand(retry_js_1.retryCommand);
|
|
|
29
31
|
program.addCommand(report_js_1.reportCommand);
|
|
30
32
|
program.addCommand(meeting_js_1.meetingCommand);
|
|
31
33
|
program.addCommand(auto_js_1.autoCommand);
|
|
34
|
+
program.addCommand(complete_js_1.completeCommand);
|
|
35
|
+
program.addCommand(step_js_1.stepCommand);
|
|
32
36
|
program.addCommand(install_skills_js_1.installSkillsCommand);
|
|
33
37
|
program.addCommand(check_js_1.checkCommand);
|
|
34
38
|
program.addCommand(check_gitignore_js_1.checkGitignoreCommand);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export interface GlobalState {
|
|
|
75
75
|
version: string;
|
|
76
76
|
runId: string;
|
|
77
77
|
status: RunStatus;
|
|
78
|
-
currentPhase: 'planning' | 'execution' | 'verification' | 'acceptance';
|
|
78
|
+
currentPhase: 'planning' | 'execution' | 'verification' | 'acceptance' | 'completed';
|
|
79
79
|
startedAt: string;
|
|
80
80
|
config: AppConfig;
|
|
81
81
|
statistics: {
|
package/package.json
CHANGED
package/skills/auto.md
CHANGED
|
@@ -126,23 +126,21 @@ CLI 返回的 JSON 中 `subagentTasks` 数组包含每个待执行任务:
|
|
|
126
126
|
❌ **禁止在还有未完成任务时停止** — 即使 Agent 返回了大段输出,也必须继续下一个
|
|
127
127
|
❌ **禁止询问"是否继续"** — 直接执行下一个任务
|
|
128
128
|
❌ **禁止输出"让我知道是否..."后停止** — 继续执行
|
|
129
|
-
❌ **禁止因为上下文压缩而忘记剩余任务** —
|
|
129
|
+
❌ **禁止因为上下文压缩而忘记剩余任务** — 通过 CLI 命令从磁盘获取真实状态
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
result = Agent(task) // 执行
|
|
137
|
-
更新任务状态为 completed
|
|
138
|
-
remaining = 从 state.json 重新读取未完成任务
|
|
139
|
-
}
|
|
131
|
+
**文件持久化循环(防止上下文压缩丢失状态):**
|
|
132
|
+
```bash
|
|
133
|
+
# 每个 Agent 完成后执行:
|
|
134
|
+
openmatrix complete TASK-XXX --success # 标记完成 + 更新统计
|
|
135
|
+
openmatrix step --json # 获取下一个任务 + 检查是否全部完成
|
|
140
136
|
```
|
|
137
|
+
`openmatrix step` 从磁盘读取真实状态,不依赖上下文记忆。
|
|
141
138
|
|
|
142
139
|
**中断恢复:** 如果会话中断,再次执行 `/om:auto` 时:
|
|
143
|
-
1.
|
|
144
|
-
2.
|
|
145
|
-
3.
|
|
140
|
+
1. 执行 `openmatrix step --json`
|
|
141
|
+
2. 如果返回 `status: "next"` → 从返回的任务继续执行
|
|
142
|
+
3. 如果返回 `status: "done"` → 所有任务已完成
|
|
143
|
+
4. 如果返回 `status: "blocked"` → 有阻塞任务需要处理
|
|
146
144
|
</LOOP-ENFORCEMENT>
|
|
147
145
|
|
|
148
146
|
对 `subagentTasks` 列表中的每个任务,调用 Agent 工具执行:
|
|
@@ -157,9 +155,46 @@ Agent({
|
|
|
157
155
|
```
|
|
158
156
|
|
|
159
157
|
每个 Agent 完成后:
|
|
160
|
-
1.
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
1. **保存 Agent 上下文** — 将执行结果摘要写入 `.openmatrix/tasks/TASK-XXX/context.md`,格式如下:
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
## 任务: TASK-XXX 任务标题
|
|
162
|
+
|
|
163
|
+
### 关键决策
|
|
164
|
+
- [做出的重要决策]
|
|
165
|
+
|
|
166
|
+
### 创建/修改的文件
|
|
167
|
+
- `path/to/file1.ts` - 简述用途
|
|
168
|
+
- `path/to/file2.ts` - 简述用途
|
|
169
|
+
|
|
170
|
+
### 重要发现
|
|
171
|
+
- [发现的问题、模式、注意事项]
|
|
172
|
+
|
|
173
|
+
### 对后续任务的建议
|
|
174
|
+
- [下一个 Agent 应该注意什么]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
2. **标记完成并更新统计(必须执行):**
|
|
178
|
+
```bash
|
|
179
|
+
openmatrix complete TASK-XXX --success
|
|
180
|
+
```
|
|
181
|
+
3. **获取下一个任务(防止上下文压缩丢失):**
|
|
182
|
+
```bash
|
|
183
|
+
openmatrix step --json
|
|
184
|
+
```
|
|
185
|
+
如果返回 `status: "next"` → 继续执行返回的 task
|
|
186
|
+
如果返回 `status: "done"` → 所有任务完成,进入最终提交
|
|
187
|
+
如果返回 `status: "blocked"` → 有阻塞任务,处理 Meeting
|
|
188
|
+
4. Git 自动提交(**必须使用 HEREDOC 格式**):
|
|
189
|
+
|
|
190
|
+
**Agent 上下文共享机制 (Agent Memory):**
|
|
191
|
+
|
|
192
|
+
每个 Agent 执行时会自动接收前序 Agent 的上下文信息(通过 `context.md` 文件)。
|
|
193
|
+
这确保 Agent 之间共享知识、避免重复工作、保持决策一致性。
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
Agent-1 完成 → 写入 context.md → Agent-2 读取 Agent-1 的上下文 → 写入 context.md → ...
|
|
197
|
+
```
|
|
163
198
|
```bash
|
|
164
199
|
git add -A && git commit -m "$(cat <<'EOF'
|
|
165
200
|
feat: (TASK-XXX) 任务标题
|
package/skills/start.md
CHANGED
|
@@ -174,18 +174,15 @@ CLI 返回 JSON 中 `subagentTasks` 数组包含待执行任务。
|
|
|
174
174
|
❌ **禁止在还有未完成任务时停止** — 即使 Agent 返回了大段输出,也必须继续下一个
|
|
175
175
|
❌ **禁止询问"是否继续"** — 直接执行下一个任务
|
|
176
176
|
❌ **禁止输出"让我知道是否..."后停止** — 继续执行
|
|
177
|
-
❌ **禁止因为上下文压缩而忘记剩余任务** —
|
|
177
|
+
❌ **禁止因为上下文压缩而忘记剩余任务** — 通过 `openmatrix step --json` 重新获取状态
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
result = Agent(task) // 执行
|
|
185
|
-
更新任务状态为 completed
|
|
186
|
-
remaining = 从 state.json 重新读取未完成任务
|
|
187
|
-
}
|
|
179
|
+
**文件持久化循环(防止上下文压缩丢失状态):**
|
|
180
|
+
```bash
|
|
181
|
+
# 每个 Agent 完成后执行:
|
|
182
|
+
openmatrix complete TASK-XXX --success # 标记完成 + 更新统计
|
|
183
|
+
openmatrix step --json # 获取下一个任务 + 检查是否全部完成
|
|
188
184
|
```
|
|
185
|
+
`openmatrix step` 会从磁盘读取真实状态,不依赖上下文记忆。
|
|
189
186
|
</LOOP-ENFORCEMENT>
|
|
190
187
|
|
|
191
188
|
对每个任务调用 Agent 工具:
|
|
@@ -200,10 +197,47 @@ Agent({
|
|
|
200
197
|
```
|
|
201
198
|
|
|
202
199
|
每个 Agent 完成后:
|
|
203
|
-
1.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
1. **标记完成并更新统计(必须执行):**
|
|
201
|
+
```bash
|
|
202
|
+
openmatrix complete TASK-XXX --success
|
|
203
|
+
```
|
|
204
|
+
2. **保存 Agent 上下文** — 将执行结果摘要写入 `.openmatrix/tasks/TASK-XXX/context.md`,格式如下:
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
## 任务: TASK-XXX 任务标题
|
|
208
|
+
|
|
209
|
+
### 关键决策
|
|
210
|
+
- [做出的重要决策]
|
|
211
|
+
|
|
212
|
+
### 创建/修改的文件
|
|
213
|
+
- `path/to/file1.ts` - 简述用途
|
|
214
|
+
- `path/to/file2.ts` - 简述用途
|
|
215
|
+
|
|
216
|
+
### 重要发现
|
|
217
|
+
- [发现的问题、模式、注意事项]
|
|
218
|
+
|
|
219
|
+
### 对后续任务的建议
|
|
220
|
+
- [下一个 Agent 应该注意什么]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
3. Git 自动提交(必须使用下方统一提交格式)
|
|
224
|
+
4. **获取下一个任务(防止上下文压缩丢失):**
|
|
225
|
+
```bash
|
|
226
|
+
openmatrix step --json
|
|
227
|
+
```
|
|
228
|
+
如果返回 `status: "next"` → 继续执行返回的 task
|
|
229
|
+
如果返回 `status: "done"` → 所有任务完成,进入最终提交
|
|
230
|
+
如果返回 `status: "blocked"` → 有阻塞任务,处理 Meeting
|
|
231
|
+
5. 检查审批点(auto 模式自动批准,其他模式按配置暂停)
|
|
232
|
+
|
|
233
|
+
**Agent 上下文共享机制 (Agent Memory):**
|
|
234
|
+
|
|
235
|
+
每个 Agent 执行时会自动接收前序 Agent 的上下文信息(通过 `context.md` 文件)。
|
|
236
|
+
这确保 Agent 之间共享知识、避免重复工作、保持决策一致性。
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
Agent-1 完成 → 写入 context.md → Agent-2 读取 Agent-1 的上下文 → 写入 context.md → ...
|
|
240
|
+
```
|
|
207
241
|
|
|
208
242
|
**中断恢复:** 如果会话中断,再次执行 `/om:start` 时:
|
|
209
243
|
1. 读取 `.openmatrix/state.json`
|