coretik-block-generator-mcp 1.0.0
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/CLAUDE_INSTRUCTIONS.md +30 -0
- package/README.md +193 -0
- package/dist/constants.d.ts +55 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +27 -0
- package/dist/constants.js.map +1 -0
- package/dist/conventions.d.ts +19 -0
- package/dist/conventions.d.ts.map +1 -0
- package/dist/conventions.js +158 -0
- package/dist/conventions.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +518 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/learned-conventions.d.ts +53 -0
- package/dist/schemas/learned-conventions.d.ts.map +1 -0
- package/dist/schemas/learned-conventions.js +47 -0
- package/dist/schemas/learned-conventions.js.map +1 -0
- package/dist/services/convention-store.d.ts +9 -0
- package/dist/services/convention-store.d.ts.map +1 -0
- package/dist/services/convention-store.js +84 -0
- package/dist/services/convention-store.js.map +1 -0
- package/dist/services/feedback.d.ts +29 -0
- package/dist/services/feedback.d.ts.map +1 -0
- package/dist/services/feedback.js +199 -0
- package/dist/services/feedback.js.map +1 -0
- package/dist/services/naming.d.ts +51 -0
- package/dist/services/naming.d.ts.map +1 -0
- package/dist/services/naming.js +87 -0
- package/dist/services/naming.js.map +1 -0
- package/dist/services/pattern-extractor.d.ts +14 -0
- package/dist/services/pattern-extractor.d.ts.map +1 -0
- package/dist/services/pattern-extractor.js +310 -0
- package/dist/services/pattern-extractor.js.map +1 -0
- package/dist/services/registration.d.ts +31 -0
- package/dist/services/registration.d.ts.map +1 -0
- package/dist/services/registration.js +275 -0
- package/dist/services/registration.js.map +1 -0
- package/dist/templates/generators.d.ts +59 -0
- package/dist/templates/generators.d.ts.map +1 -0
- package/dist/templates/generators.js +79 -0
- package/dist/templates/generators.js.map +1 -0
- package/dist/templates/html-template.d.ts +12 -0
- package/dist/templates/html-template.d.ts.map +1 -0
- package/dist/templates/html-template.js +189 -0
- package/dist/templates/html-template.js.map +1 -0
- package/dist/templates/php-class.d.ts +19 -0
- package/dist/templates/php-class.d.ts.map +1 -0
- package/dist/templates/php-class.js +271 -0
- package/dist/templates/php-class.js.map +1 -0
- package/dist/templates/scss.d.ts +7 -0
- package/dist/templates/scss.d.ts.map +1 -0
- package/dist/templates/scss.js +102 -0
- package/dist/templates/scss.js.map +1 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +56 -0
- package/dist/utils.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Coretik Page Builder — Instructions pour l'IA
|
|
2
|
+
|
|
3
|
+
## Contexte
|
|
4
|
+
Ce projet WordPress utilise le framework Coretik et Coretik Page Builder pour construire des pages via un système de blocs ACF.
|
|
5
|
+
|
|
6
|
+
## Workflow de génération de bloc
|
|
7
|
+
|
|
8
|
+
Quand on te demande de créer un nouveau bloc Page Builder :
|
|
9
|
+
|
|
10
|
+
1. **Appelle `get_conventions`** pour charger les patterns de code Coretik
|
|
11
|
+
2. **Appelle `scan_blocks`** pour voir les blocs existants et s'inspirer du style du projet
|
|
12
|
+
3. **Appelle `read_block`** sur un bloc similaire existant si pertinent
|
|
13
|
+
4. **Appelle `generate_block`** en `dryRun: true` pour montrer le code au développeur
|
|
14
|
+
5. Après validation, appelle `generate_block` en `dryRun: false` pour écrire les fichiers
|
|
15
|
+
|
|
16
|
+
## Conventions importantes
|
|
17
|
+
|
|
18
|
+
- Noms de blocs en kebab-case : `text-image`, `hero-banner`
|
|
19
|
+
- BEM pour le CSS : `.block-text-image__title`
|
|
20
|
+
- Les images ACF renvoient un ID (`returnFormat: 'id'`), utiliser `wp_get_attachment_image()`
|
|
21
|
+
- Les liens ACF renvoient un array (`returnFormat: 'array'`) avec `url`, `title`, `target`
|
|
22
|
+
- Le WYSIWYG n'est PAS échappé dans le template (il contient du HTML)
|
|
23
|
+
- Toujours wrapper les champs optionnels dans `<?php if (!empty($var)) : ?>`
|
|
24
|
+
- Le SCSS est un partial préfixé `_` dans `assets/styles/components/blocks/`
|
|
25
|
+
|
|
26
|
+
## Types de blocs
|
|
27
|
+
|
|
28
|
+
- **Component** : brique réutilisable (pas visible dans la bibliothèque utilisateur)
|
|
29
|
+
- **Block** : bloc autonome complet
|
|
30
|
+
- **Composite** : assemblage de Components existants
|
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Coretik Block Generator MCP Server
|
|
2
|
+
|
|
3
|
+
Un serveur MCP (Model Context Protocol) qui permet de générer des blocs [Coretik Page Builder](https://github.com/idetik/coretik-page-builder) complets à partir d'une description en langage naturel.
|
|
4
|
+
|
|
5
|
+
## Ce que ça fait
|
|
6
|
+
|
|
7
|
+
Demandez simplement : *"Crée un bloc Texte et image avec un titre H2, un wysiwyg et une image à droite"* et le serveur génère **tous les fichiers** :
|
|
8
|
+
|
|
9
|
+
| Fichier | Chemin |
|
|
10
|
+
|---------|--------|
|
|
11
|
+
| Classe PHP | `src/Services/PageBuilder/Blocks/Block/TextImageBlock.php` |
|
|
12
|
+
| Template HTML | `templates/blocks/block/text-image.php` |
|
|
13
|
+
| SCSS | `assets/styles/components/blocks/_text-image.scss` |
|
|
14
|
+
| Thumbnail ACF | `assets/images/admin/acf/text-image.svg` |
|
|
15
|
+
|
|
16
|
+
## Prérequis
|
|
17
|
+
|
|
18
|
+
- Node.js ≥ 18
|
|
19
|
+
- Un projet WordPress avec Coretik Page Builder installé
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g coretik-block-generator-mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Ou utilisez directement via `npx` sans installation (voir configuration ci-dessous).
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
### Pour les projets wp-cubi
|
|
32
|
+
|
|
33
|
+
Un fichier `.mcp.json` est inclus à la racine des projets wp-cubi. Il suffit d'adapter le chemin du thème dans la variable `CORETIK_PROJECT_ROOT`.
|
|
34
|
+
|
|
35
|
+
### Pour Claude Desktop
|
|
36
|
+
|
|
37
|
+
Ajoutez dans `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) ou `%APPDATA%\Claude\claude_desktop_config.json` (Windows) :
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"coretik-blocks": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["coretik-block-generator-mcp"],
|
|
45
|
+
"env": {
|
|
46
|
+
"CORETIK_PROJECT_ROOT": "/chemin/vers/votre-theme-wordpress"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Pour VS Code (avec extension MCP)
|
|
54
|
+
|
|
55
|
+
Dans `.vscode/mcp.json` à la racine de votre projet :
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"servers": {
|
|
60
|
+
"coretik-blocks": {
|
|
61
|
+
"command": "npx",
|
|
62
|
+
"args": ["coretik-block-generator-mcp"],
|
|
63
|
+
"env": {
|
|
64
|
+
"CORETIK_PROJECT_ROOT": "${workspaceFolder}/web/app/themes/mon-theme"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Pour Claude Code
|
|
72
|
+
|
|
73
|
+
Dans `.mcp.json` à la racine de votre projet :
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"coretik-blocks": {
|
|
79
|
+
"command": "npx",
|
|
80
|
+
"args": ["coretik-block-generator-mcp"],
|
|
81
|
+
"env": {
|
|
82
|
+
"CORETIK_PROJECT_ROOT": "./web/app/themes/mon-theme"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Ou via la CLI :
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
claude mcp add coretik-blocks \
|
|
93
|
+
npx coretik-block-generator-mcp \
|
|
94
|
+
-e CORETIK_PROJECT_ROOT=./web/app/themes/mon-theme
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Variables d'environnement
|
|
98
|
+
|
|
99
|
+
| Variable | Défaut | Description |
|
|
100
|
+
|----------|--------|-------------|
|
|
101
|
+
| `CORETIK_PROJECT_ROOT` | Répertoire courant | Racine du thème WordPress |
|
|
102
|
+
| `CORETIK_ROOT_NAMESPACE` | `App\Services\PageBuilder\Blocks` | Namespace PHP des blocs |
|
|
103
|
+
| `CORETIK_BLOCKS_PHP_DIR` | `src/Services/PageBuilder/Blocks` | Dossier des classes PHP |
|
|
104
|
+
| `CORETIK_TEMPLATES_DIR` | `templates/blocks` | Dossier des templates |
|
|
105
|
+
| `CORETIK_SCSS_DIR` | `assets/styles/components/blocks` | Dossier des fichiers SCSS |
|
|
106
|
+
| `CORETIK_THUMBNAILS_DIR` | `assets/images/admin/acf` | Dossier des thumbnails admin |
|
|
107
|
+
| `CORETIK_ACF_ADMIN_DIR` | `templates/acf` | Dossier des fichiers admin ACF |
|
|
108
|
+
|
|
109
|
+
## Outils disponibles
|
|
110
|
+
|
|
111
|
+
### `get_conventions`
|
|
112
|
+
|
|
113
|
+
Renvoie les conventions et patterns de code Coretik Page Builder. L'IA appelle cet outil en premier pour comprendre la structure attendue.
|
|
114
|
+
|
|
115
|
+
### `scan_blocks`
|
|
116
|
+
|
|
117
|
+
Analyse le projet et liste tous les blocs existants avec leur type, leur nom et l'état de leurs fichiers (template ✓/✗, SCSS ✓/✗).
|
|
118
|
+
|
|
119
|
+
### `read_block`
|
|
120
|
+
|
|
121
|
+
Lit tous les fichiers d'un bloc existant (PHP, template, SCSS) pour s'en inspirer.
|
|
122
|
+
|
|
123
|
+
### `generate_block`
|
|
124
|
+
|
|
125
|
+
Génère les 4 fichiers d'un nouveau bloc. Paramètres :
|
|
126
|
+
|
|
127
|
+
- `name` : Nom en kebab-case (`text-image`)
|
|
128
|
+
- `label` : Label lisible (`"Texte et image"`)
|
|
129
|
+
- `type` : `component`, `block`, ou `composite`
|
|
130
|
+
- `fields` : Définition des champs ACF
|
|
131
|
+
- `components` : Sous-composants (pour les composites)
|
|
132
|
+
- `dryRun` : Prévisualiser sans écrire (`true`/`false`)
|
|
133
|
+
|
|
134
|
+
### `get_project_config`
|
|
135
|
+
|
|
136
|
+
Affiche la configuration courante du serveur et vérifie l'existence des dossiers.
|
|
137
|
+
|
|
138
|
+
## Exemples d'utilisation
|
|
139
|
+
|
|
140
|
+
### Scénario 1 : Bloc simple via conversation
|
|
141
|
+
|
|
142
|
+
> **Vous :** Crée un bloc "Hero banner" avec un titre, un sous-titre, une image de fond et un bouton CTA.
|
|
143
|
+
|
|
144
|
+
L'IA va :
|
|
145
|
+
1. Appeler `get_conventions` pour charger les patterns
|
|
146
|
+
2. Appeler `scan_blocks` pour voir le style existant
|
|
147
|
+
3. Appeler `generate_block` avec les bons champs ACF
|
|
148
|
+
4. Vous confirmer les fichiers créés
|
|
149
|
+
|
|
150
|
+
### Scénario 2 : Bloc composite
|
|
151
|
+
|
|
152
|
+
> **Vous :** J'ai besoin d'un bloc FAQ composé d'un TitleComponent et d'un repeater de questions/réponses.
|
|
153
|
+
|
|
154
|
+
### Scénario 3 : Dry-run pour valider
|
|
155
|
+
|
|
156
|
+
> **Vous :** Montre-moi le code que tu génèrerais pour un bloc "Témoignages" avec photo, nom, rôle et citation, sans écrire les fichiers.
|
|
157
|
+
|
|
158
|
+
### Scénario 4 : S'inspirer d'un bloc existant
|
|
159
|
+
|
|
160
|
+
> **Vous :** Lis le bloc `block.hero` et crée un bloc similaire mais avec une vidéo en fond au lieu d'une image.
|
|
161
|
+
|
|
162
|
+
## Structure des champs supportés
|
|
163
|
+
|
|
164
|
+
Le générateur supporte tous les types de champs ACF courants :
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
text, textarea, wysiwyg, image, file, gallery, number, url, email,
|
|
168
|
+
link, oembed, true_false, radio, select, checkbox, repeater, group,
|
|
169
|
+
post_object, relationship, page_link, color_picker
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Chaque champ accepte les options : `required`, `instructions`, `defaultValue`, `returnFormat`, `choices`, `width`, `conditional`, `subFields` (pour group/repeater).
|
|
173
|
+
|
|
174
|
+
## Développement
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Mode watch pendant le développement
|
|
178
|
+
npm run dev
|
|
179
|
+
|
|
180
|
+
# Tester le serveur (affiche la config)
|
|
181
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | node dist/index.js
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Roadmap
|
|
185
|
+
|
|
186
|
+
- [ ] Support de l'analyse de maquettes (image → bloc)
|
|
187
|
+
- [ ] Génération des fichiers ACF admin (CSS/JS preview)
|
|
188
|
+
- [ ] Import/export de définitions de blocs (JSON)
|
|
189
|
+
- [ ] Intégration WP-CLI pour `wp page-builder build-block-types`
|
|
190
|
+
|
|
191
|
+
## Licence
|
|
192
|
+
|
|
193
|
+
GPL-3.0 — Compatible avec Coretik et WordPress.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coretik Page Builder conventions and default paths.
|
|
3
|
+
* These can be overridden via the MCP tool parameters.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CONFIG: {
|
|
6
|
+
/** PHP class directory relative to theme root */
|
|
7
|
+
readonly blocksSrcDirectory: "src/Services/PageBuilder/Blocks/";
|
|
8
|
+
/** HTML template directory relative to theme root */
|
|
9
|
+
readonly blocksTemplateDirectory: "templates/blocks/";
|
|
10
|
+
/** SCSS directory relative to theme root */
|
|
11
|
+
readonly blocksScssDirectory: "assets/styles/components/blocks/";
|
|
12
|
+
/** ACF admin files directory relative to theme root */
|
|
13
|
+
readonly blocksAcfDirectory: "templates/acf/";
|
|
14
|
+
/** ACF thumbnails directory relative to theme root */
|
|
15
|
+
readonly blocksThumbnailDirectory: "assets/images/admin/acf/";
|
|
16
|
+
/** Root PHP namespace */
|
|
17
|
+
readonly rootNamespace: "App\\Services\\PageBuilder\\Blocks";
|
|
18
|
+
};
|
|
19
|
+
/** Block types supported by the generator */
|
|
20
|
+
export type BlockType = 'component' | 'block' | 'composite';
|
|
21
|
+
/** ACF field types commonly used in Coretik blocks */
|
|
22
|
+
export declare const ACF_FIELD_TYPES: readonly ["text", "textarea", "wysiwyg", "image", "gallery", "file", "select", "radio", "checkbox", "true_false", "link", "url", "number", "range", "email", "password", "repeater", "group", "relationship", "post_object", "taxonomy", "user", "color_picker", "date_picker", "date_time_picker", "time_picker", "oembed"];
|
|
23
|
+
export type AcfFieldType = typeof ACF_FIELD_TYPES[number];
|
|
24
|
+
/** Block field definition */
|
|
25
|
+
export interface BlockField {
|
|
26
|
+
name: string;
|
|
27
|
+
type: AcfFieldType;
|
|
28
|
+
label: string;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
defaultValue?: string;
|
|
31
|
+
choices?: string[];
|
|
32
|
+
instructions?: string;
|
|
33
|
+
/** For repeater / group: sub-fields */
|
|
34
|
+
subFields?: BlockField[];
|
|
35
|
+
}
|
|
36
|
+
/** Complete block specification */
|
|
37
|
+
export interface BlockSpec {
|
|
38
|
+
/** Human label, e.g. "Text and Image" */
|
|
39
|
+
label: string;
|
|
40
|
+
/** Block name override (auto-generated if empty) */
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Block type: component, block, or composite */
|
|
43
|
+
type: BlockType;
|
|
44
|
+
/** ACF fields definition */
|
|
45
|
+
fields: BlockField[];
|
|
46
|
+
/** For composites: list of component names to compose */
|
|
47
|
+
components?: string[];
|
|
48
|
+
/** CSS classes to use in HTML template */
|
|
49
|
+
cssClasses?: string[];
|
|
50
|
+
/** Brief description of the block's purpose */
|
|
51
|
+
description?: string;
|
|
52
|
+
/** Whether to implement ShouldBuildBlockType interface */
|
|
53
|
+
blockTypeSupport?: boolean;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,cAAc;IACzB,iDAAiD;;IAGjD,qDAAqD;;IAGrD,4CAA4C;;IAG5C,uDAAuD;;IAGvD,sDAAsD;;IAGtD,yBAAyB;;CAEjB,CAAC;AAEX,6CAA6C;AAC7C,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAE5D,sDAAsD;AACtD,eAAO,MAAM,eAAe,8TAMlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAE1D,6BAA6B;AAC7B,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,4BAA4B;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coretik Page Builder conventions and default paths.
|
|
3
|
+
* These can be overridden via the MCP tool parameters.
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_CONFIG = {
|
|
6
|
+
/** PHP class directory relative to theme root */
|
|
7
|
+
blocksSrcDirectory: 'src/Services/PageBuilder/Blocks/',
|
|
8
|
+
/** HTML template directory relative to theme root */
|
|
9
|
+
blocksTemplateDirectory: 'templates/blocks/',
|
|
10
|
+
/** SCSS directory relative to theme root */
|
|
11
|
+
blocksScssDirectory: 'assets/styles/components/blocks/',
|
|
12
|
+
/** ACF admin files directory relative to theme root */
|
|
13
|
+
blocksAcfDirectory: 'templates/acf/',
|
|
14
|
+
/** ACF thumbnails directory relative to theme root */
|
|
15
|
+
blocksThumbnailDirectory: 'assets/images/admin/acf/',
|
|
16
|
+
/** Root PHP namespace */
|
|
17
|
+
rootNamespace: 'App\\Services\\PageBuilder\\Blocks',
|
|
18
|
+
};
|
|
19
|
+
/** ACF field types commonly used in Coretik blocks */
|
|
20
|
+
export const ACF_FIELD_TYPES = [
|
|
21
|
+
'text', 'textarea', 'wysiwyg', 'image', 'gallery', 'file',
|
|
22
|
+
'select', 'radio', 'checkbox', 'true_false', 'link', 'url',
|
|
23
|
+
'number', 'range', 'email', 'password', 'repeater', 'group',
|
|
24
|
+
'relationship', 'post_object', 'taxonomy', 'user', 'color_picker',
|
|
25
|
+
'date_picker', 'date_time_picker', 'time_picker', 'oembed',
|
|
26
|
+
];
|
|
27
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,iDAAiD;IACjD,kBAAkB,EAAE,kCAAkC;IAEtD,qDAAqD;IACrD,uBAAuB,EAAE,mBAAmB;IAE5C,4CAA4C;IAC5C,mBAAmB,EAAE,kCAAkC;IAEvD,uDAAuD;IACvD,kBAAkB,EAAE,gBAAgB;IAEpC,sDAAsD;IACtD,wBAAwB,EAAE,0BAA0B;IAEpD,yBAAyB;IACzB,aAAa,EAAE,oCAAoC;CAC3C,CAAC;AAKX,sDAAsD;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM;IACzD,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK;IAC1D,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO;IAC3D,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc;IACjE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ;CAClD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coretik Page Builder conventions documentation.
|
|
3
|
+
* Exposed as MCP resources and via the get_conventions tool.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CONVENTIONS: {
|
|
6
|
+
readonly overview: "# Coretik Page Builder — Overview\n\nCoretik Page Builder is a WordPress page builder based on ACF (Advanced Custom Fields).\nBlocks are PHP classes that define ACF fields and render HTML templates.\n\nThere are two primary block types:\n- **Component** — Small reusable UI pieces (title, button, image, CTA, text box…)\n- **Composite** — Blocks that compose multiple components into a complete section\n\nComposites live in the Block/ directory and are the main building blocks of pages.\nComponents are reused across multiple composites.";
|
|
7
|
+
readonly fileStructure: "# File Structure\n\nA typical Coretik block consists of:\n- PHP class: src/Services/PageBuilder/Blocks/{Type}/{PascalName}{Suffix}.php\n- HTML template: templates/blocks/{type}/{kebab-name}.php\n- SCSS stylesheet: assets/styles/60-components/blocks/{kebab-name}.scss (or _kebab-name.scss)\n- ACF thumbnail: assets/images/admin/acf/{kebab-name}.svg\n\nDirectory layout:\n- Component/ — Small reusable UI components (PascalNameComponent.php)\n- Block/ — Composite blocks that compose components (PascalNameComposite.php)\n\nSCSS uses ITCSS architecture:\n- assets/styles/60-components/blocks.scss — imports all block SCSS partials\n- assets/styles/60-components/blocks/{block-name}.scss — individual block styles";
|
|
8
|
+
readonly phpClassPattern: "# PHP Class Pattern\n\nEach block extends a base class:\n- Component → extends BlockComponent\n- Composite → extends BlockComposite\n\nRequired constants:\n- NAME — dot-notation identifier, e.g. \"component.title\", \"block.text-image\"\n- LABEL — human-readable label, e.g. \"Texte et image\"\n\nComponent methods:\n- fieldsBuilder(): FieldsBuilder — defines ACF fields using StoutLogic\\AcfBuilder\n- toArray(): array — returns field values for template rendering\n- getPlainHtml(array $parameters): string — optional HTML output override\n\nComposite methods:\n- prepareComponents(): array — returns component class references\n- getPlainHtml(array $parameters): string — arranges rendered components\n\nComponent composition helpers:\n- tap(Component::class, fn) — modify a component's field configuration\n- repeat(Component::class, [...]) — repeat a component in a repeater\n- OnTheFlyComponent::named('label')->with('key', Component::class)->build() — inline composition\n\nOptional interfaces:\n- ShouldBuildBlockType — adds Gutenberg block type support (use BlockType trait)\n\nCommon trait:\n- Components — provides $this->component(Name::NAME) for nested component access";
|
|
9
|
+
readonly compositePattern: "# Composite Pattern\n\nComposites compose multiple components into a single block.\nThey live in the Block/ directory and are named *Composite.\n\nprepareComponents() returns an associative array:\n 'key' => ComponentClass::class — simple reference\n 'key' => tap(ComponentClass::class, fn) — modify field config\n 'key' => repeat(ComponentClass::class, []) — repeater\n 'key' => OnTheFlyComponent::named(...)->build() — inline\n\nTemplate variables are component instances with methods:\n $component->render() — renders the component HTML\n $component->getParameters() — returns the component's data array\n $component->toArray() — returns the raw array\n $component->withCssClasses('cls') — adds CSS classes before rendering\n $image->imageTag('large', [...]) — renders an image tag with size and attributes\n\nSettings support:\n $this->addSettings([$this, 'blockSettings'], priority)\n $this->block — access block-level settings in toArray()";
|
|
10
|
+
readonly templatePattern: "# Template Pattern\n\nComponent templates receive simple PHP variables from toArray().\nComposite templates receive component instances with method calls.\n\nConventions:\n- Use short echo: <?= $var ?> (not <?php echo)\n- Composites use <section> wrapper, components use <div>\n- Use dynamic classlist with context: $classlist = ['block-name'];\n- Support container context: BlockContextType::CONTAINER->name\n- Check !empty() before rendering optional fields\n- Use $component->render() to output sub-components\n- Use $image->imageTag('size', ['class' => '...']) for images\n- Use $cta->withCssClasses('btn btn--link') for styled CTAs\n- Support aria-labelledby for accessibility with $uniqId";
|
|
11
|
+
readonly scssPattern: "# SCSS Pattern\n\n- ITCSS architecture: 60-components/blocks.scss imports block partials\n- One file per block: blocks/{kebab-name}.scss\n- BEM methodology: .block-name { &__element { } &--modifier { } }\n- Use $spacing-unit for spacing (e.g., $spacing-unit * 4)\n- Use color() function: color('primary', 'base'), color('secondary', 'lighten-2')\n- Use responsive mixins: @include media-breakpoint-up(medium)\n- Use SCSS placeholders %name for shared styles across components\n- Parent selector caching: $self: &; for complex nesting";
|
|
12
|
+
readonly acfFieldTypes: "# ACF Field Types\n\nCommon field types and their PHP return values:\n- text, textarea, email, url → string\n- wysiwyg → string (HTML)\n- number, range → int|float\n- image, file → int (ID) or array\n- gallery → array of int|array\n- link → array with keys: url, title, target\n- select, radio → string\n- checkbox → array\n- true_false → bool\n- repeater, group → array\n- relationship, post_object → int|WP_Post\n- oembed → string (HTML embed code)";
|
|
13
|
+
readonly namingConventions: "# Naming Conventions\n\n- Component NAME: \"component.{kebab-case}\" — e.g. \"component.title\"\n- Composite NAME: \"block.{kebab-case}\" — e.g. \"block.text-image\"\n- Component class: PascalCase + Component — e.g. \"TitleComponent\"\n- Composite class: PascalCase + Composite — e.g. \"TextImageComposite\"\n- Template file: {kebab-case}.php — e.g. \"text-image.php\"\n- SCSS file: {kebab-case}.scss — e.g. \"text-image.scss\"\n- CSS class: block-{kebab-case} or {kebab-case}-component\n- PHP namespace: {RootNamespace}\\Component or {RootNamespace}\\Block";
|
|
14
|
+
readonly registrationPattern: "# Block Registration\n\nBlocks are registered via the Coretik container in a config/dependencies file:\n\n$container->extend('pageBuilder.library', function ($blocks, $c) {\n $our_blocks = [\n Namespace\\Component\\TitleComponent::class,\n Namespace\\Block\\TextImageComposite::class,\n // ...\n ];\n foreach ($our_blocks as $class) {\n $blocks->push($class);\n }\n return $blocks;\n});\n\nSCSS partials are imported in the ITCSS blocks aggregator:\n@import 'blocks/text-image';\n@import 'blocks/testimonials';";
|
|
15
|
+
};
|
|
16
|
+
export type ConventionSection = keyof typeof CONVENTIONS;
|
|
17
|
+
export declare function getConventionSection(section: ConventionSection): string;
|
|
18
|
+
export declare function getFullConventions(): string;
|
|
19
|
+
//# sourceMappingURL=conventions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conventions.d.ts","sourceRoot":"","sources":["../src/conventions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,WAAW;;;;;;;;;;CA0Jd,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,WAAW,CAAC;AAEzD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAEvE;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coretik Page Builder conventions documentation.
|
|
3
|
+
* Exposed as MCP resources and via the get_conventions tool.
|
|
4
|
+
*/
|
|
5
|
+
export const CONVENTIONS = {
|
|
6
|
+
overview: `# Coretik Page Builder — Overview
|
|
7
|
+
|
|
8
|
+
Coretik Page Builder is a WordPress page builder based on ACF (Advanced Custom Fields).
|
|
9
|
+
Blocks are PHP classes that define ACF fields and render HTML templates.
|
|
10
|
+
|
|
11
|
+
There are two primary block types:
|
|
12
|
+
- **Component** — Small reusable UI pieces (title, button, image, CTA, text box…)
|
|
13
|
+
- **Composite** — Blocks that compose multiple components into a complete section
|
|
14
|
+
|
|
15
|
+
Composites live in the Block/ directory and are the main building blocks of pages.
|
|
16
|
+
Components are reused across multiple composites.`,
|
|
17
|
+
fileStructure: `# File Structure
|
|
18
|
+
|
|
19
|
+
A typical Coretik block consists of:
|
|
20
|
+
- PHP class: src/Services/PageBuilder/Blocks/{Type}/{PascalName}{Suffix}.php
|
|
21
|
+
- HTML template: templates/blocks/{type}/{kebab-name}.php
|
|
22
|
+
- SCSS stylesheet: assets/styles/60-components/blocks/{kebab-name}.scss (or _kebab-name.scss)
|
|
23
|
+
- ACF thumbnail: assets/images/admin/acf/{kebab-name}.svg
|
|
24
|
+
|
|
25
|
+
Directory layout:
|
|
26
|
+
- Component/ — Small reusable UI components (PascalNameComponent.php)
|
|
27
|
+
- Block/ — Composite blocks that compose components (PascalNameComposite.php)
|
|
28
|
+
|
|
29
|
+
SCSS uses ITCSS architecture:
|
|
30
|
+
- assets/styles/60-components/blocks.scss — imports all block SCSS partials
|
|
31
|
+
- assets/styles/60-components/blocks/{block-name}.scss — individual block styles`,
|
|
32
|
+
phpClassPattern: `# PHP Class Pattern
|
|
33
|
+
|
|
34
|
+
Each block extends a base class:
|
|
35
|
+
- Component → extends BlockComponent
|
|
36
|
+
- Composite → extends BlockComposite
|
|
37
|
+
|
|
38
|
+
Required constants:
|
|
39
|
+
- NAME — dot-notation identifier, e.g. "component.title", "block.text-image"
|
|
40
|
+
- LABEL — human-readable label, e.g. "Texte et image"
|
|
41
|
+
|
|
42
|
+
Component methods:
|
|
43
|
+
- fieldsBuilder(): FieldsBuilder — defines ACF fields using StoutLogic\\AcfBuilder
|
|
44
|
+
- toArray(): array — returns field values for template rendering
|
|
45
|
+
- getPlainHtml(array $parameters): string — optional HTML output override
|
|
46
|
+
|
|
47
|
+
Composite methods:
|
|
48
|
+
- prepareComponents(): array — returns component class references
|
|
49
|
+
- getPlainHtml(array $parameters): string — arranges rendered components
|
|
50
|
+
|
|
51
|
+
Component composition helpers:
|
|
52
|
+
- tap(Component::class, fn) — modify a component's field configuration
|
|
53
|
+
- repeat(Component::class, [...]) — repeat a component in a repeater
|
|
54
|
+
- OnTheFlyComponent::named('label')->with('key', Component::class)->build() — inline composition
|
|
55
|
+
|
|
56
|
+
Optional interfaces:
|
|
57
|
+
- ShouldBuildBlockType — adds Gutenberg block type support (use BlockType trait)
|
|
58
|
+
|
|
59
|
+
Common trait:
|
|
60
|
+
- Components — provides $this->component(Name::NAME) for nested component access`,
|
|
61
|
+
compositePattern: `# Composite Pattern
|
|
62
|
+
|
|
63
|
+
Composites compose multiple components into a single block.
|
|
64
|
+
They live in the Block/ directory and are named *Composite.
|
|
65
|
+
|
|
66
|
+
prepareComponents() returns an associative array:
|
|
67
|
+
'key' => ComponentClass::class — simple reference
|
|
68
|
+
'key' => tap(ComponentClass::class, fn) — modify field config
|
|
69
|
+
'key' => repeat(ComponentClass::class, []) — repeater
|
|
70
|
+
'key' => OnTheFlyComponent::named(...)->build() — inline
|
|
71
|
+
|
|
72
|
+
Template variables are component instances with methods:
|
|
73
|
+
$component->render() — renders the component HTML
|
|
74
|
+
$component->getParameters() — returns the component's data array
|
|
75
|
+
$component->toArray() — returns the raw array
|
|
76
|
+
$component->withCssClasses('cls') — adds CSS classes before rendering
|
|
77
|
+
$image->imageTag('large', [...]) — renders an image tag with size and attributes
|
|
78
|
+
|
|
79
|
+
Settings support:
|
|
80
|
+
$this->addSettings([$this, 'blockSettings'], priority)
|
|
81
|
+
$this->block — access block-level settings in toArray()`,
|
|
82
|
+
templatePattern: `# Template Pattern
|
|
83
|
+
|
|
84
|
+
Component templates receive simple PHP variables from toArray().
|
|
85
|
+
Composite templates receive component instances with method calls.
|
|
86
|
+
|
|
87
|
+
Conventions:
|
|
88
|
+
- Use short echo: <?= $var ?> (not <?php echo)
|
|
89
|
+
- Composites use <section> wrapper, components use <div>
|
|
90
|
+
- Use dynamic classlist with context: $classlist = ['block-name'];
|
|
91
|
+
- Support container context: BlockContextType::CONTAINER->name
|
|
92
|
+
- Check !empty() before rendering optional fields
|
|
93
|
+
- Use $component->render() to output sub-components
|
|
94
|
+
- Use $image->imageTag('size', ['class' => '...']) for images
|
|
95
|
+
- Use $cta->withCssClasses('btn btn--link') for styled CTAs
|
|
96
|
+
- Support aria-labelledby for accessibility with $uniqId`,
|
|
97
|
+
scssPattern: `# SCSS Pattern
|
|
98
|
+
|
|
99
|
+
- ITCSS architecture: 60-components/blocks.scss imports block partials
|
|
100
|
+
- One file per block: blocks/{kebab-name}.scss
|
|
101
|
+
- BEM methodology: .block-name { &__element { } &--modifier { } }
|
|
102
|
+
- Use $spacing-unit for spacing (e.g., $spacing-unit * 4)
|
|
103
|
+
- Use color() function: color('primary', 'base'), color('secondary', 'lighten-2')
|
|
104
|
+
- Use responsive mixins: @include media-breakpoint-up(medium)
|
|
105
|
+
- Use SCSS placeholders %name for shared styles across components
|
|
106
|
+
- Parent selector caching: $self: &; for complex nesting`,
|
|
107
|
+
acfFieldTypes: `# ACF Field Types
|
|
108
|
+
|
|
109
|
+
Common field types and their PHP return values:
|
|
110
|
+
- text, textarea, email, url → string
|
|
111
|
+
- wysiwyg → string (HTML)
|
|
112
|
+
- number, range → int|float
|
|
113
|
+
- image, file → int (ID) or array
|
|
114
|
+
- gallery → array of int|array
|
|
115
|
+
- link → array with keys: url, title, target
|
|
116
|
+
- select, radio → string
|
|
117
|
+
- checkbox → array
|
|
118
|
+
- true_false → bool
|
|
119
|
+
- repeater, group → array
|
|
120
|
+
- relationship, post_object → int|WP_Post
|
|
121
|
+
- oembed → string (HTML embed code)`,
|
|
122
|
+
namingConventions: `# Naming Conventions
|
|
123
|
+
|
|
124
|
+
- Component NAME: "component.{kebab-case}" — e.g. "component.title"
|
|
125
|
+
- Composite NAME: "block.{kebab-case}" — e.g. "block.text-image"
|
|
126
|
+
- Component class: PascalCase + Component — e.g. "TitleComponent"
|
|
127
|
+
- Composite class: PascalCase + Composite — e.g. "TextImageComposite"
|
|
128
|
+
- Template file: {kebab-case}.php — e.g. "text-image.php"
|
|
129
|
+
- SCSS file: {kebab-case}.scss — e.g. "text-image.scss"
|
|
130
|
+
- CSS class: block-{kebab-case} or {kebab-case}-component
|
|
131
|
+
- PHP namespace: {RootNamespace}\\Component or {RootNamespace}\\Block`,
|
|
132
|
+
registrationPattern: `# Block Registration
|
|
133
|
+
|
|
134
|
+
Blocks are registered via the Coretik container in a config/dependencies file:
|
|
135
|
+
|
|
136
|
+
$container->extend('pageBuilder.library', function ($blocks, $c) {
|
|
137
|
+
$our_blocks = [
|
|
138
|
+
Namespace\\Component\\TitleComponent::class,
|
|
139
|
+
Namespace\\Block\\TextImageComposite::class,
|
|
140
|
+
// ...
|
|
141
|
+
];
|
|
142
|
+
foreach ($our_blocks as $class) {
|
|
143
|
+
$blocks->push($class);
|
|
144
|
+
}
|
|
145
|
+
return $blocks;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
SCSS partials are imported in the ITCSS blocks aggregator:
|
|
149
|
+
@import 'blocks/text-image';
|
|
150
|
+
@import 'blocks/testimonials';`,
|
|
151
|
+
};
|
|
152
|
+
export function getConventionSection(section) {
|
|
153
|
+
return CONVENTIONS[section] ?? '';
|
|
154
|
+
}
|
|
155
|
+
export function getFullConventions() {
|
|
156
|
+
return Object.values(CONVENTIONS).join('\n\n---\n\n');
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=conventions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conventions.js","sourceRoot":"","sources":["../src/conventions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE;;;;;;;;;;kDAUsC;IAEhD,aAAa,EAAE;;;;;;;;;;;;;;iFAcgE;IAE/E,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFA4B8D;IAE/E,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;0DAoBsC;IAExD,eAAe,EAAE;;;;;;;;;;;;;;yDAcsC;IAEvD,WAAW,EAAE;;;;;;;;;yDAS0C;IAEvD,aAAa,EAAE;;;;;;;;;;;;;;oCAcmB;IAElC,iBAAiB,EAAE;;;;;;;;;sEASiD;IAEpE,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;+BAkBQ;CACrB,CAAC;AAIX,MAAM,UAAU,oBAAoB,CAAC,OAA0B;IAC7D,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Coretik Block Generator MCP Server
|
|
4
|
+
*
|
|
5
|
+
* An MCP server that provides tools for generating Coretik Page Builder blocks.
|
|
6
|
+
* Exposes conventions as resources and block generation as tools.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|