@diviops/mcp-server 1.5.30 → 1.5.32
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/README.md +30 -12
- package/dist/compatibility.d.ts +11 -0
- package/dist/cross-env-preflight/header-preflight.d.ts +7 -0
- package/dist/cross-env-preflight/header-preflight.js +94 -0
- package/dist/cross-env-preflight/source-payload-ref.d.ts +20 -0
- package/dist/cross-env-preflight/source-payload-ref.js +178 -0
- package/dist/index.js +238 -24
- package/dist/preset-cli/cli.d.ts +1 -1
- package/dist/preset-cli/cli.js +12 -3
- package/dist/preset-cli/nav-emitter.d.ts +17 -6
- package/dist/preset-cli/nav-emitter.js +148 -36
- package/dist/wp-cli.d.ts +10 -0
- package/dist/wp-cli.js +110 -4
- package/dist/wp-client.js +5 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -12,9 +12,10 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
12
12
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { WPClient } from "./wp-client.js";
|
|
15
|
-
import { MissingCapabilityError, proToolGatesSatisfied } from "./compatibility.js";
|
|
15
|
+
import { MissingCapabilityError, proToolGatesSatisfied, } from "./compatibility.js";
|
|
16
16
|
import { ErrorCodes, envelopeMap, recordIdempotent, serializeEnvelope, withCode, wrapResponse, } from "./envelope.js";
|
|
17
17
|
import { preflightCrossEnvHeaderSync, } from "./cross-env-preflight/header-preflight.js";
|
|
18
|
+
import { createSourcePayloadRef, loadSourcePayloadRef, } from "./cross-env-preflight/source-payload-ref.js";
|
|
18
19
|
import { optimizeSchema } from "./schema-optimizer.js";
|
|
19
20
|
import { schemaModuleRoute } from "./schema-route.js";
|
|
20
21
|
import { createWpCli } from "./wp-cli.js";
|
|
@@ -87,6 +88,62 @@ const server = new McpServer({
|
|
|
87
88
|
version: SERVER_VERSION,
|
|
88
89
|
});
|
|
89
90
|
let handshakeState = { kind: "pending" };
|
|
91
|
+
const toolCatalog = [];
|
|
92
|
+
function recordToolCatalog(entry) {
|
|
93
|
+
const existing = toolCatalog.find((item) => item.name === entry.name && item.kind === entry.kind);
|
|
94
|
+
if (existing) {
|
|
95
|
+
Object.assign(existing, entry);
|
|
96
|
+
return existing;
|
|
97
|
+
}
|
|
98
|
+
toolCatalog.push(entry);
|
|
99
|
+
return entry;
|
|
100
|
+
}
|
|
101
|
+
function countTools(predicate) {
|
|
102
|
+
return toolCatalog.filter(predicate).length;
|
|
103
|
+
}
|
|
104
|
+
function registeredToolNamesFor(kind) {
|
|
105
|
+
return toolCatalog
|
|
106
|
+
.filter((entry) => entry.registered)
|
|
107
|
+
.filter((entry) => (kind ? entry.kind === kind : true))
|
|
108
|
+
.map((entry) => entry.name)
|
|
109
|
+
.sort();
|
|
110
|
+
}
|
|
111
|
+
function proTargetSummary(target) {
|
|
112
|
+
const possible = toolCatalog
|
|
113
|
+
.filter((entry) => entry.kind === "pro" && entry.target === target)
|
|
114
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
115
|
+
const registered = possible.filter((entry) => entry.registered);
|
|
116
|
+
return {
|
|
117
|
+
registered_tool_count: registered.length,
|
|
118
|
+
possible_tool_count: possible.length,
|
|
119
|
+
registered_tool_names: registered.map((entry) => entry.name),
|
|
120
|
+
capability_keys: registered
|
|
121
|
+
.map((entry) => entry.capability_key)
|
|
122
|
+
.filter((key) => typeof key === "string")
|
|
123
|
+
.sort(),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function buildToolCatalogSummary() {
|
|
127
|
+
const registeredTotal = countTools((entry) => entry.registered);
|
|
128
|
+
const registeredLocal = countTools((entry) => entry.registered && entry.kind === "server_local");
|
|
129
|
+
const registeredPlugin = countTools((entry) => entry.registered && entry.kind === "plugin");
|
|
130
|
+
const registeredPro = countTools((entry) => entry.registered && entry.kind === "pro");
|
|
131
|
+
const proTargets = Array.from(new Set(toolCatalog
|
|
132
|
+
.filter((entry) => entry.kind === "pro" && entry.target)
|
|
133
|
+
.map((entry) => entry.target))).sort();
|
|
134
|
+
return {
|
|
135
|
+
registered_total: registeredTotal,
|
|
136
|
+
possible_total: toolCatalog.length,
|
|
137
|
+
by_kind: {
|
|
138
|
+
server_local: registeredLocal,
|
|
139
|
+
plugin: registeredPlugin,
|
|
140
|
+
pro: registeredPro,
|
|
141
|
+
},
|
|
142
|
+
always_on_registered: registeredLocal + registeredPlugin,
|
|
143
|
+
registered_tool_names: registeredToolNamesFor(),
|
|
144
|
+
pro: Object.fromEntries(proTargets.map((target) => [target, proTargetSummary(target)])),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
90
147
|
const BASE_META_CAPABILITIES = [
|
|
91
148
|
"pages",
|
|
92
149
|
"modules",
|
|
@@ -109,6 +166,36 @@ function enabledCapabilityKeys(prefix) {
|
|
|
109
166
|
.filter((key) => (prefix ? key.startsWith(prefix) : true))
|
|
110
167
|
.sort();
|
|
111
168
|
}
|
|
169
|
+
function buildPluginVersionSummary() {
|
|
170
|
+
if (handshakeState.kind !== "ok") {
|
|
171
|
+
return {
|
|
172
|
+
diviops_agent: { active: false, version: null },
|
|
173
|
+
diviops_agent_pro: { active: false, version: null },
|
|
174
|
+
fluent_cart: { active: false, version: null },
|
|
175
|
+
fluent_cart_pro: { active: false, version: null },
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const plugins = handshakeState.plugins;
|
|
179
|
+
const fluentCartTarget = handshakeState.availableTargets.fluentcart;
|
|
180
|
+
return {
|
|
181
|
+
diviops_agent: {
|
|
182
|
+
active: true,
|
|
183
|
+
version: handshakeState.pluginVersion,
|
|
184
|
+
},
|
|
185
|
+
diviops_agent_pro: plugins.diviops_agent_pro ?? {
|
|
186
|
+
active: handshakeState.proActive,
|
|
187
|
+
version: handshakeState.proVersion ?? null,
|
|
188
|
+
},
|
|
189
|
+
fluent_cart: plugins.fluent_cart ?? {
|
|
190
|
+
active: fluentCartTarget?.present === true,
|
|
191
|
+
version: fluentCartTarget?.version ?? null,
|
|
192
|
+
},
|
|
193
|
+
fluent_cart_pro: plugins.fluent_cart_pro ?? {
|
|
194
|
+
active: false,
|
|
195
|
+
version: null,
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
112
199
|
function buildMetaInfo() {
|
|
113
200
|
const fluentCartCapabilityKeys = enabledCapabilityKeys("fluentcart_");
|
|
114
201
|
const crossEnvCapabilityKeys = enabledCapabilityKeys("cross_env_");
|
|
@@ -133,12 +220,17 @@ function buildMetaInfo() {
|
|
|
133
220
|
: [...BASE_META_CAPABILITIES];
|
|
134
221
|
if (crossEnvActive)
|
|
135
222
|
capabilities.push("cross_env");
|
|
223
|
+
const tools = buildToolCatalogSummary();
|
|
136
224
|
return {
|
|
137
225
|
brand: "DiviOps",
|
|
138
226
|
server: "diviops-mcp",
|
|
227
|
+
server_version: SERVER_VERSION,
|
|
139
228
|
version: SERVER_VERSION,
|
|
140
229
|
license: "MIT",
|
|
141
230
|
capabilities,
|
|
231
|
+
tool_count: tools.registered_total,
|
|
232
|
+
tools,
|
|
233
|
+
plugins: buildPluginVersionSummary(),
|
|
142
234
|
handshake: handshakeState.kind === "ok"
|
|
143
235
|
? {
|
|
144
236
|
state: "ok",
|
|
@@ -198,6 +290,12 @@ function requireCapability(key) {
|
|
|
198
290
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
199
291
|
function registerPluginTool(name, config, handler) {
|
|
200
292
|
const key = name.replace(/^diviops_/, "");
|
|
293
|
+
recordToolCatalog({
|
|
294
|
+
name,
|
|
295
|
+
kind: "plugin",
|
|
296
|
+
registered: true,
|
|
297
|
+
capability_key: key,
|
|
298
|
+
});
|
|
201
299
|
const wrapped = (async (args) => {
|
|
202
300
|
try {
|
|
203
301
|
requireCapability(key);
|
|
@@ -224,6 +322,7 @@ function registerPluginTool(name, config, handler) {
|
|
|
224
322
|
* can emit it on per-call responses (#597).
|
|
225
323
|
*/
|
|
226
324
|
function registerLocalTool(name, config, handler) {
|
|
325
|
+
recordToolCatalog({ name, kind: "server_local", registered: true });
|
|
227
326
|
recordIdempotent(name, config?._meta);
|
|
228
327
|
server.registerTool(name, config, handler);
|
|
229
328
|
}
|
|
@@ -265,10 +364,18 @@ function registerLocalTool(name, config, handler) {
|
|
|
265
364
|
* the resolved handshakeState.
|
|
266
365
|
*/
|
|
267
366
|
function registerProTool(name, config, handler, gates) {
|
|
367
|
+
const catalogEntry = recordToolCatalog({
|
|
368
|
+
name,
|
|
369
|
+
kind: "pro",
|
|
370
|
+
registered: false,
|
|
371
|
+
target: gates.target,
|
|
372
|
+
capability_key: gates.capabilityKey,
|
|
373
|
+
});
|
|
268
374
|
if (handshakeState.kind !== "ok")
|
|
269
375
|
return;
|
|
270
376
|
if (!proToolGatesSatisfied(handshakeState, gates))
|
|
271
377
|
return;
|
|
378
|
+
catalogEntry.registered = true;
|
|
272
379
|
recordIdempotent(name, config?._meta);
|
|
273
380
|
server.registerTool(name, config, handler);
|
|
274
381
|
}
|
|
@@ -1942,7 +2049,7 @@ registerPluginTool("diviops_cross_env_target_context_get", {
|
|
|
1942
2049
|
};
|
|
1943
2050
|
});
|
|
1944
2051
|
registerPluginTool("diviops_cross_env_source_export_get", {
|
|
1945
|
-
description: "Export read-only, secret-free source-site payload for the offline cross-environment Theme Builder header preflight. Produces JSON suitable for `diviops-cross-env-preflight --source`: source origin, `tb_header_layout` metadata, sanitized markup, bare sha256 checksum of that exported markup, export timestamp, DiviOps plugin version, and best-effort attachment inventory from markup media URLs and attachment IDs. This Free/core tool does not write layouts, upload media, create global colors, reconcile references, expose cookies, nonces, app passwords, signed URLs, query strings, fragments, admin URLs, or local filesystem paths. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; unsupported source_kind returns invalid_input, and missing/non-header source layouts return not_found.",
|
|
2052
|
+
description: "Export read-only, secret-free source-site payload for the offline cross-environment Theme Builder header preflight. Produces JSON suitable for `diviops-cross-env-preflight --source`: source origin, `tb_header_layout` metadata, sanitized markup, bare sha256 checksum of that exported markup, export timestamp, DiviOps plugin version, and best-effort attachment inventory from markup media URLs and attachment IDs. The MCP server also writes the exported payload to a bounded local artifact under `.diviops-tmp/cross-env-source-payloads/` and returns `source_payload_ref` so large real headers can be applied later without inlining full markup through the model. This Free/core tool does not write WordPress layouts, upload media, create global colors, reconcile references, expose cookies, nonces, app passwords, signed URLs, query strings, fragments, admin URLs, or arbitrary local filesystem paths. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; unsupported source_kind returns invalid_input, and missing/non-header source layouts return not_found.",
|
|
1946
2053
|
inputSchema: {
|
|
1947
2054
|
source_id: z
|
|
1948
2055
|
.number()
|
|
@@ -1963,19 +2070,32 @@ registerPluginTool("diviops_cross_env_source_export_get", {
|
|
|
1963
2070
|
annotations: { idempotentHint: true },
|
|
1964
2071
|
_meta: { idempotent: "true" },
|
|
1965
2072
|
}, async ({ source_id, source_kind }) => {
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2073
|
+
const withRef = await wrapResponse(async () => {
|
|
2074
|
+
const body = {
|
|
2075
|
+
source_id,
|
|
2076
|
+
source_kind: source_kind ?? "tb_header_layout",
|
|
2077
|
+
};
|
|
2078
|
+
const result = await wp.requestEnveloped("/cross-env/source-export", {
|
|
2079
|
+
method: "POST",
|
|
2080
|
+
body,
|
|
2081
|
+
});
|
|
2082
|
+
return envelopeMap(result, (data) => ({
|
|
2083
|
+
...data,
|
|
2084
|
+
source_payload_ref: createSourcePayloadRef(data),
|
|
2085
|
+
_meta: {
|
|
2086
|
+
...(typeof data._meta === "object" &&
|
|
2087
|
+
data._meta !== null
|
|
2088
|
+
? (data._meta ?? {})
|
|
2089
|
+
: {}),
|
|
2090
|
+
source_payload_ref: "server-local artifact handle for diviops_cross_env_header_apply; stores the same source payload under .diviops-tmp/cross-env-source-payloads and is bounded by handle + checksum + TTL",
|
|
2091
|
+
},
|
|
2092
|
+
}));
|
|
1973
2093
|
});
|
|
1974
2094
|
return {
|
|
1975
2095
|
content: [
|
|
1976
2096
|
{
|
|
1977
2097
|
type: "text",
|
|
1978
|
-
text: serializeEnvelope(
|
|
2098
|
+
text: serializeEnvelope(withRef, "diviops_cross_env_source_export_get"),
|
|
1979
2099
|
},
|
|
1980
2100
|
],
|
|
1981
2101
|
};
|
|
@@ -2197,6 +2317,60 @@ registerPluginTool("diviops_canvas_list", {
|
|
|
2197
2317
|
],
|
|
2198
2318
|
};
|
|
2199
2319
|
});
|
|
2320
|
+
registerPluginTool("diviops_canvas_orphan_audit", {
|
|
2321
|
+
description: "Read-only audit of et_pb_canvas posts and off-canvas reference evidence. Returns canvases[], references[], unknowns[], and summary with verdicts referenced, likely_orphan, or unknown. Ambiguous, malformed, cache-only, or weak evidence returns unknown rather than likely_orphan. No delete, cleanup, remap, cache mutation, or cross-environment apply path is performed. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
2322
|
+
inputSchema: {
|
|
2323
|
+
parent_page_id: z
|
|
2324
|
+
.number()
|
|
2325
|
+
.int()
|
|
2326
|
+
.positive()
|
|
2327
|
+
.optional()
|
|
2328
|
+
.describe("Optional parent page/layout post ID filter"),
|
|
2329
|
+
include_global: z
|
|
2330
|
+
.boolean()
|
|
2331
|
+
.optional()
|
|
2332
|
+
.default(true)
|
|
2333
|
+
.describe("Include canvases without parent/context evidence (default true)"),
|
|
2334
|
+
include_context: z
|
|
2335
|
+
.boolean()
|
|
2336
|
+
.optional()
|
|
2337
|
+
.default(true)
|
|
2338
|
+
.describe("Use _divi_canvas_parent_context as reference evidence when present"),
|
|
2339
|
+
status: z
|
|
2340
|
+
.enum(["any", "publish", "draft", "pending", "private", "future", "trash"])
|
|
2341
|
+
.optional()
|
|
2342
|
+
.default("any")
|
|
2343
|
+
.describe("Canvas post_status filter"),
|
|
2344
|
+
per_page: z
|
|
2345
|
+
.number()
|
|
2346
|
+
.int()
|
|
2347
|
+
.min(1)
|
|
2348
|
+
.max(100)
|
|
2349
|
+
.optional()
|
|
2350
|
+
.default(100)
|
|
2351
|
+
.describe("Max canvas posts to audit (default 100, 1-100)"),
|
|
2352
|
+
},
|
|
2353
|
+
annotations: { idempotentHint: true },
|
|
2354
|
+
_meta: { idempotent: "true" },
|
|
2355
|
+
}, async ({ parent_page_id, include_global, include_context, status, per_page }) => {
|
|
2356
|
+
const params = {};
|
|
2357
|
+
if (parent_page_id)
|
|
2358
|
+
params.parent_page_id = String(parent_page_id);
|
|
2359
|
+
if (include_global !== undefined)
|
|
2360
|
+
params.include_global = String(include_global);
|
|
2361
|
+
if (include_context !== undefined)
|
|
2362
|
+
params.include_context = String(include_context);
|
|
2363
|
+
if (status)
|
|
2364
|
+
params.status = status;
|
|
2365
|
+
if (per_page)
|
|
2366
|
+
params.per_page = String(per_page);
|
|
2367
|
+
const result = await wp.requestEnveloped("/canvas/orphan-audit", { params });
|
|
2368
|
+
return {
|
|
2369
|
+
content: [
|
|
2370
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_canvas_orphan_audit") },
|
|
2371
|
+
],
|
|
2372
|
+
};
|
|
2373
|
+
});
|
|
2200
2374
|
registerPluginTool("diviops_canvas_get", {
|
|
2201
2375
|
description: "Get a canvas's block content and metadata. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing canvas_post_id returns ok:false with code 'not_found' and a hint pointing to diviops_canvas_list.",
|
|
2202
2376
|
inputSchema: {
|
|
@@ -2783,7 +2957,7 @@ registerLocalTool("diviops_meta_ping", {
|
|
|
2783
2957
|
};
|
|
2784
2958
|
});
|
|
2785
2959
|
registerLocalTool("diviops_meta_info", {
|
|
2786
|
-
description: "Returns DiviOps MCP server identity,
|
|
2960
|
+
description: "Returns DiviOps MCP server identity, server_version, license type, numeric tool_count, registered tool catalog summary, active plugin version summary, WP-CLI allowlist, and plugin handshake/slice state including Pro and FluentCart target readiness. Use as the S0 preflight before dogfooding or product work. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
2787
2961
|
annotations: { idempotentHint: true },
|
|
2788
2962
|
_meta: { idempotent: "true" },
|
|
2789
2963
|
}, async () => {
|
|
@@ -3288,7 +3462,7 @@ registerPluginTool("diviops_variable_used_on_page", {
|
|
|
3288
3462
|
};
|
|
3289
3463
|
});
|
|
3290
3464
|
registerPluginTool("diviops_meta_flush_cache", {
|
|
3291
|
-
description: "Flush Divi's compiled static CSS cache under wp-content/et-cache/. wp cache flush does NOT touch these files — the frontend can keep serving stale CSS after a preset/variable/module mutation until the cache is cleared. Delegates to Divi's native ET_Core_PageResource::remove_static_resources when available (response backend: \"divi_native\"), which additionally clears Theme Builder CSS scattered across other post dirs, archive/taxonomy/home/notfound CSS, the object cache, module features cache, post features cache, Google Fonts cache, dynamic assets cache, and post meta caches. Falls back to a targeted filesystem walk of numeric-named et-cache subdirs when the Divi class is absent (backend: \"fs_fallback\"). Provide exactly one selector — no site-wide default to prevent accidental full flush. Optional cleanup_dynamic_assets=true explicitly deletes and reports _divi_dynamic_assets_cached_feature_used postmeta for the selected target IDs; cleanup_canvas_refs=true also deletes _divi_dynamic_assets_canvases_used and is only appropriate when canvas/off-canvas references are affected. Dynamic-assets postmeta cleanup is supported with post_id or all (bounded to posts that already carry the selected meta keys), not after. Idempotent: missing cache root returns 200 with empty list and repeat postmeta cleanup reports absent keys. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; namespace-specific error codes: meta_flush_cache.unwritable (filesystem refused), meta_flush_cache.fs_init_failed (WP_Filesystem could not authenticate)." +
|
|
3465
|
+
description: "Flush Divi's compiled static CSS cache under wp-content/et-cache/. wp cache flush does NOT touch these files — the frontend can keep serving stale CSS after a preset/variable/module mutation until the cache is cleared. Delegates to Divi's native ET_Core_PageResource::remove_static_resources when available (response backend: \"divi_native\"), which additionally clears Theme Builder CSS scattered across other post dirs, archive/taxonomy/home/notfound CSS, the object cache, module features cache, post features cache, Google Fonts cache, dynamic assets cache, and post meta caches. In post_id native mode, DiviOps also performs a targeted WP_Filesystem sweep of wp-content/et-cache/{post_id}/ and reports post_dir_sweep evidence because Divi's native invalidation can leave that directory on disk. Falls back to a targeted filesystem walk of numeric-named et-cache subdirs when the Divi class is absent (backend: \"fs_fallback\"). Provide exactly one selector — no site-wide default to prevent accidental full flush. Optional cleanup_dynamic_assets=true explicitly deletes and reports _divi_dynamic_assets_cached_feature_used postmeta for the selected target IDs; cleanup_canvas_refs=true also deletes _divi_dynamic_assets_canvases_used and is only appropriate when canvas/off-canvas references are affected. Dynamic-assets postmeta cleanup is supported with post_id or all (bounded to posts that already carry the selected meta keys), not after. Idempotent: missing cache root returns 200 with empty list and repeat postmeta cleanup reports absent keys. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; namespace-specific error codes: meta_flush_cache.unwritable (filesystem refused), meta_flush_cache.fs_init_failed (WP_Filesystem could not authenticate)." +
|
|
3292
3466
|
DRY_RUN_DESC_SUFFIX +
|
|
3293
3467
|
" Note: in `after` mode the dry-run plan reports the cutoff only — accurate file count requires the live mtime walk.",
|
|
3294
3468
|
inputSchema: {
|
|
@@ -3297,7 +3471,7 @@ registerPluginTool("diviops_meta_flush_cache", {
|
|
|
3297
3471
|
.int()
|
|
3298
3472
|
.positive()
|
|
3299
3473
|
.optional()
|
|
3300
|
-
.describe("Flush cache for one post. Native backend
|
|
3474
|
+
.describe("Flush cache for one post. Native backend clears matching Theme Builder CSS in other post dirs and then physically sweeps wp-content/et-cache/{post_id}/; fs_fallback only clears wp-content/et-cache/{post_id}/."),
|
|
3301
3475
|
all: z
|
|
3302
3476
|
.boolean()
|
|
3303
3477
|
.optional()
|
|
@@ -3380,6 +3554,25 @@ const CrossEnvSourcePayloadSchema = z
|
|
|
3380
3554
|
.regex(/^(sha256:)?[a-fA-F0-9]{64}$/)
|
|
3381
3555
|
.describe("sha256 checksum of source_payload.markup from source export."),
|
|
3382
3556
|
attachments: z.array(CrossEnvSourceAttachmentSchema).optional(),
|
|
3557
|
+
module_preset_ids: z
|
|
3558
|
+
.array(z.string())
|
|
3559
|
+
.optional()
|
|
3560
|
+
.describe("Referenced attrs.modulePreset IDs from source export; definitions are not included."),
|
|
3561
|
+
})
|
|
3562
|
+
.passthrough();
|
|
3563
|
+
const CrossEnvSourcePayloadRefSchema = z
|
|
3564
|
+
.object({
|
|
3565
|
+
handle: z
|
|
3566
|
+
.string()
|
|
3567
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)
|
|
3568
|
+
.describe("Server-created source payload artifact handle returned by diviops_cross_env_source_export_get."),
|
|
3569
|
+
checksum: z
|
|
3570
|
+
.string()
|
|
3571
|
+
.regex(/^(sha256:)?[a-fA-F0-9]{64}$/)
|
|
3572
|
+
.describe("sha256 checksum of the referenced source payload markup."),
|
|
3573
|
+
algorithm: z.literal("sha256").optional(),
|
|
3574
|
+
storage: z.literal("server_local_artifact").optional(),
|
|
3575
|
+
expires_at: z.string().optional(),
|
|
3383
3576
|
})
|
|
3384
3577
|
.passthrough();
|
|
3385
3578
|
function normalizeReviewedFingerprint(value) {
|
|
@@ -3405,9 +3598,10 @@ function sourceHintsFromPayload(source) {
|
|
|
3405
3598
|
function registerProTools() {
|
|
3406
3599
|
// diviops_cross_env_header_apply — guarded Pro apply for reviewed header preflight
|
|
3407
3600
|
registerProTool("diviops_cross_env_header_apply", {
|
|
3408
|
-
description: "Apply a reviewed cross-environment Theme Builder header payload into an existing target header layout (Pro tier; requires the cross_env Pro module). This first MVP is intentionally narrow: it requires `confirm_apply: true`,
|
|
3601
|
+
description: "Apply a reviewed cross-environment Theme Builder header payload into an existing target header layout (Pro tier; requires the cross_env Pro module). This first MVP is intentionally narrow: it requires `confirm_apply: true`, either an inline source export payload or a bounded `source_payload_ref` returned by diviops_cross_env_source_export_get, an existing target `destination_id`, and the reviewed `confirmation_binding.fingerprint` from `diviops-cross-env-preflight`. Large real headers should use `source_payload_ref`; inline `source_payload` remains supported for small/disposable tests. The server loads referenced payload bytes from its own `.diviops-tmp/cross-env-source-payloads/` artifact store, verifies checksum, re-exports current target context, reruns the TypeScript preflight engine, refuses fingerprint mismatch, unsafe verdicts, destination checksum drift, missing/ambiguous attachment remaps, missing global-color value evidence, missing target module preset definitions, and off-canvas/canvas references, then calls the Pro route with the verified plan. The Pro route re-loads the destination post, verifies the current checksum again, builds content only from source-origin upload URL rewrites and proven attachment-ID remaps, writes with readback/rollback evidence, and runs Divi static-resource cleanup plus explicit _divi_dynamic_assets_cached_feature_used cleanup. No media upload/import, global-color creation/import, preset import/clone, new layout creation, off-canvas reconcile, public/store/license change, or live-site smoke is performed by this tool. Returns the standardized envelope { ok, data?, error: { code, message, hint?, data? } }. Error codes include cross_env.confirmation_required, cross_env.source_payload_ref_invalid, cross_env.fingerprint_mismatch, cross_env.preflight_not_safe, cross_env.destination_checksum_drift, cross_env.source_checksum_mismatch, cross_env.content_write_corruption, invalid_input, not_found, forbidden, and wp_error.",
|
|
3409
3602
|
inputSchema: {
|
|
3410
|
-
source_payload: CrossEnvSourcePayloadSchema.describe("The `data` object returned by diviops_cross_env_source_export_get on the source site."),
|
|
3603
|
+
source_payload: CrossEnvSourcePayloadSchema.optional().describe("The `data` object returned by diviops_cross_env_source_export_get on the source site. Use source_payload_ref instead for large real headers."),
|
|
3604
|
+
source_payload_ref: CrossEnvSourcePayloadRefSchema.optional().describe("Bounded server-local artifact reference returned as data.source_payload_ref by diviops_cross_env_source_export_get. Preferred for large real headers because it avoids inlining full markup through the model."),
|
|
3411
3605
|
destination_id: z
|
|
3412
3606
|
.number()
|
|
3413
3607
|
.int()
|
|
@@ -3428,21 +3622,39 @@ function registerProTools() {
|
|
|
3428
3622
|
},
|
|
3429
3623
|
annotations: { idempotentHint: false },
|
|
3430
3624
|
_meta: { idempotent: "conditional" },
|
|
3431
|
-
}, async ({ source_payload, destination_id, destination_kind, reviewed_fingerprint, confirm_apply, }) => {
|
|
3625
|
+
}, async ({ source_payload, source_payload_ref, destination_id, destination_kind, reviewed_fingerprint, confirm_apply, }) => {
|
|
3432
3626
|
const result = await wrapResponse(async () => {
|
|
3433
3627
|
if (confirm_apply !== true) {
|
|
3434
3628
|
withCode("cross_env.confirmation_required", "confirm_apply: true is required before a cross-env header apply can mutate content.", "Review the preflight report, then retry with confirm_apply: true.");
|
|
3435
3629
|
}
|
|
3630
|
+
if (source_payload && source_payload_ref) {
|
|
3631
|
+
withCode("invalid_input", "Provide either source_payload or source_payload_ref, not both.", "Use source_payload_ref for large real headers and inline source_payload only for small/disposable tests.", { fields: ["source_payload", "source_payload_ref"] });
|
|
3632
|
+
}
|
|
3633
|
+
if (!source_payload && !source_payload_ref) {
|
|
3634
|
+
withCode("invalid_input", "Either source_payload or source_payload_ref is required.", "Run diviops_cross_env_source_export_get and pass its data.source_payload_ref for large real headers.", { fields: ["source_payload", "source_payload_ref"] });
|
|
3635
|
+
}
|
|
3636
|
+
let resolvedSourcePayload;
|
|
3637
|
+
if (source_payload) {
|
|
3638
|
+
resolvedSourcePayload = source_payload;
|
|
3639
|
+
}
|
|
3640
|
+
else {
|
|
3641
|
+
try {
|
|
3642
|
+
resolvedSourcePayload = loadSourcePayloadRef(source_payload_ref);
|
|
3643
|
+
}
|
|
3644
|
+
catch (err) {
|
|
3645
|
+
withCode("cross_env.source_payload_ref_invalid", err instanceof Error ? err.message : String(err), "Re-run diviops_cross_env_source_export_get and pass the fresh data.source_payload_ref.", { source_payload_ref });
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3436
3648
|
const targetBody = {
|
|
3437
3649
|
destination_id,
|
|
3438
3650
|
destination_kind: destination_kind ?? "tb_header_layout",
|
|
3439
|
-
...sourceHintsFromPayload(
|
|
3651
|
+
...sourceHintsFromPayload(resolvedSourcePayload),
|
|
3440
3652
|
};
|
|
3441
3653
|
const targetEnvelope = await wp.requestEnveloped("/cross-env/target-context", { method: "POST", body: targetBody });
|
|
3442
3654
|
if (!targetEnvelope.ok)
|
|
3443
3655
|
return targetEnvelope;
|
|
3444
3656
|
const report = preflightCrossEnvHeaderSync({
|
|
3445
|
-
source:
|
|
3657
|
+
source: resolvedSourcePayload,
|
|
3446
3658
|
target: targetEnvelope.data,
|
|
3447
3659
|
});
|
|
3448
3660
|
const reviewed = normalizeReviewedFingerprint(reviewed_fingerprint);
|
|
@@ -3466,8 +3678,8 @@ function registerProTools() {
|
|
|
3466
3678
|
confirm_apply: true,
|
|
3467
3679
|
destination_id,
|
|
3468
3680
|
destination_kind: destination_kind ?? "tb_header_layout",
|
|
3469
|
-
source_payload,
|
|
3470
|
-
source_checksum:
|
|
3681
|
+
source_payload: resolvedSourcePayload,
|
|
3682
|
+
source_checksum: resolvedSourcePayload.checksum,
|
|
3471
3683
|
destination_checksum: report.target.destination_checksum,
|
|
3472
3684
|
reviewed_fingerprint: reviewed,
|
|
3473
3685
|
preflight_report: report,
|
|
@@ -4019,9 +4231,10 @@ function registerProTools() {
|
|
|
4019
4231
|
//
|
|
4020
4232
|
// Store-deployment helper surface. This intentionally complements
|
|
4021
4233
|
// FluentCart's native MCP by focusing on DiviOps-specific launch
|
|
4022
|
-
// readiness: metadata-only download rows,
|
|
4023
|
-
// server-side ZIP,
|
|
4024
|
-
//
|
|
4234
|
+
// readiness: metadata-only download rows, validating an already-present
|
|
4235
|
+
// server-side ZIP, copying it into FluentCart-managed download storage,
|
|
4236
|
+
// and the FCP Pro updater changelog field. No MCP-client binary upload and
|
|
4237
|
+
// no signed buyer URLs.
|
|
4025
4238
|
// diviops_fc_download_list — POST /diviops/v1/pro/fluentcart/products/{id}/downloads
|
|
4026
4239
|
registerProTool("diviops_fc_download_list", {
|
|
4027
4240
|
description: "List FluentCart downloadable-file rows for a product (Pro tier; V3.4; requires FluentCart Pro installed + activated). Read-only metadata surface for store artifact deployment. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { product_id, downloads: DownloadRow[] }. DownloadRow is { id, title, file_name, driver, file_size, type, variation_ids, is_update_file } — metadata only, never file_path, file_url, download_identifier, signed URLs, or buyer URLs. `is_update_file` is derived from the product's license_settings.global_update_file pointer when present. Use this before `diviops_fc_license_settings_update` so the updater pointer can be set to the plugin ZIP row, not the suite ZIP row. Error codes: invalid_input (400), not_found (404), fluentcart.module_inactive (412), fluentcart.query_failed (500). Idempotency: read-only.",
|
|
@@ -4047,7 +4260,7 @@ function registerProTools() {
|
|
|
4047
4260
|
}, { target: "fluentcart", capabilityKey: "fluentcart_download_list" });
|
|
4048
4261
|
// diviops_fc_download_attach — POST /diviops/v1/pro/fluentcart/products/{id}/downloads/attach
|
|
4049
4262
|
registerProTool("diviops_fc_download_attach", {
|
|
4050
|
-
description: "Attach an already-present server-side ZIP as a FluentCart downloadable-file row (Pro tier; V3.4; requires FluentCart Pro installed + activated). This is NOT a binary upload tool: `file_path` must resolve to a readable .zip on the WordPress server under ABSPATH or the uploads directory. The response never exposes file paths, file URLs, download identifiers, signed URLs, or buyer URLs. Required: product_id, file_path. Optional: file_name (defaults to basename(file_path), must end in .zip), title (defaults to filename without .zip), variation_ids (must belong to this product; empty means all variants), expected_sha1, expected_size, allow_duplicate (default false), dry_run. Duplicate detection rejects an existing row with the same file_name or title unless allow_duplicate:true is passed. Expected hash/size let operators verify the server-side file matches the locally built artifact before creating the row. Apply-mode success payload is { product_id, created: DownloadRow, downloads: DownloadRow[] } with DownloadRow metadata only. This tool only creates the download row and enables manage_downloadable; it does NOT set license_settings.global_update_file — follow with diviops_fc_license_settings_update using the created row ID. Error codes: invalid_input (400), not_found (404), fluentcart.download_duplicate (409), fluentcart.module_inactive (412), fluentcart.command_failed (500). Idempotency: false; repeat calls are rejected by duplicate detection unless allow_duplicate:true." +
|
|
4263
|
+
description: "Attach an already-present server-side ZIP as a FluentCart downloadable-file row (Pro tier; V3.4; requires FluentCart Pro installed + activated). This is NOT a binary upload tool: `file_path` must resolve to a readable .zip on the WordPress server under ABSPATH or the uploads directory. Apply mode copies the validated file into FluentCart's managed `wp-content/uploads/fluent-cart/*__fluent-cart__*.zip` storage before creating the row, because FluentCart's signed package endpoint serves that managed filename shape. The response never exposes file paths, file URLs, download identifiers, signed URLs, or buyer URLs. Required: product_id, file_path. Optional: file_name (defaults to basename(file_path), must end in .zip), title (defaults to filename without .zip), variation_ids (must belong to this product; empty means all variants), expected_sha1, expected_size, allow_duplicate (default false), dry_run. Duplicate detection rejects an existing row with the same file_name or title unless allow_duplicate:true is passed. Expected hash/size let operators verify the server-side file matches the locally built artifact before creating the row. Apply-mode success payload is { product_id, created: DownloadRow, downloads: DownloadRow[] } with DownloadRow metadata only. This tool only creates the download row and enables manage_downloadable; it does NOT set license_settings.global_update_file — follow with diviops_fc_license_settings_update using the created row ID. Error codes: invalid_input (400), not_found (404), fluentcart.download_duplicate (409), fluentcart.module_inactive (412), fluentcart.command_failed (500). Idempotency: false; repeat calls are rejected by duplicate detection unless allow_duplicate:true." +
|
|
4051
4264
|
DRY_RUN_DESC_SUFFIX,
|
|
4052
4265
|
inputSchema: {
|
|
4053
4266
|
product_id: z
|
|
@@ -4600,6 +4813,7 @@ async function main() {
|
|
|
4600
4813
|
proActive: hs.pro_active === true,
|
|
4601
4814
|
availableTargets: hs.available_targets ?? {},
|
|
4602
4815
|
activeModules: hs.active_modules ?? {},
|
|
4816
|
+
plugins: hs.plugins ?? {},
|
|
4603
4817
|
};
|
|
4604
4818
|
const diviInfo = hs.divi.active
|
|
4605
4819
|
? `Divi ${hs.divi.version ?? "unknown"}`
|
package/dist/preset-cli/cli.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Usage:
|
|
10
10
|
* diviops-preset button [options] Emit a divi/button group preset
|
|
11
|
-
* diviops-preset nav [options] Emit
|
|
11
|
+
* diviops-preset nav [options] Emit Divi nav block skeletons
|
|
12
12
|
* diviops-preset --help Show help
|
|
13
13
|
*
|
|
14
14
|
* Modes:
|
package/dist/preset-cli/cli.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Usage:
|
|
10
10
|
* diviops-preset button [options] Emit a divi/button group preset
|
|
11
|
-
* diviops-preset nav [options] Emit
|
|
11
|
+
* diviops-preset nav [options] Emit Divi nav block skeletons
|
|
12
12
|
* diviops-preset --help Show help
|
|
13
13
|
*
|
|
14
14
|
* Modes:
|
|
@@ -53,8 +53,8 @@ USAGE
|
|
|
53
53
|
for divi/text (Pattern A only)
|
|
54
54
|
diviops-preset spacing [options] Emit a divi/spacing group preset
|
|
55
55
|
(currently divi/section only)
|
|
56
|
-
diviops-preset nav [options] Emit
|
|
57
|
-
|
|
56
|
+
diviops-preset nav [options] Emit Divi nav block-markup
|
|
57
|
+
skeletons
|
|
58
58
|
diviops-preset --help Show this help
|
|
59
59
|
|
|
60
60
|
MODE
|
|
@@ -169,6 +169,8 @@ nav OPTIONS (dry-run block markup only; --apply is refused)
|
|
|
169
169
|
--spec <json> Compact nav spec JSON. Mutually exclusive with
|
|
170
170
|
--spec-file.
|
|
171
171
|
--spec-file <path> Read compact nav spec JSON from disk.
|
|
172
|
+
--responsive-split Emit sibling desktop/mobile nav units using native
|
|
173
|
+
Divi disabledOn visibility. Default is one drawer.
|
|
172
174
|
|
|
173
175
|
Spec shape:
|
|
174
176
|
{"label":"Menu","idPrefix":"main-nav","items":[
|
|
@@ -270,6 +272,10 @@ export function parseArgs(argv) {
|
|
|
270
272
|
parsed.options.set(tok, true);
|
|
271
273
|
continue;
|
|
272
274
|
}
|
|
275
|
+
if (tok === "--responsive-split") {
|
|
276
|
+
parsed.options.set(tok, true);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
273
279
|
if (VALUE_FLAGS.has(tok)) {
|
|
274
280
|
const val = argv[i + 1];
|
|
275
281
|
if (val === undefined || val.startsWith("--")) {
|
|
@@ -554,6 +560,9 @@ export function buildNavInput(parsed) {
|
|
|
554
560
|
return {
|
|
555
561
|
name,
|
|
556
562
|
spec: parseNavSpecJson(specJson),
|
|
563
|
+
mode: parsed.options.has("--responsive-split")
|
|
564
|
+
? "responsive_split"
|
|
565
|
+
: "drawer",
|
|
557
566
|
};
|
|
558
567
|
}
|
|
559
568
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `diviops-preset nav` block-markup emitter.
|
|
3
3
|
*
|
|
4
|
-
* Emits
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Emits small, Free-safe Divi 5 navigation skeletons from a compact JSON spec.
|
|
5
|
+
* This MVP is dry-run only: it writes no WordPress content and does not add
|
|
6
|
+
* MCP/plugin routes. The output is serialized Divi block markup with the
|
|
7
|
+
* high-signal nav reliability contracts encoded up front:
|
|
8
8
|
*
|
|
9
9
|
* - one leaf `divi/text` button trigger with `aria-controls`;
|
|
10
10
|
* - one `divi/dropdown` panel with the matching custom `id`;
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* - semantic submenu list shape: dropdown as `ul`, links wrapped with
|
|
13
13
|
* `htmlBefore:"<li>"` / `htmlAfter:"</li>"`;
|
|
14
14
|
* - non-empty boolean-style custom attrs;
|
|
15
|
-
* - wrapper-level tap-highlight suppression and a floating-width
|
|
15
|
+
* - wrapper-level tap-highlight suppression and a CSS-only floating-width
|
|
16
|
+
* guard, because Divi floating dropdowns can ignore VB sizing controls.
|
|
16
17
|
*/
|
|
17
18
|
export interface NavLinkSpec {
|
|
18
19
|
label: string;
|
|
@@ -30,8 +31,12 @@ interface ParsedNavSectionSpec {
|
|
|
30
31
|
}
|
|
31
32
|
interface ParsedNavSpec {
|
|
32
33
|
label?: string;
|
|
34
|
+
desktopLabel?: string;
|
|
35
|
+
mobileLabel?: string;
|
|
33
36
|
idPrefix?: string;
|
|
34
37
|
items: Array<ParsedNavLinkSpec | ParsedNavSectionSpec>;
|
|
38
|
+
desktopItems?: Array<ParsedNavLinkSpec | ParsedNavSectionSpec>;
|
|
39
|
+
mobileItems?: Array<ParsedNavLinkSpec | ParsedNavSectionSpec>;
|
|
35
40
|
}
|
|
36
41
|
export interface NavItemSpec {
|
|
37
42
|
label: string;
|
|
@@ -41,12 +46,18 @@ export interface NavItemSpec {
|
|
|
41
46
|
}
|
|
42
47
|
export interface NavSpec {
|
|
43
48
|
label?: string;
|
|
49
|
+
desktopLabel?: string;
|
|
50
|
+
mobileLabel?: string;
|
|
44
51
|
idPrefix?: string;
|
|
45
|
-
items
|
|
52
|
+
items?: NavItemSpec[];
|
|
53
|
+
desktopItems?: NavItemSpec[];
|
|
54
|
+
mobileItems?: NavItemSpec[];
|
|
46
55
|
}
|
|
56
|
+
export type NavEmitterMode = "drawer" | "responsive_split";
|
|
47
57
|
export interface NavEmitterInput {
|
|
48
58
|
name: string;
|
|
49
59
|
spec: NavSpec;
|
|
60
|
+
mode?: NavEmitterMode;
|
|
50
61
|
}
|
|
51
62
|
export interface NavMarkupEntry {
|
|
52
63
|
type: "block_markup";
|