@se-studio/contentful-cms 1.0.4 → 1.0.6

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @se-studio/contentful-cms Changelog
2
2
 
3
+ ## 1.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Bulk version bump: patch for all packages
8
+
9
+ ## 1.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - Bulk version bump: patch for all packages
14
+
3
15
  ## 1.0.4
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -231,6 +231,8 @@ Capture a PNG of a component, collection, external component, person, or page. *
231
231
 
232
232
  Use `--out before.png` / `--out after.png` with `agent-browser diff screenshot` for visual diffing. See the **screenshots** skill for details.
233
233
 
234
+ **Batch screenshots:** The `cms-capture-screenshots` script (same package) captures multiple variants to `<app-dir>/docs/cms-guidelines/screenshots/`. Run it from the **monorepo root** so the output path is correct: `node packages/contentful-cms/dist/bin/cms-capture-screenshots.js --variants /tmp/type-variants.json --app-dir apps/example-se2026`.
235
+
234
236
  ### export-converted
235
237
 
236
238
  Export a session ref's entry as **converted (`IBase*`) JSON** via the app's convert API. Use the output with `screenshot --json-file` for custom variants without a session.
@@ -41,7 +41,7 @@ export function loadConfig(configPath) {
41
41
  environment: resolveEnvToken(space.environment),
42
42
  managementToken: resolveEnvToken(space.managementToken),
43
43
  defaultLocale: space.defaultLocale || 'en-US',
44
- ...(space.devBaseUrl ? { devBaseUrl: space.devBaseUrl } : {}),
44
+ ...(space.devBaseUrl ? { devBaseUrl: resolveEnvToken(space.devBaseUrl) } : {}),
45
45
  };
46
46
  }
47
47
  return resolved;
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AACl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": "1.0.6",
4
4
  "description": "CLI tool for AI agents to read and edit Contentful draft content without publish permissions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "@biomejs/biome": "^2.4.6",
37
37
  "@types/node": "^22.19.15",
38
38
  "typescript": "^5.9.3",
39
- "vitest": "^4.0.18"
39
+ "vitest": "^4.1.0"
40
40
  },
