'content/get-cpt-item', 'args' => array( 'label' => __( 'Get CPT Item', 'acrossai-abilities-manager' ), 'description' => __( 'Fetch a custom post type record by ID. post_type is required and must match the post.', 'acrossai-abilities-manager' ), 'category' => 'acrossai-content', 'execute_callback' => array( $this, 'execute' ), 'permission_callback' => static function (): bool { return current_user_can( 'manage_options' ); }, 'input_schema' => array( 'type' => 'object', 'properties' => array( 'post_type' => array( 'type' => 'string' ), 'id' => array( 'type' => 'integer', 'minimum' => 1, ), ), 'required' => array( 'post_type', 'id' ), 'additionalProperties' => false, ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'item' => array( 'type' => 'object' ), 'message' => array( 'type' => 'string' ), ), 'required' => array( 'success' ), 'additionalProperties' => false, ), 'meta' => array( 'acrossai' => array( 'tab_group' => 'content', 'sub_group' => 'cpt', 'sub_group_label' => __( 'Custom Post Types', 'acrossai-abilities-manager' ), ), 'show_in_rest' => true, 'mcp' => array( 'public' => false, 'type' => 'tool', ), 'annotations' => array( 'readonly' => true, 'destructive' => false, 'idempotent' => true, ), ), ), ); } /** * Feature 095 follow-up — hint that block-structure lookups are far cheaper * via the outline ability than fetching the whole CPT item. * * @return array> */ protected function suggested_abilities(): array { return array( array( 'slug' => 'blocks/outline-post-blocks', 'reason' => __( 'If you only need the block structure or want to locate a specific block, outline returns paths + short text previews without the full post_content — kilobytes instead of hundreds.', 'acrossai-abilities-manager' ), 'saves' => __( '~20x fewer tokens on a 97 KB body', 'acrossai-abilities-manager' ), ), ); } /** * Execute the ability. * * @param array $input Ability input payload. * @return array */ public function execute( array $input = array() ): array { $post_type = sanitize_key( (string) ( $input['post_type'] ?? '' ) ); $id = (int) ( $input['id'] ?? 0 ); if ( '' === $post_type || ! post_type_exists( $post_type ) ) { return array( 'success' => false, /* translators: %s: post type */ 'message' => sprintf( __( 'Unknown post type "%s".', 'acrossai-abilities-manager' ), $post_type ), ); } $post = $id > 0 ? get_post( $id, ARRAY_A ) : null; if ( ! $post || $post['post_type'] !== $post_type ) { return array( 'success' => false, 'message' => __( 'Item not found.', 'acrossai-abilities-manager' ), ); } return array( 'success' => true, 'item' => $post, ); } }