doukui 0.3.0 → 0.4.0
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 +1 -1
- package/bin/commands/loop.js +133 -45
- package/package.json +1 -1
- package/plugins/core/hook-skill-gate/index.js +18 -17
- package/plugins/core/provider-loop-engine/index.js +14 -0
- package/plugins/core/skill-agent-dispatcher/skill.md +93 -388
- package/plugins/core/skill-agentic-loop/mirror-rules.md +99 -0
- package/plugins/core/skill-agentic-loop/plugin.json +1 -1
- package/plugins/core/skill-agentic-loop/skill.md +31 -147
- package/plugins/core/skill-batch-task-creator/skill.md +14 -65
- package/plugins/core/skill-split-work-package/skill.md +14 -65
- package/plugins/core/skill-task-creator/context-budget-reference.md +67 -0
- package/plugins/core/skill-task-creator/skill.md +14 -63
- package/plugins/runtime/executor-claude.js +11 -235
- package/plugins/runtime/executor-default.js +7 -7
- package/plugins/runtime/executor-sdk.js +26 -1
- package/plugins/runtime/loop-report.js +68 -0
- package/plugins/runtime/plan-lint.js +106 -0
- package/plugins/runtime/reflection-evaluator.js +5 -0
- package/plugins/runtime/self-rescue-ladder.js +51 -0
- package/templates/harness-config.yaml +35 -4
|
@@ -27,30 +27,13 @@ description: "Use when user says \"批量执行\", \"并行执行\", \"调度子
|
|
|
27
27
|
|
|
28
28
|
## 团队机制现状 (🔴 必读)
|
|
29
29
|
|
|
30
|
-
Claude Code harness
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| 失去的能力 | — | 仅"显式命名团队管理":TeamCreate 命名、TeamDelete、按 `batch-xxx` 管理团队目录 |
|
|
38
|
-
|
|
39
|
-
**本 skill 中 `team_name` 变量的重新定义**:
|
|
40
|
-
- `team_name` **不再是 harness 团队名**(不再驱动 TeamCreate,不再作为 Agent 参数)。
|
|
41
|
-
- `team_name` 现在是 **Lead 内部的"批次逻辑标签"**,仍用于:
|
|
42
|
-
- 状态文件 `dispatcher-state.json` 的 `team_name` 字段(标识"这批执行")
|
|
43
|
-
- 心跳 `heartbeat.json` 的 `session_id` / `team_name` 字段(供守护进程监控)
|
|
44
|
-
- 执行报告的批次标识
|
|
45
|
-
- idle 检测里 `assignment.team_name == team_name` 的批次一致性校验
|
|
46
|
-
- 实际的 harness 团队由 session 自动分配,Lead 无需也无法干预。
|
|
47
|
-
|
|
48
|
-
**清理流程的相应调整**:
|
|
49
|
-
- 当前 session 的 implicit team 随 session 结束自动清理,**无需 TeamDelete**(工具也不存在)。
|
|
50
|
-
- `team-cleanup` CLI 保留,定位调整为**清理历史残留的显式/UUID 团队目录**(如旧的 `cybershop-wp101`、UUID 命名团队),而非清理当前 session team。
|
|
51
|
-
- session team 目录若需提前释放,仍可由 `team-cleanup` CLI 物理删除目录(CLI 内部直接走文件系统删除,**不调 TeamDelete**,见 cleanup-reference.md)。
|
|
52
|
-
|
|
53
|
-
**关于 Teamee Prompt 模板**: `roles-reference.md` 的 Prompt 模板仍含历史措辞(`团队名称: {team_name}`、`shutdown_request` 响应协议帧)。Lead 实际构建 prompt 时以 `build_single_task_prompt()` 行为为准——Teamee 一经 spawn 自动加入 implicit session team,无需注入 harness 团队名;销毁走逻辑销毁(markTeameeDestroyed),不发 shutdown 协议帧。
|
|
30
|
+
Claude Code harness 为 **implicit session team 模式**:每个 session 自动有一个 implicit team,subagent(Teamee)一经 spawn 自动加入,**并行 spawn + SendMessage + 共享 Task List 的协作能力随之可用**。`TeamCreate`/`TeamDelete` 工具已移除,不存在任何显式团队管理。
|
|
31
|
+
|
|
32
|
+
由此确定的运行规则:
|
|
33
|
+
- **`team_name` 变量是 Lead 内部的批次逻辑标签**,仅用于:状态文件/心跳的批次标识、执行报告标识、idle 检测的批次一致性校验。它**不进 Agent 参数**、不驱动团队创建。
|
|
34
|
+
- **Teamee 销毁走逻辑销毁**(`markTeameeDestroyed`,从映射表移除),无协议帧;session team 随 session 自动清理。
|
|
35
|
+
- **`team-cleanup` CLI 仅用于清理历史残留**的显式/UUID 团队目录(旧机制遗留),非当前 session team。
|
|
36
|
+
- `roles-reference.md` 的 Prompt 模板若含历史措辞(`团队名称: {team_name}`、shutdown 协议帧),以 `build_single_task_prompt()` 行为为准,忽略之。
|
|
54
37
|
|
|
55
38
|
---
|
|
56
39
|
|
|
@@ -95,39 +78,10 @@ Claude Code harness 已升级到 **implicit single-team 模式**。本 skill 的
|
|
|
95
78
|
|
|
96
79
|
## SendMessage 使用规范 (🔴 必须遵守)
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
`message text must not be a teammate protocol frame`。
|
|
103
|
-
这不是本项目代码能绕过的——**根本不要尝试用 SendMessage 发 protocol frame**。
|
|
104
|
-
|
|
105
|
-
2. **SendMessage 只用于纯文本状态沟通**,且**必须带 summary 参数**(5-10 词预览):
|
|
106
|
-
```
|
|
107
|
-
# ✅ 纯文本状态,带 summary
|
|
108
|
-
SendMessage(
|
|
109
|
-
to=target,
|
|
110
|
-
summary="Task 1 status update",
|
|
111
|
-
message="Task #1 已完成进度 50%"
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
# ❌ 任何 protocol frame 作为 message 都被拦截
|
|
115
|
-
SendMessage(to=target, message={"type": "shutdown_request", ...})
|
|
116
|
-
SendMessage(to=target, summary="...", message={"type": "shutdown_response", ...})
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
3. **Teamee 销毁走逻辑销毁**,不依赖任何协议帧:
|
|
120
|
-
```
|
|
121
|
-
# ✅ 逻辑销毁:从映射表移除,in-process Teamee 随 session 自然终止
|
|
122
|
-
markTeameeDestroyed(teamee_map, task_id)
|
|
123
|
-
```
|
|
124
|
-
销毁后**无需**等待响应、**无需**发送 shutdown。
|
|
125
|
-
|
|
126
|
-
4. **历史残留团队目录清理走确定性 CLI**(按需执行,非批末强制):
|
|
127
|
-
```
|
|
128
|
-
node bin/doukui.js team-cleanup <residual_team_name> --force
|
|
129
|
-
```
|
|
130
|
-
该 CLI 封装跨平台 `fs.rmSync` + 安全校验,绕过 harness Bash 权限系统。注意:当前 session 的 implicit team 随 session 自动清理,本 CLI 仅用于清理**历史残留**的显式/UUID 团队目录(如旧 batch-xxx、cybershop-wp101 等)。CLI 内部直接走文件系统删除,**不调用 TeamDelete**(工具已移除)。
|
|
81
|
+
1. **🔴 绝不携带 protocol frame**(`shutdown_request` / `shutdown_response` / `permission` / `mode` / `plan` 的 JSON)——harness 工具层直接拦截报错(`message text must not be a teammate protocol frame`),无法绕过,根本不要尝试。
|
|
82
|
+
2. **只用于纯文本状态沟通**,且**必须带 summary 参数**(5-10 词预览):`SendMessage(to=target, summary="Task 1 status update", message="Task #1 已完成进度 50%")`
|
|
83
|
+
3. **Teamee 销毁走逻辑销毁**(`markTeameeDestroyed(teamee_map, task_id)`,从映射表移除),不依赖任何协议帧,销毁后无需等待响应、无需发送 shutdown。
|
|
84
|
+
4. **历史残留团队目录清理走确定性 CLI**(按需执行,非批末强制):`node bin/doukui.js team-cleanup <residual_team_name> --force`——仅用于清理**历史残留**的显式/UUID 团队目录,非当前 session team(后者自动清理);CLI 内部直接走文件系统删除,不调用 TeamDelete(工具已移除)。
|
|
131
85
|
|
|
132
86
|
**原则**:SendMessage 是**纯文本沟通通道**;Teamee 生命周期管理(销毁/清理)走**逻辑销毁 + CLI**,两者解耦。
|
|
133
87
|
|
|
@@ -135,78 +89,15 @@ Claude Code harness 已升级到 **implicit single-team 模式**。本 skill 的
|
|
|
135
89
|
|
|
136
90
|
## Flow
|
|
137
91
|
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// 团队创建
|
|
148
|
-
"初始化批次标签 team_name" [shape=box, style=filled, fillcolor=lightblue];
|
|
149
|
-
"TaskCreate 创建任务" [shape=box, style=filled, fillcolor=lightblue];
|
|
150
|
-
"设置 blockedBy 依赖" [shape=box];
|
|
151
|
-
|
|
152
|
-
// 角色匹配
|
|
153
|
-
"角色匹配 (预计算)" [shape=box, style=filled, fillcolor=lightyellow];
|
|
154
|
-
"读取角色定义" [shape=box];
|
|
155
|
-
"注入专属记忆" [shape=box];
|
|
156
|
-
|
|
157
|
-
// 监控循环
|
|
158
|
-
"监控循环: TaskList" [shape=diamond, style=filled, fillcolor=orange];
|
|
159
|
-
"检测 newly-unblocked 任务" [shape=box];
|
|
160
|
-
"为可用任务创建专用 Teamee" [shape=box, style=filled, fillcolor=orange];
|
|
161
|
-
"预分配 owner (TaskUpdate)" [shape=box];
|
|
162
|
-
"Teamee 执行单一任务" [shape=box];
|
|
163
|
-
"TaskUpdate 标记 completed" [shape=box];
|
|
164
|
-
|
|
165
|
-
// 即时销毁(逻辑销毁,无协议帧)
|
|
166
|
-
"检测已完成任务" [shape=box];
|
|
167
|
-
"从映射表移除(逻辑销毁)" [shape=box];
|
|
168
|
-
|
|
169
|
-
// 循环判断
|
|
170
|
-
"所有任务 completed?" [shape=diamond];
|
|
171
|
-
"超时?" [shape=diamond];
|
|
172
|
-
|
|
173
|
-
// 收尾
|
|
174
|
-
"逻辑销毁残留 + 可选 team-cleanup CLI" [shape=box];
|
|
175
|
-
"经验提取" [shape=box, style=filled, fillcolor=lightgreen];
|
|
176
|
-
"生成执行报告" [shape=box];
|
|
177
|
-
|
|
178
|
-
// 流程连接
|
|
179
|
-
"解析工作包清单" -> "分析依赖关系";
|
|
180
|
-
"分析依赖关系" -> "检测循环依赖";
|
|
181
|
-
"检测循环依赖" -> "初始化批次标签 team_name" [label="无循环"];
|
|
182
|
-
"检测循环依赖" -> "报错退出" [label="有循环", style=dashed];
|
|
183
|
-
|
|
184
|
-
"初始化批次标签 team_name" -> "TaskCreate 创建任务";
|
|
185
|
-
"TaskCreate 创建任务" -> "设置 blockedBy 依赖";
|
|
186
|
-
"设置 blockedBy 依赖" -> "角色匹配 (预计算)";
|
|
187
|
-
|
|
188
|
-
"角色匹配 (预计算)" -> "读取角色定义";
|
|
189
|
-
"读取角色定义" -> "注入专属记忆";
|
|
190
|
-
"注入专属记忆" -> "监控循环: TaskList";
|
|
191
|
-
|
|
192
|
-
"监控循环: TaskList" -> "检测 newly-unblocked 任务";
|
|
193
|
-
"检测 newly-unblocked 任务" -> "为可用任务创建专用 Teamee" [label="有可用任务"];
|
|
194
|
-
"为可用任务创建专用 Teamee" -> "预分配 owner (TaskUpdate)";
|
|
195
|
-
"预分配 owner (TaskUpdate)" -> "Teamee 执行单一任务";
|
|
196
|
-
"Teamee 执行单一任务" -> "TaskUpdate 标记 completed";
|
|
197
|
-
|
|
198
|
-
"监控循环: TaskList" -> "检测已完成任务";
|
|
199
|
-
"检测已完成任务" -> "从映射表移除(逻辑销毁)" [label="有新完成"];
|
|
200
|
-
|
|
201
|
-
"监控循环: TaskList" -> "所有任务 completed?";
|
|
202
|
-
"所有任务 completed?" -> "逻辑销毁残留 + 可选 team-cleanup CLI" [label="是"];
|
|
203
|
-
"所有任务 completed?" -> "超时?" [label="否"];
|
|
204
|
-
"超时?" -> "监控循环: TaskList" [label="否"];
|
|
205
|
-
"超时?" -> "逻辑销毁残留 + 可选 team-cleanup CLI" [label="是"];
|
|
206
|
-
|
|
207
|
-
"逻辑销毁残留 + 可选 team-cleanup CLI" -> "经验提取";
|
|
208
|
-
"经验提取" -> "生成执行报告";
|
|
209
|
-
}
|
|
92
|
+
```
|
|
93
|
+
解析工作包清单 → 分析依赖 → 检测循环依赖(有则报错退出)
|
|
94
|
+
→ 初始化批次标签 team_name → TaskCreate + 设置 blockedBy
|
|
95
|
+
→ 角色匹配(预计算,Read roles-reference.md)
|
|
96
|
+
→ 监控循环(Step 6.5):
|
|
97
|
+
检测 newly-unblocked → 创建专用 Teamee(预分配 owner)
|
|
98
|
+
检测已完成 → 逻辑销毁对应 Teamee
|
|
99
|
+
所有任务 completed 或超时 → 退出循环
|
|
100
|
+
→ 逻辑销毁残留 + 可选 team-cleanup CLI → 经验提取 → 生成执行报告
|
|
210
101
|
```
|
|
211
102
|
|
|
212
103
|
---
|
|
@@ -337,19 +228,12 @@ for task in tasks:
|
|
|
337
228
|
all_tasks_verify = TaskList()
|
|
338
229
|
unblocked_verify = [t for t in all_tasks_verify if t.status == "pending" and is_unblocked(t)]
|
|
339
230
|
if len(teamee_map) != len(unblocked_verify):
|
|
340
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
341
231
|
# 输出: "⚠️ 验证失败: 有 {len(unblocked_verify)} 个已解除阻塞的 WP 但只创建了 {len(teamee_map)} 个 Teamee"
|
|
342
232
|
# 输出: "❌ 这可能意味着某些 WP 被错误合并。请检查以上步骤是否严格遵循 1:1 映射规则。"
|
|
343
233
|
else:
|
|
344
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
345
234
|
# 输出: "✅ 1:1 映射验证通过: {len(teamee_map)} 个 Teamee 对应 {len(unblocked_verify)} 个已解除阻塞的 WP"
|
|
346
235
|
```
|
|
347
236
|
|
|
348
|
-
**为什么不能用 Explore agent**:
|
|
349
|
-
- Explore agent 的工具集: `All tools except Agent, ExitPlanMode, Edit, Write, NotebookEdit`
|
|
350
|
-
- 没有 Write/Edit/Bash = 无法完成实现工作(不能写代码、改文件、跑测试)
|
|
351
|
-
- Teamee 的核心职责是实现 WP,只读 agent 无法胜任
|
|
352
|
-
|
|
353
237
|
### Step 6.5: 监控循环 (🔴 关键步骤 — 动态创建 + 即时销毁)
|
|
354
238
|
|
|
355
239
|
<HARD-GATE>
|
|
@@ -364,10 +248,11 @@ Lead Agent 必须进入监控循环,不可跳过!
|
|
|
364
248
|
```
|
|
365
249
|
# Lead Agent 监控循环
|
|
366
250
|
|
|
367
|
-
# ⚠️
|
|
251
|
+
# ⚠️ 监控循环基础规则 (🔴 必须遵守):
|
|
368
252
|
# 1. 任务完成 → 调 markTeameeDestroyed(teamee_map, task_id) 逻辑销毁(无协议帧)
|
|
369
253
|
# 2. SendMessage 仅用于纯文本状态沟通(必须带 summary),绝不携带 protocol frame
|
|
370
|
-
#
|
|
254
|
+
# (shutdown/permission/mode/plan JSON 一律禁止,harness 会拦截报错)
|
|
255
|
+
# 3. 下文所有「输出:」注释均为**直接文本输出**(写进回复正文),禁止用 SendMessage 发送
|
|
371
256
|
|
|
372
257
|
loop_interval = 30 # 秒
|
|
373
258
|
max_wait_time = 7200 # 2 小时
|
|
@@ -390,56 +275,51 @@ if is_multi_window:
|
|
|
390
275
|
state_file = f"{state_dir}/state.json"
|
|
391
276
|
heartbeat_file = f"{state_dir}/heartbeat.json"
|
|
392
277
|
|
|
278
|
+
# ---- 状态恢复统一通道(初始恢复与每轮 Phase 0 共用,防三处手抄漂移) ----
|
|
279
|
+
def restore_from_state(state):
|
|
280
|
+
"""从 state payload 恢复关键变量(缺失字段保当前值/默认值):
|
|
281
|
+
team_name / teamee_map / wp_assignments / start_time(parse_iso8601) /
|
|
282
|
+
loop_iteration / processed_action_ids / max_batch_size(默认5) /
|
|
283
|
+
current_batch / pending_batches / global_pause_flag(默认False)。"""
|
|
284
|
+
...
|
|
285
|
+
|
|
393
286
|
# 检查是否存在已有状态文件(上下文压缩后恢复)
|
|
394
287
|
if file_exists(state_file):
|
|
395
288
|
try:
|
|
396
289
|
existing_state = json_loads(Read(file_path=state_file))
|
|
397
290
|
except Exception as e:
|
|
398
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
399
291
|
# 输出: "⚠️ 状态文件解析失败,使用默认初始状态: {e}"
|
|
400
292
|
existing_state = {}
|
|
401
293
|
if existing_state.get("status") == "monitoring":
|
|
402
|
-
#
|
|
403
|
-
team_name = existing_state["team_name"]
|
|
404
|
-
teamee_map = existing_state["teamee_map"]
|
|
405
|
-
wp_assignments = existing_state["wp_assignments"]
|
|
406
|
-
loop_iteration = existing_state["loop_iteration"]
|
|
407
|
-
start_time = parse_iso8601(existing_state["start_time"])
|
|
408
|
-
processed_action_ids = existing_state["processed_action_ids"]
|
|
409
|
-
max_batch_size = existing_state.get("max_batch_size", 5)
|
|
410
|
-
current_batch = existing_state.get("current_batch", [])
|
|
411
|
-
pending_batches = existing_state.get("pending_batches", [])
|
|
412
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
294
|
+
restore_from_state(existing_state) # 上下文压缩后重新进入走此分支
|
|
413
295
|
# 输出: "从状态文件恢复: {len(teamee_map)} 个活跃 Teamee, 迭代 {loop_iteration}"
|
|
414
|
-
else:
|
|
415
|
-
# 状态文件存在但已完成,正常初始化
|
|
416
|
-
pass
|
|
417
|
-
|
|
418
|
-
# 首次初始化守护进程相关状态
|
|
419
|
-
loop_iteration = loop_iteration if 'loop_iteration' in locals() else 0
|
|
420
|
-
processed_action_ids = processed_action_ids if 'processed_action_ids' in locals() else []
|
|
421
296
|
|
|
422
297
|
# ---- 批量大小控制参数 ----
|
|
423
298
|
max_batch_size = get_config("agent_dispatcher.max_batch_size", default=5)
|
|
424
299
|
current_batch = current_batch if 'current_batch' in locals() else []
|
|
425
300
|
pending_batches = pending_batches if 'pending_batches' in locals() else []
|
|
426
301
|
|
|
302
|
+
# ---- 状态写回统一通道(全循环唯一构造点,防五处手抄漂移) ----
|
|
303
|
+
def build_state_payload(status="monitoring"):
|
|
304
|
+
"""构造 dispatcher-state.json 完整 payload。
|
|
305
|
+
字段:team_name / teamee_map / wp_assignments / start_time / loop_iteration /
|
|
306
|
+
processed_action_ids / total_tasks / status / max_batch_size / current_batch /
|
|
307
|
+
pending_batches / global_pause_flag。
|
|
308
|
+
多窗口模式(is_multi_window)自动附加 window_id + session_id。
|
|
309
|
+
completed 终态时省略 global_pause_flag。"""
|
|
310
|
+
payload = { ...上述字段全部取自当前变量... }
|
|
311
|
+
if is_multi_window:
|
|
312
|
+
payload["window_id"] = window_id
|
|
313
|
+
payload["session_id"] = multi_window_session
|
|
314
|
+
return payload
|
|
315
|
+
|
|
316
|
+
def write_state(status="monitoring"):
|
|
317
|
+
"""build_state_payload + Write(state_file)。每次 teamee_map / processed_action_ids /
|
|
318
|
+
批次变更后必须调用(防上下文压缩丢失)。"""
|
|
319
|
+
Write(file_path=state_file, content=json_dumps(build_state_payload(status)))
|
|
320
|
+
|
|
427
321
|
# 首次写入状态文件
|
|
428
|
-
|
|
429
|
-
"team_name": "{team_name}",
|
|
430
|
-
"teamee_map": teamee_map if 'teamee_map' in locals() else {},
|
|
431
|
-
"wp_assignments": wp_assignments if 'wp_assignments' in locals() else {},
|
|
432
|
-
"start_time": now_iso8601(),
|
|
433
|
-
"loop_iteration": loop_iteration,
|
|
434
|
-
"processed_action_ids": processed_action_ids,
|
|
435
|
-
"total_tasks": len(tasks) if 'tasks' in locals() else 0,
|
|
436
|
-
"status": "monitoring",
|
|
437
|
-
"max_batch_size": max_batch_size,
|
|
438
|
-
"current_batch": current_batch,
|
|
439
|
-
"pending_batches": pending_batches,
|
|
440
|
-
"global_pause_flag": False
|
|
441
|
-
}
|
|
442
|
-
Write(file_path=state_file, content=json_dumps(initial_state))
|
|
322
|
+
write_state("monitoring")
|
|
443
323
|
|
|
444
324
|
start_time = start_time if 'start_time' in locals() else now()
|
|
445
325
|
while (now() - start_time) < max_wait_time:
|
|
@@ -450,19 +330,9 @@ while (now() - start_time) < max_wait_time:
|
|
|
450
330
|
try:
|
|
451
331
|
state = json_loads(Read(file_path=state_file))
|
|
452
332
|
except Exception as e:
|
|
453
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
454
333
|
# 输出: "⚠️ 状态文件解析失败,使用当前内存状态继续: {e}"
|
|
455
334
|
state = {}
|
|
456
|
-
|
|
457
|
-
teamee_map = state.get("teamee_map", teamee_map)
|
|
458
|
-
wp_assignments = state.get("wp_assignments", wp_assignments)
|
|
459
|
-
start_time = parse_iso8601(state["start_time"]) if state.get("start_time") else start_time
|
|
460
|
-
loop_iteration = state.get("loop_iteration", loop_iteration)
|
|
461
|
-
processed_action_ids = state.get("processed_action_ids", processed_action_ids)
|
|
462
|
-
max_batch_size = state.get("max_batch_size", max_batch_size)
|
|
463
|
-
current_batch = state.get("current_batch", current_batch)
|
|
464
|
-
pending_batches = state.get("pending_batches", pending_batches)
|
|
465
|
-
global_pause_flag = state.get("global_pause_flag", False)
|
|
335
|
+
restore_from_state(state)
|
|
466
336
|
|
|
467
337
|
# ---- Phase 0.1: 多窗口阶段信号检查 ----
|
|
468
338
|
# 读取 multi-window-session.json,检查当前窗口的阶段是否就绪
|
|
@@ -483,7 +353,6 @@ while (now() - start_time) < max_wait_time:
|
|
|
483
353
|
if my_stage:
|
|
484
354
|
if my_stage.get("status") == "pending":
|
|
485
355
|
# 当前阶段未就绪,跳过本轮 Teamee 创建
|
|
486
|
-
# ── 状态输出 ──
|
|
487
356
|
# 输出: "⏸ 窗口 {window_id} 阶段 {my_stage['stage_id']} 尚未就绪,等待阶段信号"
|
|
488
357
|
pass # 跳过后续 Phase C 创建逻辑(通过标志控制)
|
|
489
358
|
elif my_stage.get("status") == "completed":
|
|
@@ -497,7 +366,6 @@ while (now() - start_time) < max_wait_time:
|
|
|
497
366
|
# 切换到下一阶段的任务
|
|
498
367
|
assigned_wps = next_stage.get("work_packages", assigned_wps)
|
|
499
368
|
current_stage = next_stage.get("stage_id", current_stage)
|
|
500
|
-
# ── 状态输出 ──
|
|
501
369
|
# 输出: "🔄 窗口 {window_id} 切换到阶段 {next_stage['stage_id']}: {next_stage.get('name', '')}"
|
|
502
370
|
|
|
503
371
|
# ---- Phase A: 获取任务状态 ----
|
|
@@ -526,12 +394,10 @@ while (now() - start_time) < max_wait_time:
|
|
|
526
394
|
for task in tasks:
|
|
527
395
|
if task.status == "completed" and task.id in teamee_map:
|
|
528
396
|
teamee_name = teamee_map[task.id]
|
|
529
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
530
397
|
# 输出: "任务 {task.id} 已完成,逻辑销毁 Teamee: {teamee_name}"
|
|
531
398
|
|
|
532
399
|
# B1. 逻辑销毁:从映射表移除(不发任何协议帧;in-process Teamee 随 session 终止)
|
|
533
400
|
markTeameeDestroyed(teamee_map, task.id)
|
|
534
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
535
401
|
# 输出: "逻辑销毁 Teamee: {teamee_name}(映射已移除)"
|
|
536
402
|
|
|
537
403
|
# B2. 更新任务状态文件 (DISP-002)
|
|
@@ -539,24 +405,7 @@ while (now() - start_time) < max_wait_time:
|
|
|
539
405
|
update_task_file(task.id, status="completed")
|
|
540
406
|
|
|
541
407
|
# ---- Phase B.5: 状态持久化写回 (teamee_map 变更) ----
|
|
542
|
-
|
|
543
|
-
"team_name": team_name,
|
|
544
|
-
"teamee_map": teamee_map,
|
|
545
|
-
"wp_assignments": wp_assignments,
|
|
546
|
-
"start_time": start_time.isoformat() if hasattr(start_time, 'isoformat') else start_time,
|
|
547
|
-
"loop_iteration": loop_iteration,
|
|
548
|
-
"processed_action_ids": processed_action_ids,
|
|
549
|
-
"total_tasks": len(tasks),
|
|
550
|
-
"status": "monitoring",
|
|
551
|
-
"max_batch_size": max_batch_size,
|
|
552
|
-
"current_batch": current_batch,
|
|
553
|
-
"pending_batches": pending_batches,
|
|
554
|
-
"global_pause_flag": global_pause_flag
|
|
555
|
-
}
|
|
556
|
-
if is_multi_window:
|
|
557
|
-
state_payload_b5["window_id"] = window_id
|
|
558
|
-
state_payload_b5["session_id"] = multi_window_session
|
|
559
|
-
Write(file_path=state_file, content=json_dumps(state_payload_b5))
|
|
408
|
+
write_state("monitoring")
|
|
560
409
|
|
|
561
410
|
# ---- Phase C: 按需创建 Teamee 处理 newly-unblocked 任务 ----
|
|
562
411
|
# C0. 读取并发配置,计算当前时段的并发上限
|
|
@@ -576,14 +425,12 @@ while (now() - start_time) < max_wait_time:
|
|
|
576
425
|
overflow = unblocked_candidates[max_batch_size:]
|
|
577
426
|
if overflow:
|
|
578
427
|
pending_batches.extend([t.id for t in overflow])
|
|
579
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
580
428
|
# 输出: "批量控制: 当前批次 {len(current_batch)} 个任务, 待处理批次 {len(pending_batches)} 个任务"
|
|
581
429
|
|
|
582
430
|
for task in tasks:
|
|
583
431
|
if task.status == "pending" and task.owner == "" and is_unblocked(task):
|
|
584
432
|
# C0.1 并发检查:活跃 Teamee 数已达上限,跳过创建
|
|
585
433
|
if active_count >= max_concurrent:
|
|
586
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
587
434
|
# 输出: "并发上限 {max_concurrent} 已达,任务 {task.id} 保持 pending"
|
|
588
435
|
continue
|
|
589
436
|
|
|
@@ -618,7 +465,6 @@ while (now() - start_time) < max_wait_time:
|
|
|
618
465
|
# C5. 记录映射关系
|
|
619
466
|
teamee_map[task.id] = teamee_name
|
|
620
467
|
active_count += 1
|
|
621
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
622
468
|
# 输出: "为任务 {task.id} 创建专用 Teamee: {teamee_name}"
|
|
623
469
|
|
|
624
470
|
# C6. 创建任务状态文件 (DISP-002)
|
|
@@ -632,24 +478,7 @@ while (now() - start_time) < max_wait_time:
|
|
|
632
478
|
)
|
|
633
479
|
|
|
634
480
|
# ---- Phase C.5: 状态持久化写回 (teamee_map 变更) ----
|
|
635
|
-
|
|
636
|
-
"team_name": team_name,
|
|
637
|
-
"teamee_map": teamee_map,
|
|
638
|
-
"wp_assignments": wp_assignments,
|
|
639
|
-
"start_time": start_time.isoformat() if hasattr(start_time, 'isoformat') else start_time,
|
|
640
|
-
"loop_iteration": loop_iteration,
|
|
641
|
-
"processed_action_ids": processed_action_ids,
|
|
642
|
-
"total_tasks": len(tasks),
|
|
643
|
-
"status": "monitoring",
|
|
644
|
-
"max_batch_size": max_batch_size,
|
|
645
|
-
"current_batch": current_batch,
|
|
646
|
-
"pending_batches": pending_batches,
|
|
647
|
-
"global_pause_flag": global_pause_flag
|
|
648
|
-
}
|
|
649
|
-
if is_multi_window:
|
|
650
|
-
state_payload_c5["window_id"] = window_id
|
|
651
|
-
state_payload_c5["session_id"] = multi_window_session
|
|
652
|
-
Write(file_path=state_file, content=json_dumps(state_payload_c5))
|
|
481
|
+
write_state("monitoring")
|
|
653
482
|
|
|
654
483
|
# ---- Phase D.1: 读取守护进程指令 (DISP-003) ----
|
|
655
484
|
# 在判断退出条件前,读取守护进程下发的指令
|
|
@@ -659,7 +488,6 @@ while (now() - start_time) < max_wait_time:
|
|
|
659
488
|
try:
|
|
660
489
|
actions = json_loads(actions_data).get("actions", [])
|
|
661
490
|
except Exception as e:
|
|
662
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
663
491
|
# 输出: "⚠️ 守护进程指令文件解析失败,跳过本轮指令: {e}"
|
|
664
492
|
actions = []
|
|
665
493
|
|
|
@@ -746,7 +574,6 @@ while (now() - start_time) < max_wait_time:
|
|
|
746
574
|
for task_id in list(teamee_map.keys()):
|
|
747
575
|
markTeameeDestroyed(teamee_map, task_id)
|
|
748
576
|
teamee_map.clear()
|
|
749
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
750
577
|
# 输出: "收到 abort_all 指令,终止监控循环"
|
|
751
578
|
processed_action_ids.append(action.get("id"))
|
|
752
579
|
break # 跳出监控循环
|
|
@@ -759,24 +586,7 @@ while (now() - start_time) < max_wait_time:
|
|
|
759
586
|
}))
|
|
760
587
|
|
|
761
588
|
# ---- Phase D.5: 状态持久化写回 (processed_action_ids 变更) ----
|
|
762
|
-
|
|
763
|
-
"team_name": team_name,
|
|
764
|
-
"teamee_map": teamee_map,
|
|
765
|
-
"wp_assignments": wp_assignments,
|
|
766
|
-
"start_time": start_time.isoformat() if hasattr(start_time, 'isoformat') else start_time,
|
|
767
|
-
"loop_iteration": loop_iteration,
|
|
768
|
-
"processed_action_ids": processed_action_ids,
|
|
769
|
-
"total_tasks": len(tasks),
|
|
770
|
-
"status": "monitoring",
|
|
771
|
-
"max_batch_size": max_batch_size,
|
|
772
|
-
"current_batch": current_batch,
|
|
773
|
-
"pending_batches": pending_batches,
|
|
774
|
-
"global_pause_flag": global_pause_flag
|
|
775
|
-
}
|
|
776
|
-
if is_multi_window:
|
|
777
|
-
state_payload_d5["window_id"] = window_id
|
|
778
|
-
state_payload_d5["session_id"] = multi_window_session
|
|
779
|
-
Write(file_path=state_file, content=json_dumps(state_payload_d5))
|
|
589
|
+
write_state("monitoring")
|
|
780
590
|
|
|
781
591
|
# ---- Phase D: 判断退出条件 ----
|
|
782
592
|
completed = count(status == "completed")
|
|
@@ -789,24 +599,7 @@ while (now() - start_time) < max_wait_time:
|
|
|
789
599
|
heartbeat_data["window_id"] = window_id
|
|
790
600
|
Write(file_path=heartbeat_file, content=json_dumps(heartbeat_data))
|
|
791
601
|
# 写入最终状态文件
|
|
792
|
-
|
|
793
|
-
"team_name": team_name,
|
|
794
|
-
"teamee_map": teamee_map,
|
|
795
|
-
"wp_assignments": wp_assignments,
|
|
796
|
-
"start_time": start_time.isoformat() if hasattr(start_time, 'isoformat') else start_time,
|
|
797
|
-
"loop_iteration": loop_iteration,
|
|
798
|
-
"processed_action_ids": processed_action_ids,
|
|
799
|
-
"total_tasks": len(tasks),
|
|
800
|
-
"status": "completed",
|
|
801
|
-
"max_batch_size": max_batch_size,
|
|
802
|
-
"current_batch": current_batch,
|
|
803
|
-
"pending_batches": pending_batches
|
|
804
|
-
}
|
|
805
|
-
if is_multi_window:
|
|
806
|
-
final_state["window_id"] = window_id
|
|
807
|
-
final_state["session_id"] = multi_window_session
|
|
808
|
-
Write(file_path=state_file, content=json_dumps(final_state))
|
|
809
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
602
|
+
write_state("completed")
|
|
810
603
|
# 输出: "所有任务完成,退出监控循环"
|
|
811
604
|
break
|
|
812
605
|
|
|
@@ -814,62 +607,42 @@ while (now() - start_time) < max_wait_time:
|
|
|
814
607
|
in_progress = count(status == "in_progress")
|
|
815
608
|
pending = count(status == "pending")
|
|
816
609
|
if pending > 0 and in_progress == 0 and len(teamee_map) == 0:
|
|
817
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
818
610
|
# 输出: "异常: 有待处理任务但无活跃 Teamee 且无映射"
|
|
819
611
|
break
|
|
820
612
|
|
|
821
613
|
# Phase D2-idle: idle 不执行检测(teamee_map 非空但 Task 长时间未推进)
|
|
822
|
-
# 与上方 len(teamee_map)==0
|
|
823
|
-
#
|
|
824
|
-
#
|
|
825
|
-
#
|
|
826
|
-
#
|
|
827
|
-
#
|
|
828
|
-
#
|
|
829
|
-
#
|
|
830
|
-
# 改动范围且与运行时不符,故降级并标注 TODO。expected_product_path() 伪函数见下方定义。
|
|
831
|
-
# - F2: idle 计时起点从任务状态文件 read_task_file(task_id)["started_at"] 读取——TaskList 的
|
|
832
|
-
# task 对象无 assigned_at/started_at 字段,原 fallback 链 task.assigned_at 恒 None。
|
|
833
|
-
# - F3: 催促去重位 idle_nudge_sent(任务状态文件),Step 1 前检查,已催促则跳过直接进 Step 2-3。
|
|
834
|
-
# - F4: 重 spawn 后 update_task_file(reset_started_at=True) 刷新 started_at + 重置 idle_nudge_sent,
|
|
835
|
-
# 新 Teamee 获得完整 idle_threshold 窗口。F3+F4 联动才能阻断"spawn 即判定 idle→每轮自愈→熔断"死亡螺旋。
|
|
614
|
+
# 与上方 len(teamee_map)==0 异常分支并列。Teamee 已 spawn 但 idle 不执行时,
|
|
615
|
+
# 走自愈流程(催促→重 spawn→熔断),🔴 绝不 Lead 接手(见文末 HARD-GATE)。
|
|
616
|
+
# 关键不变量(防"spawn 即判 idle→每轮自愈→熔断"死亡螺旋):
|
|
617
|
+
# - idle 计时起点 = 任务状态文件 started_at(回退 last_update → start_time),非 TaskList 对象
|
|
618
|
+
# - 催促去重位 idle_nudge_sent:本 idle 窗口内仅催促一次,催促后给满一个 idle_threshold 窗口
|
|
619
|
+
# 才允许进重 spawn;首轮只催促不重 spawn
|
|
620
|
+
# - 重 spawn 时 increment_retry + reset_started_at + set_idle_nudge=False 三者必须
|
|
621
|
+
# 同一次 update_task_file 完成(缺任一都会复活死亡螺旋)
|
|
836
622
|
idle_threshold = loop_interval * 2 # 建议取 loop_interval 的 2-3 倍或显式配置项
|
|
837
623
|
for task_id, teamee_name in list(teamee_map.items()):
|
|
838
624
|
task = find_by_id(tasks, task_id)
|
|
839
625
|
if task is None:
|
|
840
626
|
continue
|
|
841
|
-
# 双验证:TaskList
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
product_exists = Glob(expected_product_path(task)) # F1: 预期产物路径,见下方函数定义(无声明时返回 None 触发弱信号)
|
|
627
|
+
# 双验证:TaskList status 未推进 + 产物弱信号(expected_product_path 无声明时恒 None → 弱信号)
|
|
628
|
+
task_file = read_task_file(task_id)
|
|
629
|
+
product_exists = Glob(expected_product_path(task))
|
|
845
630
|
task_stalled = task.status in ("pending", "in_progress") and not product_exists
|
|
846
|
-
# F2: idle 计时起点 = 任务状态文件 started_at(TaskList task 对象无此字段)。
|
|
847
|
-
# 缺失时回退到 last_update,再缺失回退到 start_time(监控循环起点)。
|
|
848
631
|
assigned_at = task_file.get("started_at") or task_file.get("last_update") or start_time
|
|
849
|
-
# F3 去重位:本 idle 窗口内是否已催促过(重 spawn 后由 Step 4 重置)
|
|
850
632
|
idle_nudge_sent = task_file.get("idle_nudge_sent", False)
|
|
851
633
|
if task_stalled and (now() - assigned_at) >= idle_threshold:
|
|
852
|
-
#
|
|
853
|
-
# 输出: "⚠️ idle 检测: Teamee {teamee_name} (task {task_id}) 停滞 {idle_seconds}s 未推进产物,进入自愈流程"
|
|
854
|
-
# 进入自愈流程(Phase D2-idle-heal),绝不 Lead 接手
|
|
634
|
+
# 输出: "⚠️ idle 检测: Teamee {teamee_name} (task {task_id}) 停滞,进入自愈流程"
|
|
855
635
|
# ---- Phase D2-idle-heal: 自愈流程 ----
|
|
856
|
-
# Step 1:
|
|
857
|
-
# F3 去重 + 催促生效窗口:本 idle 窗口内仅催促一次,催促后给 Teamee 至少一个
|
|
858
|
-
# idle_threshold 窗口响应——首轮只催促(设 idle_nudge_sent=True)并结束本轮自愈,
|
|
859
|
-
# 不立即重 spawn;下一轮若仍 idle 且已催促,才跳过催促进入 Step 2-4 重 spawn。
|
|
860
|
-
# 缺失去重位/催促窗口会导致每轮重复催促 + 立即重 spawn,数轮内耗尽 max_retries 熔断。
|
|
636
|
+
# Step 1: 首轮仅催促一次(去重位),给满一个 idle_threshold 窗口,本轮不重 spawn
|
|
861
637
|
if not idle_nudge_sent:
|
|
862
638
|
SendMessage(
|
|
863
639
|
to=teamee_name,
|
|
864
640
|
summary="idle 检测催促,请立即执行任务",
|
|
865
641
|
message=f"检测到任务 {task_id} 长时间未推进。请立即开始执行 WP 文档中的任务,完成后用 SendMessage 向 team-lead 发送完成报告。"
|
|
866
642
|
)
|
|
867
|
-
update_task_file(task_id, set_idle_nudge=True)
|
|
868
|
-
#
|
|
869
|
-
|
|
870
|
-
continue # 结束本轮自愈,下一轮若仍 idle 且已催促才进 Step 2-4
|
|
871
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
872
|
-
# 输出: "idle 自愈: task {task_id} 本窗口已催促过仍无推进,跳过催促直接进 Step 2-4 重 spawn"
|
|
643
|
+
update_task_file(task_id, set_idle_nudge=True)
|
|
644
|
+
continue # 下一轮若仍 idle 且已催促,才进 Step 2-4
|
|
645
|
+
# 输出: "idle 自愈: task {task_id} 已催促过仍无推进,进 Step 2-4 重 spawn"
|
|
873
646
|
# Step 2: 验证 spawn 参数(定位根因,避免原样重 spawn 仍 idle)
|
|
874
647
|
assignment = wp_assignments[task_id]
|
|
875
648
|
spawn_params_ok = (
|
|
@@ -880,12 +653,11 @@ while (now() - start_time) < max_wait_time:
|
|
|
880
653
|
and "SendMessage" in assignment.prompt # prompt 须要求完成报告用 SendMessage
|
|
881
654
|
)
|
|
882
655
|
if not spawn_params_ok:
|
|
883
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
884
656
|
# 输出: "spawn 参数异常 (subagent_type/批次标签 team_name/prompt 完整性),将在重 spawn 时修正"
|
|
885
657
|
pass
|
|
886
658
|
# Step 3: 仍不执行 → 逻辑销毁旧 Teamee(无协议帧)
|
|
887
659
|
markTeameeDestroyed(teamee_map, task_id)
|
|
888
|
-
# Step 4: 检查 retry_count < max_retries → 重新 spawn(复用
|
|
660
|
+
# Step 4: 检查 retry_count < max_retries → 重新 spawn(复用 Phase D.1 restart 指令段的重 spawn 逻辑)
|
|
889
661
|
# 复用 idle 检测顶部已读取的 task_file(read_task_file 结果),避免重复 IO
|
|
890
662
|
retry_count = task_file.get("retry_count", 0)
|
|
891
663
|
max_retries = task_file.get("max_retries", 3)
|
|
@@ -906,23 +678,18 @@ while (now() - start_time) < max_wait_time:
|
|
|
906
678
|
prompt=prompt
|
|
907
679
|
)
|
|
908
680
|
teamee_map[task_id] = new_teamee_name
|
|
909
|
-
#
|
|
910
|
-
# + 重置 idle_nudge_sent=False(F3,新 Teamee 重新获得一次催促机会)。
|
|
911
|
-
# 单独刷新 started_at 而不重置去重位 → 新窗口仍无法催促;单独重置去重位而不刷新 started_at
|
|
912
|
-
# → 新 Teamee 一出生即满足 idle 阈值又被判定 idle。两者必须同一次调用完成(阻断死亡螺旋)。
|
|
681
|
+
# 三合一调用(缺任一复活死亡螺旋):递增 retry + 刷新 started_at + 重置催促去重位
|
|
913
682
|
update_task_file(
|
|
914
683
|
task_id,
|
|
915
684
|
increment_retry=True,
|
|
916
685
|
reset_started_at=True, # F4
|
|
917
686
|
set_idle_nudge=False # F3
|
|
918
687
|
)
|
|
919
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
920
688
|
# 输出: "idle 自愈: task {task_id} 重新 spawn 为 {new_teamee_name} (retry {retry_count+1}/{max_retries}),已刷新 started_at + 重置催促去重位"
|
|
921
689
|
else:
|
|
922
690
|
# Step 5: 超限 → 熔断,绝不 Lead 接手,转 Step 7 清理
|
|
923
691
|
TaskUpdate(taskId=task_id, status="failed")
|
|
924
692
|
update_task_file(task_id, status="failed")
|
|
925
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
926
693
|
# 输出: "🔴 idle 自愈超限: task {task_id} 重试 {retry_count}/{max_retries} 仍 idle,熔断标记 failed,绝不 Lead 接手,转 Step 7 清理"
|
|
927
694
|
|
|
928
695
|
# Phase D3: 批次自动加载 — 当前批次全部完成后从 pending_batches 加载下一批
|
|
@@ -935,27 +702,9 @@ while (now() - start_time) < max_wait_time:
|
|
|
935
702
|
next_batch_size = min(max_batch_size, len(pending_batches))
|
|
936
703
|
current_batch = pending_batches[:next_batch_size]
|
|
937
704
|
pending_batches = pending_batches[next_batch_size:]
|
|
938
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
939
705
|
# 输出: "当前批次完成,自动加载下一批: {len(current_batch)} 个任务, 剩余 {len(pending_batches)} 个"
|
|
940
706
|
# 写回状态文件保存批次进度
|
|
941
|
-
|
|
942
|
-
"team_name": team_name,
|
|
943
|
-
"teamee_map": teamee_map,
|
|
944
|
-
"wp_assignments": wp_assignments,
|
|
945
|
-
"start_time": start_time.isoformat() if hasattr(start_time, 'isoformat') else start_time,
|
|
946
|
-
"loop_iteration": loop_iteration,
|
|
947
|
-
"processed_action_ids": processed_action_ids,
|
|
948
|
-
"total_tasks": len(tasks),
|
|
949
|
-
"status": "monitoring",
|
|
950
|
-
"max_batch_size": max_batch_size,
|
|
951
|
-
"current_batch": current_batch,
|
|
952
|
-
"pending_batches": pending_batches,
|
|
953
|
-
"global_pause_flag": global_pause_flag
|
|
954
|
-
}
|
|
955
|
-
if is_multi_window:
|
|
956
|
-
state_payload_batch["window_id"] = window_id
|
|
957
|
-
state_payload_batch["session_id"] = multi_window_session
|
|
958
|
-
Write(file_path=state_file, content=json_dumps(state_payload_batch))
|
|
707
|
+
write_state("monitoring")
|
|
959
708
|
|
|
960
709
|
sleep(loop_interval)
|
|
961
710
|
|
|
@@ -966,42 +715,27 @@ if (now() - start_time) >= max_wait_time:
|
|
|
966
715
|
if is_multi_window:
|
|
967
716
|
heartbeat_data["window_id"] = window_id
|
|
968
717
|
Write(file_path=heartbeat_file, content=json_dumps(heartbeat_data))
|
|
969
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
970
718
|
# 输出: "监控超时,强制执行清理"
|
|
971
719
|
# 逻辑销毁所有残留 Teamee(无协议帧)
|
|
972
720
|
remaining_count = len(teamee_map)
|
|
973
721
|
for task_id in list(teamee_map.keys()):
|
|
974
722
|
markTeameeDestroyed(teamee_map, task_id)
|
|
975
|
-
# ── 状态输出(直接文本输出,禁止使用 SendMessage)──
|
|
976
723
|
# 输出: "监控超时,已逻辑销毁 {remaining_count} 个残留 Teamee,转入 Step 7 目录清理"
|
|
977
724
|
```
|
|
978
725
|
|
|
979
726
|
**上下文恢复协议**:
|
|
980
727
|
|
|
981
|
-
如果监控循环因上下文压缩(auto-compact
|
|
728
|
+
如果监控循环因上下文压缩(auto-compact)而中断,按以下步骤恢复:
|
|
982
729
|
|
|
983
730
|
```
|
|
984
|
-
1. Read
|
|
985
|
-
-
|
|
986
|
-
-
|
|
987
|
-
-
|
|
988
|
-
|
|
989
|
-
2.
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
teamee_map = state["teamee_map"]
|
|
993
|
-
wp_assignments = state["wp_assignments"]
|
|
994
|
-
start_time = parse_iso8601(state["start_time"])
|
|
995
|
-
loop_iteration = state["loop_iteration"]
|
|
996
|
-
processed_action_ids = state["processed_action_ids"]
|
|
997
|
-
max_batch_size = state.get("max_batch_size", 5)
|
|
998
|
-
current_batch = state.get("current_batch", [])
|
|
999
|
-
pending_batches = state.get("pending_batches", [])
|
|
1000
|
-
|
|
1001
|
-
3. 验证恢复有效性:
|
|
1002
|
-
- 检查 team 配置是否仍然有效
|
|
1003
|
-
- 检查 teamee_map 中的 teamee 是否仍然活跃
|
|
1004
|
-
- 如果某个 teamee 已不存在,从映射表中移除
|
|
731
|
+
1. Read 状态文件(多窗口模式读 windows/{window_id}/state.json)
|
|
732
|
+
- 不存在 → 首次运行或已清理,从头开始
|
|
733
|
+
- status == "completed" → 执行已完成,无需恢复
|
|
734
|
+
- status == "monitoring" → 进入恢复流程
|
|
735
|
+
|
|
736
|
+
2. restore_from_state(state) # 字段清单见监控循环顶部的统一恢复通道定义
|
|
737
|
+
|
|
738
|
+
3. 验证恢复有效性: teamee_map 中的 teamee 若已不存在,从映射表移除
|
|
1005
739
|
|
|
1006
740
|
4. 继续监控循环(从恢复的 loop_iteration + 1 开始)
|
|
1007
741
|
```
|
|
@@ -1178,44 +912,15 @@ Read("plugins/core/skill-agent-dispatcher/roles-reference.md")
|
|
|
1178
912
|
|
|
1179
913
|
## Execution Report
|
|
1180
914
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
### 报告命名规范
|
|
1184
|
-
|
|
1185
|
-
```
|
|
1186
|
-
docs/reports/{YYYY-MM-DD}_{工作包列表}_execution_report.md
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
### 报告内容模板
|
|
915
|
+
批量执行完成后生成汇总报告到 `docs/reports/{YYYY-MM-DD}_{工作包列表}_execution_report.md`。
|
|
1190
916
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
## 执行总览
|
|
1200
|
-
|
|
1201
|
-
| Task ID | 工作包 | 角色 | 状态 | 依赖 | 说明 |
|
|
1202
|
-
|---------|--------|------|------|------|------|
|
|
1203
|
-
| #1 | WP-073 | godot-scene-expert | ✅ 完成 | - | - |
|
|
1204
|
-
| #2 | WP-074 | godot-script-expert | ✅ 完成 | #1 | - |
|
|
1205
|
-
| #3 | WP-075 | combat-ai-expert | ✅ 完成 | #2 | - |
|
|
1206
|
-
|
|
1207
|
-
## 详细结果
|
|
1208
|
-
(每个 WP 的执行者、子任务完成情况、文件变更)
|
|
1209
|
-
|
|
1210
|
-
## 📁 文件变更汇总
|
|
1211
|
-
新增: X 个 / 修改: Y 个 / 测试: Z 个
|
|
1212
|
-
|
|
1213
|
-
## 💡 新增经验
|
|
1214
|
-
(如有新经验,已写入角色专属库)
|
|
1215
|
-
|
|
1216
|
-
---
|
|
1217
|
-
报告生成时间: {timestamp}
|
|
1218
|
-
```
|
|
917
|
+
模板必备段落:
|
|
918
|
+
1. **基本信息**:批次标签 (team_name) / 执行日期 / 工作包列表
|
|
919
|
+
2. **执行总览**:表格(Task ID / 工作包 / 角色 / 状态 / 依赖 / 说明)
|
|
920
|
+
3. **详细结果**:每个 WP 的执行者、子任务完成情况、文件变更
|
|
921
|
+
4. **文件变更汇总**:新增 / 修改 / 测试计数
|
|
922
|
+
5. **新增经验**:如有新经验,注明已写入角色专属库
|
|
923
|
+
6. 报告生成时间戳
|
|
1219
924
|
|
|
1220
925
|
---
|
|
1221
926
|
|