41
41
  "keywords": [
42
42
  "contentful",
@@ -0,0 +1,140 @@
1
+ # CMS Guidelines Generation
2
+
3
+ This directory contains the pipeline prompts and documentation for generating CMS component guideline fragments for any app in the monorepo.
4
+
5
+ ---
6
+
7
+ ## What are CMS guidelines?
8
+
9
+ Guidelines are short markdown fragments — one per CMS type — that describe how each component or collection looks, what fields it uses, how colours are applied, and how it behaves. They are merged into `docs/cms-guidelines/COMPONENT_GUIDELINES_FOR_LLM.md`, a single document used to give LLMs accurate context about the app's component library.
10
+
11
+ ---
12
+
13
+ ## Lifecycle: From content to guidelines
14
+
15
+ 1. **Build the site** — implement all components and collections; ensure all content is correct and published in Contentful.
16
+ 2. **Generate showcase data** — pull real Contentful data into the app's showcase:
17
+ ```bash
18
+ pnpm --filter <appName> generate-showcase
19
+ ```
20
+ This writes `src/cms-showcase/showcase-examples.json`.
21
+ 3. **Curate showcase mocks** — run the [curate-showcase-mocks skill](.cursor/skills/se-marketing-sites/curate-showcase-mocks/SKILL.md) to select the best examples into `showcase-mocks.json`. This makes the showcase (and screenshots) show realistic content.
22
+ 4. **Generate field list** — parse TypeScript types to produce structured field metadata:
23
+ ```bash
24
+ # From the app directory:
25
+ pnpm run cms-discovery:field-list
26
+
27
+ # Or from repo root:
28
+ pnpm --filter <appName> exec cms-generate-field-list --app-dir .
29
+ ```
30
+ 5. **Generate guidelines** — run the [Generate CMS guidelines skill](.cursor/skills/contentful-cms/generate-cms-guidelines/SKILL.md).
31
+
32
+ Steps 1–3 only need to be repeated when content or component code changes significantly. Step 4 only needs to be repeated when TypeScript types change. Step 5 can be re-run at any time.
33
+
34
+ ---
35
+
36
+ ## How to run guideline generation
37
+
38
+ Use the Cursor skill at [`.cursor/skills/contentful-cms/generate-cms-guidelines/SKILL.md`](.cursor/skills/contentful-cms/generate-cms-guidelines/SKILL.md). It supports three modes:
39
+
40
+ | Mode | When to use |
41
+ |---|---|
42
+ | `full` | First-time generation, or regenerate everything |
43
+ | `single` | Regenerate one component after code changes |
44
+ | `merge-only` | Rebuild `COMPONENT_GUIDELINES_FOR_LLM.md` after manual fragment edits |
45
+
46
+ **Example: full from scratch for `example-om1`**
47
+
48
+ Start the app:
49
+ ```bash
50
+ pnpm --filter example-om1 dev
51
+ ```
52
+
53
+ Then invoke the skill with:
54
+ - App directory: `apps/example-om1`
55
+ - Mode: `full`
56
+ - Discovery URL: `http://localhost:3013/api/cms/discovery/`
57
+
58
+ **Example: single component**
59
+
60
+ Invoke the skill with:
61
+ - App directory: `apps/example-se2026`
62
+ - Mode: `single`
63
+ - Type name: `Hero`
64
+ - Discovery URL: `http://localhost:3012/api/cms/discovery/`
65
+
66
+ **Example: merge only**
67
+
68
+ ```bash
69
+ cms-merge-guidelines --app-dir apps/example-om1
70
+ ```
71
+
72
+ ---
73
+
74
+ ## CLIs used by this pipeline
75
+
76
+ | CLI | Purpose |
77
+ |---|---|
78
+ | `cms-generate-field-list` | Parse TypeScript types → `field-list.json` |
79
+ | `cms-capture-screenshots` | Capture component screenshots for variant evaluation |
80
+ | `cms-update-colour-hints` | Upsert a colour hint in `colour-hints.json` |
81
+ | `cms-generate-collection-guidelines` | **New** — generate all collection/external `.md` files from a discovery URL |
82
+ | `cms-merge-guidelines` | Merge all fragments → `COMPONENT_GUIDELINES_FOR_LLM.md` |
83
+
84
+ All CLIs are provided by `@se-studio/contentful-cms`. Run `pnpm build` from the repo root to ensure they are built and linked.
85
+
86
+ ---
87
+
88
+ ## `cms-generate-collection-guidelines`
89
+
90
+ New project-independent CLI. Reads the discovery API and writes collection and external guideline fragments without any app-specific hardcoding.
91
+
92
+ ```bash
93
+ cms-generate-collection-guidelines \
94
+ --discovery-url http://localhost:3010/api/cms/discovery/ \
95
+ --app-dir apps/example-brightline
96
+ ```
97
+
98
+ Options:
99
+
100
+ | Flag | Description |
101
+ |---|---|
102
+ | `--discovery-url <url>` | Discovery API URL (required). App must be running. |
103
+ | `--app-dir <path>` | App directory (default: cwd). |
104
+
105
+ Outputs:
106
+ - `docs/cms-guidelines/collections/<slug>.md` for every collection
107
+ - `docs/cms-guidelines/externals/<slug>.md` for every external
108
+ - Updates `generated/cms-discovery/colour-hints.json`
109
+
110
+ ---
111
+
112
+ ## Pipeline document index
113
+
114
+ | File | Purpose |
115
+ |---|---|
116
+ | `generate-component-guidelines.md` | Full pipeline overview: Phases A–F |
117
+ | `variant-loop.md` | Phase A: propose variants → screenshot → evaluate |
118
+ | `variant-proposal-prompt.md` | LLM prompt: propose showcase variants |
119
+ | `evaluation-prompt.md` | LLM prompt: evaluate screenshot diversity |
120
+ | `generation-prompt.md` | Phase B: three-step guideline generation |
121
+ | `colour-hint-prompt.md` | Phase C: derive colour application hint |
122
+ | `validation-prompt.md` | Phase D: 9-check guideline validation |
123
+
124
+ ---
125
+
126
+ ## Output files (per app)
127
+
128
+ ```
129
+ <appDir>/
130
+ docs/cms-guidelines/
131
+ components/ # one .md per componentType
132
+ collections/ # one .md per collectionType
133
+ externals/ # one .md per externalComponentType
134
+ COMPONENT_GUIDELINES_FOR_LLM.md # merged document
135
+ generated/cms-discovery/
136
+ field-list.json
137
+ colour-hints.json
138
+ accepted-variants/ # one .json per component (variant screenshots)
139
+ screenshots/ # screenshot PNGs (not committed; captured during pipeline)
140
+ ```
@@ -0,0 +1,77 @@
1
+ # Colour Hint Prompt
2
+
3
+ **Step 5.2 — Produce a structured colour hint per CMS type.**
4
+
5
+ The colour hint is a short machine-readable label describing how `backgroundColour` and
6
+ `textColour` are applied in this component. It is stored in
7
+ `generated/cms-discovery/colour-hints.json` and served by the discovery API.
8
+
9
+ ---
10
+
11
+ ## Purpose
12
+
13
+ The colour hint helps tools and LLMs quickly understand how colours work without reading
14
+ the full guideline. For example:
15
+
16
+ - `"section"` → the colour applies to the full-width section (both copy and visual columns).
17
+ - `"card"` → the colour is applied per-card inside a collection.
18
+ - `"none"` → this type does not use backgroundColour/textColour.
19
+
20
+ ---
21
+
22
+ ## Valid hint values
23
+
24
+ | Value | Meaning |
25
+ |---|---|
26
+ | `"section"` | backgroundColour/textColour apply to the full-width section wrapper (most components) |
27
+ | `"card"` | Colours apply per-card (collection items); section has no colour |
28
+ | `"section+card"` | Both section-level and card-level colours exist |
29
+ | `"none"` | The type does not use backgroundColour or textColour |
30
+
31
+ ---
32
+
33
+ ## Prompt (to run as part of generation)
34
+
35
+ ```
36
+ You are writing a colour hint for a CMS component documentation system.
37
+
38
+ Component: <COMPONENT_TYPE>
39
+ Component source:
40
+ <COMPONENT_SOURCE>
41
+
42
+ Section.tsx source (shows how backgroundColour/textColour are applied at section level):
43
+ <SECTION_SOURCE>
44
+
45
+ Look at how backgroundColour and textColour are used in the source.
46
+
47
+ Rules:
48
+ - If backgroundColour/textColour are in USED_FIELDS AND passed to a Section wrapper (or
49
+ similar full-width wrapper): hint = "section"
50
+ - If backgroundColour/textColour are applied per-card in a collection: hint = "card"
51
+ - If both are true: hint = "section+card"
52
+ - If neither backgroundColour nor textColour is in USED_FIELDS: hint = "none"
53
+
54
+ Output JSON only:
55
+ {
56
+ "typeName": "<COMPONENT_TYPE>",
57
+ "colourApplication": "section",
58
+ "notes": "backgroundColour and textColour applied to the full Section wrapper."
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Script to update colour-hints.json
65
+
66
+ Run the script after generating each component:
67
+
68
+ ```bash
69
+ cms-update-colour-hints --type "Hero" --hint "section" \
70
+ --notes "backgroundColour and textColour applied to the full Section wrapper."
71
+ ```
72
+
73
+ Or provide an LLM-generated JSON file:
74
+
75
+ ```bash
76
+ cms-update-colour-hints --from /tmp/hero-colour-hint.json
77
+ ```
@@ -0,0 +1,84 @@
1
+ # Evaluation Prompt — Screenshot Differences
2
+
3
+ **Step 4.3 — Prompt for evaluating whether captured screenshots are suitably different.**
4
+
5
+ The evaluation step is used by the orchestrator (Step 4.4) to decide whether to accept the
6
+ current set of screenshots, or to request additional variants (up to the 2×N cap).
7
+
8
+ ---
9
+
10
+ ## When to run
11
+
12
+ After `cms-capture-screenshots` has captured a batch of screenshots, feed them to an LLM with
13
+ this prompt. The LLM inspects the images and returns a verdict.
14
+
15
+ ---
16
+
17
+ ## Prompt
18
+
19
+ ```
20
+ You are reviewing a set of component screenshots for CMS documentation purposes.
21
+
22
+ Your task: decide whether this set of screenshots is "suitably different" — meaning
23
+ each screenshot looks visually distinct enough that a reader could tell them apart,
24
+ and together they cover the important visual states of the component.
25
+
26
+ Component: <COMPONENT_TYPE>
27
+ Screenshots (attached as images):
28
+ <LIST OF {label, path, description} PAIRS>
29
+
30
+ Rules:
31
+ 1. Two screenshots are "not different enough" if they look nearly identical — same layout,
32
+ same colours, same content, just minor text length differences.
33
+ 2. The set is "suitably different" if:
34
+ - At least two screenshots have clearly different layouts (e.g. one has a visual, one does not), OR
35
+ - At least two screenshots have clearly different colour schemes (e.g. one light, one dark), OR
36
+ - At least two screenshots show clearly different content (e.g. one full, one minimal).
37
+ 3. A set with only one screenshot is NEVER "suitably different" — we need at least two variants.
38
+
39
+ Output JSON only:
40
+ {
41
+ "suitablyDifferent": true,
42
+ "reason": "Short explanation of why the set is or is not diverse enough.",
43
+ "acceptedVariants": ["default", "navy", "no-visual"],
44
+ "rejectedVariants": ["minimal"],
45
+ "suggestions": [
46
+ "The 'minimal' variant looks too similar to 'no-visual'. Try a variant with a tinted background
47
+ instead, e.g. Pine background."
48
+ ]
49
+ }
50
+
51
+ - acceptedVariants: labels of screenshots that are good to keep.
52
+ - rejectedVariants: labels that are too similar to others or not useful.
53
+ - suggestions: optional list of new variant ideas to try if suitablyDifferent is false
54
+ (or if any variant was rejected).
55
+ - If suitablyDifferent is true, suggestions can be empty.
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Output contract
61
+
62
+ ```json
63
+ {
64
+ "suitablyDifferent": true,
65
+ "reason": "The default and navy variants have clearly different colour schemes. The no-visual variant shows a different layout. Together they document the main visual states.",
66
+ "acceptedVariants": ["default", "navy", "no-visual"],
67
+ "rejectedVariants": ["minimal"],
68
+ "suggestions": [
69
+ "Consider replacing 'minimal' with a Pine background variant to show a green colour scheme."
70
+ ]
71
+ }
72
+ ```
73
+
74
+ ---
75
+
76
+ ## How the orchestrator uses this
77
+
78
+ 1. If `suitablyDifferent === true` AND all variants are accepted → stop; use the accepted set.
79
+ 2. If `suitablyDifferent === false` OR any variants were rejected:
80
+ - If `attempts < 2 × N` → use `suggestions` to generate additional variant params; capture
81
+ the new screenshots; re-evaluate.
82
+ - If `attempts >= 2 × N` → stop; use `acceptedVariants` from the best evaluation so far.
83
+ 3. The final accepted set is written to `generated/cms-discovery/accepted-variants.json`
84
+ and the screenshots are committed to `docs/cms-guidelines/screenshots/`.
@@ -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.
@@ -0,0 +1,127 @@
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:** `backgroundColour` and `textColour` enum values from `generated/cms-discovery/field-list.json`
18
+ (or from `generated/colors.ts`).
19
+ - **N:** number of variants to propose (typically 4–6 for a component, up to 8 for complex ones).
20
+
21
+ The LLM should output **N variants** in JSON format (see below).
22
+
23
+ ---
24
+
25
+ ## Prompt
26
+
27
+ ```
28
+ You are preparing screenshots for CMS component guidelines.
29
+
30
+ I will give you the source code of a Next.js component that renders a CMS entry.
31
+ Your task: propose N variants that, together, best document how the component looks
32
+ under different conditions. Choose variants that are VISUALLY DISTINCT — a reader
33
+ should be able to tell them apart at a glance.
34
+
35
+ Component source:
36
+ <COMPONENT_SOURCE>
37
+
38
+ Palette (backgroundColour options):
39
+ <BACKGROUND_COLOURS>
40
+
41
+ Text colour options (textColour):
42
+ <TEXT_COLOURS>
43
+
44
+ Rules:
45
+ 1. Always include a "default" variant with all optional fields populated and no colour override.
46
+ 2. Include at least one variant per important "missing field" state (e.g. no visual, no links).
47
+ 3. Include at least one colour variant if the component has backgroundColour (use a dark colour
48
+ like Navy or Deep Periwinkle).
49
+ 4. If the component has a flipped/alternate variant (e.g. Hero Flipped), include it.
50
+ 5. Avoid variants that will look identical or near-identical to another variant in the list.
51
+ 6. N = <N>; produce exactly N variants (or fewer if the component is simple).
52
+
53
+ Output JSON only, no explanation. Format:
54
+ {
55
+ "typeName": "<CMS componentType or collectionType>",
56
+ "variants": [
57
+ {
58
+ "label": "default",
59
+ "description": "All fields populated, no colour override.",
60
+ "showcaseParams": {}
61
+ },
62
+ {
63
+ "label": "no-visual",
64
+ "description": "visual field removed; copy spans full width.",
65
+ "showcaseParams": { "showVisual": "false" }
66
+ },
67
+ {
68
+ "label": "navy-background",
69
+ "description": "Navy background with Off White text.",
70
+ "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
71
+ }
72
+ ]
73
+ }
74
+
75
+ showcaseParams keys must match the cms-edit screenshot --param format:
76
+ backgroundColour, textColour, showVisual, showLinks, showHeading, etc.
77
+ For a flipped variant, use a separate typeName entry for "Hero Flipped".
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Output contract
83
+
84
+ ```json
85
+ {
86
+ "typeName": "Hero",
87
+ "variants": [
88
+ {
89
+ "label": "default",
90
+ "description": "All optional fields populated, no colour override.",
91
+ "showcaseParams": {}
92
+ },
93
+ {
94
+ "label": "no-visual",
95
+ "description": "Visual removed; copy spans full width.",
96
+ "showcaseParams": { "showVisual": "false" }
97
+ },
98
+ {
99
+ "label": "navy",
100
+ "description": "Navy background + Off White text.",
101
+ "showcaseParams": { "backgroundColour": "Navy", "textColour": "Off White" }
102
+ },
103
+ {
104
+ "label": "minimal",
105
+ "description": "Heading only, no eyebrow/subtitle/body/links/visual.",
106
+ "showcaseParams": { "showVisual": "false", "showLinks": "false" }
107
+ }
108
+ ]
109
+ }
110
+ ```
111
+
112
+ - `label` — used to name the screenshot file: `<typeName-kebab>-<label>.png`
113
+ - `description` — included in the screenshot log and used by the evaluation step
114
+ - `showcaseParams` — key-value pairs passed as `--param key=value` to `cms-edit screenshot`
115
+
116
+ ---
117
+
118
+ ## Notes on N and the cap
119
+
120
+ The orchestrator (Step 4.4) uses N (the number of proposed variants) as a cap:
121
+
122
+ - It will attempt up to **2×N** screenshots in total.
123
+ - If the evaluation step (Step 4.3) concludes the variants are "suitably different" before
124
+ reaching 2×N attempts, it stops early.
125
+ - If not, it requests a new proposal from the LLM for the remaining slots (up to 2×N total).
126
+
127
+ For most components, N = 4–6 produces a good coverage set.