@se-studio/contentful-cms 1.0.3 → 1.0.5

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 (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -0
  3. package/dist/bin/cms-capture-screenshots.d.ts +4 -0
  4. package/dist/bin/cms-capture-screenshots.d.ts.map +1 -0
  5. package/dist/bin/cms-capture-screenshots.js +183 -0
  6. package/dist/bin/cms-capture-screenshots.js.map +1 -0
  7. package/dist/bin/cms-generate-collection-guidelines.d.ts +4 -0
  8. package/dist/bin/cms-generate-collection-guidelines.d.ts.map +1 -0
  9. package/dist/bin/cms-generate-collection-guidelines.js +209 -0
  10. package/dist/bin/cms-generate-collection-guidelines.js.map +1 -0
  11. package/dist/bin/cms-generate-field-list.d.ts +4 -0
  12. package/dist/bin/cms-generate-field-list.d.ts.map +1 -0
  13. package/dist/bin/cms-generate-field-list.js +114 -0
  14. package/dist/bin/cms-generate-field-list.js.map +1 -0
  15. package/dist/bin/cms-merge-guidelines.d.ts +4 -0
  16. package/dist/bin/cms-merge-guidelines.d.ts.map +1 -0
  17. package/dist/bin/cms-merge-guidelines.js +147 -0
  18. package/dist/bin/cms-merge-guidelines.js.map +1 -0
  19. package/dist/bin/cms-update-colour-hints.d.ts +4 -0
  20. package/dist/bin/cms-update-colour-hints.d.ts.map +1 -0
  21. package/dist/bin/cms-update-colour-hints.js +111 -0
  22. package/dist/bin/cms-update-colour-hints.js.map +1 -0
  23. package/dist/config/load.js +1 -1
  24. package/dist/config/load.js.map +1 -1
  25. package/package.json +7 -2
  26. package/skills/cms-guidelines/README.md +140 -0
  27. package/skills/cms-guidelines/colour-hint-prompt.md +77 -0
  28. package/skills/cms-guidelines/evaluation-prompt.md +84 -0
  29. package/skills/cms-guidelines/generate-component-guidelines.md +126 -0
  30. package/skills/cms-guidelines/generation-prompt.md +202 -0
  31. package/skills/cms-guidelines/validation-prompt.md +170 -0
  32. package/skills/cms-guidelines/variant-loop.md +184 -0
  33. package/skills/cms-guidelines/variant-proposal-prompt.md +127 -0
@@ -0,0 +1,126 @@
1
+ # Generate Component Guidelines — Full Pipeline (Step 5.4)
2
+
3
+ **End-to-end pipeline for one component:** variant loop → generate → colour hint → validate → merge → commit.
4
+
5
+ ---
6
+
7
+ ## What this produces
8
+
9
+ For one CMS type (e.g. Hero):
10
+
11
+ | Output | Location |
12
+ |---|---|
13
+ | Variant screenshots | `docs/cms-guidelines/screenshots/hero-*.png` |
14
+ | Accepted variant list | `generated/cms-discovery/accepted-variants/hero.json` |
15
+ | Guideline fragment | `docs/cms-guidelines/components/hero.md` |
16
+ | Colour hint entry | `generated/cms-discovery/colour-hints.json` |
17
+ | Merged full doc (updated) | `docs/cms-guidelines/COMPONENT_GUIDELINES_FOR_LLM.md` |
18
+
19
+ ---
20
+
21
+ ## Cursor agent task prompt
22
+
23
+ **Assign to a Cursor subagent. Provide:**
24
+ - This file
25
+ - `variant-loop.md` (in the same skills/cms-guidelines/ directory)
26
+ - `generation-prompt.md`
27
+ - `colour-hint-prompt.md`
28
+ - `validation-prompt.md`
29
+ - `docs/cms-guidelines/LAYOUT.md`
30
+ - `tmp/component-guidelines-target-format.md`
31
+
32
+ **Task prompt:**
33
+
34
+ ```
35
+ Run the full guideline generation pipeline for <COMPONENT_TYPE>.
36
+ Target app: <APP_DIR> (all paths relative to that directory).
37
+
38
+ === Phase A: Variant loop ===
39
+ Follow variant-loop.md.
40
+ 1. Read src/project/components/<TypeName>.tsx (or collections/<TypeName>.tsx).
41
+ 2. Read generated/cms-discovery/field-list.json for field metadata.
42
+ 3. Propose N=5 variants using the prompt in variant-proposal-prompt.md.
43
+ 4. Capture screenshots:
44
+ cms-capture-screenshots --variants /tmp/<type-slug>-variants.json --app-dir <APP_DIR>
45
+ 5. Evaluate screenshots using evaluation-prompt.md.
46
+ - If not suitably different and attempts < 2×N: capture new suggestions, re-evaluate.
47
+ - When done: save accepted list to generated/cms-discovery/accepted-variants/<type-slug>.json
48
+
49
+ === Phase B: Generate guideline ===
50
+ Follow generation-prompt.md.
51
+ 1. Describe screenshots (Step 1 prompt).
52
+ 2. Extract behaviour from code (Step 2 prompt).
53
+ 3. Merge into guideline block (Step 3 prompt).
54
+ 4. Save output to docs/cms-guidelines/components/<type-slug>.md.
55
+ (Collections → collections/<type-slug>.md, externals → externals/<type-slug>.md)
56
+
57
+ === Phase C: Colour hint ===
58
+ Follow colour-hint-prompt.md.
59
+ Derive the colour application hint (section/card/section+card/none) from the source.
60
+ Run:
61
+ cms-update-colour-hints --app-dir <APP_DIR> \
62
+ --type "<COMPONENT_TYPE>" --hint "<hint>" --notes "<brief reason>"
63
+
64
+ === Phase D: Validate ===
65
+ Follow validation-prompt.md.
66
+ 1. Read the generated fragment and the component source.
67
+ 2. Run the 9-check validation.
68
+ 3. If NEEDS REVISION: apply fixes to the fragment and re-run validation.
69
+ 4. Repeat until APPROVED.
70
+
71
+ === Phase E: Merge ===
72
+ cms-merge-guidelines --app-dir <APP_DIR>
73
+ This updates docs/cms-guidelines/COMPONENT_GUIDELINES_FOR_LLM.md.
74
+
75
+ === Phase F: Commit ===
76
+ git add docs/cms-guidelines/ generated/cms-discovery/
77
+ git commit -m "chore: generate guidelines for <COMPONENT_TYPE>"
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Manual pipeline (for Hero — already partially done)
83
+
84
+ Hero has a hand-written guideline fragment (Step 3.1), accepted variant screenshots
85
+ (Step 4.2), and colour hints (Step 5.2). To complete the pipeline manually:
86
+
87
+ ```bash
88
+ # Phase D: Validate hero.md (hand-written)
89
+ # Use: validation-prompt.md + src/project/components/Hero.tsx
90
+ # Apply any fixes to docs/cms-guidelines/components/hero.md
91
+
92
+ # Phase E: Merge
93
+ cms-merge-guidelines
94
+
95
+ # Phase F: Commit
96
+ git add docs/cms-guidelines/ generated/cms-discovery/
97
+ git commit -m "chore: complete Hero guideline pipeline"
98
+ ```
99
+
100
+ ---
101
+
102
+ ## For all components (full site run)
103
+
104
+ To generate guidelines for all components and collections:
105
+
106
+ 1. Get the list of all types from the discovery API:
107
+ ```
108
+ GET /api/cms/discovery
109
+ ```
110
+ 2. For each type in components[], collections[], externals[], run this pipeline.
111
+ 3. After all types: run merge and commit the final COMPONENT_GUIDELINES_FOR_LLM.md.
112
+
113
+ A full run typically takes 5–10 minutes per component (mostly LLM time) and
114
+ 30–60 minutes total for a typical site.
115
+
116
+ ---
117
+
118
+ ## npm scripts summary
119
+
120
+ | Script | What it does |
121
+ |---|---|
122
+ | `pnpm run cms-discovery:field-list` | Generate `generated/cms-discovery/field-list.json` from TypeScript types |
123
+ | `pnpm run cms-guidelines:screenshots` | Capture screenshots for a type (interactive) |
124
+ | `pnpm run cms-guidelines:merge` | Merge per-type files into COMPONENT_GUIDELINES_FOR_LLM.md |
125
+ | `cms-update-colour-hints` | Upsert a colour hint in colour-hints.json |
126
+ | `cms-capture-screenshots` | Capture screenshots for a type |
@@ -0,0 +1,202 @@
1
+ # Generation Prompt — Code + Screenshots → Guideline Block
2
+
3
+ **Step 5.1 — Multi-step prompts for generating one guideline fragment.**
4
+
5
+ Run as a **Cursor agent task**. The agent reads the component source, screenshots, and field
6
+ metadata, then writes a self-contained markdown guideline fragment in the target format.
7
+
8
+ ---
9
+
10
+ ## Inputs
11
+
12
+ | Input | Source |
13
+ |---|---|
14
+ | Component source file | `src/project/components/<TypeName>.tsx` |
15
+ | Field metadata (used fields + types + enums) | `generated/cms-discovery/field-list.json` |
16
+ | Accepted screenshots | `generated/cms-discovery/accepted-variants/<type-slug>.json` + image files |
17
+ | Target format example | `tmp/component-guidelines-target-format.md` (Hero example) |
18
+ | Mapping reference | `generated/cms-discovery/mapping.md` |
19
+ | SizingInformation source | `src/lib/SizingInformation.ts` |
20
+ | Section wrapper source | `src/framework/Section.tsx` (for backgroundColour/textColour behaviour) |
21
+
22
+ ---
23
+
24
+ ## Step 1 of 3 — Describe the screenshots
25
+
26
+ **Prompt:**
27
+
28
+ ```
29
+ You are documenting a CMS component for a marketing site.
30
+
31
+ I will give you screenshots of the component in different states, and the component's
32
+ accepted variant list. Describe what you see in each screenshot.
33
+
34
+ Component: <COMPONENT_TYPE>
35
+
36
+ Accepted variants (from accepted-variants/<type-slug>.json):
37
+ <ACCEPTED_VARIANTS_JSON>
38
+
39
+ For each variant, describe:
40
+ - The visual layout (columns, stack, full-width, etc.)
41
+ - The elements visible (heading, eyebrow, body, links, visual/image, background colour)
42
+ - The typography appearance (large heading, small body text, etc.)
43
+ - The colour scheme (background colour, text colour, whether the visual is tinted)
44
+ - Anything notable (animations not applicable in screenshots, spacing gaps, alignment)
45
+
46
+ Be precise. Write one short paragraph per variant (3–5 sentences). No code references.
47
+ Only use colour names from the site palette and typography class names (h1–h6, p2, p3).
48
+
49
+ Output format: one section per variant, headed by ## <label>.
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Step 2 of 3 — Extract behaviour and fields from code
55
+
56
+ **Prompt:**
57
+
58
+ ```
59
+ You are writing CMS component documentation.
60
+
61
+ I will give you the source code of a Next.js component. Extract all behaviour
62
+ rules for the documentation. Do NOT quote or reference the code — translate
63
+ the code behaviour into plain English rules that a non-developer can follow.
64
+
65
+ Component source:
66
+ <COMPONENT_SOURCE>
67
+
68
+ SizingInformation.ts source (shows how index affects heading level and section spacing):
69
+ <SIZING_INFORMATION_SOURCE>
70
+
71
+ Section.tsx source (shows how backgroundColour and textColour are applied):
72
+ <SECTION_SOURCE>
73
+
74
+ Field mapping reference (mapping.md — shows how CMS fields map to app props):
75
+ <MAPPING_SOURCE>
76
+
77
+ Extract and write:
78
+ 1. FIELDS: For each field in USED_FIELDS, write one row: field name, type, what it does when
79
+ set, what happens when it is empty. Use only typography class names and colour names as
80
+ code snippets. No file paths.
81
+ 2. BEHAVIOUR: Any behaviour that depends on position (index), variant (flipped), or other
82
+ logic. E.g. "When this is the first block on the page, the heading renders as <h1>".
83
+ 3. IMPACT: What visually changes when content changes (longer text, add/remove visual, etc.).
84
+ 4. TYPOGRAPHY: Which typography classes (h1–h6, p2, p3, h4, etc.) are applied to each element.
85
+ 5. COLOUR APPLICATION: How backgroundColour and textColour are applied. Section-wide? Per-card?
86
+
87
+ Output each section clearly labelled (## Fields, ## Behaviour, ## Impact, ## Typography,
88
+ ## Colour Application). No code blocks. No file references. Plain English only (except
89
+ typography class names and colour names).
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Step 3 of 3 — Merge into guideline block
95
+
96
+ **Prompt:**
97
+
98
+ ```
99
+ You are writing a self-contained CMS component guideline fragment.
100
+
101
+ Below are two inputs:
102
+ A) Screenshot descriptions for each variant of <COMPONENT_TYPE>.
103
+ B) Extracted behaviour rules from the source code.
104
+
105
+ Also provided:
106
+ - The target format example (Hero guideline from tmp/component-guidelines-target-format.md).
107
+ - The field list from generated/cms-discovery/field-list.json.
108
+
109
+ Produce a single markdown fragment for <COMPONENT_TYPE> following EXACTLY this structure:
110
+
111
+ # <ComponentType>
112
+ (one-line summary of what it is and when to use it)
113
+
114
+ ## What it looks like
115
+ (describe layout, columns, stacking, visible elements — based on screenshot descriptions)
116
+
117
+ ## Typography
118
+ (typography classes for heading, body, subtitle — bullets only)
119
+
120
+ ## Colours
121
+ (how backgroundColour/textColour apply — section-wide? per-card? valid palette values)
122
+
123
+ ## Used fields
124
+ (table: Field | Type | Effect when set | Effect when empty/removed)
125
+
126
+ ## Behaviour
127
+ (position/index rules, variant differences, anything that depends on content logic)
128
+
129
+ ## Impact of content changes
130
+ (table or bullets: what changes when you add/remove/change specific fields)
131
+
132
+ ## Screenshots to capture
133
+ (list of recommended variants for future captures)
134
+
135
+ Rules:
136
+ - SELF-CONTAINED. A reader with no code access must fully understand the component.
137
+ - No source code references, no file paths, no "see Hero.tsx".
138
+ - Only use typography class names (h1–h6, p2, p3, h4) and colour names from the palette
139
+ as code-like snippets. Everything else is plain English.
140
+ - If a field is listed in USED_FIELDS but has no visual effect when empty, say
141
+ "No visible effect when empty" in the table.
142
+ - Collections: add a section for card-level fields and describe how the number of cards
143
+ affects layout.
144
+ - External components: omit "Screenshots to capture"; describe parameters (props) instead.
145
+
146
+ Output raw markdown only. Start with "# <ComponentType>". No preamble.
147
+ ```
148
+
149
+ ---
150
+
151
+ ## External component variant
152
+
153
+ For external components (no showcase), replace Step 1 with:
154
+
155
+ ```
156
+ The component has no screenshots (not yet in the showcase). Instead, describe what
157
+ the component likely looks like based on its name and parameters alone. Mark this
158
+ section with a note: "(Visual description estimated from code; no screenshots available.)"
159
+ ```
160
+
161
+ All other steps are the same.
162
+
163
+ ---
164
+
165
+ ## After generation
166
+
167
+ After the LLM produces the fragment:
168
+
169
+ 1. Save to `docs/cms-guidelines/components/<type-slug>.md`
170
+ (or `collections/` or `externals/` as appropriate).
171
+ 2. Run validation (Step 5.3 prompt).
172
+ 3. If validation passes, run merge: `pnpm run cms-guidelines:merge`
173
+ 4. Commit both files.
174
+
175
+ ---
176
+
177
+ ## Cursor agent task prompt
178
+
179
+ ```
180
+ Generate the CMS guideline fragment for <COMPONENT_TYPE>.
181
+
182
+ Files to read:
183
+ - src/project/components/<TypeName>.tsx (or collections/<TypeName>.tsx)
184
+ - generated/cms-discovery/field-list.json
185
+ - generated/cms-discovery/mapping.md
186
+ - generated/cms-discovery/accepted-variants/<type-slug>.json
187
+ - src/lib/SizingInformation.ts
188
+ - src/framework/Section.tsx
189
+ - tmp/component-guidelines-target-format.md (example format)
190
+
191
+ Images to analyse:
192
+ - docs/cms-guidelines/screenshots/<type-slug>-*.png (all accepted variant screenshots)
193
+
194
+ Follow the three-step generation process in generation-prompt.md:
195
+ 1. Describe screenshots.
196
+ 2. Extract behaviour from code.
197
+ 3. Merge into guideline fragment.
198
+
199
+ Save the output to docs/cms-guidelines/components/<type-slug>.md.
200
+ Then run: pnpm run cms-guidelines:merge
201
+ Then commit: git add docs/cms-guidelines/ && git commit -m "chore(bl): generate guideline for <TypeName>"
202
+ ```
@@ -0,0 +1,170 @@
1
+ # Validation Prompt — Guideline vs Code
2
+
3
+ **Step 5.3 — LLM validation of a guideline fragment against the component source.**
4
+
5
+ Run as part of the generation pipeline (not CI). Heavy validation that checks completeness
6
+ and consistency before committing. It is acceptable for this to take time — correctness is
7
+ the priority.
8
+
9
+ ---
10
+
11
+ ## When to run
12
+
13
+ After Step 5.1 (generation) produces a guideline fragment, before committing. Feed the
14
+ fragment and the component source to this prompt.
15
+
16
+ ---
17
+
18
+ ## Prompt
19
+
20
+ ```
21
+ You are validating a CMS component guideline fragment for accuracy and completeness.
22
+
23
+ You will be given:
24
+ 1. The guideline fragment (markdown).
25
+ 2. The component source file (TypeScript/React).
26
+ 3. Supporting files: SizingInformation.ts, Section.tsx, mapping.md.
27
+
28
+ Your task: systematically check whether the guideline is COMPLETE and CONSISTENT with
29
+ the code. Produce a detailed report.
30
+
31
+ Guideline fragment:
32
+ <GUIDELINE_MARKDOWN>
33
+
34
+ Component source:
35
+ <COMPONENT_SOURCE>
36
+
37
+ SizingInformation.ts:
38
+ <SIZING_SOURCE>
39
+
40
+ Section.tsx:
41
+ <SECTION_SOURCE>
42
+
43
+ mapping.md (CMS field → app prop mapping):
44
+ <MAPPING_SOURCE>
45
+
46
+ ---
47
+
48
+ Check the following and report each as PASS, FAIL, or N/A:
49
+
50
+ 1. FIELDS COVERAGE
51
+ - Are all fields in USED_FIELDS mentioned in the "Used fields" table?
52
+ - Are any fields mentioned in the table that are NOT in USED_FIELDS?
53
+
54
+ 2. FIELD DESCRIPTIONS
55
+ - For each field in the table: is the "Effect when set" accurate?
56
+ - For each field in the table: is the "Effect when empty/removed" accurate?
57
+ - Are any effects described that do not match the code?
58
+
59
+ 3. TYPOGRAPHY
60
+ - Does the guideline state the correct typography class for each element?
61
+ (e.g. heading = h4, body = p3)
62
+ - Does it correctly describe which HTML element the heading renders as
63
+ based on index (h1 for first, h2 for later)?
64
+
65
+ 4. COLOUR BEHAVIOUR
66
+ - Does the guideline correctly describe how backgroundColour and textColour are applied
67
+ (section-wide, card-level, or neither)?
68
+ - Are the valid enum values for backgroundColour and textColour correct?
69
+
70
+ 5. POSITION/INDEX BEHAVIOUR
71
+ - If the component uses getSizingInformation(index), does the guideline describe:
72
+ (a) the heading level change (h1 vs h2)?
73
+ (b) the spacing/padding change?
74
+
75
+ 6. VARIANT DIFFERENCES
76
+ - If there are multiple registered variants (e.g. Hero and Hero Flipped), are they
77
+ all described, and are the differences accurately stated?
78
+
79
+ 7. IMPACT SECTION
80
+ - Does the "Impact of content changes" section describe what happens when:
81
+ (a) important optional fields are added?
82
+ (b) important optional fields are removed?
83
+ - Are there missing impact scenarios that would be confusing to a user?
84
+
85
+ 8. NO CODE REFERENCES
86
+ - Does the guideline contain any file path references (e.g. "Hero.tsx", "Section.tsx")?
87
+ - Does it contain any code beyond typography class names and colour names?
88
+
89
+ 9. COMPLETENESS
90
+ - Is there anything important in the code that the guideline does NOT mention and SHOULD?
91
+ - List any missing items.
92
+
93
+ ---
94
+
95
+ Output format:
96
+
97
+ ## Validation Report — <ComponentType>
98
+
99
+ ### Summary
100
+ PASS / FAIL / PARTIAL — one sentence overall verdict.
101
+
102
+ ### Checks
103
+
104
+ | Check | Result | Detail |
105
+ |---|---|---|
106
+ | Fields coverage | PASS | All 10 used fields are in the table. |
107
+ | Field descriptions | FAIL | `visual` empty description says "copy-only" but should say "copy spans full width". |
108
+ | Typography | PASS | Heading h4, body p3 — correct. |
109
+ | Colour behaviour | PASS | Section-wide application described correctly. |
110
+ | Position/index | PASS | h1/h2 and padding described. |
111
+ | Variant differences | PASS | Hero Flipped column order described. |
112
+ | Impact section | PARTIAL | Removing preHeading described; removing body not described. |
113
+ | No code references | PASS | No file paths or raw code. |
114
+ | Completeness | PARTIAL | Animation behaviour (animate-when-seen) not mentioned. |
115
+
116
+ ### Issues to fix
117
+
118
+ List each FAIL and PARTIAL item with a specific fix instruction:
119
+ - **Field: visual empty description** — change to: "Copy spans full section width on all breakpoints."
120
+ - **Impact: removing body** — add row: "Remove body → body block disappears; links follow directly after heading/subtitle."
121
+ - **Completeness: animation** — add to Behaviour section: "All text elements animate in when they scroll into view."
122
+
123
+ ### Verdict
124
+
125
+ APPROVED — The guideline is complete and consistent. Minor fixes applied.
126
+ OR
127
+ NEEDS REVISION — Fix issues above before committing.
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Acceptance criteria
133
+
134
+ **Approved if:**
135
+ - Fields coverage = PASS
136
+ - Typography = PASS
137
+ - Colour behaviour = PASS
138
+ - No code references = PASS
139
+ - No more than 2 PARTIAL items (and they are minor)
140
+
141
+ **Needs revision if:**
142
+ - Any FAIL item
143
+ - More than 2 PARTIAL items
144
+
145
+ When revision is needed: apply the specific fixes from the "Issues to fix" list and re-run
146
+ validation. Repeat until approved.
147
+
148
+ ---
149
+
150
+ ## Cursor agent task prompt
151
+
152
+ ```
153
+ Validate the CMS guideline fragment for <COMPONENT_TYPE>.
154
+
155
+ Files to read:
156
+ - docs/cms-guidelines/components/<type-slug>.md (the guideline to validate)
157
+ - src/project/components/<TypeName>.tsx (source of truth)
158
+ - src/lib/SizingInformation.ts
159
+ - src/framework/Section.tsx
160
+ - generated/cms-discovery/mapping.md
161
+
162
+ Follow the validation prompt in validation-prompt.md.
163
+ Produce a validation report.
164
+
165
+ If APPROVED: proceed to merge.
166
+ If NEEDS REVISION: apply the specific fixes to docs/cms-guidelines/components/<type-slug>.md,
167
+ then re-validate (run this task again with the updated fragment).
168
+ When approved, run: pnpm run cms-guidelines:merge
169
+ Then commit both files.
170
+ ```
@@ -0,0 +1,184 @@
1
+ # Variant Loop — Orchestrator
2
+
3
+ **Step 4.4 — Orchestration of: propose → screenshot → evaluate.**
4
+
5
+ This document describes the full variant loop for one CMS type. Run it as a **Cursor agent task**,
6
+ or manually follow the steps below.
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ ```
13
+ ┌──────────────────────────────────────────────────┐
14
+ │ INPUT: typeName, source file path, N │
15
+ └──────────────────────┬───────────────────────────┘
16
+
17
+
18
+ ┌──────────────────────────────────────────────────┐
19
+ │ Step 1: Propose N variants (LLM) │
20
+ │ → variants.json (typeName, variants[]) │
21
+ └──────────────────────┬───────────────────────────┘
22
+
23
+
24
+ ┌──────────────────────────────────────────────────┐
25
+ │ Step 2: Capture screenshots │
26
+ │ → docs/cms-guidelines/screenshots/<name>.png │
27
+ └──────────────────────┬───────────────────────────┘
28
+
29
+
30
+ ┌──────────────────────────────────────────────────┐
31
+ │ Step 3: Evaluate screenshot diversity (LLM) │
32
+ │ → suitablyDifferent, acceptedVariants, rejected │
33
+ └──────────────────────┬───────────────────────────┘
34
+
35
+ ┌────────────┴─────────────┐
36
+ │ suitablyDifferent? │
37
+ ▼ YES ▼ NO + attempts < 2×N
38
+ ┌──────────────────┐ ┌──────────────────────────────┐
39
+ │ Accept set; │ │ Capture suggested new │
40
+ │ proceed to gen │ │ variants; re-evaluate │
41
+ └──────────────────┘ └──────────────────────────────┘
42
+ │ attempts >= 2×N
43
+
44
+ ┌──────────────────────────┐
45
+ │ Accept best set so far │
46
+ └──────────────────────────┘
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Cursor agent task
52
+
53
+ **Assign this task to a Cursor subagent.** Provide:
54
+ - `apps/example-brightline/src/project/components/<TypeName>.tsx` (component source)
55
+ - `generated/cms-discovery/field-list.json` (field metadata including enum values)
56
+ - `scripts/guidelines/variant-proposal-prompt.md` (variant proposal instructions)
57
+ - `scripts/guidelines/evaluation-prompt.md` (evaluation instructions)
58
+ - `scripts/guidelines/capture-screenshots.mjs` (screenshot tool)
59
+ - This file (orchestration rules)
60
+
61
+ **Task prompt:**
62
+
63
+ ```
64
+ Run the variant loop for <TypeName>:
65
+
66
+ 1. PROPOSE: Read the component source file and field list. Using the instructions in
67
+ scripts/guidelines/variant-proposal-prompt.md, produce a variants.json for <TypeName>.
68
+ Use N = 5 (or fewer if the component is simple).
69
+
70
+ 2. CAPTURE: Run:
71
+ node scripts/guidelines/capture-screenshots.mjs --variants /tmp/variants.json
72
+ This saves screenshots to docs/cms-guidelines/screenshots/.
73
+
74
+ 3. EVALUATE: Using the instructions in scripts/guidelines/evaluation-prompt.md, look at
75
+ the captured screenshots and produce an evaluation JSON.
76
+ - If suitablyDifferent = true: proceed to Step 4.
77
+ - If suitablyDifferent = false AND total attempts < 2 × N:
78
+ Extend variants.json with 1–2 new variants from the suggestions, capture them,
79
+ re-evaluate. Repeat until suitablyDifferent = true or 2×N total attempts.
80
+ - If 2×N attempts reached: accept the best acceptedVariants set seen.
81
+
82
+ 4. WRITE ACCEPTED LIST: Save the final accepted variant list to:
83
+ generated/cms-discovery/accepted-variants/<type-slug>.json
84
+ Format: { "typeName": "<TypeName>", "acceptedVariants": [...] }
85
+
86
+ 5. COMMIT: git add docs/cms-guidelines/screenshots/ generated/cms-discovery/
87
+ git commit -m "chore(bl): variant screenshots for <TypeName>"
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Manual steps
93
+
94
+ If running manually:
95
+
96
+ ### 1 — Propose variants
97
+
98
+ Feed the component source file to an LLM with the prompt in
99
+ `scripts/guidelines/variant-proposal-prompt.md`.
100
+
101
+ Save the output as `/tmp/<type-slug>-variants.json`.
102
+
103
+ Example for Hero:
104
+ ```json
105
+ {
106
+ "typeName": "Hero",
107
+ "mode": "component",
108
+ "variants": [
109
+ { "label": "default", "description": "All fields.", "showcaseParams": {} },
110
+ { "label": "no-visual", "description": "No visual.", "showcaseParams": { "showVisual": "false" } },
111
+ { "label": "navy", "description": "Navy bg.", "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" } },
112
+ { "label": "pine", "description": "Pine bg.", "showcaseParams": { "backgroundColour": "Pine", "textColour": "Off White" } },
113
+ { "label": "minimal", "description": "Heading only.", "showcaseParams": { "showVisual": "false", "showLinks": "false" } }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ ### 2 — Capture screenshots
119
+
120
+ ```bash
121
+ # From apps/example-brightline
122
+ node scripts/guidelines/capture-screenshots.mjs --variants /tmp/hero-variants.json
123
+ ```
124
+
125
+ Saves to `docs/cms-guidelines/screenshots/hero-*.png`.
126
+
127
+ ### 3 — Evaluate
128
+
129
+ Feed the screenshots + evaluation prompt to an LLM. The LLM looks at the images and
130
+ returns `suitablyDifferent`, `acceptedVariants`, `rejectedVariants`, and `suggestions`.
131
+
132
+ If not suitably different: replace rejected screenshots with suggestions, re-capture, re-evaluate.
133
+
134
+ ### 4 — Save accepted list
135
+
136
+ ```bash
137
+ mkdir -p generated/cms-discovery/accepted-variants
138
+ # Write manually or via script
139
+ ```
140
+
141
+ ### 5 — Commit
142
+
143
+ ```bash
144
+ git add docs/cms-guidelines/screenshots/ generated/cms-discovery/accepted-variants/
145
+ git commit -m "chore(bl): variant screenshots for Hero"
146
+ ```
147
+
148
+ ---
149
+
150
+ ## accepted-variants JSON format
151
+
152
+ ```json
153
+ {
154
+ "typeName": "Hero",
155
+ "generatedAt": "2026-03-12",
156
+ "acceptedVariants": [
157
+ {
158
+ "label": "default",
159
+ "description": "All fields populated, no colour override.",
160
+ "screenshotPath": "docs/cms-guidelines/screenshots/hero-default.png",
161
+ "showcaseParams": {}
162
+ },
163
+ {
164
+ "label": "navy",
165
+ "description": "Navy background + Off White text.",
166
+ "screenshotPath": "docs/cms-guidelines/screenshots/hero-navy.png",
167
+ "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
168
+ }
169
+ ]
170
+ }
171
+ ```
172
+
173
+ This file is read by the generation step (Phase 5) to know which screenshots to include
174
+ in the guideline prompt.
175
+
176
+ ---
177
+
178
+ ## Notes
179
+
180
+ - Collections use `--collection <TypeName>` in cms-edit. The capture script handles this via `mode`.
181
+ - If `agent-browser` is not installed, the capture script degrades to URL-only output; run
182
+ `agent-browser install` to enable actual screenshot capture.
183
+ - The variant loop is the most expensive step. For simple components (1–2 visual states),
184
+ N = 3 is usually sufficient.