From 39a7f9a9ea0306afd1db2c0fc09caad9f5afc462 Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Sun, 24 May 2026 14:43:14 +0700 Subject: [PATCH 1/3] feat: persist AI reasoning as post meta and add debug meta box Store _waygate_reasoning, _waygate_patterns, and _waygate_generated_at on every generated page. Add a Waygate sidebar meta box that always shows the reasoning sentence and exposes the pattern slug list and timestamp when WP_ENV=development. Success notice also shows pattern slugs in dev mode. --- includes/class-admin.php | 51 +++++++++++++++++++++++++++++++ includes/class-ai-integration.php | 8 ++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index c0cc437..5a1f82e 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -8,6 +8,7 @@ class Admin { public static function init(): void { add_action( 'admin_menu', [ self::class, 'register_menu' ] ); + add_action( 'add_meta_boxes', [ self::class, 'register_meta_box' ] ); } public static function register_menu(): void { @@ -230,6 +231,10 @@ private static function status_notices( bool $ai_available, bool $text_gen_suppo

Error: ' . esc_html( $result['error'] ) . '

'; @@ -245,6 +250,11 @@ private static function result_notice( array $result ): void {

AI reasoning:

+ +

+ Patterns (dev): +

+

Edit page   @@ -253,4 +263,45 @@ private static function result_notice( array $result ): void { ID, '_waygate_reasoning', true ); + + if ( ! $reasoning ) { + echo '

Not generated by Waygate.

'; + return; + } + + echo '

AI reasoning
' . esc_html( $reasoning ) . '

'; + + if ( self::is_dev() ) { + $patterns_json = get_post_meta( $post->ID, '_waygate_patterns', true ); + $generated_at = get_post_meta( $post->ID, '_waygate_generated_at', true ); + $patterns = $patterns_json ? json_decode( $patterns_json, true ) : []; + + if ( $generated_at ) { + echo '

Generated: ' . esc_html( $generated_at ) . '

'; + } + + if ( $patterns ) { + echo '

Patterns

'; + echo '
    '; + foreach ( $patterns as $slug ) { + echo '
  1. ' . esc_html( $slug ) . '
  2. '; + } + echo '
'; + } + } + } } diff --git a/includes/class-ai-integration.php b/includes/class-ai-integration.php index daa5e7e..7353bb4 100644 --- a/includes/class-ai-integration.php +++ b/includes/class-ai-integration.php @@ -137,11 +137,17 @@ public static function generate_page( string $description ): array { return [ 'error' => $post_id->get_error_message() ]; } + $reasoning = $data['reasoning'] ?? ''; + + update_post_meta( $post_id, '_waygate_reasoning', $reasoning ); + update_post_meta( $post_id, '_waygate_patterns', wp_json_encode( $data['patterns'] ) ); + update_post_meta( $post_id, '_waygate_generated_at', current_time( 'mysql' ) ); + return [ 'title' => $data['title'] ?? $description, 'patterns' => $data['patterns'], 'pattern_count' => count( $data['patterns'] ), - 'reasoning' => $data['reasoning'] ?? '', + 'reasoning' => $reasoning, 'edit_url' => get_edit_post_link( $post_id, 'raw' ), 'view_url' => get_permalink( $post_id ), ]; From 847867e8b2ce4d6ce2ec527add99075904080508 Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Sun, 24 May 2026 14:43:20 +0700 Subject: [PATCH 2/3] chore: bump version to 0.5.0 --- waygate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/waygate.php b/waygate.php index 4b19d09..2bc21c5 100644 --- a/waygate.php +++ b/waygate.php @@ -3,7 +3,7 @@ * Plugin Name: Waygate * Plugin URI: https://github.com/imagewize/waygate * Description: AI-powered pattern page builder for the Elayne block theme. Lists registered patterns, creates pages from pattern slugs, and integrates with WordPress AI Client for natural-language page generation. - * Version: 0.4.0 + * Version: 0.5.0 * Author: Jasper Frumau * Author URI: https://imagewize.com * License: GPL-2.0-or-later @@ -16,7 +16,7 @@ defined( 'ABSPATH' ) || exit; -define( 'WAYGATE_VERSION', '0.4.0' ); +define( 'WAYGATE_VERSION', '0.5.0' ); define( 'WAYGATE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'WAYGATE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); From baadfd9a5953647724e2474299c42ddfe3da99a6 Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Sun, 24 May 2026 14:43:25 +0700 Subject: [PATCH 3/3] docs: update CHANGELOG and README for v0.5.0 --- CHANGELOG.md | 10 ++++++++++ README.md | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee4b868..c328b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to Waygate will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.0] - 2026-05-24 + +### Added +- AI reasoning and selected pattern slugs are now persisted as post meta (`_waygate_reasoning`, `_waygate_patterns`, `_waygate_generated_at`) on every Waygate-generated page +- "Waygate" meta box on the page editor sidebar — always shows the AI reasoning sentence; shows generation timestamp and ordered pattern slug list when `WP_ENV=development` +- Success notice in Tools → Waygate now shows the ordered pattern slugs when `WP_ENV=development` + +### Documentation +- `README.md` updated with AI reasoning and developer debug info features; version badge bumped to 0.5.0 + ## [0.4.0] - 2026-05-24 ### Added diff --git a/README.md b/README.md index 7258f30..6036c76 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Waygate lets you assemble WordPress pages from block patterns — manually or via a natural-language AI prompt powered by the WordPress AI Client (WordPress 7.0+). Works with any block theme; [Elayne](https://github.com/imagewize/elayne) is the primary supported theme. -> **Beta** — v0.4.0. Use on staging/development sites; not yet recommended for production. +> **Beta** — v0.5.0. Use on staging/development sites; not yet recommended for production. --- @@ -12,6 +12,8 @@ Waygate lets you assemble WordPress pages from block patterns — manually or vi - **Pattern catalog** — Browse registered block patterns with slug, title, and categories; filter by category - **AI page generation** — Describe the page you want; the AI picks patterns and creates a draft +- **AI reasoning** — The AI's one-sentence explanation of its pattern choices is shown after generation and persisted as post meta on the created page +- **Developer debug info** — When `WP_ENV=development`, the page editor sidebar and the generation notice also show the ordered pattern slugs and generation timestamp - **Feature detection** — AI form is hidden automatically when no provider supports text generation - **Abilities API** — Exposes `elayne/list-patterns` and `elayne/create-page` abilities for WP 7.0+ - **Multi-provider** — Works with Mistral, Claude, OpenAI, or Gemini via WP AI Client