dflow-sdd-ddd 0.1.1 → 0.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/CHANGELOG.md +2055 -0
- package/CONTRIBUTING.md +123 -0
- package/README.en.md +345 -0
- package/README.md +222 -102
- package/TEMPLATE-COVERAGE.md +46 -0
- package/TEMPLATE-LANGUAGE-GLOSSARY.md +52 -0
- package/bin/dflow.js +37 -1
- package/docs/evaluating-dflow.en.md +238 -0
- package/docs/evaluating-dflow.md +169 -0
- package/docs/migrating-to-dflow-v1.md +230 -0
- package/docs/npm-publish-checklist.md +93 -0
- package/docs/release-versioning-policy.md +99 -0
- package/docs/using-with-claude-code.en.md +210 -0
- package/docs/using-with-claude-code.md +191 -0
- package/docs/using-with-codex.en.md +248 -0
- package/docs/using-with-codex.md +224 -0
- package/docs/using-with-gemini-cli.en.md +200 -0
- package/docs/using-with-gemini-cli.md +184 -0
- package/docs/using-with-github-copilot.en.md +136 -0
- package/docs/using-with-github-copilot.md +177 -0
- package/docs/why-ddd-for-ai.en.md +37 -0
- package/docs/why-ddd-for-ai.md +19 -17
- package/lib/init.js +97 -1
- package/package.json +5 -1
- package/templates/brownfield/scaffolding/AI-AGENT-GUIDE.md +29 -0
- package/templates/brownfield/scaffolding/CLAUDE-md-snippet.md +8 -7
- package/templates/brownfield/scaffolding/_conventions.md +1 -0
- package/templates/brownfield/templates/CLAUDE.md +1 -1
- package/templates/brownfield/templates/phase-spec.md +23 -20
- package/templates/greenfield/scaffolding/AI-AGENT-GUIDE.md +29 -0
- package/templates/greenfield/scaffolding/CLAUDE-md-snippet.md +9 -7
- package/templates/greenfield/scaffolding/_conventions.md +2 -1
- package/templates/greenfield/templates/CLAUDE.md +1 -1
- package/templates/greenfield/templates/phase-spec.md +24 -21
package/lib/init.js
CHANGED
|
@@ -3,6 +3,8 @@ const path = require('node:path');
|
|
|
3
3
|
const readline = require('node:readline');
|
|
4
4
|
const { TextDecoder } = require('node:util');
|
|
5
5
|
|
|
6
|
+
const pkg = require('../package.json');
|
|
7
|
+
|
|
6
8
|
const MIN_NODE_VERSION = '22.0.0';
|
|
7
9
|
const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
8
10
|
const TEMPLATE_ROOT = path.join(PACKAGE_ROOT, 'templates');
|
|
@@ -320,7 +322,7 @@ async function runPreflight(cwd) {
|
|
|
320
322
|
const legacySpecsPath = path.join(cwd, 'specs');
|
|
321
323
|
if ((await pathExists(legacySpecsPath)) && (await containsInitializedContent(legacySpecsPath))) {
|
|
322
324
|
warnings.push(
|
|
323
|
-
'Detected legacy specs/. Dflow V1 will not migrate or modify it; new files will be created under dflow/specs/.'
|
|
325
|
+
'Detected legacy specs/. Dflow V1 will not migrate or modify it; new files will be created under dflow/specs/. See docs/migrating-to-dflow-v1.md for the manual migration checklist.'
|
|
324
326
|
);
|
|
325
327
|
}
|
|
326
328
|
|
|
@@ -1117,6 +1119,7 @@ function buildSubstitutionMap(cwd, answers) {
|
|
|
1117
1119
|
['{tech-stack-summary}', answers.techStackSummary],
|
|
1118
1120
|
['{migration-context}', answers.migrationContext],
|
|
1119
1121
|
['{prose-language}', answers.proseLanguage],
|
|
1122
|
+
['{dflow-version}', pkg.version],
|
|
1120
1123
|
['{ASP.NET Core version}', extracted.aspNetCoreVersion || '{ASP.NET Core version}'],
|
|
1121
1124
|
['{EF Core version}', extracted.efCoreVersion || '{EF Core version}'],
|
|
1122
1125
|
['{MediatR version}', extracted.mediatRVersion || '{MediatR version}'],
|
|
@@ -1479,8 +1482,101 @@ function dedupe(values) {
|
|
|
1479
1482
|
return Array.from(new Set(values));
|
|
1480
1483
|
}
|
|
1481
1484
|
|
|
1485
|
+
async function runDoctor(options = {}) {
|
|
1486
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
1487
|
+
const stdout = options.stdout || process.stdout;
|
|
1488
|
+
const stderr = options.stderr || process.stderr;
|
|
1489
|
+
|
|
1490
|
+
try {
|
|
1491
|
+
if (compareVersions(process.versions.node, MIN_NODE_VERSION) < 0) {
|
|
1492
|
+
throw new InitError(`Dflow doctor requires Node.js ${MIN_NODE_VERSION}+.`, 1);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
const findings = [];
|
|
1496
|
+
await checkLegacyRootSpecsDir(cwd, findings);
|
|
1497
|
+
await checkLegacySharedDir(cwd, findings);
|
|
1498
|
+
await checkConventionsDflowVersion(cwd, findings);
|
|
1499
|
+
|
|
1500
|
+
printDoctorReport(stdout, cwd, findings);
|
|
1501
|
+
return 0;
|
|
1502
|
+
} catch (error) {
|
|
1503
|
+
if (error instanceof InitError) {
|
|
1504
|
+
stderr.write(`${error.message}\n`);
|
|
1505
|
+
return error.exitCode;
|
|
1506
|
+
}
|
|
1507
|
+
stderr.write(`${error && error.message ? error.message : error}\n`);
|
|
1508
|
+
return 1;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
async function checkLegacyRootSpecsDir(cwd, findings) {
|
|
1513
|
+
const legacyPath = path.join(cwd, 'specs');
|
|
1514
|
+
if ((await pathExists(legacyPath)) && (await containsInitializedContent(legacyPath))) {
|
|
1515
|
+
findings.push({
|
|
1516
|
+
level: 'warn',
|
|
1517
|
+
title: 'Legacy specs/ directory at project root',
|
|
1518
|
+
detail: 'V1 layout uses dflow/specs/ instead. The CLI does not modify root specs/.',
|
|
1519
|
+
action: 'See docs/migrating-to-dflow-v1.md (Step 1) for the manual migration steps.'
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
async function checkLegacySharedDir(cwd, findings) {
|
|
1525
|
+
const candidates = [
|
|
1526
|
+
path.join(cwd, 'dflow', 'specs', '_共用'),
|
|
1527
|
+
path.join(cwd, 'specs', '_共用')
|
|
1528
|
+
];
|
|
1529
|
+
for (const candidate of candidates) {
|
|
1530
|
+
if (await pathExists(candidate)) {
|
|
1531
|
+
const rel = normalizePath(path.relative(cwd, candidate));
|
|
1532
|
+
findings.push({
|
|
1533
|
+
level: 'warn',
|
|
1534
|
+
title: `Legacy ${rel}/ directory`,
|
|
1535
|
+
detail: 'V1 layout uses shared/ (canonical English directory name).',
|
|
1536
|
+
action: 'See docs/migrating-to-dflow-v1.md (Step 2) for the rename steps.'
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
async function checkConventionsDflowVersion(cwd, findings) {
|
|
1543
|
+
const conventionsPath = path.join(cwd, 'dflow', 'specs', 'shared', '_conventions.md');
|
|
1544
|
+
if (!(await pathExists(conventionsPath))) return;
|
|
1545
|
+
const content = await fs.readFile(conventionsPath, 'utf8').catch(() => '');
|
|
1546
|
+
if (!/^> Dflow Version:/m.test(content)) {
|
|
1547
|
+
findings.push({
|
|
1548
|
+
level: 'info',
|
|
1549
|
+
title: 'dflow/specs/shared/_conventions.md missing Dflow Version line',
|
|
1550
|
+
detail: 'V1 init writes a `> Dflow Version: <x.y.z>` line in the front matter automatically. This project predates that convention.',
|
|
1551
|
+
action: 'Optionally add the line manually so future migration / review can identify the spec convention version.'
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
function printDoctorReport(stdout, cwd, findings) {
|
|
1557
|
+
stdout.write(`Dflow Doctor ${pkg.version}\n`);
|
|
1558
|
+
stdout.write(`Project: ${cwd}\n\n`);
|
|
1559
|
+
|
|
1560
|
+
if (findings.length === 0) {
|
|
1561
|
+
stdout.write('All checks passed. No legacy artifacts detected.\n');
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
for (const finding of findings) {
|
|
1566
|
+
stdout.write(`[${finding.level}] ${finding.title}\n`);
|
|
1567
|
+
stdout.write(` ${finding.detail}\n`);
|
|
1568
|
+
stdout.write(` ${finding.action}\n\n`);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
const counts = { warn: 0, info: 0 };
|
|
1572
|
+
for (const f of findings) counts[f.level] = (counts[f.level] || 0) + 1;
|
|
1573
|
+
stdout.write(`${findings.length} finding(s): ${counts.warn} warn, ${counts.info} info.\n`);
|
|
1574
|
+
stdout.write('Doctor is read-only and does not modify any files.\n');
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1482
1577
|
module.exports = {
|
|
1483
1578
|
runConfigureAgents,
|
|
1579
|
+
runDoctor,
|
|
1484
1580
|
runInit,
|
|
1485
1581
|
validateProseLanguage,
|
|
1486
1582
|
ensureProseLanguageSection,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dflow-sdd-ddd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Spec-first SDD/DDD workflow kit for AI-assisted development",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"bin/",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"CONTRIBUTING.md",
|
|
15
17
|
"docs/",
|
|
16
18
|
"lib/",
|
|
19
|
+
"TEMPLATE-COVERAGE.md",
|
|
20
|
+
"TEMPLATE-LANGUAGE-GLOSSARY.md",
|
|
17
21
|
"templates/",
|
|
18
22
|
"README.md"
|
|
19
23
|
],
|
|
@@ -30,6 +30,7 @@ are not available in the current AI tool:
|
|
|
30
30
|
| `/dflow:finish-feature` | Implementation is complete and needs drift closure. |
|
|
31
31
|
| `/dflow:verify` | Specs, domain docs, implementation, and tests need consistency checks. |
|
|
32
32
|
| `/dflow:pr-review` | A change is ready for SDD/DDD review. |
|
|
33
|
+
| `/dflow:report-dflow-feedback` | You found a Dflow issue or improvement and want a sanitized upstream feedback draft. |
|
|
33
34
|
|
|
34
35
|
## Source of Truth
|
|
35
36
|
|
|
@@ -53,6 +54,34 @@ Dflow-owned project documents live under `dflow/specs/`.
|
|
|
53
54
|
4. Check drift before calling work complete.
|
|
54
55
|
5. Follow `dflow/specs/shared/_conventions.md`, especially `## Prose Language`.
|
|
55
56
|
|
|
57
|
+
## Pre-V1 Artifacts Detection
|
|
58
|
+
|
|
59
|
+
When working in a project that adopted Dflow before `dflow-sdd-ddd@0.1.0`,
|
|
60
|
+
you may encounter layout or naming patterns that predate the V1 baseline.
|
|
61
|
+
If any of the following appear, surface the observation to the developer
|
|
62
|
+
and recommend manual migration; do not rewrite anything silently.
|
|
63
|
+
|
|
64
|
+
Signals:
|
|
65
|
+
|
|
66
|
+
- Top-level `specs/` directory containing Dflow-shaped content (V1 layout
|
|
67
|
+
uses `dflow/specs/`).
|
|
68
|
+
- `_共用/` directory under `specs/` or `dflow/specs/` (V1 uses `shared/`).
|
|
69
|
+
- Section headings in Traditional Chinese where V1 templates render
|
|
70
|
+
canonical English; compare against `TEMPLATE-LANGUAGE-GLOSSARY.md` if
|
|
71
|
+
available.
|
|
72
|
+
- References to a runtime `/dflow:init-project` slash command (V1
|
|
73
|
+
replaced it with the Dflow CLI init command (`dflow init`, or
|
|
74
|
+
`npx dflow-sdd-ddd init` when using the no-install path)).
|
|
75
|
+
- A root `CLAUDE.md`, `AGENTS.md`, or equivalent that holds the full
|
|
76
|
+
Dflow workflow text instead of being a thin shim pointing to this
|
|
77
|
+
file.
|
|
78
|
+
- `dflow/specs/shared/_conventions.md` is missing the `> Dflow Version:`
|
|
79
|
+
front-matter line (V1 init writes it automatically).
|
|
80
|
+
|
|
81
|
+
Recommend `docs/migrating-to-dflow-v1.md` for the manual migration
|
|
82
|
+
checklist. Migration affects every spec the team has written; manual
|
|
83
|
+
review is required.
|
|
84
|
+
|
|
56
85
|
## Tool-Specific Notes
|
|
57
86
|
|
|
58
87
|
This file is the canonical Dflow guide. Root-level files such as
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
> This file is a **snippet**, not a standalone `CLAUDE.md`. Its purpose
|
|
6
6
|
> is to be merged into your project's root `CLAUDE.md`:
|
|
7
7
|
>
|
|
8
|
-
> - New `npx dflow-sdd-ddd init`
|
|
9
|
-
> `dflow/specs/shared/AI-AGENT-GUIDE.md` as
|
|
10
|
-
> creates a thin `CLAUDE.md` shim that points back to it.
|
|
8
|
+
> - New Dflow CLI init output (`dflow init`, or `npx dflow-sdd-ddd init` when
|
|
9
|
+
> using the no-install path) uses `dflow/specs/shared/AI-AGENT-GUIDE.md` as
|
|
10
|
+
> the canonical guide and creates a thin `CLAUDE.md` shim that points back to it.
|
|
11
11
|
> - Use this legacy snippet only if you intentionally want the older
|
|
12
12
|
> Claude-specific two-H2 layout in your project's root `CLAUDE.md`.
|
|
13
13
|
|
|
@@ -45,7 +45,7 @@ ASP.NET Core 做準備。
|
|
|
45
45
|
|
|
46
46
|
```
|
|
47
47
|
dflow/specs/
|
|
48
|
-
├── shared/ # 專案級治理文件(由
|
|
48
|
+
├── shared/ # 專案級治理文件(由 Dflow CLI init 寫入)
|
|
49
49
|
│ ├── _overview.md # 系統現況與遷移策略
|
|
50
50
|
│ ├── _conventions.md # 規格撰寫慣例
|
|
51
51
|
│ └── Git-principles-*.md # Git 規範(gitflow 或 trunk 版)
|
|
@@ -97,7 +97,7 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
97
97
|
當你作為 AI assistant 被呼叫時,若偵測到使用者需要 SDD/DDD 工作流
|
|
98
98
|
引導,請參考 Dflow entry points:
|
|
99
99
|
|
|
100
|
-
- `npx dflow-sdd-ddd init` — 專案初始化(建立 `dflow/specs/` 結構)
|
|
100
|
+
- Dflow CLI init command (`dflow init`, or `npx dflow-sdd-ddd init` when using the no-install path) — 專案初始化(建立 `dflow/specs/` 結構)
|
|
101
101
|
- `/dflow:new-feature` — 新功能開發
|
|
102
102
|
- `/dflow:new-phase` — 在 active feature 內新增階段
|
|
103
103
|
- `/dflow:modify-existing` — 修改既有功能
|
|
@@ -105,6 +105,7 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
105
105
|
- `/dflow:finish-feature` — feature 收尾
|
|
106
106
|
- `/dflow:pr-review` — PR 審查
|
|
107
107
|
- `/dflow:verify` — rules.md ↔ behavior.md 漂移檢查
|
|
108
|
+
- `/dflow:report-dflow-feedback` — 草擬給 Dflow upstream 的已清理回饋,不自動送出
|
|
108
109
|
- `/dflow:status` / `/dflow:next` / `/dflow:cancel` — 狀態管理
|
|
109
110
|
|
|
110
111
|
### Project-Level Supplemental Rules
|
|
@@ -161,5 +162,5 @@ When merging this snippet into an existing `CLAUDE.md`:
|
|
|
161
162
|
duplicate it.
|
|
162
163
|
|
|
163
164
|
If you are starting from scratch (no existing `CLAUDE.md`), the
|
|
164
|
-
`npx dflow-sdd-ddd init`
|
|
165
|
-
can refine from there.
|
|
165
|
+
the Dflow CLI init flow (`dflow init`, or `npx dflow-sdd-ddd init` when using
|
|
166
|
+
the no-install path) will install this snippet as-is and you can refine from there.
|
|
@@ -19,30 +19,33 @@ Template note (for AI):
|
|
|
19
19
|
`phase-spec-YYYY-MM-DD-{slug}.md` placed at
|
|
20
20
|
`dflow/specs/features/active/{SPEC-ID}-{slug}/`.
|
|
21
21
|
|
|
22
|
-
Each section below carries an HTML comment indicating its fill-in
|
|
23
|
-
These
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
The "Implementation Tasks" section at the end is generated by AI after
|
|
22
|
+
Each section below carries an HTML comment indicating its fill-in activity (Activity 1-4).
|
|
23
|
+
These activity markers let /dflow:status and the completion checklist track progress.
|
|
24
|
+
Activities correspond to SKILL.md § Guiding Questions by Activity:
|
|
25
|
+
Activity 1: Understanding (What & Why)
|
|
26
|
+
Activity 2: Domain Analysis (Where does it live?)
|
|
27
|
+
Activity 3: Spec Writing (Behavior + Rules + Edge Cases)
|
|
28
|
+
Activity 4: Implementation Planning
|
|
29
|
+
The "Implementation Tasks" section at the end is generated by AI after Activity 4 (Implementation Planning) is done
|
|
30
30
|
(see new-feature-flow.md Step 5 end / new-phase-flow.md Step 4 end /
|
|
31
31
|
modify-existing-flow.md Step 4 end).
|
|
32
32
|
|
|
33
|
+
Note: "phase 2+ specs" / "Phase 2+" in the BR and Delta sections below refers to
|
|
34
|
+
the N-th phase-spec of this feature (i.e. iteration unit), NOT an activity number.
|
|
35
|
+
|
|
33
36
|
For phase 2+ specs in the same feature: only list BRs that are NEW or
|
|
34
37
|
MODIFIED in this phase under "Business Rules"; do not re-copy unchanged BRs from
|
|
35
38
|
prior phases. The cumulative state lives in the feature's `_index.md`
|
|
36
39
|
Current BR Snapshot table.
|
|
37
40
|
-->
|
|
38
41
|
|
|
39
|
-
## Problem Description <!-- Fill timing:
|
|
42
|
+
## Problem Description <!-- Fill timing: Activity 1: Understanding -->
|
|
40
43
|
|
|
41
44
|
這個功能要解決什麼問題?誰需要它?
|
|
42
45
|
|
|
43
46
|
> 用使用者的角度描述,避免技術用語。
|
|
44
47
|
|
|
45
|
-
## Domain Concepts <!-- Fill timing:
|
|
48
|
+
## Domain Concepts <!-- Fill timing: Activity 2: Domain Analysis -->
|
|
46
49
|
|
|
47
50
|
涉及的 Domain 概念(引用 `dflow/specs/domain/{context}/models.md`):
|
|
48
51
|
|
|
@@ -55,7 +58,7 @@ Template note (for AI):
|
|
|
55
58
|
- [ ] `dflow/specs/domain/{context}/models.md` — 新增模型定義
|
|
56
59
|
|
|
57
60
|
<!-- dflow:section behavior-scenarios -->
|
|
58
|
-
## Behavior Scenarios <!-- Fill timing:
|
|
61
|
+
## Behavior Scenarios <!-- Fill timing: Activity 3: Spec Writing -->
|
|
59
62
|
|
|
60
63
|
### Main Success Scenario
|
|
61
64
|
|
|
@@ -75,7 +78,7 @@ Scenario: {替代情境}
|
|
|
75
78
|
Then {不同的預期結果}
|
|
76
79
|
```
|
|
77
80
|
|
|
78
|
-
## Business Rules <!-- Fill timing:
|
|
81
|
+
## Business Rules <!-- Fill timing: Activity 3: Spec Writing -->
|
|
79
82
|
|
|
80
83
|
> Phase 2+ 注意:本段僅列**本 phase 新增 / 修改到的 BR**;未變動的 BR 不重抄
|
|
81
84
|
> (它們的當前狀態見 feature 的 `_index.md` Current BR Snapshot 表)。
|
|
@@ -85,7 +88,7 @@ Scenario: {替代情境}
|
|
|
85
88
|
| BR-01 | {規則描述} | |
|
|
86
89
|
| BR-02 | {規則描述} | |
|
|
87
90
|
|
|
88
|
-
## Delta from prior phases <!-- Fill timing:
|
|
91
|
+
## Delta from prior phases <!-- Fill timing: Activity 3: Spec Writing; skip for the first phase -->
|
|
89
92
|
|
|
90
93
|
> 本段僅記**本 phase 相對前一 phase 的變化**,不累積歷史。歷史由 feature 目錄下
|
|
91
94
|
> 各 phase-spec 的本段串接閱讀;feature 層的當前累積狀態見 `_index.md` 的
|
|
@@ -119,14 +122,14 @@ Then {新的預期結果}
|
|
|
119
122
|
- BR-003 金額上限
|
|
120
123
|
- BR-005 提交後不可修改
|
|
121
124
|
|
|
122
|
-
## Edge Cases <!-- Fill timing:
|
|
125
|
+
## Edge Cases <!-- Fill timing: Activity 3: Spec Writing -->
|
|
123
126
|
|
|
124
127
|
| ID | Case | Expected Handling |
|
|
125
128
|
|---|---|---|
|
|
126
129
|
| EC-01 | {邊界描述} | {處理方式} |
|
|
127
130
|
| EC-02 | {邊界描述} | {處理方式} |
|
|
128
131
|
|
|
129
|
-
## Implementation Notes <!-- Fill timing:
|
|
132
|
+
## Implementation Notes <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
130
133
|
|
|
131
134
|
### Current WebForms Implementation
|
|
132
135
|
|
|
@@ -148,7 +151,7 @@ Then {新的預期結果}
|
|
|
148
151
|
|
|
149
152
|
> 遷移時需要注意的事項,或者現在的設計如何幫助未來遷移。
|
|
150
153
|
|
|
151
|
-
## Data Structure Changes <!-- Fill timing:
|
|
154
|
+
## Data Structure Changes <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
152
155
|
|
|
153
156
|
> 涉及的資料表與欄位變更(如有)
|
|
154
157
|
|
|
@@ -156,7 +159,7 @@ Then {新的預期結果}
|
|
|
156
159
|
|---|---|---|---|
|
|
157
160
|
| {Table} | {Column} | 新增/修改/刪除 | |
|
|
158
161
|
|
|
159
|
-
## Test Strategy <!-- Fill timing:
|
|
162
|
+
## Test Strategy <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
160
163
|
|
|
161
164
|
> Domain 層的單元測試應驗證哪些行為?
|
|
162
165
|
|
|
@@ -164,14 +167,14 @@ Then {新的預期結果}
|
|
|
164
167
|
- [ ] {測試案例 2}
|
|
165
168
|
|
|
166
169
|
<!-- dflow:section open-questions -->
|
|
167
|
-
## Open Questions <!-- Fill timing:
|
|
170
|
+
## Open Questions <!-- Fill timing: Activity 1-4; any time during planning -->
|
|
168
171
|
|
|
169
172
|
- {尚未釐清的需求、規則、資料或實作問題}
|
|
170
173
|
|
|
171
174
|
<!-- dflow:section implementation-tasks -->
|
|
172
|
-
## Implementation Tasks <!-- Fill timing: generated by AI after
|
|
175
|
+
## Implementation Tasks <!-- Fill timing: generated by AI after Activity 4: Implementation Planning; all items should be checked at completion -->
|
|
173
176
|
|
|
174
|
-
> AI 在
|
|
177
|
+
> AI 在 Activity 4 (Implementation Planning) 完成後,根據「Implementation Notes」產生的具體任務清單。
|
|
175
178
|
> 格式:`[LAYER]-[NUMBER]: 任務描述`
|
|
176
179
|
> 分類標籤(Brownfield track):
|
|
177
180
|
> - `DOMAIN` — Domain 層類別、VO、Service、Interface
|
|
@@ -30,6 +30,7 @@ are not available in the current AI tool:
|
|
|
30
30
|
| `/dflow:finish-feature` | Implementation is complete and needs drift closure. |
|
|
31
31
|
| `/dflow:verify` | Specs, domain docs, implementation, and tests need consistency checks. |
|
|
32
32
|
| `/dflow:pr-review` | A change is ready for SDD/DDD review. |
|
|
33
|
+
| `/dflow:report-dflow-feedback` | You found a Dflow issue or improvement and want a sanitized upstream feedback draft. |
|
|
33
34
|
|
|
34
35
|
## Source of Truth
|
|
35
36
|
|
|
@@ -53,6 +54,34 @@ Dflow-owned project documents live under `dflow/specs/`.
|
|
|
53
54
|
4. Check drift before calling work complete.
|
|
54
55
|
5. Follow `dflow/specs/shared/_conventions.md`, especially `## Prose Language`.
|
|
55
56
|
|
|
57
|
+
## Pre-V1 Artifacts Detection
|
|
58
|
+
|
|
59
|
+
When working in a project that adopted Dflow before `dflow-sdd-ddd@0.1.0`,
|
|
60
|
+
you may encounter layout or naming patterns that predate the V1 baseline.
|
|
61
|
+
If any of the following appear, surface the observation to the developer
|
|
62
|
+
and recommend manual migration; do not rewrite anything silently.
|
|
63
|
+
|
|
64
|
+
Signals:
|
|
65
|
+
|
|
66
|
+
- Top-level `specs/` directory containing Dflow-shaped content (V1 layout
|
|
67
|
+
uses `dflow/specs/`).
|
|
68
|
+
- `_共用/` directory under `specs/` or `dflow/specs/` (V1 uses `shared/`).
|
|
69
|
+
- Section headings in Traditional Chinese where V1 templates render
|
|
70
|
+
canonical English; compare against `TEMPLATE-LANGUAGE-GLOSSARY.md` if
|
|
71
|
+
available.
|
|
72
|
+
- References to a runtime `/dflow:init-project` slash command (V1
|
|
73
|
+
replaced it with the Dflow CLI init command (`dflow init`, or
|
|
74
|
+
`npx dflow-sdd-ddd init` when using the no-install path)).
|
|
75
|
+
- A root `CLAUDE.md`, `AGENTS.md`, or equivalent that holds the full
|
|
76
|
+
Dflow workflow text instead of being a thin shim pointing to this
|
|
77
|
+
file.
|
|
78
|
+
- `dflow/specs/shared/_conventions.md` is missing the `> Dflow Version:`
|
|
79
|
+
front-matter line (V1 init writes it automatically).
|
|
80
|
+
|
|
81
|
+
Recommend `docs/migrating-to-dflow-v1.md` for the manual migration
|
|
82
|
+
checklist. Migration affects every spec the team has written; manual
|
|
83
|
+
review is required.
|
|
84
|
+
|
|
56
85
|
## Tool-Specific Notes
|
|
57
86
|
|
|
58
87
|
This file is the canonical Dflow guide. Root-level files such as
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
## How to use this snippet
|
|
16
16
|
|
|
17
|
-
- New `npx dflow-sdd-ddd init`
|
|
18
|
-
`dflow/specs/shared/AI-AGENT-GUIDE.md` as
|
|
19
|
-
a thin `CLAUDE.md` shim that points back to it.
|
|
17
|
+
- New Dflow CLI init output (`dflow init`, or `npx dflow-sdd-ddd init` when
|
|
18
|
+
using the no-install path) uses `dflow/specs/shared/AI-AGENT-GUIDE.md` as
|
|
19
|
+
the canonical guide and creates a thin `CLAUDE.md` shim that points back to it.
|
|
20
20
|
- Use this legacy snippet only if you intentionally want the older
|
|
21
21
|
Claude-specific two-H2 layout in your project's root `CLAUDE.md`.
|
|
22
22
|
|
|
@@ -66,7 +66,7 @@ Presentation → Application → Domain ← Infrastructure
|
|
|
66
66
|
### Project Structure
|
|
67
67
|
|
|
68
68
|
完整 specs 目錄結構見 Dflow skill `SKILL.md` § "Project Structure"。
|
|
69
|
-
|
|
69
|
+
以下只列本專案當前狀態(Dflow CLI init 建立後可能還未全填):
|
|
70
70
|
|
|
71
71
|
```
|
|
72
72
|
dflow/specs/
|
|
@@ -101,13 +101,14 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
101
101
|
- `sdd-ddd-greenfield-skill/references/` 內各 flow 文件
|
|
102
102
|
|
|
103
103
|
本專案採用的 Dflow entry points:
|
|
104
|
-
- `npx dflow-sdd-ddd init` — 專案初始化(一次性,已執行過)
|
|
104
|
+
- Dflow CLI init command (`dflow init`, or `npx dflow-sdd-ddd init` when using the no-install path) — 專案初始化(一次性,已執行過)
|
|
105
105
|
- `/dflow:new-feature` — 新功能
|
|
106
106
|
- `/dflow:new-phase` — 既有 active feature 加新 phase
|
|
107
107
|
- `/dflow:modify-existing` — 修改既有行為
|
|
108
108
|
- `/dflow:bug-fix` — Bug 修復
|
|
109
109
|
- `/dflow:finish-feature` — Feature 收尾 + 整合摘要
|
|
110
110
|
- `/dflow:pr-review` — PR 審查檢查點
|
|
111
|
+
- `/dflow:report-dflow-feedback` — 草擬給 Dflow upstream 的已清理回饋,不自動送出
|
|
111
112
|
|
|
112
113
|
### Core Principles (Project Reaffirmed)
|
|
113
114
|
|
|
@@ -164,5 +165,6 @@ AI 的完整決策樹、Workflow Transparency、Ceremony Scaling 三層判準
|
|
|
164
165
|
- The snippet does NOT re-copy the Dflow decision tree, Ceremony
|
|
165
166
|
Scaling criteria, or per-flow step details — those live in the
|
|
166
167
|
skill and change when the skill evolves
|
|
167
|
-
- Re-
|
|
168
|
-
|
|
168
|
+
- Re-running the Dflow CLI init command (`dflow init`, or `npx dflow-sdd-ddd init`
|
|
169
|
+
when using the no-install path) will NOT overwrite an existing `CLAUDE.md`;
|
|
170
|
+
if you want to re-sync, merge manually
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Spec Writing Conventions — {System Name}
|
|
4
4
|
|
|
5
5
|
> Created: {YYYY-MM-DD}
|
|
6
|
+
> Dflow Version: {dflow-version}
|
|
6
7
|
> Scope: how spec documents are authored and named in this project.
|
|
7
8
|
> Audience: engineers writing specs; AI assistants producing spec drafts.
|
|
8
9
|
|
|
@@ -100,7 +101,7 @@ Project-specific guidance when filling these templates:
|
|
|
100
101
|
descriptions (Mermaid state diagram or Given / When / Then + "And
|
|
101
102
|
the Aggregate is in state X").
|
|
102
103
|
- **CQRS split**: commands (write) vs queries (read) should be
|
|
103
|
-
identified during
|
|
104
|
+
identified during Activity 4 (Implementation Planning). Commands
|
|
104
105
|
generally map 1:1 to an Aggregate method; queries bypass the
|
|
105
106
|
Domain layer and read projections.
|
|
106
107
|
|
|
@@ -19,17 +19,20 @@ Template note (for AI):
|
|
|
19
19
|
`phase-spec-YYYY-MM-DD-{slug}.md` placed at
|
|
20
20
|
`dflow/specs/features/active/{SPEC-ID}-{slug}/`.
|
|
21
21
|
|
|
22
|
-
Each section below carries an HTML comment indicating its fill-in
|
|
23
|
-
These
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
The "Implementation Tasks" section at the end is generated by AI after
|
|
22
|
+
Each section below carries an HTML comment indicating its fill-in activity (Activity 1-4).
|
|
23
|
+
These activity markers let /dflow:status and the completion checklist track progress.
|
|
24
|
+
Activities correspond to SKILL.md § Guiding Questions by Activity:
|
|
25
|
+
Activity 1: Understanding (What & Why)
|
|
26
|
+
Activity 2: Domain Modeling (BC, Aggregate, VO, Events)
|
|
27
|
+
Activity 3: Spec Writing (Behavior + Rules + Edge Cases)
|
|
28
|
+
Activity 4: Implementation Planning (layer-by-layer)
|
|
29
|
+
The "Implementation Tasks" section at the end is generated by AI after Activity 4 (Implementation Planning) is done
|
|
30
30
|
(see new-feature-flow.md Step 5 end / new-phase-flow.md Step 4 end /
|
|
31
31
|
modify-existing-flow.md Step 3 end).
|
|
32
32
|
|
|
33
|
+
Note: "phase 2+ specs" / "Phase 2+" in the BR and Delta sections below refers to
|
|
34
|
+
the N-th phase-spec of this feature (i.e. iteration unit), NOT an activity number.
|
|
35
|
+
|
|
33
36
|
For phase 2+ specs in the same feature: only list BRs that are NEW or
|
|
34
37
|
MODIFIED in this phase under "Business Rules"; do not re-copy unchanged BRs from
|
|
35
38
|
prior phases. The cumulative state lives in the feature's `_index.md`
|
|
@@ -37,11 +40,11 @@ Template note (for AI):
|
|
|
37
40
|
bounded context's `rules.md` / `behavior.md` (synced at /dflow:finish-feature).
|
|
38
41
|
-->
|
|
39
42
|
|
|
40
|
-
## Problem Description <!-- Fill timing:
|
|
43
|
+
## Problem Description <!-- Fill timing: Activity 1: Understanding -->
|
|
41
44
|
|
|
42
45
|
> 用使用者的角度描述,避免技術用語。
|
|
43
46
|
|
|
44
|
-
## Domain Concepts <!-- Fill timing:
|
|
47
|
+
## Domain Concepts <!-- Fill timing: Activity 2: Domain Modeling -->
|
|
45
48
|
|
|
46
49
|
涉及的 Domain 概念(引用 `dflow/specs/domain/{context}/models.md`):
|
|
47
50
|
|
|
@@ -55,7 +58,7 @@ Template note (for AI):
|
|
|
55
58
|
- [ ] `dflow/specs/domain/{context}/events.md` — Domain Events
|
|
56
59
|
|
|
57
60
|
<!-- dflow:section behavior-scenarios -->
|
|
58
|
-
## Behavior Scenarios <!-- Fill timing:
|
|
61
|
+
## Behavior Scenarios <!-- Fill timing: Activity 3: Spec Writing -->
|
|
59
62
|
|
|
60
63
|
### Main Success Scenario
|
|
61
64
|
|
|
@@ -76,7 +79,7 @@ Scenario: {替代情境}
|
|
|
76
79
|
Then {不同結果}
|
|
77
80
|
```
|
|
78
81
|
|
|
79
|
-
## Business Rules <!-- Fill timing:
|
|
82
|
+
## Business Rules <!-- Fill timing: Activity 3: Spec Writing -->
|
|
80
83
|
|
|
81
84
|
> Phase 2+ 注意:本段僅列**本 phase 新增 / 修改到的 BR**;未變動的 BR 不重抄
|
|
82
85
|
> (它們的當前狀態見 feature 的 `_index.md` Current BR Snapshot 表)。
|
|
@@ -86,7 +89,7 @@ Scenario: {替代情境}
|
|
|
86
89
|
| BR-01 | {規則描述} | Domain: {Entity/VO/Service} |
|
|
87
90
|
| BR-02 | {規則描述} | Domain: {Entity/VO/Service} |
|
|
88
91
|
|
|
89
|
-
## Delta from prior phases <!-- Fill timing:
|
|
92
|
+
## Delta from prior phases <!-- Fill timing: Activity 3: Spec Writing; skip for the first phase -->
|
|
90
93
|
|
|
91
94
|
> 本段僅記**本 phase 相對前一 phase 的變化**,不累積歷史。歷史由 feature 目錄下
|
|
92
95
|
> 各 phase-spec 的本段串接閱讀;feature 層的當前累積狀態見 `_index.md` 的
|
|
@@ -122,19 +125,19 @@ And {產生的 Domain Event}
|
|
|
122
125
|
- BR-003 金額上限
|
|
123
126
|
- BR-005 提交後不可修改
|
|
124
127
|
|
|
125
|
-
## Edge Cases <!-- Fill timing:
|
|
128
|
+
## Edge Cases <!-- Fill timing: Activity 3: Spec Writing -->
|
|
126
129
|
|
|
127
130
|
| ID | Case | Expected Handling |
|
|
128
131
|
|---|---|---|
|
|
129
132
|
| EC-01 | {邊界描述} | {處理方式} |
|
|
130
133
|
|
|
131
|
-
## Domain Events <!-- Fill timing:
|
|
134
|
+
## Domain Events <!-- Fill timing: Activity 2-3; draft during Domain Modeling, finalized during Spec Writing -->
|
|
132
135
|
|
|
133
136
|
| Event | Trigger | Handler | Sync / Async |
|
|
134
137
|
|---|---|---|---|
|
|
135
138
|
| {EventName} | {何時觸發} | {Handler} | 同步/異步 |
|
|
136
139
|
|
|
137
|
-
## Implementation Plan (Layer by Layer) <!-- Fill timing:
|
|
140
|
+
## Implementation Plan (Layer by Layer) <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
138
141
|
|
|
139
142
|
### Domain Layer
|
|
140
143
|
> Aggregate 設計、Value Objects、Events、Interfaces
|
|
@@ -148,13 +151,13 @@ And {產生的 Domain Event}
|
|
|
148
151
|
### Presentation Layer
|
|
149
152
|
> API Endpoint 設計、Request/Response 模型
|
|
150
153
|
|
|
151
|
-
## Data Structure Changes <!-- Fill timing:
|
|
154
|
+
## Data Structure Changes <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
152
155
|
|
|
153
156
|
| Table | Column | Change Type | Description |
|
|
154
157
|
|---|---|---|---|
|
|
155
158
|
| {Table} | {Column} | 新增/修改/刪除 | |
|
|
156
159
|
|
|
157
|
-
## Test Strategy <!-- Fill timing:
|
|
160
|
+
## Test Strategy <!-- Fill timing: Activity 4: Implementation Planning -->
|
|
158
161
|
|
|
159
162
|
### Domain Unit Tests
|
|
160
163
|
- [ ] {不變條件測試}
|
|
@@ -169,14 +172,14 @@ And {產生的 Domain Event}
|
|
|
169
172
|
- [ ] {Repository 測試}
|
|
170
173
|
|
|
171
174
|
<!-- dflow:section open-questions -->
|
|
172
|
-
## Open Questions <!-- Fill timing:
|
|
175
|
+
## Open Questions <!-- Fill timing: Activity 1-4; any time during planning -->
|
|
173
176
|
|
|
174
177
|
- {尚未釐清的需求、規則、資料或實作問題}
|
|
175
178
|
|
|
176
179
|
<!-- dflow:section implementation-tasks -->
|
|
177
|
-
## Implementation Tasks <!-- Fill timing: generated by AI after
|
|
180
|
+
## Implementation Tasks <!-- Fill timing: generated by AI after Activity 4: Implementation Planning; all items should be checked at completion -->
|
|
178
181
|
|
|
179
|
-
> AI 在
|
|
182
|
+
> AI 在 Activity 4 (Implementation Planning) 完成後,根據「Implementation Plan (Layer by Layer)」產生的具體任務清單。
|
|
180
183
|
> 格式:`[LAYER]-[NUMBER]: 任務描述`
|
|
181
184
|
> 分類標籤(Greenfield track,對應 Clean Architecture 各層):
|
|
182
185
|
> - `DOMAIN` — Aggregate、Entity、VO、Domain Event、Domain Service、Repository Interface
|