From f56e13cceb323d4d4ffb1b16a65372c25b4b1488 Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:50:45 +0000 Subject: [PATCH] Batch49: Oxygen Builder tools (guarded, net-new) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- includes/Extensions/Batch49.php | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 includes/Extensions/Batch49.php diff --git a/includes/Extensions/Batch49.php b/includes/Extensions/Batch49.php new file mode 100644 index 0000000..b5cdba4 --- /dev/null +++ b/includes/Extensions/Batch49.php @@ -0,0 +1,48 @@ + 'object', 'properties' => $props ?: new \stdClass()]; + if ($required) $schema['required'] = $required; + return ['name' => $name, 'description' => $desc, 'scope' => $scope, + 'handler' => 'AskTamMCP\\Extensions\\Batch49::' . $method, 'inputSchema' => $schema]; + }; + + $registry->register($def('oxygen_detect', 'Report whether Oxygen Builder is active and its version.', [], [], 'read', 'detect')); + $registry->register($def('oxygen_list_templates', 'List Oxygen templates (id, title).', + ['per_page' => ['type' => 'integer', 'default' => 100]], [], 'read', 'listTemplates')); + $registry->register($def('oxygen_is_built', 'Report whether Oxygen shortcodes are stored on a post.', + ['post_id' => ['type' => 'integer']], ['post_id'], 'read', 'isBuilt')); + } + + public static function detect(array $args): array { + return ['active' => defined('CT_VERSION'), 'version' => defined('CT_VERSION') ? CT_VERSION : null]; + } + + public static function listTemplates(array $args): array { + $posts = get_posts(['post_type' => 'ct_template', '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 ['count' => count($out), 'templates' => $out]; + } + + public static function isBuilt(array $args): array { + $id = (int) ($args['post_id'] ?? 0); + if (!get_post($id)) throw new \RuntimeException("Post not found: {$id}"); + $sc = get_post_meta($id, 'ct_builder_shortcodes', true); + return ['post_id' => $id, 'oxygen_built' => get_post_meta($id, 'ct_builder_json', true) ? true : !empty($sc)]; + } +}