Batch55: Blocksy tools (guarded, net-new)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Batch 55 — Blocksy (Companion) tools. Net-new, GPL-2.0-or-later. See NOTICE.md.
|
||||||
|
* Inert unless Blocksy Companion (BLOCKSY_COMPANION_VERSION) is active. Content blocks are the 'ct_content_block' CPT.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace AskTamMCP\Extensions;
|
||||||
|
|
||||||
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
class Batch55 {
|
||||||
|
|
||||||
|
public static function register($registry): void {
|
||||||
|
if (!defined('BLOCKSY_COMPANION_VERSION')) return;
|
||||||
|
|
||||||
|
$def = function (string $name, string $desc, array $props, array $required, string $scope, string $method) {
|
||||||
|
$schema = ['type' => 'object', 'properties' => $props ?: new \stdClass()];
|
||||||
|
if ($required) $schema['required'] = $required;
|
||||||
|
return ['name' => $name, 'description' => $desc, 'scope' => $scope,
|
||||||
|
'handler' => 'AskTamMCP\\Extensions\\Batch55::' . $method, 'inputSchema' => $schema];
|
||||||
|
};
|
||||||
|
|
||||||
|
$registry->register($def('blocksy_detect', 'Report whether Blocksy Companion is active and its version.', [], [], 'read', 'detect'));
|
||||||
|
$registry->register($def('blocksy_list_content_blocks', 'List Blocksy content blocks / hooks (id, title).',
|
||||||
|
['per_page' => ['type' => 'integer', 'default' => 100]], [], 'read', 'listContentBlocks'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function detect(array $args): array {
|
||||||
|
return ['active' => defined('BLOCKSY_COMPANION_VERSION'), 'version' => defined('BLOCKSY_COMPANION_VERSION') ? BLOCKSY_COMPANION_VERSION : null];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function listContentBlocks(array $args): array {
|
||||||
|
if (!post_type_exists('ct_content_block')) {
|
||||||
|
return ['supported' => false, 'note' => 'ct_content_block post type not registered.', 'blocks' => []];
|
||||||
|
}
|
||||||
|
$posts = get_posts(['post_type' => 'ct_content_block', 'post_status' => ['publish', 'draft'],
|
||||||
|
'numberposts' => (int) ($args['per_page'] ?? 100), 'orderby' => 'title', 'order' => 'ASC']);
|
||||||
|
$out = [];
|
||||||
|
foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title];
|
||||||
|
return ['supported' => true, 'count' => count($out), 'blocks' => $out];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user