dev-playbooks-cn 1.1.0 → 1.2.2
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/bin/devbooks.js +228 -0
- package/package.json +1 -1
- package/skills/_shared/references//345/201/217/347/246/273/346/243/200/346/265/213/344/270/216/350/267/257/347/224/261/345/215/217/350/256/256.md +199 -0
- package/skills/devbooks-brownfield-bootstrap/SKILL.md +1 -6
- package/skills/devbooks-code-review/SKILL.md +1 -1
- package/skills/devbooks-coder/SKILL.md +83 -24
- package/skills/devbooks-delivery-workflow/SKILL.md +1 -1
- package/skills/devbooks-design-backport/SKILL.md +1 -1
- package/skills/devbooks-design-doc/SKILL.md +1 -1
- package/skills/devbooks-docs-sync/SKILL.md +338 -0
- package/skills/devbooks-entropy-monitor/SKILL.md +1 -1
- package/skills/devbooks-impact-analysis/SKILL.md +1 -1
- package/skills/devbooks-implementation-plan/SKILL.md +1 -1
- package/skills/devbooks-proposal-author/SKILL.md +1 -1
- package/skills/devbooks-proposal-challenger/SKILL.md +1 -1
- package/skills/devbooks-proposal-judge/SKILL.md +1 -1
- package/skills/devbooks-router/SKILL.md +38 -7
- package/skills/devbooks-spec-contract/SKILL.md +1 -1
- package/skills/devbooks-spec-gardener/SKILL.md +1 -1
- package/skills/devbooks-test-owner/SKILL.md +81 -22
- package/skills/devbooks-test-reviewer/SKILL.md +27 -1
- package/templates/claude-agents/devbooks-coder.md +21 -0
- package/templates/claude-agents/devbooks-explorer.md +21 -0
- package/templates/claude-agents/devbooks-reviewer.md +21 -0
- package/templates/claude-agents/devbooks-test-owner.md +21 -0
package/bin/devbooks.js
CHANGED
|
@@ -305,6 +305,160 @@ function getCliVersion() {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
// ============================================================================
|
|
309
|
+
// 自动更新 .gitignore 和 .npmignore
|
|
310
|
+
// ============================================================================
|
|
311
|
+
|
|
312
|
+
const IGNORE_MARKERS = {
|
|
313
|
+
start: '# DevBooks managed - DO NOT EDIT',
|
|
314
|
+
end: '# End DevBooks managed'
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 获取需要添加到 .gitignore 的条目
|
|
319
|
+
* @param {string[]} toolIds - 选择的 AI 工具 ID
|
|
320
|
+
* @returns {string[]} - 需要忽略的条目
|
|
321
|
+
*/
|
|
322
|
+
function getGitIgnoreEntries(toolIds) {
|
|
323
|
+
const entries = [
|
|
324
|
+
'# DevBooks 本地配置(包含用户偏好,不应提交)',
|
|
325
|
+
'.devbooks/'
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
// 根据选择的工具添加对应的 AI 工具目录
|
|
329
|
+
for (const toolId of toolIds) {
|
|
330
|
+
const tool = AI_TOOLS.find(t => t.id === toolId);
|
|
331
|
+
if (!tool) continue;
|
|
332
|
+
|
|
333
|
+
// 添加 slash 命令目录
|
|
334
|
+
if (tool.slashDir) {
|
|
335
|
+
const topDir = tool.slashDir.split('/')[0];
|
|
336
|
+
if (!entries.includes(topDir + '/')) {
|
|
337
|
+
entries.push(`${topDir}/`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 添加 rules 目录
|
|
342
|
+
if (tool.rulesDir) {
|
|
343
|
+
const topDir = tool.rulesDir.split('/')[0];
|
|
344
|
+
if (!entries.includes(topDir + '/')) {
|
|
345
|
+
entries.push(`${topDir}/`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// 添加 agents 目录(如 .github/instructions 等)
|
|
350
|
+
if (tool.instructionsDir) {
|
|
351
|
+
const topDir = tool.instructionsDir.split('/')[0];
|
|
352
|
+
if (topDir !== '.github') { // .github 目录通常需要保留
|
|
353
|
+
if (!entries.includes(topDir + '/')) {
|
|
354
|
+
entries.push(`${topDir}/`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return entries;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 获取需要添加到 .npmignore 的条目
|
|
365
|
+
* @returns {string[]} - 需要忽略的条目
|
|
366
|
+
*/
|
|
367
|
+
function getNpmIgnoreEntries() {
|
|
368
|
+
return [
|
|
369
|
+
'# DevBooks 开发文档(运行时不需要)',
|
|
370
|
+
'dev-playbooks/',
|
|
371
|
+
'.devbooks/',
|
|
372
|
+
'',
|
|
373
|
+
'# AI 工具配置目录',
|
|
374
|
+
'.claude/',
|
|
375
|
+
'.cursor/',
|
|
376
|
+
'.windsurf/',
|
|
377
|
+
'.gemini/',
|
|
378
|
+
'.agent/',
|
|
379
|
+
'.opencode/',
|
|
380
|
+
'.continue/',
|
|
381
|
+
'.qoder/',
|
|
382
|
+
'.github/instructions/',
|
|
383
|
+
'.github/copilot-instructions.md',
|
|
384
|
+
'',
|
|
385
|
+
'# DevBooks 指令文件',
|
|
386
|
+
'CLAUDE.md',
|
|
387
|
+
'AGENTS.md',
|
|
388
|
+
'GEMINI.md'
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 更新 ignore 文件,保留用户自定义内容
|
|
394
|
+
* @param {string} filePath - ignore 文件路径
|
|
395
|
+
* @param {string[]} entries - 需要添加的条目
|
|
396
|
+
* @returns {object} - { updated: boolean, action: 'created' | 'updated' | 'unchanged' }
|
|
397
|
+
*/
|
|
398
|
+
function updateIgnoreFile(filePath, entries) {
|
|
399
|
+
const managedBlock = [
|
|
400
|
+
IGNORE_MARKERS.start,
|
|
401
|
+
...entries,
|
|
402
|
+
IGNORE_MARKERS.end
|
|
403
|
+
].join('\n');
|
|
404
|
+
|
|
405
|
+
if (!fs.existsSync(filePath)) {
|
|
406
|
+
// 文件不存在,创建新文件
|
|
407
|
+
fs.writeFileSync(filePath, managedBlock + '\n');
|
|
408
|
+
return { updated: true, action: 'created' };
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
412
|
+
const startIdx = content.indexOf(IGNORE_MARKERS.start);
|
|
413
|
+
const endIdx = content.indexOf(IGNORE_MARKERS.end);
|
|
414
|
+
|
|
415
|
+
if (startIdx !== -1 && endIdx !== -1 && startIdx < endIdx) {
|
|
416
|
+
// 已有托管块,更新它
|
|
417
|
+
const before = content.slice(0, startIdx);
|
|
418
|
+
const after = content.slice(endIdx + IGNORE_MARKERS.end.length);
|
|
419
|
+
const newContent = before + managedBlock + after;
|
|
420
|
+
|
|
421
|
+
if (newContent !== content) {
|
|
422
|
+
fs.writeFileSync(filePath, newContent);
|
|
423
|
+
return { updated: true, action: 'updated' };
|
|
424
|
+
}
|
|
425
|
+
return { updated: false, action: 'unchanged' };
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// 没有托管块,追加到文件末尾
|
|
429
|
+
const newContent = content.trimEnd() + '\n\n' + managedBlock + '\n';
|
|
430
|
+
fs.writeFileSync(filePath, newContent);
|
|
431
|
+
return { updated: true, action: 'updated' };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* 设置项目的 ignore 文件
|
|
436
|
+
* @param {string[]} toolIds - 选择的 AI 工具 ID
|
|
437
|
+
* @param {string} projectDir - 项目目录
|
|
438
|
+
* @returns {object[]} - 结果数组
|
|
439
|
+
*/
|
|
440
|
+
function setupIgnoreFiles(toolIds, projectDir) {
|
|
441
|
+
const results = [];
|
|
442
|
+
|
|
443
|
+
// 更新 .gitignore
|
|
444
|
+
const gitIgnorePath = path.join(projectDir, '.gitignore');
|
|
445
|
+
const gitIgnoreEntries = getGitIgnoreEntries(toolIds);
|
|
446
|
+
const gitResult = updateIgnoreFile(gitIgnorePath, gitIgnoreEntries);
|
|
447
|
+
if (gitResult.updated) {
|
|
448
|
+
results.push({ file: '.gitignore', action: gitResult.action });
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// 更新 .npmignore
|
|
452
|
+
const npmIgnorePath = path.join(projectDir, '.npmignore');
|
|
453
|
+
const npmIgnoreEntries = getNpmIgnoreEntries();
|
|
454
|
+
const npmResult = updateIgnoreFile(npmIgnorePath, npmIgnoreEntries);
|
|
455
|
+
if (npmResult.updated) {
|
|
456
|
+
results.push({ file: '.npmignore', action: npmResult.action });
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return results;
|
|
460
|
+
}
|
|
461
|
+
|
|
308
462
|
function showVersion() {
|
|
309
463
|
console.log(`${CLI_COMMAND} v${getCliVersion()}`);
|
|
310
464
|
}
|
|
@@ -458,6 +612,52 @@ function installSkills(toolIds, update = false) {
|
|
|
458
612
|
return results;
|
|
459
613
|
}
|
|
460
614
|
|
|
615
|
+
// ============================================================================
|
|
616
|
+
// 安装 Claude Code 自定义子代理(解决内置子代理无法访问 Skills 的问题)
|
|
617
|
+
// ============================================================================
|
|
618
|
+
|
|
619
|
+
function installClaudeAgents(toolIds, projectDir, update = false) {
|
|
620
|
+
const results = [];
|
|
621
|
+
|
|
622
|
+
// 只有 Claude Code 需要安装自定义子代理
|
|
623
|
+
if (!toolIds.includes('claude')) return results;
|
|
624
|
+
|
|
625
|
+
const agentsSrcDir = path.join(__dirname, '..', 'templates', 'claude-agents');
|
|
626
|
+
const agentsDestDir = path.join(projectDir, '.claude', 'agents');
|
|
627
|
+
|
|
628
|
+
if (!fs.existsSync(agentsSrcDir)) return results;
|
|
629
|
+
|
|
630
|
+
const agentFiles = fs.readdirSync(agentsSrcDir)
|
|
631
|
+
.filter(name => name.endsWith('.md'));
|
|
632
|
+
|
|
633
|
+
if (agentFiles.length === 0) return results;
|
|
634
|
+
|
|
635
|
+
fs.mkdirSync(agentsDestDir, { recursive: true });
|
|
636
|
+
|
|
637
|
+
let installedCount = 0;
|
|
638
|
+
for (const agentFile of agentFiles) {
|
|
639
|
+
const srcPath = path.join(agentsSrcDir, agentFile);
|
|
640
|
+
const destPath = path.join(agentsDestDir, agentFile);
|
|
641
|
+
|
|
642
|
+
if (fs.existsSync(destPath) && !update) continue;
|
|
643
|
+
|
|
644
|
+
fs.copyFileSync(srcPath, destPath);
|
|
645
|
+
installedCount++;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (installedCount > 0) {
|
|
649
|
+
results.push({
|
|
650
|
+
tool: 'Claude Code',
|
|
651
|
+
type: 'agents',
|
|
652
|
+
count: installedCount,
|
|
653
|
+
total: agentFiles.length,
|
|
654
|
+
path: agentsDestDir
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return results;
|
|
659
|
+
}
|
|
660
|
+
|
|
461
661
|
// ============================================================================
|
|
462
662
|
// 安装 Rules(Cursor, Windsurf, Gemini, Antigravity, OpenCode, Continue)
|
|
463
663
|
// ============================================================================
|
|
@@ -853,6 +1053,14 @@ async function initCommand(projectDir, options) {
|
|
|
853
1053
|
console.log(chalk.gray(` └ ${result.tool}: ${result.note}`));
|
|
854
1054
|
}
|
|
855
1055
|
}
|
|
1056
|
+
|
|
1057
|
+
// 安装 Claude Code 自定义子代理(解决内置子代理无法访问 Skills 的问题)
|
|
1058
|
+
const agentsResults = installClaudeAgents(fullSupportTools, projectDir);
|
|
1059
|
+
for (const result of agentsResults) {
|
|
1060
|
+
if (result.count > 0) {
|
|
1061
|
+
console.log(chalk.gray(` └ ${result.tool}: ${result.count} 个自定义子代理 → ${result.path}`));
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
856
1064
|
}
|
|
857
1065
|
|
|
858
1066
|
// 安装 Rules(Rules 类似系统的工具)
|
|
@@ -880,6 +1088,18 @@ async function initCommand(projectDir, options) {
|
|
|
880
1088
|
console.log(chalk.gray(` └ ${result.tool}: ${path.relative(projectDir, result.path)}`));
|
|
881
1089
|
}
|
|
882
1090
|
|
|
1091
|
+
// 设置 ignore 文件
|
|
1092
|
+
const ignoreSpinner = ora('配置 ignore 文件...').start();
|
|
1093
|
+
const ignoreResults = setupIgnoreFiles(selectedTools, projectDir);
|
|
1094
|
+
if (ignoreResults.length > 0) {
|
|
1095
|
+
ignoreSpinner.succeed('ignore 文件已配置');
|
|
1096
|
+
for (const result of ignoreResults) {
|
|
1097
|
+
console.log(chalk.gray(` └ ${result.file}: ${result.action === 'created' ? '已创建' : '已更新'}`));
|
|
1098
|
+
}
|
|
1099
|
+
} else {
|
|
1100
|
+
ignoreSpinner.succeed('ignore 文件无需更新');
|
|
1101
|
+
}
|
|
1102
|
+
|
|
883
1103
|
// 完成
|
|
884
1104
|
console.log();
|
|
885
1105
|
console.log(chalk.green('══════════════════════════════════════'));
|
|
@@ -946,6 +1166,14 @@ async function updateCommand(projectDir) {
|
|
|
946
1166
|
}
|
|
947
1167
|
}
|
|
948
1168
|
|
|
1169
|
+
// 更新 Claude Code 自定义子代理(项目目录)
|
|
1170
|
+
const agentsResults = installClaudeAgents(configuredTools, projectDir, true);
|
|
1171
|
+
for (const result of agentsResults) {
|
|
1172
|
+
if (result.count > 0) {
|
|
1173
|
+
console.log(chalk.green('✓') + ` ${result.tool}: 更新了 ${result.count} 个自定义子代理`);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
949
1177
|
// 更新 Rules(项目目录)
|
|
950
1178
|
const rulesTools = configuredTools.filter(id => {
|
|
951
1179
|
const tool = AI_TOOLS.find(t => t.id === id);
|
package/package.json
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# 偏离检测与路由协议
|
|
2
|
+
|
|
3
|
+
> 本协议定义了 skill 执行过程中的偏离检测、记录和路由机制。
|
|
4
|
+
> 所有 Apply 阶段的 skill(coder、test-owner、reviewer)必须遵循本协议。
|
|
5
|
+
|
|
6
|
+
## 核心问题
|
|
7
|
+
|
|
8
|
+
在长任务(如 coder)执行过程中,可能出现:
|
|
9
|
+
1. 计划外的功能修改或新增
|
|
10
|
+
2. 发现设计文档的约束需要调整
|
|
11
|
+
3. 上下文超出引发 compact,导致偏离信息丢失
|
|
12
|
+
|
|
13
|
+
**解决方案**:实时落盘 + 完成时检测 + 结构化路由
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 完成状态分类(MECE)
|
|
18
|
+
|
|
19
|
+
每个 skill 结束时,必须识别并声明当前状态:
|
|
20
|
+
|
|
21
|
+
| 状态码 | 状态 | 含义 | 下一步 |
|
|
22
|
+
|:------:|------|------|--------|
|
|
23
|
+
| ✅ | COMPLETED | 正常完成,无偏离 | 进入下一个 skill |
|
|
24
|
+
| ⚠️ | COMPLETED_WITH_DEVIATION | 完成但有偏离/新增 | 先 design-backport,再下一步 |
|
|
25
|
+
| 🔄 | HANDOFF | 需要其他角色处理 | 退回指定 skill |
|
|
26
|
+
| ❌ | BLOCKED | 阻塞,需要外部输入 | 记录断点,等待 |
|
|
27
|
+
| 💥 | FAILED | 失败,闸门未通过 | 修复后重试 |
|
|
28
|
+
|
|
29
|
+
### 状态判定规则
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
如果 deviation-log.md 有未回写的记录
|
|
33
|
+
→ COMPLETED_WITH_DEVIATION
|
|
34
|
+
|
|
35
|
+
如果 tasks.md 有未完成项
|
|
36
|
+
→ BLOCKED 或 FAILED(取决于原因)
|
|
37
|
+
|
|
38
|
+
如果发现需要修改 tests/(对于 coder)
|
|
39
|
+
→ HANDOFF to test-owner
|
|
40
|
+
|
|
41
|
+
如果所有任务完成且无偏离
|
|
42
|
+
→ COMPLETED
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 偏离日志协议(Deviation Log Protocol)
|
|
48
|
+
|
|
49
|
+
### 文件位置
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
<change-root>/<change-id>/deviation-log.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 文件格式
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
# 偏离日志 (Deviation Log)
|
|
59
|
+
|
|
60
|
+
> 此文件记录实现过程中发现的所有偏离、新增和临时决策。
|
|
61
|
+
> **重要**:Compact 后此文件仍然存在,确保信息不丢失。
|
|
62
|
+
|
|
63
|
+
## 待回写记录
|
|
64
|
+
|
|
65
|
+
| 时间 | 类型 | 描述 | 涉及文件 | 已回写 |
|
|
66
|
+
|------|------|------|----------|:------:|
|
|
67
|
+
| YYYY-MM-DD HH:mm | NEW_FEATURE | 添加了 X 功能 | src/x.ts | ❌ |
|
|
68
|
+
| YYYY-MM-DD HH:mm | CONSTRAINT_CHANGE | 超时改为 60s | config.ts | ❌ |
|
|
69
|
+
| YYYY-MM-DD HH:mm | DESIGN_GAP | 发现未覆盖的边界情况 | - | ❌ |
|
|
70
|
+
|
|
71
|
+
## 已回写记录
|
|
72
|
+
|
|
73
|
+
(design-backport 完成后移动到此处)
|
|
74
|
+
|
|
75
|
+
| 时间 | 类型 | 描述 | 回写到 |
|
|
76
|
+
|------|------|------|--------|
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 偏离类型定义
|
|
80
|
+
|
|
81
|
+
| 类型 | 代码 | 描述 | 示例 |
|
|
82
|
+
|------|------|------|------|
|
|
83
|
+
| 新增功能 | NEW_FEATURE | 添加了设计中没有的功能 | 新增 warmup() 方法 |
|
|
84
|
+
| 约束变更 | CONSTRAINT_CHANGE | 修改了设计中的约束/配置 | 超时从 30s 改为 60s |
|
|
85
|
+
| 设计缺口 | DESIGN_GAP | 发现设计未覆盖的场景 | 并发情况未考虑 |
|
|
86
|
+
| 接口变更 | API_CHANGE | 公共接口与设计不一致 | 参数增加了 options |
|
|
87
|
+
| 依赖变更 | DEPENDENCY_CHANGE | 引入了计划外的依赖 | 新增 lodash |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 实时落盘协议
|
|
92
|
+
|
|
93
|
+
### 何时写入 deviation-log.md
|
|
94
|
+
|
|
95
|
+
**必须立即写入**的情况:
|
|
96
|
+
|
|
97
|
+
1. **添加了新文件/函数**,且不在 tasks.md 中
|
|
98
|
+
2. **修改了配置/约束**,且与 design.md 不一致
|
|
99
|
+
3. **发现边界情况**,design.md 未覆盖
|
|
100
|
+
4. **临时决策**,需要事后确认
|
|
101
|
+
|
|
102
|
+
### 如何写入
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
## 示例:发现需要新增功能
|
|
106
|
+
|
|
107
|
+
在 deviation-log.md 中追加一行:
|
|
108
|
+
|
|
109
|
+
| 2024-01-15 10:30 | NEW_FEATURE | 添加缓存预热功能,提升首次访问性能 | src/cache.ts | ❌ |
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Compact 保护
|
|
113
|
+
|
|
114
|
+
deviation-log.md 是**持久化文件**,不受 compact 影响。即使对话上下文被压缩:
|
|
115
|
+
- 文件内容仍然存在
|
|
116
|
+
- 下一个 skill 可以读取并处理
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 下一步路由规则
|
|
121
|
+
|
|
122
|
+
### 通用路由表
|
|
123
|
+
|
|
124
|
+
| 当前 Skill | 完成状态 | 下一步 |
|
|
125
|
+
|------------|----------|--------|
|
|
126
|
+
| 任意 | COMPLETED_WITH_DEVIATION | `devbooks-design-backport` |
|
|
127
|
+
| coder | COMPLETED | `devbooks-code-review` |
|
|
128
|
+
| coder | HANDOFF (测试问题) | `devbooks-test-owner` |
|
|
129
|
+
| test-owner | COMPLETED | `devbooks-coder` |
|
|
130
|
+
| test-owner | HANDOFF (设计问题) | `devbooks-design-backport` |
|
|
131
|
+
| code-review | COMPLETED (有 spec delta) | `devbooks-spec-gardener` |
|
|
132
|
+
| code-review | COMPLETED (无 spec delta) | 归档完成 |
|
|
133
|
+
| 任意 | BLOCKED | 记录断点,等待用户 |
|
|
134
|
+
| 任意 | FAILED | 修复后重试当前 skill |
|
|
135
|
+
|
|
136
|
+
### 路由输出模板
|
|
137
|
+
|
|
138
|
+
完成 skill 后,必须输出以下格式:
|
|
139
|
+
|
|
140
|
+
```markdown
|
|
141
|
+
## 完成状态
|
|
142
|
+
|
|
143
|
+
**状态**:[COMPLETED / COMPLETED_WITH_DEVIATION / HANDOFF / BLOCKED / FAILED]
|
|
144
|
+
|
|
145
|
+
**偏离记录**:[有 N 条 / 无]
|
|
146
|
+
|
|
147
|
+
## 下一步
|
|
148
|
+
|
|
149
|
+
**推荐**:`devbooks-xxx skill`
|
|
150
|
+
|
|
151
|
+
**原因**:[具体原因]
|
|
152
|
+
|
|
153
|
+
**调用方式**:
|
|
154
|
+
运行 devbooks-xxx skill 处理变更 <change-id>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 与 design-backport 的交互
|
|
160
|
+
|
|
161
|
+
### 触发条件
|
|
162
|
+
|
|
163
|
+
当 deviation-log.md 中有**未回写记录**(已回写=❌)时,必须先执行 design-backport。
|
|
164
|
+
|
|
165
|
+
### 回写完成标记
|
|
166
|
+
|
|
167
|
+
design-backport 完成后:
|
|
168
|
+
1. 将记录从"待回写"移动到"已回写"
|
|
169
|
+
2. 更新"已回写"列为 ✅
|
|
170
|
+
3. 记录回写到的具体位置
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 检测脚本(可选)
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# 检查是否有未回写的偏离
|
|
178
|
+
check_deviation() {
|
|
179
|
+
local change_dir="$1"
|
|
180
|
+
local log_file="${change_dir}/deviation-log.md"
|
|
181
|
+
|
|
182
|
+
if [[ ! -f "$log_file" ]]; then
|
|
183
|
+
echo "NO_DEVIATION"
|
|
184
|
+
return 0
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
if grep -q "| ❌" "$log_file"; then
|
|
188
|
+
echo "HAS_PENDING_DEVIATION"
|
|
189
|
+
return 1
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
echo "ALL_BACKPORTED"
|
|
193
|
+
return 0
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
*此协议是 DevBooks Apply 阶段的核心协议,所有实现类 skill 必须遵循。*
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: devbooks-brownfield-bootstrap
|
|
3
3
|
description: devbooks-brownfield-bootstrap:存量项目初始化:在当前真理目录为空时生成项目画像、术语表、基线规格与最小验证锚点,避免"边补 specs 边改行为"。用户说"存量初始化/基线 specs/项目画像/建立 glossary/把老项目接入上下文协议"等时使用。
|
|
4
|
-
tools:
|
|
4
|
+
allowed-tools:
|
|
5
5
|
- Glob
|
|
6
6
|
- Grep
|
|
7
7
|
- Read
|
|
8
8
|
- Write
|
|
9
9
|
- Edit
|
|
10
10
|
- Bash
|
|
11
|
-
- mcp__ckb__getStatus
|
|
12
|
-
- mcp__ckb__getArchitecture
|
|
13
|
-
- mcp__ckb__getHotspots
|
|
14
|
-
- mcp__ckb__listKeyConcepts
|
|
15
|
-
- mcp__ckb__getModuleOverview
|
|
16
11
|
---
|
|
17
12
|
|
|
18
13
|
# DevBooks:存量项目初始化(Brownfield Bootstrap)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: devbooks-coder
|
|
3
3
|
description: devbooks-coder:以 Coder 角色严格按 tasks.md 实现功能并跑闸门,禁止修改 tests/,以测试/静态检查为唯一完成判据。用户说"按计划实现/修复测试失败/让闸门全绿/实现任务项/不改测试",或在 DevBooks apply 阶段以 coder 执行时使用。
|
|
4
|
-
tools:
|
|
4
|
+
allowed-tools:
|
|
5
5
|
- Glob
|
|
6
6
|
- Grep
|
|
7
7
|
- Read
|
|
@@ -245,45 +245,104 @@ fi
|
|
|
245
245
|
|
|
246
246
|
---
|
|
247
247
|
|
|
248
|
-
##
|
|
248
|
+
## 偏离检测与落盘协议
|
|
249
249
|
|
|
250
|
-
**参考**:`skills/_shared/
|
|
250
|
+
**参考**:`skills/_shared/references/偏离检测与路由协议.md`
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
### 实时落盘要求
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
|
257
|
-
|
|
254
|
+
在实现过程中,**必须立即**将以下情况写入 `deviation-log.md`:
|
|
255
|
+
|
|
256
|
+
| 情况 | 类型 | 示例 |
|
|
257
|
+
|------|------|------|
|
|
258
|
+
| 添加了 tasks.md 中没有的功能 | NEW_FEATURE | 新增 warmup() 方法 |
|
|
259
|
+
| 修改了 design.md 中的约束 | CONSTRAINT_CHANGE | 超时改为 60s |
|
|
260
|
+
| 发现设计未覆盖的边界情况 | DESIGN_GAP | 并发场景 |
|
|
261
|
+
| 公共接口与设计不一致 | API_CHANGE | 参数增加 |
|
|
262
|
+
|
|
263
|
+
### deviation-log.md 格式
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
# 偏离日志
|
|
267
|
+
|
|
268
|
+
## 待回写记录
|
|
269
|
+
|
|
270
|
+
| 时间 | 类型 | 描述 | 涉及文件 | 已回写 |
|
|
271
|
+
|------|------|------|----------|:------:|
|
|
272
|
+
| 2024-01-15 10:30 | NEW_FEATURE | 添加缓存预热功能 | src/cache.ts | ❌ |
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Compact 保护
|
|
276
|
+
|
|
277
|
+
**重要**:deviation-log.md 是持久化文件,不受 compact 影响。即使对话被压缩,偏离信息仍然保留。
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 完成状态与下一步路由
|
|
282
|
+
|
|
283
|
+
### 完成状态分类(MECE)
|
|
284
|
+
|
|
285
|
+
| 状态码 | 状态 | 判定条件 | 下一步 |
|
|
286
|
+
|:------:|------|----------|--------|
|
|
287
|
+
| ✅ | COMPLETED | 所有任务完成,无偏离 | `devbooks-code-review` |
|
|
288
|
+
| ⚠️ | COMPLETED_WITH_DEVIATION | 任务完成,deviation-log 有未回写记录 | `devbooks-design-backport` |
|
|
289
|
+
| 🔄 | HANDOFF | 发现测试问题需要修改 | `devbooks-test-owner` |
|
|
290
|
+
| ❌ | BLOCKED | 需要外部输入/决策 | 记录断点,等待用户 |
|
|
291
|
+
| 💥 | FAILED | 闸门未通过 | 修复后重试 |
|
|
292
|
+
|
|
293
|
+
### 状态判定流程
|
|
258
294
|
|
|
259
|
-
**关键**:
|
|
260
|
-
- Coder **不能修改** `tests/**`
|
|
261
|
-
- 如发现测试问题,交回 Test Owner(单独会话)
|
|
262
|
-
- 工作流顺序是:
|
|
263
295
|
```
|
|
264
|
-
|
|
296
|
+
1. 检查 deviation-log.md 是否有 "| ❌" 记录
|
|
297
|
+
→ 有:COMPLETED_WITH_DEVIATION
|
|
298
|
+
|
|
299
|
+
2. 检查是否需要修改 tests/
|
|
300
|
+
→ 是:HANDOFF to test-owner
|
|
301
|
+
|
|
302
|
+
3. 检查 tasks.md 是否全部完成
|
|
303
|
+
→ 否:BLOCKED 或 FAILED
|
|
304
|
+
|
|
305
|
+
4. 以上都通过
|
|
306
|
+
→ COMPLETED
|
|
265
307
|
```
|
|
266
308
|
|
|
267
|
-
###
|
|
309
|
+
### 路由输出模板(必须使用)
|
|
268
310
|
|
|
269
|
-
完成 coder
|
|
311
|
+
完成 coder 后,**必须**输出以下格式:
|
|
270
312
|
|
|
271
313
|
```markdown
|
|
272
|
-
##
|
|
314
|
+
## 完成状态
|
|
315
|
+
|
|
316
|
+
**状态**:✅ COMPLETED / ⚠️ COMPLETED_WITH_DEVIATION / 🔄 HANDOFF / ❌ BLOCKED / 💥 FAILED
|
|
317
|
+
|
|
318
|
+
**任务进度**:X/Y 已完成
|
|
273
319
|
|
|
274
|
-
|
|
320
|
+
**偏离记录**:有 N 条待回写 / 无
|
|
275
321
|
|
|
276
|
-
|
|
322
|
+
## 下一步
|
|
323
|
+
|
|
324
|
+
**推荐**:`devbooks-xxx skill`
|
|
325
|
+
|
|
326
|
+
**原因**:[具体原因]
|
|
277
327
|
|
|
278
328
|
### 如何调用
|
|
279
|
-
|
|
280
|
-
运行 devbooks-code-review skill 处理变更 <change-id>
|
|
329
|
+
运行 devbooks-xxx skill 处理变更 <change-id>
|
|
281
330
|
```
|
|
282
331
|
|
|
283
|
-
###
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
332
|
+
### 具体路由规则
|
|
333
|
+
|
|
334
|
+
| 我的状态 | 下一步 | 原因 |
|
|
335
|
+
|----------|--------|------|
|
|
336
|
+
| COMPLETED | `devbooks-code-review` | 评审可读性/一致性 |
|
|
337
|
+
| COMPLETED_WITH_DEVIATION | `devbooks-design-backport` | 先回写设计,再评审 |
|
|
338
|
+
| HANDOFF (测试问题) | `devbooks-test-owner` | Coder 不能修改测试 |
|
|
339
|
+
| BLOCKED | 等待用户 | 记录断点区 |
|
|
340
|
+
| FAILED | 修复后重试 | 分析失败原因 |
|
|
341
|
+
|
|
342
|
+
**关键约束**:
|
|
343
|
+
- Coder **永远不能修改** `tests/**`
|
|
344
|
+
- 如发现测试问题,必须 HANDOFF 给 Test Owner(单独会话)
|
|
345
|
+
- 如有偏离,必须先 design-backport 再继续
|
|
287
346
|
|
|
288
347
|
---
|
|
289
348
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: devbooks-delivery-workflow
|
|
3
3
|
description: devbooks-delivery-workflow:把一次变更跑成可追溯闭环(Design→Plan→Trace→Verify→Implement→Archive),明确 DoD、追溯矩阵与角色隔离(Test Owner 与 Coder 分离)。用户说"跑一遍闭环/交付验收/追溯矩阵/DoD/关账归档/验收工作流"等时使用。
|
|
4
|
-
tools:
|
|
4
|
+
allowed-tools:
|
|
5
5
|
- Glob
|
|
6
6
|
- Grep
|
|
7
7
|
- Read
|