@diviops/mcp-server 1.5.31 → 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 CHANGED
@@ -83,7 +83,7 @@ The skill enforces the Divi block format, the design system, and the response co
83
83
 
84
84
  ## Tools at a glance
85
85
 
86
- The server exposes **77 always-on tools** across the categories below. Each category links to representative tools; the full table lives in [server-reference.md](../docs/server-reference.md).
86
+ The server exposes **78 always-on tools** across the categories below. Each category links to representative tools; the full table lives in [server-reference.md](../docs/server-reference.md).
87
87
 
88
88
  | Category | Use case | Tool prefixes |
89
89
  |----------|----------|---------------|
@@ -97,6 +97,8 @@ The server exposes **77 always-on tools** across the categories below. Each cate
97
97
  | WP-CLI passthrough | Escape hatch for site ops | `meta_wp_cli` |
98
98
  | Cache + meta | Connection probe, identity, icons, cache flush | `meta_*` |
99
99
 
100
+ Use `diviops_meta_info` as the S0 preflight before dogfooding or product work. It returns `server_version`, a numeric `tool_count`, a `tools` catalog summary (`registered_total`, always-on count, Pro possible/registered counts by target), `plugins` version records for `diviops-agent`, `diviops-agent-pro`, FluentCart, and FluentCart Pro when available, plus the existing handshake and slice state.
101
+
100
102
  Additional **conditionally-registered Pro tools** appear only on sites that have the Pro plugin (`diviops-agent-pro`) active alongside the target coverage plugin:
101
103
 
102
104
  | Category | Conditional gate | Tool names |
@@ -172,11 +174,13 @@ The MVP supports `tb_header_layout` source payloads preflighted against an
172
174
  existing `tb_header_layout` target context. It reports source-domain upload URL
173
175
  rewrites, attachment remap status, `gcid-*` target resolution including Divi
174
176
  built-in customizer colors, resolved target global-color value evidence,
175
- off-canvas/canvas refusal, and the required cache cleanup plan. Each report also
176
- emits a deterministic `confirmation_binding` fingerprint over the reviewed
177
- source identity/checksum, target identity/current target checksum, rewrite plan,
178
- cache plan, blocker/operator-action codes, reference-resolution summaries, and
179
- the per-`gcid` value evidence for target colors referenced by the source layout.
177
+ referenced `modulePreset` target-presence status, off-canvas/canvas refusal, and
178
+ the required cache cleanup plan. Each report also emits a deterministic
179
+ `confirmation_binding` fingerprint over the reviewed source identity/checksum,
180
+ target identity/current target checksum, rewrite plan, cache plan,
181
+ blocker/operator-action codes, reference-resolution summaries, target module
182
+ preset resolution, and the per-`gcid` value evidence for target colors
183
+ referenced by the source layout.
180
184
  The fingerprint is reviewed-plan evidence for the Pro-gated
181
185
  `diviops_cross_env_header_apply` tool. The CLI itself still has no apply path.
182
186
 
@@ -185,8 +189,10 @@ read-only MCP tool `diviops_cross_env_source_export_get` and save the returned
185
189
  `data` object as `source.json`. The export includes the source origin, header
186
190
  layout metadata, sanitized markup, a bare SHA-256 checksum of the exported
187
191
  markup, export metadata, and best-effort attachment inventory from upload URLs
188
- and attachment IDs. It strips query strings, fragments, credentials, nonces,
189
- cookies, signed URL material, admin URLs, and local filesystem paths.
192
+ and attachment IDs. It also inventories referenced `attrs.modulePreset` IDs
193
+ without exporting preset definitions. It strips query strings, fragments,
194
+ credentials, nonces, cookies, signed URL material, admin URLs, and local
195
+ filesystem paths.
190
196
 
191
197
  The MCP server also writes the same source payload to a bounded local artifact
192
198
  under `.diviops-tmp/cross-env-source-payloads/` and returns
@@ -207,6 +213,9 @@ to the target state without exposing the raw target content. It also includes
207
213
  `global_color_value_evidence`, a deterministic SHA-256 digest map for resolved
208
214
  user global colors and WP Customizer-backed built-ins; preflight binds only the
209
215
  entries that are referenced by source markup.
216
+ It also includes target D5 module preset IDs, without preset definitions, so the
217
+ preflight can fail closed when source markup references a module preset the
218
+ target site does not have.
210
219
 
211
220
  Workflow:
212
221
 
