dflow-sdd-ddd 0.9.0 → 0.10.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 (46) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.en.md +19 -8
  3. package/README.md +12 -5
  4. package/TEMPLATE-COVERAGE.md +0 -1
  5. package/bin/dflow.js +4 -4
  6. package/docs/evaluating-dflow.en.md +11 -7
  7. package/docs/evaluating-dflow.md +9 -4
  8. package/docs/migrating-to-dflow-v1.md +7 -3
  9. package/docs/using-with-claude-code.en.md +40 -23
  10. package/docs/using-with-claude-code.md +34 -23
  11. package/docs/using-with-codex.en.md +125 -42
  12. package/docs/using-with-codex.md +93 -34
  13. package/docs/using-with-github-copilot.en.md +135 -34
  14. package/docs/using-with-github-copilot.md +120 -43
  15. package/lib/init.js +761 -145
  16. package/package.json +2 -2
  17. package/templates/brownfield/references/drift-verification.md +1 -4
  18. package/templates/brownfield/references/finish-feature-flow.md +3 -2
  19. package/templates/brownfield/references/git-integration.md +0 -1
  20. package/templates/brownfield/references/init-project-flow.md +31 -17
  21. package/templates/brownfield/references/modify-existing-flow.md +6 -38
  22. package/templates/brownfield/references/new-feature-flow.md +13 -11
  23. package/templates/brownfield/references/new-phase-flow.md +1 -1
  24. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +253 -2
  25. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  26. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  27. package/templates/brownfield/templates/_index.md +1 -1
  28. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  29. package/templates/brownfield/templates/phase-spec.md +1 -1
  30. package/templates/common/skill/SKILL.md +9 -6
  31. package/templates/greenfield/references/drift-verification.md +1 -4
  32. package/templates/greenfield/references/finish-feature-flow.md +3 -2
  33. package/templates/greenfield/references/git-integration.md +0 -1
  34. package/templates/greenfield/references/init-project-flow.md +31 -17
  35. package/templates/greenfield/references/modify-existing-flow.md +5 -7
  36. package/templates/greenfield/references/new-feature-flow.md +14 -12
  37. package/templates/greenfield/references/new-phase-flow.md +1 -1
  38. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +222 -2
  39. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  40. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  41. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  42. package/templates/greenfield/templates/_index.md +1 -1
  43. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  44. package/templates/greenfield/templates/phase-spec.md +1 -1
  45. package/templates/brownfield/templates/CLAUDE.md +0 -165
  46. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -1,172 +0,0 @@
