Repository navigation
fix: update rewrite list ability to categorize rules and sample output - #159
Conversation
|
Fixes #113 |
There was a problem hiding this comment.
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_detailsinput and detailedrulesoutput from the ability schema/result. - Adds rule categorization logic and returns
rule_categories(counts by category) plusrule_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.
| $sampled_count = count( $sample ); | ||
|
|
||
| while ( $sampled_count < $sample_limit ) { |
There was a problem hiding this comment.
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.
| $sampled_count = count( $sample ); | |
| while ( $sampled_count < $sample_limit ) { | |
| while ( count( $sample ) < $sample_limit ) { |
| 'default' => false, | ||
| ), | ||
| ), | ||
| 'properties' => array(), |
There was a problem hiding this comment.
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.
| '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, | |
| ), | |
| ), |
| * | ||
| * @param array $input Input parameters. | ||
| * @return array | ||
| */ |
There was a problem hiding this comment.
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).
| */ | |
| */ | |
| // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed |
pluginslab
left a comment
There was a problem hiding this comment.
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!
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:
.github/workflows/ci.yml) that runs PHP lint, JS lint, unit tests, and build checks on every pull request todevandmain, improving code quality and reliability..env.examplewith a configurable S3 endpoint for anonymous feedback uploads, supporting local development and privacy controls.Ability Development and Extensibility:
build-abilityClaude 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..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:
wp-abilities-apiskill (.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..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:
PROGRESS.mdwith 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:
Ability Building and Patterns:
build-abilityskill for automated, interview-driven ability scaffolding, with a reference for patterns and conventions. [1] [2]WP Abilities API Reference:
Project Progress:
PROGRESS.mdwith new PRs, features, and contributor achievements, documenting the project's ongoing momentum. [1] [2]