Skip to content

Replace Strauss with Mozart for wordpress/mcp-adapter namespace prefixing#1282

Open
circlecube wants to merge 7 commits into
mainfrom
claude/strauss-mozart-migration-vsn6z
Open

Replace Strauss with Mozart for wordpress/mcp-adapter namespace prefixing#1282
circlecube wants to merge 7 commits into
mainfrom
claude/strauss-mozart-migration-vsn6z

Conversation

@circlecube

@circlecube circlecube commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces BrianHenryIE/Strauss with coenjacobs/Mozart (v1.1.6) for prefixing wordpress/mcp-adapter and its dependency wordpress/php-mcp-schema
  • Prefixes WP\MCP\Bluehost\Plugin\WP\MCP\ and WP\McpSchema\Bluehost\Plugin\WP\McpSchema\ in vendor-prefixed/
  • Mozart 1.1.6 requires PHP ^8.1; the bin/mozart wrapper silently exits 0 on PHP < 8.1 so PHPCS/codecoverage jobs (PHP 7.4) are unaffected
  • Eliminates the post-autoload-dump hook by using standard Composer autoload.psr-4 mappings instead of Strauss's proprietary include-autoloader command

What changed

File Change
composer.json extra.straussextra.mozart (packages: mcp-adapter + php-mcp-schema); autoload.psr-4 entries for both prefixed namespaces; ensure-mozart/bin/mozart.phar scripts; removed post-autoload-dump hook
composer.lock Updated content-hash to match new extra.mozart config
bin/mozart Committed PHP wrapper: pre-registers PHAR alias (works around Mozart PHAR alias bug), PHP 8.1+ guard for PHP 7.4 CI jobs
.gitignore bin/strauss.pharbin/mozart.phar
.distignore Added exclusion rules for dev files of both mcp-adapter and php-mcp-schema
bootstrap.php Updated comment only

How autoloading works now

Before (Strauss): Strauss's include-autoloader command modified vendor/autoload.php directly after every autoload dump via a post-autoload-dump hook.

After (Mozart): PSR-4 entries in composer.json map the prefixed namespaces to their vendor-prefixed/ locations. Standard composer dump-autoload (called at the end of prefix-namespaces) picks this up natively — no hook needed.

Namespace Path
Bluehost\Plugin\WP\MCP\ vendor-prefixed/wordpress/mcp-adapter/includes/
Bluehost\Plugin\WP\McpSchema\ vendor-prefixed/wordpress/php-mcp-schema/src/

