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,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validator-work-package - 工作包文档验证器
|
|
3
|
+
*
|
|
4
|
+
* 检测 WP 文档结构缺陷和依赖有效性:
|
|
5
|
+
* - 验证必要章节(目标、验收标准、关键文件)
|
|
6
|
+
* - 验证依赖关系引用的 WP 是否存在
|
|
7
|
+
* - validate(wpPath) 验证单个 WP 文档
|
|
8
|
+
* - validateAll() 验证所有 WP 文档
|
|
9
|
+
*
|
|
10
|
+
* 使用方式:
|
|
11
|
+
* var Validator = require('./index.js');
|
|
12
|
+
* var v = new Validator({ projectRoot: '/path/to/project' });
|
|
13
|
+
* var result = v.validate('/path/to/WP-001.md');
|
|
14
|
+
* var allResult = v.validateAll();
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
var fs = require('fs');
|
|
20
|
+
var path = require('path');
|
|
21
|
+
var { ValidatorPlugin } = require('../../contracts/plugin-interface');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* WP 文档必要章节定义
|
|
25
|
+
* 每个 WP 文档应包含这些章节标题(二级标题 ## 或更高级别)
|
|
26
|
+
*/
|
|
27
|
+
var REQUIRED_SECTIONS = [
|
|
28
|
+
{ id: 'goal', patterns: [/^#{1,6}\s*目标/m, /^#{1,6}\s*Goal/im] },
|
|
29
|
+
{ id: 'acceptance', patterns: [/^#{1,6}\s*验收标准/m, /^#{1,6}\s*Acceptance/im] },
|
|
30
|
+
{ id: 'keyfiles', patterns: [/^#{1,6}\s*关键文件/m, /^#{1,6}\s*Key\s*Files/im] },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 依赖关系提取正则
|
|
35
|
+
* 匹配 "依赖: WP-001, WP-002" 或 "依赖: 无" 或 "Dependencies: ..."
|
|
36
|
+
*/
|
|
37
|
+
var DEPS_LINE_RE = /^>\s*依赖[::]\s*(.+)$/m;
|
|
38
|
+
var DEPS_LINE_ALT_RE = /^\*?\*?依赖\*?\*?[::]\s*(.+)$/m;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* WP ID 提取正则
|
|
42
|
+
*/
|
|
43
|
+
var WP_ID_RE = /WP-\d+/gi;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* WorkPackageValidator
|
|
47
|
+
*/
|
|
48
|
+
class WorkPackageValidator extends ValidatorPlugin {
|
|
49
|
+
/**
|
|
50
|
+
* @param {object} [options]
|
|
51
|
+
* @param {string} [options.projectRoot] - 项目根目录,默认 process.cwd()
|
|
52
|
+
*/
|
|
53
|
+
constructor(options) {
|
|
54
|
+
super();
|
|
55
|
+
options = options || {};
|
|
56
|
+
|
|
57
|
+
this.name = 'validator-work-package';
|
|
58
|
+
this.version = '1.0.0';
|
|
59
|
+
this.description = '工作包文档验证器';
|
|
60
|
+
this.blocking = false;
|
|
61
|
+
|
|
62
|
+
/** @type {string} */
|
|
63
|
+
this._projectRoot = options.projectRoot || process.cwd();
|
|
64
|
+
/** @type {string} */
|
|
65
|
+
this._docsWpDir = path.join(this._projectRoot, 'docs', 'wp');
|
|
66
|
+
/** @type {string|null} */
|
|
67
|
+
this._taskMdPath = path.join(this._projectRoot, 'task.md');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 获取所有已知 WP ID(从 docs/wp/ 目录和 task.md 收集)
|
|
72
|
+
* @returns {Set<string>}
|
|
73
|
+
*/
|
|
74
|
+
_getKnownWpIds() {
|
|
75
|
+
var ids = new Set();
|
|
76
|
+
|
|
77
|
+
// 从 docs/wp/ 目录
|
|
78
|
+
var files = this._readdir(this._docsWpDir);
|
|
79
|
+
for (var i = 0; i < files.length; i++) {
|
|
80
|
+
var match = /^(WP-\d+)\.md$/i.exec(files[i]);
|
|
81
|
+
if (match) {
|
|
82
|
+
ids.add(match[1].toUpperCase());
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return ids;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 从 WP 文档内容中提取依赖的 WP ID
|
|
91
|
+
* @param {string} content
|
|
92
|
+
* @returns {string[]}
|
|
93
|
+
*/
|
|
94
|
+
_extractDependencies(content) {
|
|
95
|
+
var deps = [];
|
|
96
|
+
|
|
97
|
+
// 尝试匹配依赖行
|
|
98
|
+
var match = DEPS_LINE_RE.exec(content) || DEPS_LINE_ALT_RE.exec(content);
|
|
99
|
+
if (match) {
|
|
100
|
+
var depStr = match[1].trim();
|
|
101
|
+
if (depStr === '无' || depStr === '-' || depStr === 'none') {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var ids = depStr.match(WP_ID_RE);
|
|
106
|
+
if (ids) {
|
|
107
|
+
for (var i = 0; i < ids.length; i++) {
|
|
108
|
+
deps.push(ids[i].toUpperCase());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 也检查依赖图或表格中的引用(mermaid 语法)
|
|
114
|
+
var mermaidBlock = /```mermaid[\s\S]*?```/g.exec(content);
|
|
115
|
+
if (mermaidBlock) {
|
|
116
|
+
var mermaidDeps = mermaidBlock[0].match(/WP-\d+/gi);
|
|
117
|
+
if (mermaidDeps) {
|
|
118
|
+
for (var j = 0; j < mermaidDeps.length; j++) {
|
|
119
|
+
var id = mermaidDeps[j].toUpperCase();
|
|
120
|
+
if (deps.indexOf(id) === -1) {
|
|
121
|
+
deps.push(id);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return deps;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 检查文档中是否包含指定章节
|
|
132
|
+
* @param {string} content
|
|
133
|
+
* @param {{ id: string, patterns: RegExp[] }} section
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
_hasSection(content, section) {
|
|
137
|
+
for (var i = 0; i < section.patterns.length; i++) {
|
|
138
|
+
if (section.patterns[i].test(content)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 验证单个 WP 文档
|
|
147
|
+
* @param {string} wpPath - WP 文档的完整路径,或 WP ID (如 "WP-001")
|
|
148
|
+
* @param {object} [context] - 验证上下文(保留兼容接口)
|
|
149
|
+
* @returns {{ valid: boolean, errors: string[], warnings: string[] }}
|
|
150
|
+
*/
|
|
151
|
+
validate(wpPath, context) {
|
|
152
|
+
var errors = [];
|
|
153
|
+
var warnings = [];
|
|
154
|
+
|
|
155
|
+
// 支持 WP ID 简写
|
|
156
|
+
var filePath = wpPath;
|
|
157
|
+
if (/^WP-\d+$/i.test(wpPath)) {
|
|
158
|
+
filePath = path.join(this._docsWpDir, wpPath.toUpperCase() + '.md');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var wpId = path.basename(filePath, '.md').toUpperCase();
|
|
162
|
+
var content = this._readFile(filePath);
|
|
163
|
+
|
|
164
|
+
if (content === null) {
|
|
165
|
+
errors.push(wpId + ' 文档文件不存在或无法读取: ' + filePath);
|
|
166
|
+
return { valid: false, errors: errors, warnings: warnings };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 1. 检查必要章节
|
|
170
|
+
for (var i = 0; i < REQUIRED_SECTIONS.length; i++) {
|
|
171
|
+
var section = REQUIRED_SECTIONS[i];
|
|
172
|
+
if (!this._hasSection(content, section)) {
|
|
173
|
+
errors.push(wpId + ' 缺少必要章节: ' + section.id);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 2. 检查依赖关系有效性
|
|
178
|
+
var deps = this._extractDependencies(content);
|
|
179
|
+
if (deps.length > 0) {
|
|
180
|
+
var knownIds = this._getKnownWpIds();
|
|
181
|
+
|
|
182
|
+
for (var j = 0; j < deps.length; j++) {
|
|
183
|
+
// 跳过自引用
|
|
184
|
+
if (deps[j] === wpId) {
|
|
185
|
+
warnings.push(wpId + ' 依赖关系中包含自引用');
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (!knownIds.has(deps[j])) {
|
|
189
|
+
errors.push(wpId + ' 引用了不存在的依赖: ' + deps[j]);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// 3. 额外结构检查
|
|
195
|
+
|
|
196
|
+
// 检查是否有预估时间
|
|
197
|
+
if (!/预估时间|Estimated\s*Time/i.test(content)) {
|
|
198
|
+
warnings.push(wpId + ' 缺少预估时间章节');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// 检查验收标准是否有复选框条目
|
|
202
|
+
if (/验收标准/.test(content)) {
|
|
203
|
+
var acceptanceSection = content.split(/#{1,6}\s*验收标准/)[1];
|
|
204
|
+
if (acceptanceSection) {
|
|
205
|
+
// 取到下一个章节标题之前
|
|
206
|
+
var nextSection = acceptanceSection.split(/^#{1,6}\s/m)[0];
|
|
207
|
+
if (nextSection && !/^\s*- \[[ x]\]/m.test(nextSection) && !/^\s*\[[ x]\]/m.test(nextSection)) {
|
|
208
|
+
warnings.push(wpId + ' 验收标准中未发现复选框条目,建议使用 - [ ] 格式列出验收项');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
valid: errors.length === 0,
|
|
215
|
+
errors: errors,
|
|
216
|
+
warnings: warnings,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 验证所有 WP 文档
|
|
222
|
+
* @param {object} [context] - 验证上下文(保留兼容接口)
|
|
223
|
+
* @returns {{ valid: boolean, errors: string[], warnings: string[], results: object }}
|
|
224
|
+
*/
|
|
225
|
+
validateAll(context) {
|
|
226
|
+
var allErrors = [];
|
|
227
|
+
var allWarnings = [];
|
|
228
|
+
var perFile = {};
|
|
229
|
+
|
|
230
|
+
var files = this._readdir(this._docsWpDir);
|
|
231
|
+
var wpFiles = [];
|
|
232
|
+
|
|
233
|
+
for (var i = 0; i < files.length; i++) {
|
|
234
|
+
if (/^WP-\d+\.md$/i.test(files[i])) {
|
|
235
|
+
wpFiles.push(files[i]);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (wpFiles.length === 0) {
|
|
240
|
+
allWarnings.push('docs/wp/ 目录下未找到任何 WP 文档');
|
|
241
|
+
return {
|
|
242
|
+
valid: true,
|
|
243
|
+
errors: allErrors,
|
|
244
|
+
warnings: allWarnings,
|
|
245
|
+
results: perFile,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
for (var j = 0; j < wpFiles.length; j++) {
|
|
250
|
+
var filePath = path.join(this._docsWpDir, wpFiles[j]);
|
|
251
|
+
var result = this.validate(filePath);
|
|
252
|
+
var wpId = path.basename(filePath, '.md').toUpperCase();
|
|
253
|
+
perFile[wpId] = result;
|
|
254
|
+
|
|
255
|
+
for (var k = 0; k < result.errors.length; k++) {
|
|
256
|
+
allErrors.push(result.errors[k]);
|
|
257
|
+
}
|
|
258
|
+
for (var m = 0; m < result.warnings.length; m++) {
|
|
259
|
+
allWarnings.push(result.warnings[m]);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
valid: allErrors.length === 0,
|
|
265
|
+
errors: allErrors,
|
|
266
|
+
warnings: allWarnings,
|
|
267
|
+
results: perFile,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// --- internal helpers ---
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 同步读取文件,失败返回 null
|
|
275
|
+
* @param {string} filePath
|
|
276
|
+
* @returns {string|null}
|
|
277
|
+
*/
|
|
278
|
+
_readFile(filePath) {
|
|
279
|
+
try {
|
|
280
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
281
|
+
} catch (err) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 同步读取目录,失败返回空数组
|
|
288
|
+
* @param {string} dirPath
|
|
289
|
+
* @returns {string[]}
|
|
290
|
+
*/
|
|
291
|
+
_readdir(dirPath) {
|
|
292
|
+
try {
|
|
293
|
+
return fs.readdirSync(dirPath);
|
|
294
|
+
} catch (err) {
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
module.exports = WorkPackageValidator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "validator-work-package",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "validator",
|
|
5
|
+
"description": "工作包文档验证器 - 检测 WP 文档结构缺陷和依赖有效性",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"provides": ["validator:work-package"],
|
|
8
|
+
"metadata": {
|
|
9
|
+
"targets": ["wp-create", "wp-modify", "manual"]
|
|
10
|
+
},
|
|
11
|
+
"config": {}
|
|
12
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"plugins": [
|
|
4
|
+
{
|
|
5
|
+
"name": "provider-state-store",
|
|
6
|
+
"source": "provider-state-store",
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"config": {}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "provider-loop-engine",
|
|
12
|
+
"source": "provider-loop-engine",
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"config": {
|
|
15
|
+
"max_iterations": 6,
|
|
16
|
+
"max_round_time_ms": 600000,
|
|
17
|
+
"max_wall_time_ms": 3600000,
|
|
18
|
+
"divergence_threshold": 3,
|
|
19
|
+
"proximity_goal": 0.9
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "provider-role-registry",
|
|
24
|
+
"source": "provider-role-registry",
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"config": {}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "provider-memory-store",
|
|
30
|
+
"source": "provider-memory-store",
|
|
31
|
+
"enabled": true,
|
|
32
|
+
"config": {}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "validator-doc-sync",
|
|
36
|
+
"source": "validator-doc-sync",
|
|
37
|
+
"enabled": true,
|
|
38
|
+
"config": {}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "validator-work-package",
|
|
42
|
+
"source": "validator-work-package",
|
|
43
|
+
"enabled": true,
|
|
44
|
+
"config": {}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "hook-skill-gate",
|
|
48
|
+
"source": "hook-skill-gate",
|
|
49
|
+
"enabled": true,
|
|
50
|
+
"config": {
|
|
51
|
+
"gatedSkills": [],
|
|
52
|
+
"blockedStates": [
|
|
53
|
+
"waiting"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "hook-session-start",
|
|
59
|
+
"source": "hook-session-start",
|
|
60
|
+
"enabled": true,
|
|
61
|
+
"config": {}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "skill-task-creator",
|
|
65
|
+
"source": "skill-task-creator",
|
|
66
|
+
"enabled": true,
|
|
67
|
+
"config": {}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "skill-batch-task-creator",
|
|
71
|
+
"source": "skill-batch-task-creator",
|
|
72
|
+
"enabled": true,
|
|
73
|
+
"config": {}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "skill-split-work-package",
|
|
77
|
+
"source": "skill-split-work-package",
|
|
78
|
+
"enabled": true,
|
|
79
|
+
"config": {}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "skill-progress-tracker",
|
|
83
|
+
"source": "skill-progress-tracker",
|
|
84
|
+
"enabled": true,
|
|
85
|
+
"config": {}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "skill-team-cleanup",
|
|
89
|
+
"source": "skill-team-cleanup",
|
|
90
|
+
"enabled": true,
|
|
91
|
+
"config": {}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "skill-human-checkpoint",
|
|
95
|
+
"source": "skill-human-checkpoint",
|
|
96
|
+
"enabled": true,
|
|
97
|
+
"config": {}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "skill-role-manager",
|
|
101
|
+
"source": "skill-role-manager",
|
|
102
|
+
"enabled": true,
|
|
103
|
+
"config": {}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "skill-checklist",
|
|
107
|
+
"source": "skill-checklist",
|
|
108
|
+
"enabled": true,
|
|
109
|
+
"config": {}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "skill-completion-report",
|
|
113
|
+
"source": "skill-completion-report",
|
|
114
|
+
"enabled": true,
|
|
115
|
+
"config": {}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "skill-experience-logger",
|
|
119
|
+
"source": "skill-experience-logger",
|
|
120
|
+
"enabled": true,
|
|
121
|
+
"config": {}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "skill-agent-dispatcher",
|
|
125
|
+
"source": "skill-agent-dispatcher",
|
|
126
|
+
"enabled": true,
|
|
127
|
+
"config": {
|
|
128
|
+
"concurrency": {
|
|
129
|
+
"default_max": 6,
|
|
130
|
+
"schedules": [
|
|
131
|
+
{
|
|
132
|
+
"name": "peak",
|
|
133
|
+
"time_range": {
|
|
134
|
+
"start": "14:00",
|
|
135
|
+
"end": "18:00"
|
|
136
|
+
},
|
|
137
|
+
"max_concurrent": 3
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "skill-workflow-orchestrator",
|
|
145
|
+
"source": "skill-workflow-orchestrator",
|
|
146
|
+
"enabled": true,
|
|
147
|
+
"config": {}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "skill-agentic-loop",
|
|
151
|
+
"source": "skill-agentic-loop",
|
|
152
|
+
"enabled": true,
|
|
153
|
+
"config": {}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "provider-watchdog",
|
|
157
|
+
"source": "provider-watchdog",
|
|
158
|
+
"enabled": true,
|
|
159
|
+
"config": {}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "skill-watchdog-manager",
|
|
163
|
+
"source": "skill-watchdog-manager",
|
|
164
|
+
"enabled": true,
|
|
165
|
+
"config": {}
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "skill-doukui-sync",
|
|
169
|
+
"source": "skill-doukui-sync",
|
|
170
|
+
"enabled": true,
|
|
171
|
+
"config": {}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "skill-doukui-plan",
|
|
175
|
+
"source": "skill-doukui-plan",
|
|
176
|
+
"enabled": true,
|
|
177
|
+
"config": {}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "skill-task-archive",
|
|
181
|
+
"source": "skill-task-archive",
|
|
182
|
+
"enabled": true,
|
|
183
|
+
"config": {}
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Agent Definition Generator(WP-D2 模型分级路由)
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// 把项目角色定义(.claude/agents/roles/*.yaml)渲染为 Claude Code 自定义
|
|
7
|
+
// subagent 定义(.claude/agents/{roleId}.md,frontmatter 携带 model/tools),
|
|
8
|
+
// 使 dispatcher 可按 role spawn 指定模型的 Teamee——强模型跑 review/规划、
|
|
9
|
+
// 便宜模型跑批量实现,一份 plan 多模型混跑。
|
|
10
|
+
//
|
|
11
|
+
// role YAML 新增可选字段:
|
|
12
|
+
// model: <模型名或档位> # 如 glm-4.6-air / deepseek-v4-pro / sonnet / inherit
|
|
13
|
+
// # 缺省不写 frontmatter model → 走会话默认模型(现状)
|
|
14
|
+
// subagent_type: 生成后即为此 id(.claude/agents/{id}.md),dispatcher 按
|
|
15
|
+
// role.subagent_type spawn 时命中本定义。
|
|
16
|
+
//
|
|
17
|
+
// 设计约束:
|
|
18
|
+
// - 幂等:生成内容不变不重写(保 mtime,避免触发 IDE 热重载抖动)
|
|
19
|
+
// - abstract: true 的角色跳过(抽象基类不 spawn)
|
|
20
|
+
// - 全程 try/catch 降级:单个 role 失败不阻断整体,返回 per-role 错误
|
|
21
|
+
// - role YAML 解析复用 provider-role-registry 的 parseRoleYaml(经内部 require,
|
|
22
|
+
// 避免第二份解析器——plugin core 与 runtime 的既有依赖方向允许 runtime→core)
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
var fs = require('fs');
|
|
26
|
+
var path = require('path');
|
|
27
|
+
|
|
28
|
+
var _parseRoleYaml = null;
|
|
29
|
+
|
|
30
|
+
function getParseRoleYaml() {
|
|
31
|
+
if (_parseRoleYaml) return _parseRoleYaml;
|
|
32
|
+
try {
|
|
33
|
+
var mod = require('../core/provider-role-registry');
|
|
34
|
+
// provider 模块不直接导出解析函数时,走内部探测(_parseRoleYaml export 优先)
|
|
35
|
+
_parseRoleYaml = mod._parseRoleYaml || null;
|
|
36
|
+
} catch (_e) {
|
|
37
|
+
_parseRoleYaml = null;
|
|
38
|
+
}
|
|
39
|
+
return _parseRoleYaml;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 最小 role YAML 解析(provider 未导出解析器时的降级内联版,字段对齐 parseRoleYaml) */
|
|
43
|
+
function fallbackParseRoleYaml(content) {
|
|
44
|
+
var out = { id: '', name: '', description: '', tools: [], model: '', subagent_type: '', prompt_template: '', abstract: false };
|
|
45
|
+
var lines = String(content || '').split(/\r?\n/);
|
|
46
|
+
var inTools = false;
|
|
47
|
+
for (var i = 0; i < lines.length; i++) {
|
|
48
|
+
var line = lines[i];
|
|
49
|
+
if (/^\s*-\s+/.test(line)) {
|
|
50
|
+
if (inTools) out.tools.push(line.replace(/^\s*-\s+/, '').trim());
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
inTools = false;
|
|
54
|
+
var m = line.match(/^(\w+):\s*(.*)$/);
|
|
55
|
+
if (!m) continue;
|
|
56
|
+
var key = m[1];
|
|
57
|
+
var val = m[2].trim();
|
|
58
|
+
if (key === 'tools') { inTools = true; out.tools = []; continue; }
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(out, key)) {
|
|
60
|
+
out[key] = (key === 'abstract') ? (val === 'true') : val;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 渲染单个 role 为 agent 定义 markdown。
|
|
68
|
+
* @param {object} role parseRoleYaml 产物(含 model 字段)
|
|
69
|
+
* @returns {string} .md 文件内容
|
|
70
|
+
*/
|
|
71
|
+
function renderAgentDef(role) {
|
|
72
|
+
var fm = [];
|
|
73
|
+
// name 必须用 role.id(文件名 {id}.md 的配套)——不能用 subagent_type:其默认值
|
|
74
|
+
// 'general-purpose' 会与 Claude Code 内置 agent 同名覆盖,产生未定义行为。
|
|
75
|
+
// dispatcher 想按自定义名命中时,把 role 的 subagent_type 配成与 id 同值即可。
|
|
76
|
+
fm.push('name: ' + role.id);
|
|
77
|
+
// description 是 Claude Code 用来决定何时自动委派的依据——给足上下文
|
|
78
|
+
var desc = (role.description || role.name || role.id || '').replace(/\s*\n\s*/g, ' ').trim();
|
|
79
|
+
if (desc.length > 300) desc = desc.slice(0, 297) + '...';
|
|
80
|
+
fm.push('description: ' + JSON.stringify(desc));
|
|
81
|
+
if (Array.isArray(role.tools) && role.tools.length > 0) {
|
|
82
|
+
fm.push('tools: ' + role.tools.join(', '));
|
|
83
|
+
}
|
|
84
|
+
if (role.model && typeof role.model === 'string') {
|
|
85
|
+
fm.push('model: ' + role.model);
|
|
86
|
+
}
|
|
87
|
+
var body = role.prompt_template || desc ||
|
|
88
|
+
'You are the "' + (role.name || role.id) + '" role of a doukui-managed team. Follow the task prompt precisely.';
|
|
89
|
+
return '---\n' + fm.join('\n') + '\n---\n\n' + body + '\n';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 扫描 roles_dir 并生成 .claude/agents/{id}.md。
|
|
94
|
+
* @param {object} [opts]
|
|
95
|
+
* @param {string} [opts.projectRoot] 项目根(默认 cwd)
|
|
96
|
+
* @param {string} [opts.rolesDir] 角色定义目录(默认 .claude/agents/roles)
|
|
97
|
+
* @param {string} [opts.outDir] 生成目标目录(默认 .claude/agents)
|
|
98
|
+
* @param {boolean} [opts.enabled=true] 总开关(config roles.generate_agent_defs)
|
|
99
|
+
* @param {Function} [opts.log] 日志(可选)
|
|
100
|
+
* @returns {{ generated: string[], skipped: string[], errors: Array<{file:string,error:string}> }}
|
|
101
|
+
*/
|
|
102
|
+
function generateAgentDefs(opts) {
|
|
103
|
+
opts = opts || {};
|
|
104
|
+
var result = { generated: [], skipped: [], errors: [] };
|
|
105
|
+
if (opts.enabled === false) return result;
|
|
106
|
+
|
|
107
|
+
var projectRoot = opts.projectRoot || process.cwd();
|
|
108
|
+
var rolesDir = opts.rolesDir || path.join(projectRoot, '.claude', 'agents', 'roles');
|
|
109
|
+
var outDir = opts.outDir || path.join(projectRoot, '.claude', 'agents');
|
|
110
|
+
|
|
111
|
+
var files;
|
|
112
|
+
try {
|
|
113
|
+
files = fs.readdirSync(rolesDir).filter(function (f) { return /\.ya?ml$/i.test(f); });
|
|
114
|
+
} catch (_e) {
|
|
115
|
+
return result; // roles 目录不存在 → 无角色定义,跳过(首次使用尚未创建)
|
|
116
|
+
}
|
|
117
|
+
if (files.length === 0) return result;
|
|
118
|
+
|
|
119
|
+
try { fs.mkdirSync(outDir, { recursive: true }); } catch (_e) { /* 写失败在 per-file 捕获 */ }
|
|
120
|
+
|
|
121
|
+
var parser = getParseRoleYaml() || fallbackParseRoleYaml;
|
|
122
|
+
|
|
123
|
+
for (var i = 0; i < files.length; i++) {
|
|
124
|
+
var file = files[i];
|
|
125
|
+
try {
|
|
126
|
+
var raw = fs.readFileSync(path.join(rolesDir, file), 'utf8');
|
|
127
|
+
var role = parser(raw);
|
|
128
|
+
if (!role.id) { result.skipped.push(file); continue; }
|
|
129
|
+
if (role.abstract === true) { result.skipped.push(file); continue; }
|
|
130
|
+
var content = renderAgentDef(role);
|
|
131
|
+
var dest = path.join(outDir, role.id + '.md');
|
|
132
|
+
// 幂等:内容不变不重写
|
|
133
|
+
if (fs.existsSync(dest) && fs.readFileSync(dest, 'utf8') === content) {
|
|
134
|
+
result.skipped.push(file);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
fs.writeFileSync(dest, content, 'utf8');
|
|
138
|
+
result.generated.push(dest);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
result.errors.push({ file: file, error: e && e.message ? e.message : String(e) });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = {
|
|
147
|
+
generateAgentDefs: generateAgentDefs,
|
|
148
|
+
renderAgentDef: renderAgentDef,
|
|
149
|
+
_fallbackParseRoleYaml: fallbackParseRoleYaml,
|
|
150
|
+
};
|