@anselmdk/feature-spec-md 0.1.1 → 0.2.1
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/README.md +94 -50
- package/SPEC_FORMAT.md +200 -38
- package/dist/cli.js +178 -28
- package/dist/cli.js.map +1 -1
- package/dist/featureSpecs.d.ts +34 -0
- package/dist/featureSpecs.d.ts.map +1 -0
- package/dist/featureSpecs.js +240 -0
- package/dist/featureSpecs.js.map +1 -0
- package/dist/filePatterns.d.ts.map +1 -1
- package/dist/filePatterns.js +4 -0
- package/dist/filePatterns.js.map +1 -1
- package/dist/html.d.ts +3 -0
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +3 -0
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +3 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -338
- package/dist/index.js.map +1 -1
- package/dist/playwright.d.ts.map +1 -1
- package/dist/playwright.js +13 -21
- package/dist/playwright.js.map +1 -1
- package/dist/reportTemplate.d.ts +4 -1
- package/dist/reportTemplate.d.ts.map +1 -1
- package/dist/reportTemplate.js +251 -21
- package/dist/reportTemplate.js.map +1 -1
- package/dist/screenshots.d.ts.map +1 -1
- package/dist/screenshots.js +4 -0
- package/dist/screenshots.js.map +1 -1
- package/dist/specDocuments.d.ts +86 -0
- package/dist/specDocuments.d.ts.map +1 -0
- package/dist/specDocuments.js +351 -0
- package/dist/specDocuments.js.map +1 -0
- package/dist/specMarkdown.d.ts +26 -0
- package/dist/specMarkdown.d.ts.map +1 -0
- package/dist/specMarkdown.js +126 -0
- package/dist/specMarkdown.js.map +1 -0
- package/dist/testImplementationReport.d.ts +53 -0
- package/dist/testImplementationReport.d.ts.map +1 -0
- package/dist/testImplementationReport.js +160 -0
- package/dist/testImplementationReport.js.map +1 -0
- package/dist/types.d.ts +76 -11
- package/dist/types.d.ts.map +1 -1
- package/docs/releasing.md +107 -0
- package/docs/spec-driven-flow.md +175 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -1,67 +1,123 @@
|
|
|
1
1
|
# feature-spec-md
|
|
2
2
|
|
|
3
|
-
Markdown
|
|
3
|
+
Markdown specs for AI-assisted, testable spec driven development.
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The concept is deliberately small:
|
|
6
6
|
|
|
7
7
|
```txt
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
model + features + stack + design
|
|
9
|
+
-> AI-written executable tests that reference stable spec IDs
|
|
10
|
+
-> validation, coverage, screenshots, and reports
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
The
|
|
13
|
+
The specs are meant to be written with an AI before implementation. The tests are meant to be written with an AI from those specs. `feature-spec-md` checks that the Markdown stays structured and that executable tests still cover the model items, rules, and scenarios the specs define.
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## What You Write
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Use four ordinary Markdown document types:
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
```txt
|
|
20
|
+
*.model.md shared domain vocabulary
|
|
21
|
+
*.feature.md user-facing behavior, rules, and scenarios
|
|
22
|
+
*.stack.md technical platform choices
|
|
23
|
+
*.design.md product, UI, and interaction direction
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Each document has frontmatter, a short `## Purpose`, and stable IDs. Tests reference those IDs in titles, tags, annotations, comments, or metadata.
|
|
27
|
+
|
|
28
|
+
```md
|
|
29
|
+
### ACCOUNT-ACCESS-S001: Registered person signs in
|
|
30
|
+
|
|
31
|
+
Given a registered person is on the sign-in page
|
|
32
|
+
When they request and open a valid sign-in link
|
|
33
|
+
Then they are signed in
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
test("ACCOUNT-ACCESS-S001 registered person signs in", async ({ page }) => {
|
|
38
|
+
// Covers ACCOUNT-ACCESS-R001 and ACCOUNT-M001.
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See [SPEC_FORMAT.md](SPEC_FORMAT.md) for the exact document format.
|
|
20
43
|
|
|
21
|
-
|
|
22
|
-
- `## Purpose` for intent
|
|
23
|
-
- `## Rules` for general business rules
|
|
24
|
-
- `## Scenarios` for Given / When / Then examples
|
|
44
|
+
## Install
|
|
25
45
|
|
|
26
|
-
|
|
46
|
+
```bash
|
|
47
|
+
npm install -D @anselmdk/feature-spec-md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Create starter specs:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx feature-spec-md init --kind model --dir specs
|
|
54
|
+
npx feature-spec-md init --kind feature --dir specs
|
|
55
|
+
npx feature-spec-md init --kind stack --dir specs
|
|
56
|
+
npx feature-spec-md init --kind design --dir specs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Workflow
|
|
60
|
+
|
|
61
|
+
1. Ask an AI to draft or update `*.model.md`, `*.feature.md`, `*.stack.md`, and `*.design.md` files.
|
|
62
|
+
2. Run `npx feature-spec-md check` until the spec set is valid.
|
|
63
|
+
3. Ask an AI to write executable tests from the specs, preserving the relevant `-M001`, `-R001`, and `-S001` IDs in the test source.
|
|
64
|
+
4. Run `npx feature-spec-md coverage` to see which scenarios, rules, and model items have tests.
|
|
65
|
+
5. Run `npx feature-spec-md report` to generate an HTML implementation report for review or CI artifacts.
|
|
66
|
+
|
|
67
|
+
The longer flow, including AI prompts and CI setup, is in [docs/spec-driven-flow.md](docs/spec-driven-flow.md).
|
|
27
68
|
|
|
28
69
|
## CLI
|
|
29
70
|
|
|
30
71
|
```bash
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
npm run dev -- report --specs "examples/**/*.feature.md" --tests "tests/**/*.test.ts" --screenshots "test-results/spec-report/screenshots-*.json"
|
|
72
|
+
npx feature-spec-md check
|
|
73
|
+
npx feature-spec-md coverage --fail-on-missing
|
|
74
|
+
npx feature-spec-md report --out test-results/feature-spec-report/index.html
|
|
35
75
|
```
|
|
36
76
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
By default the CLI scans:
|
|
78
|
+
|
|
79
|
+
```txt
|
|
80
|
+
specs/**/*.model.md
|
|
81
|
+
specs/**/*.feature.md
|
|
82
|
+
specs/**/*.stack.md
|
|
83
|
+
specs/**/*.design.md
|
|
84
|
+
tests/**/*.spec.ts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use explicit patterns when your project uses different paths:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx feature-spec-md check \
|
|
91
|
+
--specs "product/**/*.model.md,product/**/*.feature.md,product/**/*.stack.md,product/**/*.design.md" \
|
|
92
|
+
--tests "e2e/**/*.spec.ts"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The `check` command validates spec structure, references between documents, and test coverage. Scenario coverage is required by default when tests are scanned. Use `--require-scenario-coverage=false` while drafting.
|
|
96
|
+
|
|
97
|
+
The `coverage` command prints a terminal implementation report. Use `--fail-on-missing` when missing scenario tests should fail CI.
|
|
98
|
+
|
|
99
|
+
The `report` command writes an HTML report. It can include screenshot evidence from Playwright or another test runner by passing one or more screenshot manifest files:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx feature-spec-md report \
|
|
103
|
+
--screenshots "test-results/spec-report/screenshots-*.json"
|
|
52
104
|
```
|
|
53
105
|
|
|
54
106
|
## Library API
|
|
55
107
|
|
|
108
|
+
Most integrations can use the top-level document API:
|
|
109
|
+
|
|
56
110
|
```ts
|
|
57
111
|
import {
|
|
58
|
-
|
|
59
|
-
|
|
112
|
+
checkSpecDocuments,
|
|
113
|
+
parseSpecDocument,
|
|
60
114
|
renderHtmlReport,
|
|
61
|
-
|
|
62
|
-
} from "feature-spec-md";
|
|
115
|
+
validateSpecDocument,
|
|
116
|
+
} from "@anselmdk/feature-spec-md";
|
|
63
117
|
```
|
|
64
118
|
|
|
119
|
+
Feature-only helpers such as `parseFeatureSpec` and `checkFeatureSpecs` remain available for compatibility.
|
|
120
|
+
|
|
65
121
|
## Development
|
|
66
122
|
|
|
67
123
|
```bash
|
|
@@ -73,16 +129,4 @@ npm run build
|
|
|
73
129
|
|
|
74
130
|
## Releases
|
|
75
131
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Release candidates are published manually from GitHub Actions:
|
|
79
|
-
|
|
80
|
-
1. Open the `Publish RC to npm` workflow.
|
|
81
|
-
2. Run the workflow from `main`.
|
|
82
|
-
3. The workflow verifies the package, creates a prerelease version using the current package version and GitHub run number, and publishes it with the npm `rc` dist-tag.
|
|
83
|
-
|
|
84
|
-
Install the latest release candidate with:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npm install @anselmdk/feature-spec-md@rc
|
|
88
|
-
```
|
|
132
|
+
Release candidates and stable releases are documented in [docs/releasing.md](docs/releasing.md).
|
package/SPEC_FORMAT.md
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
# Feature Spec Markdown
|
|
1
|
+
# Feature Spec Markdown Format
|
|
2
2
|
|
|
3
|
-
Feature Spec Markdown is a lightweight
|
|
3
|
+
Feature Spec Markdown is a lightweight format for testable specs.
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
It uses ordinary Markdown plus stable IDs so an AI can write clear product specs, another AI pass can write executable tests from those specs, and tooling can verify that the tests still cover the documented behavior.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Document Set
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
A spec set can contain four document types:
|
|
10
10
|
|
|
11
11
|
```txt
|
|
12
|
+
*.model.md
|
|
12
13
|
*.feature.md
|
|
14
|
+
*.stack.md
|
|
15
|
+
*.design.md
|
|
13
16
|
```
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
- `*.model.md` defines shared domain vocabulary and global domain rules.
|
|
19
|
+
- `*.feature.md` defines user-facing behavior with rules and scenarios.
|
|
20
|
+
- `*.stack.md` defines technical platform choices and their rationale.
|
|
21
|
+
- `*.design.md` defines product, UI, layout, visual, and interaction direction.
|
|
22
|
+
|
|
23
|
+
The short version:
|
|
16
24
|
|
|
17
25
|
```txt
|
|
18
|
-
|
|
26
|
+
model tells tests what things mean
|
|
27
|
+
features tell tests what behavior must work
|
|
28
|
+
stack tells implementation what tools and constraints to use
|
|
29
|
+
design tells implementation what experience to create
|
|
19
30
|
```
|
|
20
31
|
|
|
21
32
|
## Frontmatter
|
|
@@ -24,9 +35,10 @@ Every file starts with YAML-like frontmatter:
|
|
|
24
35
|
|
|
25
36
|
```md
|
|
26
37
|
---
|
|
27
|
-
id:
|
|
28
|
-
title:
|
|
38
|
+
id: KANBAN-CARD-AUTHORING
|
|
39
|
+
title: Card authoring
|
|
29
40
|
status: draft
|
|
41
|
+
model: KANBAN
|
|
30
42
|
---
|
|
31
43
|
```
|
|
32
44
|
|
|
@@ -39,48 +51,81 @@ Optional fields:
|
|
|
39
51
|
|
|
40
52
|
- `status`: `draft`, `active`, or `deprecated`
|
|
41
53
|
- `owner`
|
|
54
|
+
- `model`: a single referenced model id, for feature and design files
|
|
55
|
+
- `models`: comma-separated referenced model ids, for feature and design files
|
|
56
|
+
|
|
57
|
+
IDs use uppercase words separated by hyphens. IDs are the contract between specs, tests, reports, and implementation work.
|
|
58
|
+
|
|
59
|
+
## Purpose
|
|
60
|
+
|
|
61
|
+
Every model, feature, stack, and design file MUST include a short `## Purpose` section.
|
|
62
|
+
|
|
63
|
+
Purpose explains the document boundary and intent. It SHOULD be one or two short paragraphs and SHOULD NOT contain rules, scenarios, implementation details, or roadmap notes.
|
|
42
64
|
|
|
43
|
-
##
|
|
65
|
+
## Model Files
|
|
66
|
+
|
|
67
|
+
Model files use the `.model.md` suffix.
|
|
68
|
+
|
|
69
|
+
Required sections:
|
|
44
70
|
|
|
45
71
|
```md
|
|
46
|
-
#
|
|
72
|
+
# Kanban model
|
|
47
73
|
|
|
48
74
|
## Purpose
|
|
49
75
|
|
|
50
|
-
##
|
|
51
|
-
|
|
52
|
-
## Scenarios
|
|
76
|
+
## Model
|
|
53
77
|
```
|
|
54
78
|
|
|
79
|
+
Optional sections:
|
|
80
|
+
|
|
81
|
+
```md
|
|
55
82
|
## Rules
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Model items use stable `-M001` IDs:
|
|
86
|
+
|
|
87
|
+
```md
|
|
88
|
+
### KANBAN-M001: Card
|
|
89
|
+
|
|
90
|
+
A card represents one work item on the board.
|
|
91
|
+
```
|
|
56
92
|
|
|
57
|
-
|
|
93
|
+
Model rules use stable `-R001` IDs and describe global invariants for the domain vocabulary:
|
|
58
94
|
|
|
59
95
|
```md
|
|
60
|
-
-
|
|
61
|
-
- ACCOUNT-R002: The system MUST NOT reveal whether an unknown email address belongs to an account.
|
|
62
|
-
- ACCOUNT-R003: A signed-in person SHOULD be returned to the page they originally requested.
|
|
96
|
+
- KANBAN-R001: A card MUST have one current workflow state.
|
|
63
97
|
```
|
|
64
98
|
|
|
65
|
-
|
|
99
|
+
## Feature Files
|
|
100
|
+
|
|
101
|
+
Feature files use the `.feature.md` suffix.
|
|
102
|
+
|
|
103
|
+
Required sections:
|
|
104
|
+
|
|
105
|
+
```md
|
|
106
|
+
# Card authoring
|
|
107
|
+
|
|
108
|
+
## Purpose
|
|
66
109
|
|
|
67
|
-
|
|
68
|
-
- `MUST NOT`
|
|
69
|
-
- `SHOULD`
|
|
70
|
-
- `SHOULD NOT`
|
|
71
|
-
- `MAY`
|
|
72
|
-
- `OPTIONAL`
|
|
110
|
+
## Rules
|
|
73
111
|
|
|
74
112
|
## Scenarios
|
|
113
|
+
```
|
|
75
114
|
|
|
76
|
-
|
|
115
|
+
Rules use stable `-R001` IDs:
|
|
77
116
|
|
|
78
117
|
```md
|
|
79
|
-
|
|
118
|
+
- KANBAN-CARD-AUTHORING-R001: A new card MUST start in the To do column.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Scenarios use stable `-S001` IDs and Given / When / Then steps:
|
|
80
122
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
123
|
+
```md
|
|
124
|
+
### KANBAN-CARD-AUTHORING-S001: User creates a card
|
|
125
|
+
|
|
126
|
+
Given the user is on the board
|
|
127
|
+
When they create a card with the title "Write release notes"
|
|
128
|
+
Then the card "Write release notes" is visible in the To do column
|
|
84
129
|
```
|
|
85
130
|
|
|
86
131
|
Allowed step keywords:
|
|
@@ -91,20 +136,137 @@ Allowed step keywords:
|
|
|
91
136
|
- `And`
|
|
92
137
|
- `But`
|
|
93
138
|
|
|
94
|
-
|
|
139
|
+
Rules state durable product truths. Scenarios show concrete examples that executable tests can implement.
|
|
140
|
+
|
|
141
|
+
## Stack Files
|
|
142
|
+
|
|
143
|
+
Stack files use the `.stack.md` suffix.
|
|
144
|
+
|
|
145
|
+
A stack file defines technical platform choices and the reasoning behind them.
|
|
146
|
+
|
|
147
|
+
Required sections:
|
|
148
|
+
|
|
149
|
+
```md
|
|
150
|
+
# Kanban tech stack
|
|
151
|
+
|
|
152
|
+
## Purpose
|
|
153
|
+
|
|
154
|
+
## Stack
|
|
155
|
+
```
|
|
95
156
|
|
|
96
|
-
|
|
157
|
+
Optional sections:
|
|
97
158
|
|
|
98
|
-
|
|
159
|
+
```md
|
|
160
|
+
## Context
|
|
161
|
+
|
|
162
|
+
## Rationale
|
|
163
|
+
|
|
164
|
+
## Consequences
|
|
165
|
+
```
|
|
99
166
|
|
|
100
|
-
|
|
167
|
+
Example:
|
|
168
|
+
|
|
169
|
+
```md
|
|
170
|
+
---
|
|
171
|
+
id: KANBAN-STACK
|
|
172
|
+
title: Kanban tech stack
|
|
173
|
+
status: draft
|
|
174
|
+
---
|
|
101
175
|
|
|
176
|
+
# Kanban tech stack
|
|
177
|
+
|
|
178
|
+
## Purpose
|
|
179
|
+
|
|
180
|
+
Define the initial technical stack for implementing the Kanban board.
|
|
181
|
+
|
|
182
|
+
## Stack
|
|
183
|
+
|
|
184
|
+
| Area | Choice |
|
|
185
|
+
| -------- | ---------- |
|
|
186
|
+
| Frontend | React |
|
|
187
|
+
| Language | TypeScript |
|
|
188
|
+
| Testing | Playwright |
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Design Files
|
|
192
|
+
|
|
193
|
+
Design files use the `.design.md` suffix.
|
|
194
|
+
|
|
195
|
+
A design file defines product, UI, layout, visual, and interaction direction.
|
|
196
|
+
|
|
197
|
+
Required sections:
|
|
198
|
+
|
|
199
|
+
```md
|
|
200
|
+
# Kanban board design
|
|
201
|
+
|
|
202
|
+
## Purpose
|
|
203
|
+
|
|
204
|
+
## Design
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Optional sections:
|
|
208
|
+
|
|
209
|
+
```md
|
|
210
|
+
## Principles
|
|
211
|
+
|
|
212
|
+
## Layout
|
|
213
|
+
|
|
214
|
+
## Interaction
|
|
215
|
+
|
|
216
|
+
## Visual style
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Example:
|
|
220
|
+
|
|
221
|
+
```md
|
|
222
|
+
---
|
|
223
|
+
id: KANBAN-DESIGN
|
|
224
|
+
title: Kanban board design
|
|
225
|
+
status: draft
|
|
226
|
+
model: KANBAN
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
# Kanban board design
|
|
230
|
+
|
|
231
|
+
## Purpose
|
|
232
|
+
|
|
233
|
+
Define the visual and interaction design direction for the Kanban board.
|
|
234
|
+
|
|
235
|
+
## Design
|
|
236
|
+
|
|
237
|
+
The board should feel lightweight, immediate, and calm.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Splitting Guidance
|
|
241
|
+
|
|
242
|
+
Split model files by coherent domain vocabulary, ownership, or lifecycle.
|
|
243
|
+
|
|
244
|
+
Split feature files by user capability.
|
|
245
|
+
|
|
246
|
+
Use stack files for broad technical choices such as framework, language, testing, persistence, deployment, and runtime constraints.
|
|
247
|
+
|
|
248
|
+
Use design files for product/UI direction such as layout, interaction, visual style, and design principles.
|
|
249
|
+
|
|
250
|
+
Keep each document small enough for an AI to read, revise, and use as test-writing context without extra explanation.
|
|
251
|
+
|
|
252
|
+
## Test Coverage Convention
|
|
253
|
+
|
|
254
|
+
Spec files do not contain test mappings.
|
|
255
|
+
|
|
256
|
+
Tests reference model item, rule, and scenario IDs in test titles, tags, annotations, comments, or metadata.
|
|
257
|
+
|
|
258
|
+
Generated tooling can answer:
|
|
259
|
+
|
|
260
|
+
- Which model items are referenced?
|
|
102
261
|
- Which scenarios have tests?
|
|
103
262
|
- Which rules have executable coverage?
|
|
104
263
|
- Which tests reference deleted or unknown spec IDs?
|
|
105
264
|
- Which visible flows have screenshots, traces, or other evidence?
|
|
106
265
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
266
|
+
Example:
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
test("KANBAN-CARD-AUTHORING-S001 user creates a card", async ({ page }) => {
|
|
270
|
+
// Covers KANBAN-M001 and KANBAN-CARD-AUTHORING-R001.
|
|
271
|
+
});
|
|
272
|
+
```
|