dflow-sdd-ddd 0.6.0 → 0.8.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 (59) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.en.md +30 -0
  3. package/README.md +14 -0
  4. package/bin/dflow.js +7 -3
  5. package/docs/evaluating-dflow.en.md +14 -5
  6. package/docs/evaluating-dflow.md +14 -5
  7. package/docs/npm-publish-checklist.md +8 -0
  8. package/docs/using-with-claude-code.en.md +118 -11
  9. package/docs/using-with-claude-code.md +94 -9
  10. package/docs/using-with-codex.en.md +14 -0
  11. package/docs/using-with-codex.md +10 -0
  12. package/docs/using-with-github-copilot.en.md +36 -0
  13. package/docs/using-with-github-copilot.md +26 -0
  14. package/lib/init.js +461 -24
  15. package/package.json +1 -1
  16. package/templates/brownfield/references/dflow-feedback-flow.md +179 -0
  17. package/templates/brownfield/references/drift-verification.md +183 -0
  18. package/templates/brownfield/references/finish-feature-flow.md +259 -0
  19. package/templates/brownfield/references/git-integration.md +312 -0
  20. package/templates/brownfield/references/init-project-flow.md +413 -0
  21. package/templates/brownfield/references/modify-existing-flow.md +444 -0
  22. package/templates/brownfield/references/new-feature-flow.md +367 -0
  23. package/templates/brownfield/references/new-phase-flow.md +259 -0
  24. package/templates/brownfield/references/pr-review-checklist.md +179 -0
  25. package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  26. package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +12 -8
  27. package/templates/brownfield/scaffolding/Git-principles-gitflow.md +1 -1
  28. package/templates/brownfield/scaffolding/Git-principles-trunk.md +1 -1
  29. package/templates/brownfield/scaffolding/_conventions.md +1 -1
  30. package/templates/brownfield/scaffolding/_overview.md +3 -3
  31. package/templates/brownfield/templates/context-map.md +1 -1
  32. package/templates/brownfield/templates/glossary.md +1 -1
  33. package/templates/brownfield/templates/models.md +1 -1
  34. package/templates/brownfield/templates/rules.md +1 -1
  35. package/templates/brownfield/templates/tech-debt.md +1 -1
  36. package/templates/common/skill/SKILL.md +35 -0
  37. package/templates/greenfield/references/ddd-modeling-guide.md +351 -0
  38. package/templates/greenfield/references/dflow-feedback-flow.md +179 -0
  39. package/templates/greenfield/references/drift-verification.md +195 -0
  40. package/templates/greenfield/references/finish-feature-flow.md +280 -0
  41. package/templates/greenfield/references/git-integration.md +285 -0
  42. package/templates/greenfield/references/init-project-flow.md +447 -0
  43. package/templates/greenfield/references/modify-existing-flow.md +362 -0
  44. package/templates/greenfield/references/new-feature-flow.md +397 -0
  45. package/templates/greenfield/references/new-phase-flow.md +273 -0
  46. package/templates/greenfield/references/pr-review-checklist.md +130 -0
  47. package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +31 -4
  48. package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +15 -13
  49. package/templates/greenfield/scaffolding/Git-principles-gitflow.md +1 -1
  50. package/templates/greenfield/scaffolding/Git-principles-trunk.md +1 -1
  51. package/templates/greenfield/scaffolding/_conventions.md +1 -1
  52. package/templates/greenfield/scaffolding/_overview.md +5 -3
  53. package/templates/greenfield/scaffolding/architecture-decisions-README.md +1 -1
  54. package/templates/greenfield/templates/context-map.md +1 -1
  55. package/templates/greenfield/templates/events.md +1 -1
  56. package/templates/greenfield/templates/glossary.md +1 -1
  57. package/templates/greenfield/templates/models.md +1 -1
  58. package/templates/greenfield/templates/rules.md +1 -1
  59. package/templates/greenfield/templates/tech-debt.md +1 -1