@@ -308,7 +317,7 @@ Common quick fixes — full reference in [troubleshooting.md](../docs/troublesho
308
317
  - **`npx` fails with "could not determine executable to run"** — use `npx -y --package @diviops/mcp-server diviops-mcp`; this explicitly selects the MCP server bin.
309
318
  - **"Connection failed"** — verify the plugin is active by visiting `{WP_URL}/wp-json/diviops/v1/schema/settings`; test the credentials with `curl -u "user:pass" …`.
310
319
  - **"This tool requires plugin capability"** — the plugin doesn't advertise the capability this tool needs. Update the plugin to the latest release.
311
- - **Preset edits not visible on the frontend** — Divi serves frontend CSS from `wp-content/et-cache/{post_id}/`, which `wp cache flush` doesn't touch. Use `diviops_meta_flush_cache` after preset writes.
320
+ - **Preset edits not visible on the frontend** — Divi serves frontend CSS from `wp-content/et-cache/{post_id}/`, which `wp cache flush` doesn't touch. Use `diviops_meta_flush_cache` after preset writes; `post_id` mode also sweeps that exact directory and reports `post_dir_sweep` evidence.
312
321
 
313
322
  ## Learn more
314
323
 
@@ -38,6 +38,15 @@ export interface HandshakeTarget {
38
38
  present: boolean;
39
39
  version?: string | null;
40
40
  }
41
+ /**
42
+ * Advisory plugin version/presence record contributed by extension plugins.
43
+ * This is a diagnostics/preflight surface only; capability gates continue to
44
+ * use the explicit capability map and target/module flags.
45
+ */
46
+ export interface HandshakePluginInfo {
47
+ active: boolean;
48
+ version?: string | null;
49
+ }
41
50
  /**
42
51
  * Shape returned by `POST /diviops/v1/handshake`.
43
52
  *
@@ -70,6 +79,8 @@ export interface HandshakeResult {
70
79
  available_targets?: Record<string, HandshakeTarget>;
71
80
  /** ADR-003 — per-target admin-controlled activation toggle. */
72
81
  active_modules?: Record<string, boolean>;
82
+ /** Advisory installed-plugin versions for S0 preflight reports. */
83
+ plugins?: Record<string, HandshakePluginInfo>;
73
84
  }
74
85
  export declare function proToolGatesSatisfied(state: {
75
86
  proActive: boolean;
@@ -15,6 +15,7 @@ export interface SourceLayoutPayload {
15
15
  markup: string;
16
16
  checksum?: string;
17
17
  attachments?: SourceAttachmentInventoryItem[];
18
+ module_preset_ids?: unknown;
18
19
  }
19
20
  export interface TargetAttachmentInventoryItem {
20
21
  id?: number;
@@ -42,6 +43,7 @@ export interface TargetLayoutContext {
42
43
  global_colors?: unknown;
43
44
  global_color_value_evidence?: unknown;
44
45
  builtin_customizer_color_ids?: unknown;
46
+ module_preset_ids?: unknown;
45
47
  cache_scope?: string;
46
48
  }
47
49
  export interface CrossEnvHeaderPreflightInput {
@@ -84,6 +86,10 @@ export interface OffCanvasReference {
84
86
  token: string;
85
87
  reason: string;
86
88
  }
89
+ export interface ModulePresetReference {
90
+ id: string;
91
+ status: "target_module_preset" | "missing_target_context" | "missing_definition";
92
+ }
87
93
  export interface CrossEnvHeaderPreflightReport {
88
94
  type: "cross_env_header_preflight";
89
95
  dry_run: true;
@@ -115,6 +121,7 @@ export interface CrossEnvHeaderPreflightReport {
115
121
  };
116
122
  attachments: AttachmentReference[];
117
123
  global_colors: GcidReference[];
124
+ module_presets: ModulePresetReference[];
118
125
  off_canvas: OffCanvasReference[];
119
126
  };
120
127
  rewrite_plan: {
@@ -462,6 +462,72 @@ function findGcidRefs(markup, target) {
462
462
  return { id, status: "missing_definition" };
463
463
  });
464
464
  }
465
+ function isSafePresetId(value) {
466
+ return value !== "" && value !== "default" && /^[A-Za-z0-9_-]+$/.test(value);
467
+ }
468
+ function collectPresetIdsFromList(value) {
469
+ if (value === undefined || value === null)
470
+ return null;
471
+ const ids = new Set();
472
+ const add = (candidate) => {
473
+ if (typeof candidate === "string" && isSafePresetId(candidate)) {
474
+ ids.add(candidate);
475
+ }
476
+ };
477
+ if (Array.isArray(value)) {
478
+ for (const item of value)
479
+ add(item);
480
+ }
481
+ else if (value && typeof value === "object") {
482
+ for (const [key, item] of Object.entries(value)) {
483
+ add(key);
484
+ if (item && typeof item === "object") {
485
+ add(item.id);
486
+ }
487
+ }
488
+ }
489
+ else {
490
+ add(value);
491
+ }
492
+ return ids;
493
+ }
494
+ function findModulePresetRefs(source, target) {
495
+ const refs = collectPresetIdsFromList(source.module_preset_ids) ?? new Set();
496
+ const decoded = decodeMarkup(source.markup);
497
+ if (decoded.includes('"modulePreset"')) {
498
+ const blockRe = /<!--\s+(?:\/)?wp:([A-Za-z0-9_-]+\/[A-Za-z0-9_-]+)(.*?)(?:\/)?-->/gs;
499
+ let match;
500
+ while ((match = blockRe.exec(decoded)) !== null) {
501
+ const blockName = match[1];
502
+ if (!blockName.startsWith("divi/"))
503
+ continue;
504
+ const attrsText = jsonObjectFromBlockCommentTail(match[2] ?? "");
505
+ if (!attrsText)
506
+ continue;
507
+ try {
508
+ const attrs = JSON.parse(attrsText);
509
+ const values = Array.isArray(attrs.modulePreset)
510
+ ? attrs.modulePreset
511
+ : [attrs.modulePreset];
512
+ for (const id of values) {
513
+ if (typeof id === "string" && isSafePresetId(id))
514
+ refs.add(id);
515
+ }
516
+ }
517
+ catch {
518
+ continue;
519
+ }
520
+ }
521
+ }
522
+ const targetIds = collectPresetIdsFromList(target.module_preset_ids);
523
+ return uniqueSorted(refs).map((id) => {
524
+ if (targetIds === null)
525
+ return { id, status: "missing_target_context" };
526
+ if (targetIds.has(id))
527
+ return { id, status: "target_module_preset" };
528
+ return { id, status: "missing_definition" };
529
+ });
530
+ }
465
531
  function findOffCanvasRefs(markup) {
466
532
  const decoded = decodeMarkup(markup);
467
533
  const refs = new Map();
@@ -561,6 +627,16 @@ function buildConfirmationBinding(report) {
561
627
  value_evidence: color.value_evidence ?? null,
562
628
  }))
563
629
  .sort((a, b) => canonicalJson(a).localeCompare(canonicalJson(b))),
630
+ ...(report.findings.module_presets.length > 0
631
+ ? {
632
+ module_preset_resolution: report.findings.module_presets
633
+ .map((preset) => ({
634
+ id: preset.id,
635
+ status: preset.status,
636
+ }))
637
+ .sort((a, b) => canonicalJson(a).localeCompare(canonicalJson(b))),
638
+ }
639
+ : {}),
564
640
  };
565
641
  const schema = "diviops.cross_env.header_preflight.confirmation_binding.v1";
566
642
  const fingerprint = sha256(canonicalJson({ schema, input }));
@@ -694,6 +770,23 @@ export function preflightCrossEnvHeaderSync(input) {
694
770
  });
