cc-devflow 4.2.0 → 4.3.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.
Files changed (119) hide show
  1. package/.claude/commands/flow/CLAUDE.md +0 -4
  2. package/.claude/docs/examples/design-inspiration-pool.md +59 -0
  3. package/.claude/docs/examples/ui-prototype-constitution-checklist.md +75 -0
  4. package/.claude/docs/implementation-summary-v7.md +449 -0
  5. package/.claude/docs/spec-format-guide.md +349 -0
  6. package/.claude/docs/state-consolidation-design.md +323 -0
  7. package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +85 -386
  8. package/.claude/docs/templates/DESIGN_TEMPLATE.md +157 -0
  9. package/.claude/docs/templates/PROPOSAL_TEMPLATE.md +91 -0
  10. package/.claude/docs/templates/SPEC_TEMPLATE_DELTA.md +139 -0
  11. package/.claude/docs/templates/SPEC_TEMPLATE_PROJECT.md +93 -0
  12. package/.claude/docs/templates/STYLE_TEMPLATE.md +114 -901
  13. package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +143 -1205
  14. package/.claude/hooks/inject-agent-context.ts +9 -9
  15. package/.claude/scripts/.claude/commands/flow/export-openspec.md +221 -0
  16. package/.claude/scripts/.claude/commands/flow/import-openspec.md +171 -0
  17. package/.claude/scripts/__tests__/openspec.test.js +212 -0
  18. package/.claude/scripts/delta-parser.ts +112 -2
  19. package/.claude/scripts/export-openspec.js +222 -0
  20. package/.claude/scripts/import-openspec.js +272 -0
  21. package/.claude/scripts/validate-scope.sh +200 -0
  22. package/.claude/skills/{workflow/flow-init → flow-init}/SKILL.md +25 -4
  23. package/.claude/skills/{workflow/flow-release → flow-release}/SKILL.md +14 -3
  24. package/.claude/skills/{workflow/flow-spec → flow-spec}/SKILL.md +30 -2
  25. package/.claude/skills/utility/npm-release/CLAUDE.md +55 -0
  26. package/.claude/skills/utility/npm-release/SKILL.md +111 -46
  27. package/.claude/skills/utility/npm-release/references/version-decision-guide.md +134 -0
  28. package/.claude/skills/utility/npm-release/scripts/atomic-version-bump.sh +95 -0
  29. package/.claude/skills/utility/npm-release/scripts/validate-version-sync.sh +82 -0
  30. package/.claude/skills/utility/npm-release/scripts/version-decision-tree.sh +44 -0
  31. package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/affected-repos.txt +1 -0
  32. package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/edited-files.log +2 -0
  33. package/CHANGELOG.md +40 -0
  34. package/README.md +2 -1
  35. package/README.zh-CN.md +2 -1
  36. package/docs/v4.3.0-migration-guide.md +276 -0
  37. package/lib/harness/CLAUDE.md +5 -4
  38. package/lib/harness/__tests__/planner.tdd.test.js +125 -0
  39. package/lib/harness/index.js +4 -2
  40. package/lib/harness/operations/dispatch.js +13 -0
  41. package/lib/harness/operations/plan.js +55 -1
  42. package/lib/harness/operations/release.js +87 -0
  43. package/lib/harness/operations/verify.js +14 -0
  44. package/lib/harness/planner.js +131 -0
  45. package/lib/harness/query.js +126 -0
  46. package/lib/harness/schemas.js +22 -1
  47. package/package.json +1 -1
  48. package/.claude/commands/flow/checklist.md +0 -18
  49. package/.claude/commands/flow/clarify.md +0 -18
  50. package/.claude/commands/flow/new.md +0 -23
  51. package/.claude/commands/flow/quality.md +0 -21
  52. package/.claude/docs/templates/EPIC_TEMPLATE.md +0 -805
  53. package/.claude/docs/templates/PRD_TEMPLATE.md +0 -562
  54. package/.claude/docs/templates/TASKS_TEMPLATE.md +0 -523
  55. package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +0 -1019
  56. package/.claude/skills/workflow/CLAUDE.md +0 -24
  57. /package/.claude/skills/{domain/attention-refresh → attention-refresh}/SKILL.md +0 -0
  58. /package/.claude/skills/{domain/brainstorming → brainstorming}/SKILL.md +0 -0
  59. /package/.claude/skills/{guardrail/constitution-guardian → constitution-guardian}/SKILL.md +0 -0
  60. /package/.claude/skills/{utility/constitution-quick-ref → constitution-quick-ref}/SKILL.md +0 -0
  61. /package/.claude/skills/{domain/debugging → debugging}/SKILL.md +0 -0
  62. /package/.claude/skills/{utility/file-standards → file-standards}/SKILL.md +0 -0
  63. /package/.claude/skills/{domain/finishing-branch → finishing-branch}/SKILL.md +0 -0
  64. /package/.claude/skills/{workflow/flow-dev → flow-dev}/CLAUDE.md +0 -0
  65. /package/.claude/skills/{workflow/flow-dev → flow-dev}/SKILL.md +0 -0
  66. /package/.claude/skills/{workflow/flow-dev → flow-dev}/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +0 -0
  67. /package/.claude/skills/{workflow/flow-dev → flow-dev}/context.jsonl +0 -0
  68. /package/.claude/skills/{workflow/flow-dev → flow-dev}/dev-implementer.jsonl +0 -0
  69. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/entry-gate.sh +0 -0
  70. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/exit-gate.sh +0 -0
  71. /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/task-orchestrator.sh +0 -0
  72. /package/.claude/skills/{workflow/flow-fix → flow-fix}/SKILL.md +0 -0
  73. /package/.claude/skills/{workflow/flow-fix → flow-fix}/context.jsonl +0 -0
  74. /package/.claude/skills/{workflow/flow-fix → flow-fix}/references/bug-analyzer.md +0 -0
  75. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/BRAINSTORM_TEMPLATE.md +0 -0
  76. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/INIT_FLOW_TEMPLATE.md +0 -0
  77. /package/.claude/skills/{workflow/flow-init → flow-init}/assets/RESEARCH_TEMPLATE.md +0 -0
  78. /package/.claude/skills/{workflow/flow-init → flow-init}/context.jsonl +0 -0
  79. /package/.claude/skills/{workflow/flow-init → flow-init}/references/flow-researcher.md +0 -0
  80. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/check-prerequisites.sh +0 -0
  81. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/consolidate-research.sh +0 -0
  82. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/create-requirement.sh +0 -0
  83. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/generate-research-tasks.sh +0 -0
  84. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/populate-research-tasks.sh +0 -0
  85. /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/validate-research.sh +0 -0
  86. /package/.claude/skills/{workflow/flow-quality → flow-quality}/SKILL.md +0 -0
  87. /package/.claude/skills/{workflow/flow-quality → flow-quality}/context.jsonl +0 -0
  88. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/code-quality-reviewer.md +0 -0
  89. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/qa-tester.md +0 -0
  90. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/security-reviewer.md +0 -0
  91. /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/spec-reviewer.md +0 -0
  92. /package/.claude/skills/{workflow/flow-release → flow-release}/context.jsonl +0 -0
  93. /package/.claude/skills/{workflow/flow-release → flow-release}/references/release-manager.md +0 -0
  94. /package/.claude/skills/{workflow/flow-spec → flow-spec}/CLAUDE.md +0 -0
  95. /package/.claude/skills/{workflow/flow-spec → flow-spec}/context.jsonl +0 -0
  96. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/entry-gate.sh +0 -0
  97. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/exit-gate.sh +0 -0
  98. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/parallel-orchestrator.sh +0 -0
  99. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-communication.sh +0 -0
  100. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-init.sh +0 -0
  101. /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/test-team-mode.sh +0 -0
  102. /package/.claude/skills/{workflow/flow-spec → flow-spec}/team-config.json +0 -0
  103. /package/.claude/skills/{workflow/flow-verify → flow-verify}/CLAUDE.md +0 -0
  104. /package/.claude/skills/{workflow/flow-verify → flow-verify}/SKILL.md +0 -0
  105. /package/.claude/skills/{workflow/flow-verify → flow-verify}/context.jsonl +0 -0
  106. /package/.claude/skills/{utility/fractal-docs → fractal-docs}/SKILL.md +0 -0
  107. /package/.claude/skills/{utility/journey-checker → journey-checker}/SKILL.md +0 -0
  108. /package/.claude/skills/{utility/journey-checker → journey-checker}/pressure-scenarios.md +0 -0
  109. /package/.claude/skills/{domain/receiving-review → receiving-review}/SKILL.md +0 -0
  110. /package/.claude/skills/{utility/skill-creator → skill-creator}/LICENSE.txt +0 -0
  111. /package/.claude/skills/{utility/skill-creator → skill-creator}/SKILL.md +0 -0
  112. /package/.claude/skills/{utility/skill-creator → skill-creator}/references/output-patterns.md +0 -0
  113. /package/.claude/skills/{utility/skill-creator → skill-creator}/references/workflows.md +0 -0
  114. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/init_skill.py +0 -0
  115. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/package_skill.py +0 -0
  116. /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/quick_validate.py +0 -0
  117. /package/.claude/skills/{domain/tdd → tdd}/SKILL.md +0 -0
  118. /package/.claude/skills/{guardrail/tdd-enforcer → tdd-enforcer}/SKILL.md +0 -0
  119. /package/.claude/skills/{domain/verification → verification}/SKILL.md +0 -0
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env bash
2
+ # [INPUT]: 依赖 proposal.md 和 Delta spec.md
3
+ # [OUTPUT]: 生成 scope-creep-report.md
4
+ # [POS]: 反扩散检查脚本,被 /flow:spec 和 /flow:verify 调用
5
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
6
+
7
+ set -euo pipefail
8
+
9
+ # ============================================================================
10
+ # Configuration
11
+ # ============================================================================
12
+
13
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ source "${SCRIPT_DIR}/common.sh"
15
+
16
+ REQ_ID="${1:-}"
17
+ if [[ -z "$REQ_ID" ]]; then
18
+ error "Usage: validate-scope.sh <REQ-ID>"
19
+ exit 1
20
+ fi
21
+
22
+ REQ_DIR="devflow/requirements/${REQ_ID}"
23
+ PROPOSAL_FILE="${REQ_DIR}/proposal.md"
24
+ REPORT_FILE="${REQ_DIR}/scope-creep-report.md"
25
+
26
+ # ============================================================================
27
+ # Validation
28
+ # ============================================================================
29
+
30
+ if [[ ! -f "$PROPOSAL_FILE" ]]; then
31
+ error "proposal.md not found: $PROPOSAL_FILE"
32
+ exit 1
33
+ fi
34
+
35
+ # 查找所有 Delta spec.md 文件
36
+ DELTA_SPECS=$(find "${REQ_DIR}/specs" -name "spec.md" 2>/dev/null || true)
37
+
38
+ if [[ -z "$DELTA_SPECS" ]]; then
39
+ warn "No Delta specs found in ${REQ_DIR}/specs/"
40
+ exit 0
41
+ fi
42
+
43
+ # ============================================================================
44
+ # Extract Original Intent
45
+ # ============================================================================
46
+
47
+ info "Extracting original intent from proposal.md..."
48
+
49
+ # 提取 ## What 章节(原始需求描述)
50
+ ORIGINAL_INTENT=$(awk '
51
+ /^## What/ { flag=1; next }
52
+ /^## / { flag=0 }
53
+ flag { print }
54
+ ' "$PROPOSAL_FILE" | sed '/^$/d')
55
+
56
+ if [[ -z "$ORIGINAL_INTENT" ]]; then
57
+ warn "No 'What' section found in proposal.md"
58
+ ORIGINAL_INTENT="(No explicit requirements found)"
59
+ fi
60
+
61
+ # ============================================================================
62
+ # Extract Delta Requirements
63
+ # ============================================================================
64
+
65
+ info "Extracting ADDED requirements from Delta specs..."
66
+
67
+ ADDED_REQUIREMENTS=""
68
+ SCOPE_CREEP_COUNT=0
69
+
70
+ while IFS= read -r delta_file; do
71
+ module=$(basename "$(dirname "$delta_file")")
72
+
73
+ # 提取 ADDED Requirements 章节
74
+ added=$(awk '
75
+ /^## ADDED Requirements/ { flag=1; next }
76
+ /^## / { flag=0 }
77
+ flag && /^### Requirement:/ { print $0 }
78
+ ' "$delta_file")
79
+
80
+ if [[ -n "$added" ]]; then
81
+ ADDED_REQUIREMENTS+="
82
+ ### Module: $module
83
+ $added
84
+ "
85
+ fi
86
+ done <<< "$DELTA_SPECS"
87
+
88
+ # ============================================================================
89
+ # Detect Scope Creep
90
+ # ============================================================================
91
+
92
+ info "Detecting scope creep..."
93
+
94
+ # 简单启发式:检查 ADDED 需求中的关键词是否在原始意图中出现
95
+ CREEP_ITEMS=""
96
+
97
+ while IFS= read -r line; do
98
+ if [[ "$line" =~ ^###\ Requirement:\ (.+)$ ]]; then
99
+ req_name="${BASH_REMATCH[1]}"
100
+
101
+ # 提取关键词(去除常见词)
102
+ keywords=$(echo "$req_name" | tr '[:upper:]' '[:lower:]' | \
103
+ sed -e 's/the //g' -e 's/a //g' -e 's/an //g' -e 's/and //g' | \
104
+ tr -s ' ' '\n' | grep -v '^$')
105
+
106
+ # 检查关键词是否在原始意图中
107
+ found=false
108
+ while IFS= read -r keyword; do
109
+ if echo "$ORIGINAL_INTENT" | grep -qi "$keyword"; then
110
+ found=true
111
+ break
112
+ fi
113
+ done <<< "$keywords"
114
+
115
+ if [[ "$found" == "false" ]]; then
116
+ CREEP_ITEMS+="- ⚠️ $req_name (not mentioned in original intent)
117
+ "
118
+ ((SCOPE_CREEP_COUNT++))
119
+ else
120
+ CREEP_ITEMS+="- ✅ $req_name
121
+ "
122
+ fi
123
+ fi
124
+ done <<< "$ADDED_REQUIREMENTS"
125
+
126
+ # ============================================================================
127
+ # Generate Report
128
+ # ============================================================================
129
+
130
+ info "Generating scope-creep-report.md..."
131
+
132
+ cat > "$REPORT_FILE" <<EOF
133
+ # Scope Creep Report - ${REQ_ID}
134
+
135
+ > **Generated**: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
136
+ > **Status**: $([ $SCOPE_CREEP_COUNT -eq 0 ] && echo "✅ No scope creep detected" || echo "⚠️ Potential scope creep detected")
137
+
138
+ ---
139
+
140
+ ## Original Intent (from proposal.md)
141
+
142
+ ${ORIGINAL_INTENT}
143
+
144
+ ---
145
+
146
+ ## Current Delta (from specs/)
147
+
148
+ ${ADDED_REQUIREMENTS:-No ADDED requirements found}
149
+
150
+ ---
151
+
152
+ ## Analysis
153
+
154
+ ${CREEP_ITEMS:-No requirements to analyze}
155
+
156
+ ---
157
+
158
+ ## Summary
159
+
160
+ - **Total ADDED requirements**: $(echo "$ADDED_REQUIREMENTS" | grep -c "^### Requirement:" || echo 0)
161
+ - **Potential scope creep**: ${SCOPE_CREEP_COUNT}
162
+
163
+ ## Recommendation
164
+
165
+ EOF
166
+
167
+ if [[ $SCOPE_CREEP_COUNT -eq 0 ]]; then
168
+ cat >> "$REPORT_FILE" <<EOF
169
+ ✅ All ADDED requirements align with original intent. Safe to proceed.
170
+ EOF
171
+ else
172
+ cat >> "$REPORT_FILE" <<EOF
173
+ ⚠️ ${SCOPE_CREEP_COUNT} requirement(s) may be beyond original scope.
174
+
175
+ **Action Required**:
176
+ 1. Review each ⚠️ marked requirement
177
+ 2. If necessary, update proposal.md to include these features
178
+ 3. If not necessary, remove from Delta specs
179
+ 4. Consider creating separate REQs for additional features
180
+
181
+ **Constitutional Reference**: Article X - Requirement Boundary
182
+ EOF
183
+ fi
184
+
185
+ # ============================================================================
186
+ # Output
187
+ # ============================================================================
188
+
189
+ success "Scope creep report generated: $REPORT_FILE"
190
+
191
+ if [[ $SCOPE_CREEP_COUNT -gt 0 ]]; then
192
+ warn "⚠️ Potential scope creep detected: ${SCOPE_CREEP_COUNT} requirement(s)"
193
+ echo ""
194
+ echo "Review the report and confirm before proceeding:"
195
+ echo " cat $REPORT_FILE"
196
+ exit 1
197
+ else
198
+ success "✅ No scope creep detected"
199
+ exit 0
200
+ fi
@@ -53,29 +53,50 @@ description: 'Initialize a requirement with harness state and context package. U
53
53
  ## Execution Steps
54
54
 
55
55
  1. 解析输入,提取 `REQ_ID`、`TITLE`、`PLAN_URLS`。
56
- 2. 组装 goal 文本:
56
+
57
+ 2. **读取项目级 specs/ 了解当前系统状态**(v4.3 新增):
58
+ - 读取 `devflow/specs/README.md` 了解模块结构
59
+ - 扫描 `devflow/specs/*/spec.md` 识别相关模块
60
+ - 记录当前系统状态到上下文
61
+
62
+ 3. 组装 goal 文本:
57
63
  - `Deliver <REQ_ID>: <TITLE>`
58
64
  - 若有 URL,追加 `Sources: <URLS>`。
59
- 3. 运行初始化:
65
+
66
+ 4. 运行初始化:
60
67
 
61
68
  ```bash
62
69
  npm run harness:init -- --change-id "${REQ_ID}" --goal "${GOAL}"
63
70
  ```
64
71
 
65
- 4. 运行上下文打包:
72
+ 5. 运行上下文打包:
66
73
 
67
74
  ```bash
68
75
  npm run harness:pack -- --change-id "${REQ_ID}" --goal "${GOAL}"
69
76
  ```
70
77
 
71
- 5. 验证输出文件:
78
+ 6. **生成 proposal.md**(v4.3 新增,替代 PRD.md):
79
+ - 基于 TITLE 和 PLAN_URLS 生成 proposal.md
80
+ - 格式:Why(为什么需要)+ What(要做什么)
81
+ - 使用 `.claude/docs/templates/PROPOSAL_TEMPLATE.md`
82
+ - 输出到 `devflow/requirements/${REQ_ID}/proposal.md`
83
+
84
+ 7. **创建 specs/ 目录**(v4.3 新增):
85
+ - 创建 `devflow/requirements/${REQ_ID}/specs/` 目录
86
+ - 准备存放 Delta spec.md
87
+
88
+ 8. 验证输出文件:
72
89
  - `devflow/requirements/${REQ_ID}/harness-state.json`
73
90
  - `devflow/requirements/${REQ_ID}/context-package.md`
91
+ - `devflow/requirements/${REQ_ID}/proposal.md` ⭐ 新增
92
+ - `devflow/requirements/${REQ_ID}/specs/` 目录存在 ⭐ 新增
74
93
 
75
94
  ## Exit Criteria
76
95
 
77
96
  - `harness-state.json.status == "initialized"`
78
97
  - `context-package.md` 存在并包含 Next Commands 段落
98
+ - `proposal.md` 存在且包含 Why 和 What 章节 ⭐ v4.3 新增
99
+ - `specs/` 目录已创建 ⭐ v4.3 新增
79
100
 
80
101
  ## Next Step
81
102
 
@@ -23,25 +23,36 @@ description: 'Release a verified requirement and run runtime cleanup. Use only a
23
23
 
24
24
  1. 检查 `report-card.json`:
25
25
  - `overall` 必须为 `pass`
26
- 2. 运行发布:
26
+
27
+ 2. **合并 Delta specs 到项目级 specs/**(v4.3 新增):
28
+ - 检测 `devflow/requirements/${REQ_ID}/specs/` 目录
29
+ - 遍历所有模块的 Delta spec.md
30
+ - 调用 `delta-parser.ts merge` 合并到 `devflow/specs/{module}/spec.md`
31
+ - 自动更新项目级 spec.md 的版本号和时间戳
32
+ - 记录合并结果到 RELEASE_NOTE.md
33
+
34
+ 3. 运行发布:
27
35
 
28
36
  ```bash
29
37
  npm run harness:release -- --change-id "${REQ_ID}"
30
38
  ```
31
39
 
32
- 3. 运行熵清理:
40
+ 4. 运行熵清理:
33
41
 
34
42
  ```bash
35
43
  npm run harness:janitor -- --hours ${HOURS}
36
44
  ```
37
45
 
38
- 4. 验证输出:
46
+ 5. 验证输出:
39
47
  - `devflow/requirements/${REQ_ID}/RELEASE_NOTE.md`
40
48
  - `devflow/requirements/${REQ_ID}/harness-state.json` 中 `status == "released"`
49
+ - 项目级 `devflow/specs/{module}/spec.md` 已更新版本号 ⭐ v4.3 新增
41
50
 
42
51
  ## Exit Criteria
43
52
 
44
53
  - 发布文件存在且状态为 released
54
+ - Delta specs 已成功合并到项目级 specs/ ⭐ v4.3 新增
55
+ - 项目级 spec.md 版本号已更新 ⭐ v4.3 新增
45
56
  - janitor 执行成功
46
57
 
47
58
  ## Next Step
@@ -52,18 +52,46 @@ description: 'Generate and refresh task-manifest for a requirement. Use when con
52
52
  ## Execution Steps
53
53
 
54
54
  1. 解析 `REQ_ID` 和可选 `--overwrite`。
55
- 2. 运行计划生成:
55
+
56
+ 2. **读取项目级 specs/ 了解当前系统状态**(v4.3 新增):
57
+ - 读取 `devflow/specs/README.md` 了解模块结构
58
+ - 扫描 `devflow/specs/*/spec.md` 识别相关模块
59
+ - 记录当前系统状态到上下文
60
+
61
+ 3. **生成 design.md**(v4.3 新增,替代 TECH_DESIGN.md):
62
+ - 基于 `proposal.md` 的 What 章节
63
+ - 基于项目级 `specs/` 的当前状态
64
+ - 输出到 `devflow/requirements/${REQ_ID}/design.md`
65
+ - 格式:How(技术方案)+ Implementation(实现细节)
66
+
67
+ 4. **生成 Delta specs/**(v4.3 新增):
68
+ - 基于 `proposal.md` 和 `design.md`
69
+ - 为每个受影响的模块生成 Delta spec.md
70
+ - 输出到 `devflow/requirements/${REQ_ID}/specs/{module}/spec.md`
71
+ - 格式:ADDED/MODIFIED/REMOVED/RENAMED Requirements
72
+ - 使用 `.claude/docs/templates/SPEC_TEMPLATE_DELTA.md`
73
+
74
+ 5. **自动反扩散检查**(v4.3 新增):
75
+ - 运行 `bash .claude/scripts/validate-scope.sh "${REQ_ID}"`
76
+ - 对比 `proposal.md` 原始意图与 Delta specs 的 ADDED 需求
77
+ - 生成 `scope-creep-report.md`
78
+ - 如检测到范围扩散,阻塞并要求人工确认
79
+
80
+ 6. 运行计划生成:
56
81
 
57
82
  ```bash
58
83
  npm run harness:plan -- --change-id "${REQ_ID}" [--overwrite]
59
84
  ```
60
85
 
61
- 3. 校验输出:
86
+ 7. 校验输出:
62
87
  - `devflow/requirements/${REQ_ID}/task-manifest.json`
63
88
  - `tasks` 数组非空,`id/dependsOn/run` 字段完整
64
89
 
65
90
  ## Exit Criteria
66
91
 
92
+ - `design.md` 存在且包含 How 和 Implementation 章节 ⭐ v4.3 新增
93
+ - `specs/` 目录存在且至少有一个模块的 Delta spec.md ⭐ v4.3 新增
94
+ - `scope-creep-report.md` 存在且无阻塞性警告 ⭐ v4.3 新增
67
95
  - `task-manifest.json` 可通过 schema 校验
68
96
  - 任务依赖图无自循环(由 planner 保障)
69
97
 
@@ -0,0 +1,55 @@
1
+ # npm-release Skill
2
+
3
+ Version management skill with semantic versioning enforcement.
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ npm-release/
9
+ ├── SKILL.md # Main workflow instructions
10
+ ├── scripts/
11
+ │ ├── validate-version-sync.sh # Check version consistency
12
+ │ ├── version-decision-tree.sh # Calculate next version
13
+ │ └── atomic-version-bump.sh # Atomic version update
14
+ └── references/
15
+ └── version-decision-guide.md # Detailed SemVer rules
16
+ ```
17
+
18
+ ## Purpose
19
+
20
+ Prevents version chaos by enforcing:
21
+ 1. Semantic versioning rules (no arbitrary jumps)
22
+ 2. Atomic synchronization (package.json + CHANGELOG.md + git tags)
23
+ 3. Format consistency (vX.Y.Z everywhere)
24
+
25
+ ## Key Scripts
26
+
27
+ ### validate-version-sync.sh
28
+ Checks that package.json, git tags, and CHANGELOG.md all have matching versions.
29
+
30
+ ### version-decision-tree.sh
31
+ Enforces SemVer rules:
32
+ - Breaking change → MAJOR (X.0.0)
33
+ - New feature → MINOR (X.Y.0)
34
+ - Bug fix → PATCH (X.Y.Z)
35
+
36
+ ### atomic-version-bump.sh
37
+ Updates all version markers in one transaction, preventing inconsistencies.
38
+
39
+ ## Usage
40
+
41
+ ```bash
42
+ # Validate current state
43
+ bash scripts/validate-version-sync.sh
44
+
45
+ # Calculate next version
46
+ bash scripts/version-decision-tree.sh 4.2.0 minor
47
+ # Output: 4.3.0
48
+
49
+ # Atomic bump (recommended)
50
+ bash scripts/atomic-version-bump.sh minor "Add export command"
51
+ ```
52
+
53
+ ---
54
+
55
+ **[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: npm-release
3
- description: Use when ready to publish a new version of cc-devflow npm package to npm registry
3
+ description: Use when ready to publish a new version of cc-devflow npm package to npm registry. Enforces semantic versioning rules, prevents arbitrary version jumps (e.g., 3.0.1→7.0.0), and ensures atomic synchronization across package.json, CHANGELOG.md, and git tags.
4
4
  ---
5
5
 
6
6
  # NPM Release Workflow
@@ -9,7 +9,10 @@ description: Use when ready to publish a new version of cc-devflow npm package t
9
9
 
10
10
  Standardized release process for cc-devflow npm package ensuring consistent versioning, changelog maintenance, and safe publishing.
11
11
 
12
- **Core Principle**: Atomic release - all version markers (package.json, CHANGELOG.md, git tag) must stay in sync.
12
+ **Core Principles**:
13
+ 1. **Atomic release** - All version markers (package.json, CHANGELOG.md, git tag) stay in sync
14
+ 2. **Semantic versioning enforcement** - Prevents arbitrary jumps and format inconsistencies
15
+ 3. **Decision tree validation** - Every version bump follows explicit SemVer rules
13
16
 
14
17
  ## When to Use
15
18
 
@@ -24,18 +27,57 @@ Don't use when:
24
27
  - ❌ Not on main branch
25
28
  - ❌ Pre-release/beta versions (needs adaptation)
26
29
 
27
- ## Release Types
30
+ ## Version Decision Protocol
31
+
32
+ **MANDATORY**: Before any version bump, determine change type using the decision tree.
33
+
34
+ See [references/version-decision-guide.md](references/version-decision-guide.md) for detailed rules and examples.
35
+
36
+ ### Quick Decision Tree
37
+
38
+ ```
39
+ Is this a breaking change?
40
+ ├─ YES → MAJOR bump (X.0.0)
41
+ └─ NO → Is this a new feature?
42
+ ├─ YES → MINOR bump (X.Y.0)
43
+ └─ NO → PATCH bump (X.Y.Z)
44
+ ```
45
+
46
+ ### Release Types
28
47
 
29
48
  Follow [Semantic Versioning](https://semver.org/):
30
49
 
31
50
  | Type | Version Change | When |
32
51
  |------|---------------|------|
33
- | **Patch** | 2.4.3 → 2.4.4 | Bug fixes, minor improvements |
34
- | **Minor** | 2.4.42.5.0 | New features, backward compatible |
35
- | **Major** | 2.5.0 → 3.0.0 | Breaking changes |
52
+ | **Patch** | 4.2.04.2.1 | Bug fixes, minor improvements |
53
+ | **Minor** | 4.2.14.3.0 | New features, backward compatible |
54
+ | **Major** | 4.3.0 → 5.0.0 | Breaking changes |
55
+
56
+ ### Anti-Patterns (FORBIDDEN)
57
+
58
+ ❌ **Arbitrary jumps**: 3.0.1 → 7.0.0 (no justification)
59
+ ❌ **Skipping versions**: 4.2.0 → 4.4.0 (skipped 4.3.0)
60
+ ❌ **Inconsistent formats**: v1.0, 1.0.0, release-1.0 (mixed formats)
36
61
 
37
62
  ## Complete Workflow
38
63
 
64
+ ### Phase 0: Version Validation (MANDATORY)
65
+
66
+ **Before any changes**, validate current state and determine next version:
67
+
68
+ ```bash
69
+ # 1. Validate version synchronization
70
+ bash .claude/skills/utility/npm-release/scripts/validate-version-sync.sh
71
+
72
+ # 2. Determine change type (patch/minor/major)
73
+ # Use decision tree in references/version-decision-guide.md
74
+
75
+ # 3. Calculate next version
76
+ bash .claude/skills/utility/npm-release/scripts/version-decision-tree.sh $(grep -o '"version": *"[^"]*"' package.json | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+') <patch|minor|major>
77
+ ```
78
+
79
+ **STOP if validation fails** - Fix inconsistencies before proceeding.
80
+
39
81
  ### Phase 1: Pre-Release Checks
40
82
 
41
83
  ```bash
@@ -45,7 +87,7 @@ git status
45
87
 
46
88
  # 2. Check current version
47
89
  cat package.json | grep version
48
- # e.g., "version": "2.4.3"
90
+ # e.g., "version": "4.2.0"
49
91
 
50
92
  # 3. Review recent changes
51
93
  git log --oneline -10
@@ -56,9 +98,29 @@ git log --oneline -10
56
98
  - Uncommitted changes exist
57
99
  - Unpushed commits exist
58
100
 
59
- ### Phase 2: Version Updates
101
+ ### Phase 2: Atomic Version Bump
102
+
103
+ **Use the atomic bump script** (recommended):
104
+
105
+ ```bash
106
+ # Automatically updates package.json + CHANGELOG.md
107
+ bash .claude/skills/utility/npm-release/scripts/atomic-version-bump.sh <patch|minor|major> "Brief description"
108
+
109
+ # Example:
110
+ bash .claude/skills/utility/npm-release/scripts/atomic-version-bump.sh minor "Add export command"
111
+ ```
112
+
113
+ **Or manual update** (if script unavailable):
114
+
115
+ **Step 1: Update package.json**
116
+
117
+ ```bash
118
+ npm version patch --no-git-tag-version # For patch release
119
+ npm version minor --no-git-tag-version # For minor release
120
+ npm version major --no-git-tag-version # For major release
121
+ ```
60
122
 
61
- **Step 1: Update CHANGELOG.md**
123
+ **Step 2: Update CHANGELOG.md**
62
124
 
63
125
  Add new version section at the top (after `---`):
64
126
 
@@ -78,22 +140,6 @@ Brief description of main changes.
78
140
  - ✅ Benefit 2
79
141
  ```
80
142
 
81
- **Step 2: Update package.json**
82
-
83
- ```bash
84
- # Manually edit or use npm version
85
- npm version patch --no-git-tag-version # For patch release
86
- npm version minor --no-git-tag-version # For minor release
87
- npm version major --no-git-tag-version # For major release
88
- ```
89
-
90
- Or edit directly:
91
- ```json
92
- {
93
- "version": "X.Y.Z"
94
- }
95
- ```
96
-
97
143
  ### Phase 3: Git Operations
98
144
 
99
145
  **Step 1: Create Release Commit**
@@ -188,56 +234,75 @@ npm view cc-devflow version
188
234
 
189
235
  | Step | Command | Purpose |
190
236
  |------|---------|---------|
237
+ | **Validate sync** | `bash scripts/validate-version-sync.sh` | Check version consistency |
238
+ | **Decide version** | `bash scripts/version-decision-tree.sh <current> <type>` | Calculate next version |
239
+ | **Atomic bump** | `bash scripts/atomic-version-bump.sh <type> "desc"` | Update all markers |
191
240
  | Check status | `git status` | Verify clean state |
192
241
  | Check version | `grep version package.json` | Current version |
193
- | Bump version | Edit package.json | Update version number |
194
- | Update changelog | Edit CHANGELOG.md | Document changes |
195
242
  | Create commit | `git commit -m "chore(release): ..."` | Commit version bump |
196
243
  | Create tag | `git tag -a vX.Y.Z -m "..."` | Tag release |
197
244
  | Push commits | `git push origin main` | Push to GitHub |
198
245
  | Push tags | `git push origin vX.Y.Z` | Push tag to GitHub |
199
246
  | Publish npm | `npm publish` | Publish to registry |
200
247
 
248
+ ## Version Management Scripts
249
+
250
+ Three scripts enforce version discipline:
251
+
252
+ 1. **validate-version-sync.sh** - Checks package.json, git tags, CHANGELOG.md consistency
253
+ 2. **version-decision-tree.sh** - Calculates next version following SemVer rules
254
+ 3. **atomic-version-bump.sh** - Updates all version markers atomically
255
+
256
+ **Usage**:
257
+ ```bash
258
+ # Check current state
259
+ bash .claude/skills/utility/npm-release/scripts/validate-version-sync.sh
260
+
261
+ # Calculate next version
262
+ bash .claude/skills/utility/npm-release/scripts/version-decision-tree.sh 4.2.0 minor
263
+ # Output: 4.3.0
264
+
265
+ # Atomic bump (recommended)
266
+ bash .claude/skills/utility/npm-release/scripts/atomic-version-bump.sh minor "Add export command"
267
+ ```
268
+
201
269
  ## Common Mistakes
202
270
 
203
- ### ❌ Mistake 1: Forgetting to Update CHANGELOG.md
271
+ ### ❌ Mistake 1: Arbitrary Version Jumps
204
272
 
205
- **Problem**: Version bumped but no changelog entry
273
+ **Problem**: Version jumps from 3.0.1 to 7.0.0 without justification
206
274
 
207
- **Fix**: Always update CHANGELOG.md BEFORE committing
275
+ **Fix**: Use version-decision-tree.sh to calculate correct next version based on change type
208
276
 
209
277
  ### ❌ Mistake 2: Inconsistent Version Numbers
210
278
 
211
- **Problem**: package.json shows 2.4.4 but CHANGELOG.md shows 2.4.3
279
+ **Problem**: package.json shows 4.2.1 but CHANGELOG.md shows 4.2.0
280
+
281
+ **Fix**: Use atomic-version-bump.sh to update all markers simultaneously
282
+
283
+ ### ❌ Mistake 3: Forgetting to Update CHANGELOG.md
284
+
285
+ **Problem**: Version bumped but no changelog entry
212
286
 
213
- **Fix**: Double-check all version numbers match before committing
287
+ **Fix**: Always update CHANGELOG.md BEFORE committing (atomic-version-bump.sh does this automatically)
214
288
 
215
- ### ❌ Mistake 3: Pushing Tag Before Commit
289
+ ### ❌ Mistake 4: Pushing Tag Before Commit
216
290
 
217
291
  **Problem**: Tag points to wrong commit
218
292
 
219
293
  **Fix**: Always commit first, then tag, then push both together
220
294
 
221
- ### ❌ Mistake 4: Not Testing npm publish
295
+ ### ❌ Mistake 5: Not Testing npm publish
222
296
 
223
297
  **Problem**: Published package is broken
224
298
 
225
299
  **Fix**: Run `npm publish --dry-run` first to catch issues
226
300
 
227
- ### ❌ Mistake 5: Network Timeout During Push
301
+ ### ❌ Mistake 6: Inconsistent Tag Format
228
302
 
229
- **Problem**: `Failed to connect to github.com port 443`
303
+ **Problem**: Mixed formats like v1.0, 1.0.0, release-1.0
230
304
 
231
- **Fix**:
232
- ```bash
233
- # Option 1: Retry after network stabilizes
234
- git push origin main
235
- git push origin vX.Y.Z
236
-
237
- # Option 2: Switch to SSH (if HTTPS blocked)
238
- git remote set-url origin git@github.com:Dimon94/cc-devflow.git
239
- git push origin main
240
- ```
305
+ **Fix**: Always use vX.Y.Z format (e.g., v4.2.0). validate-version-sync.sh detects format inconsistencies
241
306
 
242
307
  ## Network Troubleshooting
243
308