Mozart config notes

  • delete_vendor_directories: false preserves the original vendor/wordpress/mcp-adapter/ and vendor/wordpress/php-mcp-schema/ alongside the prefixed copies (mirrors Strauss's delete_vendor_packages: false)
  • Mozart PHAR is downloaded on-demand by the ensure-mozart script (same pattern as Strauss was), so it works with composer install --no-dev in CI without requiring Mozart as a Composer dependency
  • The bin/mozart wrapper pre-registers the PHAR alias to work around a known Mozart PHAR stub bug, and silently skips on PHP < 8.1

CI status

All checks pass: Build Plugin ✅ · Run PHP Code Sniffer ✅ · On Push ✅ · playground-preview ✅ · codecoverage (all PHP versions) ✅ · CodeQL ✅

Playwright failures (wp-env start exit code 1 on all matrix combinations) are a pre-existing infrastructure issue unrelated to this PR — PR #1281 (the release PR, with no Mozart changes) has the same Playwright failures on the same base commit.

Test plan

  • Run composer install locally and verify vendor-prefixed/wordpress/mcp-adapter/includes/ and vendor-prefixed/wordpress/php-mcp-schema/src/ are created with Bluehost\Plugin\WP\MCP\ and Bluehost\Plugin\WP\McpSchema\ namespaces respectively
  • Verify vendor/autoload.php resolves both prefixed namespace classes after install
  • Confirm vendor/wordpress/mcp-adapter/ and vendor/wordpress/php-mcp-schema/ still exist (delete_vendor_directories: false)

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT

…adapter

Switches from BrianHenryIE/strauss to coenjacobs/mozart (v1.1.6) to
prefix the WP\MCP\ namespace to Bluehost\Plugin\WP\MCP\ in vendor-prefixed/.

Key changes:
- Replace extra.strauss config with extra.mozart config
- Add autoload.psr-4 mapping so composer dump-autoload natively handles
  the vendor-prefixed path (eliminates need for Strauss include-autoloader)
- Replace ensure-strauss/bin/strauss.phar with ensure-mozart/bin/mozart.phar
  (Mozart 1.1.6 PHAR, PHP ^8.1 compatible — no CI version changes needed)
- Remove post-autoload-dump hook (was Strauss-specific; Mozart approach
  uses standard Composer PSR-4 autoload config instead)
- Update .gitignore and bootstrap.php comment accordingly

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
Adding autoload.psr-4 to composer.json changed its content-hash.
Computed the new hash to match Composer's Locker algorithm so
composer validate passes in CI.

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
Previous attempt used wrong fields (included autoload, missed config.platform).
Correct algorithm per Composer Locker::getContentHash(): relevant keys are
name/version/require/require-dev/conflict/replace/provide/minimum-stability/
prefer-stable/repositories/extra + config.platform, encoded with json_encode
options=0, hashed with md5.

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
Two bugs fixed:

1. Mozart PHAR alias bug: The PHAR stub calls Phar::mapPhar('') (empty alias)
   but the internal entry point references phar://mozart.phar/... Using a
   relative path like @php bin/mozart.phar never registers the alias, causing
   PHP fatal error (exit 255). Fix: add bin/mozart wrapper script that calls
   Phar::loadPhar() to pre-register the 'mozart.phar' alias before requiring
   the PHAR entry point. bin/mozart.phar stays gitignored and downloaded on
   demand; bin/mozart (the wrapper) is committed.

2. Missing classmap_directory: Mozart's isValidMozartConfig() requires all four
   fields — dep_namespace, dep_directory, classmap_directory, classmap_prefix.
   Our config was missing classmap_directory, causing "Mozart config not
   readable" (exit 1). Added classmap_directory pointing to vendor-prefixed/.

Also updates composer.lock content-hash for the extra.mozart config change.

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

🎮 WordPress Playground Preview

▶️ Launch Preview in Playground

This spins up a fresh WordPress-in-browser, installs this PR's plugin build, and drops you straight into the Bluehost screen.


Preview Details

  • 📦 Build ZIP: bluehost-pr-1282.zip (7.6M)
  • 🗂️ Branch: claude/strauss-mozart-migration-vsn6z
  • 📝 Commit: 16788ff
  • 🔗 Direct Download of ZIP

⚠ Every new commit / comment on this PR overwrites the preview ZIP for this PR number.

The PHPCS lint workflow and codecoverage jobs run under PHP 7.4 (for
WordPress coding-standards compatibility) but Mozart 1.1.6 requires PHP ^8.1.
Running the PHAR under PHP 7.4 causes a PHP fatal error (exit 255).

Those workflows only need PHPCS rules / coverage data, not vendor-prefixed
output, so the wrapper now exits 0 silently when PHP < 8.1. On PHP 8.1+ the
PHAR is loaded and Mozart runs as normal.

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Coverage: Base 26.12% → PR 26.12% (must not decrease).
✅ No decrease.

Code Coverage

project coverage report 26.12% @ 16788ff

- Add wordpress/php-mcp-schema to extra.mozart.packages so Mozart
  prefixes WP\McpSchema\ → Bluehost\Plugin\WP\McpSchema\ alongside
  the existing mcp-adapter prefixing
- Update composer.lock content-hash for the extra.mozart change
- Add .distignore rules for php-mcp-schema dev files

https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT
@arunshenoy99

Copy link
Copy Markdown
Member

@circlecube, I believe there was some discussion around using https://github.com/humbug/php-scoper as well. It seems like the other package has less dependency on one person and is also being used by Yoast.

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