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.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +42 -0
  3. package/README.md +147 -2
  4. package/bin/commands/build.js +178 -0
  5. package/bin/commands/config.js +88 -0
  6. package/bin/commands/help.js +83 -0
  7. package/bin/commands/init.js +194 -0
  8. package/bin/commands/install.js +202 -0
  9. package/bin/commands/interactive.js +352 -0
  10. package/bin/commands/list.js +108 -0
  11. package/bin/commands/loop-server.js +357 -0
  12. package/bin/commands/loop.js +1443 -0
  13. package/bin/commands/migrate.js +120 -0
  14. package/bin/commands/setup-global.js +81 -0
  15. package/bin/commands/status.js +140 -0
  16. package/bin/commands/team-cleanup.js +190 -0
  17. package/bin/commands/validate-config.js +35 -0
  18. package/bin/commands/validate.js +21 -0
  19. package/bin/commands/version.js +22 -0
  20. package/bin/context.js +143 -0
  21. package/bin/doukui.js +216 -0
  22. package/package.json +47 -4
  23. package/plugins/contracts/capabilities.js +268 -0
  24. package/plugins/contracts/checkresult-schema.json +75 -0
  25. package/plugins/contracts/config-schema.json +179 -0
  26. package/plugins/contracts/plugin-interface.js +262 -0
  27. package/plugins/contracts/plugin-schema.json +104 -0
  28. package/plugins/core/hook-session-start/index.js +281 -0
  29. package/plugins/core/hook-session-start/plugin.json +7 -0
  30. package/plugins/core/hook-skill-gate/index.js +661 -0
  31. package/plugins/core/hook-skill-gate/plugin.json +12 -0
  32. package/plugins/core/provider-loop-engine/index.js +1411 -0
  33. package/plugins/core/provider-loop-engine/plugin.json +15 -0
  34. package/plugins/core/provider-memory-store/index.js +510 -0
  35. package/plugins/core/provider-memory-store/plugin.json +9 -0
  36. package/plugins/core/provider-role-registry/index.js +376 -0
  37. package/plugins/core/provider-role-registry/plugin.json +9 -0
  38. package/plugins/core/provider-state-store/index.js +244 -0
  39. package/plugins/core/provider-state-store/plugin.json +9 -0
  40. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
  41. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
  42. package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
  43. package/plugins/core/provider-watchdog/index.js +151 -0
  44. package/plugins/core/provider-watchdog/plugin.json +13 -0
  45. package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
  46. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
  47. package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
  48. package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
  49. package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
  50. package/plugins/core/skill-agentic-loop/plugin.json +20 -0
  51. package/plugins/core/skill-agentic-loop/skill.md +588 -0
  52. package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
  53. package/plugins/core/skill-batch-task-creator/skill.md +620 -0
  54. package/plugins/core/skill-checklist/plugin.json +10 -0
  55. package/plugins/core/skill-checklist/skill.md +171 -0
  56. package/plugins/core/skill-completion-report/plugin.json +10 -0
  57. package/plugins/core/skill-completion-report/skill.md +331 -0
  58. package/plugins/core/skill-doukui-plan/plugin.json +15 -0
  59. package/plugins/core/skill-doukui-plan/skill.md +233 -0
  60. package/plugins/core/skill-doukui-sync/plugin.json +10 -0
  61. package/plugins/core/skill-doukui-sync/skill.md +76 -0
  62. package/plugins/core/skill-experience-logger/plugin.json +10 -0
  63. package/plugins/core/skill-experience-logger/skill.md +235 -0
  64. package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
  65. package/plugins/core/skill-human-checkpoint/skill.md +194 -0
  66. package/plugins/core/skill-progress-tracker/plugin.json +10 -0
  67. package/plugins/core/skill-progress-tracker/skill.md +228 -0
  68. package/plugins/core/skill-role-manager/plugin.json +10 -0
  69. package/plugins/core/skill-role-manager/skill.md +252 -0
  70. package/plugins/core/skill-split-work-package/plugin.json +15 -0
  71. package/plugins/core/skill-split-work-package/skill.md +441 -0
  72. package/plugins/core/skill-task-archive/plugin.json +10 -0
  73. package/plugins/core/skill-task-archive/skill.md +116 -0
  74. package/plugins/core/skill-task-creator/plugin.json +15 -0
  75. package/plugins/core/skill-task-creator/skill.md +886 -0
  76. package/plugins/core/skill-team-cleanup/plugin.json +10 -0
  77. package/plugins/core/skill-team-cleanup/skill.md +266 -0
  78. package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
  79. package/plugins/core/skill-watchdog-manager/skill.md +143 -0
  80. package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
  81. package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
  82. package/plugins/core/validator-doc-sync/index.js +248 -0
  83. package/plugins/core/validator-doc-sync/plugin.json +12 -0
  84. package/plugins/core/validator-work-package/index.js +300 -0
  85. package/plugins/core/validator-work-package/plugin.json +12 -0
  86. package/plugins/plugin-registry.json +186 -0
  87. package/plugins/runtime/agent-def-generator.js +150 -0
  88. package/plugins/runtime/audit-logger.js +311 -0
  89. package/plugins/runtime/build-cli.js +89 -0
  90. package/plugins/runtime/checkresult-validator.js +131 -0
  91. package/plugins/runtime/claude-md-injector.js +159 -0
  92. package/plugins/runtime/cleanup-utils.js +293 -0
  93. package/plugins/runtime/config-manager.js +317 -0
  94. package/plugins/runtime/config-validator.js +320 -0
  95. package/plugins/runtime/context-window.js +81 -0
  96. package/plugins/runtime/event-bus.js +207 -0
  97. package/plugins/runtime/executor-claude.js +828 -0
  98. package/plugins/runtime/executor-default.js +448 -0
  99. package/plugins/runtime/executor-local.js +178 -0
  100. package/plugins/runtime/executor-sdk.js +415 -0
  101. package/plugins/runtime/harness-build.js +1037 -0
  102. package/plugins/runtime/hook-dispatcher.js +315 -0
  103. package/plugins/runtime/logger.js +192 -0
  104. package/plugins/runtime/loop-actuator.js +292 -0
  105. package/plugins/runtime/loop-coordinator.js +347 -0
  106. package/plugins/runtime/loop-defaults.js +29 -0
  107. package/plugins/runtime/loop-dispatch-batch.js +247 -0
  108. package/plugins/runtime/loop-executor.js +120 -0
  109. package/plugins/runtime/loop-report.js +327 -0
  110. package/plugins/runtime/loop-server-core.js +750 -0
  111. package/plugins/runtime/loop-snapshot.js +581 -0
  112. package/plugins/runtime/loop-trace.js +242 -0
  113. package/plugins/runtime/loop-worktree.js +404 -0
  114. package/plugins/runtime/manifest-resolver.js +457 -0
  115. package/plugins/runtime/multi-window-coordinator.js +560 -0
  116. package/plugins/runtime/objective-verifier.js +136 -0
  117. package/plugins/runtime/plan-lint.js +100 -0
  118. package/plugins/runtime/plan-reader.js +763 -0
  119. package/plugins/runtime/plugin-loader.js +798 -0
  120. package/plugins/runtime/plugin-trust.js +182 -0
  121. package/plugins/runtime/plugin-validator.js +491 -0
  122. package/plugins/runtime/provider-failover.js +114 -0
  123. package/plugins/runtime/provider-resolver.js +342 -0
  124. package/plugins/runtime/reflection-evaluator.js +545 -0
  125. package/plugins/runtime/resolve-plugin-path.js +297 -0
  126. package/plugins/runtime/safe-path.js +119 -0
  127. package/plugins/runtime/sandbox-context.js +235 -0
  128. package/plugins/runtime/sandbox-manager.js +609 -0
  129. package/plugins/runtime/sandbox-worker.js +215 -0
  130. package/plugins/runtime/self-rescue-ladder.js +38 -0
  131. package/plugins/runtime/settings-merger.js +172 -0
  132. package/plugins/runtime/state-store.js +527 -0
  133. package/plugins/runtime/team-cleanup.js +497 -0
  134. package/plugins/runtime/text-tokenize.js +25 -0
  135. package/plugins/runtime/validator-pipeline.js +475 -0
  136. package/plugins/runtime/yaml-parser.js +692 -0
  137. package/templates/harness-config.yaml +394 -0