1
- # Project: {系統名稱} — Clean Architecture + DDD
2
-
3
- **重要:所有開發工作都必須遵循本文件定義的流程。**
4
-
5
- ---
6
-
7
- ## System Context
8
-
9
- > 技術棧、架構、業務領域、目錄結構
10
-
11
- ### Background
12
-
13
- 這是一個遵循 Clean Architecture 與 Domain-Driven Design 的新建專案;具體 stack 詳見 `dflow/specs/shared/_overview.md`。
14
- 採用 SDD 流程,所有開發工作必須遵循本文件定義的流程。
15
-
16
- ### Architecture (Clean Architecture)
17
-
18
- ```
19
- Presentation → Application → Domain ← Infrastructure
20
- ```
21
-
22
- 依賴方向永遠朝內。Domain 層是核心,不依賴任何外部套件。
23
-
24
- **各層職責**
25
-
26
- | 層 | 職責 | 不可以做的事 |
27
- |---|---|---|
28
- | Domain | 業務規則、Aggregate、Value Object、Domain Event | 依賴外部套件、存取資料庫、處理 HTTP |
29
- | Application | 編排領域操作、CQRS、驗證、DTO | 包含業務邏輯、直接存取資料庫 |
30
- | Infrastructure | {ORM / persistence}、外部 API、檔案存取 | 包含業務邏輯 |
31
- | Presentation | HTTP 端點、Request/Response | 包含業務邏輯、直接操作 Domain 物件 |
32
-
33
- ### Project Structure
34
-
35
- ```
36
- dflow/specs/
37
- ├── shared/ # 專案級治理文件(由 dflow init 寫入)
38
- │ ├── _overview.md # 系統概覽與架構方向
39
- │ └── _conventions.md # 規格撰寫慣例
40
- ├── domain/
41
- │ ├── glossary.md
42
- │ ├── context-map.md
43
- │ └── {context}/
44
- │ ├── context.md
45
- │ ├── models.md
46
- │ ├── rules.md
47
- │ └── events.md # Domain Events 目錄
48
- ├── features/
49
- │ ├── active/ # 進行中的 feature
50
- │ │ └── {SPEC-ID}-{slug}/ # 一個 feature 一個目錄
51
- │ │ ├── _index.md # Feature dashboard:Goals & Scope / Phase Specs / Current BR Snapshot / Lightweight Changes / Resume Pointer
52
- │ │ ├── phase-spec-YYYY-MM-DD-{slug}.md # T1 Heavy:每 phase 一份
53
- │ │ └── lightweight-YYYY-MM-DD-{slug}.md # T2 Light(或 BUG-NNN-{slug}.md)
54
- │ ├── completed/ # 整個 feature 目錄 git mv 到這裡
55
- │ └── backlog/
56
- │ # SPEC-ID 格式:SPEC-YYYYMMDD-NNN;slug 跟隨討論語言(中文/英文皆可)
57
- │ # T3 無獨立檔,只在 _index.md Lightweight Changes 寫一列
58
- └── architecture/
59
- ├── decisions/ # ADR
60
- └── tech-debt.md
61
-
62
- src/
63
- ├── {Project}.Domain/
64
- ├── {Project}.Application/
65
- ├── {Project}.Infrastructure/
66
- └── {Project}.WebAPI/
67
-
68
- tests/
69
- ├── Domain.UnitTests/
70
- ├── Application.UnitTests/
71
- └── Integration.Tests/
72
- ```
73
-
74
- ---
75
-
76
- ## Development Workflow
77
-
78
- > SDD 流程、Git 整合、Domain 層規範、AI 協作
79
-
80
- ### Core Principles
81
- 1. **Spec Before Code** — 沒有規格就不寫實作
82
- 2. **Domain at the Center** — 業務邏輯只存在於 Domain 層
83
- 3. **Ubiquitous Language** — 使用 `dflow/specs/domain/glossary.md` 中定義的術語
84
- 4. **One Aggregate per Transaction** — 單一操作只修改一個 Aggregate
85
- 5. **Dependency Inversion** — Domain 定義介面,Infrastructure 實作
86
-
87
- ### Three Ceremony Tiers
88
-
89
- 不是每次修改都要跑完整流程。AI 依下列判準選 tier:
90
-
91
- - **T1 Heavy** — 新功能、新 phase、新 Aggregate / BC、新增 BR、新 Domain Event →
92
- 建獨立 phase-spec,走 `/dflow:new-feature` 或 `/dflow:new-phase`
93
- - **T2 Light** — bug fix(邏輯錯誤)、UI 輸入驗證、流程分支修改(有 BR Delta
94
- 但無 Aggregate / 資料結構動)→ 建獨立 lightweight spec 置於 feature 目錄內
95
- - **T3 Trivial** — 按鈕顏色、文案修正、typo、排版、純註解(無 BR 變動、
96
- 無 Domain 概念動、無資料結構動、只改 UI 表層 / 註解 / 格式化)→
97
- 只在 `_index.md` Lightweight Changes inline 寫一列
98
-
99
- 純 typo / 純格式化 commit(`dotnet format` / `prettier` 自動整理)**低於 T3**:
100
- 直接 `git commit`,不走 Dflow。
101
-
102
- ### New Feature
103
- 1. 建 feature 目錄 `dflow/specs/features/active/{SPEC-ID}-{slug}/`
104
- 2. 建 `_index.md`(feature dashboard)+ 第一份 `phase-spec-YYYY-MM-DD-{slug}.md`
105
- 3. 設計 Aggregate(不變條件、狀態變更方法、Domain Events)
106
- 4. 實作順序:Domain → Application → Infrastructure → Presentation
107
- 5. 撰寫測試:Domain 單元測試 → Application 測試 → 整合測試
108
-
109
- ### New Phase
110
- 1. 在已啟動的 active feature 上新增一份 phase-spec(含 Delta-from-prior-phases)
111
- 2. 更新 `_index.md` 的 Phase Specs 表 + regenerate Current BR Snapshot
112
- 3. 嚴格只適用於 active feature;completed 的 feature 不接受新 phase
113
-
114
- ### Modify Existing
115
- 1. AI 依 T1 / T2 / T3 判準分流
116
- 2. 若偵測到改動與 completed feature 相關,主動詢問是否為 follow-up
117
- (follow-up 走新建 feature + `follow-up-of` 鏈回原 feature;不把 T2/T3
118
- 寫回 completed 目錄)
119
- 3. 確認 fix 在正確的 Clean Architecture 層
120
-
121
- ### Bug Fix
122
- 1. 建立輕量規格
123
- 2. 若 bug 不附掛既有 feature,先建最小 feature 目錄再放 lightweight-spec
124
- 3. 找到問題所在的層
125
- 4. 在正確的層修復
126
-
127
- ### Feature Closeout
128
- 1. 驗證 feature 目錄內所有 phase-spec `status: completed`
129
- 2. 把 `_index.md` Current BR Snapshot 同步到 BC 層 `rules.md` /
130
- `behavior.md` / `events.md` / `context-map.md`
131
- 3. `git mv` 整個 feature 目錄從 `active/` 搬到 `completed/`
132
- 4. 產出 Integration Summary(Git-strategy-neutral;不自動 merge)
133
-
134
- ### Git Integration
135
-
136
- > 本流程只規定 SDD 必要的最小 Git 耦合(feature branch per feature、
137
- > `git mv`、commit 對應 SPEC-ID)。實際採用的分支策略(Git Flow /
138
- > GitHub Flow / trunk-based / 單一 main)由專案決定,不在此強制。
139
- > 若採用 Git Flow,可參考 `scaffolding/Git-principles-gitflow.md` 範本。
140
-
141
- **分支命名**
142
- ```
143
- feature/{SPEC-ID}-{short-description} # 新功能(SDD 必須)
144
- bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
145
- ```
146
-
147
- **Commit Message**
148
- ```
149
- [SPEC-ID] 簡述變更
150
- ```
151
-
152
- > `/dflow:bug-fix` 不綁定任何分支策略;採 Git Flow 的專案可選擇把緊急修復
153
- > 放在 `hotfix/` 分支,但這是專案決策,Dflow 不代為規定。
154
-
155
- ### Domain Layer Rules
156
-
157
- - ❌ 不可有任何外部套件依賴(語言純粹 types)
158
- - ❌ 不可有 ORM 屬性([Table], [Column] 等)
159
- - ❌ 不可有序列化屬性([JsonProperty] 等)
160
- - ❌ 不可有 DbContext、IConfiguration、HttpClient
161
- - ✅ Entity 使用 private setter,透過方法改變狀態
162
- - ✅ Value Object 使用 record,建構式驗證
163
- - ✅ Aggregate Root 管理 DomainEvents 集合
164
- - ✅ 其他 Aggregate 只透過 ID 引用
165
-
166
- ### AI Collaboration Notes
167
-
168
- - 開發者提出任何需求時,先引導建立 spec 和 Aggregate 設計
169
- - 確認實作順序:Domain → Application → Infrastructure → Presentation
170
- - 發現業務邏輯在錯誤的層時,指出並建議搬移
171
- - 每次開發循環結束時,提醒更新術語表、models.md、events.md
172
- - Review 時檢查 Domain 層的純淨度(零外部依賴)