Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

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.

---

## Features

- **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
Expand Down
51 changes: 51 additions & 0 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -230,6 +231,10 @@ private static function status_notices( bool $ai_available, bool $text_gen_suppo
<?php
}

private static function is_dev(): bool {
return defined( 'WP_ENV' ) && 'development' === WP_ENV;
}

private static function result_notice( array $result ): void {
if ( isset( $result['error'] ) ) {
echo '<div class="notice notice-error"><p><strong>Error:</strong> ' . esc_html( $result['error'] ) . '</p></div>';
Expand All @@ -245,6 +250,11 @@ private static function result_notice( array $result ): void {
<p style="margin:0 0 6px;font-size:12px;color:#555">
<strong>AI reasoning:</strong> <?php echo esc_html( $result['reasoning'] ); ?>
</p>
<?php if ( self::is_dev() ) : ?>
<p style="margin:0 0 6px;font-size:12px;color:#888">
<strong>Patterns (dev):</strong> <?php echo esc_html( implode( ' → ', $result['patterns'] ) ); ?>
</p>
<?php endif; ?>
<p style="margin:0">
<a href="<?php echo esc_url( $result['edit_url'] ); ?>" class="button button-primary">Edit page</a>
&nbsp;
Expand All @@ -253,4 +263,45 @@ private static function result_notice( array $result ): void {
</div>
<?php
}

public static function register_meta_box(): void {
add_meta_box(
'waygate-info',
'Waygate',
[ self::class, 'render_meta_box' ],
'page',
'side',
'low'
);
}

public static function render_meta_box( \WP_Post $post ): void {
$reasoning = get_post_meta( $post->ID, '_waygate_reasoning', true );

if ( ! $reasoning ) {
echo '<p style="color:#888;margin:0;font-size:12px">Not generated by Waygate.</p>';
return;
}

echo '<p style="margin:0 0 8px;font-size:12px"><strong>AI reasoning</strong><br>' . esc_html( $reasoning ) . '</p>';

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 '<p style="margin:0 0 6px;font-size:11px;color:#888"><strong>Generated:</strong> ' . esc_html( $generated_at ) . '</p>';
}

if ( $patterns ) {
echo '<p style="margin:0 0 4px;font-size:11px;color:#888"><strong>Patterns</strong></p>';
echo '<ol style="margin:0;padding-left:16px;font-size:11px;color:#555">';
foreach ( $patterns as $slug ) {
echo '<li><code>' . esc_html( $slug ) . '</code></li>';
}
echo '</ol>';
}
}
}
}
8 changes: 7 additions & 1 deletion includes/class-ai-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
];
Expand Down
4 changes: 2 additions & 2 deletions waygate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__ ) );

Expand Down
Loading