@@ -0,0 +1,253 @@
1
+ # Agent Dispatcher — 角色赋能与记忆注入参考
2
+
3
+ > 本文档由 `skill-agent-dispatcher` 在 Step 4-5 阶段按需读取,不作为独立 skill 触发。
4
+
5
+ ---
6
+
7
+ ## Step 4: 角色匹配算法
8
+
9
+ ```python
10
+ def match_role(work_package):
11
+ """匹配最合适的角色"""
12
+ scores = {}
13
+
14
+ for role in roles:
15
+ score = 0
16
+ # 关键词匹配 (权重 0.5)
17
+ for keyword in work_package.keywords:
18
+ if keyword in role.keywords:
19
+ score += 0.5
20
+
21
+ # 任务类型匹配 (权重 0.3)
22
+ if work_package.type in role.task_types:
23
+ score += 0.3
24
+
25
+ # 模块标签匹配 (权重 0.2)
26
+ for tag in work_package.tags:
27
+ if tag in role.module_tags:
28
+ score += 0.2
29
+
30
+ scores[role.id] = score
31
+
32
+ return max(scores, key=scores.get)
33
+ ```
34
+
35
+ ### 角色匹配失败回退
36
+
37
+ ```
38
+ ⚠️ 无法自动匹配角色,使用默认 general-purpose
39
+ 工作包: WP-XXX
40
+ 建议手动指定角色
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Step 5: 预计算角色 + 记忆准备
46
+
47
+ **⚠️ 重要**: 角色匹配和记忆注入在监控循环之前完成(预计算),为每个工作包准备好角色 Prompt。
48
+
49
+ ```
50
+ # 预计算所有工作包的角色匹配结果和记忆
51
+
52
+ wp_assignments = {} # {task_id: {role_id, role_prompt, memories, wp_doc_path}}
53
+
54
+ for task in tasks:
55
+ wp = extract_work_package(task)
56
+ role = match_role(wp)
57
+ memories = load_memories(role.id)
58
+ wp_assignments[task.id] = {
59
+ "role_id": role.id,
60
+ "role_prompt": role.prompt_template,
61
+ "memories": memories,
62
+ "wp_doc_path": wp.doc_path
63
+ }
64
+ ```
65
+
66
+ **为什么预计算**:
67
+ - 监控循环中按需创建 Teamee 时,直接使用预计算结果构建 Prompt
68
+ - 避免在监控循环中重复执行角色匹配逻辑
69
+ - 角色匹配算法不变(仍使用 Step 4 中的算法)
70
+
71
+ ---
72
+
73
+ ## 角色赋能系统
74
+
75
+ ### 核心角色(通用框架)
76
+
77
+ | 角色ID | 名称 | 匹配关键词 |
78
+ |--------|------|------------|
79
+ | `coordinator` | 协调者 | 调度、协调、监控、分配、统筹 |
80
+ | `architect` | 架构师 | 架构、设计、结构、模块、接口 |
81
+ | `implementer` | 实现者 | 实现、编码、开发、修复、重构 |
82
+ | `tester` | 测试者 | 测试、验证、检查、单元测试 |
83
+ | `documenter` | 文档编写者 | 文档、说明、注释、README |
84
+
85
+ ### 领域角色(由项目模板扩展)
86
+
87
+ | 角色ID | 名称 | 匹配关键词 |
88
+ |--------|------|------------|
89
+ | `frontend-dev` | 前端开发 | 前端、UI、组件、样式 |
90
+ | `backend-dev` | 后端开发 | 后端、API、服务、数据库 |
91
+ | `devops` | 运维专家 | 部署、CI/CD、Docker、容器 |
92
+ | `godot-scene-expert` | Godot 场景+UI专家 | 场景、节点、tscn、UI(Godot模板)|
93
+
94
+ ### 拆分工作包角色自动匹配
95
+
96
+ | 子工作包类型 | 自动匹配角色 |
97
+ |--------------|--------------|
98
+ | `-impl` | 根据关键词匹配领域专家 |
99
+ | `-test` | test-reviewer |
100
+ | `-verify` | test-reviewer |
101
+ | `-review` | code-reviewer |
102
+
103
+ ### 角色文件位置
104
+
105
+ | 文件类型 | 路径 |
106
+ |----------|------|
107
+ | 角色注册表 | `.claude/agents/role-registry.yaml` |
108
+ | 元角色定义 | `.claude/agents/roles/meta/{role_id}.yaml` |
109
+ | 职能角色定义 | `.claude/agents/roles/functional/{role_id}.yaml` |
110
+ | 领域角色定义 | `.claude/agents/roles/domain/{role_id}.yaml` |
111
+ | 专属经验库 | `.claude/agents/memories/{role_id}.md` |
112
+
113
+ ---
114
+
115
+ ## 记忆注入机制
116
+
117
+ ### 经验提取逻辑
118
+
119
+ 1. **读取角色专属库**:`.claude/agents/memories/{role_id}.md`
120
+ 2. **回退机制**:如专属库不足,读取 `docs/EXPERIENCE.md`
121
+ 3. **按标签过滤**:使用角色的 `experience_tags` 过滤
122
+ 4. **动态数量**:
123
+ - 简单任务(<2h):1-2 条
124
+ - 中等任务(2-4h):3 条
125
+ - 复杂任务(>4h):5 条
126
+
127
+ ---
128
+
129
+ ## 经验沉淀闭环
130
+
131
+ 执行完成后:
132
+
133
+ 1. **分析 Teamee 输出** - 提取新经验
134
+ 2. **写入角色专属库** - `.claude/agents/memories/{role_id}.md`
135
+ 3. **同步到 EXPERIENCE.md** - 去重合并
136
+ 4. **触发 experience-logger** - 记录本次执行的经验
137
+
138
+ ---
139
+
140
+ ## Teamee Prompt 模板
141
+
142
+ 以下模板用于 `build_single_task_prompt()` 函数,在 Step 6 / Step 6.5 创建 Teamee 时使用。
143
+
144
+ ```markdown
145
+ # [角色名称] - 单一任务专用执行
146
+
147
+ ## 你的身份
148
+ {角色 prompt_template}
149
+
150
+ ## 团队信息
151
+ - 批次标签 (team_name): {team_name}(Lead 内部标识,非 harness 团队名)
152
+ - 你的角色: {role_id}
153
+ - 你已自动加入当前 session 的 implicit session team,可与 Lead 及其他 Teamee 通过 SendMessage / 共享 Task List 协作
154
+
155
+ ## 任务绑定 (1:1 专用)
156
+
157
+ **⚠️ 重要:你只负责处理一个任务,不可认领其他任务!**
158
+
159
+ - 分配给你的任务 ID: {task_id}
160
+ - 任务主题: {task_subject}
161
+ - 完成此任务后,你将被立即销毁释放资源
162
+ - **禁止** 认领或执行其他任务
163
+ - 可以调用 TaskList 查看全局进度,但仅限查看,不可对其他任务执行 TaskUpdate
164
+
165
+ ## 📖 首要任务:阅读工作包文档
166
+
167
+ **执行任何任务前,必须先读取工作包文档!**
168
+
169
+ 1. 确认任务后,立即读取任务 description 中指定的工作包文档
170
+ 2. 工作包文档路径格式: `docs/wp/WP-XXX.md` 或 `docs/wp/WP-XXX-N-type.md`
171
+ 3. 从文档中获取: 问题分析/上下文、实施计划 Step 1-N、关键文件列表、验收标准
172
+
173
+ ## 工作流程 (必须严格遵守)
174
+
175
+ ### 1. 确认任务分配
176
+ TaskGet(taskId="{task_id}") — 验证 owner 是你、status 是 pending 或 in_progress
177
+
178
+ ### 2. 开始执行
179
+ - 立即将 status 改为 "in_progress": TaskUpdate(taskId="{task_id}", status="in_progress")
180
+ - 读取工作包文档获取完整上下文
181
+ - 按任务描述执行
182
+ - 完成验收标准
183
+
184
+ ### 3. 完成任务
185
+ TaskUpdate(taskId="{task_id}", status="completed")
186
+
187
+ ### 4. 等待关闭 (🔴 必须响应)
188
+
189
+ **完成任务后,不要查找其他任务!直接等待 Lead 的 shutdown_request。**
190
+
191
+ 当收到 `shutdown_request` 消息时,**必须**发送响应:
192
+
193
+ ```
194
+ SendMessage(
195
+ to="team-lead",
196
+ summary="Shutdown approved, exiting",
197
+ message={
198
+ "type": "shutdown_response",
199
+ "request_id": "{从 shutdown_request 中提取的 request_id}",
200
+ "approve": true
201
+ }
202
+ )
203
+ ```
204
+
205
+ 发送响应后,你的工作结束,可以退出。
206
+
207
+ **⚠️ SendMessage 使用注意**:
208
+ 所有 SendMessage 调用都必须提供 `summary` 参数:
209
+ - 使用 object 类型 message:`summary="...", message={"type": "status_update", ...}`
210
+ - 使用 string message:`summary="...", message="..."`
211
+ - 禁止任何 SendMessage 调用不提供 summary
212
+
213
+ **⚠️ 禁止事项**:
214
+ - 不要认领或执行其他任务(可以查看 TaskList 了解进度,但不可对其他任务执行 TaskUpdate)
215
+ - 不要在完成后继续工作
216
+ - 必须等待 Lead 的 shutdown_request,不要主动退出
217
+
218
+ ## 相关经验(从历史中学习)
219
+
220
+ ### 经验 1: {标题}
221
+ **问题**: {problem}
222
+ **解决方案**: {solution}
223
+
224
+ ## 输出要求
225
+ 1. 修改/新增的文件清单
226
+ 2. 验收标准完成情况
227
+ 3. 遇到的问题和解决方案
228
+ 4. **如有新经验,请按以下格式总结**:
229
+ ```
230
+ ### [标签] 经验标题
231
+ **问题**: ...
232
+ **解决方案**: ...
233
+ ```
234
+
235
+ ## 任务完成后必须执行 (Critical!)
236
+
237
+ ### 状态同步 (不可跳过)
238
+ 完成工作包后,你必须更新以下文档:
239
+
240
+ 1. **更新 task.md**: 将工作包状态改为 `✅ 完成`,添加到"最近完成"列表
241
+ 2. **更新 docs/wp/WP-XXX.md** (如存在): 更新状态为 ✅ 完成,添加完成日期
242
+ 3. **验证同步**: 重新读取 task.md 确认状态已更新
243
+
244
+ ⚠️ 如果不执行状态同步,工作包将被视为未完成!
245
+
246
+ ## 重要提醒
247
+ - **你只处理一个任务** — 完成后等待 shutdown,不要查找其他任务
248
+ - 完成后必须执行测试验证
249
+ - 如遇阻塞问题,在任务描述中说明阻塞原因
250
+ - 不要跳过任何验收标准
251
+ - 任务完成后立即更新状态为 completed,方便 Lead 检测并解锁依赖任务
252
+ - 收到 shutdown_request 后立即响应,不要延迟
253
+ ```