'Clear the AEOLynx for WebMCP activity log and lifetime counters.', ) ); WP_CLI::add_command( $cmd_prefix . ' audit', array( __CLASS__, 'audit' ), array( 'shortdesc' => 'Run the local Agent-Ready audit and print the score.', ) ); WP_CLI::add_command( $cmd_prefix . ' flush-cache', array( __CLASS__, 'flush_cache' ), array( 'shortdesc' => 'Invalidate all schema graph and llms.txt caches.', ) ); WP_CLI::add_command( $cmd_prefix . ' tools', array( __CLASS__, 'tools' ), array( 'shortdesc' => 'List the MCP tools this gateway exposes.', ) ); WP_CLI::add_command( $cmd_prefix . ' status', array( __CLASS__, 'status' ), array( 'shortdesc' => 'Show gateway status, endpoints, and activity counters.', ) ); } } /** * wp aeolynx clear-log * * @return void */ public static function clear_log() { delete_option( 'aeolynx_activity_events' ); delete_option( 'aeolynx_activity_counters' ); WP_CLI::success( 'Activity log and counters cleared.' ); } /** * wp aeolynx audit * * @return void */ public static function audit() { $report = AEOLynx_Agent_Audit::run_local_audit(); if ( ! is_array( $report ) || empty( $report ) ) { WP_CLI::error( 'Audit could not run.' ); } $score = isset( $report['counts']['score'] ) ? (int) $report['counts']['score'] : ( isset( $report['score'] ) ? (int) $report['score'] : 0 ); $level = isset( $report['levelName'] ) ? (string) $report['levelName'] : ( isset( $report['level'] ) ? (string) $report['level'] : '' ); WP_CLI::line( 'Agent-Ready score: ' . $score . '/100 (' . $level . ')' ); if ( isset( $report['checks'] ) && is_array( $report['checks'] ) ) { foreach ( $report['checks'] as $group_id => $group ) { if ( ! is_array( $group ) ) { continue; } WP_CLI::line( '[' . $group_id . ']' ); foreach ( $group as $check_id => $check ) { if ( ! is_array( $check ) ) { continue; } $status = strtoupper( (string) ( isset( $check['status'] ) ? $check['status'] : 'info' ) ); $msg = isset( $check['message'] ) ? wp_strip_all_tags( (string) $check['message'] ) : ''; WP_CLI::line( sprintf( ' [%s] %s — %s', $status, $check_id, $msg ) ); } } } WP_CLI::success( 'Audit complete.' ); } /** * wp aeolynx flush-cache * * @return void */ public static function flush_cache() { update_option( 'aeolynx_schema_rev', (int) get_option( 'aeolynx_schema_rev', 0 ) + 1, false ); update_option( 'aeolynx_llmstxt_rev', (int) get_option( 'aeolynx_llmstxt_rev', 0 ) + 1, false ); delete_option( 'aeolynx_llmstxt_cache' ); global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time cache flush; caching is pointless here. $cleared = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s", '_aeolynx_graph_cache' ) ); WP_CLI::success( 'Schema and llms.txt caches flushed (' . (int) $cleared . ' post graph entries removed).' ); } /** * wp aeolynx tools * * @return void */ public static function tools() { $tools = (array) apply_filters( 'aeolynx_register_tools', AEOLynx_Schema_Builder::get_core_tools( 0 ), 'homepage', 0 ); if ( empty( $tools ) ) { WP_CLI::line( 'No tools registered.' ); return; } foreach ( $tools as $tool ) { $tool = (array) $tool; $name = isset( $tool['name'] ) ? $tool['name'] : '?'; $desc = isset( $tool['description'] ) ? $tool['description'] : ''; WP_CLI::line( $name . ' — ' . wp_strip_all_tags( (string) $desc ) ); } } /** * wp aeolynx status * * @return void */ public static function status() { WP_CLI::line( 'Gateway: ' . ( AEOLynx_Frontend::is_enabled() ? 'active' : 'paused' ) ); WP_CLI::line( 'Version: ' . AEOLYNX_CORE_VERSION ); WP_CLI::line( 'Manifest: ' . rest_url( 'aeolynx/v1/manifest' ) ); WP_CLI::line( 'llms.txt: ' . home_url( '/llms.txt' ) ); WP_CLI::line( 'mcp.json: ' . home_url( '/.well-known/mcp.json' ) ); $counters = AEOLynx_Activity_Log::get_counters(); foreach ( $counters as $type => $count ) { WP_CLI::line( ' ' . $type . ': ' . (int) $count ); } } } }