Skip to content

fix: update rewrite list ability to categorize rules and sample output - #159

Merged
pluginslab merged 1 commit into
devfrom
fix/fix-rewrite-list-return-data
Mar 21, 2026
Merged

pluginslab merged 1 commit into
devfrom
fix/fix-rewrite-list-return-data

Conversation

@Lucisu

@Lucisu Lucisu commented Mar 21, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces significant improvements to developer experience, extensibility, and documentation for the WP Agentic Admin project. Key highlights include a new CI workflow for automated quality checks, a comprehensive "build-ability" skill for scaffolding new abilities, detailed references for both the WP Abilities API and ability-building patterns, and updates to project progress and environment configuration.

Developer Experience and Automation:

  • Added a GitHub Actions CI workflow (.github/workflows/ci.yml) that runs PHP lint, JS lint, unit tests, and build checks on every pull request to dev and main, improving code quality and reliability.
  • Introduced .env.example with a configurable S3 endpoint for anonymous feedback uploads, supporting local development and privacy controls.

Ability Development and Extensibility:

  • Added the build-ability Claude skill (.claude/skills/build-ability/SKILL.md) that guides developers through an interview-driven workflow to generate new abilities (PHP backend, JS frontend, registration, tests), including conventions and validation steps.
  • Provided a detailed ability patterns reference (.claude/skills/build-ability/references/ability-patterns.md) covering annotation-to-HTTP method mapping, schema requirements, JS conventions, and helper usage.

WP Abilities API Documentation:

  • Introduced the wp-abilities-api skill (.claude/skills/wp-abilities-api/SKILL.md) for tasks involving the WordPress Abilities API, including registration, REST exposure, and client consumption, with step-by-step procedures and troubleshooting.
  • Added concise guides for PHP registration (.claude/skills/wp-abilities-api/references/php-registration.md) and REST API usage (.claude/skills/wp-abilities-api/references/rest-api.md), clarifying hooks, arguments, and debugging steps. [1] [2]

Project Documentation and Progress:

  • Updated PROGRESS.md with detailed summaries of recent PRs, new abilities, contributor highlights, and milestone achievements, reflecting the project's rapid development and community contributions. [1] [2]

Developer Automation and Environment:

  • Added a GitHub Actions CI workflow to automate linting, testing, and build checks for both PHP and JS codebases.
  • Provided an example environment variable file for feedback upload configuration.

Ability Building and Patterns:

  • Introduced the build-ability skill for automated, interview-driven ability scaffolding, with a reference for patterns and conventions. [1] [2]

WP Abilities API Reference:

  • Added a skill and reference guides for using and registering abilities with the WordPress Abilities API, including REST exposure and troubleshooting. [1] [2] [3]

Project Progress:

  • Expanded PROGRESS.md with new PRs, features, and contributor achievements, documenting the project's ongoing momentum. [1] [2]

@Lucisu

Lucisu commented Mar 21, 2026

Copy link
Copy Markdown
Collaborator Author

Fixes #113

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the rewrite-list ability to return a higher-level, more digestible view of WordPress rewrite rules by grouping them into categories and returning a balanced sample of rules instead of optionally returning the full ruleset.

Changes:

  • Removes the show_details input and detailed rules output from the ability schema/result.
  • Adds rule categorization logic and returns rule_categories (counts by category) plus rule_sample (representative rules across categories).
  • Introduces helper functions to normalize rule queries, detect categories, and build the balanced sample.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +244 to +246
$sampled_count = count( $sample );

while ( $sampled_count < $sample_limit ) {

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_agentic_admin_get_rewrite_rule_sample() uses $sampled_count in the while condition but never updates it inside the loop. This can cause the loop to ignore $sample_limit and keep appending rules until categories are exhausted (and potentially exceed the limit by a lot). Use while ( count( $sample ) < $sample_limit ) (or update $sampled_count each iteration) so the loop terminates correctly at the requested limit.

Suggested change
$sampled_count = count( $sample );
while ( $sampled_count < $sample_limit ) {
while ( count( $sample ) < $sample_limit ) {

Copilot uses AI. Check for mistakes.
'default' => false,
),
),
'properties' => array(),

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input schema now declares an empty properties set with additionalProperties: false, which means any provided argument will be rejected by schema validation. The frontend currently sends show_details for this ability (see src/extensions/abilities/rewrite-list.js), so this change will likely break calls at runtime. Either re-add show_details to the schema (even if deprecated/ignored), or update the client to stop sending it and relax schema validation accordingly.

Suggested change
'properties' => array(),
'properties' => array(
// Kept for backward compatibility with the frontend, which still sends `show_details`.
'show_details' => array(
'type' => 'boolean',
'description' => __( 'Whether to include detailed information in the response. Deprecated and currently ignored.', 'wp-agentic-admin' ),
'default' => false,
),
),

Copilot uses AI. Check for mistakes.
*
* @param array $input Input parameters.
* @return array
*/

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_agentic_admin_execute_rewrite_list() no longer uses the $input parameter after removing show_details, so this will be flagged by PHPCS (other abilities add a // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter... when the callback signature requires an unused param). Add the appropriate PHPCS ignore (or otherwise use/remove the parameter if the callback signature allows).

Suggested change
*/
*/
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed

Copilot uses AI. Check for mistakes.

@pluginslab pluginslab left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix for #56 — categorized rules with balanced sampling instead of raw dump or bare count. LLM-friendly output that fits in context window. LGTM!

@pluginslab
pluginslab merged commit d3da7dc into dev Mar 21, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants