@diviops/mcp-server 1.5.32 → 1.5.34
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 +18 -5
- package/dist/index.js +397 -20
- package/dist/wp-cli.d.ts +10 -0
- package/dist/wp-cli.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ DiviOps fits multiple WordPress workflows where AI-driven authoring + management
|
|
|
16
16
|
- **SCF setup + management** — provision Secure Custom Fields field groups, sync schemas, export/import field group definitions; SCF data model becomes a tool surface, not an admin-UI flow.
|
|
17
17
|
- **CPT + post population** — register custom post types via wp-cli passthrough; bulk-populate posts and pages across any post type, not just Divi-built ones.
|
|
18
18
|
- **Data model reasoning** — schema introspection across Divi modules + SCF field groups + post meta; ask Claude what fields a post type carries, what attributes a module accepts, what tokens are defined.
|
|
19
|
-
- **WordPress site auditing** — preset audits, design-token usage scans, orphan detection (presets, variables, dangling references); broader site surveys via wp-cli (`wp option list`, `wp post list --format=json`, `wp user list`).
|
|
19
|
+
- **WordPress site auditing** — preset audits, design-token usage scans, orphan detection (presets, variables, dangling references); broader site surveys via wp-cli (`wp option list`, `wp post list --format=json`, `wp post term list <id> <taxonomy> --format=json`, `wp user list`).
|
|
20
20
|
- **Hybrid sites (Divi + custom PHP)** — Divi authors the marketing pages; custom PHP templates handle dynamic ones (CPT listings, single-post views, member portals); design tokens harmonized across both surfaces via CSS custom properties driven from the Divi variable system.
|
|
21
21
|
|
|
22
22
|
## Quick start
|
|
@@ -25,9 +25,9 @@ Three steps to your first tool call.
|
|
|
25
25
|
|
|
26
26
|
### 1. Install the WordPress plugin
|
|
27
27
|
|
|
28
|
-
Download and activate the **DiviOps Agent** plugin
|
|
28
|
+
Download and activate the **DiviOps Agent** plugin from WordPress.org once it is listed there. For pre-listing test packages or a manual fallback install, use the [direct zip](https://github.com/oaris-dev/diviops/raw/main/diviops-agent.zip) or browse the [public distribution repo](https://github.com/oaris-dev/diviops). Requires Divi 5.1+ on WordPress 6.5+.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
The npm MCP server updates through npm. WordPress.org installs of the Free plugin update through the normal WordPress plugin update flow. For pre-listing test packages or a manual fallback install, replace `diviops-agent.zip` through **WP Admin → Plugins → Add New → Upload Plugin** and choose **Replace current with uploaded**.
|
|
31
31
|
|
|
32
32
|
### 2. Create an Application Password
|
|
33
33
|
|
|
@@ -83,13 +83,14 @@ 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 **
|
|
86
|
+
The server exposes **90 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
|
|----------|----------|---------------|
|
|
90
90
|
| Page authoring | Create, edit, restructure pages | `page_*`, `section_*`, `module_*` |
|
|
91
91
|
| Design system | Manage colors, fonts, variables, presets | `variable_*`, `global_color_*`, `global_font_*`, `preset_*` |
|
|
92
92
|
| Library + templates | Reusable layouts + Theme Builder | `library_*`, `template_*`, `tb_*` |
|
|
93
|
+
| WordPress menus | Author reusable nav menus and theme-location assignments | `menu_*` |
|
|
93
94
|
| Schema introspection | Module attribute discovery | `schema_*` |
|
|
94
95
|
| Canvas / off-canvas | Popups, modals, menus | `canvas_*` |
|
|
95
96
|
| SCF integration | Secure Custom Fields sync | `scf_*` |
|
|
@@ -283,7 +284,19 @@ Every write tool accepts `dry_run: boolean` (default `false`). When `true`, the
|
|
|
283
284
|
}
|
|
284
285
|
```
|
|
285
286
|
|
|
286
|
-
`meta_wp_cli` and `scf_import` do not accept `dry_run` (raw passthrough / upstream gap respectively). For bulk preview-then-commit flows (preset reassign, preset cleanup), see [safety-patterns.md](../docs/safety-patterns.md).
|
|
287
|
+
`meta_wp_cli` and `scf_import` do not accept `dry_run` (raw passthrough / upstream gap respectively). `scf_sync` passes `dry_run` through to upstream `wp scf json sync --dry-run`, so its preview is the upstream plain-text summary rather than a plugin-built `data.plan`. For bulk preview-then-commit flows (preset reassign, preset cleanup), see [safety-patterns.md](../docs/safety-patterns.md).
|
|
288
|
+
|
|
289
|
+
Selected guarded post-content write tools also accept `backup: true`. In apply
|
|
290
|
+
mode the Free plugin stores an option-backed rollback snapshot before writing
|
|
291
|
+
and returns `data.backup` evidence with the snapshot id and status. With
|
|
292
|
+
`dry_run: true`, `backup: true` only reports the planned snapshot; it never
|
|
293
|
+
creates an option record.
|
|
294
|
+
|
|
295
|
+
`diviops_rollback_snapshot_restore` restores those snapshots only to their
|
|
296
|
+
captured post/page or Theme Builder layout target. It requires row-level edit
|
|
297
|
+
permission, refuses content or supported Divi post-meta drift before mutation,
|
|
298
|
+
uses the same full-content integrity/readback guard, and has no force override
|
|
299
|
+
or second pre-restore snapshot in this MVP.
|
|
287
300
|
|
|
288
301
|
### `_meta.idempotent` markers
|
|
289
302
|
|
package/dist/index.js
CHANGED
|
@@ -279,6 +279,24 @@ function requireCapability(key) {
|
|
|
279
279
|
throw new MissingCapabilityError(key, handshakeState.pluginVersion);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
+
function backupCapabilityError(toolName, backup) {
|
|
283
|
+
if (!backup)
|
|
284
|
+
return null;
|
|
285
|
+
const key = toolName.replace(/^diviops_/, "") + "_backup";
|
|
286
|
+
try {
|
|
287
|
+
requireCapability(key);
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
if (e instanceof MissingCapabilityError) {
|
|
291
|
+
return {
|
|
292
|
+
content: [{ type: "text", text: e.message }],
|
|
293
|
+
isError: true,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
throw e;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
282
300
|
// `any` here is deliberate, not laziness. McpServer.registerTool is a
|
|
283
301
|
// multi-overload generic whose `cb`/`InputArgs` machinery doesn't compose
|
|
284
302
|
// with `Parameters<typeof server.registerTool>` (overload collapse to
|
|
@@ -399,6 +417,11 @@ const DRY_RUN_FIELD = z
|
|
|
399
417
|
.optional()
|
|
400
418
|
.default(false)
|
|
401
419
|
.describe("When true, return the change plan { summary, changes[, warnings] } without mutating state.");
|
|
420
|
+
const BACKUP_FIELD = z
|
|
421
|
+
.boolean()
|
|
422
|
+
.optional()
|
|
423
|
+
.default(false)
|
|
424
|
+
.describe("When true on supported content writes, capture a rollback snapshot before applying. dry_run + backup only reports the planned snapshot and does not create one.");
|
|
402
425
|
// ── Read Tools ───────────────────────────────────────────────────────
|
|
403
426
|
registerPluginTool("diviops_page_list", {
|
|
404
427
|
description: "List pages/posts in the WordPress site. Returns title, ID, URL, status, and whether each page uses Divi builder. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
@@ -523,6 +546,146 @@ registerPluginTool("diviops_module_get", {
|
|
|
523
546
|
],
|
|
524
547
|
};
|
|
525
548
|
});
|
|
549
|
+
registerPluginTool("diviops_menu_list", {
|
|
550
|
+
description: "List WordPress nav menus, registered theme locations, and current location assignments. Free/core, read-only. Requires the WordPress user to have edit_theme_options. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { menus[], count, registered_locations, assigned_locations }.",
|
|
551
|
+
annotations: { idempotentHint: true },
|
|
552
|
+
_meta: { idempotent: "true" },
|
|
553
|
+
}, async () => {
|
|
554
|
+
const result = await wp.requestEnveloped("/menu/list");
|
|
555
|
+
return {
|
|
556
|
+
content: [
|
|
557
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_list") },
|
|
558
|
+
],
|
|
559
|
+
};
|
|
560
|
+
});
|
|
561
|
+
registerPluginTool("diviops_menu_get", {
|
|
562
|
+
description: "Fetch one WordPress nav menu with normalized flat items and a nested item tree. Free/core, read-only. Requires edit_theme_options. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing menu_id returns not_found.",
|
|
563
|
+
inputSchema: {
|
|
564
|
+
menu_id: z.number().int().positive().describe("WordPress nav menu term ID"),
|
|
565
|
+
},
|
|
566
|
+
annotations: { idempotentHint: true },
|
|
567
|
+
_meta: { idempotent: "true" },
|
|
568
|
+
}, async ({ menu_id }) => {
|
|
569
|
+
const result = await wp.requestEnveloped(`/menu/get/${menu_id}`);
|
|
570
|
+
return {
|
|
571
|
+
content: [
|
|
572
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_get") },
|
|
573
|
+
],
|
|
574
|
+
};
|
|
575
|
+
});
|
|
576
|
+
registerPluginTool("diviops_menu_create", {
|
|
577
|
+
description: "Create a WordPress nav menu by name, optionally with a requested slug. Free/core single-site menu authoring primitive. Requires edit_theme_options. Existing same-name or same-slug menus return ok:true with noop:true instead of creating duplicates. Does not assign the menu to a location; follow with diviops_menu_location_assign. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }." +
|
|
578
|
+
DRY_RUN_DESC_SUFFIX,
|
|
579
|
+
inputSchema: {
|
|
580
|
+
name: z.string().min(1).describe("Menu display name, e.g. Primary"),
|
|
581
|
+
slug: z.string().optional().describe("Optional sanitized menu slug. Omit to let WordPress derive it."),
|
|
582
|
+
dry_run: DRY_RUN_FIELD,
|
|
583
|
+
},
|
|
584
|
+
annotations: { idempotentHint: true },
|
|
585
|
+
_meta: { idempotent: "true" },
|
|
586
|
+
}, async ({ name, slug, dry_run }) => {
|
|
587
|
+
const body = { name };
|
|
588
|
+
if (slug !== undefined)
|
|
589
|
+
body.slug = slug;
|
|
590
|
+
if (dry_run)
|
|
591
|
+
body.dry_run = true;
|
|
592
|
+
const result = await wp.requestEnveloped("/menu/create", {
|
|
593
|
+
method: "POST",
|
|
594
|
+
body,
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
content: [
|
|
598
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_create") },
|
|
599
|
+
],
|
|
600
|
+
};
|
|
601
|
+
});
|
|
602
|
+
registerPluginTool("diviops_menu_item_add_page", {
|
|
603
|
+
description: "Append a readable published page to an existing WordPress nav menu. Free/core single-site menu authoring primitive. Requires edit_theme_options plus read access to the page. Validates menu, page status/visibility, and optional parent menu item. Existing same page under the same parent returns noop:true; a different existing label returns conflict because item-update/reorder are deferred. No delete, reorder, or broad reconcile path. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }." +
|
|
604
|
+
DRY_RUN_DESC_SUFFIX,
|
|
605
|
+
inputSchema: {
|
|
606
|
+
menu_id: z.number().int().positive().describe("WordPress nav menu term ID"),
|
|
607
|
+
page_id: z.number().int().positive().describe("Published page ID to add"),
|
|
608
|
+
label: z.string().optional().describe("Optional menu label. Defaults to the page title."),
|
|
609
|
+
parent_item_id: z.number().int().min(0).optional().default(0).describe("Optional parent menu item ID from diviops_menu_get; 0 for top level."),
|
|
610
|
+
dry_run: DRY_RUN_FIELD,
|
|
611
|
+
},
|
|
612
|
+
annotations: { idempotentHint: true },
|
|
613
|
+
_meta: { idempotent: "true" },
|
|
614
|
+
}, async ({ menu_id, page_id, label, parent_item_id, dry_run }) => {
|
|
615
|
+
const body = {
|
|
616
|
+
menu_id,
|
|
617
|
+
page_id,
|
|
618
|
+
parent_item_id: parent_item_id ?? 0,
|
|
619
|
+
};
|
|
620
|
+
if (label !== undefined)
|
|
621
|
+
body.label = label;
|
|
622
|
+
if (dry_run)
|
|
623
|
+
body.dry_run = true;
|
|
624
|
+
const result = await wp.requestEnveloped("/menu/item/add-page", {
|
|
625
|
+
method: "POST",
|
|
626
|
+
body,
|
|
627
|
+
});
|
|
628
|
+
return {
|
|
629
|
+
content: [
|
|
630
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_item_add_page") },
|
|
631
|
+
],
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
registerPluginTool("diviops_menu_item_add_custom", {
|
|
635
|
+
description: "Append a custom URL item to an existing WordPress nav menu. Free/core single-site menu authoring primitive. Requires edit_theme_options. URL validation allows only http, https, root-relative paths, same-page hashes, mailto, and tel; protocol-relative/javascript/data URLs are rejected. Existing same URL under the same parent with the same label returns noop:true. No delete, reorder, or broad reconcile path. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }." +
|
|
636
|
+
DRY_RUN_DESC_SUFFIX,
|
|
637
|
+
inputSchema: {
|
|
638
|
+
menu_id: z.number().int().positive().describe("WordPress nav menu term ID"),
|
|
639
|
+
label: z.string().min(1).describe("Menu item label"),
|
|
640
|
+
url: z.string().min(1).describe("Allowed URL: http(s), root-relative path, #hash, mailto, or tel"),
|
|
641
|
+
parent_item_id: z.number().int().min(0).optional().default(0).describe("Optional parent menu item ID from diviops_menu_get; 0 for top level."),
|
|
642
|
+
dry_run: DRY_RUN_FIELD,
|
|
643
|
+
},
|
|
644
|
+
annotations: { idempotentHint: true },
|
|
645
|
+
_meta: { idempotent: "true" },
|
|
646
|
+
}, async ({ menu_id, label, url, parent_item_id, dry_run }) => {
|
|
647
|
+
const body = {
|
|
648
|
+
menu_id,
|
|
649
|
+
label,
|
|
650
|
+
url,
|
|
651
|
+
parent_item_id: parent_item_id ?? 0,
|
|
652
|
+
};
|
|
653
|
+
if (dry_run)
|
|
654
|
+
body.dry_run = true;
|
|
655
|
+
const result = await wp.requestEnveloped("/menu/item/add-custom", {
|
|
656
|
+
method: "POST",
|
|
657
|
+
body,
|
|
658
|
+
});
|
|
659
|
+
return {
|
|
660
|
+
content: [
|
|
661
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_item_add_custom") },
|
|
662
|
+
],
|
|
663
|
+
};
|
|
664
|
+
});
|
|
665
|
+
registerPluginTool("diviops_menu_location_assign", {
|
|
666
|
+
description: "Assign an existing WordPress nav menu to a registered theme location discovered from the current theme. Free/core single-site menu authoring primitive. Requires edit_theme_options. Rejects arbitrary location strings; call diviops_menu_list first and use data.registered_locations keys. Reassigning the same menu/location returns noop:true. No location removal path in this MVP. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }." +
|
|
667
|
+
DRY_RUN_DESC_SUFFIX,
|
|
668
|
+
inputSchema: {
|
|
669
|
+
menu_id: z.number().int().positive().describe("WordPress nav menu term ID"),
|
|
670
|
+
location: z.string().min(1).describe("Registered theme location key from diviops_menu_list"),
|
|
671
|
+
dry_run: DRY_RUN_FIELD,
|
|
672
|
+
},
|
|
673
|
+
annotations: { idempotentHint: true },
|
|
674
|
+
_meta: { idempotent: "true" },
|
|
675
|
+
}, async ({ menu_id, location, dry_run }) => {
|
|
676
|
+
const body = { menu_id, location };
|
|
677
|
+
if (dry_run)
|
|
678
|
+
body.dry_run = true;
|
|
679
|
+
const result = await wp.requestEnveloped("/menu/location/assign", {
|
|
680
|
+
method: "POST",
|
|
681
|
+
body,
|
|
682
|
+
});
|
|
683
|
+
return {
|
|
684
|
+
content: [
|
|
685
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_menu_location_assign") },
|
|
686
|
+
],
|
|
687
|
+
};
|
|
688
|
+
});
|
|
526
689
|
registerPluginTool("diviops_schema_list_modules", {
|
|
527
690
|
description: "List all available Divi modules (block types) with their names, titles, and categories. Use this to discover what modules can be used in layouts. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
528
691
|
annotations: { idempotentHint: true },
|
|
@@ -602,7 +765,7 @@ registerPluginTool("diviops_schema_get_module", {
|
|
|
602
765
|
};
|
|
603
766
|
});
|
|
604
767
|
registerPluginTool("diviops_schema_get_settings", {
|
|
605
|
-
description: "Get Divi site settings including
|
|
768
|
+
description: "Get Divi site settings including site info, builder version, and a narrow public allowlist of non-sensitive Divi theme options (fonts, colors, sizes). Useful for understanding the site context before generating content. Does not expose the raw `et_divi` option bag. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
606
769
|
annotations: { idempotentHint: true },
|
|
607
770
|
_meta: { idempotent: "true" },
|
|
608
771
|
}, async () => {
|
|
@@ -965,16 +1128,22 @@ registerPluginTool("diviops_page_update_content", {
|
|
|
965
1128
|
.string()
|
|
966
1129
|
.describe("Full page content in WordPress block markup format (<!-- wp:divi/section -->...<!-- /wp:divi/section -->)"),
|
|
967
1130
|
dry_run: DRY_RUN_FIELD,
|
|
1131
|
+
backup: BACKUP_FIELD,
|
|
968
1132
|
},
|
|
969
1133
|
annotations: { idempotentHint: false },
|
|
970
1134
|
_meta: { idempotent: "conditional" },
|
|
971
|
-
}, async ({ page_id, content, dry_run }) => {
|
|
1135
|
+
}, async ({ page_id, content, dry_run, backup }) => {
|
|
1136
|
+
const backupGate = backupCapabilityError("diviops_page_update_content", backup);
|
|
1137
|
+
if (backupGate)
|
|
1138
|
+
return backupGate;
|
|
972
1139
|
const hits = findForeignVarRefs(content, "content");
|
|
973
1140
|
if (hits.length > 0)
|
|
974
1141
|
return isolationErrorResult("diviops_page_update_content", hits);
|
|
975
1142
|
const body = { content };
|
|
976
1143
|
if (dry_run)
|
|
977
1144
|
body.dry_run = true;
|
|
1145
|
+
if (backup)
|
|
1146
|
+
body.backup = true;
|
|
978
1147
|
const result = await wp.requestEnveloped(`/page/update-content/${page_id}`, {
|
|
979
1148
|
method: "POST",
|
|
980
1149
|
body,
|
|
@@ -985,6 +1154,64 @@ registerPluginTool("diviops_page_update_content", {
|
|
|
985
1154
|
],
|
|
986
1155
|
};
|
|
987
1156
|
});
|
|
1157
|
+
registerPluginTool("diviops_page_update_meta", {
|
|
1158
|
+
description: "Update page/post metadata fields without touching post_content. Supports title, slug, parent, and menu_order; use diviops_page_update_status for status changes. Slug input must already be in sanitized WordPress post_name form. When a published post's slug changes, preserve_old_slug defaults to true and records the previous slug in _wp_old_slug so WordPress old-slug redirects can work. Returns readback fields after apply. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing page_id or invalid parent returns 'not_found', edit-permission failures return 'forbidden' (HTTP 403), invalid/empty slug or malformed field values return 'invalid_input' with `error.data` documenting the field and sanitized slug where relevant." +
|
|
1159
|
+
DRY_RUN_DESC_SUFFIX,
|
|
1160
|
+
inputSchema: {
|
|
1161
|
+
page_id: z.number().int().describe("WordPress post/page ID to update"),
|
|
1162
|
+
title: z
|
|
1163
|
+
.string()
|
|
1164
|
+
.optional()
|
|
1165
|
+
.describe("New post_title. Omit to leave unchanged."),
|
|
1166
|
+
slug: z
|
|
1167
|
+
.string()
|
|
1168
|
+
.optional()
|
|
1169
|
+
.describe("New post_name. Must already be sanitized, e.g. 'legal-notice'."),
|
|
1170
|
+
parent: z
|
|
1171
|
+
.number()
|
|
1172
|
+
.int()
|
|
1173
|
+
.min(0)
|
|
1174
|
+
.optional()
|
|
1175
|
+
.describe("New post_parent. Use 0 for no parent."),
|
|
1176
|
+
menu_order: z
|
|
1177
|
+
.number()
|
|
1178
|
+
.int()
|
|
1179
|
+
.min(0)
|
|
1180
|
+
.optional()
|
|
1181
|
+
.describe("New menu_order value."),
|
|
1182
|
+
preserve_old_slug: z
|
|
1183
|
+
.boolean()
|
|
1184
|
+
.optional()
|
|
1185
|
+
.default(true)
|
|
1186
|
+
.describe("When true, record the previous slug in _wp_old_slug for published posts when slug changes."),
|
|
1187
|
+
dry_run: DRY_RUN_FIELD,
|
|
1188
|
+
},
|
|
1189
|
+
annotations: { idempotentHint: true },
|
|
1190
|
+
_meta: { idempotent: "true" },
|
|
1191
|
+
}, async ({ page_id, title, slug, parent, menu_order, preserve_old_slug, dry_run }) => {
|
|
1192
|
+
const body = {
|
|
1193
|
+
preserve_old_slug: preserve_old_slug ?? true,
|
|
1194
|
+
};
|
|
1195
|
+
if (title !== undefined)
|
|
1196
|
+
body.title = title;
|
|
1197
|
+
if (slug !== undefined)
|
|
1198
|
+
body.slug = slug;
|
|
1199
|
+
if (parent !== undefined)
|
|
1200
|
+
body.parent = parent;
|
|
1201
|
+
if (menu_order !== undefined)
|
|
1202
|
+
body.menu_order = menu_order;
|
|
1203
|
+
if (dry_run)
|
|
1204
|
+
body.dry_run = true;
|
|
1205
|
+
const result = await wp.requestEnveloped(`/page/update-meta/${page_id}`, {
|
|
1206
|
+
method: "POST",
|
|
1207
|
+
body,
|
|
1208
|
+
});
|
|
1209
|
+
return {
|
|
1210
|
+
content: [
|
|
1211
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_page_update_meta") },
|
|
1212
|
+
],
|
|
1213
|
+
};
|
|
1214
|
+
});
|
|
988
1215
|
registerPluginTool("diviops_render_preview", {
|
|
989
1216
|
description: "Render Divi block markup to HTML. Accepts EITHER inline `content` (string of block markup) OR `page_id` (loads `post_content` from the DB, requires edit_post capability on the page — useful for previewing shipped pages without round-tripping the markup blob). Provide exactly one. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { rendered_html: string }. Errors map to `invalid_input` (neither/both supplied, or invalid page_id), `forbidden` (caller lacks edit_post on the page), `not_found` (page_id does not exist), or `divi_error` (parser/render exception, with truncated message and full detail in `error.data.detail`).",
|
|
990
1217
|
inputSchema: {
|
|
@@ -1079,16 +1306,22 @@ registerPluginTool("diviops_section_append", {
|
|
|
1079
1306
|
.default("end")
|
|
1080
1307
|
.describe('Where to insert: "start" or "end" (default)'),
|
|
1081
1308
|
dry_run: DRY_RUN_FIELD,
|
|
1309
|
+
backup: BACKUP_FIELD,
|
|
1082
1310
|
},
|
|
1083
1311
|
annotations: { idempotentHint: false },
|
|
1084
1312
|
_meta: { idempotent: "false" },
|
|
1085
|
-
}, async ({ page_id, content, position, dry_run }) => {
|
|
1313
|
+
}, async ({ page_id, content, position, dry_run, backup }) => {
|
|
1314
|
+
const backupGate = backupCapabilityError("diviops_section_append", backup);
|
|
1315
|
+
if (backupGate)
|
|
1316
|
+
return backupGate;
|
|
1086
1317
|
const hits = findForeignVarRefs(content, "content");
|
|
1087
1318
|
if (hits.length > 0)
|
|
1088
1319
|
return isolationErrorResult("diviops_section_append", hits);
|
|
1089
1320
|
const body = { content, position: position ?? "end" };
|
|
1090
1321
|
if (dry_run)
|
|
1091
1322
|
body.dry_run = true;
|
|
1323
|
+
if (backup)
|
|
1324
|
+
body.backup = true;
|
|
1092
1325
|
const result = await wp.requestEnveloped(`/section/append/${page_id}`, {
|
|
1093
1326
|
method: "POST",
|
|
1094
1327
|
body,
|
|
@@ -1123,10 +1356,14 @@ registerPluginTool("diviops_section_replace", {
|
|
|
1123
1356
|
.default(1)
|
|
1124
1357
|
.describe("Which match to target (1-based, default: 1)"),
|
|
1125
1358
|
dry_run: DRY_RUN_FIELD,
|
|
1359
|
+
backup: BACKUP_FIELD,
|
|
1126
1360
|
},
|
|
1127
1361
|
annotations: { idempotentHint: false },
|
|
1128
1362
|
_meta: { idempotent: "conditional" },
|
|
1129
|
-
}, async ({ page_id, label, match_text, content, occurrence, dry_run }) => {
|
|
1363
|
+
}, async ({ page_id, label, match_text, content, occurrence, dry_run, backup }) => {
|
|
1364
|
+
const backupGate = backupCapabilityError("diviops_section_replace", backup);
|
|
1365
|
+
if (backupGate)
|
|
1366
|
+
return backupGate;
|
|
1130
1367
|
const hits = findForeignVarRefs(content, "content");
|
|
1131
1368
|
if (hits.length > 0)
|
|
1132
1369
|
return isolationErrorResult("diviops_section_replace", hits);
|
|
@@ -1137,6 +1374,8 @@ registerPluginTool("diviops_section_replace", {
|
|
|
1137
1374
|
body.match_text = match_text;
|
|
1138
1375
|
if (dry_run)
|
|
1139
1376
|
body.dry_run = true;
|
|
1377
|
+
if (backup)
|
|
1378
|
+
body.backup = true;
|
|
1140
1379
|
const result = await wp.requestEnveloped(`/section/replace/${page_id}`, {
|
|
1141
1380
|
method: "POST",
|
|
1142
1381
|
body,
|
|
@@ -1168,10 +1407,14 @@ registerPluginTool("diviops_section_remove", {
|
|
|
1168
1407
|
.default(1)
|
|
1169
1408
|
.describe("Which match to target (1-based, default: 1)"),
|
|
1170
1409
|
dry_run: DRY_RUN_FIELD,
|
|
1410
|
+
backup: BACKUP_FIELD,
|
|
1171
1411
|
},
|
|
1172
1412
|
annotations: { idempotentHint: true },
|
|
1173
1413
|
_meta: { idempotent: "true" },
|
|
1174
|
-
}, async ({ page_id, label, match_text, occurrence, dry_run }) => {
|
|
1414
|
+
}, async ({ page_id, label, match_text, occurrence, dry_run, backup }) => {
|
|
1415
|
+
const backupGate = backupCapabilityError("diviops_section_remove", backup);
|
|
1416
|
+
if (backupGate)
|
|
1417
|
+
return backupGate;
|
|
1175
1418
|
const body = { occurrence };
|
|
1176
1419
|
if (label)
|
|
1177
1420
|
body.label = label;
|
|
@@ -1179,6 +1422,8 @@ registerPluginTool("diviops_section_remove", {
|
|
|
1179
1422
|
body.match_text = match_text;
|
|
1180
1423
|
if (dry_run)
|
|
1181
1424
|
body.dry_run = true;
|
|
1425
|
+
if (backup)
|
|
1426
|
+
body.backup = true;
|
|
1182
1427
|
const result = await wp.requestEnveloped(`/section/remove/${page_id}`, {
|
|
1183
1428
|
method: "POST",
|
|
1184
1429
|
body,
|
|
@@ -1226,7 +1471,7 @@ registerPluginTool("diviops_section_get", {
|
|
|
1226
1471
|
};
|
|
1227
1472
|
});
|
|
1228
1473
|
registerPluginTool("diviops_module_update", {
|
|
1229
|
-
description: 'Update specific attributes of a module. Target by auto_index (e.g. "text:5"), admin label, or text content. Uses dot notation for attribute paths. Example: {"content.decoration.headingFont.h2.font.desktop.value.color": "#ff0000"}. For paths whose key segments contain literal dots — notably Composable Settings preset slots like groupPreset["title.decoration.spacing"] — escape the inner dots with `\\.` to keep the segment intact: {"groupPreset.title\\\\.decoration\\\\.spacing.presetId": ["uuid"]}. Priority: auto_index > label > match_text. Use occurrence with label when duplicates exist. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing module returns code "not_found" with error.data = { target_kind: "module", target_mode, target_value, page_id }, non-array attrs returns code "invalid_input" with error.data.field = "attrs", malformed Divi block markup surfaces code "divi_error" (HTTP 500).' +
|
|
1474
|
+
description: 'Update specific attributes of a module. Target by auto_index (e.g. "text:5"), admin label, or text content. Uses dot notation for attribute paths. Example: {"content.decoration.headingFont.h2.font.desktop.value.color": "#ff0000"}. For paths whose key segments contain literal dots — notably Composable Settings preset slots like groupPreset["title.decoration.spacing"] — escape the inner dots with `\\.` to keep the segment intact: {"groupPreset.title\\\\.decoration\\\\.spacing.presetId": ["uuid"]}. Priority: auto_index > label > match_text. Use occurrence with label when duplicates exist. match_text is a convenience selector: for generic or repeated visible text, prefer auto_index from diviops_page_get_layout/module_get. Content-slot mismatches such as writing a heading `title.innerContent` path into a matched divi/text block are rejected with invalid_input instead of silently storing never-rendered attrs. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing module returns code "not_found" with error.data = { target_kind: "module", target_mode, target_value, page_id }, non-array attrs returns code "invalid_input" with error.data.field = "attrs", malformed Divi block markup surfaces code "divi_error" (HTTP 500).' +
|
|
1230
1475
|
DRY_RUN_DESC_SUFFIX,
|
|
1231
1476
|
inputSchema: {
|
|
1232
1477
|
page_id: z.number().describe("WordPress post/page ID"),
|
|
@@ -1253,10 +1498,14 @@ registerPluginTool("diviops_module_update", {
|
|
|
1253
1498
|
.record(z.string(), z.any())
|
|
1254
1499
|
.describe("Attribute paths (dot notation) and their new values"),
|
|
1255
1500
|
dry_run: DRY_RUN_FIELD,
|
|
1501
|
+
backup: BACKUP_FIELD,
|
|
1256
1502
|
},
|
|
1257
1503
|
annotations: { idempotentHint: false },
|
|
1258
1504
|
_meta: { idempotent: "conditional" },
|
|
1259
|
-
}, async ({ page_id, label, match_text, auto_index, occurrence, attrs, dry_run }) => {
|
|
1505
|
+
}, async ({ page_id, label, match_text, auto_index, occurrence, attrs, dry_run, backup }) => {
|
|
1506
|
+
const backupGate = backupCapabilityError("diviops_module_update", backup);
|
|
1507
|
+
if (backupGate)
|
|
1508
|
+
return backupGate;
|
|
1260
1509
|
const hits = scanAttrsForForeignVarRefs(attrs);
|
|
1261
1510
|
if (hits.length > 0)
|
|
1262
1511
|
return isolationErrorResult("diviops_module_update", hits);
|
|
@@ -1271,6 +1520,8 @@ registerPluginTool("diviops_module_update", {
|
|
|
1271
1520
|
body.occurrence = occurrence;
|
|
1272
1521
|
if (dry_run)
|
|
1273
1522
|
body.dry_run = true;
|
|
1523
|
+
if (backup)
|
|
1524
|
+
body.backup = true;
|
|
1274
1525
|
const result = await wp.requestEnveloped(`/module/update/${page_id}`, {
|
|
1275
1526
|
method: "POST",
|
|
1276
1527
|
body,
|
|
@@ -1328,10 +1579,14 @@ registerPluginTool("diviops_module_move", {
|
|
|
1328
1579
|
.enum(["before", "after"])
|
|
1329
1580
|
.describe("Place the source before or after the target"),
|
|
1330
1581
|
dry_run: DRY_RUN_FIELD,
|
|
1582
|
+
backup: BACKUP_FIELD,
|
|
1331
1583
|
},
|
|
1332
1584
|
annotations: { idempotentHint: false },
|
|
1333
1585
|
_meta: { idempotent: "conditional" },
|
|
1334
|
-
}, async ({ page_id, source_label, source_match_text, source_auto_index, source_occurrence, target_label, target_match_text, target_auto_index, target_occurrence, position, dry_run, }) => {
|
|
1586
|
+
}, async ({ page_id, source_label, source_match_text, source_auto_index, source_occurrence, target_label, target_match_text, target_auto_index, target_occurrence, position, dry_run, backup, }) => {
|
|
1587
|
+
const backupGate = backupCapabilityError("diviops_module_move", backup);
|
|
1588
|
+
if (backupGate)
|
|
1589
|
+
return backupGate;
|
|
1335
1590
|
const body = { position };
|
|
1336
1591
|
if (source_label)
|
|
1337
1592
|
body.source_label = source_label;
|
|
@@ -1351,6 +1606,8 @@ registerPluginTool("diviops_module_move", {
|
|
|
1351
1606
|
body.target_occurrence = target_occurrence;
|
|
1352
1607
|
if (dry_run)
|
|
1353
1608
|
body.dry_run = true;
|
|
1609
|
+
if (backup)
|
|
1610
|
+
body.backup = true;
|
|
1354
1611
|
const result = await wp.requestEnveloped(`/module/move/${page_id}`, {
|
|
1355
1612
|
method: "POST",
|
|
1356
1613
|
body,
|
|
@@ -1371,10 +1628,14 @@ registerPluginTool("diviops_module_lock", {
|
|
|
1371
1628
|
auto_index: z.string().optional().describe('Auto-index in "type:N" format (e.g. "text:3")'),
|
|
1372
1629
|
occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
|
|
1373
1630
|
dry_run: DRY_RUN_FIELD,
|
|
1631
|
+
backup: BACKUP_FIELD,
|
|
1374
1632
|
},
|
|
1375
1633
|
annotations: { idempotentHint: false },
|
|
1376
1634
|
_meta: { idempotent: "false" },
|
|
1377
|
-
}, async ({ page_id, label, match_text, auto_index, occurrence, dry_run }) => {
|
|
1635
|
+
}, async ({ page_id, label, match_text, auto_index, occurrence, dry_run, backup }) => {
|
|
1636
|
+
const backupGate = backupCapabilityError("diviops_module_lock", backup);
|
|
1637
|
+
if (backupGate)
|
|
1638
|
+
return backupGate;
|
|
1378
1639
|
const body = {};
|
|
1379
1640
|
if (label)
|
|
1380
1641
|
body.label = label;
|
|
@@ -1386,6 +1647,8 @@ registerPluginTool("diviops_module_lock", {
|
|
|
1386
1647
|
body.occurrence = occurrence;
|
|
1387
1648
|
if (dry_run)
|
|
1388
1649
|
body.dry_run = true;
|
|
1650
|
+
if (backup)
|
|
1651
|
+
body.backup = true;
|
|
1389
1652
|
const result = await wp.requestEnveloped(`/module/lock/${page_id}`, { method: "POST", body });
|
|
1390
1653
|
return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_lock") }] };
|
|
1391
1654
|
});
|
|
@@ -1399,10 +1662,14 @@ registerPluginTool("diviops_module_unlock", {
|
|
|
1399
1662
|
auto_index: z.string().optional().describe('Auto-index in "type:N" format'),
|
|
1400
1663
|
occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
|
|
1401
1664
|
dry_run: DRY_RUN_FIELD,
|
|
1665
|
+
backup: BACKUP_FIELD,
|
|
1402
1666
|
},
|
|
1403
1667
|
annotations: { idempotentHint: false },
|
|
1404
1668
|
_meta: { idempotent: "false" },
|
|
1405
|
-
}, async ({ page_id, label, match_text, auto_index, occurrence, dry_run }) => {
|
|
1669
|
+
}, async ({ page_id, label, match_text, auto_index, occurrence, dry_run, backup }) => {
|
|
1670
|
+
const backupGate = backupCapabilityError("diviops_module_unlock", backup);
|
|
1671
|
+
if (backupGate)
|
|
1672
|
+
return backupGate;
|
|
1406
1673
|
const body = {};
|
|
1407
1674
|
if (label)
|
|
1408
1675
|
body.label = label;
|
|
@@ -1414,6 +1681,8 @@ registerPluginTool("diviops_module_unlock", {
|
|
|
1414
1681
|
body.occurrence = occurrence;
|
|
1415
1682
|
if (dry_run)
|
|
1416
1683
|
body.dry_run = true;
|
|
1684
|
+
if (backup)
|
|
1685
|
+
body.backup = true;
|
|
1417
1686
|
const result = await wp.requestEnveloped(`/module/unlock/${page_id}`, { method: "POST", body });
|
|
1418
1687
|
return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_unlock") }] };
|
|
1419
1688
|
});
|
|
@@ -1428,10 +1697,14 @@ registerPluginTool("diviops_module_clone", {
|
|
|
1428
1697
|
occurrence: z.number().int().min(1).optional().default(1).describe("Which occurrence when multiple modules share the same label (1-based)"),
|
|
1429
1698
|
position: z.enum(["before", "after"]).optional().default("after").describe('Place the clone "before" or "after" the source module within its parent.'),
|
|
1430
1699
|
dry_run: DRY_RUN_FIELD,
|
|
1700
|
+
backup: BACKUP_FIELD,
|
|
1431
1701
|
},
|
|
1432
1702
|
annotations: { idempotentHint: false },
|
|
1433
1703
|
_meta: { idempotent: "false" },
|
|
1434
|
-
}, async ({ page_id, label, match_text, auto_index, occurrence, position, dry_run }) => {
|
|
1704
|
+
}, async ({ page_id, label, match_text, auto_index, occurrence, position, dry_run, backup }) => {
|
|
1705
|
+
const backupGate = backupCapabilityError("diviops_module_clone", backup);
|
|
1706
|
+
if (backupGate)
|
|
1707
|
+
return backupGate;
|
|
1435
1708
|
const body = {};
|
|
1436
1709
|
if (label)
|
|
1437
1710
|
body.label = label;
|
|
@@ -1445,6 +1718,8 @@ registerPluginTool("diviops_module_clone", {
|
|
|
1445
1718
|
body.position = position;
|
|
1446
1719
|
if (dry_run)
|
|
1447
1720
|
body.dry_run = true;
|
|
1721
|
+
if (backup)
|
|
1722
|
+
body.backup = true;
|
|
1448
1723
|
const result = await wp.requestEnveloped(`/module/clone/${page_id}`, { method: "POST", body });
|
|
1449
1724
|
return { content: [{ type: "text", text: serializeEnvelope(result, "diviops_module_clone") }] };
|
|
1450
1725
|
});
|
|
@@ -1487,7 +1762,7 @@ registerPluginTool("diviops_page_create", {
|
|
|
1487
1762
|
};
|
|
1488
1763
|
});
|
|
1489
1764
|
registerPluginTool("diviops_page_trash", {
|
|
1490
|
-
description: "Trash or permanently delete a page/post. Defaults to trash (reversible via WP Admin → Trash). Pass force=true to permanently delete (wp_delete_post — irreversible). Idempotent: trashing an already-trashed post returns ok:true with `data.already_trashed = true` (repeat-safe semantics for AI-agent retries). Pass dry_run=true to preview without mutating. Replaces wp-cli `post delete --force=0|1` routing for AI-agent callers (typed input, deterministic envelope). Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing post_id returns 'not_found', delete-permission failures return 'forbidden' (HTTP 403).
|
|
1765
|
+
description: "Trash or permanently delete a page/post. Defaults to trash (reversible via WP Admin → Trash). Pass force=true to permanently delete (wp_delete_post — irreversible). Idempotent: trashing an already-trashed post returns ok:true with `data.already_trashed = true` (repeat-safe semantics for AI-agent retries). Pass dry_run=true to preview the standard `data.plan = { summary, changes[] }` without mutating. Replaces wp-cli `post delete --force=0|1` routing for AI-agent callers (typed input, deterministic envelope). Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing post_id returns 'not_found', delete-permission failures return 'forbidden' (HTTP 403).",
|
|
1491
1766
|
inputSchema: {
|
|
1492
1767
|
post_id: z.number().int().describe("WordPress post/page ID"),
|
|
1493
1768
|
force: z
|
|
@@ -1518,7 +1793,7 @@ registerPluginTool("diviops_page_trash", {
|
|
|
1518
1793
|
};
|
|
1519
1794
|
});
|
|
1520
1795
|
registerPluginTool("diviops_page_update_status", {
|
|
1521
|
-
description: "Update a page's post_status. Valid statuses: publish, draft, private, pending, future. status='future' requires date_gmt (ISO 8601 UTC, must be in the future) — server writes both post_date_gmt and the site-tz post_date so WP's scheduler picks it up. status='publish' on a previously-scheduled post clears the future date so it publishes immediately. Idempotent: same-status update returns ok:true with `data.noop = true`. Pass dry_run=true to preview. Replaces wp-cli `post update --post_status=...` routing. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing post_id returns 'not_found', edit-permission failures return 'forbidden' (HTTP 403); status enum violations and date_gmt validation failures return 'invalid_input' with `error.data` documenting the field.
|
|
1796
|
+
description: "Update a page's post_status. Valid statuses: publish, draft, private, pending, future. status='future' requires date_gmt (ISO 8601 UTC, must be in the future) — server writes both post_date_gmt and the site-tz post_date so WP's scheduler picks it up. status='publish' on a previously-scheduled post clears the future date so it publishes immediately. Idempotent: same-status update returns ok:true with `data.noop = true`. Pass dry_run=true to preview the standard `data.plan = { summary, changes[] }` without mutating. Replaces wp-cli `post update --post_status=...` routing. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; missing post_id returns 'not_found', edit-permission failures return 'forbidden' (HTTP 403); status enum violations and date_gmt validation failures return 'invalid_input' with `error.data` documenting the field.",
|
|
1522
1797
|
inputSchema: {
|
|
1523
1798
|
post_id: z.number().int().describe("WordPress post/page ID"),
|
|
1524
1799
|
status: z
|
|
@@ -1578,8 +1853,98 @@ registerPluginTool("diviops_preset_audit_storage", {
|
|
|
1578
1853
|
],
|
|
1579
1854
|
};
|
|
1580
1855
|
});
|
|
1856
|
+
registerPluginTool("diviops_preset_inspect", {
|
|
1857
|
+
description: "Inspect one Divi 5 preset UUID without writing. Returns bucket/type/module/group coordinates, attrs/styleAttrs/renderAttrs, storage path and provenance, block plus preset-chain reference counts with sample consumers, geometry-scope warnings for layout/position/sizing/transform attrs, and a warning when the same UUID also exists in nested D5 or legacy _ng storage. This is intentionally narrower than diviops_preset_audit and has no repair mode. Missing UUID returns not_found.",
|
|
1858
|
+
inputSchema: {
|
|
1859
|
+
preset_id: z.string().min(1).describe("Preset UUID to inspect."),
|
|
1860
|
+
},
|
|
1861
|
+
annotations: { idempotentHint: true },
|
|
1862
|
+
_meta: { idempotent: "true" },
|
|
1863
|
+
}, async ({ preset_id }) => {
|
|
1864
|
+
const result = await wp.requestEnveloped(`/preset/inspect/${encodeURIComponent(preset_id)}`);
|
|
1865
|
+
return {
|
|
1866
|
+
content: [
|
|
1867
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_preset_inspect") },
|
|
1868
|
+
],
|
|
1869
|
+
};
|
|
1870
|
+
});
|
|
1871
|
+
registerPluginTool("diviops_rollback_snapshot_list", {
|
|
1872
|
+
description: "List DiviOps rollback snapshots from the option-backed store. Free/core storage management read surface; returns metadata only, never stored before.value payloads. Supports target_kind, target_id, status, and limit filters. Results are target-permission filtered; missing-target snapshots are shown only to site admins or the snapshot creator and are payload-redacted. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
1873
|
+
inputSchema: {
|
|
1874
|
+
target_kind: z.string().optional().describe("Optional target kind filter, usually post."),
|
|
1875
|
+
target_id: z.number().int().positive().optional().describe("Optional target post/layout ID filter."),
|
|
1876
|
+
status: z.string().optional().describe("Optional snapshot status filter, such as created or write_applied."),
|
|
1877
|
+
limit: z.number().int().min(1).max(100).optional().default(20).describe("Maximum snapshots to return."),
|
|
1878
|
+
},
|
|
1879
|
+
annotations: { idempotentHint: true },
|
|
1880
|
+
_meta: { idempotent: "true" },
|
|
1881
|
+
}, async ({ target_kind, target_id, status, limit }) => {
|
|
1882
|
+
const params = {};
|
|
1883
|
+
if (target_kind)
|
|
1884
|
+
params.target_kind = target_kind;
|
|
1885
|
+
if (target_id)
|
|
1886
|
+
params.target_id = String(target_id);
|
|
1887
|
+
if (status)
|
|
1888
|
+
params.status = status;
|
|
1889
|
+
if (limit && limit !== 20)
|
|
1890
|
+
params.limit = String(limit);
|
|
1891
|
+
const qs = new URLSearchParams(params).toString();
|
|
1892
|
+
const result = await wp.requestEnveloped(`/rollback-snapshot/list${qs ? `?${qs}` : ""}`);
|
|
1893
|
+
return {
|
|
1894
|
+
content: [
|
|
1895
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_list") },
|
|
1896
|
+
],
|
|
1897
|
+
};
|
|
1898
|
+
});
|
|
1899
|
+
registerPluginTool("diviops_rollback_snapshot_get", {
|
|
1900
|
+
description: "Inspect one rollback snapshot. Free/core storage management read surface. include_value defaults false; true returns the stored before.value and captured side-effect payload only when the referenced target still exists and the caller passes the target-level permission gate. Missing-target snapshots are metadata-only for admins/creators. No restore path in this tool. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
1901
|
+
inputSchema: {
|
|
1902
|
+
snapshot_id: z.string().min(1).describe("Snapshot id returned by diviops_rollback_snapshot_list."),
|
|
1903
|
+
include_value: z.boolean().optional().default(false).describe("Include stored before.value and side-effect payload when target access allows it."),
|
|
1904
|
+
},
|
|
1905
|
+
annotations: { idempotentHint: true },
|
|
1906
|
+
_meta: { idempotent: "true" },
|
|
1907
|
+
}, async ({ snapshot_id, include_value }) => {
|
|
1908
|
+
const params = include_value ? "?include_value=true" : "";
|
|
1909
|
+
const result = await wp.requestEnveloped(`/rollback-snapshot/get/${encodeURIComponent(snapshot_id)}${params}`);
|
|
1910
|
+
return {
|
|
1911
|
+
content: [
|
|
1912
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_get") },
|
|
1913
|
+
],
|
|
1914
|
+
};
|
|
1915
|
+
});
|
|
1916
|
+
registerPluginTool("diviops_rollback_snapshot_delete", {
|
|
1917
|
+
description: "Hard-delete one rollback snapshot option after operator acceptance. Free/core cleanup surface; normally requires target-level permission, with a missing-target cleanup path for site admins or the snapshot creator. Does not expose before.value and does not restore content. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.",
|
|
1918
|
+
inputSchema: {
|
|
1919
|
+
snapshot_id: z.string().min(1).describe("Snapshot id to delete."),
|
|
1920
|
+
},
|
|
1921
|
+
annotations: { idempotentHint: true },
|
|
1922
|
+
_meta: { idempotent: "true" },
|
|
1923
|
+
}, async ({ snapshot_id }) => {
|
|
1924
|
+
const result = await wp.requestEnveloped(`/rollback-snapshot/delete/${encodeURIComponent(snapshot_id)}`, { method: "POST" });
|
|
1925
|
+
return {
|
|
1926
|
+
content: [
|
|
1927
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_delete") },
|
|
1928
|
+
],
|
|
1929
|
+
};
|
|
1930
|
+
});
|
|
1931
|
+
registerPluginTool("diviops_rollback_snapshot_restore", {
|
|
1932
|
+
description: "Restore one guarded rollback snapshot to its original post/page or Theme Builder layout target. Requires target edit permission, refuses content or captured Divi post-meta checksum drift with conflict before mutation, has no force override, writes through the shared full-content integrity/readback guard, restores captured supported post meta, invalidates Divi cache, and marks restore_applied only after verified readback. dry_run previews without writing. This MVP does not create a second pre-restore snapshot. Returns the standardized envelope.",
|
|
1933
|
+
inputSchema: {
|
|
1934
|
+
snapshot_id: z.string().min(1).describe("Snapshot id to restore."),
|
|
1935
|
+
dry_run: z.boolean().optional().default(false).describe("Preview the checksum-bound restore without mutation."),
|
|
1936
|
+
},
|
|
1937
|
+
_meta: { idempotent: "false" },
|
|
1938
|
+
}, async ({ snapshot_id, dry_run }) => {
|
|
1939
|
+
const result = await wp.requestEnveloped(`/rollback-snapshot/restore/${encodeURIComponent(snapshot_id)}`, { method: "POST", body: { dry_run } });
|
|
1940
|
+
return {
|
|
1941
|
+
content: [
|
|
1942
|
+
{ type: "text", text: serializeEnvelope(result, "diviops_rollback_snapshot_restore") },
|
|
1943
|
+
],
|
|
1944
|
+
};
|
|
1945
|
+
});
|
|
1581
1946
|
registerPluginTool("diviops_preset_cleanup", {
|
|
1582
|
-
description: 'Clean up presets. Default: remove spam presets. Optional: dedup=true to also remove duplicates, action="rename_strip_prefix" with prefix to strip a name prefix, or action="remove_orphans" with scope="spam"|"all" to remove unreferenced presets. Use dry_run: true (default) to preview
|
|
1947
|
+
description: 'Clean up presets. Default: remove spam presets. Optional: dedup=true to also remove duplicates, action="rename_strip_prefix" with prefix to strip a name prefix, or action="remove_orphans" with scope="spam"|"all" to remove unreferenced presets. Use dry_run: true (default) to preview the standard `data.plan = { summary, changes[] }` without mutating; legacy removed/renamed/deduped summary arrays are preserved as sibling metadata. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }.',
|
|
1583
1948
|
inputSchema: {
|
|
1584
1949
|
dry_run: z
|
|
1585
1950
|
.boolean()
|
|
@@ -2107,13 +2472,19 @@ registerPluginTool("diviops_tb_layout_update", {
|
|
|
2107
2472
|
layout_id: z.number().describe("Layout post ID to update"),
|
|
2108
2473
|
content: z.string().describe("New block markup content"),
|
|
2109
2474
|
dry_run: DRY_RUN_FIELD,
|
|
2475
|
+
backup: BACKUP_FIELD,
|
|
2110
2476
|
},
|
|
2111
2477
|
annotations: { idempotentHint: false },
|
|
2112
2478
|
_meta: { idempotent: "conditional" },
|
|
2113
|
-
}, async ({ layout_id, content, dry_run }) => {
|
|
2479
|
+
}, async ({ layout_id, content, dry_run, backup }) => {
|
|
2480
|
+
const backupGate = backupCapabilityError("diviops_tb_layout_update", backup);
|
|
2481
|
+
if (backupGate)
|
|
2482
|
+
return backupGate;
|
|
2114
2483
|
const body = { content };
|
|
2115
2484
|
if (dry_run)
|
|
2116
2485
|
body.dry_run = true;
|
|
2486
|
+
if (backup)
|
|
2487
|
+
body.backup = true;
|
|
2117
2488
|
const result = await wp.requestEnveloped(`/theme-builder/layout/update/${layout_id}`, {
|
|
2118
2489
|
method: "PUT",
|
|
2119
2490
|
body,
|
|
@@ -2144,10 +2515,14 @@ registerPluginTool("diviops_tb_layout_block_insert", {
|
|
|
2144
2515
|
.describe("Where to insert relative to the target block."),
|
|
2145
2516
|
content: z.string().describe("One or more serialized Divi blocks to insert"),
|
|
2146
2517
|
dry_run: DRY_RUN_FIELD,
|
|
2518
|
+
backup: BACKUP_FIELD,
|
|
2147
2519
|
},
|
|
2148
2520
|
annotations: { idempotentHint: false },
|
|
2149
2521
|
_meta: { idempotent: "conditional" },
|
|
2150
|
-
}, async ({ layout_id, parent_selector, parent_path, position, content, dry_run }) => {
|
|
2522
|
+
}, async ({ layout_id, parent_selector, parent_path, position, content, dry_run, backup }) => {
|
|
2523
|
+
const backupGate = backupCapabilityError("diviops_tb_layout_block_insert", backup);
|
|
2524
|
+
if (backupGate)
|
|
2525
|
+
return backupGate;
|
|
2151
2526
|
const body = {
|
|
2152
2527
|
content,
|
|
2153
2528
|
position: position ?? "append",
|
|
@@ -2158,6 +2533,8 @@ registerPluginTool("diviops_tb_layout_block_insert", {
|
|
|
2158
2533
|
body.parent_path = parent_path;
|
|
2159
2534
|
if (dry_run)
|
|
2160
2535
|
body.dry_run = true;
|
|
2536
|
+
if (backup)
|
|
2537
|
+
body.backup = true;
|
|
2161
2538
|
const result = await wp.requestEnveloped(`/theme-builder/layout/block-insert/${layout_id}`, {
|
|
2162
2539
|
method: "POST",
|
|
2163
2540
|
body,
|
|
@@ -3104,7 +3481,7 @@ registerLocalTool("diviops_template_get", {
|
|
|
3104
3481
|
});
|
|
3105
3482
|
// ── Variable Manager CRUD ─────────────────────────────────────────────
|
|
3106
3483
|
registerPluginTool("diviops_variable_list", {
|
|
3107
|
-
description: "List all design token variables from the Divi Variable Manager. Colors (gcid-*) come from et_global_data, numbers/strings/etc (gvid-*) from et_divi_global_variables. Filter by type or ID prefix. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; invalid `type` returns ok:false with code 'invalid_input'.",
|
|
3484
|
+
description: "List all design token variables from the Divi Variable Manager. Colors (gcid-*) come from et_global_data, numbers/strings/etc (gvid-*) from et_divi_global_variables. Filter by type or stored ID prefix. The `prefix` parameter does not match labels; for semantic names such as `oa-*` labels on UUID-backed Divi variables, list by type and filter returned labels client-side. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; invalid `type` returns ok:false with code 'invalid_input'.",
|
|
3108
3485
|
inputSchema: {
|
|
3109
3486
|
type: z
|
|
3110
3487
|
.enum(["colors", "numbers", "strings", "images", "links", "fonts", "gradients"])
|
|
@@ -3113,7 +3490,7 @@ registerPluginTool("diviops_variable_list", {
|
|
|
3113
3490
|
prefix: z
|
|
3114
3491
|
.string()
|
|
3115
3492
|
.optional()
|
|
3116
|
-
.describe('Filter by ID prefix
|
|
3493
|
+
.describe('Filter by stored ID prefix only. Does not match labels; for semantic names such as "oa-*" labels, list by type and filter returned labels client-side.'),
|
|
3117
3494
|
},
|
|
3118
3495
|
annotations: { idempotentHint: true },
|
|
3119
3496
|
_meta: { idempotent: "true" },
|
|
@@ -3361,7 +3738,7 @@ registerPluginTool("diviops_variable_create_fluid_system", {
|
|
|
3361
3738
|
.boolean()
|
|
3362
3739
|
.optional()
|
|
3363
3740
|
.default(false)
|
|
3364
|
-
.describe("Preview the
|
|
3741
|
+
.describe("Preview the standard dry-run plan without persisting. The response also preserves `created`/`skipped` diagnostics so callers can audit IDs and clamp() values before committing."),
|
|
3365
3742
|
overwrite: z
|
|
3366
3743
|
.boolean()
|
|
3367
3744
|
.optional()
|
|
@@ -3975,7 +4352,7 @@ function registerProTools() {
|
|
|
3975
4352
|
// no license activation flow, no update-ZIP / readme / banner config.
|
|
3976
4353
|
// diviops_fc_variation_list — POST /diviops/v1/pro/fluentcart/products/{id}/variations
|
|
3977
4354
|
registerProTool("diviops_fc_variation_list", {
|
|
3978
|
-
description: "List FluentCart Pro variations for a product (Pro tier; V3; requires FluentCart Pro installed + activated). Read-only. Returns every variation row attached to the product with its subscription shape (payment_type, other_info.repeat_interval/times/trial_days/manage_setup_fee) and a license-settings projection when ProductMeta.license_settings is configured. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { product_id, variation_type, default_variation_id, variations: VariationRow[], variations_count }. Each VariationRow carries { id, post_id, variation_title, sku, payment_type, item_price, compare_price, fulfillment_type, stock_status, manage_stock, available, other_info: { ...all stored keys... }, license: { activation_limit, validity: { unit, value } } | null }. Unit convention: item_price and compare_price are stored cents (e.g. 1900 = $19.00). compare_price is null when FCP stores the no-compare sentinel 0; sku is null when the column is SQL NULL OR an empty string. license is null when the product has no license_settings; otherwise activation_limit is null/'' (unset), 0 (unlimited per FluentCart Pro License::getActivationLimit), or a positive integer (max activations). validity.unit is one of: lifetime/day/week/month/year. Error codes: invalid_input (400) when id is not a positive integer; not_found (404) when the product does not exist; fluentcart.module_inactive (412); fluentcart.query_failed (500). Idempotency: read-only.",
|
|
4355
|
+
description: "List FluentCart Pro variations for a product (Pro tier; V3; requires FluentCart Pro installed + activated). Read-only. Returns every variation row attached to the product with its subscription shape (payment_type, other_info.repeat_interval/times/trial_days/manage_setup_fee) and a license-settings projection when ProductMeta.license_settings is configured. For FluentCart 1.5 advanced_variations products, also resolves attribute relation metadata into VariationRow.attributes[] while preserving raw other_info.variant term IDs; each attribute row carries { group_id, group_title, group_slug, group_type, term_id, term_title, term_slug, term_settings }. Returns the standardized envelope { ok, data?, error: { code, message, hint? } }; success payload is { product_id, variation_type, default_variation_id, variations: VariationRow[], variations_count }. Each VariationRow carries { id, post_id, variation_title, sku, payment_type, item_price, compare_price, fulfillment_type, stock_status, manage_stock, available, other_info: { ...all stored keys... }, attributes?: AttributeRow[], license: { activation_limit, validity: { unit, value } } | null }. Unit convention: item_price and compare_price are stored cents (e.g. 1900 = $19.00). compare_price is null when FCP stores the no-compare sentinel 0; sku is null when the column is SQL NULL OR an empty string. license is null when the product has no license_settings; otherwise activation_limit is null/'' (unset), 0 (unlimited per FluentCart Pro License::getActivationLimit), or a positive integer (max activations). validity.unit is one of: lifetime/day/week/month/year. Advanced Variations authoring remains out of scope; write tools still refuse non-simple shapes with fluentcart.unsupported_product_shape. Error codes: invalid_input (400) when id is not a positive integer; not_found (404) when the product does not exist; fluentcart.module_inactive (412); fluentcart.query_failed (500). Idempotency: read-only.",
|
|
3979
4356
|
inputSchema: {
|
|
3980
4357
|
product_id: z
|
|
3981
4358
|
.number()
|
package/dist/wp-cli.d.ts
CHANGED
|
@@ -13,6 +13,15 @@ interface WpCliConfig {
|
|
|
13
13
|
/** Custom WP-CLI command prefix for containerized environments (e.g. "ddev wp"). */
|
|
14
14
|
wpCliCmd?: string;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate a parsed command against the allowlist.
|
|
18
|
+
* Checks the first 1-3 args against allowed command prefixes (supports
|
|
19
|
+
* 2-word commands like "post list" and 3-word like "post meta get").
|
|
20
|
+
*/
|
|
21
|
+
declare function isCommandAllowed(args: string[]): {
|
|
22
|
+
allowed: boolean;
|
|
23
|
+
reason?: string;
|
|
24
|
+
};
|
|
16
25
|
/**
|
|
17
26
|
* Parse a command string into an array of arguments.
|
|
18
27
|
* Handles quoted strings (single and double quotes).
|
|
@@ -20,6 +29,7 @@ interface WpCliConfig {
|
|
|
20
29
|
declare function parseCommand(command: string): string[];
|
|
21
30
|
declare function normalizeWpCliPathArgs(args: string[], wpPath: string): string[];
|
|
22
31
|
export declare const __wpCliTesting: {
|
|
32
|
+
isCommandAllowed: typeof isCommandAllowed;
|
|
23
33
|
parseCommand: typeof parseCommand;
|
|
24
34
|
normalizeWpCliPathArgs: typeof normalizeWpCliPathArgs;
|
|
25
35
|
};
|
package/dist/wp-cli.js
CHANGED
|
@@ -27,6 +27,9 @@ const DEFAULT_COMMANDS = [
|
|
|
27
27
|
'post meta list',
|
|
28
28
|
'post meta set',
|
|
29
29
|
'post meta update',
|
|
30
|
+
// Taxonomy assignments (read-only). Assignment writes (`post term add/set/remove`)
|
|
31
|
+
// stay unsupported until a concrete workflow justifies a typed or extended path.
|
|
32
|
+
'post term list',
|
|
30
33
|
// Post types (read-only)
|
|
31
34
|
'post-type list',
|
|
32
35
|
'post-type get',
|
|
@@ -312,6 +315,7 @@ function normalizeWpCliPathArgs(args, wpPath) {
|
|
|
312
315
|
return args;
|
|
313
316
|
}
|
|
314
317
|
export const __wpCliTesting = {
|
|
318
|
+
isCommandAllowed,
|
|
315
319
|
parseCommand,
|
|
316
320
|
normalizeWpCliPathArgs,
|
|
317
321
|
};
|