@se-studio/contentful-cms 1.0.4 → 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.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/bin/cms-capture-screenshots.d.ts +4 -0
- package/dist/bin/cms-capture-screenshots.d.ts.map +1 -0
- package/dist/bin/cms-capture-screenshots.js +183 -0
- package/dist/bin/cms-capture-screenshots.js.map +1 -0
- package/dist/bin/cms-generate-collection-guidelines.d.ts +4 -0
- package/dist/bin/cms-generate-collection-guidelines.d.ts.map +1 -0
- package/dist/bin/cms-generate-collection-guidelines.js +209 -0
- package/dist/bin/cms-generate-collection-guidelines.js.map +1 -0
- package/dist/bin/cms-generate-field-list.d.ts +4 -0
- package/dist/bin/cms-generate-field-list.d.ts.map +1 -0
- package/dist/bin/cms-generate-field-list.js +114 -0
- package/dist/bin/cms-generate-field-list.js.map +1 -0
- package/dist/bin/cms-merge-guidelines.d.ts +4 -0
- package/dist/bin/cms-merge-guidelines.d.ts.map +1 -0
- package/dist/bin/cms-merge-guidelines.js +147 -0
- package/dist/bin/cms-merge-guidelines.js.map +1 -0
- package/dist/bin/cms-update-colour-hints.d.ts +4 -0
- package/dist/bin/cms-update-colour-hints.d.ts.map +1 -0
- package/dist/bin/cms-update-colour-hints.js +111 -0
- package/dist/bin/cms-update-colour-hints.js.map +1 -0
- package/dist/config/load.js +1 -1
- package/dist/config/load.js.map +1 -1
- package/package.json +7 -2
- package/skills/cms-guidelines/README.md +140 -0
- package/skills/cms-guidelines/colour-hint-prompt.md +77 -0
- package/skills/cms-guidelines/evaluation-prompt.md +84 -0
- package/skills/cms-guidelines/generate-component-guidelines.md +126 -0
- package/skills/cms-guidelines/generation-prompt.md +202 -0
- package/skills/cms-guidelines/validation-prompt.md +170 -0
- package/skills/cms-guidelines/variant-loop.md +184 -0
- package/skills/cms-guidelines/variant-proposal-prompt.md +127 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noConsole: Console output is intentional in CLI */
|
|
3
|
+
/**
|
|
4
|
+
* cms-merge-guidelines
|
|
5
|
+
*
|
|
6
|
+
* Merges all per-type guideline markdown files into one document:
|
|
7
|
+
* <app-dir>/docs/cms-guidelines/COMPONENT_GUIDELINES_FOR_LLM.md
|
|
8
|
+
*
|
|
9
|
+
* Reads from:
|
|
10
|
+
* docs/cms-guidelines/components/*.md (one file per componentType)
|
|
11
|
+
* docs/cms-guidelines/collections/*.md (one file per collectionType)
|
|
12
|
+
* docs/cms-guidelines/externals/*.md (one file per externalComponentType)
|
|
13
|
+
*
|
|
14
|
+
* Versioning: generated date and current git commit id are appended.
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* cms-merge-guidelines [--app-dir <path>] [--app-name <name>]
|
|
18
|
+
*/
|
|
19
|
+
import { execSync } from 'node:child_process';
|
|
20
|
+
import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { basename, extname, join } from 'node:path';
|
|
22
|
+
// Parse CLI flags
|
|
23
|
+
function parseCli() {
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
let appDir = process.cwd();
|
|
26
|
+
let appName = null;
|
|
27
|
+
for (let i = 0; i < args.length; i++) {
|
|
28
|
+
if (args[i] === '--app-dir' && args[i + 1]) {
|
|
29
|
+
appDir = args[++i];
|
|
30
|
+
}
|
|
31
|
+
else if (args[i] === '--app-name' && args[i + 1]) {
|
|
32
|
+
appName = args[++i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { appDir, appName };
|
|
36
|
+
}
|
|
37
|
+
const { appDir: appRoot, appName: cliAppName } = parseCli();
|
|
38
|
+
// Derive app name from directory if not provided
|
|
39
|
+
const appName = cliAppName ?? basename(appRoot);
|
|
40
|
+
const GUIDELINES_DIR = join(appRoot, 'docs/cms-guidelines');
|
|
41
|
+
const OUTPUT_PATH = join(GUIDELINES_DIR, 'COMPONENT_GUIDELINES_FOR_LLM.md');
|
|
42
|
+
const SECTIONS = [
|
|
43
|
+
{ dir: 'components', label: 'Components' },
|
|
44
|
+
{ dir: 'collections', label: 'Collections' },
|
|
45
|
+
{ dir: 'externals', label: 'External Components' },
|
|
46
|
+
];
|
|
47
|
+
function readMarkdownFiles(dir) {
|
|
48
|
+
let files;
|
|
49
|
+
try {
|
|
50
|
+
files = readdirSync(dir);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
return files
|
|
56
|
+
.filter((f) => extname(f) === '.md')
|
|
57
|
+
.sort()
|
|
58
|
+
.map((f) => ({
|
|
59
|
+
name: basename(f, '.md'),
|
|
60
|
+
content: readFileSync(join(dir, f), 'utf8').trim(),
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function getCommitId() {
|
|
64
|
+
try {
|
|
65
|
+
return execSync('git rev-parse --short HEAD', { cwd: appRoot }).toString().trim();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return 'unknown';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function formatDate(date) {
|
|
72
|
+
return date.toISOString().split('T')[0];
|
|
73
|
+
}
|
|
74
|
+
function main() {
|
|
75
|
+
console.log(`Merging guidelines for: ${appRoot}`);
|
|
76
|
+
const commitId = getCommitId();
|
|
77
|
+
const generatedDate = formatDate(new Date());
|
|
78
|
+
const parts = [];
|
|
79
|
+
parts.push(`# CMS Component Guidelines — ${appName}`);
|
|
80
|
+
parts.push('');
|
|
81
|
+
parts.push('This document is **self-contained**: it describes the visual layout, typography, colours,');
|
|
82
|
+
parts.push('field behaviour, and content impact for every CMS component, collection, and external');
|
|
83
|
+
parts.push('component available on this site. Source code access is not required to use it.');
|
|
84
|
+
parts.push('');
|
|
85
|
+
parts.push('All behaviour described here is accurate as of the version noted below.');
|
|
86
|
+
parts.push('');
|
|
87
|
+
parts.push(`> Generated: ${generatedDate} | Commit: ${commitId}`);
|
|
88
|
+
parts.push('');
|
|
89
|
+
parts.push('---');
|
|
90
|
+
parts.push('');
|
|
91
|
+
// Table of contents
|
|
92
|
+
parts.push('## Table of Contents');
|
|
93
|
+
parts.push('');
|
|
94
|
+
for (const { dir, label } of SECTIONS) {
|
|
95
|
+
const entries = readMarkdownFiles(join(GUIDELINES_DIR, dir));
|
|
96
|
+
if (entries.length === 0) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
parts.push(`### ${label}`);
|
|
100
|
+
parts.push('');
|
|
101
|
+
for (const { name, content } of entries) {
|
|
102
|
+
const h1Match = content.match(/^#\s+(.+)$/m);
|
|
103
|
+
const displayName = h1Match ? h1Match[1] : name;
|
|
104
|
+
parts.push(`- [${displayName}](#${name.replace(/\s+/g, '-').toLowerCase()})`);
|
|
105
|
+
}
|
|
106
|
+
parts.push('');
|
|
107
|
+
}
|
|
108
|
+
parts.push('---');
|
|
109
|
+
parts.push('');
|
|
110
|
+
// Content sections
|
|
111
|
+
let hasContent = false;
|
|
112
|
+
for (const { dir, label } of SECTIONS) {
|
|
113
|
+
const entries = readMarkdownFiles(join(GUIDELINES_DIR, dir));
|
|
114
|
+
if (entries.length === 0) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
hasContent = true;
|
|
118
|
+
parts.push(`## ${label}`);
|
|
119
|
+
parts.push('');
|
|
120
|
+
for (const { content } of entries) {
|
|
121
|
+
parts.push(content);
|
|
122
|
+
parts.push('');
|
|
123
|
+
parts.push('---');
|
|
124
|
+
parts.push('');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!hasContent) {
|
|
128
|
+
parts.push('*No guidelines have been generated yet.*');
|
|
129
|
+
parts.push('');
|
|
130
|
+
parts.push('Run the generation pipeline to populate this document.');
|
|
131
|
+
parts.push('See `docs/cms-guidelines/README.md` for instructions.');
|
|
132
|
+
parts.push('');
|
|
133
|
+
}
|
|
134
|
+
// Footer
|
|
135
|
+
parts.push('---');
|
|
136
|
+
parts.push('');
|
|
137
|
+
parts.push('*This document was generated automatically. Do not edit directly — edit the per-type*');
|
|
138
|
+
parts.push(`*files in \`docs/cms-guidelines/\` and re-run \`cms-merge-guidelines\`.*`);
|
|
139
|
+
parts.push('');
|
|
140
|
+
parts.push(`Generated: ${generatedDate} | Commit: ${commitId}`);
|
|
141
|
+
const output = parts.join('\n');
|
|
142
|
+
writeFileSync(OUTPUT_PATH, output);
|
|
143
|
+
console.log(`Merged ${OUTPUT_PATH}`);
|
|
144
|
+
console.log(` Generated: ${generatedDate} | Commit: ${commitId}`);
|
|
145
|
+
}
|
|
146
|
+
main();
|
|
147
|
+
//# sourceMappingURL=cms-merge-guidelines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms-merge-guidelines.js","sourceRoot":"","sources":["../../src/bin/cms-merge-guidelines.ts"],"names":[],"mappings":";AAEA,uFAAuF;AAEvF;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,kBAAkB;AAClB,SAAS,QAAQ;IACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;Y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EhE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAEnC,OAAO,CAAC,GAAG,CAAC,UAAU,WAAW,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,gBAAgB,aAAa,cAAc,QAAQ,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms-update-colour-hints.d.ts","sourceRoot":"","sources":["../../src/bin/cms-update-colour-hints.ts"],"names":[],"mappings":";AACA,uFAAuF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noConsole: Console output is intentional in CLI */
|
|
3
|
+
/**
|
|
4
|
+
* cms-update-colour-hints
|
|
5
|
+
*
|
|
6
|
+
* Adds or updates a colour hint entry in generated/cms-discovery/colour-hints.json.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* cms-update-colour-hints --type "Hero" --hint "section" [--app-dir <path>]
|
|
10
|
+
* [--notes "backgroundColour and textColour applied to the full Section wrapper."]
|
|
11
|
+
*
|
|
12
|
+
* cms-update-colour-hints --from /tmp/hero-colour-hint.json [--app-dir <path>]
|
|
13
|
+
*
|
|
14
|
+
* colour-hints.json format:
|
|
15
|
+
* {
|
|
16
|
+
* "Hero": { "colourApplication": "section", "notes": "..." },
|
|
17
|
+
* "Cards Grid": { "colourApplication": "section", "notes": "..." }
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* Valid colourApplication values: "section", "card", "section+card", "none"
|
|
21
|
+
*/
|
|
22
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import { dirname, join } from 'node:path';
|
|
24
|
+
const VALID_HINTS = ['section', 'card', 'section+card', 'none'];
|
|
25
|
+
function parseCli() {
|
|
26
|
+
const args = process.argv.slice(2);
|
|
27
|
+
const result = {
|
|
28
|
+
type: null,
|
|
29
|
+
hint: null,
|
|
30
|
+
notes: null,
|
|
31
|
+
from: null,
|
|
32
|
+
appDir: process.cwd(),
|
|
33
|
+
};
|
|
34
|
+
for (let i = 0; i < args.length; i++) {
|
|
35
|
+
if (args[i] === '--type' && args[i + 1]) {
|
|
36
|
+
result.type = args[++i];
|
|
37
|
+
}
|
|
38
|
+
else if (args[i] === '--hint' && args[i + 1]) {
|
|
39
|
+
result.hint = args[++i];
|
|
40
|
+
}
|
|
41
|
+
else if (args[i] === '--notes' && args[i + 1]) {
|
|
42
|
+
result.notes = args[++i];
|
|
43
|
+
}
|
|
44
|
+
else if (args[i] === '--from' && args[i + 1]) {
|
|
45
|
+
result.from = args[++i];
|
|
46
|
+
}
|
|
47
|
+
else if (args[i] === '--app-dir' && args[i + 1]) {
|
|
48
|
+
result.appDir = args[++i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function loadHints(hintsPath) {
|
|
54
|
+
if (!existsSync(hintsPath)) {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
return JSON.parse(readFileSync(hintsPath, 'utf8'));
|
|
58
|
+
}
|
|
59
|
+
function saveHints(hintsPath, hints) {
|
|
60
|
+
mkdirSync(dirname(hintsPath), { recursive: true });
|
|
61
|
+
const sorted = Object.fromEntries(Object.entries(hints).sort(([a], [b]) => a.localeCompare(b)));
|
|
62
|
+
writeFileSync(hintsPath, JSON.stringify(sorted, null, 2));
|
|
63
|
+
}
|
|
64
|
+
function isValidHint(value) {
|
|
65
|
+
return VALID_HINTS.includes(value);
|
|
66
|
+
}
|
|
67
|
+
function main() {
|
|
68
|
+
const { type, hint, notes, from, appDir } = parseCli();
|
|
69
|
+
const hintsPath = join(appDir, 'generated/cms-discovery/colour-hints.json');
|
|
70
|
+
const hints = loadHints(hintsPath);
|
|
71
|
+
if (from) {
|
|
72
|
+
const data = JSON.parse(readFileSync(from, 'utf8'));
|
|
73
|
+
const typeName = data.typeName;
|
|
74
|
+
const colourApplication = data.colourApplication;
|
|
75
|
+
if (!typeName || !colourApplication) {
|
|
76
|
+
console.error('JSON must have typeName and colourApplication fields.');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
if (!isValidHint(colourApplication)) {
|
|
80
|
+
console.error(`Invalid colourApplication "${colourApplication}". Valid: ${VALID_HINTS.join(', ')}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
hints[typeName] = { colourApplication };
|
|
84
|
+
if (data.notes) {
|
|
85
|
+
hints[typeName] = { ...hints[typeName], notes: data.notes };
|
|
86
|
+
}
|
|
87
|
+
saveHints(hintsPath, hints);
|
|
88
|
+
console.log(`Updated colour hint for "${typeName}": ${colourApplication}`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!type || !hint) {
|
|
92
|
+
console.log('Usage:');
|
|
93
|
+
console.log(' cms-update-colour-hints --type "Hero" --hint "section" [--notes "..."] [--app-dir <path>]');
|
|
94
|
+
console.log(' cms-update-colour-hints --from /tmp/hint.json [--app-dir <path>]');
|
|
95
|
+
console.log(`Valid hints: ${VALID_HINTS.join(', ')}`);
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
if (!isValidHint(hint)) {
|
|
99
|
+
console.error(`Invalid hint "${hint}". Valid: ${VALID_HINTS.join(', ')}`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
hints[type] = { colourApplication: hint };
|
|
103
|
+
if (notes) {
|
|
104
|
+
hints[type] = { ...hints[type], notes };
|
|
105
|
+
}
|
|
106
|
+
saveHints(hintsPath, hints);
|
|
107
|
+
console.log(`Updated colour hint for "${type}": ${hint}`);
|
|
108
|
+
console.log(`Written to ${hintsPath}`);
|
|
109
|
+
}
|
|
110
|
+
main();
|
|
111
|
+
//# sourceM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C;QAC5B,OAAO,CAAC,GAAG,CAAC,4BAA4B,QAAQ,MAAM,iBAAiB,EAAE,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,6FAA6F,CAC9F,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,OAAO,CAAC,GAAG,CAAC,gBAAgB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,aAAa,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC;IAED,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/config/load.js
CHANGED
|
@@ -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;
|
package/dist/config/load.js.map
CHANGED
|
@@ -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;AAClC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAG9C;;GAEG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAW,EAAE,EAAE;QACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,yBAAyB,GAAG,2DAA2D,CACxF,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,UAAmB;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,mEAAmE;IACnE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,UAAU,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;I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;;GAEG;AACH,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;QAC7D,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,IAAI,CAAC;QACpC,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/contentful-cms",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"bin": {
|
|
21
|
-
"cms-edit": "./dist/bin/cms-edit.js"
|
|
21
|
+
"cms-edit": "./dist/bin/cms-edit.js",
|
|
22
|
+
"cms-generate-field-list": "./dist/bin/cms-generate-field-list.js",
|
|
23
|
+
"cms-merge-guidelines": "./dist/bin/cms-merge-guidelines.js",
|
|
24
|
+
"cms-capture-screenshots": "./dist/bin/cms-capture-screenshots.js",
|
|
25
|
+
"cms-update-colour-hints": "./dist/bin/cms-update-colour-hints.js",
|
|
26
|
+
"cms-generate-collection-guidelines": "./dist/bin/cms-generate-collection-guidelines.js"
|
|
22
27
|
},
|
|
23
28
|
"files": [
|
|
24
29
|
"dist",
|
|
@@ -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/`.
|