Replace Strauss with Mozart for wordpress/mcp-adapter namespace prefixing#1282
Open
circlecube wants to merge 7 commits into
Open
Replace Strauss with Mozart for wordpress/mcp-adapter namespace prefixing#1282circlecube wants to merge 7 commits into
circlecube wants to merge 7 commits into
Conversation
…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
Contributor
🎮 WordPress Playground PreviewThis spins up a fresh WordPress-in-browser, installs this PR's plugin build, and drops you straight into the Bluehost screen. Preview Details
⚠ 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
Contributor
|
Coverage: Base 26.12% → PR 26.12% (must not decrease). |
- 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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wordpress/mcp-adapterand its dependencywordpress/php-mcp-schemaWP\MCP\→Bluehost\Plugin\WP\MCP\andWP\McpSchema\→Bluehost\Plugin\WP\McpSchema\invendor-prefixed/bin/mozartwrapper silently exits 0 on PHP < 8.1 so PHPCS/codecoverage jobs (PHP 7.4) are unaffectedpost-autoload-dumphook by using standard Composerautoload.psr-4mappings instead of Strauss's proprietaryinclude-autoloadercommandWhat changed
composer.jsonextra.strauss→extra.mozart(packages: mcp-adapter + php-mcp-schema);autoload.psr-4entries for both prefixed namespaces;ensure-mozart/bin/mozart.pharscripts; removedpost-autoload-dumphookcomposer.lockcontent-hashto match newextra.mozartconfigbin/mozart.gitignorebin/strauss.phar→bin/mozart.phar.distignorebootstrap.phpHow autoloading works now
Before (Strauss): Strauss's
include-autoloadercommand modifiedvendor/autoload.phpdirectly after every autoload dump via apost-autoload-dumphook.After (Mozart): PSR-4 entries in
composer.jsonmap the prefixed namespaces to theirvendor-prefixed/locations. Standardcomposer dump-autoload(called at the end ofprefix-namespaces) picks this up natively — no hook needed.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: falsepreserves the originalvendor/wordpress/mcp-adapter/andvendor/wordpress/php-mcp-schema/alongside the prefixed copies (mirrors Strauss'sdelete_vendor_packages: false)ensure-mozartscript (same pattern as Strauss was), so it works withcomposer install --no-devin CI without requiring Mozart as a Composer dependencybin/mozartwrapper pre-registers the PHAR alias to work around a known Mozart PHAR stub bug, and silently skips on PHP < 8.1CI status
All checks pass: Build Plugin ✅ · Run PHP Code Sniffer ✅ · On Push ✅ · playground-preview ✅ · codecoverage (all PHP versions) ✅ · CodeQL ✅
Playwright failures (
wp-env startexit 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
composer installlocally and verifyvendor-prefixed/wordpress/mcp-adapter/includes/andvendor-prefixed/wordpress/php-mcp-schema/src/are created withBluehost\Plugin\WP\MCP\andBluehost\Plugin\WP\McpSchema\namespaces respectivelyvendor/autoload.phpresolves both prefixed namespace classes after installvendor/wordpress/mcp-adapter/andvendor/wordpress/php-mcp-schema/still exist (delete_vendor_directories: false)https://claude.ai/code/session_01JUvFjmTwDxXHX8Y7mEULtT