PluginProbe
WDesignKit – AI Templates, Widget Builder & MCP Workflow / 2.7.0
WDesignKit – AI Templates, Widget Builder & MCP Workflow v2.7.0
2.7.1 2.7.0 2.6.6 2.6.5 2.6.4 2.6.3 2.6.2 2.6.1 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 2.5.1 2.5.0 2.4.0 2.3.3 2.3.2 2.3.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 All 130 releases
wdesignkit / includes / abilities / utilities / wdesignkit-get-abilities-guide.php

wdesignkit-get-abilities-guide.php in WDesignKit – AI Templates, Widget Builder & MCP Workflow 2.7.0, at includes/abilities/utilities/wdesignkit-get-abilities-guide.php

77 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ability: Return the bundled WDesignKit Abilities Guide (SKILL.md) so any
4 * MCP client can fetch it and follow the documented rules before calling
5 * wdesignkit/* or nexter-blocks/* abilities.
6 */
7
8 declare(strict_types=1);
9
10 if (!defined('ABSPATH')) {
11 exit();
12 }
13
14 wp_register_ability('wdesignkit/get-abilities-guide', [
15 'label' => __('Get WDesignKit Abilities Guide', 'wdesignkit'),
16 'description' => __(
17 'Returns the full WDesignKit Abilities Guide (Markdown) — builder mapping, the create-code-verify widget workflow, the Nexter Blocks dedicated-ability rule, and safety rules for irreversible calls (dry_run before confirm, login before cloud, read before write). Call this BEFORE the first wdesignkit/* or nexter-blocks/* call in a session so subsequent calls follow the documented contracts.',
18 'wdesignkit',
19 ),
20 'category' => 'wdesignkit',
21 'input_schema' => [
22 'type' => 'object',
23 ],
24 'output_schema' => [
25 'type' => 'object',
26 'properties' => [
27 'success' => ['type' => 'boolean'],
28 'guide' => ['type' => 'string'],
29 ],
30 ],
31 'execute_callback' => 'wdesignkit_mcp_get_abilities_guide',
32 'permission_callback' => 'wdesignkit_mcp_permission_callback',
33 'meta' => [
34 'public' => true,
35 'show_in_rest' => true,
36 'mcp' => ['public' => true],
37 'annotations' => [
38 'instructions' => implode("\n", [
39 'Call this once at the start of any session that will use wdesignkit/ or nexter-blocks/* abilities.',
40 'Returns Markdown covering: builder mapping (Elementor/Gutenberg/Nexter/Bricks), the create-widget → get-widget → update-widget → widget-preview workflow, the Nexter Blocks add-tpgb-* + verify-page rule, and confirm/dry_run safety rules for irreversible abilities.',
41 'wdesignkit/list-abilities enumerates every ability if something is not covered by the guide.',
42 ]),
43 'readonly' => true,
44 'destructive' => false,
45 'idempotent' => true,
46 ],
47 ],
48 ]);
49
50 /**
51 * Execute callback: returns the WDesignKit Abilities Guide as Markdown.
52 *
53 * @param array $input Ability input arguments (unused; kept for callback signature).
54 * @return array|WP_Error array{success:bool,guide:string} on success, WP_Error when
55 * the bundled guide file is missing or unreadable so the MCP
56 * client can surface a real failure instead of silently
57 * treating an empty guide as valid output.
58 */
59 function wdesignkit_mcp_get_abilities_guide(array $input) {
60 unset($input);
61
62 $path = WDKIT_INCLUDES . 'abilities/skills/wdesignkit-abilities/SKILL.md';
63
64 if (!is_readable($path)) {
65 return new WP_Error(
66 'skill_unreadable',
67 __('WDesignKit abilities guide is missing or unreadable.', 'wdesignkit')
68 );
69 }
70
71 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local plugin file path, not a remote URL.
72 return [
73 'success' => true,
74 'guide' => (string) file_get_contents($path),
75 ];
76 }
77