@se-studio/contentful-cms 1.0.43 → 1.0.44

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.
@@ -1,170 +0,0 @@
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
- ```
@@ -1,189 +0,0 @@
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/{mode}s/<n>.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
- - `generated/cms-discovery/theme-context.md` (palette + typography — authoritative colour names)
57
- - `scripts/guidelines/variant-proposal-prompt.md` (variant proposal instructions)
58
- - `scripts/guidelines/evaluation-prompt.md` (evaluation instructions)
59
- - `scripts/guidelines/capture-screenshots.mjs` (screenshot tool)
60
- - This file (orchestration rules)
61
-
62
- **Task prompt:**
63
-
64
- ```
65
- Run the variant loop for <TypeName>:
66
-
67
- 1. PROPOSE: Read the component source file, field list, and theme-context.md (for palette names).
68
- Using the instructions in scripts/guidelines/variant-proposal-prompt.md, produce a variants.json
69
- for <TypeName>. Use N = 5 (or fewer if the component is simple).
70
- IMPORTANT: use only colour names from theme-context.md — do NOT invent colour names.
71
-
72
- 2. CAPTURE: Run:
73
- node scripts/guidelines/capture-screenshots.mjs --variants /tmp/variants.json
74
- This saves screenshots to docs/cms-guidelines/screenshots/.
75
-
76
- 3. EVALUATE: Using the instructions in scripts/guidelines/evaluation-prompt.md, look at
77
- the captured screenshots and produce an evaluation JSON.
78
- - If suitablyDifferent = true: proceed to Step 4.
79
- - If suitablyDifferent = false AND total attempts < 2 × N:
80
- Extend variants.json with 1–2 new variants from the suggestions, capture them,
81
- re-evaluate. Repeat until suitablyDifferent = true or 2×N total attempts.
82
- - If 2×N attempts reached: accept the best acceptedVariants set seen.
83
-
84
- 4. WRITE ACCEPTED LIST: Save the final accepted variant list to:
85
- generated/cms-discovery/accepted-variants/{components|collections|externals}/<type-slug>.json
86
- Use the `mode` field to pick the subdir: component → components/, collection → collections/, external → externals/.
87
- Format: { "typeName": "<TypeName>", "mode": "<mode>", "variants": [...] }
88
-
89
- 5. COMMIT: git add docs/cms-guidelines/screenshots/ generated/cms-discovery/
90
- git commit -m "chore(bl): variant screenshots for <TypeName>"
91
- ```
92
-
93
- ---
94
-
95
- ## Manual steps
96
-
97
- If running manually:
98
-
99
- ### 1 — Propose variants
100
-
101
- Feed the component source file to an LLM with the prompt in
102
- `scripts/guidelines/variant-proposal-prompt.md`.
103
-
104
- Save the output as `/tmp/<type-slug>-variants.json`.
105
-
106
- Example for Hero:
107
- ```json
108
- {
109
- "typeName": "Hero",
110
- "mode": "component",
111
- "variants": [
112
- { "label": "default", "description": "All fields.", "showcaseParams": {} },
113
- { "label": "no-visual", "description": "No visual.", "showcaseParams": { "showVisual": "false" } },
114
- { "label": "navy", "description": "Navy bg.", "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" } },
115
- { "label": "pine", "description": "Pine bg.", "showcaseParams": { "backgroundColour": "Pine", "textColour": "Off White" } },
116
- { "label": "minimal", "description": "Heading only.", "showcaseParams": { "showVisual": "false", "showLinks": "false" } }
117
- ]
118
- }
119
- ```
120
-
121
- ### 2 — Capture screenshots
122
-
123
- ```bash
124
- # From apps/example-brightline
125
- node scripts/guidelines/capture-screenshots.mjs --variants /tmp/hero-variants.json
126
- ```
127
-
128
- Saves to `docs/cms-guidelines/screenshots/components/hero-*.png` (or `collections/` for collection types).
129
-
130
- ### 3 — Evaluate
131
-
132
- Feed the screenshots + evaluation prompt to an LLM. The LLM looks at the images and
133
- returns `suitablyDifferent`, `acceptedVariants`, `rejectedVariants`, and `suggestions`.
134
-
135
- If not suitably different: replace rejected screenshots with suggestions, re-capture, re-evaluate.
136
-
137
- ### 4 — Save accepted list
138
-
139
- ```bash
140
- # Use the appropriate subdir based on mode: components/, collections/, or externals/
141
- mkdir -p generated/cms-discovery/accepted-variants/components
142
- # Write manually or via script — e.g. for a component:
143
- # generated/cms-discovery/accepted-variants/components/hero.json
144
- ```
145
-
146
- ### 5 — Commit
147
-
148
- ```bash
149
- git add docs/cms-guidelines/screenshots/ generated/cms-discovery/accepted-variants/
150
- git commit -m "chore(bl): variant screenshots for Hero"
151
- ```
152
-
153
- ---
154
-
155
- ## accepted-variants JSON format
156
-
157
- ```json
158
- {
159
- "typeName": "Hero",
160
- "generatedAt": "2026-03-12",
161
- "acceptedVariants": [
162
- {
163
- "label": "default",
164
- "description": "All fields populated, no colour override.",
165
- "screenshotPath": "docs/cms-guidelines/screenshots/components/hero-default.png",
166
- "showcaseParams": {}
167
- },
168
- {
169
- "label": "navy",
170
- "description": "Navy background + Off White text.",
171
- "screenshotPath": "docs/cms-guidelines/screenshots/components/hero-navy.png",
172
- "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
173
- }
174
- ]
175
- }
176
- ```
177
-
178
- This file is read by the generation step (Phase 5) to know which screenshots to include
179
- in the guideline prompt.
180
-
181
- ---
182
-
183
- ## Notes
184
-
185
- - Collections use `--collection <TypeName>` in cms-edit. The capture script handles this via `mode`.
186
- - If `agent-browser` is not installed, the capture script degrades to URL-only output; run
187
- `agent-browser install` to enable actual screenshot capture.
188
- - The variant loop is the most expensive step. For simple components (1–2 visual states),
189
- N = 3 is usually sufficient.
@@ -1,131 +0,0 @@
1
- # Variant Proposal Prompt
2
-
3
- **Step 4.1 — Input/output contract and prompt for proposing component variants.**
4
-
5
- The variant loop produces screenshots that cover the visual diversity of a component. A good
6
- set captures: default state, important absent-field states, colour variants, and any layout
7
- variants (like flipped). The screenshots are then used to write the "What it looks like" and
8
- "Colours" sections of the guideline.
9
-
10
- ---
11
-
12
- ## Input
13
-
14
- - **Component source file:** full contents of `src/project/components/<Type>.tsx` (or
15
- `src/project/collections/<Type>.tsx`).
16
- - **Used fields:** the `USED_FIELDS` or `FIELD_KEYS` from the source file.
17
- - **Palette:** colour names from `generated/cms-discovery/theme-context.md` (generated by
18
- `cms-generate-collection-guidelines` from `tailwind.config.json`). This is the authoritative
19
- source — use it in preference to `field-list.json` or `generated/colors.ts`.
20
- - **N:** number of variants to propose (typically 4–6 for a component, up to 8 for complex ones).
21
-
22
- The LLM should output **N variants** in JSON format (see below).
23
-
24
- ---
25
-
26
- ## Prompt
27
-
28
- ```
29
- You are preparing screenshots for CMS component guidelines.
30
-
31
- I will give you the source code of a Next.js component that renders a CMS entry.
32
- Your task: propose N variants that, together, best document how the component looks
33
- under different conditions. Choose variants that are VISUALLY DISTINCT — a reader
34
- should be able to tell them apart at a glance.
35
-
36
- Component source:
37
- <COMPONENT_SOURCE>
38
-
39
- Palette (from generated/cms-discovery/theme-context.md — use ONLY these names):
40
- Background colours (backgroundColour):
41
- <BACKGROUND_COLOURS>
42
-
43
- Text colours (textColour, i.e. foreground colours):
44
- <TEXT_COLOURS>
45
-
46
- Do NOT invent or paraphrase colour names. Use the exact names from theme-context.md.
47
-
48
- Rules:
49
- 1. Always include a "default" variant with all optional fields populated and no colour override.
50
- 2. Include at least one variant per important "missing field" state (e.g. no visual, no links).
51
- 3. Include at least one colour variant if the component has backgroundColour (use a dark colour
52
- like Navy or Deep Periwinkle).
53
- 4. If the component has a flipped/alternate variant (e.g. Hero Flipped), include it.
54
- 5. Avoid variants that will look identical or near-identical to another variant in the list.
55
- 6. N = <N>; produce exactly N variants (or fewer if the component is simple).
56
-
57
- Output JSON only, no explanation. Format:
58
- {
59
- "typeName": "<CMS componentType or collectionType>",
60
- "variants": [
61
- {
62
- "label": "default",
63
- "description": "All fields populated, no colour override.",
64
- "showcaseParams": {}
65
- },
66
- {
67
- "label": "no-visual",
68
- "description": "visual field removed; copy spans full width.",
69
- "showcaseParams": { "showVisual": "false" }
70
- },
71
- {
72
- "label": "navy-background",
73
- "description": "Navy background with Off White text.",
74
- "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
75
- }
76
- ]
77
- }
78
-
79
- showcaseParams keys must match the cms-edit screenshot --param format:
80
- backgroundColour, textColour, showVisual, showLinks, showHeading, etc.
81
- For a flipped variant, use a separate typeName entry for "Hero Flipped".
82
- ```
83
-
84
- ---
85
-
86
- ## Output contract
87
-
88
- ```json
89
- {
90
- "typeName": "Hero",
91
- "variants": [
92
- {
93
- "label": "default",
94
- "description": "All optional fields populated, no colour override.",
95
- "showcaseParams": {}
96
- },
97
- {
98
- "label": "no-visual",
99
- "description": "Visual removed; copy spans full width.",
100
- "showcaseParams": { "showVisual": "false" }
101
- },
102
- {
103
- "label": "navy",
104
- "description": "Navy background + Off White text.",
105
- "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
106
- },
107
- {
108
- "label": "minimal",
109
- "description": "Heading only, no eyebrow/subtitle/body/links/visual.",
110
- "showcaseParams": { "showVisual": "false", "showLinks": "false" }
111
- }
112
- ]
113
- }
114
- ```
115
-
116
- - `label` — used to name the screenshot file: `<typeName-kebab>-<label>.png`
117
- - `description` — included in the screenshot log and used by the evaluation step
118
- - `showcaseParams` — key-value pairs passed as `--param key=value` to `cms-edit screenshot`
119
-
120
- ---
121
-
122
- ## Notes on N and the cap
123
-
124
- The orchestrator (Step 4.4) uses N (the number of proposed variants) as a cap:
125
-
126
- - It will attempt up to **2×N** screenshots in total.
127
- - If the evaluation step (Step 4.3) concludes the variants are "suitably different" before
128
- reaching 2×N attempts, it stops early.
129
- - If not, it requests a new proposal from the LLM for the remaining slots (up to 2×N total).
130
-
131
- For most components, N = 4–6 produces a good coverage set.