@marvalt/digivalt-mcp 0.0.0-stage → 0.5.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/CHANGELOG.md +56 -0
- package/LICENSE +674 -0
- package/README.md +69 -2
- package/dist/audit.d.ts +24 -0
- package/dist/audit.js +34 -0
- package/dist/audit.js.map +1 -0
- package/dist/blocks/serialize.d.ts +15 -0
- package/dist/blocks/serialize.js +231 -0
- package/dist/blocks/serialize.js.map +1 -0
- package/dist/catalogue/blocks.d.ts +17 -0
- package/dist/catalogue/blocks.js +37 -0
- package/dist/catalogue/blocks.js.map +1 -0
- package/dist/catalogue/shortcodes.d.ts +49 -0
- package/dist/catalogue/shortcodes.js +384 -0
- package/dist/catalogue/shortcodes.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +58 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.js +139 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/media.d.ts +26 -0
- package/dist/media.js +118 -0
- package/dist/media.js.map +1 -0
- package/dist/publish.d.ts +32 -0
- package/dist/publish.js +74 -0
- package/dist/publish.js.map +1 -0
- package/dist/refresh.d.ts +30 -0
- package/dist/refresh.js +93 -0
- package/dist/refresh.js.map +1 -0
- package/dist/resources/guides.d.ts +2 -0
- package/dist/resources/guides.js +51 -0
- package/dist/resources/guides.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.js +522 -0
- package/dist/server.js.map +1 -0
- package/dist/validate/local.d.ts +17 -0
- package/dist/validate/local.js +75 -0
- package/dist/validate/local.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/dist/wp-client.d.ts +31 -0
- package/dist/wp-client.js +94 -0
- package/dist/wp-client.js.map +1 -0
- package/docs/README.md +114 -0
- package/docs/SECURITY.md +44 -0
- package/package.json +51 -4
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @marvalt/digivalt-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local MCP server (stdio) that lets an AI agent read, validate and draft WordPress pages for a DigiValt frontend, through the `wp-pagesync` 2.1.0+ plugin. Works with Claude Code, Claude Desktop / Cowork, Cursor and OpenClaw.
|
|
4
|
+
|
|
5
|
+
Status: 0.5.0 reads, validates and writes drafts, previews them, and, only with a separate publisher credential and the person's approval, promotes, publishes and rolls back.
|
|
6
|
+
|
|
7
|
+
## Claude Desktop extension
|
|
8
|
+
|
|
9
|
+
Content managers who do not use the repository can install `digivalt-mcp-<version>.mcpb` in Claude Desktop and fill in a settings form. See `docs/README.md` ("Claude Desktop extension"). Build it with `npm run pack:mcpb`.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
In the app repo, put these in `.env.local`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
VITE_WORDPRESS_API_URL=https://cms.example.com
|
|
17
|
+
DIGIVALT_MCP_WP_USER=mcp-agent
|
|
18
|
+
DIGIVALT_MCP_WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx
|
|
19
|
+
VITE_STAGING_FRONTEND=staging-website
|
|
20
|
+
VITE_ENABLED_POST_TYPES=post,event
|
|
21
|
+
# Cloudflare Access service token, only if WordPress sits behind Access:
|
|
22
|
+
# CF_ACCESS_CLIENT_ID=...
|
|
23
|
+
# CF_ACCESS_CLIENT_SECRET=...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Register the server (Claude Code shown; run from the app repo):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
claude mcp add digivalt -- npx -y @marvalt/digivalt-mcp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Other clients: command `npx`, args `["-y", "@marvalt/digivalt-mcp"]`, working directory the app repo (or pass `--cwd <dir>`).
|
|
33
|
+
|
|
34
|
+
Then ask the agent to call `site_info`.
|
|
35
|
+
|
|
36
|
+
## Tools
|
|
37
|
+
|
|
38
|
+
| Tool | Purpose |
|
|
39
|
+
|------|---------|
|
|
40
|
+
| `site_info` | Connection, user permissions, post types, staging frontend, limits |
|
|
41
|
+
| `list_post_types` | Enabled post types |
|
|
42
|
+
| `list_pages` | List posts of a type, including drafts |
|
|
43
|
+
| `get_page` | Read one post (block markup, status, shadow draft) |
|
|
44
|
+
| `list_blocks` | Blocks the frontend renders, and replacements for those it does not |
|
|
45
|
+
| `list_shortcodes` | Shortcode catalogue with attributes |
|
|
46
|
+
| `validate_page` | Local renderability check plus WordPress integrity check |
|
|
47
|
+
| `create_page` | New draft pinned to the staging frontend, from a block tree or markup |
|
|
48
|
+
| `update_page` | Edit a draft; on a published page the change goes to a shadow draft |
|
|
49
|
+
| `set_seo` | SEO fields on a draft (needs `digivalt-seo`) |
|
|
50
|
+
| `diff_page` | Published page vs its shadow draft |
|
|
51
|
+
| `discard_draft` | Trash a shadow draft (needs `confirm`) |
|
|
52
|
+
| `upload_media` | Upload a local image (alt required, max 12 MB and 3840x2160) |
|
|
53
|
+
| `promote_page` | Publisher only: make a shadow draft the live page (approval required; revision kept) |
|
|
54
|
+
| `publish_page` | Publisher only: publish a never-published draft (approval required) |
|
|
55
|
+
| `rollback_page` | Publisher only: restore the revision saved by the last promote (approval required) |
|
|
56
|
+
| `refresh_static_data` | Developer: run the app's `generate` with drafts overlaid for a local preview (needs wp-pagesync 2.1+, `VITE_FRONTEND_ID` = staging frontend) |
|
|
57
|
+
|
|
58
|
+
Every write is validated locally first; nothing is sent if there are errors. Writes are recorded in `.digivalt-mcp/audit.jsonl` (time, tool, post id, content hash; never content or credentials). Add `.digivalt-mcp` to the app's `.gitignore`.
|
|
59
|
+
|
|
60
|
+
Resources: `digivalt://guide/workflow`, `digivalt://guide/layout`, `digivalt://catalogue/shortcodes`, `digivalt://catalogue/blocks`.
|
|
61
|
+
|
|
62
|
+
## Security
|
|
63
|
+
|
|
64
|
+
- The agent user needs `edit_pages`, `edit_others_pages` and `upload_files`, and must not have `publish_pages` or `edit_published_pages`. WordPress enforces this; the MCP does not rely on trust.
|
|
65
|
+
- Publishing is off unless `DIGIVALT_MCP_PUBLISH_USER` / `DIGIVALT_MCP_PUBLISH_APP_PASSWORD` are set, for a separate WordPress user with publish rights. Keep them out of `.env.local` by default; add them for one session. Even then each publish needs the person's approval. See `docs/SECURITY.md`.
|
|
66
|
+
- Use a dedicated user and application password, not the app's Gravity Forms credentials (those work, with a notice).
|
|
67
|
+
- HTTPS is required except for localhost. Credentials are never logged. stdout carries the protocol; logs go to stderr.
|
|
68
|
+
- Cloudflare Access: set a service token, or run from an allowed network (static IP or WARP).
|
|
69
|
+
|
|
70
|
+
See `docs/README.md` for configuration details.
|
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface AuditEntry {
|
|
2
|
+
tool: string;
|
|
3
|
+
post_id?: number | null;
|
|
4
|
+
post_type?: string;
|
|
5
|
+
outcome: 'ok' | 'error';
|
|
6
|
+
detail?: string;
|
|
7
|
+
/** SHA-256 of the content written, never the content itself. */
|
|
8
|
+
content_sha256?: string;
|
|
9
|
+
/** Publish-type actions: who approved, how, and what was approved. */
|
|
10
|
+
publisher?: string | null;
|
|
11
|
+
approval?: 'elicitation' | 'code';
|
|
12
|
+
plan_sha256?: string;
|
|
13
|
+
revision_id?: number | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function hashContent(content: string): string;
|
|
16
|
+
/** Append-only JSON-lines log of writes. Never contains credentials or page content. */
|
|
17
|
+
export declare class AuditLog {
|
|
18
|
+
private readonly file;
|
|
19
|
+
private readonly user;
|
|
20
|
+
constructor(file: string | null, user: string | null);
|
|
21
|
+
static forDir(dir: string, user: string | null): AuditLog;
|
|
22
|
+
get path(): string | null;
|
|
23
|
+
record(entry: AuditEntry): Promise<void>;
|
|
24
|
+
}
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { appendFile, mkdir } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
export function hashContent(content) {
|
|
5
|
+
return createHash('sha256').update(content).digest('hex');
|
|
6
|
+
}
|
|
7
|
+
/** Append-only JSON-lines log of writes. Never contains credentials or page content. */
|
|
8
|
+
export class AuditLog {
|
|
9
|
+
file;
|
|
10
|
+
user;
|
|
11
|
+
constructor(file, user) {
|
|
12
|
+
this.file = file;
|
|
13
|
+
this.user = user;
|
|
14
|
+
}
|
|
15
|
+
static forDir(dir, user) {
|
|
16
|
+
return new AuditLog(join(dir, '.digivalt-mcp', 'audit.jsonl'), user);
|
|
17
|
+
}
|
|
18
|
+
get path() {
|
|
19
|
+
return this.file;
|
|
20
|
+
}
|
|
21
|
+
async record(entry) {
|
|
22
|
+
if (!this.file)
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
await mkdir(dirname(this.file), { recursive: true });
|
|
26
|
+
await appendFile(this.file, JSON.stringify({ time: new Date().toISOString(), wp_user: this.user, ...entry }) + '\n');
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// An audit failure must not hide the write result, but it must be visible.
|
|
30
|
+
console.error('[digivalt-mcp] audit log write failed:', e instanceof Error ? e.message : e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAiB1C,MAAM,U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markup.
|
|
3
|
+
*
|
|
4
|
+
* Only blocks the DigiValt frontend renders can be produced, so output is valid by construction.
|
|
5
|
+
* Nodes are plain JSON: { type: 'group', className?, children: [...] } and so on (see NODE_DOCS).
|
|
6
|
+
*/
|
|
7
|
+
export declare class SerializeError extends Error {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
constructor(path: string, message: string);
|
|
10
|
+
}
|
|
11
|
+
export type Node = {
|
|
12
|
+
type: string;
|
|
13
|
+
} & Record<string, unknown>;
|
|
14
|
+
export declare const NODE_DOCS = "Node types (each is a JSON object with \"type\"):\n- group { children[], className? } section container (top level)\n- heading { level 1-6, text, className? }\n- paragraph { text, className? } text may use <a href>, <strong>, <em>, <br>, <span>, <code>\n- shortcode { name, attrs? } e.g. {\"type\":\"shortcode\",\"name\":\"gf_embed\",\"attrs\":{\"id\":\"3\"}}\n- image { url, alt, id?, className? } url from upload_media; alt required\n- list { items[] of text, ordered? }\n- columns { columns[] of { children[], width? } } width like \"50%\"\n- buttons { buttons[] of { text, url, className? } }\n- quote { text, cite? }\n- separator {}\n- spacer { height? } e.g. \"40px\"\n- cover { url, alt?, id?, dimRatio?, children[] } hero with background image\n- code { text }\n- html { html } escape hatch, no scripts";
|
|
15
|
+
export declare function serializeBlocks(nodes: unknown): string;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed block tree -> canonical Gutenberg block markup.
|
|
3
|
+
*
|
|
4
|
+
* Only blocks the DigiValt frontend renders can be produced, so output is valid by construction.
|
|
5
|
+
* Nodes are plain JSON: { type: 'group', className?, children: [...] } and so on (see NODE_DOCS).
|
|
6
|
+
*/
|
|
7
|
+
export class SerializeError extends Error {
|
|
8
|
+
path;
|
|
9
|
+
constructor(path, message) {
|
|
10
|
+
super(`blocks[${path}]: ${message}`);
|
|
11
|
+
this.path = path;
|
|
12
|
+
this.name = 'SerializeError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const NODE_DOCS = `Node types (each is a JSON object with "type"):
|
|
16
|
+
- group { children[], className? } section container (top level)
|
|
17
|
+
- heading { level 1-6, text, className? }
|
|
18
|
+
- paragraph { text, className? } text may use <a href>, <strong>, <em>, <br>, <span>, <code>
|
|
19
|
+
- shortcode { name, attrs? } e.g. {"type":"shortcode","name":"gf_embed","attrs":{"id":"3"}}
|
|
20
|
+
- image { url, alt, id?, className? } url from upload_media; alt required
|
|
21
|
+
- list { items[] of text, ordered? }
|
|
22
|
+
- columns { columns[] of { children[], width? } } width like "50%"
|
|
23
|
+
- buttons { buttons[] of { text, url, className? } }
|
|
24
|
+
- quote { text, cite? }
|
|
25
|
+
- separator {}
|
|
26
|
+
- spacer { height? } e.g. "40px"
|
|
27
|
+
- cover { url, alt?, id?, dimRatio?, children[] } hero with background image
|
|
28
|
+
- code { text }
|
|
29
|
+
- html { html } escape hatch, no scripts`;
|
|
30
|
+
const ALLOWED_INLINE = new Set(['a', 'strong', 'em', 'b', 'i', 'br', 'span', 'code', 'sup', 'sub', 'mark']);
|
|
31
|
+
function str(node, key, path, opts = {}) {
|
|
32
|
+
const v = node[key];
|
|
33
|
+
if (v === undefined || v === null) {
|
|
34
|
+
if (opts.required)
|
|
35
|
+
throw new SerializeError(path, `${node.type} needs "${key}".`);
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
if (typeof v !== 'string')
|
|
39
|
+
throw new SerializeError(path, `${node.type}.${key} must be a string.`);
|
|
40
|
+
if (opts.required && !v.trim())
|
|
41
|
+
throw new SerializeError(path, `${node.type}.${key} must not be empty.`);
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
function escAttr(v) {
|
|
45
|
+
return v.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
46
|
+
}
|
|
47
|
+
function escText(v) {
|
|
48
|
+
return v.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
49
|
+
}
|
|
50
|
+
function safeUrl(v, path) {
|
|
51
|
+
if (!/^(https?:\/\/|\/|#|mailto:|tel:)/i.test(v)) {
|
|
52
|
+
throw new SerializeError(path, `URL "${v}" must start with https://, /, #, mailto: or tel:.`);
|
|
53
|
+
}
|
|
54
|
+
return escAttr(v);
|
|
55
|
+
}
|
|
56
|
+
/** Allow a small set of inline tags; everything else is an error rather than silently stripped. */
|
|
57
|
+
function inline(v, path) {
|
|
58
|
+
for (const m of v.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi)) {
|
|
59
|
+
if (!ALLOWED_INLINE.has(m[1].toLowerCase())) {
|
|
60
|
+
throw new SerializeError(path, `<${m[1]}> is not allowed in text. Use block nodes for structure.`);
|
|
61
|
+
}
|
|
62
|
+
if (/\son[a-z]+\s*=|javascript:/i.test(m[0]))
|
|
63
|
+
throw new SerializeError(path, 'Event handlers and javascript: URLs are not allowed.');
|
|
64
|
+
}
|
|
65
|
+
if (/<(?![/a-z])/i.test(v))
|
|
66
|
+
throw new SerializeError(path, 'Stray "<" in text; write < instead.');
|
|
67
|
+
return v;
|
|
68
|
+
}
|
|
69
|
+
function classes(node, path) {
|
|
70
|
+
const c = str(node, 'className', path);
|
|
71
|
+
if (c && !/^[\w\- ]+$/.test(c))
|
|
72
|
+
throw new SerializeError(path, `className "${c}" has invalid characters.`);
|
|
73
|
+
return c.trim();
|
|
74
|
+
}
|
|
75
|
+
function comment(name, attrs, selfClose = false) {
|
|
76
|
+
const json = Object.keys(attrs).length
|
|
77
|
+
? ' ' +
|
|
78
|
+
JSON.stringify(attrs).replace(/--/g, '\\u002d\\u002d').replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
|
|
79
|
+
: '';
|
|
80
|
+
return `<!-- wp:${name}${json}${selfClose ? ' /' : ''} -->`;
|
|
81
|
+
}
|
|
82
|
+
function wrap(name, attrs, html) {
|
|
83
|
+
return `${comment(name, attrs)}${html}<!-- /wp:${name} -->`;
|
|
84
|
+
}
|
|
85
|
+
function withClass(base, extra) {
|
|
86
|
+
return extra ? `${base} ${extra}` : base;
|
|
87
|
+
}
|
|
88
|
+
function children(node, key, path, required = false) {
|
|
89
|
+
const list = node[key];
|
|
90
|
+
if (list === undefined && !required)
|
|
91
|
+
return '';
|
|
92
|
+
if (!Array.isArray(list))
|
|
93
|
+
throw new SerializeError(path, `${node.type}.${key} must be an array.`);
|
|
94
|
+
return list.map((c, i) => serializeNode(c, `${path}.${i}`)).join('');
|
|
95
|
+
}
|
|
96
|
+
function serializeNode(node, path) {
|
|
97
|
+
if (!node || typeof node !== 'object' || typeof node.type !== 'string') {
|
|
98
|
+
throw new SerializeError(path, 'each block needs a "type".');
|
|
99
|
+
}
|
|
100
|
+
const cls = classes(node, path);
|
|
101
|
+
const attrs = (more = {}) => (cls ? { className: cls, ...more } : more);
|
|
102
|
+
switch (node.type) {
|
|
103
|
+
case 'group':
|
|
104
|
+
return wrap('group', attrs(), `<div class="${withClass('wp-block-group', cls)}">${children(node, 'children', path, true)}</div>`);
|
|
105
|
+
case 'heading': {
|
|
106
|
+
const level = Number(node.level ?? 2);
|
|
107
|
+
if (!Number.isInteger(level) || level < 1 || level > 6)
|
|
108
|
+
throw new SerializeError(path, 'heading.level must be 1-6.');
|
|
109
|
+
const text = inline(str(node, 'text', path, { required: true }), path);
|
|
110
|
+
return wrap('heading', attrs({ level }), `<h${level} class="${withClass('wp-block-heading', cls)}">${text}</h${level}>`);
|
|
111
|
+
}
|
|
112
|
+
case 'paragraph': {
|
|
113
|
+
const text = inline(str(node, 'text', path, { required: true }), path);
|
|
114
|
+
return wrap('paragraph', attrs(), `<p${cls ? ` class="${cls}"` : ''}>${text}</p>`);
|
|
115
|
+
}
|
|
116
|
+
case 'shortcode': {
|
|
117
|
+
const name = str(node, 'name', path, { required: true });
|
|
118
|
+
if (!/^[a-z][a-z0-9_-]*$/i.test(name))
|
|
119
|
+
throw new SerializeError(path, `shortcode name "${name}" is invalid.`);
|
|
120
|
+
const given = (node.attrs ?? {});
|
|
121
|
+
if (typeof given !== 'object' || Array.isArray(given))
|
|
122
|
+
throw new SerializeError(path, 'shortcode.attrs must be an object.');
|
|
123
|
+
const parts = Object.entries(given).map(([k, v]) => {
|
|
124
|
+
if (!/^[\w-]+$/.test(k))
|
|
125
|
+
throw new SerializeError(path, `attribute name "${k}" is invalid.`);
|
|
126
|
+
const value = String(v);
|
|
127
|
+
if (/["\]\n]/.test(value))
|
|
128
|
+
throw new SerializeError(path, `attribute ${k} must not contain quotes, "]" or line breaks.`);
|
|
129
|
+
return `${k}="${value}"`;
|
|
130
|
+
});
|
|
131
|
+
return wrap('paragraph', attrs(), `<p${cls ? ` class="${cls}"` : ''}>[${[name, ...parts].join(' ')}]</p>`);
|
|
132
|
+
}
|
|
133
|
+
case 'image': {
|
|
134
|
+
const url = safeUrl(str(node, 'url', path, { required: true }), path);
|
|
135
|
+
const alt = str(node, 'alt', path, { required: true });
|
|
136
|
+
const id = node.id === undefined ? undefined : Number(node.id);
|
|
137
|
+
if (id !== undefined && (!Number.isInteger(id) || id <= 0))
|
|
138
|
+
throw new SerializeError(path, 'image.id must be a positive integer.');
|
|
139
|
+
const imgClass = id ? ` class="wp-image-${id}"` : '';
|
|
140
|
+
return wrap('image', attrs({ ...(id ? { id } : {}), sizeSlug: 'full', linkDestination: 'none' }), `<figure class="${withClass('wp-block-image size-full', cls)}"><img src="${url}" alt="${escAttr(alt)}"${imgClass}/></figure>`);
|
|
141
|
+
}
|
|
142
|
+
case 'list': {
|
|
143
|
+
const items = node.items;
|
|
144
|
+
if (!Array.isArray(items) || items.length === 0)
|
|
145
|
+
throw new SerializeError(path, 'list.items must be a non-empty array of strings.');
|
|
146
|
+
const ordered = node.ordered === true;
|
|
147
|
+
const tag = ordered ? 'ol' : 'ul';
|
|
148
|
+
const lis = items
|
|
149
|
+
.map((t, i) => {
|
|
150
|
+
if (typeof t !== 'string' || !t.trim())
|
|
151
|
+
throw new SerializeError(`${path}.${i}`, 'list item must be a non-empty string.');
|
|
152
|
+
return wrap('list-item', {}, `<li>${inline(t, `${path}.${i}`)}</li>`);
|
|
153
|
+
})
|
|
154
|
+
.join('');
|
|
155
|
+
return wrap('list', attrs(ordered ? { ordered: true } : {}), `<${tag} class="${withClass('wp-block-list', cls)}">${lis}</${tag}>`);
|
|
156
|
+
}
|
|
157
|
+
case 'columns': {
|
|
158
|
+
const cols = node.columns;
|
|
159
|
+
if (!Array.isArray(cols) || cols.length === 0)
|
|
160
|
+
throw new SerializeError(path, 'columns.columns must be a non-empty array.');
|
|
161
|
+
const inner = cols
|
|
162
|
+
.map((c, i) => {
|
|
163
|
+
const col = c;
|
|
164
|
+
const p = `${path}.${i}`;
|
|
165
|
+
const width = str({ ...col, type: 'column' }, 'width', p);
|
|
166
|
+
if (width && !/^\d+(\.\d+)?(%|px)$/.test(width))
|
|
167
|
+
throw new SerializeError(p, 'column.width must look like "50%".');
|
|
168
|
+
return wrap('column', width ? { width } : {}, `<div class="wp-block-column"${width ? ` style="flex-basis:${width}"` : ''}>${children({ ...col, type: 'column' }, 'children', p, true)}</div>`);
|
|
169
|
+
})
|
|
170
|
+
.join('');
|
|
171
|
+
return wrap('columns', attrs(), `<div class="${withClass('wp-block-columns', cls)}">${inner}</div>`);
|
|
172
|
+
}
|
|
173
|
+
case 'buttons': {
|
|
174
|
+
const list = node.buttons;
|
|
175
|
+
if (!Array.isArray(list) || list.length === 0)
|
|
176
|
+
throw new SerializeError(path, 'buttons.buttons must be a non-empty array.');
|
|
177
|
+
const inner = list
|
|
178
|
+
.map((b, i) => {
|
|
179
|
+
const btn = { ...b, type: 'button' };
|
|
180
|
+
const p = `${path}.${i}`;
|
|
181
|
+
const text = inline(str(btn, 'text', p, { required: true }), p);
|
|
182
|
+
const url = safeUrl(str(btn, 'url', p, { required: true }), p);
|
|
183
|
+
const bcls = classes(btn, p);
|
|
184
|
+
return wrap('button', bcls ? { className: bcls } : {}, `<div class="${withClass('wp-block-button', bcls)}"><a class="wp-block-button__link wp-element-button" href="${url}">${text}</a></div>`);
|
|
185
|
+
})
|
|
186
|
+
.join('');
|
|
187
|
+
return wrap('buttons', attrs(), `<div class="${withClass('wp-block-buttons', cls)}">${inner}</div>`);
|
|
188
|
+
}
|
|
189
|
+
case 'quote': {
|
|
190
|
+
const text = inline(str(node, 'text', path, { required: true }), path);
|
|
191
|
+
const cite = str(node, 'cite', path);
|
|
192
|
+
return wrap('quote', attrs(), `<blockquote class="${withClass('wp-block-quote', cls)}">${wrap('paragraph', {}, `<p>${text}</p>`)}${cite ? `<cite>${inline(cite, path)}</cite>` : ''}</blockquote>`);
|
|
193
|
+
}
|
|
194
|
+
case 'separator':
|
|
195
|
+
return wrap('separator', attrs(), `<hr class="${withClass('wp-block-separator has-alpha-channel-opacity', cls)}"/>`);
|
|
196
|
+
case 'spacer': {
|
|
197
|
+
const height = str(node, 'height', path) || '40px';
|
|
198
|
+
if (!/^\d+(\.\d+)?(px|rem|em|vh)$/.test(height))
|
|
199
|
+
throw new SerializeError(path, 'spacer.height must look like "40px".');
|
|
200
|
+
return wrap('spacer', attrs({ height }), `<div style="height:${height}" aria-hidden="true" class="${withClass('wp-block-spacer', cls)}"></div>`);
|
|
201
|
+
}
|
|
202
|
+
case 'cover': {
|
|
203
|
+
const url = safeUrl(str(node, 'url', path, { required: true }), path);
|
|
204
|
+
const alt = str(node, 'alt', path);
|
|
205
|
+
const id = node.id === undefined ? undefined : Number(node.id);
|
|
206
|
+
if (id !== undefined && (!Number.isInteger(id) || id <= 0))
|
|
207
|
+
throw new SerializeError(path, 'cover.id must be a positive integer.');
|
|
208
|
+
const dim = node.dimRatio === undefined ? 50 : Number(node.dimRatio);
|
|
209
|
+
if (!Number.isInteger(dim) || dim < 0 || dim > 100)
|
|
210
|
+
throw new SerializeError(path, 'cover.dimRatio must be 0-100.');
|
|
211
|
+
const img = `<img class="wp-block-cover__image-background${id ? ` wp-image-${id}` : ''}" alt="${escAttr(alt)}" src="${url}" data-object-fit="cover"/>`;
|
|
212
|
+
return wrap('cover', attrs({ url: node.url, ...(id ? { id } : {}), dimRatio: dim }), `<div class="${withClass('wp-block-cover', cls)}"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span>${img}<div class="wp-block-cover__inner-container">${children(node, 'children', path)}</div></div>`);
|
|
213
|
+
}
|
|
214
|
+
case 'code':
|
|
215
|
+
return wrap('code', attrs(), `<pre class="${withClass('wp-block-code', cls)}"><code>${escText(str(node, 'text', path, { required: true }))}</code></pre>`);
|
|
216
|
+
case 'html': {
|
|
217
|
+
const html = str(node, 'html', path, { required: true });
|
|
218
|
+
if (/<script\b/i.test(html))
|
|
219
|
+
throw new SerializeError(path, 'Scripts are not allowed.');
|
|
220
|
+
return wrap('html', {}, html);
|
|
221
|
+
}
|
|
222
|
+
default:
|
|
223
|
+
throw new SerializeError(path, `unknown block type "${node.type}". Allowed: group, heading, paragraph, shortcode, image, list, columns, buttons, quote, separator, spacer, cover, code, html.`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
export function serializeBlocks(nodes) {
|
|
227
|
+
if (!Array.isArray(nodes) || nodes.length === 0)
|
|
228
|
+
throw new SerializeError('', 'blocks must be a non-empty array.');
|
|
229
|
+
return nodes.map((n, i) => serializeNode(n, String(i))).join('\n\n');
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/blocks/serialize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAErB,IAAI;IADtB,YACkB,IAAY,EAC5B,OAAe;QAEf,KAAK,CAAC,UAAU,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;oBAHrB,IAAI;QAIpB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAID,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;kFAcyD,CAAC;AAEnF,MAAM,cAAc,GAAG,IAAI,GAA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gutenberg blocks and whether the DigiValt frontend renders them.
|
|
3
|
+
*
|
|
4
|
+
* Source: @marvalt/wparser createDefaultRegistry (renderers map). Blocks without a renderer fall back to an
|
|
5
|
+
* empty wrapper, so their content is lost on the site. Apps with their own registry can add blocks through
|
|
6
|
+
* DIGIVALT_MCP_EXTRA_BLOCKS.
|
|
7
|
+
*/
|
|
8
|
+
export interface BlockInfo {
|
|
9
|
+
name: string;
|
|
10
|
+
rendered: boolean;
|
|
11
|
+
note: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const BLOCK_CATALOGUE_VERSION = "2026-11-13";
|
|
14
|
+
export declare const BLOCKS: BlockInfo[];
|
|
15
|
+
/** Blocks WordPress offers but the default registry does not render, with the preferred replacement. */
|
|
16
|
+
export declare const UNRENDERED_HINTS: Record<string, string>;
|
|
17
|
+
export declare function renderedBlockNames(extra?: string[]): Set<string>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const BLOCK_CATALOGUE_VERSION = '2026-11-13';
|
|
2
|
+
export const BLOCKS = [
|
|
3
|
+
{ name: 'core/paragraph', rendered: true, note: 'Text. The only block where shortcodes are processed.' },
|
|
4
|
+
{ name: 'core/heading', rendered: true, note: 'One H1 per page; do not skip levels.' },
|
|
5
|
+
{ name: 'core/image', rendered: true, note: 'Use a media library image; alt text required.' },
|
|
6
|
+
{ name: 'core/list', rendered: true, note: 'Wraps core/list-item blocks.' },
|
|
7
|
+
{ name: 'core/list-item', rendered: true, note: '' },
|
|
8
|
+
{ name: 'core/group', rendered: true, note: 'Section container. Build each page as a flat list of top-level groups.' },
|
|
9
|
+
{ name: 'core/columns', rendered: true, note: 'Contains core/column blocks.' },
|
|
10
|
+
{ name: 'core/column', rendered: true, note: '' },
|
|
11
|
+
{ name: 'core/separator', rendered: true, note: '' },
|
|
12
|
+
{ name: 'core/spacer', rendered: true, note: '' },
|
|
13
|
+
{ name: 'core/buttons', rendered: true, note: 'Contains core/button blocks.' },
|
|
14
|
+
{ name: 'core/button', rendered: true, note: '' },
|
|
15
|
+
{ name: 'core/quote', rendered: true, note: '' },
|
|
16
|
+
{ name: 'core/code', rendered: true, note: '' },
|
|
17
|
+
{ name: 'core/preformatted', rendered: true, note: '' },
|
|
18
|
+
{ name: 'core/table', rendered: true, note: '' },
|
|
19
|
+
{ name: 'core/cover', rendered: true, note: 'Background image or colour with inner blocks.' },
|
|
20
|
+
{ name: 'core/media-text', rendered: true, note: 'Media beside text (image or video iframe).' },
|
|
21
|
+
{ name: 'core/html', rendered: true, note: 'Escape hatch for raw HTML (for example a video iframe). No scripts. No shortcodes (they are not processed here).' },
|
|
22
|
+
];
|
|
23
|
+
/** Blocks WordPress offers but the default registry does not render, with the preferred replacement. */
|
|
24
|
+
export const UNRENDERED_HINTS = {
|
|
25
|
+
'core/pullquote': 'Use core/quote.',
|
|
26
|
+
'core/gallery': 'Use core/columns with core/image blocks.',
|
|
27
|
+
'core/video': 'Use core/html with an iframe, or core/media-text.',
|
|
28
|
+
'core/embed': 'Use core/html with an iframe.',
|
|
29
|
+
'core/details': 'Use core/group with a heading and paragraphs.',
|
|
30
|
+
'core/shortcode': 'Put the shortcode in a core/paragraph block instead.',
|
|
31
|
+
'core/freeform': 'Classic blocks are not rendered; use block markup.',
|
|
32
|
+
'core/latest-posts': 'Use the [post_cards] shortcode in a core/paragraph.',
|
|
33
|
+
};
|
|
34
|
+
export function renderedBlockNames(extra = []) {
|
|
35
|
+
return new Set([...BLOCKS.filter((b) => b.rendered).map((b) => b.name), ...extra]);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/catalogue/blocks.ts"],"names":[],"mappings":"AAaA,MA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alt-core GLOBAL-SHORTCODES.md and docs/SHORTCODES.md, madapter and plister SHORTCODES.md,
|
|
5
|
+
* and the WordPress plugins that register PHP shortcodes (which the React frontend does NOT render).
|
|
6
|
+
* These are literal tokens in WordPress content: never register them as PHP shortcodes.
|
|
7
|
+
*/
|
|
8
|
+
export type ShortcodeStatus = 'supported' | 'optional-app' | 'wp-only';
|
|
9
|
+
export interface ShortcodeAttr {
|
|
10
|
+
name: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/** Other attribute names the frontend accepts for the same thing. */
|
|
13
|
+
aliases?: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
/** Allowed values, when the attribute is an enum. */
|
|
16
|
+
values?: string[];
|
|
17
|
+
/** Regular expression the value must match. */
|
|
18
|
+
pattern?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ShortcodeDef {
|
|
21
|
+
name: string;
|
|
22
|
+
/** Package or plugin that provides it. */
|
|
23
|
+
source: string;
|
|
24
|
+
description: string;
|
|
25
|
+
status: ShortcodeStatus;
|
|
26
|
+
/** For aliases: the preferred shortcode name. */
|
|
27
|
+
aliasOf?: string;
|
|
28
|
+
attrs: ShortcodeAttr[];
|
|
29
|
+
example: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const SHORTCODE_CATALOGUE_VERSION = "2026-11-13";
|
|
32
|
+
export declare const SHORTCODES: ShortcodeDef[];
|
|
33
|
+
export declare function getShortcode(name: string): ShortcodeDef | undefined;
|
|
34
|
+
export interface ParsedShortcode {
|
|
35
|
+
name: string;
|
|
36
|
+
attrs: Record<string, string>;
|
|
37
|
+
raw: string;
|
|
38
|
+
}
|
|
39
|
+
/** Decode the few entities WordPress produces inside shortcode attributes. */
|
|
40
|
+
export declare function decodeEntities(text: string): string;
|
|
41
|
+
/** Find [name attr="value"] tokens in text (HTML tags are stripped first). Closing tags are ignored. */
|
|
42
|
+
export declare function findShortcodes(html: string): ParsedShortcode[];
|
|
43
|
+
export interface ShortcodeIssue {
|
|
44
|
+
severity: 'error' | 'warning';
|
|
45
|
+
code: string;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
/** Check one parsed shortcode against the catalogue. */
|
|
49
|
+
export declare function checkShortcode(sc: ParsedShortcode): ShortcodeIssue[];
|