@@ -0,0 +1,413 @@
1
+ # Init Project Flow — Brownfield Track
2
+
3
+ Internal flow spec for `npx dflow-sdd-ddd init` after the CLI selects the
4
+ Brownfield track. It also serves as the manual reference for environments
5
+ where Node.js/npm is unavailable.
6
+
7
+ This is not a skill slash command. Do not describe or invoke it as one.
8
+
9
+ This is a **one-time project bootstrap** flow. It sets up the `dflow/specs/`
10
+ directory structure, seeds project-level governance files from the packaged
11
+ `scaffolding/` template set, and points the developer at `/dflow:new-feature`
12
+ as the natural next command.
13
+
14
+ The V1 CLI clean cut does not migrate or dual-read a legacy root `specs/`
15
+ directory. If root `specs/` exists, warn that new Dflow files will be created
16
+ under `dflow/specs/`.
17
+
18
+ **Confirmations** in this flow:
19
+ - Step 2 → Step 3: information collected → present file-list preview
20
+ - Step 3 → Step 4: file-list confirmed → write
21
+
22
+ In the CLI, use ordinary yes/no confirmation. In the manual AI fallback,
23
+ ask for explicit confirmation in natural language; do not require
24
+ the workflow next command for init.
25
+
26
+ **Ceremony**: this flow is **meta-level** — it sets up the infrastructure
27
+ that subsequent T1 / T2 / T3 work will live in. It does not itself produce
28
+ a SPEC-ID, feature directory, or branch. It does not count against Ceremony
29
+ Scaling.
30
+
31
+ ---
32
+
33
+ ## Step 1: Current-State Inventory
34
+
35
+ The CLI inspects the project root before prompting.
36
+
37
+ **Read** (using the Read / Glob / LS tools):
38
+ - Is there a `.git` directory? → repo exists
39
+ - Is there an existing non-empty `dflow/specs/` directory? → Dflow already initialized; abort
40
+ - Is there an empty `dflow/specs/` directory? → continue with existing-file protection
41
+ - Is there an existing root `specs/` directory? → legacy / other-tool warning only; do not read, copy, move, or rewrite it
42
+ - Is there an existing `CLAUDE.md` at the repo root? → project already
43
+ has AI-collab rules
44
+
45
+ Report findings plainly:
46
+
47
+ > "Repo inventory:
48
+ > - `.git`: present
49
+ > - `dflow/specs/`: not yet present → greenfield Dflow setup
50
+ > - `specs/`: present → legacy / other-tool directory; Dflow V1 will not
51
+ > migrate or modify it
52
+ > - `CLAUDE.md`: present → will not overwrite; I'll offer a snippet
53
+ > to merge into it"
54
+
55
+ Or:
56
+
57
+ > "Repo inventory:
58
+ > - `dflow/specs/`: already contains files
59
+ > - `CLAUDE.md`: not present
60
+ >
61
+ > Dflow already appears initialized here. I will stop rather than risk
62
+ > mixing bootstrap versions."
63
+
64
+ Classify the scenario:
65
+ - **Greenfield**: no `dflow/specs/` at all → create full baseline
66
+ - **Empty Dflow namespace**: `dflow/specs/` exists but contains no files → continue
67
+ - **Already initialized**: non-empty `dflow/specs/` exists → abort cleanly
68
+
69
+ **→ Transition (step-internal)**: Step 1 complete. Announce
70
+ > "Step 1 complete (current-state inventory). Entering Step 2: Project
71
+ > Information."
72
+
73
+ and continue.
74
+
75
+ ---
76
+
77
+ ## Step 2: Project Information (track-specific intake)
78
+
79
+ Ask these questions naturally — not as a checklist dump. Skip any
80
+ question where Step 1 already gave a confident answer.
81
+
82
+ ### Q1. Project type
83
+
84
+ > "Is this project greenfield (fresh start with Dflow) or brownfield
85
+ > (existing code, now adopting Dflow)?"
86
+
87
+ Used to seed `_overview.md`'s "現有問題" section (brownfield typically
88
+ has backlog issues to document).
89
+
90
+ ### Q2. Tech stack confirmation
91
+
92
+ > "Confirm the tech stack so I populate the right scaffolding
93
+ > variables: current presentation framework or entrypoint stack?
94
+ > language? database / ORM / persistence approach?"
95
+
96
+ Used to substitute `{Framework}` / `{Framework version}` / `{Language}` /
97
+ `{ORM / persistence}` / `{ORM version}` placeholders in `_overview.md`.
98
+
99
+ ### Q3. Migration plan
100
+
101
+ > "Is there an existing plan to migrate this Brownfield project to
102
+ > a target architecture?"
103
+
104
+ If yes → `_overview.md` "Target Architecture Strategy" section is emphasised and
105
+ `migration/tech-debt.md` is prioritised. If no → the scaffolding still
106
+ mentions the principles (Migration Awareness / Domain Extraction /
107
+ Dual-Track Parallel / Pragmatic First) but framed as forward-option.
108
+
109
+ ### Q4. Project prose language
110
+
111
+ > "Project prose language for generated spec content? Choose an explicit
112
+ > language tag: `zh-TW`, `en`, `ja-JP`, or another BCP-47 tag."
113
+
114
+ Used to write `dflow/specs/shared/_conventions.md` under `## Prose
115
+ Language`. This value is required. Do not accept `any`, `skip`, `later`,
116
+ blank input, or prose descriptions such as "Traditional Chinese". Dflow
117
+ templates keep canonical English structural language; this setting controls
118
+ free prose inside generated spec sections.
119
+
120
+ ### Q5. Optional starter files (multi-select)
121
+
122
+ > "Besides the mandatory baseline, which optional starter files do
123
+ > you want me to seed? You can check as many as apply:
124
+ >
125
+ > - [ ] `dflow/specs/shared/_overview.md` — system overview template
126
+ > - [ ] Git principles — **pick one** if your project has opinions
127
+ > about Git conventions (decision hint: **if you're not sure,
128
+ > pick trunk-based** — that's the default for GitHub / GitLab.
129
+ > Pick Git Flow only if you have a formal release cycle with
130
+ > dedicated release / hotfix branches):
131
+ > - [ ] `dflow/specs/shared/Git-principles-gitflow.md`
132
+ > - [ ] `dflow/specs/shared/Git-principles-trunk.md`"
133
+
134
+ Wait for answers. If the developer picks both Git-principles flavours,
135
+ confirm once more that they really want both (usually a project picks
136
+ one).
137
+
138
+ ### Q6. AI coding agents (multi-select)
139
+
140
+ > "Which AI coding agents should Dflow configure?
141
+ >
142
+ > - [ ] `AGENTS.md` — Codex / Copilot coding agent
143
+ > - [ ] `CLAUDE.md` — Claude Code
144
+ > - [ ] `.github/copilot-instructions.md` — GitHub Copilot
145
+ >
146
+ > If you select any agent, Dflow will create
147
+ > `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical guide. Root-level
148
+ > tool files stay thin and point back to that guide. Existing tool files are
149
+ > never overwritten; Dflow writes merge snippets under `dflow/specs/shared/`
150
+ > instead."
151
+
152
+ **→ Transition (step-internal)**: Step 2 complete. Announce
153
+ > "Step 2 complete (project information captured). Entering Step 3:
154
+ > File-list preview."
155
+
156
+ and continue.
157
+
158
+ ---
159
+
160
+ ## Step 3: File-list Preview
161
+
162
+ Compute the full list of files that will be created / skipped, based on
163
+ Step 1 (current state) + Step 2 (developer choices).
164
+
165
+ ### 3.1 Mandatory baseline (Brownfield track)
166
+
167
+ These files / directories are **always part of the baseline** — they
168
+ are what every Dflow-adopting Brownfield project is expected to have
169
+ before `/dflow:new-feature` runs cleanly:
170
+
171
+ ```
172
+ dflow/specs/
173
+ ├── features/
174
+ │ ├── active/ # directory (empty)
175
+ │ ├── completed/ # directory (empty)
176
+ │ └── backlog/ # directory (empty)
177
+ ├── domain/
178
+ │ └── glossary.md # ← templates/glossary.md
179
+ ├── shared/
180
+ │ └── _conventions.md # ← scaffolding/_conventions.md (mandatory)
181
+ └── migration/
182
+ └── tech-debt.md # ← templates/tech-debt.md
183
+ ```
184
+
185
+ Key Brownfield-track notes:
186
+ - `dflow/specs/migration/tech-debt.md` (not `dflow/specs/architecture/tech-debt.md`)
187
+ — Brownfield projects use `migration/` as the cross-cutting directory
188
+ for migration-era concerns. The Greenfield track uses `architecture/`
189
+ instead; this split is an F-05 decision from R7 review.
190
+ - **`behavior.md` is NOT generated here.** Per F-05, per-context
191
+ `behavior.md` files are created by `/dflow:new-feature` Step 8.3
192
+ (completion flow) or by the P007a baseline-capture flow at the moment
193
+ the first bounded context is established. Creating empty
194
+ `behavior.md` files here would create stale placeholders.
195
+ - `domain/context-map.md` is **not** mandatory in the Brownfield track
196
+ (contexts emerge organically during domain extraction; the Greenfield
197
+ track makes this file mandatory because BCs are usually planned
198
+ up-front).
199
+
200
+ ### 3.2 Optional files (from Step 2 Q5)
201
+
202
+ Use the packaged scaffolding templates listed below; their project-local
203
+ outputs are under `dflow/specs/shared/` (the scaffolding root, not the
204
+ vendored workflow bundle). Compute the destination path:
205
+
206
+ | Scaffolding source | Destination in project |
207
+ |---|---|
208
+ | `scaffolding/_overview.md` | `dflow/specs/shared/_overview.md` |
209
+ | `scaffolding/_conventions.md` | `dflow/specs/shared/_conventions.md` (mandatory baseline) |
210
+ | `scaffolding/Git-principles-gitflow.md` | `dflow/specs/shared/Git-principles-gitflow.md` |
211
+ | `scaffolding/Git-principles-trunk.md` | `dflow/specs/shared/Git-principles-trunk.md` |
212
+ | `scaffolding/AI-AGENT-GUIDE.md` | `dflow/specs/shared/AI-AGENT-GUIDE.md` when at least one AI agent is selected |
213
+ | generated tool shim | `AGENTS.md`, `CLAUDE.md`, or `.github/copilot-instructions.md` when selected and missing |
214
+ | generated merge snippet | `dflow/specs/shared/*-snippet.md` when the selected tool file already exists |
215
+
216
+ ### 3.3 Present the preview
217
+
218
+ Present the complete file list as two tables, separating create vs
219
+ skip, and wait for developer confirmation:
220
+
221
+ > "Based on Step 1 inventory + Step 2 answers, here is what I'll do:
222
+ >
223
+ > **Will create ({N} files):**
224
+ >
225
+ > | Path | Source |
226
+ > |---|---|
227
+ > | `dflow/specs/features/active/.gitkeep` | (directory placeholder) |
228
+ > | `dflow/specs/features/completed/.gitkeep` | (directory placeholder) |
229
+ > | `dflow/specs/features/backlog/.gitkeep` | (directory placeholder) |
230
+ > | `dflow/specs/domain/glossary.md` | `templates/glossary.md` (mandatory baseline) |
231
+ > | `dflow/specs/shared/_conventions.md` | `scaffolding/_conventions.md` (mandatory baseline) |
232
+ > | `dflow/specs/migration/tech-debt.md` | `templates/tech-debt.md` (mandatory baseline) |
233
+ > | `dflow/specs/shared/_overview.md` | optional (you picked it) |
234
+ > | `dflow/specs/shared/Git-principles-trunk.md` | optional (you picked it) |
235
+ > | `dflow/specs/shared/AI-AGENT-GUIDE.md` | selected AI agent guide |
236
+ > | `CLAUDE.md` | selected tool shim because repo has no CLAUDE.md |
237
+ >
238
+ > **Will skip ({M} files — already present):**
239
+ >
240
+ > | Path | Reason |
241
+ > |---|---|
242
+ > | `dflow/specs/domain/glossary.md` | already exists (47 lines) |
243
+ >
244
+ > **Not creating** (per F-05 decision):
245
+ > - No `dflow/specs/domain/{context}/behavior.md` files. These are created
246
+ > later by `/dflow:new-feature` Step 8.3 or P007a when the first
247
+ > bounded context is established.
248
+ > - No `dflow/specs/domain/context-map.md`. Brownfield track treats BCs as
249
+ > emergent from domain extraction; this file becomes relevant later,
250
+ > typically when 2+ contexts coexist.
251
+ >
252
+ > Looks good? Reply 'yes' to proceed with the writes, or tell me what to
253
+ > adjust."
254
+
255
+ **→ Step Gate: Step 3 → Step 4**
256
+
257
+ Wait for explicit confirmation. If the developer asks to change the
258
+ selection, go back to Step 2 Q5 or Q6 and re-run Step 3.
259
+
260
+ ---
261
+
262
+ ## Step 4: Write Files (placeholder fill-in + existing-file protection)
263
+
264
+ Execute the write plan agreed in Step 3. Use the Write tool (or
265
+ mkdir-equivalent for directories).
266
+
267
+ ### 4.1 Existing-file protection (strict)
268
+
269
+ Before every single write, re-check: does the target path already
270
+ exist? If yes, **skip** — do not overwrite. Announce the skip:
271
+
272
+ > "Skipped `dflow/specs/domain/glossary.md` — already exists (unchanged)."
273
+
274
+ Only overwrite if the developer said explicitly "overwrite X" in
275
+ Step 2 (rare; usually a conscious reset during early adoption).
276
+
277
+ ### 4.2 Placeholder substitution
278
+
279
+ When writing from `scaffolding/` sources, substitute the placeholders
280
+ captured in Step 2:
281
+
282
+ | Placeholder | Substitution source |
283
+ |---|---|
284
+ | `{YYYY-MM-DD}` | Today's date (ISO format) |
285
+ | `{System Name}` / `{系統名稱}` | From Step 2 or repo folder name |
286
+ | `{業務領域}` | From Step 2 Q1 / Q2 context |
287
+ | `{Language}` | From Step 2 Q2 |
288
+ | `{Framework}` | From Step 2 Q2 |
289
+ | `{Framework version}` | From Step 2 Q2 |
290
+ | `{ORM / persistence}` | From Step 2 Q2 |
291
+ | `{ORM version}` | From Step 2 Q2 |
292
+ | `{prose-language}` | From Step 2 Q4 |
293
+
294
+ For placeholders the developer did not provide, keep the `{placeholder}`
295
+ token in the emitted file and add a one-line TODO comment so they
296
+ notice:
297
+
298
+ ```markdown
299
+ <!-- TODO: fill in 業務領域 on next review -->
300
+ ```
301
+
302
+ ### 4.3 Special case — AI agent instruction files
303
+
304
+ If the developer selected any AI coding agent in Q6, create
305
+ `dflow/specs/shared/AI-AGENT-GUIDE.md` as the canonical Dflow project
306
+ guide.
307
+
308
+ For each selected tool-specific file (`AGENTS.md`, `CLAUDE.md`,
309
+ `.github/copilot-instructions.md`):
310
+
311
+ - if the target file does not exist, create a small shim at the target
312
+ path that points to `dflow/specs/shared/AI-AGENT-GUIDE.md`
313
+ - if the target file already exists, do not overwrite it; write a merge
314
+ snippet under `dflow/specs/shared/` and report that the developer
315
+ should merge it manually
316
+
317
+ ### 4.4 Directory-only entries
318
+
319
+ For directories that Git otherwise wouldn't track (empty `active/` /
320
+ `completed/` / `backlog/`), seed a `.gitkeep` file so the directory
321
+ persists across clones.
322
+
323
+ **→ Transition (step-internal)**: Step 4 complete. Announce
324
+ > "Step 4 complete (files written). Entering Step 5: Results + next
325
+ > steps."
326
+
327
+ and continue.
328
+
329
+ ---
330
+
331
+ ## Step 5: Results Report + Next-step Recommendation
332
+
333
+ Summarise what actually happened and point at the next command.
334
+
335
+ ### 5.1 Summary report
336
+
337
+ ```
338
+ Init complete. Summary:
339
+
340
+ Created ({N} files):
341
+ ✓ dflow/specs/features/active/.gitkeep
342
+ ✓ dflow/specs/features/completed/.gitkeep
343
+ ✓ dflow/specs/features/backlog/.gitkeep
344
+ ✓ dflow/specs/domain/glossary.md
345
+ ✓ dflow/specs/shared/_conventions.md
346
+ ✓ dflow/specs/migration/tech-debt.md
347
+ ✓ dflow/specs/shared/_overview.md
348
+ ✓ dflow/specs/shared/Git-principles-trunk.md
349
+ ✓ CLAUDE.md (seeded from scaffolding snippet)
350
+
351
+ Skipped ({M} files already present):
352
+ - (none this run)
353
+
354
+ Deferred (not created here by design):
355
+ - dflow/specs/domain/{context}/behavior.md — created by /dflow:new-feature
356
+ Step 8.3 or P007a baseline capture
357
+ - dflow/specs/domain/context-map.md — created organically when you have
358
+ ≥2 bounded contexts
359
+ ```
360
+
361
+ ### 5.2 Next-step recommendation
362
+
363
+ Tailor the recommendation to the Step 1 scenario:
364
+
365
+ **Greenfield**:
366
+
367
+ > "Structure is ready. Recommended next step:
368
+ > - Run `/dflow:new-feature` to start your first feature
369
+ > (this will create `dflow/specs/features/active/{SPEC-ID}-{slug}/` and
370
+ > walk you through spec → domain concepts → implementation plan)"
371
+
372
+ **Brownfield**:
373
+
374
+ > "Structure is ready. Recommended next step:
375
+ > - First, open `dflow/specs/shared/_overview.md` and fill in the 'Current
376
+ > System State' and 'Known Issues' sections — this gives Dflow
377
+ > context when you triage existing behavior later.
378
+ > - Then run `/dflow:modify-existing` to work from an incoming change
379
+ > request (most common Brownfield entry), or `/dflow:new-feature`
380
+ > for a fresh piece of work.
381
+ > - When you touch a domain concept for the first time, the completion
382
+ > flow will prompt you to baseline it into
383
+ > `dflow/specs/domain/{context}/` — don't try to pre-fill everything
384
+ > up front."
385
+
386
+ **Already fully set up (Step 1 showed nothing to do)**:
387
+
388
+ > "Your project already has a complete Dflow layout — nothing to do.
389
+ > If you were expecting changes, let me know which file you wanted
390
+ > refreshed and I'll skip the safety-net."
391
+
392
+ ### 5.3 Optional: review project-level files
393
+
394
+ Remind the developer to review files that have `{placeholder}` tokens
395
+ still in them:
396
+
397
+ > "A few files still have `{placeholder}` tokens that need your input:
398
+ > - `dflow/specs/shared/_overview.md`: `{業務領域}`, `{團隊}`,
399
+ > `{使用者規模}`
400
+ > - `CLAUDE.md`: `{業務領域}`
401
+ >
402
+ > These are fine to leave for now; fill them in during your next
403
+ > review pass."
404
+
405
+ ---
406
+
407
+ ## Notes & references
408
+
409
+ - Scaffolding templates: packaged in the Dflow tarball; project-local
410
+ outputs land under `dflow/specs/shared/`
411
+ - `_index.md` feature template: `dflow/specs/shared/dflow-workflows/templates/_index.md`
412
+ (used by `/dflow:new-feature`, NOT by this flow)
413
+ - Git integration rules: `dflow/specs/shared/dflow-workflows/references/git-integration.md`