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.
- package/.claude/commands/flow/CLAUDE.md +0 -4
- package/.claude/docs/examples/design-inspiration-pool.md +59 -0
- package/.claude/docs/examples/ui-prototype-constitution-checklist.md +75 -0
- package/.claude/docs/implementation-summary-v7.md +449 -0
- package/.claude/docs/spec-format-guide.md +349 -0
- package/.claude/docs/state-consolidation-design.md +323 -0
- package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +85 -386
- package/.claude/docs/templates/DESIGN_TEMPLATE.md +157 -0
- package/.claude/docs/templates/PROPOSAL_TEMPLATE.md +91 -0
- package/.claude/docs/templates/SPEC_TEMPLATE_DELTA.md +139 -0
- package/.claude/docs/templates/SPEC_TEMPLATE_PROJECT.md +93 -0
- package/.claude/docs/templates/STYLE_TEMPLATE.md +114 -901
- package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +143 -1205
- package/.claude/hooks/inject-agent-context.ts +9 -9
- package/.claude/scripts/.claude/commands/flow/export-openspec.md +221 -0
- package/.claude/scripts/.claude/commands/flow/import-openspec.md +171 -0
- package/.claude/scripts/__tests__/openspec.test.js +212 -0
- package/.claude/scripts/delta-parser.ts +112 -2
- package/.claude/scripts/export-openspec.js +222 -0
- package/.claude/scripts/import-openspec.js +272 -0
- package/.claude/scripts/validate-scope.sh +200 -0
- package/.claude/skills/{workflow/flow-init → flow-init}/SKILL.md +25 -4
- package/.claude/skills/{workflow/flow-release → flow-release}/SKILL.md +14 -3
- package/.claude/skills/{workflow/flow-spec → flow-spec}/SKILL.md +30 -2
- package/.claude/skills/utility/npm-release/CLAUDE.md +55 -0
- package/.claude/skills/utility/npm-release/SKILL.md +111 -46
- package/.claude/skills/utility/npm-release/references/version-decision-guide.md +134 -0
- package/.claude/skills/utility/npm-release/scripts/atomic-version-bump.sh +95 -0
- package/.claude/skills/utility/npm-release/scripts/validate-version-sync.sh +82 -0
- package/.claude/skills/utility/npm-release/scripts/version-decision-tree.sh +44 -0
- package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/affected-repos.txt +1 -0
- package/.claude/tsc-cache/70d2fc6d-2936-429b-b529-429f1aae8c88/edited-files.log +2 -0
- package/CHANGELOG.md +40 -0
- package/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/docs/v4.3.0-migration-guide.md +276 -0
- package/lib/harness/CLAUDE.md +5 -4
- package/lib/harness/__tests__/planner.tdd.test.js +125 -0
- package/lib/harness/index.js +4 -2
- package/lib/harness/operations/dispatch.js +13 -0
- package/lib/harness/operations/plan.js +55 -1
- package/lib/harness/operations/release.js +87 -0
- package/lib/harness/operations/verify.js +14 -0
- package/lib/harness/planner.js +131 -0
- package/lib/harness/query.js +126 -0
- package/lib/harness/schemas.js +22 -1
- package/package.json +1 -1
- package/.claude/commands/flow/checklist.md +0 -18
- package/.claude/commands/flow/clarify.md +0 -18
- package/.claude/commands/flow/new.md +0 -23
- package/.claude/commands/flow/quality.md +0 -21
- package/.claude/docs/templates/EPIC_TEMPLATE.md +0 -805
- package/.claude/docs/templates/PRD_TEMPLATE.md +0 -562
- package/.claude/docs/templates/TASKS_TEMPLATE.md +0 -523
- package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +0 -1019
- package/.claude/skills/workflow/CLAUDE.md +0 -24
- /package/.claude/skills/{domain/attention-refresh → attention-refresh}/SKILL.md +0 -0
- /package/.claude/skills/{domain/brainstorming → brainstorming}/SKILL.md +0 -0
- /package/.claude/skills/{guardrail/constitution-guardian → constitution-guardian}/SKILL.md +0 -0
- /package/.claude/skills/{utility/constitution-quick-ref → constitution-quick-ref}/SKILL.md +0 -0
- /package/.claude/skills/{domain/debugging → debugging}/SKILL.md +0 -0
- /package/.claude/skills/{utility/file-standards → file-standards}/SKILL.md +0 -0
- /package/.claude/skills/{domain/finishing-branch → finishing-branch}/SKILL.md +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/CLAUDE.md +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/SKILL.md +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/dev-implementer.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/entry-gate.sh +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/exit-gate.sh +0 -0
- /package/.claude/skills/{workflow/flow-dev → flow-dev}/scripts/task-orchestrator.sh +0 -0
- /package/.claude/skills/{workflow/flow-fix → flow-fix}/SKILL.md +0 -0
- /package/.claude/skills/{workflow/flow-fix → flow-fix}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-fix → flow-fix}/references/bug-analyzer.md +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/assets/BRAINSTORM_TEMPLATE.md +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/assets/INIT_FLOW_TEMPLATE.md +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/assets/RESEARCH_TEMPLATE.md +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/references/flow-researcher.md +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/check-prerequisites.sh +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/consolidate-research.sh +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/create-requirement.sh +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/generate-research-tasks.sh +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/populate-research-tasks.sh +0 -0
- /package/.claude/skills/{workflow/flow-init → flow-init}/scripts/validate-research.sh +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/SKILL.md +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/code-quality-reviewer.md +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/qa-tester.md +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/security-reviewer.md +0 -0
- /package/.claude/skills/{workflow/flow-quality → flow-quality}/references/spec-reviewer.md +0 -0
- /package/.claude/skills/{workflow/flow-release → flow-release}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-release → flow-release}/references/release-manager.md +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/CLAUDE.md +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/context.jsonl +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/entry-gate.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/exit-gate.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/parallel-orchestrator.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-communication.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/team-init.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/scripts/test-team-mode.sh +0 -0
- /package/.claude/skills/{workflow/flow-spec → flow-spec}/team-config.json +0 -0
- /package/.claude/skills/{workflow/flow-verify → flow-verify}/CLAUDE.md +0 -0
- /package/.claude/skills/{workflow/flow-verify → flow-verify}/SKILL.md +0 -0
- /package/.claude/skills/{workflow/flow-verify → flow-verify}/context.jsonl +0 -0
- /package/.claude/skills/{utility/fractal-docs → fractal-docs}/SKILL.md +0 -0
- /package/.claude/skills/{utility/journey-checker → journey-checker}/SKILL.md +0 -0
- /package/.claude/skills/{utility/journey-checker → journey-checker}/pressure-scenarios.md +0 -0
- /package/.claude/skills/{domain/receiving-review → receiving-review}/SKILL.md +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/LICENSE.txt +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/SKILL.md +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/references/output-patterns.md +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/references/workflows.md +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/init_skill.py +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/package_skill.py +0 -0
- /package/.claude/skills/{utility/skill-creator → skill-creator}/scripts/quick_validate.py +0 -0
- /package/.claude/skills/{domain/tdd → tdd}/SKILL.md +0 -0
- /package/.claude/skills/{guardrail/tdd-enforcer → tdd-enforcer}/SKILL.md +0 -0
- /package/.claude/skills/{domain/verification → verification}/SKILL.md +0 -0
|
@@ -57,15 +57,15 @@ const AGENT_SKILL_MAP: Record<string, string> = {
|
|
|
57
57
|
|
|
58
58
|
// Agent type to JSONL filename mapping
|
|
59
59
|
const AGENT_JSONL_MAP: Record<string, string> = {
|
|
60
|
-
'flow-researcher': '
|
|
61
|
-
'prd-writer': '
|
|
62
|
-
'tech-architect': '
|
|
63
|
-
'ui-designer': '
|
|
64
|
-
'planner': '
|
|
65
|
-
'dev-implementer': 'dev
|
|
66
|
-
'qa-tester': '
|
|
67
|
-
'security-reviewer': '
|
|
68
|
-
'release-manager': '
|
|
60
|
+
'flow-researcher': 'brainstorm.jsonl',
|
|
61
|
+
'prd-writer': 'spec.jsonl',
|
|
62
|
+
'tech-architect': 'spec.jsonl',
|
|
63
|
+
'ui-designer': 'spec.jsonl',
|
|
64
|
+
'planner': 'spec.jsonl',
|
|
65
|
+
'dev-implementer': 'dev.jsonl',
|
|
66
|
+
'qa-tester': 'dev.jsonl',
|
|
67
|
+
'security-reviewer': 'dev.jsonl',
|
|
68
|
+
'release-manager': 'dev.jsonl',
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const MAX_FILE_SIZE = 50000; // 50KB per file
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flow:export-openspec
|
|
3
|
+
description: Export CC-DevFlow spec.md to OpenSpec format (pure requirements, no metadata)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /flow:export-openspec - OpenSpec 导出命令
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
将 CC-DevFlow 的 spec.md 导出为 OpenSpec 格式,移除 CC-DevFlow 特定的元数据和实现细节。
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
/flow:export-openspec "REQ-123" --output "<openspec-path>"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
- `REQ-123`: CC-DevFlow 需求 ID (必需)
|
|
21
|
+
- `--output`: OpenSpec spec.md 输出路径 (必需)
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 导出到 OpenSpec 项目
|
|
27
|
+
/flow:export-openspec "REQ-123" \
|
|
28
|
+
--output "/path/to/openspec/changes/add-auth/specs/auth/spec.md"
|
|
29
|
+
|
|
30
|
+
# 导出到当前目录
|
|
31
|
+
/flow:export-openspec "REQ-124" \
|
|
32
|
+
--output "./openspec-export/payments/spec.md"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Workflow
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
1. 读取 devflow/requirements/{REQ-ID}/spec.md
|
|
39
|
+
↓
|
|
40
|
+
2. 解析 CC-DevFlow 格式
|
|
41
|
+
- 跳过 YAML frontmatter
|
|
42
|
+
- 提取 Purpose
|
|
43
|
+
- 提取 Requirements (with BDD scenarios)
|
|
44
|
+
- 忽略 Design / Tasks / Verification
|
|
45
|
+
↓
|
|
46
|
+
3. 转换为 OpenSpec 格式
|
|
47
|
+
- 移除所有元数据
|
|
48
|
+
- 移除 [NEEDS CLARIFICATION] 标记
|
|
49
|
+
- 保留纯 Requirements
|
|
50
|
+
↓
|
|
51
|
+
4. 写入 OpenSpec spec.md
|
|
52
|
+
↓
|
|
53
|
+
5. 输出转换结果
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## CC-DevFlow Format (Input)
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
---
|
|
60
|
+
req_id: "REQ-123"
|
|
61
|
+
title: "用户认证系统"
|
|
62
|
+
created_at: "2026-03-13T10:00:00Z"
|
|
63
|
+
version: "1.0.0"
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
# Authentication Module
|
|
67
|
+
|
|
68
|
+
## Purpose
|
|
69
|
+
Provides secure authentication.
|
|
70
|
+
|
|
71
|
+
## Requirements
|
|
72
|
+
|
|
73
|
+
### Requirement: User Login
|
|
74
|
+
The system SHALL allow login.
|
|
75
|
+
|
|
76
|
+
#### Scenario: Valid credentials
|
|
77
|
+
- GIVEN a registered user
|
|
78
|
+
- WHEN the user submits credentials
|
|
79
|
+
- THEN a JWT token is issued
|
|
80
|
+
|
|
81
|
+
## Design
|
|
82
|
+
[NEEDS CLARIFICATION: Implementation details]
|
|
83
|
+
|
|
84
|
+
## Tasks
|
|
85
|
+
- [ ] T001 [TEST] User Login - 测试
|
|
86
|
+
- [ ] T002 [IMPL] User Login - 实现
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## OpenSpec Format (Output)
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
# Authentication Module
|
|
93
|
+
|
|
94
|
+
## Purpose
|
|
95
|
+
Provides secure authentication.
|
|
96
|
+
|
|
97
|
+
## Requirements
|
|
98
|
+
|
|
99
|
+
### Requirement: User Login
|
|
100
|
+
The system SHALL allow login.
|
|
101
|
+
|
|
102
|
+
#### Scenario: Valid credentials
|
|
103
|
+
- GIVEN a registered user
|
|
104
|
+
- WHEN the user submits credentials
|
|
105
|
+
- THEN a JWT token is issued
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## What Gets Removed
|
|
109
|
+
|
|
110
|
+
- ❌ YAML frontmatter (req_id, title, version, etc.)
|
|
111
|
+
- ❌ `## Design` section
|
|
112
|
+
- ❌ `## Tasks` section
|
|
113
|
+
- ❌ `## Verification` section
|
|
114
|
+
- ❌ `[NEEDS CLARIFICATION]` markers
|
|
115
|
+
- ❌ TDD task annotations ([TEST], [IMPL])
|
|
116
|
+
- ❌ CC-DevFlow specific metadata
|
|
117
|
+
|
|
118
|
+
## What Gets Preserved
|
|
119
|
+
|
|
120
|
+
- ✅ Module name (# heading)
|
|
121
|
+
- ✅ `## Purpose` section
|
|
122
|
+
- ✅ `## Requirements` section
|
|
123
|
+
- ✅ Requirement names and descriptions
|
|
124
|
+
- ✅ BDD scenarios (Given-When-Then)
|
|
125
|
+
- ✅ RFC 2119 keywords (SHALL, MUST, SHOULD, MAY)
|
|
126
|
+
|
|
127
|
+
## Error Handling
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# REQ-ID 不存在
|
|
131
|
+
Error: REQ-123 not found in devflow/requirements/
|
|
132
|
+
|
|
133
|
+
# spec.md 不存在
|
|
134
|
+
Error: spec.md not found for REQ-123
|
|
135
|
+
|
|
136
|
+
# 输出目录不可写
|
|
137
|
+
Error: Cannot write to /path/to/openspec/
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Output
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"success": true,
|
|
145
|
+
"outputPath": "/path/to/openspec/changes/add-auth/specs/auth/spec.md",
|
|
146
|
+
"requirementsCount": 3
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Implementation
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
node .claude/scripts/export-openspec.js \
|
|
154
|
+
"devflow/requirements/<req-id>/spec.md" \
|
|
155
|
+
"<output-path>"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Use Cases
|
|
159
|
+
|
|
160
|
+
### 1. 贡献到 OpenSpec 项目
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# 在 CC-DevFlow 中开发完成
|
|
164
|
+
/flow:dev "REQ-123"
|
|
165
|
+
/flow:verify "REQ-123"
|
|
166
|
+
|
|
167
|
+
# 导出为 OpenSpec 格式
|
|
168
|
+
/flow:export-openspec "REQ-123" \
|
|
169
|
+
--output "/path/to/openspec/changes/add-feature/specs/module/spec.md"
|
|
170
|
+
|
|
171
|
+
# 提交到 OpenSpec 项目
|
|
172
|
+
cd /path/to/openspec
|
|
173
|
+
git add changes/add-feature/
|
|
174
|
+
git commit -m "Add feature specification"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 2. 共享需求规格
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# 导出纯需求文档(无实现细节)
|
|
181
|
+
/flow:export-openspec "REQ-124" \
|
|
182
|
+
--output "./shared-specs/payments.md"
|
|
183
|
+
|
|
184
|
+
# 分享给产品团队或其他项目
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3. 需求归档
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# 导出为标准格式归档
|
|
191
|
+
/flow:export-openspec "REQ-125" \
|
|
192
|
+
--output "./archive/specs/feature-v1.0.md"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Round-Trip Compatibility
|
|
196
|
+
|
|
197
|
+
OpenSpec ↔ CC-DevFlow 双向转换保持需求完整性:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Import: OpenSpec → CC-DevFlow
|
|
201
|
+
/flow:import-openspec "openspec/spec.md" --req-id "REQ-123" --title "Feature"
|
|
202
|
+
→ 生成 spec.md + 自动补充 TDD 任务
|
|
203
|
+
|
|
204
|
+
# Develop in CC-DevFlow
|
|
205
|
+
/flow:spec "REQ-123"
|
|
206
|
+
/flow:dev "REQ-123"
|
|
207
|
+
|
|
208
|
+
# Export: CC-DevFlow → OpenSpec
|
|
209
|
+
/flow:export-openspec "REQ-123" --output "openspec/spec.md"
|
|
210
|
+
→ 移除实现细节,保留纯需求
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Related Commands
|
|
214
|
+
|
|
215
|
+
- `/flow:import-openspec` - Import OpenSpec spec to CC-DevFlow
|
|
216
|
+
- `/flow:spec` - Generate task-manifest from spec.md
|
|
217
|
+
- `/flow:archive` - Archive completed requirements
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
**[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flow:import-openspec
|
|
3
|
+
description: Import OpenSpec spec.md and convert to CC-DevFlow format with TDD tasks
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /flow:import-openspec - OpenSpec 导入命令
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
从 OpenSpec 项目导入 spec.md 文件,转换为 CC-DevFlow 格式,自动补充 TDD 任务。
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
/flow:import-openspec "<openspec-path>" --req-id "REQ-123" --title "功能标题"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Parameters
|
|
19
|
+
|
|
20
|
+
- `<openspec-path>`: OpenSpec spec.md 文件的绝对路径或相对路径
|
|
21
|
+
- `--req-id`: CC-DevFlow 需求 ID (必需)
|
|
22
|
+
- `--title`: 需求标题 (必需)
|
|
23
|
+
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# 导入 OpenSpec 认证模块
|
|
28
|
+
/flow:import-openspec "/path/to/openspec/changes/add-auth/specs/auth/spec.md" \
|
|
29
|
+
--req-id "REQ-123" \
|
|
30
|
+
--title "用户认证系统"
|
|
31
|
+
|
|
32
|
+
# 导入支付模块
|
|
33
|
+
/flow:import-openspec "./openspec/specs/payments/spec.md" \
|
|
34
|
+
--req-id "REQ-124" \
|
|
35
|
+
--title "支付功能"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Workflow
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
1. 读取 OpenSpec spec.md
|
|
42
|
+
↓
|
|
43
|
+
2. 解析 OpenSpec 格式
|
|
44
|
+
- Purpose
|
|
45
|
+
- Requirements (with BDD scenarios)
|
|
46
|
+
↓
|
|
47
|
+
3. 转换为 CC-DevFlow 格式
|
|
48
|
+
- 添加 YAML frontmatter
|
|
49
|
+
- 保留 Purpose + Requirements
|
|
50
|
+
- 添加 Design 部分 (标记 [NEEDS CLARIFICATION])
|
|
51
|
+
- 自动生成 TDD 任务 (TEST + IMPL)
|
|
52
|
+
- 生成 Verification 清单
|
|
53
|
+
↓
|
|
54
|
+
4. 写入 devflow/requirements/{REQ-ID}/spec.md
|
|
55
|
+
↓
|
|
56
|
+
5. 输出转换结果
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## OpenSpec Format (Input)
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
# Module Name
|
|
63
|
+
|
|
64
|
+
## Purpose
|
|
65
|
+
High-level description of the module.
|
|
66
|
+
|
|
67
|
+
## Requirements
|
|
68
|
+
|
|
69
|
+
### Requirement: Feature Name
|
|
70
|
+
The system SHALL/MUST/SHOULD/MAY do something.
|
|
71
|
+
|
|
72
|
+
#### Scenario: Case Name
|
|
73
|
+
- GIVEN precondition
|
|
74
|
+
- WHEN action
|
|
75
|
+
- THEN expected result
|
|
76
|
+
- AND additional assertion
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## CC-DevFlow Format (Output)
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
---
|
|
83
|
+
req_id: "REQ-123"
|
|
84
|
+
title: "功能标题"
|
|
85
|
+
created_at: "2026-03-13T10:00:00Z"
|
|
86
|
+
updated_at: "2026-03-13T10:00:00Z"
|
|
87
|
+
version: "1.0.0"
|
|
88
|
+
status: "draft"
|
|
89
|
+
source: "openspec"
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
# Module Name
|
|
93
|
+
|
|
94
|
+
## Purpose
|
|
95
|
+
[Preserved from OpenSpec]
|
|
96
|
+
|
|
97
|
+
## Requirements
|
|
98
|
+
[Preserved from OpenSpec with BDD scenarios]
|
|
99
|
+
|
|
100
|
+
## Design
|
|
101
|
+
[NEEDS CLARIFICATION: 技术实现方案]
|
|
102
|
+
|
|
103
|
+
## Tasks
|
|
104
|
+
- [ ] T001 [TEST] Feature Name - 测试
|
|
105
|
+
- [ ] T002 [IMPL] Feature Name - 实现 (dependsOn:T001)
|
|
106
|
+
|
|
107
|
+
## Verification
|
|
108
|
+
- [ ] Feature Name
|
|
109
|
+
- [ ] Scenario 1
|
|
110
|
+
- [ ] Scenario 2
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Auto-Generated TDD Tasks
|
|
114
|
+
|
|
115
|
+
For each Requirement in OpenSpec:
|
|
116
|
+
1. **TEST task** (T001, T003, T005...)
|
|
117
|
+
2. **IMPL task** (T002, T004, T006...) with `dependsOn` to TEST
|
|
118
|
+
|
|
119
|
+
This ensures Constitution Article VI compliance (Test-First Development).
|
|
120
|
+
|
|
121
|
+
## Error Handling
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# OpenSpec 文件不存在
|
|
125
|
+
Error: OpenSpec file not found: /path/to/spec.md
|
|
126
|
+
|
|
127
|
+
# REQ-ID 格式错误
|
|
128
|
+
Error: Invalid REQ-ID format. Expected: REQ-\d+
|
|
129
|
+
|
|
130
|
+
# REQ-ID 已存在
|
|
131
|
+
Error: REQ-123 already exists in devflow/requirements/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Output
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"success": true,
|
|
139
|
+
"outputPath": "devflow/requirements/REQ-123/spec.md",
|
|
140
|
+
"requirementsCount": 3,
|
|
141
|
+
"tasksCount": 6
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Implementation
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
node .claude/scripts/import-openspec.js \
|
|
149
|
+
"<openspec-path>" \
|
|
150
|
+
"<req-id>" \
|
|
151
|
+
"<title>" \
|
|
152
|
+
"devflow/requirements/<req-id>/spec.md"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Next Steps
|
|
156
|
+
|
|
157
|
+
After import:
|
|
158
|
+
1. Review generated spec.md
|
|
159
|
+
2. Fill in `[NEEDS CLARIFICATION]` sections in Design
|
|
160
|
+
3. Run `/flow:spec "REQ-123"` to generate task-manifest.json
|
|
161
|
+
4. Proceed with `/flow:dev "REQ-123"`
|
|
162
|
+
|
|
163
|
+
## Related Commands
|
|
164
|
+
|
|
165
|
+
- `/flow:export-openspec` - Export CC-DevFlow spec to OpenSpec format
|
|
166
|
+
- `/flow:spec` - Generate task-manifest from spec.md
|
|
167
|
+
- `/flow:init` - Initialize new requirement (alternative to import)
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
**[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenSpec 互操作测试
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const { parseOpenSpecMarkdown, convertToDevFlowSpec } = require('../import-openspec');
|
|
6
|
+
const { parseDevFlowSpec, convertToOpenSpec } = require('../export-openspec');
|
|
7
|
+
|
|
8
|
+
describe('OpenSpec Import', () => {
|
|
9
|
+
test('should parse OpenSpec format correctly', () => {
|
|
10
|
+
const openspecContent = `# Authentication Module
|
|
11
|
+
|
|
12
|
+
## Purpose
|
|
13
|
+
Provides secure authentication and session management.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
### Requirement: User Login
|
|
18
|
+
The system SHALL allow users to log in with email and password.
|
|
19
|
+
|
|
20
|
+
#### Scenario: Valid credentials
|
|
21
|
+
- GIVEN a registered user
|
|
22
|
+
- WHEN the user submits valid email and password
|
|
23
|
+
- THEN a JWT token is issued
|
|
24
|
+
- AND the user is redirected to dashboard
|
|
25
|
+
|
|
26
|
+
#### Scenario: Invalid credentials
|
|
27
|
+
- GIVEN a registered user
|
|
28
|
+
- WHEN the user submits invalid password
|
|
29
|
+
- THEN an error message is displayed
|
|
30
|
+
- AND no token is issued
|
|
31
|
+
|
|
32
|
+
### Requirement: Session Management
|
|
33
|
+
The system MUST expire sessions after 30 minutes of inactivity.
|
|
34
|
+
|
|
35
|
+
#### Scenario: Idle timeout
|
|
36
|
+
- GIVEN an authenticated session
|
|
37
|
+
- WHEN 30 minutes pass without activity
|
|
38
|
+
- THEN the session is invalidated
|
|
39
|
+
- AND the user must re-authenticate
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const result = parseOpenSpecMarkdown(openspecContent);
|
|
43
|
+
|
|
44
|
+
expect(result.moduleName).toBe('Authentication Module');
|
|
45
|
+
expect(result.purpose).toContain('secure authentication');
|
|
46
|
+
expect(result.requirements).toHaveLength(2);
|
|
47
|
+
expect(result.requirements[0].name).toBe('User Login');
|
|
48
|
+
expect(result.requirements[0].scenarios).toHaveLength(2);
|
|
49
|
+
expect(result.requirements[0].scenarios[0].name).toBe('Valid credentials');
|
|
50
|
+
expect(result.requirements[0].scenarios[0].steps).toHaveLength(4);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('should convert to DevFlow spec with TDD tasks', () => {
|
|
54
|
+
const openspecData = {
|
|
55
|
+
moduleName: 'Auth Module',
|
|
56
|
+
purpose: 'Authentication',
|
|
57
|
+
requirements: [
|
|
58
|
+
{
|
|
59
|
+
name: 'User Login',
|
|
60
|
+
description: 'Login functionality',
|
|
61
|
+
scenarios: [
|
|
62
|
+
{
|
|
63
|
+
name: 'Valid credentials',
|
|
64
|
+
steps: ['GIVEN a user', 'WHEN login', 'THEN success']
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Session Management',
|
|
70
|
+
description: 'Session handling',
|
|
71
|
+
scenarios: [
|
|
72
|
+
{
|
|
73
|
+
name: 'Timeout',
|
|
74
|
+
steps: ['GIVEN session', 'WHEN timeout', 'THEN invalidate']
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const devflowSpec = convertToDevFlowSpec(openspecData, 'REQ-123', 'Auth System');
|
|
82
|
+
|
|
83
|
+
expect(devflowSpec).toContain('req_id: "REQ-123"');
|
|
84
|
+
expect(devflowSpec).toContain('title: "Auth System"');
|
|
85
|
+
expect(devflowSpec).toContain('## Purpose');
|
|
86
|
+
expect(devflowSpec).toContain('## Requirements');
|
|
87
|
+
expect(devflowSpec).toContain('## Design');
|
|
88
|
+
expect(devflowSpec).toContain('## Tasks');
|
|
89
|
+
expect(devflowSpec).toContain('[TEST] User Login - 测试');
|
|
90
|
+
expect(devflowSpec).toContain('[IMPL] User Login - 实现 (dependsOn:T001)');
|
|
91
|
+
expect(devflowSpec).toContain('[TEST] Session Management - 测试');
|
|
92
|
+
expect(devflowSpec).toContain('[IMPL] Session Management - 实现 (dependsOn:T003)');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('OpenSpec Export', () => {
|
|
97
|
+
test('should parse DevFlow spec correctly', () => {
|
|
98
|
+
const devflowContent = `---
|
|
99
|
+
req_id: "REQ-123"
|
|
100
|
+
title: "Auth System"
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
# Authentication Module
|
|
104
|
+
|
|
105
|
+
## Purpose
|
|
106
|
+
|
|
107
|
+
Provides secure authentication.
|
|
108
|
+
|
|
109
|
+
## Requirements
|
|
110
|
+
|
|
111
|
+
### Requirement: User Login
|
|
112
|
+
|
|
113
|
+
The system SHALL allow login.
|
|
114
|
+
|
|
115
|
+
#### Scenario: Valid credentials
|
|
116
|
+
- GIVEN a registered user
|
|
117
|
+
- WHEN the user submits credentials
|
|
118
|
+
- THEN a JWT token is issued
|
|
119
|
+
|
|
120
|
+
### Requirement: Session Management
|
|
121
|
+
|
|
122
|
+
The system MUST expire sessions.
|
|
123
|
+
|
|
124
|
+
## Design
|
|
125
|
+
|
|
126
|
+
[NEEDS CLARIFICATION: Implementation details]
|
|
127
|
+
|
|
128
|
+
## Tasks
|
|
129
|
+
|
|
130
|
+
- [ ] T001 [TEST] User Login - 测试
|
|
131
|
+
- [ ] T002 [IMPL] User Login - 实现 (dependsOn:T001)
|
|
132
|
+
`;
|
|
133
|
+
|
|
134
|
+
const result = parseDevFlowSpec(devflowContent);
|
|
135
|
+
|
|
136
|
+
expect(result.moduleName).toBe('Authentication Module');
|
|
137
|
+
expect(result.purpose).toContain('secure authentication');
|
|
138
|
+
expect(result.requirements).toHaveLength(2);
|
|
139
|
+
expect(result.requirements[0].name).toBe('User Login');
|
|
140
|
+
expect(result.requirements[0].scenarios).toHaveLength(1);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('should convert to OpenSpec format without metadata', () => {
|
|
144
|
+
const devflowData = {
|
|
145
|
+
moduleName: 'Auth Module',
|
|
146
|
+
purpose: 'Authentication',
|
|
147
|
+
requirements: [
|
|
148
|
+
{
|
|
149
|
+
name: 'User Login',
|
|
150
|
+
description: 'Login functionality',
|
|
151
|
+
scenarios: [
|
|
152
|
+
{
|
|
153
|
+
name: 'Valid credentials',
|
|
154
|
+
steps: ['GIVEN a user', 'WHEN login', 'THEN success']
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const openspecContent = convertToOpenSpec(devflowData);
|
|
162
|
+
|
|
163
|
+
expect(openspecContent).toContain('# Auth Module');
|
|
164
|
+
expect(openspecContent).toContain('## Purpose');
|
|
165
|
+
expect(openspecContent).toContain('## Requirements');
|
|
166
|
+
expect(openspecContent).toContain('### Requirement: User Login');
|
|
167
|
+
expect(openspecContent).toContain('#### Scenario: Valid credentials');
|
|
168
|
+
expect(openspecContent).not.toContain('req_id');
|
|
169
|
+
expect(openspecContent).not.toContain('---');
|
|
170
|
+
expect(openspecContent).not.toContain('[NEEDS CLARIFICATION');
|
|
171
|
+
expect(openspecContent).not.toContain('## Design');
|
|
172
|
+
expect(openspecContent).not.toContain('## Tasks');
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('Round-trip conversion', () => {
|
|
177
|
+
test('should preserve requirements through import-export cycle', () => {
|
|
178
|
+
const originalOpenSpec = `# Test Module
|
|
179
|
+
|
|
180
|
+
## Purpose
|
|
181
|
+
Test purpose
|
|
182
|
+
|
|
183
|
+
## Requirements
|
|
184
|
+
|
|
185
|
+
### Requirement: Feature A
|
|
186
|
+
Description A
|
|
187
|
+
|
|
188
|
+
#### Scenario: Case 1
|
|
189
|
+
- GIVEN condition
|
|
190
|
+
- WHEN action
|
|
191
|
+
- THEN result
|
|
192
|
+
`;
|
|
193
|
+
|
|
194
|
+
// Import to DevFlow
|
|
195
|
+
const openspecData = parseOpenSpecMarkdown(originalOpenSpec);
|
|
196
|
+
const devflowSpec = convertToDevFlowSpec(openspecData, 'REQ-001', 'Test');
|
|
197
|
+
|
|
198
|
+
// Export back to OpenSpec
|
|
199
|
+
const devflowData = parseDevFlowSpec(devflowSpec);
|
|
200
|
+
const exportedOpenSpec = convertToOpenSpec(devflowData);
|
|
201
|
+
|
|
202
|
+
// Verify requirements preserved
|
|
203
|
+
expect(exportedOpenSpec).toContain('# Test Module');
|
|
204
|
+
expect(exportedOpenSpec).toContain('## Purpose');
|
|
205
|
+
expect(exportedOpenSpec).toContain('Test purpose');
|
|
206
|
+
expect(exportedOpenSpec).toContain('### Requirement: Feature A');
|
|
207
|
+
expect(exportedOpenSpec).toContain('#### Scenario: Case 1');
|
|
208
|
+
expect(exportedOpenSpec).toContain('- GIVEN condition');
|
|
209
|
+
expect(exportedOpenSpec).toContain('- WHEN action');
|
|
210
|
+
expect(exportedOpenSpec).toContain('- THEN result');
|
|
211
|
+
});
|
|
212
|
+
});
|