Expose URL Metric to Chrome DevTools for agents#2571
Conversation
…r agents - Add devtools-discovery.js extension module registering two read-only tools (get_od_url_metric, get_od_element_data) via the devtoolstooldiscovery event - Register it through the existing od_extension_module_urls filter, gated on WP_DEBUG - Add tests and a short docs note Lets an AI coding agent inspect the URL Metric being collected for the current page load while debugging performance, via Chrome DevTools for agents third-party tools API. Fixes WordPress#2553
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2571 +/- ##
==========================================
+ Coverage 70.35% 70.37% +0.02%
==========================================
Files 91 91
Lines 7867 7873 +6
==========================================
+ Hits 5535 5541 +6
Misses 2332 2332
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Fixes #2553
Adds a small Optimization Detective extension module that registers with Chrome's new DevTools for agents third-party tools API. It exposes two read-only tools,
get_od_url_metricandget_od_element_data, so an AI coding agent can inspect the URL Metric being collected for the current page load while debugging performance. Only active whenWP_DEBUGis enabled.Relevant technical choices
devtools-discovery.js), same mechanism Embed Optimizer and Image Prioritizer already use via theod_extension_module_urlsfilter. No changes to coredetect.js.getRootData()/getElementData()functions that are already handed to every extension'sinitialize(), so there's no new state tracking.WP_DEBUGis true, since this is a debugging feature and should cost nothing in production (no extra listener, no extra data collection).How to test
WP_DEBUGset totrue.--categoryExperimentalThirdParty=true.get_od_url_metricandget_od_element_data.get_od_url_metric, confirm it returns the current URL Metric (viewport + tracked elements).WP_DEBUGtofalse, reload, confirm the tool group no longer appears.Also ran
composer test:optimization-detective,composer lint:optimization-detective,npm run phpstan, andnpm run tsclocally, all passing.