Skip to content

refactor: ability manifest as single source of truth (v0.11 PR 1/4) - #191

Merged
pluginslab merged 1 commit into
devfrom
feature/abilities-manifest
May 11, 2026
Merged

pluginslab merged 1 commit into
devfrom
feature/abilities-manifest

Conversation

@pluginslab

Copy link
Copy Markdown
Owner

Summary

First of four PRs implementing the v0.11 strip-down strategy from the v1 Roadmap doc. Zero behavior change — every ability that was registered before is still registered after.

Replaces 160+ lines of conditional `register_*()` calls in `class-abilities.php` and 60+ lines of `registerX()` calls in `src/extensions/abilities/index.js` with a single foreach over a categorized manifest.

What's new

  • `includes/abilities-manifest.php` — PHP source of truth with three categories (core / local-only / labs), a `WP_AGENTIC_ADMIN_ENABLE_LABS` constant, and a `wp_agentic_admin_enabled_abilities` filter for power-user / hosting-partner extensibility.
  • `src/extensions/abilities/manifest.js` — JS mirror with `REGISTRARS` map plus `LOCAL_ONLY_ABILITIES` and `LABS_ABILITIES` sets.
  • `registerAllAbilities()` reads `window.wpAgenticAdmin.enabledAbilities` if present (defaults to all keys in REGISTRARS), so PR 4 can wire the PHP-filtered list to the JS side without touching this code again.

What's the same

  • 39 PHP abilities resolved (verified via PHP smoke test).
  • All JS registrars still called.
  • Third-party `do_action( 'wp_agentic_admin_register_abilities' )` extensibility unchanged.

Roadmap context

PR Scope
1. This PR Manifest pattern, no behavior change
2. Drop Whisper from webpack entries, remove voice UI
3. Delete 6 dead features (backup-check, opcode-cache-status, disk-usage, webmcp-bridge, feedback, core-editor-blocks)
4. Flip default to core+local-only; labs requires `WP_AGENTIC_ADMIN_ENABLE_LABS`

Tests

  • New `src/extensions/abilities/tests/manifest.test.js` — 7 cases covering structural contract, expected slug sets, no-overlap invariant.
  • Full suite: 117 passing (was 110), 3 skipped, 0 failures.

Test plan

  • PHP lint passes
  • JS lint passes
  • Unit tests pass
  • Manual: load plugin in playground, verify all 39 abilities are queryable by the LLM (or just check the tool list is unchanged)

🤖 Generated with Claude Code

Replaces 160+ lines of conditional register_*() calls in class-abilities.php
and 60+ lines of registerX() calls in src/extensions/abilities/index.js with
a single foreach over a categorized manifest.

New files:
  - includes/abilities-manifest.php — PHP manifest with core / local-only /
    labs categories and a wp_agentic_admin_enabled_abilities filter
  - src/extensions/abilities/manifest.js — JS mirror with REGISTRARS map,
    LOCAL_ONLY_ABILITIES, and LABS_ABILITIES sets

Behavior is unchanged in this PR: resolve_enabled_abilities() returns
every ability (39 PHP, all JS registrars), matching the pre-refactor
count exactly. Categorization is structural prep for later PRs that
will trim parked features and gate labs behind WP_AGENTIC_ADMIN_ENABLE_LABS.

Tests: new manifest.test.js (7 cases) covering structural contract,
expected core/local/labs slug sets, and no-overlap invariant.
Full suite: 117 passing (was 110), 3 skipped, 0 failures.

Part of the WP.org submission roadmap (v0.11 hardening).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@pluginslab
pluginslab force-pushed the feature/abilities-manifest branch from ea486c4 to 85386ba Compare May 11, 2026 21:32
@pluginslab
pluginslab merged commit 95110c1 into dev May 11, 2026
8 checks passed
@pluginslab
pluginslab deleted the feature/abilities-manifest branch May 11, 2026 21:39
pluginslab added a commit that referenced this pull request May 12, 2026
Removes the first batch of parked features per the v1 Roadmap doc:
features deemed low-comeback-probability that don't merit code preservation.

