dflow-sdd-ddd 0.9.0 → 0.11.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 (57) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.en.md +73 -48
  3. package/README.md +46 -36
  4. package/TEMPLATE-COVERAGE.md +0 -1
  5. package/TEMPLATE-LANGUAGE-GLOSSARY.md +1 -0
  6. package/bin/dflow.js +7 -11
  7. package/docs/evaluating-dflow.en.md +11 -7
  8. package/docs/evaluating-dflow.md +9 -4
  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/docs/why-dflow.en.md +72 -0
  16. package/docs/why-dflow.md +72 -0
  17. package/lib/init.js +867 -214
  18. package/package.json +2 -2
  19. package/templates/brownfield/references/drift-verification.md +41 -10
  20. package/templates/brownfield/references/finish-feature-flow.md +3 -2
  21. package/templates/brownfield/references/git-integration.md +0 -1
  22. package/templates/brownfield/references/init-project-flow.md +31 -17
  23. package/templates/brownfield/references/modify-existing-flow.md +44 -38
  24. package/templates/brownfield/references/new-feature-flow.md +41 -11
  25. package/templates/brownfield/references/new-phase-flow.md +9 -2
  26. package/templates/brownfield/references/pr-review-checklist.md +7 -1
  27. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +258 -29
  28. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +5 -8
  29. package/templates/brownfield/scaffolding/_conventions.md +10 -9
  30. package/templates/brownfield/templates/_index.md +1 -1
  31. package/templates/brownfield/templates/context-map.md +12 -4
  32. package/templates/brownfield/templates/lightweight-spec.md +1 -1
  33. package/templates/brownfield/templates/phase-spec.md +1 -1
  34. package/templates/common/references/ddd-modeling-guide.md +643 -0
  35. package/templates/common/skill/SKILL.md +9 -6
  36. package/templates/greenfield/references/drift-verification.md +60 -15
  37. package/templates/greenfield/references/finish-feature-flow.md +3 -2
  38. package/templates/greenfield/references/git-integration.md +0 -1
  39. package/templates/greenfield/references/init-project-flow.md +31 -17
  40. package/templates/greenfield/references/modify-existing-flow.md +5 -7
  41. package/templates/greenfield/references/new-feature-flow.md +49 -19
  42. package/templates/greenfield/references/new-phase-flow.md +5 -2
  43. package/templates/greenfield/references/pr-review-checklist.md +9 -1
  44. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +221 -29
  45. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +10 -15
  46. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  47. package/templates/greenfield/scaffolding/_conventions.md +9 -8
  48. package/templates/greenfield/templates/_index.md +1 -1
  49. package/templates/greenfield/templates/aggregate-design.md +6 -0
  50. package/templates/greenfield/templates/context-map.md +13 -4
  51. package/templates/greenfield/templates/events.md +4 -1
  52. package/templates/greenfield/templates/lightweight-spec.md +1 -1
  53. package/templates/greenfield/templates/phase-spec.md +1 -1
  54. package/docs/migrating-to-dflow-v1.md +0 -230
  55. package/templates/brownfield/templates/CLAUDE.md +0 -165
  56. package/templates/greenfield/references/ddd-modeling-guide.md +0 -351
  57. package/templates/greenfield/templates/CLAUDE.md +0 -172
@@ -1,230 +0,0 @@
1
- # Migrating to Dflow V1
2
-
3
- > **Audience**: maintainers of an existing project that adopted an early
4
- > Dflow form (pre-`dflow-sdd-ddd@0.1.0`) and want to align it with the
5
- > V1 baseline that ships from npm.
6
- >
7
- > **Stance**: V1 took a clean cut. Dflow does not perform automatic
8
- > migration. This guide is a manual checklist. The CLI only warns when
9
- > it detects legacy paths; it does not modify existing files.
10
-
11
- > **Audience reality (2026-05-15)**: To date, the only known user of
12
- > this guide has been the **OBTS** migration (a single, completed
13
- > one-off). Dflow has not had broad pre-V1 adoption; this guide is
14
- > maintained as a contingency endpoint for `dflow doctor` and
15
- > `dflow init` warning messages, not as documentation of an active
16
- > migration program. If you reach this page via those tool outputs
17
- > and your case isn't covered below, please open a docs feedback issue
18
- > so the guide can be extended.
19
-
20
- ## When You Need This Guide
21
-
22
- Skip this guide if you started using Dflow at `dflow-sdd-ddd@0.1.0`
23
- or later. Your project is already on the V1 baseline.
24
-
25
- Read this guide if any of the following are true:
26
-
27
- - Your project has a top-level `specs/` directory that holds Dflow
28
- spec material (not the V1 `dflow/specs/`).
29
- - Your project has `specs/_共用/` instead of `dflow/specs/shared/`.
30
- - Your spec headings are in Traditional Chinese rather than the
31
- canonical English vocabulary documented in
32
- `TEMPLATE-LANGUAGE-GLOSSARY.md`.
33
- - Your AI instructions point teammates to `/dflow:init-project`
34
- instead of the Dflow CLI init command (`dflow init`, or
35
- `npx dflow-sdd-ddd init` on the no-install path).
36
- - Your `CLAUDE.md` (or equivalent root instruction file) was generated
37
- by an early Dflow variant that wrote a full Claude-only file rather
38
- than the V1 multi-AI thin shim that points to
39
- `dflow/specs/shared/AI-AGENT-GUIDE.md`.
40
-
41
- You may need only some of these steps; the five sections below are
42
- independent.
43
-
44
- ## Before You Start
45
-
46
- - Work on a dedicated branch or a disposable copy. None of the steps
47
- are destructive, but move-and-rename mistakes are easier to recover
48
- from a clean branch.
49
- - Make sure the working tree is clean (`git status`).
50
- - Note your current Dflow version if you can identify it. Older
51
- internal Dflow forms may not have been versioned at all.
52
- - Open these V1 reference files for cross-checking:
53
- - `TEMPLATE-LANGUAGE-GLOSSARY.md` — canonical English headings.
54
- - `TEMPLATE-COVERAGE.md` — V1 file layout and parity matrix.
55
- - `docs/evaluating-dflow.en.md` — what a fresh V1 `init` produces, if
56
- you want to spin up a sample project to compare against.
57
- - For an on-demand read-only summary of legacy artifacts in your
58
- project, run `dflow doctor` (or `npx dflow-sdd-ddd doctor` on the
59
- no-install path). The command lists detected legacy paths and missing
60
- V1 fields; it never modifies files.
61
-
62
- ## Migration Steps
63
-
64
- ### 1. Move root `specs/` to `dflow/specs/`
65
-
66
- V1 puts every Dflow-managed spec under `dflow/specs/`, so the `dflow/`
67
- directory becomes a single Dflow namespace separate from any
68
- unrelated `specs/` directory another tool may own (PROPOSAL-014).
69
-
70
- If your project has top-level `specs/` containing Dflow content:
71
-
72
- ```bash
73
- mkdir -p dflow
74
- git mv specs dflow/specs
75
- git status
76
- ```
77
-
78
- Commit the rename in a single commit. Avoid mixing the rename with
79
- content edits in the same commit so reviewers can read the diff
80
- cleanly.
81
-
82
- If you also have an unrelated `specs/` directory used by another
83
- tool, move only the Dflow material into `dflow/specs/`. The CLI will
84
- warn when it sees a non-Dflow `specs/` directory but will not modify
85
- it.
86
-
87
- ### 2. Rename `_共用/` to `shared/`
88
-
89
- V1 uses canonical English directory names (PROPOSAL-012). If your
90
- project has `dflow/specs/_共用/`:
91
-
92
- ```bash
93
- git mv dflow/specs/_共用 dflow/specs/shared
94
- git status
95
- ```
96
-
97
- Update any cross-references in spec files or AI instructions. A
98
- project-wide grep after the rename catches leftover references:
99
-
100
- ```bash
101
- grep -rn "_共用" .
102
- ```
103
-
104
- ### 3. Translate Chinese headings to canonical English
105
-
106
- V1 templates use canonical English structure for section headings,
107
- field labels, anchors, and placeholders (PROPOSAL-013). Free prose
108
- inside those sections may stay in your team language.
109
-
110
- This is the most labor-intensive step. Recommended approach:
111
-
112
- 1. Open `TEMPLATE-LANGUAGE-GLOSSARY.md` for the heading-by-heading
113
- mapping.
114
- 2. For each generated spec file, replace Chinese H2 / H3 headings,
115
- table column labels, and bold inline labels with their canonical
116
- English form.
117
- 3. Leave free prose (descriptions, decision rationale, task text) in
118
- the team language. The Prose Language convention recorded in
119
- `dflow/specs/shared/_conventions.md` applies here — see also
120
- step 6 below.
121
-
122
- An AI assistant can walk through each spec file heading-by-heading
123
- faster than a global search-and-replace, because earlier Dflow
124
- adoption may have used slightly different wording per team. After
125
- translation, run a project-wide search for the most common Chinese
126
- headings to catch missed files. Adjust the search list to match the
127
- templates your team actually used:
128
-
129
- ```bash
130
- grep -rn "## 業務規則\|## 行為情境\|## 領域模型" dflow/specs/
131
- ```
132
-
133
- ### 4. Switch the init entry point
134
-
135
- Pre-V1 documentation may have instructed teammates to start a Dflow
136
- project by running `/dflow:init-project` from inside an AI agent. V1
137
- removed that runtime slash command (PROPOSAL-014). The init flow now
138
- runs as a shell command. Install Dflow globally and run:
139
-
140
- ```bash
141
- npm install -g dflow-sdd-ddd
142
- dflow init
143
- ```
144
-
145
- If you cannot or do not want to install globally, use the no-install path:
146
-
147
- ```bash
148
- npx dflow-sdd-ddd init
149
- ```
150
-
151
- If you already have an initialized project, you do not need to re-run
152
- `init`. The other `/dflow:*` workflow commands (`/dflow:new-feature`,
153
- `/dflow:modify-existing`, `/dflow:bug-fix`, `/dflow:new-phase`,
154
- `/dflow:finish-feature`, `/dflow:verify`, `/dflow:pr-review`) are
155
- unchanged and continue to work.
156
-
157
- Update any team documentation, runbooks, or onboarding notes that
158
- still reference `/dflow:init-project` so new project setups use the
159
- shell command instead.
160
-
161
- ### 5. Adopt multi-AI thin shims
162
-
163
- V1 separates the canonical project guide from each per-tool
164
- instruction file (PROPOSAL-020). The canonical guide lives at
165
- `dflow/specs/shared/AI-AGENT-GUIDE.md`. Per-tool files (`AGENTS.md`,
166
- `CLAUDE.md`, `.github/copilot-instructions.md`) are thin
167
- shims pointing at the canonical guide.
168
-
169
- If your project's `CLAUDE.md` (or equivalent) was generated by an
170
- early Dflow form that wrote a full file rather than a thin shim:
171
-
172
- ```bash
173
- dflow configure-agents
174
- ```
175
-
176
- This command adds shims for any AI tools you select. `dflow configure-agents`
177
- does not overwrite an existing `CLAUDE.md`; instead, it writes a
178
- `dflow/specs/shared/<tool>-md-snippet.md` that you can merge into the
179
- existing file at your own pace.
180
-
181
- If you prefer a fully clean V1 layout, archive the existing root
182
- instruction file under another name first, then run
183
- `dflow configure-agents` so it can write the new shim from scratch.
184
-
185
- ## After Migration
186
-
187
- Verify the migrated project:
188
-
189
- - Ask the AI agent to run `/dflow:status` and confirm it can locate
190
- Dflow flow material and report the project's current state.
191
- - Open `dflow/specs/shared/_conventions.md` and confirm a `## Prose
192
- Language` section exists. If your project predates the
193
- prose-language convention (PROPOSAL-015), add the section manually
194
- with the correct BCP-47 language tag, for example `zh-TW` or `en`.
195
- - Run a final grep to confirm no legacy paths or terms remain inside
196
- `dflow/specs/`. Adjust the term list to match your earlier Dflow
197
- adoption:
198
-
199
- ```bash
200
- grep -rn "_共用\|/dflow:init-project" dflow/specs/
201
- ```
202
-
203
- ## Out of Scope
204
-
205
- This guide stays manual on purpose. The items below are not part of
206
- V1 and may or may not arrive in a later release; do not rely on them
207
- when planning a migration today.
208
-
209
- - Automatic migration of legacy paths or headings.
210
- - A `dflow doctor` health check command.
211
- - A `dflow migrate` subcommand that edits files.
212
- - Automated translation of free prose between languages.
213
-
214
- If any of these would help your team, open a docs feedback issue so
215
- the request is recorded. The maintainer position is not to refuse
216
- them, only to keep V1 a clean cut.
217
-
218
- ## Where To Go Next
219
-
220
- - `docs/evaluating-dflow.en.md` for what a fresh V1 `init` produces, in
221
- case you want to compare against your migrated project.
222
- - Per-tool walkthroughs under `docs/` for the AI tool you use:
223
- - `docs/using-with-claude-code.en.md`
224
- - `docs/using-with-codex.en.md`
225
- - `TEMPLATE-COVERAGE.md` for the V1 logical / generated file parity
226
- between Greenfield and Brownfield tracks.
227
-
228
- If something in this guide does not match your project's actual
229
- pre-V1 state, open a docs feedback issue. The guide can be extended
230
- as new edge cases come in.
@@ -1,165 +0,0 @@
1
- # Project: {系統名稱} — {Framework}
2
-
3
- **重要:所有開發工作都必須遵循本文件定義的流程。**
4
-
5
- ---
6
-
7
- ## System Context
8
-
9
- > 技術棧、業務領域、目錄結構
10
-
11
- ### Background
12
-
13
- 這是一個運行中的既有系統,使用 {Framework} / {Language},目前持續新增與修改功能。
14
- 目前採用 SDD 流程,同時為 DDD 與 target architecture 做準備。
15
-
16
- ### Project Structure
17
-
18
- ```
19
- dflow/specs/
20
- ├── shared/ # 專案級治理文件(由 dflow init 寫入)
21
- │ ├── _overview.md # 系統現況與 target architecture
22
- │ └── _conventions.md # 規格撰寫慣例與模板
23
- ├── domain/ # 領域知識
24
- │ ├── glossary.md # 術語表(Ubiquitous Language)
25
- │ └── {context}/ # 按 Bounded Context 分
26
- │ ├── context.md # Context 邊界與職責
27
- │ ├── models.md # 領域模型定義
28
- │ └── rules.md # 業務規則目錄
29
- ├── features/
30
- │ ├── active/ # 進行中的 feature
31
- │ │ └── {SPEC-ID}-{slug}/ # 一個 feature 一個目錄
32
- │ │ ├── _index.md # Feature dashboard:Goals & Scope / Phase Specs / Current BR Snapshot / Lightweight Changes / Resume Pointer
33
- │ │ ├── phase-spec-YYYY-MM-DD-{slug}.md # T1 Heavy:每 phase 一份
34
- │ │ └── lightweight-YYYY-MM-DD-{slug}.md # T2 Light(或 BUG-NNN-{slug}.md)
35
- │ ├── completed/ # 整個 feature 目錄 git mv 到這裡
36
- │ └── backlog/ # 待處理
37
- │ # SPEC-ID 格式:SPEC-YYYYMMDD-NNN;slug 跟隨討論語言(中文/英文皆可)
38
- │ # T3 無獨立檔,只在 _index.md Lightweight Changes 寫一列
39
- └── migration/
40
- └── tech-debt.md # 技術債與遷移備忘
41
-
42
- src/
43
- ├── Domain/ # 抽離的領域邏輯(framework-pure)
44
- │ ├── {Context}/
45
- │ │ ├── Entities/
46
- │ │ ├── ValueObjects/
47
- │ │ ├── Services/
48
- │ │ └── Interfaces/
49
- │ └── SharedKernel/
50
- └── Delivery/ # delivery-layer code(entrypoints, controllers, handlers)
51
- ```
52
-
53
- > **目錄命名說明**:上方 `src/Domain/` / `src/Delivery/` 是 Clean
54
- > Architecture 通用示意,不限 stack。請依專案實際慣例對應(例:Java/Spring 用
55
- > `src/main/java/com/example/domain/`、Node/TS 用 `src/domain/` /
56
- > `src/routes/`、Python 用 `domain/` package、Go 用 `internal/domain/` /
57
- > `internal/handler/`、.NET 用 `src/{Project}.Domain/` + `.csproj` 分層)。
58
- > 完整 per-stack 範例見 `docs/examples-by-stack.md`。重點是
59
- > `src/Domain/`(或對應命名)保持與 delivery/entrypoint code 獨立。
60
-
61
- ---
62
-
63
- ## Development Workflow
64
-
65
- > SDD 流程、Git 整合、Domain 層規範、術語表、AI 協作
66
-
67
- ### Core Principles
68
- 1. **Spec Before Code** — 沒有規格就不寫實作
69
- 2. **Domain Extraction** — 業務邏輯屬於 `src/Domain/`,不屬於 delivery/entrypoint code(presentation/UI layer、controllers、handlers、jobs、message consumers、data pipelines、stored procedures)
70
- 3. **Ubiquitous Language** — 使用 `dflow/specs/domain/glossary.md` 中定義的術語
71
- 4. **Migration Awareness** — 每個決策都要考慮 target architecture
72
-
73
- ### Three Ceremony Tiers
74
-
75
- 不是每次修改都要跑完整流程。AI 依下列判準選 tier:
76
-
77
- - **T1 Heavy** — 新功能、新 phase、架構變動、新增 BR → 建獨立 phase-spec,
78
- 走 `/dflow:new-feature` 或 `/dflow:new-phase`
79
- - **T2 Light** — bug fix、UI 輸入驗證、流程分支修改(有 BR Delta 但無 Domain /
80
- 資料結構變動)→ 建獨立 lightweight spec 置於 feature 目錄內
81
- - **T3 Trivial** — 按鈕顏色、文案修正、typo、排版、純註解(無 BR 變動、
82
- 無 Domain 概念動、無資料結構動、只改 UI 表層 / 註解 / 格式化)→
83
- 只在 `_index.md` Lightweight Changes inline 寫一列
84
-
85
- 純 typo / 純格式化 commit(`dotnet format` / `prettier` 自動整理)**低於 T3**:
86
- 直接 `git commit`,不走 Dflow。
87
-
88
- ### New Feature
89
- 1. 建 feature 目錄 `dflow/specs/features/active/{SPEC-ID}-{slug}/`
90
- 2. 建 `_index.md`(feature dashboard)+ 第一份 `phase-spec-YYYY-MM-DD-{slug}.md`
91
- 3. 識別涉及的領域概念,更新 `dflow/specs/domain/` 下的對應文件
92
- 4. 盡可能將業務邏輯實作在 `src/Domain/` 中(語言純粹的 class,不依賴 delivery framework)
93
- 5. Delivery/entrypoint code 僅負責輸入解析、協調流程與輸出綁定,呼叫 Domain 層處理邏輯
94
- 6. 撰寫測試驗證 Domain 層行為符合規格
95
-
96
- ### New Phase
97
- 1. 在已啟動的 active feature 上新增一份 phase-spec(含 Delta-from-prior-phases)
98
- 2. 更新 `_index.md` 的 Phase Specs 表 + regenerate Current BR Snapshot
99
- 3. 嚴格只適用於 active feature;completed 的 feature 不接受新 phase
100
-
101
- ### Modify Existing
102
- 1. AI 依 T1 / T2 / T3 判準分流
103
- 2. 若偵測到改動與 completed feature 相關,主動詢問是否為 follow-up
104
- (follow-up 走新建 feature + `follow-up-of` 鏈回原 feature;不把 T2/T3
105
- 寫回 completed 目錄)
106
- 3. 如果該功能的邏輯還在 delivery/entrypoint code 中,評估是否值得先抽離到 Domain 層
107
- 4. 在 `dflow/specs/migration/tech-debt.md` 記錄發現的技術債
108
-
109
- ### Bug Fix
110
- 1. 建立輕量規格(問題 + 現有行為 + 預期行為 + 修復方式)
111
- 2. 若 bug 不附掛既有 feature,先建最小 feature 目錄再放 lightweight-spec
112
- 3. 修 Bug 時順便記錄發現的技術債
113
-
114
- ### Feature Closeout
115
- 1. 驗證 feature 目錄內所有 phase-spec `status: completed`
116
- 2. 把 `_index.md` Current BR Snapshot 同步到 BC 層 `rules.md` / `behavior.md`
117
- 3. `git mv` 整個 feature 目錄從 `active/` 搬到 `completed/`
118
- 4. 產出 Integration Summary(Git-strategy-neutral;不自動 merge)
119
-
120
- ### Git Integration
121
-
122
- > 本流程只規定 SDD 必要的最小 Git 耦合(feature branch per feature、
123
- > `git mv`、commit 對應 SPEC-ID)。實際採用的分支策略(Git Flow /
124
- > GitHub Flow / trunk-based / 單一 main)由專案決定,不在此強制。
125
- > 若採用 Git Flow,可參考 `scaffolding/Git-principles-gitflow.md` 範本。
126
-
127
- **分支命名**
128
- ```
129
- feature/{SPEC-ID}-{short-description} # 新功能(SDD 必須)
130
- bugfix/{BUG-ID}-{short-description} # Bug 修復(SDD 必須)
131
- ```
132
-
133
- **Commit Message**
134
- ```
135
- [SPEC-ID] 簡述變更
136
- ```
137
-
138
- **分支規則**
139
- - **feature/** — 必須先有 spec 才能開始編碼
140
- - **bugfix/** — 至少要有輕量 spec
141
- - **`/dflow:bug-fix`** 不綁定任何分支策略;採 Git Flow 的專案可選擇把
142
- 緊急修復放在 `hotfix/` 分支,但這是專案決策,Dflow 不代為規定
143
-
144
- ### Domain Layer Rules (`src/Domain/`)
145
-
146
- 此目錄中的程式碼必須遵守:
147
- - ❌ 不可引用任何 delivery-framework 命名空間(例:HTTP 請求/回應物件、Session/Cookie context、job runner context、CLI flag parser、ViewState 類等)
148
- - ❌ 不可直接存取資料庫(使用 interface + Repository pattern)
149
- - ❌ 不可使用 delivery-framework runtime context(例:HTTP request/response、session/cookie、job runner state、CLI args)
150
- - ❌ 不可有 UI / entrypoint 相關邏輯(格式化顯示、controller/page/handler 引用)
151
- - ✅ 語言純粹的 class(不依賴 delivery framework),可直接搬到 target architecture
152
- - ✅ 所有公開行為都能在沒有 delivery infrastructure 的情況下測試
153
-
154
- ### Glossary
155
-
156
- 所有業務術語必須使用 `dflow/specs/domain/glossary.md` 中定義的名稱。
157
- 遇到新術語時,先新增到術語表再使用。
158
-
159
- ### AI Collaboration Notes
160
-
161
- - 開發者提出任何功能需求時,先引導建立 spec
162
- - 在回答 Domain 相關問題時,優先參考 `dflow/specs/domain/` 中的文件
163
- - 發現 delivery/entrypoint code 中的業務邏輯時,建議抽離到 `src/Domain/`
164
- - 每次開發循環結束時,提醒更新術語表和技術債記錄
165
- - 建立分支前,確認命名符合規範且對應 spec 存在