695
771
  }
696
772
  }
773
+ const modulePresets = findModulePresetRefs(input.source, input.target);
774
+ for (const preset of modulePresets) {
775
+ if (preset.status === "missing_target_context") {
776
+ operatorActions.push({
777
+ code: "missing_module_preset_context",
778
+ message: "Provide target D5 module preset IDs before apply.",
779
+ detail: { id: preset.id },
780
+ });
781
+ }
782
+ else if (preset.status === "missing_definition") {
783
+ operatorActions.push({
784
+ code: "missing_module_preset_definition",
785
+ message: "Referenced modulePreset is not defined on the target.",
786
+ detail: { id: preset.id },
787
+ });
788
+ }
789
+ }
697
790
  const offCanvas = findOffCanvasRefs(input.source.markup);
698
791
  if (offCanvas.length > 0) {
699
792
  blockers.push({
@@ -757,6 +850,7 @@ export function preflightCrossEnvHeaderSync(input) {
757
850
  },
758
851
  attachments,
759
852
  global_colors: globalColors,
853
+ module_presets: modulePresets,
760
854
  off_canvas: offCanvas,
761
855
  },
762
856
  rewrite_plan: {
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ 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
18
  import { createSourcePayloadRef, loadSourcePayloadRef, } from "./cross-env-preflight/source-payload-ref.js";
@@ -88,6 +88,62 @@ const server = new McpServer({
88
88
  version: SERVER_VERSION,
89
89
  });
90
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
+ }
91
147
  const BASE_META_CAPABILITIES = [
92
148
  "pages",
93
149
  "modules",
@@ -110,6 +166,36 @@ function enabledCapabilityKeys(prefix) {
110
166
  .filter((key) => (prefix ? key.startsWith(prefix) : true))
111
167
  .sort();
112
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
+ }
113
199
  function buildMetaInfo() {
114
200
  const fluentCartCapabilityKeys = enabledCapabilityKeys("fluentcart_");
115
201
  const crossEnvCapabilityKeys = enabledCapabilityKeys("cross_env_");
@@ -134,12 +220,17 @@ function buildMetaInfo() {
134
220
  : [...BASE_META_CAPABILITIES];
135
221
  if (crossEnvActive)
136
222
  capabilities.push("cross_env");
223
+ const tools = buildToolCatalogSummary();
137
224
  return {
138
225
  brand: "DiviOps",
139
226
  server: "diviops-mcp",
227
+ server_version: SERVER_VERSION,
140
228
  version: SERVER_VERSION,
141
229
  license: "MIT",
142
230
  capabilities,
231
+ tool_count: tools.registered_total,
232
+ tools,
233
+ plugins: buildPluginVersionSummary(),
143
234
  handshake: handshakeState.kind === "ok"
144
235
  ? {
145
236
  state: "ok",
@@ -199,6 +290,12 @@ function requireCapability(key) {
199
290
  /* eslint-disable @typescript-eslint/no-explicit-any */
200
291
  function registerPluginTool(name, config, handler) {
201
292
  const key = name.replace(/^diviops_/, "");
293
+ recordToolCatalog({
294
+ name,
295
+ kind: "plugin",
296
+ registered: true,
297
+ capability_key: key,
298
+ });
202
299
  const wrapped = (async (args) => {
203
300
  try {
204
301
  requireCapability(key);
@@ -225,6 +322,7 @@ function registerPluginTool(name, config, handler) {
225
322
  * can emit it on per-call responses (#597).
226
323
  */
227
324
  function registerLocalTool(name, config, handler) {
325
+ recordToolCatalog({ name, kind: "server_local", registered: true });
228
326
  recordIdempotent(name, config?._meta);
229
327
  server.registerTool(name, config, handler);
230
328
  }
@@ -266,10 +364,18 @@ function registerLocalTool(name, config, handler) {
266
364
  * the resolved handshakeState.
267
365
  */
268
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
+ });
269
374
  if (handshakeState.kind !== "ok")
270
375
  return;
271
376
  if (!proToolGatesSatisfied(handshakeState, gates))
272
377
  return;
378
+ catalogEntry.registered = true;
273
379
  recordIdempotent(name, config?._meta);
274
380
  server.registerTool(name, config, handler);
275
381
  }
@@ -2211,6 +2317,60 @@ registerPluginTool("diviops_canvas_list", {
2211
2317
  ],
2212
2318
  };
2213
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
+ });
2214
2374
  registerPluginTool("diviops_canvas_get", {
2215
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.",
2216
2376
  inputSchema: {
@@ -2797,7 +2957,7 @@ registerLocalTool("diviops_meta_ping", {
2797
2957
  };
2798
2958
  });
2799
2959
  registerLocalTool("diviops_meta_info", {
2800
- description: "Returns DiviOps MCP server identity, version, license type, available capability groups, WP-CLI allowlist, and plugin handshake/slice state including Pro and FluentCart target readiness. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
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? } }.",
2801
2961
  annotations: { idempotentHint: true },
2802
2962
  _meta: { idempotent: "true" },
2803
2963
  }, async () => {
@@ -3302,7 +3462,7 @@ registerPluginTool("diviops_variable_used_on_page", {
3302
3462
  };
3303
3463
  });
3304
3464
  registerPluginTool("diviops_meta_flush_cache", {
3305
- 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)." +
3306
3466
  DRY_RUN_DESC_SUFFIX +
3307
3467
  " Note: in `after` mode the dry-run plan reports the cutoff only — accurate file count requires the live mtime walk.",
3308
3468
  inputSchema: {
@@ -3311,7 +3471,7 @@ registerPluginTool("diviops_meta_flush_cache", {
3311
3471
  .int()
3312
3472
  .positive()
3313
3473
  .optional()
3314
- .describe("Flush cache for one post. Native backend also clears matching Theme Builder CSS in other post dirs; fs_fallback only clears wp-content/et-cache/{post_id}/."),
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}/."),
3315
3475
  all: z
3316
3476
  .boolean()
3317
3477
  .optional()
@@ -3394,6 +3554,10 @@ const CrossEnvSourcePayloadSchema = z
3394
3554
  .regex(/^(sha256:)?[a-fA-F0-9]{64}$/)
3395
3555
  .describe("sha256 checksum of source_payload.markup from source export."),
3396
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."),
3397
3561
  })
3398
3562
  .passthrough();
3399
3563
  const CrossEnvSourcePayloadRefSchema = z
@@ -3434,7 +3598,7 @@ function sourceHintsFromPayload(source) {
3434
3598
  function registerProTools() {
3435
3599
  // diviops_cross_env_header_apply — guarded Pro apply for reviewed header preflight
3436
3600
  registerProTool("diviops_cross_env_header_apply", {
3437
- 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, 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, 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.",
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.",
3438
3602
  inputSchema: {
3439
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."),
3440
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."),
@@ -4649,6 +4813,7 @@ async function main() {
4649
4813
  proActive: hs.pro_active === true,
4650
4814
  availableTargets: hs.available_targets ?? {},
4651
4815
  activeModules: hs.active_modules ?? {},
4816
+ plugins: hs.plugins ?? {},
4652
4817
  };
4653
4818
  const diviInfo = hs.divi.active
4654
4819
  ? `Divi ${hs.divi.version ?? "unknown"}`
@@ -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 a Divi nav drawer block skeleton
11
+ * diviops-preset nav [options] Emit Divi nav block skeletons
12
12
  * diviops-preset --help Show help
13
13
  *
14
14
  * Modes:
@@ -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 a Divi nav drawer block skeleton
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 a small Divi nav drawer
57
- block-markup skeleton
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 a small, Free-safe Divi 5 navigation drawer skeleton from a compact
5
- * JSON spec. This MVP is dry-run only: it writes no WordPress content and
6
- * does not add MCP/plugin routes. The output is serialized Divi block markup
7
- * with the high-signal nav reliability contracts encoded up front:
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 CSS guard.
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: NavItemSpec[];
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";
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * `diviops-preset nav` block-markup emitter.
3
3
  *
4
- * Emits a small, Free-safe Divi 5 navigation drawer skeleton from a compact
5
- * JSON spec. This MVP is dry-run only: it writes no WordPress content and
6
- * does not add MCP/plugin routes. The output is serialized Divi block markup
7
- * with the high-signal nav reliability contracts encoded up front:
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 CSS guard.
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
  const BUILDER_VERSION = "5.7.4";
18
19
  function isPlainObject(value) {
@@ -124,14 +125,28 @@ function serializeBlock(name, attrs, innerBlocks = []) {
124
125
  `<!-- /wp:${blockName} -->`,
125
126
  ].join("\n");
126
127
  }
127
- function rootNavBlock(label, panelId, children) {
128
+ function disabledOnAttrs(values) {
129
+ return {
130
+ module: {
131
+ decoration: {
132
+ disabledOn: {
133
+ desktop: { value: values.desktop },
134
+ tablet: { value: values.tablet },
135
+ phone: { value: values.phone },
136
+ },
137
+ },
138
+ },
139
+ };
140
+ }
141
+ function rootNavBlock(label, panelId, children, opts = {}) {
128
142
  const css = "selector{-webkit-tap-highlight-color:transparent;}" +
129
143
  "selector a:focus-visible,selector button:focus-visible{outline:2px solid currentColor;outline-offset:3px;}" +
130
- "selector .et_pb_dropdown,selector .et_pb_dropdown_content{width:min(100vw,24rem);max-width:calc(100vw - 2rem);}";
144
+ "selector .et_pb_dropdown,selector .et_pb_dropdown_content{width:clamp(16rem,calc(100vw - 2rem),32rem)!important;min-width:0!important;max-width:none!important;}";
131
145
  return serializeBlock("group", mergeObjects(htmlAttrs({ elementType: "nav" }), customAttributes([
132
146
  { name: "aria-label", value: label },
133
147
  { name: "data-diviops-nav", value: "true" },
134
- ]), {
148
+ ...(opts.customAttributes ?? []),
149
+ ]), opts.extraAttrs ?? {}, {
135
150
  module: {
136
151
  decoration: {
137
152
  layout: {
@@ -161,6 +176,31 @@ function rootNavBlock(label, panelId, children) {
161
176
  ...children,
162
177
  ]);
163
178
  }
179
+ function responsiveNavShellBlock(children) {
180
+ return serializeBlock("group", mergeObjects(htmlAttrs({ elementType: "div" }), customAttributes([{ name: "data-diviops-responsive-nav", value: "true" }]), {
181
+ module: {
182
+ decoration: {
183
+ layout: {
184
+ desktop: {
185
+ value: {
186
+ display: "flex",
187
+ flexDirection: "row",
188
+ alignItems: "center",
189
+ gap: "16px",
190
+ },
191
+ },
192
+ tablet: {
193
+ value: {
194
+ flexDirection: "column",
195
+ alignItems: "stretch",
196
+ gap: "0px",
197
+ },
198
+ },
199
+ },
200
+ },
201
+ },
202
+ }), children);
203
+ }
164
204
  function dropdownBlock(panelId, children) {
165
205
  return serializeBlock("dropdown", mergeObjects(htmlAttrs({ elementType: "ul" }), customAttributes([
166
206
  { name: "id", value: panelId },
@@ -240,38 +280,62 @@ function parseLinkSpec(raw, field) {
240
280
  const target = normalizeTarget(raw.target);
241
281
  return { label, url, target };
242
282
  }
283
+ function parseNavItems(itemsRaw, field) {
284
+ if (!Array.isArray(itemsRaw) || itemsRaw.length === 0) {
285
+ throw new Error(`nav spec requires a non-empty ${field} array.`);
286
+ }
287
+ return itemsRaw.map((itemRaw, itemIndex) => {
288
+ if (!isPlainObject(itemRaw)) {
289
+ throw new Error(`nav spec ${field}[${itemIndex}] must be an object.`);
290
+ }
291
+ const label = assertNonEmptyString(itemRaw.label, `${field}[${itemIndex}].label`);
292
+ if (Array.isArray(itemRaw.links)) {
293
+ if (itemRaw.links.length === 0) {
294
+ throw new Error(`nav spec ${field}[${itemIndex}].links must not be empty.`);
295
+ }
296
+ return {
297
+ label,
298
+ links: itemRaw.links.map((link, linkIndex) => parseLinkSpec(link, `${field}[${itemIndex}].links[${linkIndex}]`)),
299
+ };
300
+ }
301
+ return parseLinkSpec(itemRaw, `${field}[${itemIndex}]`);
302
+ });
303
+ }
243
304
  export function parseNavSpec(raw) {
244
305
  if (!isPlainObject(raw)) {
245
306
  throw new Error("nav spec must be a JSON object.");
246
307
  }
247
- const itemsRaw = raw.items;
248
- if (!Array.isArray(itemsRaw) || itemsRaw.length === 0) {
308
+ const items = raw.items !== undefined ? parseNavItems(raw.items, "items") : undefined;
309
+ const desktopItems = raw.desktopItems !== undefined
310
+ ? parseNavItems(raw.desktopItems, "desktopItems")
311
+ : undefined;
312
+ const mobileItems = raw.mobileItems !== undefined
313
+ ? parseNavItems(raw.mobileItems, "mobileItems")
314
+ : undefined;
315
+ if (!items && !desktopItems && !mobileItems) {
249
316
  throw new Error("nav spec requires a non-empty items array.");
250
317
  }
251
318
  const spec = {
252
- items: itemsRaw.map((itemRaw, itemIndex) => {
253
- if (!isPlainObject(itemRaw)) {
254
- throw new Error(`nav spec items[${itemIndex}] must be an object.`);
255
- }
256
- const label = assertNonEmptyString(itemRaw.label, `items[${itemIndex}].label`);
257
- if (Array.isArray(itemRaw.links)) {
258
- if (itemRaw.links.length === 0) {
259
- throw new Error(`nav spec items[${itemIndex}].links must not be empty.`);
260
- }
261
- return {
262
- label,
263
- links: itemRaw.links.map((link, linkIndex) => parseLinkSpec(link, `items[${itemIndex}].links[${linkIndex}]`)),
264
- };
265
- }
266
- return parseLinkSpec(itemRaw, `items[${itemIndex}]`);
267
- }),
319
+ items: items ?? desktopItems ?? mobileItems ?? [],
268
320
  };
269
321
  if (raw.label !== undefined) {
270
322
  spec.label = assertNonEmptyString(raw.label, "label");
271
323
  }
324
+ if (raw.desktopLabel !== undefined) {
325
+ spec.desktopLabel = assertNonEmptyString(raw.desktopLabel, "desktopLabel");
326
+ }
327
+ if (raw.mobileLabel !== undefined) {
328
+ spec.mobileLabel = assertNonEmptyString(raw.mobileLabel, "mobileLabel");
329
+ }
272
330
  if (raw.idPrefix !== undefined) {
273
331
  spec.idPrefix = assertNonEmptyString(raw.idPrefix, "idPrefix");
274
332
  }
333
+ if (desktopItems) {
334
+ spec.desktopItems = desktopItems;
335
+ }
336
+ if (mobileItems) {
337
+ spec.mobileItems = mobileItems;
338
+ }
275
339
  return spec;
276
340
  }
277
341
  export function parseNavSpecJson(json) {
@@ -287,22 +351,68 @@ export function parseNavSpecJson(json) {
287
351
  export function emitNavBlockMarkup(input) {
288
352
  const name = assertNonEmptyString(input.name, "name");
289
353
  const spec = parseNavSpec(input.spec);
354
+ const mode = input.mode ?? "drawer";
290
355
  const label = spec.label ?? name;
291
356
  const idPrefix = slugifyId(spec.idPrefix ?? name);
292
357
  const panelId = `${idPrefix}-panel`;
293
- const listChildren = [];
294
- for (const item of spec.items) {
295
- if ("links" in item) {
296
- listChildren.push(sectionLabelBlock(item.label));
297
- for (const link of item.links) {
298
- listChildren.push(linkBlock(link));
358
+ const buildListChildren = (items) => {
359
+ const listChildren = [];
360
+ for (const item of items) {
361
+ if ("links" in item) {
362
+ listChildren.push(sectionLabelBlock(item.label));
363
+ for (const link of item.links) {
364
+ listChildren.push(linkBlock(link));
365
+ }
366
+ }
367
+ else {
368
+ listChildren.push(linkBlock(item));
299
369
  }
300
370
  }
301
- else {
302
- listChildren.push(linkBlock(item));
303
- }
371
+ return listChildren;
372
+ };
373
+ if (mode === "responsive_split") {
374
+ const desktopPanelId = `${idPrefix}-desktop-panel`;
375
+ const mobilePanelId = `${idPrefix}-mobile-panel`;
376
+ const desktopLabel = spec.desktopLabel ?? `${label} desktop`;
377
+ const mobileLabel = spec.mobileLabel ?? `${label} mobile`;
378
+ const desktopItems = spec.desktopItems ?? spec.items;
379
+ const mobileItems = spec.mobileItems ?? spec.items;
380
+ const markup = responsiveNavShellBlock([
381
+ rootNavBlock(desktopLabel, desktopPanelId, [dropdownBlock(desktopPanelId, buildListChildren(desktopItems))], {
382
+ customAttributes: [{ name: "data-diviops-nav-unit", value: "desktop" }],
383
+ extraAttrs: disabledOnAttrs({
384
+ desktop: "off",
385
+ tablet: "on",
386
+ phone: "on",
387
+ }),
388
+ }),
389
+ rootNavBlock(mobileLabel, mobilePanelId, [dropdownBlock(mobilePanelId, buildListChildren(mobileItems))], {
390
+ customAttributes: [{ name: "data-diviops-nav-unit", value: "mobile" }],
391
+ extraAttrs: disabledOnAttrs({
392
+ desktop: "on",
393
+ tablet: "off",
394
+ phone: "off",
395
+ }),
396
+ }),
397
+ ]);
398
+ return {
399
+ type: "block_markup",
400
+ format: "divi_block_markup",
401
+ name,
402
+ markup,
403
+ notes: [
404
+ "Dry-run only: no WordPress write path is invoked.",
405
+ "Responsive split output contains two sibling nav units: desktop is disabled on tablet/phone, and mobile is disabled on desktop.",
406
+ "The split uses native Divi disabledOn visibility and emits no breakpoint JavaScript.",
407
+ "Use targeted create/clone/tree-surgery flows for placement; do not route this through whole-layout update paths.",
408
+ "Floating dropdown width is controlled by emitted CSS; Divi VB sizing controls may not constrain floating panels.",
409
+ "If custom runtime code observes style and writes style, guard unrendered dropdowns with getClientRects().length and make style writes idempotent.",
410
+ ],
411
+ };
304
412
  }
305
- const markup = rootNavBlock(label, panelId, [dropdownBlock(panelId, listChildren)]);
413
+ const markup = rootNavBlock(label, panelId, [
414
+ dropdownBlock(panelId, buildListChildren(spec.items)),
415
+ ]);
306
416
  return {
307
417
  type: "block_markup",
308
418
  format: "divi_block_markup",
@@ -311,6 +421,8 @@ export function emitNavBlockMarkup(input) {
311
421
  notes: [
312
422
  "Dry-run only: no WordPress write path is invoked.",
313
423
  "Use targeted create/clone/tree-surgery flows for placement; do not route this through whole-layout update paths.",
424
+ "Floating dropdown width is controlled by emitted CSS; Divi VB sizing controls may not constrain floating panels.",
425
+ "If custom runtime code observes style and writes style, guard unrendered dropdowns with getClientRects().length and make style writes idempotent.",
314
426
  ],
315
427
  };
316
428
  }
package/dist/wp-cli.d.ts CHANGED
@@ -13,6 +13,16 @@ interface WpCliConfig {
13
13
  /** Custom WP-CLI command prefix for containerized environments (e.g. "ddev wp"). */
14
14
  wpCliCmd?: string;
15
15
  }
16
+ /**
17
+ * Parse a command string into an array of arguments.
18
+ * Handles quoted strings (single and double quotes).
19
+ */
20
+ declare function parseCommand(command: string): string[];
21
+ declare function normalizeWpCliPathArgs(args: string[], wpPath: string): string[];
22
+ export declare const __wpCliTesting: {
23
+ parseCommand: typeof parseCommand;
24
+ normalizeWpCliPathArgs: typeof normalizeWpCliPathArgs;
25
+ };
16
26
  export declare function createWpCli(config: WpCliConfig): {
17
27
  /**
18
28
  * Execute a WP-CLI command from a string. Parsed via parseCommand
package/dist/wp-cli.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { execFile } from 'child_process';
9
9
  import { readdirSync, readFileSync, existsSync } from 'fs';
10
10
  import { homedir } from 'os';
11
- import { join } from 'path';
11
+ import { dirname, isAbsolute, join, resolve, sep } from 'path';
12
12
  import { resolveSafeFsRoot, fsValidationDisabled, ensureSafeFsRoot, matchFsSensitiveCommand, validateFilesystemFlags, } from './wp-cli-fs-validator.js';
13
13
  /**
14
14
  * Default WP-CLI commands — safe for public distribution.
@@ -188,13 +188,18 @@ function parseCommand(command) {
188
188
  let inDouble = false;
189
189
  for (let i = 0; i < command.length; i++) {
190
190
  const ch = command[i];
191
- if (ch === "'" && !inDouble) {
191
+ const next = command[i + 1];
192
+ if (ch === '\\' && !inSingle && next !== undefined) {
193
+ current += next;
194
+ i++;
195
+ }
196
+ else if (ch === "'" && !inDouble) {
192
197
  inSingle = !inSingle;
193
198
  }
194
199
  else if (ch === '"' && !inSingle) {
195
200
  inDouble = !inDouble;
196
201
  }
197
- else if (ch === ' ' && !inSingle && !inDouble) {
202
+ else if (/\s/.test(ch) && !inSingle && !inDouble) {
198
203
  if (current.length > 0) {
199
204
  args.push(current);
200
205
  current = '';
@@ -209,6 +214,107 @@ function parseCommand(command) {
209
214
  }
210
215
  return args;
211
216
  }
217
+ function isWithinWpPath(candidate, wpPath) {
218
+ const absolute = resolve(candidate);
219
+ const root = resolve(wpPath);
220
+ return absolute === root || absolute.startsWith(root + sep);
221
+ }
222
+ function normalizePathValue(value, wpPath) {
223
+ return isAbsolute(value) ? value : resolve(wpPath, value);
224
+ }
225
+ function coalesceSplitPathValue(args, startIndex, wpPath) {
226
+ const first = args[startIndex];
227
+ if (first === undefined) {
228
+ return { value: '', nextIndex: startIndex };
229
+ }
230
+ const normalizedFirst = normalizePathValue(first, wpPath);
231
+ if (!isAbsolute(first)) {
232
+ if (existsSync(normalizedFirst)) {
233
+ return { value: normalizedFirst, nextIndex: startIndex + 1 };
234
+ }
235
+ }
236
+ else {
237
+ const root = resolve(wpPath);
238
+ if (isWithinWpPath(normalizedFirst, root) && existsSync(normalizedFirst)) {
239
+ return { value: normalizedFirst, nextIndex: startIndex + 1 };
240
+ }
241
+ const couldBeWpPathSplit = root.startsWith(resolve(first) + ' ');
242
+ if (!couldBeWpPathSplit && !isWithinWpPath(normalizedFirst, root)) {
243
+ return { value: normalizedFirst, nextIndex: startIndex + 1 };
244
+ }
245
+ }
246
+ let bestParentMatch = null;
247
+ for (let endIndex = startIndex + 1; endIndex < args.length; endIndex++) {
248
+ if (args[endIndex]?.startsWith('--'))
249
+ break;
250
+ const joined = args.slice(startIndex, endIndex + 1).join(' ');
251
+ const normalized = normalizePathValue(joined, wpPath);
252
+ if (!isWithinWpPath(normalized, wpPath)) {
253
+ continue;
254
+ }
255
+ if (existsSync(normalized)) {
256
+ return { value: normalized, nextIndex: endIndex + 1 };
257
+ }
258
+ if (existsSync(dirname(normalized))) {
259
+ bestParentMatch = { value: normalized, nextIndex: endIndex + 1 };
260
+ }
261
+ }
262
+ return bestParentMatch ?? { value: normalizedFirst, nextIndex: startIndex + 1 };
263
+ }
264
+ function normalizePositionalPathArg(args, pathIndex, wpPath) {
265
+ if (args[pathIndex] === undefined || args[pathIndex]?.startsWith('--')) {
266
+ return args;
267
+ }
268
+ const before = args.slice(0, pathIndex);
269
+ const { value, nextIndex } = coalesceSplitPathValue(args, pathIndex, wpPath);
270
+ return [...before, value, ...args.slice(nextIndex)];
271
+ }
272
+ function normalizeDirFlagArgs(args, wpPath) {
273
+ const normalized = [];
274
+ for (let i = 0; i < args.length; i++) {
275
+ const arg = args[i];
276
+ if (arg === '--dir' && args[i + 1] !== undefined) {
277
+ const { value, nextIndex } = coalesceSplitPathValue(args, i + 1, wpPath);
278
+ normalized.push(arg, value);
279
+ i = nextIndex - 1;
280
+ }
281
+ else if (arg?.startsWith('--dir=')) {
282
+ const rawValue = arg.slice('--dir='.length);
283
+ const synthetic = [rawValue, ...args.slice(i + 1)];
284
+ const { value, nextIndex } = coalesceSplitPathValue(synthetic, 0, wpPath);
285
+ normalized.push(`--dir=${value}`);
286
+ i += nextIndex - 1;
287
+ }
288
+ else {
289
+ normalized.push(arg);
290
+ }
291
+ }
292
+ return normalized;
293
+ }
294
+ function normalizeWpCliPathArgs(args, wpPath) {
295
+ const threeWord = args.slice(0, 3).join(' ');
296
+ const twoWord = args.slice(0, 2).join(' ');
297
+ const oneWord = args[0];
298
+ if (oneWord === 'eval-file' || oneWord === 'import') {
299
+ return normalizePositionalPathArg(args, 1, wpPath);
300
+ }
301
+ if (twoWord === 'acf export' || twoWord === 'acf import') {
302
+ return normalizePositionalPathArg(args, 2, wpPath);
303
+ }
304
+ if (threeWord === 'scf json import' || threeWord === 'acf json import') {
305
+ return normalizePositionalPathArg(args, 3, wpPath);
306
+ }
307
+ if (oneWord === 'export' ||
308
+ threeWord === 'scf json export' ||
309
+ threeWord === 'acf json export') {
310
+ return normalizeDirFlagArgs(args, wpPath);
311
+ }
312
+ return args;
313
+ }
314
+ export const __wpCliTesting = {
315
+ parseCommand,
316
+ normalizeWpCliPathArgs,
317
+ };
212
318
  /**
213
319
  * Find the latest installed version of a Local lightning-service.
214
320
  * Scans ~/Library/Application Support/Local/lightning-services/ for directories
@@ -467,7 +573,7 @@ export function createWpCli(config) {
467
573
  * verbatim instead of being mis-split.
468
574
  */
469
575
  async run(command) {
470
- return runArgv(parseCommand(command));
576
+ return runArgv(normalizeWpCliPathArgs(parseCommand(command), config.wpPath));
471
577
  },
472
578
  /**
473
579
  * Execute a WP-CLI command from a pre-built argv array. Skips
package/dist/wp-client.js CHANGED
@@ -378,6 +378,11 @@ export class WPClient {
378
378
  Array.isArray(result.active_modules)) {
379
379
  result.active_modules = {};
380
380
  }
381
+ if (result.plugins === null ||
382
+ typeof result.plugins !== 'object' ||
383
+ Array.isArray(result.plugins)) {
384
+ result.plugins = {};
385
+ }
381
386
  return result;
382
387
  }
383
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diviops/mcp-server",
3
- "version": "1.5.31",
3
+ "version": "1.5.32",
4
4
  "description": "MCP server exposing Divi 5 Visual Builder as tools for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "build": "tsc",
22
22
  "start": "node dist/index.js",
23
23
  "dev": "tsc --watch",
24
- "test": "npm run build && node --test \"dist/preset-cli/__tests__/*.test.js\" \"dist/cross-env-preflight/__tests__/*.test.js\"",
24
+ "test": "npm run build && node --test \"dist/__tests__/*.test.js\" \"dist/preset-cli/__tests__/*.test.js\" \"dist/cross-env-preflight/__tests__/*.test.js\"",
25
25
  "prepublishOnly": "npm run build",
26
26
  "regen:skill": "node scripts/regen-module-formats.mjs"
27
27
  },