Deleted:
  - backup-check (low accuracy — guesses backup plugins by slug)
  - opcode-cache-status (niche, most admins don't care)
  - disk-usage (nice-to-have, not essential)
  - core-editor-blocks (orphaned, only useful if content-generate exists)

Total: 7 files removed (3 PHP + 4 JS), ~860 lines of source code.

Manifest updates:
  - Removed entries from PHP and JS labs manifests
  - Updated manifest.test.js expected labs slug set
  - Removed bundle references in ability-bundles.js (3 bundles cleaned)
  - Removed test cases in core-abilities.test.js (3 abilities)
  - Replaced disk-usage in issue-158.test.js with theme-list
  - Removed Disk usage e2e conversation test

Git history preserves the deleted code (recoverable via
`git show v0.10.0:includes/abilities/backup-check.php` etc.) for any
future need to consult the implementation.

Tests: 117 passing, 0 changed. Build succeeds.
Lint: clean (PHP + JS + Prettier).

Roadmap context:
  - PR #191: manifest pattern (merged)
  - PR #192: voice out of default build (merged)
  - PR 3a (this): delete 4 simple abilities
  - PR 3b (next): delete webmcp-bridge
  - PR 3c (after): delete feedback system
  - PR 4 (last): flip default to core+local-only; labs requires
    WP_AGENTIC_ADMIN_ENABLE_LABS

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pluginslab added a commit that referenced this pull request May 12, 2026
Last piece of the v0.11 strip-down. Labs (parked) abilities now require
opt-in to be registered, completing the WordPress.org submission path.

PHP — includes/abilities-manifest.php:
  resolve_enabled_abilities() now gates the labs array on the
  WP_AGENTIC_ADMIN_ENABLE_LABS constant. The wp_agentic_admin_enabled_abilities
  filter remains the per-ability override path:

    define( 'WP_AGENTIC_ADMIN_ENABLE_LABS', true );        // all labs
    add_filter( 'wp_agentic_admin_enabled_abilities', ... ); // selective

  New helper: wp_agentic_admin_labs_enabled() — single source of truth
  for the boolean.

PHP — includes/class-admin-page.php:
  Localizes two new fields on window.wpAgenticAdmin:
    - enabledAbilities: PHP-resolved slug list (the result of the
      filter above)
    - enableLabs: bool, mirrors wp_agentic_admin_labs_enabled()

  PHP becomes authoritative for which PHP-backed abilities the JS
  manifest registers.

JS — src/extensions/abilities/manifest.js:
  New JS_ONLY_ABILITIES set captures the slugs that have no PHP
  register function (current-user-role, core-site-info, core-environment-info,
  codebase-index, code-search, wp-config-list, content-generate).
  PHP's enabledAbilities list can't include these, so JS adds them
  back. Members that are also LABS are gated by enableLabs.

JS — src/extensions/abilities/index.js:
  registerAllAbilities() now delegates slug resolution to a new
  exported resolveEnabledSlugs() function:
    - With PHP-localized enabledAbilities: register that list ∪
      (JS_ONLY_ABILITIES minus labs-when-off)
    - Without (tests / dev): register all REGISTRARS minus LABS
      unless enableLabs is set

  Falls back gracefully when window.wpAgenticAdmin is unset, so
  Jest tests don't have to mock the global.

Tests:
  - manifest.test.js: 2 new cases covering JS_ONLY_ABILITIES contract
  - index.test.js (new file, 6 cases): PHP-authoritative path with
    labs on/off, empty PHP list edge case, fallback path with and
    without enableLabs

PHP smoke verification (manual):
  Without constant: 33 abilities resolved (CORE + LOCAL_ONLY)
  With constant:    39 abilities resolved (+6 labs)

Tests: 124 passing (was 117, +7 new).
Build: clean.
Lint: clean (PHP + JS + Prettier).

Roadmap context — END OF v0.11 STRIP-DOWN:
  - PR #191: manifest pattern ✅ merged
  - PR #192: voice out of default build ✅ merged
  - PR #193: delete 4 simple abilities (open)
  - PR #194: delete webmcp-bridge (open)
  - PR #195: delete feedback system (open)
  - PR 4 (this): flip default to core+local-only

After all six merge: ~3,800 LoC removed, 819 KB shipped bundle
dropped, 35 PHP abilities registered by default (down from 39),
plugin ready for WP.org submission (modulo the remaining 6 security
+ 6 compliance issues from the roadmap).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant