dflow-sdd-ddd 0.1.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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -0
  3. package/bin/dflow.js +72 -0
  4. package/lib/init.js +1206 -0
  5. package/package.json +42 -0
  6. package/templates/core/scaffolding/CLAUDE-md-snippet.md +168 -0
  7. package/templates/core/scaffolding/Git-principles-gitflow.md +350 -0
  8. package/templates/core/scaffolding/Git-principles-trunk.md +375 -0
  9. package/templates/core/scaffolding/_conventions.md +175 -0
  10. package/templates/core/scaffolding/_overview.md +165 -0
  11. package/templates/core/scaffolding/architecture-decisions-README.md +34 -0
  12. package/templates/core/templates/CLAUDE.md +172 -0
  13. package/templates/core/templates/_index.md +118 -0
  14. package/templates/core/templates/aggregate-design.md +58 -0
  15. package/templates/core/templates/behavior.md +62 -0
  16. package/templates/core/templates/context-definition.md +64 -0
  17. package/templates/core/templates/context-map.md +25 -0
  18. package/templates/core/templates/events.md +19 -0
  19. package/templates/core/templates/glossary.md +15 -0
  20. package/templates/core/templates/lightweight-spec.md +82 -0
  21. package/templates/core/templates/models.md +47 -0
  22. package/templates/core/templates/phase-spec.md +195 -0
  23. package/templates/core/templates/rules.md +24 -0
  24. package/templates/core/templates/tech-debt.md +15 -0
  25. package/templates/webforms/scaffolding/CLAUDE-md-snippet.md +167 -0
  26. package/templates/webforms/scaffolding/Git-principles-gitflow.md +333 -0
  27. package/templates/webforms/scaffolding/Git-principles-trunk.md +316 -0
  28. package/templates/webforms/scaffolding/_conventions.md +139 -0
  29. package/templates/webforms/scaffolding/_overview.md +109 -0
  30. package/templates/webforms/templates/CLAUDE.md +157 -0
  31. package/templates/webforms/templates/_index.md +110 -0
  32. package/templates/webforms/templates/behavior.md +58 -0
  33. package/templates/webforms/templates/context-definition.md +57 -0
  34. package/templates/webforms/templates/context-map.md +25 -0
  35. package/templates/webforms/templates/glossary.md +15 -0
  36. package/templates/webforms/templates/lightweight-spec.md +82 -0
  37. package/templates/webforms/templates/models.md +39 -0
  38. package/templates/webforms/templates/phase-spec.md +187 -0
  39. package/templates/webforms/templates/rules.md +24 -0
  40. package/templates/webforms/templates/tech-debt.md +15 -0
@@ -0,0 +1,82 @@
1
+ ---
2
+ id: BUG-{NUMBER}
3
+ title: {簡述問題}
4
+ status: in-progress
5
+ bounded-context: {ContextName}
6
+ created: {YYYY-MM-DD}
7
+ branch: bugfix/BUG-{NUMBER}-{short-description}
8
+ ---
9
+
10
+ <!--
11
+ Template note (for AI):
12
+ This is the **lightweight-spec** template — it corresponds to T2 Light
13
+ ceremony in the three-tier Ceremony Scaling (T1 Heavy / T2 Light /
14
+ T3 Trivial; see SKILL.md § Ceremony Scaling for the tier criteria).
15
+
16
+ - T1 Heavy → use templates/phase-spec.md instead
17
+ - T2 Light → THIS template; produces an independent file
18
+ - T3 Trivial → no independent file; just one inline row in _index.md
19
+ Lightweight Changes with a tag like [cosmetic] / [text] / [format]
20
+
21
+ Instance file location and naming:
22
+ Place the instantiated file inside the corresponding feature directory:
23
+ dflow/specs/features/active/{SPEC-ID}-{slug}/lightweight-{YYYY-MM-DD}-{slug}.md
24
+ or, when the lightweight change is a tracked bug:
25
+ dflow/specs/features/active/{SPEC-ID}-{slug}/BUG-{NUMBER}-{slug}.md
26
+
27
+ If the change is a standalone bug not yet attached to any existing
28
+ feature, /dflow:bug-fix must first create a feature directory (with a
29
+ minimal _index.md) before placing the lightweight-spec instance inside.
30
+ This keeps the structure invariant: every spec file lives under some
31
+ feature directory.
32
+
33
+ After finalizing this lightweight-spec, AI must:
34
+ 1. Add an outbound-link row to the feature's _index.md Lightweight Changes table
35
+ (Tier = T2; description includes the link to this file)
36
+ 2. Refresh the feature's _index.md Current BR Snapshot table to reflect
37
+ any BR ADDED / MODIFIED / REMOVED / RENAMED in this lightweight-spec
38
+ -->
39
+
40
+ # {問題簡述}
41
+
42
+ ## Problem
43
+
44
+ {什麼東西壞了?或什麼行為不正確?}
45
+
46
+ ## Behavior Delta
47
+
48
+ > 精簡 delta 格式:bug fix 多數只需 MODIFIED;若確實是新增規則可改用 ADDED、移除用 REMOVED、改名用 RENAMED。多項變更時照類別列。
49
+
50
+ ### MODIFIED - behavior modified in this fix
51
+ #### Rule: BR-NN {規則名稱}
52
+ **Before**: Given {current state} When {action} Then {current (incorrect) result}
53
+ **After**: Given {same state} When {same action} Then {correct result}
54
+ **Reason**: {why this change — bug / requirement clarification / spec alignment}
55
+
56
+ <!-- 若需要 ADDED / REMOVED / RENAMED / UNCHANGED 請比照 references/modify-existing-flow.md 的 Delta 格式 -->
57
+
58
+
59
+ ## Root Cause
60
+
61
+ {為什麼會這樣?是邏輯錯誤?資料問題?還是需求理解有誤?}
62
+
63
+ ## Fix Approach
64
+
65
+ {怎麼修?有沒有抽到 Domain 層的機會?}
66
+
67
+ <!-- dflow:section implementation-tasks -->
68
+ ## Implementation Tasks
69
+
70
+ > Keep T2 Light tasks concise. If the fix scope starts to expand, AI should pause and ask the developer whether to keep this as T2 or upgrade it to T1. Do not auto-upgrade based on task count alone.
71
+ >
72
+ > Recommended layer tags (WebForms): `DOMAIN` / `PAGE` / `DATA` / `TEST` / `DOC`
73
+
74
+ - [ ] {LAYER}-1: {minimal required change}
75
+ - [ ] TEST-1: {minimal verification / regression test}
76
+ - [ ] DOC-1: Update `_index.md` Lightweight Changes and Current BR Snapshot
77
+
78
+ Layer tag list above is the recommended set; the developer may extend with project-specific tags as needed.
79
+
80
+ ## Tech Debt Discovered (if any)
81
+
82
+ {在修這個 bug 時發現的其他問題,記錄到 tech-debt.md}
@@ -0,0 +1,39 @@
1
+ <!-- Template maintained by Dflow. See proposals/PROPOSAL-013 for origin. -->
2
+
3
+ # Domain Models
4
+
5
+ > Domain model catalog for one bounded context.
6
+
7
+ ## Context
8
+
9
+ - **Bounded Context**: {Context name}
10
+ - **Source Code Area**: `{project/path/or/namespace}`
11
+ - **Last Updated**: {YYYY-MM-DD}
12
+
13
+ ## Entities
14
+
15
+ | Entity | Responsibility | Key Identity | Code Mapping | Notes |
16
+ |---|---|---|---|---|
17
+ | {EntityName} | {核心職責} | {Id / composite key} | `{Namespace.Class}` | {optional notes} |
18
+
19
+ ## Value Objects
20
+
21
+ | Value Object | Responsibility | Equality Components | Code Mapping | Notes |
22
+ |---|---|---|---|---|
23
+ | {ValueObjectName} | {代表的概念} | {fields} | `{Namespace.Class}` | {optional notes} |
24
+
25
+ ## Domain Services
26
+
27
+ | Service | Responsibility | Inputs / Outputs | Code Mapping | Notes |
28
+ |---|---|---|---|---|
29
+ | {ServiceName} | {跨 entity/value object 的 domain operation} | {inputs -> outputs} | `{Namespace.Class}` | {optional notes} |
30
+
31
+ ## Repository Interfaces
32
+
33
+ | Repository | Aggregate / Entity | Query Responsibility | Code Mapping | Notes |
34
+ |---|---|---|---|---|
35
+ | {RepositoryName} | {EntityName} | {查詢或保存責任} | `{Namespace.Interface}` | {optional notes} |
36
+
37
+ ## Code Mapping Notes
38
+
39
+ - {domain concept} maps to `{existing WebForms / EF / service code}`.
@@ -0,0 +1,187 @@
1
+ ---
2
+ id: {CONTEXT}-{NUMBER}
3
+ title: Feature title
4
+ status: draft | in-progress | completed
5
+ bounded-context: {ContextName}
6
+ created: {YYYY-MM-DD}
7
+ author: {developer-name}
8
+ branch: feature/{CONTEXT}-{NUMBER}-{short-description}
9
+ ---
10
+
11
+ # {Feature Title}
12
+
13
+ <!--
14
+ Template note (for AI):
15
+ This is the **phase-spec** template - one phase-spec captures one full
16
+ "Kickoff -> Domain -> Design -> Build -> Verify" cycle inside a feature directory.
17
+ A feature can have 1..N phase-specs; the feature-level dashboard lives in
18
+ the sibling `_index.md` (see templates/_index.md). The instance file name is
19
+ `phase-spec-YYYY-MM-DD-{slug}.md` placed at
20
+ `dflow/specs/features/active/{SPEC-ID}-{slug}/`.
21
+
22
+ Each section below carries an HTML comment indicating its fill-in phase (Phase 1-4).
23
+ These phase markers let /dflow:status and the completion checklist track progress.
24
+ Phases correspond to SKILL.md § Guiding Questions by Phase:
25
+ Phase 1 - Understanding (What & Why)
26
+ Phase 2 - Domain Analysis (Where does it live?)
27
+ Phase 3 - Spec Writing (Behavior + Rules + Edge Cases)
28
+ Phase 4 - Implementation Planning
29
+ The "Implementation Tasks" section at the end is generated by AI after Phase 4 planning is done
30
+ (see new-feature-flow.md Step 5 end / new-phase-flow.md Step 4 end /
31
+ modify-existing-flow.md Step 4 end).
32
+
33
+ For phase 2+ specs in the same feature: only list BRs that are NEW or
34
+ MODIFIED in this phase under "Business Rules"; do not re-copy unchanged BRs from
35
+ prior phases. The cumulative state lives in the feature's `_index.md`
36
+ Current BR Snapshot table.
37
+ -->
38
+
39
+ ## Problem Description <!-- Fill timing: Phase 1 -->
40
+
41
+ 這個功能要解決什麼問題?誰需要它?
42
+
43
+ > 用使用者的角度描述,避免技術用語。
44
+
45
+ ## Domain Concepts <!-- Fill timing: Phase 2 -->
46
+
47
+ 涉及的 Domain 概念(引用 `dflow/specs/domain/{context}/models.md`):
48
+
49
+ | Concept | Type | Description |
50
+ |---|---|---|
51
+ | {ConceptName} | Entity / Value Object / Domain Service | 簡述角色 |
52
+
53
+ 如有新概念,先更新:
54
+ - [ ] `dflow/specs/domain/glossary.md` — 新增術語
55
+ - [ ] `dflow/specs/domain/{context}/models.md` — 新增模型定義
56
+
57
+ <!-- dflow:section behavior-scenarios -->
58
+ ## Behavior Scenarios <!-- Fill timing: Phase 3 -->
59
+
60
+ ### Main Success Scenario
61
+
62
+ ```gherkin
63
+ Scenario: {情境名稱}
64
+ Given {初始狀態}
65
+ When {使用者操作}
66
+ Then {預期結果}
67
+ ```
68
+
69
+ ### Alternative Scenarios
70
+
71
+ ```gherkin
72
+ Scenario: {替代情境}
73
+ Given {不同初始狀態}
74
+ When {使用者操作}
75
+ Then {不同的預期結果}
76
+ ```
77
+
78
+ ## Business Rules <!-- Fill timing: Phase 3 -->
79
+
80
+ > Phase 2+ 注意:本段僅列**本 phase 新增 / 修改到的 BR**;未變動的 BR 不重抄
81
+ > (它們的當前狀態見 feature 的 `_index.md` Current BR Snapshot 表)。
82
+
83
+ | BR-ID | Rule | Notes |
84
+ |---|---|---|
85
+ | BR-01 | {規則描述} | |
86
+ | BR-02 | {規則描述} | |
87
+
88
+ ## Delta from prior phases <!-- Fill timing: Phase 3; skip for the first phase -->
89
+
90
+ > 本段僅記**本 phase 相對前一 phase 的變化**,不累積歷史。歷史由 feature 目錄下
91
+ > 各 phase-spec 的本段串接閱讀;feature 層的當前累積狀態見 `_index.md` 的
92
+ > Current BR Snapshot。
93
+ >
94
+ > **首 phase**:標註「首 phase,無前置 Delta」即可,不需逐項填。
95
+ > **Phase 2+**:必填;格式沿用 modify-existing-flow.md 的 Delta 規則
96
+ > (ADDED / MODIFIED / REMOVED / RENAMED + 選用 UNCHANGED)。
97
+
98
+ ### ADDED - BR / behavior added in this phase
99
+ #### Rule: BR-NN {規則名稱}
100
+ Given {初始狀態}
101
+ When {操作}
102
+ Then {新的預期結果}
103
+
104
+ ### MODIFIED - BR / behavior modified in this phase
105
+ #### Rule: BR-NN {規則名稱}
106
+ **Before**: Given … When … Then {old result}
107
+ **After**: Given … When … Then {new result}
108
+ **Reason**: {why this change}
109
+
110
+ ### REMOVED - BR removed in this phase
111
+ #### Rule: BR-NN {規則名稱}
112
+ **Reason**: {why removed}
113
+
114
+ ### RENAMED - BR renamed in this phase
115
+ #### Rule: {old name} -> {new name}
116
+ **Reason**: {why renamed}
117
+
118
+ ### UNCHANGED - explicitly unaffected (optional)
119
+ - BR-003 金額上限
120
+ - BR-005 提交後不可修改
121
+
122
+ ## Edge Cases <!-- Fill timing: Phase 3 -->
123
+
124
+ | ID | Case | Expected Handling |
125
+ |---|---|---|
126
+ | EC-01 | {邊界描述} | {處理方式} |
127
+ | EC-02 | {邊界描述} | {處理方式} |
128
+
129
+ ## Implementation Notes <!-- Fill timing: Phase 4 -->
130
+
131
+ ### Current WebForms Implementation
132
+
133
+ > 在現有架構下如何實作?哪些 Code-Behind 會被修改?
134
+
135
+ ### Domain Layer Design
136
+
137
+ > 哪些邏輯放到 `src/Domain/{Context}/`?需要哪些 interface?
138
+
139
+ ```csharp
140
+ // 關鍵 Domain 類別草稿
141
+ ```
142
+
143
+ ### Keep Code-Behind Thin
144
+
145
+ > Code-Behind 只負責:解析 UI 輸入 -> 呼叫 Domain 層 -> 顯示結果
146
+
147
+ ### Future ASP.NET Core Migration Considerations
148
+
149
+ > 遷移時需要注意的事項,或者現在的設計如何幫助未來遷移。
150
+
151
+ ## Data Structure Changes <!-- Fill timing: Phase 4 -->
152
+
153
+ > 涉及的資料表與欄位變更(如有)
154
+
155
+ | Table | Column | Change Type | Description |
156
+ |---|---|---|---|
157
+ | {Table} | {Column} | 新增/修改/刪除 | |
158
+
159
+ ## Test Strategy <!-- Fill timing: Phase 4 -->
160
+
161
+ > Domain 層的單元測試應驗證哪些行為?
162
+
163
+ - [ ] {測試案例 1}
164
+ - [ ] {測試案例 2}
165
+
166
+ <!-- dflow:section open-questions -->
167
+ ## Open Questions <!-- Fill timing: Phase 1-4 -->
168
+
169
+ - {尚未釐清的需求、規則、資料或實作問題}
170
+
171
+ <!-- dflow:section implementation-tasks -->
172
+ ## Implementation Tasks <!-- Fill timing: generated by AI after Phase 4; all items should be checked at completion -->
173
+
174
+ > AI 在 Phase 4 實作規劃完成後,根據「Implementation Notes」產生的具體任務清單。
175
+ > 格式:`[LAYER]-[NUMBER]: 任務描述`
176
+ > 分類標籤(WebForms 版):
177
+ > - `DOMAIN` — Domain 層類別、VO、Service、Interface
178
+ > - `PAGE` — Code-Behind / ASPX 變更
179
+ > - `DATA` — 資料表 schema 或 Repository 實作
180
+ > - `TEST` — 測試案例
181
+ > 本段在 spec 歸檔(搬到 `completed/`)前應確認全部勾選,或明確標註未完成項的 follow-up。
182
+
183
+ - [ ] DOMAIN-1: {任務描述}
184
+ - [ ] DOMAIN-2: {任務描述}
185
+ - [ ] PAGE-1: {任務描述}
186
+ - [ ] DATA-1: {任務描述}
187
+ - [ ] TEST-1: {任務描述}
@@ -0,0 +1,24 @@
1
+ <!-- Template maintained by Dflow. See proposals/PROPOSAL-013 for origin. -->
2
+
3
+ # Business Rules
4
+
5
+ > Declarative BR-ID index for one bounded context.
6
+
7
+ <!-- dflow:section business-rules -->
8
+ ## Rule Index
9
+
10
+ | BR-ID | Rule summary | Behavior anchor | Status | Last updated |
11
+ |---|---|---|---|---|
12
+ | BR-001 | {業務規則摘要} | [BR-001](./behavior.md#br-001-rule-name) | draft | {YYYY-MM-DD} |
13
+
14
+ ## Status Legend
15
+
16
+ | Status | Meaning |
17
+ |---|---|
18
+ | draft | Rule is identified but not fully validated. |
19
+ | active | Rule is validated and expected to be enforced. |
20
+ | deprecated | Rule is retained for history but no longer active. |
21
+
22
+ ## Open Questions
23
+
24
+ - {需要 domain expert 確認的規則}
@@ -0,0 +1,15 @@
1
+ <!-- Template maintained by Dflow. See proposals/PROPOSAL-013 for origin. -->
2
+
3
+ # Migration Tech Debt
4
+
5
+ > WebForms migration debt backlog discovered during SDD/DDD work.
6
+
7
+ ## Debt Items
8
+
9
+ | Item | Location | Description | Severity | Migration impact | Status |
10
+ |---|---|---|---|---|---|
11
+ | {Debt item} | `{file/path/or/namespace}` | {問題描述} | {Low/Medium/High/Critical} | {對 WebForms -> Core 遷移的影響} | {open/planned/in-progress/done} |
12
+
13
+ ## Follow-up Notes
14
+
15
+ - {需要後續 proposal、refactor 或 migration plan 的事項}