From 8f2a225a06045bb42f782d908cb006b0e3e86295 Mon Sep 17 00:00:00 2001 From: colorlink Date: Fri, 16 Oct 2026 04:51:24 +0000 Subject: [PATCH] Batch52: Thrive Architect tools (guarded, net-new) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg --- includes/Extensions/Batch52.php | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 includes/Extensions/Batch52.php diff --git a/includes/Extensions/Batch52.php b/includes/Extensions/Batch52.php new file mode 100644 index 0000000..c8c9399 --- /dev/null +++ b/includes/Extensions/Batch52.php @@ -0,0 +1,49 @@ + 'object', 'properties' => $props ?: new \stdClass()]; + if ($required) $schema['required'] = $required; + return ['name' => $name, 'description' => $desc, 'scope' => $scope, + 'handler' => 'AskTamMCP\\Extensions\\Batch52::' . $method, 'inputSchema' => $schema]; + }; + + $registry->register($def('thrive_detect', 'Report whether Thrive Architect is active and its version.', [], [], 'read', 'detect')); + $registry->register($def('thrive_is_built', 'Report whether Thrive Architect content is stored on a post.', + ['post_id' => ['type' => 'integer']], ['post_id'], 'read', 'isBuilt')); + $registry->register($def('thrive_list_built', 'List recent posts that have Thrive Architect content (id, title).', + ['post_type' => ['type' => 'string', 'default' => 'page'], 'per_page' => ['type' => 'integer', 'default' => 50]], [], 'read', 'listBuilt')); + } + + public static function detect(array $args): array { + return ['active' => defined('TVE_VERSION'), 'version' => defined('TVE_VERSION') ? TVE_VERSION : null]; + } + + public static function isBuilt(array $args): array { + $id = (int) ($args['post_id'] ?? 0); + if (!get_post($id)) throw new \RuntimeException("Post not found: {$id}"); + $built = get_post_meta($id, 'tcb2_ready', true) || get_post_meta($id, 'tve_updated_post', true); + return ['post_id' => $id, 'thrive_built' => (bool) $built]; + } + + public static function listBuilt(array $args): array { + $pt = (string) ($args['post_type'] ?? 'page'); + $posts = get_posts(['post_type' => $pt, 'post_status' => 'publish', 'numberposts' => (int) ($args['per_page'] ?? 50), + 'meta_query' => [['key' => 'tve_updated_post', 'compare' => 'EXISTS']]]); + $out = []; + foreach ($posts as $p) $out[] = ['id' => $p->ID, 'title' => $p->post_title]; + return ['count' => count($out), 'posts' => $out]; + } +}