doukui 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.en.md +42 -0
- package/README.md +147 -2
- package/bin/commands/build.js +178 -0
- package/bin/commands/config.js +88 -0
- package/bin/commands/help.js +83 -0
- package/bin/commands/init.js +194 -0
- package/bin/commands/install.js +202 -0
- package/bin/commands/interactive.js +352 -0
- package/bin/commands/list.js +108 -0
- package/bin/commands/loop-server.js +357 -0
- package/bin/commands/loop.js +1443 -0
- package/bin/commands/migrate.js +120 -0
- package/bin/commands/setup-global.js +81 -0
- package/bin/commands/status.js +140 -0
- package/bin/commands/team-cleanup.js +190 -0
- package/bin/commands/validate-config.js +35 -0
- package/bin/commands/validate.js +21 -0
- package/bin/commands/version.js +22 -0
- package/bin/context.js +143 -0
- package/bin/doukui.js +216 -0
- package/package.json +47 -4
- package/plugins/contracts/capabilities.js +268 -0
- package/plugins/contracts/checkresult-schema.json +75 -0
- package/plugins/contracts/config-schema.json +179 -0
- package/plugins/contracts/plugin-interface.js +262 -0
- package/plugins/contracts/plugin-schema.json +104 -0
- package/plugins/core/hook-session-start/index.js +281 -0
- package/plugins/core/hook-session-start/plugin.json +7 -0
- package/plugins/core/hook-skill-gate/index.js +661 -0
- package/plugins/core/hook-skill-gate/plugin.json +12 -0
- package/plugins/core/provider-loop-engine/index.js +1411 -0
- package/plugins/core/provider-loop-engine/plugin.json +15 -0
- package/plugins/core/provider-memory-store/index.js +510 -0
- package/plugins/core/provider-memory-store/plugin.json +9 -0
- package/plugins/core/provider-role-registry/index.js +376 -0
- package/plugins/core/provider-role-registry/plugin.json +9 -0
- package/plugins/core/provider-state-store/index.js +244 -0
- package/plugins/core/provider-state-store/plugin.json +9 -0
- package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
- package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
- package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
- package/plugins/core/provider-watchdog/index.js +151 -0
- package/plugins/core/provider-watchdog/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
- package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
- package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
- package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
- package/plugins/core/skill-agentic-loop/plugin.json +20 -0
- package/plugins/core/skill-agentic-loop/skill.md +588 -0
- package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
- package/plugins/core/skill-batch-task-creator/skill.md +620 -0
- package/plugins/core/skill-checklist/plugin.json +10 -0
- package/plugins/core/skill-checklist/skill.md +171 -0
- package/plugins/core/skill-completion-report/plugin.json +10 -0
- package/plugins/core/skill-completion-report/skill.md +331 -0
- package/plugins/core/skill-doukui-plan/plugin.json +15 -0
- package/plugins/core/skill-doukui-plan/skill.md +233 -0
- package/plugins/core/skill-doukui-sync/plugin.json +10 -0
- package/plugins/core/skill-doukui-sync/skill.md +76 -0
- package/plugins/core/skill-experience-logger/plugin.json +10 -0
- package/plugins/core/skill-experience-logger/skill.md +235 -0
- package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
- package/plugins/core/skill-human-checkpoint/skill.md +194 -0
- package/plugins/core/skill-progress-tracker/plugin.json +10 -0
- package/plugins/core/skill-progress-tracker/skill.md +228 -0
- package/plugins/core/skill-role-manager/plugin.json +10 -0
- package/plugins/core/skill-role-manager/skill.md +252 -0
- package/plugins/core/skill-split-work-package/plugin.json +15 -0
- package/plugins/core/skill-split-work-package/skill.md +441 -0
- package/plugins/core/skill-task-archive/plugin.json +10 -0
- package/plugins/core/skill-task-archive/skill.md +116 -0
- package/plugins/core/skill-task-creator/plugin.json +15 -0
- package/plugins/core/skill-task-creator/skill.md +886 -0
- package/plugins/core/skill-team-cleanup/plugin.json +10 -0
- package/plugins/core/skill-team-cleanup/skill.md +266 -0
- package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
- package/plugins/core/skill-watchdog-manager/skill.md +143 -0
- package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
- package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
- package/plugins/core/validator-doc-sync/index.js +248 -0
- package/plugins/core/validator-doc-sync/plugin.json +12 -0
- package/plugins/core/validator-work-package/index.js +300 -0
- package/plugins/core/validator-work-package/plugin.json +12 -0
- package/plugins/plugin-registry.json +186 -0
- package/plugins/runtime/agent-def-generator.js +150 -0
- package/plugins/runtime/audit-logger.js +311 -0
- package/plugins/runtime/build-cli.js +89 -0
- package/plugins/runtime/checkresult-validator.js +131 -0
- package/plugins/runtime/claude-md-injector.js +159 -0
- package/plugins/runtime/cleanup-utils.js +293 -0
- package/plugins/runtime/config-manager.js +317 -0
- package/plugins/runtime/config-validator.js +320 -0
- package/plugins/runtime/context-window.js +81 -0
- package/plugins/runtime/event-bus.js +207 -0
- package/plugins/runtime/executor-claude.js +828 -0
- package/plugins/runtime/executor-default.js +448 -0
- package/plugins/runtime/executor-local.js +178 -0
- package/plugins/runtime/executor-sdk.js +415 -0
- package/plugins/runtime/harness-build.js +1037 -0
- package/plugins/runtime/hook-dispatcher.js +315 -0
- package/plugins/runtime/logger.js +192 -0
- package/plugins/runtime/loop-actuator.js +292 -0
- package/plugins/runtime/loop-coordinator.js +347 -0
- package/plugins/runtime/loop-defaults.js +29 -0
- package/plugins/runtime/loop-dispatch-batch.js +247 -0
- package/plugins/runtime/loop-executor.js +120 -0
- package/plugins/runtime/loop-report.js +327 -0
- package/plugins/runtime/loop-server-core.js +750 -0
- package/plugins/runtime/loop-snapshot.js +581 -0
- package/plugins/runtime/loop-trace.js +242 -0
- package/plugins/runtime/loop-worktree.js +404 -0
- package/plugins/runtime/manifest-resolver.js +457 -0
- package/plugins/runtime/multi-window-coordinator.js +560 -0
- package/plugins/runtime/objective-verifier.js +136 -0
- package/plugins/runtime/plan-lint.js +100 -0
- package/plugins/runtime/plan-reader.js +763 -0
- package/plugins/runtime/plugin-loader.js +798 -0
- package/plugins/runtime/plugin-trust.js +182 -0
- package/plugins/runtime/plugin-validator.js +491 -0
- package/plugins/runtime/provider-failover.js +114 -0
- package/plugins/runtime/provider-resolver.js +342 -0
- package/plugins/runtime/reflection-evaluator.js +545 -0
- package/plugins/runtime/resolve-plugin-path.js +297 -0
- package/plugins/runtime/safe-path.js +119 -0
- package/plugins/runtime/sandbox-context.js +235 -0
- package/plugins/runtime/sandbox-manager.js +609 -0
- package/plugins/runtime/sandbox-worker.js +215 -0
- package/plugins/runtime/self-rescue-ladder.js +38 -0
- package/plugins/runtime/settings-merger.js +172 -0
- package/plugins/runtime/state-store.js +527 -0
- package/plugins/runtime/team-cleanup.js +497 -0
- package/plugins/runtime/text-tokenize.js +25 -0
- package/plugins/runtime/validator-pipeline.js +475 -0
- package/plugins/runtime/yaml-parser.js +692 -0
- package/templates/harness-config.yaml +394 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skill-team-cleanup",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "skill",
|
|
5
|
+
"description": "Manual cleanup tool for orphaned agent teams. Use when user says \"清理团队\", \"清理残留\", \"删除过期团队\", or needs to remove accumulated team/task directories.",
|
|
6
|
+
"triggers": ["清理团队", "清理残留", "删除过期团队", "清理 teams 目录", "清理 agent teams", "cleanup team", "cleanup orphaned teams"],
|
|
7
|
+
"dependencies": [],
|
|
8
|
+
"provides": ["skill:team-cleanup"],
|
|
9
|
+
"config": {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-team-cleanup
|
|
3
|
+
description: "Manual cleanup tool for orphaned agent teams. Use when user says \"清理团队\", \"清理残留\", \"删除过期团队\", or needs to remove accumulated team/task directories."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Team Cleanup
|
|
7
|
+
|
|
8
|
+
手动清理残留团队目录(历史显式命名/UUID 团队)的工具。当前 session 的 implicit team 随 session 自动清理,本工具主要用于清理旧 harness 时期遗留的团队目录。
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
**触发词**:
|
|
13
|
+
- "清理团队" / "清理残留"
|
|
14
|
+
- "清理 teams 目录"
|
|
15
|
+
- "删除过期团队"
|
|
16
|
+
- "清理 agent teams"
|
|
17
|
+
|
|
18
|
+
## Problem
|
|
19
|
+
|
|
20
|
+
当 agent-dispatcher 的自动清理失败时,会留下残留的团队目录:
|
|
21
|
+
- `~/.claude/teams/{team_name}/` - 团队配置和成员信息
|
|
22
|
+
- `~/.claude/tasks/{session_id}/` - 任务列表数据
|
|
23
|
+
|
|
24
|
+
这些残留会:
|
|
25
|
+
- 占用磁盘空间
|
|
26
|
+
- 混淆活跃团队和历史团队
|
|
27
|
+
- 影响后续批量执行的调试
|
|
28
|
+
|
|
29
|
+
## Flow
|
|
30
|
+
|
|
31
|
+
```dot
|
|
32
|
+
digraph cleanup {
|
|
33
|
+
rankdir=TB;
|
|
34
|
+
|
|
35
|
+
"扫描 teams 目录" [shape=box];
|
|
36
|
+
"扫描 tasks 目录" [shape=box];
|
|
37
|
+
"识别残留团队" [shape=box];
|
|
38
|
+
"列出清理清单" [shape=box];
|
|
39
|
+
"用户确认" [shape=diamond];
|
|
40
|
+
"批量删除" [shape=box, style=filled, fillcolor=orange];
|
|
41
|
+
"验证清理结果" [shape=box];
|
|
42
|
+
"生成清理报告" [shape=box, style=filled, fillcolor=lightgreen];
|
|
43
|
+
|
|
44
|
+
"扫描 teams 目录" -> "识别残留团队";
|
|
45
|
+
"扫描 tasks 目录" -> "识别残留团队";
|
|
46
|
+
"识别残留团队" -> "列出清理清单";
|
|
47
|
+
"列出清理清单" -> "用户确认";
|
|
48
|
+
"用户确认" -> "批量删除" [label="确认"];
|
|
49
|
+
"用户确认" -> "取消" [label="取消"];
|
|
50
|
+
"批量删除" -> "验证清理结果";
|
|
51
|
+
"验证清理结果" -> "生成清理报告";
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Step-by-Step Implementation
|
|
58
|
+
|
|
59
|
+
### Step 1: 扫描残留资源
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# 扫描 teams 目录
|
|
63
|
+
teams_dir = "~/.claude/teams/"
|
|
64
|
+
tasks_dir = "~/.claude/tasks/"
|
|
65
|
+
|
|
66
|
+
orphaned_teams = []
|
|
67
|
+
orphaned_tasks = []
|
|
68
|
+
|
|
69
|
+
# 扫描 teams 目录
|
|
70
|
+
for team in list_directory(teams_dir):
|
|
71
|
+
# 检查是否有活跃会话(通过检查 config.json 中的会话信息)
|
|
72
|
+
config = Read(f"{teams_dir}/{team}/config.json")
|
|
73
|
+
if not is_active_session(config):
|
|
74
|
+
orphaned_teams.append({
|
|
75
|
+
"name": team,
|
|
76
|
+
"path": f"{teams_dir}/{team}",
|
|
77
|
+
"created": config.createdAt,
|
|
78
|
+
"members": len(config.members)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
# 扫描 tasks 目录
|
|
82
|
+
for task_dir in list_directory(tasks_dir):
|
|
83
|
+
# 检查是否有对应的活跃 teams
|
|
84
|
+
if not has_active_team(task_dir):
|
|
85
|
+
orphaned_tasks.append({
|
|
86
|
+
"name": task_dir,
|
|
87
|
+
"path": f"{tasks_dir}/{task_dir}"
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Step 2: 列出清理清单
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
帅哥,发现以下残留团队资源:
|
|
95
|
+
|
|
96
|
+
## 📁 Teams 目录 ({count} 个)
|
|
97
|
+
|
|
98
|
+
| 团队名称 | 类型 | 创建时间 | 成员数 |
|
|
99
|
+
|----------|------|----------|--------|
|
|
100
|
+
| batch-20260314-WP073-075 | 批量执行 | 2026-03-14 | 2 |
|
|
101
|
+
| batch-20260315-WP085-087 | 批量执行 | 2026-03-15 | 3 |
|
|
102
|
+
| ... | ... | ... | ... |
|
|
103
|
+
|
|
104
|
+
## 📁 Tasks 目录 ({count} 个)
|
|
105
|
+
|
|
106
|
+
| 目录名称 | 大小 |
|
|
107
|
+
|----------|------|
|
|
108
|
+
| 00e3fa6c-9282-... | 12KB |
|
|
109
|
+
| 02a9b203-e378-... | 8KB |
|
|
110
|
+
| ... | ... | ... |
|
|
111
|
+
|
|
112
|
+
## 📊 统计
|
|
113
|
+
- **Teams 目录总数**: X 个
|
|
114
|
+
- **Tasks 目录总数**: Y 个
|
|
115
|
+
- **预估释放空间**: Z MB
|
|
116
|
+
|
|
117
|
+
🔴 是否清理这些资源?(回复 "确认清理" 继续,或指定要保留的团队)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Step 3: 执行清理
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# 用户确认后执行
|
|
124
|
+
|
|
125
|
+
cleaned_teams = 0
|
|
126
|
+
cleaned_tasks = 0
|
|
127
|
+
errors = []
|
|
128
|
+
|
|
129
|
+
# 清理 teams 目录
|
|
130
|
+
for team in orphaned_teams:
|
|
131
|
+
try:
|
|
132
|
+
delete_directory(team.path)
|
|
133
|
+
cleaned_teams += 1
|
|
134
|
+
log(f"✅ 已清理团队: {team.name}")
|
|
135
|
+
except Exception as e:
|
|
136
|
+
errors.append(f"❌ 清理失败 {team.name}: {e}")
|
|
137
|
+
|
|
138
|
+
# 清理 tasks 目录
|
|
139
|
+
for task in orphaned_tasks:
|
|
140
|
+
try:
|
|
141
|
+
delete_directory(task.path)
|
|
142
|
+
cleaned_tasks += 1
|
|
143
|
+
except Exception as e:
|
|
144
|
+
errors.append(f"❌ 清理失败 {task.name}: {e}")
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Step 4: 生成清理报告
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
## 🧹 清理报告
|
|
151
|
+
|
|
152
|
+
**清理时间**: YYYY-MM-DD HH:mm
|
|
153
|
+
**清理操作**: Teams + Tasks 目录
|
|
154
|
+
|
|
155
|
+
### Teams 目录
|
|
156
|
+
| 团队名称 | 状态 |
|
|
157
|
+
|----------|------|
|
|
158
|
+
| batch-20260314-WP073-075 | ✅ 已删除 |
|
|
159
|
+
| batch-20260315-WP085-087 | ✅ 已删除 |
|
|
160
|
+
| ... | ... |
|
|
161
|
+
|
|
162
|
+
**总计**: {cleaned_teams}/{total_teams} 个已清理
|
|
163
|
+
|
|
164
|
+
### Tasks 目录
|
|
165
|
+
**总计**: {cleaned_tasks}/{total_tasks} 个已清理
|
|
166
|
+
|
|
167
|
+
### 释放空间
|
|
168
|
+
约 {freed_space} MB
|
|
169
|
+
|
|
170
|
+
### 错误 (如有)
|
|
171
|
+
{errors}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Safety Checks
|
|
177
|
+
|
|
178
|
+
### 保留条件
|
|
179
|
+
|
|
180
|
+
以下团队**不会被清理**:
|
|
181
|
+
1. 当前活跃的团队(有正在运行的会话)
|
|
182
|
+
2. 用户明确指定保留的团队
|
|
183
|
+
3. 创建时间在 1 小时内的团队(可能正在初始化)
|
|
184
|
+
|
|
185
|
+
### 确认机制
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
⚠️ 清理前必须用户确认!
|
|
189
|
+
|
|
190
|
+
- 列出所有待清理项
|
|
191
|
+
- 显示预估释放空间
|
|
192
|
+
- 用户必须输入 "确认清理" 或选择保留项
|
|
193
|
+
- 不支持自动清理(防止误删)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Integration with Other Skills
|
|
199
|
+
|
|
200
|
+
| Skill | 集成点 |
|
|
201
|
+
|-------|--------|
|
|
202
|
+
| `agent-dispatcher` | 自动清理失败时建议使用本 skill |
|
|
203
|
+
| `completion-report` | 报告中检测到未清理时建议使用 |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Example Usage
|
|
208
|
+
|
|
209
|
+
### 场景 1: 常规清理
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
用户: 清理团队
|
|
213
|
+
|
|
214
|
+
AI:
|
|
215
|
+
帅哥,发现以下残留团队资源:
|
|
216
|
+
[列出清单]
|
|
217
|
+
是否清理?
|
|
218
|
+
|
|
219
|
+
用户: 确认清理
|
|
220
|
+
|
|
221
|
+
AI:
|
|
222
|
+
[执行清理]
|
|
223
|
+
[生成报告]
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 场景 2: 选择性保留
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
用户: 清理团队,但保留 batch-20260321-wp145
|
|
230
|
+
|
|
231
|
+
AI:
|
|
232
|
+
[排除 batch-20260321-wp145]
|
|
233
|
+
[清理其他]
|
|
234
|
+
[生成报告]
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Important
|
|
240
|
+
|
|
241
|
+
1. **清理前必须用户确认** - 不支持自动清理
|
|
242
|
+
2. **保护活跃团队** - 不清理正在使用的团队
|
|
243
|
+
3. **保护新创建团队** - 1 小时内创建的不清理
|
|
244
|
+
4. **记录清理日志** - 便于追踪和恢复
|
|
245
|
+
5. **错误不中断** - 单个失败不影响其他清理
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Diagnostic Commands
|
|
250
|
+
|
|
251
|
+
检查当前残留情况:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# 查看 teams 目录数量
|
|
255
|
+
ls ~/.claude/teams/ | wc -l
|
|
256
|
+
|
|
257
|
+
# 查看 tasks 目录数量
|
|
258
|
+
ls ~/.claude/tasks/ | wc -l
|
|
259
|
+
|
|
260
|
+
# 查看最近创建的团队
|
|
261
|
+
ls -lt ~/.claude/teams/ | head -5
|
|
262
|
+
|
|
263
|
+
# 查看磁盘占用
|
|
264
|
+
du -sh ~/.claude/teams/
|
|
265
|
+
du -sh ~/.claude/tasks/
|
|
266
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skill-watchdog-manager",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "skill",
|
|
5
|
+
"description": "Use when user says \"启动守护进程\", \"watchdog\", \"守护进程状态\", or needs to manage the Watchdog daemon for agent-dispatcher monitoring.",
|
|
6
|
+
"triggers": ["启动守护进程", "watchdog", "守护进程状态", "停止守护进程", "watchdog status", "watchdog start", "watchdog stop"],
|
|
7
|
+
"dependencies": ["provider:watchdog"],
|
|
8
|
+
"provides": ["skill:watchdog-manager"],
|
|
9
|
+
"config": {}
|
|
10
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-watchdog-manager
|
|
3
|
+
description: "Use when user says \"启动守护进程\", \"watchdog\", \"守护进程状态\", or needs to manage the Watchdog daemon for agent-dispatcher monitoring."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Watchdog Manager
|
|
7
|
+
|
|
8
|
+
Watchdog 守护进程管理技能,用于启动/停止/查看守护进程状态,与 agent-dispatcher 配合使用。
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
**触发词**:
|
|
13
|
+
- "启动守护进程" / "开启 watchdog"
|
|
14
|
+
- "停止守护进程" / "关闭 watchdog"
|
|
15
|
+
- "守护进程状态" / "watchdog 状态"
|
|
16
|
+
- "watchdog" / "watchdog start" / "watchdog stop"
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
Watchdog 必须已部署到项目中。检查条件:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
# 检查 watchdog 是否已部署
|
|
24
|
+
file_exists = Bash(command="test -f .claude/watchdog/watchdog.js && echo 'exists' || echo 'not_found'")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**如果文件不存在**:说明 watchdog provider 未启用。告知用户需要在 `plugins/plugin-registry.json` 中启用 `provider-watchdog` 后重新执行 `node bin/doukui.js build`。
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
### 初始化(首次使用)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node .claude/watchdog/watchdog.js init
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
创建 `.claude-daemon/` 目录和默认配置文件。
|
|
38
|
+
|
|
39
|
+
### 启动守护进程
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 前台模式(调试用)
|
|
43
|
+
node .claude/watchdog/watchdog.js start --foreground
|
|
44
|
+
|
|
45
|
+
# 后台模式(生产用,默认)
|
|
46
|
+
node .claude/watchdog/watchdog.js start
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 查看状态
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
node .claude/watchdog/watchdog.js status
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
输出包括:PID、运行模式、健康状态、会话信息、任务列表、重启历史、熔断状态。
|
|
56
|
+
|
|
57
|
+
### 手动重启任务
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node .claude/watchdog/watchdog.js restart --task <task_id>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 暂停/恢复检测
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 暂停
|
|
67
|
+
node .claude/watchdog/watchdog.js pause
|
|
68
|
+
|
|
69
|
+
# 恢复
|
|
70
|
+
node .claude/watchdog/watchdog.js pause --resume
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 停止守护进程
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
node .claude/watchdog/watchdog.js stop
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Workflow Integration
|
|
80
|
+
|
|
81
|
+
### 与 agent-dispatcher 配合
|
|
82
|
+
|
|
83
|
+
Watchdog 通过文件系统与 agent-dispatcher 通信:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
agent-dispatcher 写入 → .claude-daemon/heartbeat.json ← watchdog 读取
|
|
87
|
+
agent-dispatcher 写入 → .claude-daemon/tasks/task-{id}.json ← watchdog 读取
|
|
88
|
+
watchdog 写入 → .claude-daemon/daemon-actions.json ← agent-dispatcher 读取
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**推荐工作流**:
|
|
92
|
+
|
|
93
|
+
1. 用户发出"批量执行"请求 → agent-dispatcher skill 被触发
|
|
94
|
+
2. agent-dispatcher 开始监控循环,自动写入心跳和任务文件(DISP-001/002)
|
|
95
|
+
3. watchdog 独立运行,检测卡死任务并下发 restart/abort 指令(DISP-003)
|
|
96
|
+
4. 任务完成后 watchdog 自动检测并退出
|
|
97
|
+
|
|
98
|
+
**启动时序**:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
# 终端 1:先启动 watchdog
|
|
102
|
+
node .claude/watchdog/watchdog.js start
|
|
103
|
+
|
|
104
|
+
# 终端 2:再启动 agent-dispatcher 批量任务
|
|
105
|
+
# (agent-dispatcher 会自动写入心跳和任务文件)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Architecture Reference
|
|
109
|
+
|
|
110
|
+
### 三级检测
|
|
111
|
+
|
|
112
|
+
| 等级 | 检测目标 | 判定条件 | 动作 |
|
|
113
|
+
|------|----------|----------|------|
|
|
114
|
+
| L1 任务级 | 单个 Teamee | task-{id}.json 无更新且无新 progress_markers | restart 指令 |
|
|
115
|
+
| L2 会话级 | Team Lead | heartbeat.json 无更新 | 检查 OS 进程 |
|
|
116
|
+
| L3 进程级 | Claude Code CLI | OS 进程 PID 不存在 | abort_all 指令 |
|
|
117
|
+
|
|
118
|
+
### 四层防御
|
|
119
|
+
|
|
120
|
+
1. retry_count 计数器(max_retries: 3)
|
|
121
|
+
2. 动作消费确认(防止重复下发)
|
|
122
|
+
3. 指数退避(冷却: 0/2/5 分钟)
|
|
123
|
+
4. 全局熔断(连续 3 次失败触发)
|
|
124
|
+
|
|
125
|
+
### 重启策略
|
|
126
|
+
|
|
127
|
+
- `full_restart`:complexity_score <= 6 的简单任务
|
|
128
|
+
- `checkpoint_resume`:complexity_score > 6 的复杂任务,注入已完成文件上下文
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
配置文件:`.claude-daemon/daemon-config.json`
|
|
133
|
+
|
|
134
|
+
关键配置项:
|
|
135
|
+
- `check_interval_sec`: 守护进程轮询间隔(默认 30 秒)
|
|
136
|
+
- `timeouts.task_stalled_min`: 单任务无进展超时(默认 15 分钟)
|
|
137
|
+
- `retry.max_retries`: 单任务最大重试次数(默认 3)
|
|
138
|
+
|
|
139
|
+
## Error Handling
|
|
140
|
+
|
|
141
|
+
- **守护进程启动失败**:检查 `.claude-daemon/daemon-stdout.log` 和 `daemon-stderr.log`
|
|
142
|
+
- **任务反复重启**:查看熔断状态,可能需要调整 `timeouts.task_stalled_min` 或 `retry.max_retries`
|
|
143
|
+
- **进程检测不准**:Windows 上使用 `tasklist`,Unix 上使用 `kill -0`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skill-workflow-orchestrator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "skill",
|
|
5
|
+
"description": "Use when user says \"开始工作流\", \"执行完整流程\", or needs to run the full development workflow from requirements to completion with automatic checkpoint management.",
|
|
6
|
+
"triggers": ["开始工作流", "执行完整流程", "workflow-orchestrator", "start workflow", "execute workflow"],
|
|
7
|
+
"dependencies": ["provider:state-store"],
|
|
8
|
+
"provides": ["skill:workflow-orchestrator"],
|
|
9
|
+
"metadata": {
|
|
10
|
+
"gatedByCode": true
|
|
11
|
+
},
|
|
12
|
+
"config": {}
|
|
13
|
+
}
|