Add WordPress framework support - #983
Conversation
|
Two updates since opening. Removed four duplicated prompt lines. Telemetry. Still a draft pending PostHog/context-mill#279. |
The wizard had no way to recognize a WordPress project, so `npx @posthog/wizard` in a WordPress directory detected nothing and fell through to the Node fallback whenever a theme build had left a package.json behind. - `Integration.wordpress`, ordered after laravel and before the language fallbacks, so a site with a theme package.json resolves to WordPress - `src/frameworks/wordpress/` — a FrameworkConfig following the shape in .claude/skills/adding-framework-support, with composer package management and no package.json checks - detection covers the four real shapes: an installed site (wp-config.php, wp-load.php, wp-includes/version.php), unpacked core before install (wp-config-sample.php), a Composer-managed install where core is not in the root (roots/wordpress, johnpbloch/wordpress, wpackagist-*), and a standalone plugin or theme directory identified by its `Plugin Name:` / `Theme Name:` header - context gathering reports project type, plugins directory (including Bedrock's web/app/plugins), and an existing plugin entry file so the agent extends that plugin instead of creating a second one - prompts carry the WordPress-specific rules: plugin over functions.php, ABSPATH guard, esc_js on the token, client SDK for pageviews and the PHP SDK for server-side actions, flush after capture - version read from $wp_version in wp-includes/version.php, bucketed as 6.4.x - 9 detection tests, including the negative cases (a Laravel project and a plain Composer PHP project must not be claimed) Depends on PostHog/context-mill#279, which adds the matching `integration-wordpress` variant with `framework: wordpress`. The pinned skill-menu fixture in variant-resolution.test.ts is updated to match — without that variant released, the cross-repo contract test fails for wordpress. pnpm build, pnpm test (1576 passing), pnpm fix — all clean.
The prompt lines about shipping a plugin instead of editing functions.php, the ABSPATH guard, esc_js on the token, and flushing after capture are all in the wordpress block of context-mill's commandments.yaml, which reaches the agent with the skill. Repeating them here duplicates integration knowledge across the boundary AGENTS.md draws between the two repos, and would drift the moment either side is edited. getAdditionalContextLines now carries only what the skill cannot know: the project shape this run is pointed at. pnpm build, pnpm test (1576 passing), pnpm fix — clean.
3346c19 to
9df8cdc
Compare
|
Out of draft: PostHog/context-mill#279 (the skill-side half) merged today, so the cross-repo contract this PR pins now holds on both sides. Rebased on main — all 1553 tests pass, including |
Problem
The wizard has no way to recognize a WordPress project.
npx @posthog/wizardin a WordPress directory detects nothing — and when a theme build has left apackage.jsonbehind, detection falls through to the generic Node integration and gives advice that doesn't apply.WordPress is already a PostHog product surface: there are WordPress library docs, and WooCommerce is a supported data-warehouse source. The wizard just hadn't been told.
What this adds
Followed
.claude/skills/adding-framework-support/SKILL.mdstep by step.Integration.wordpress— ordered afterlaraveland before the language fallbacks, so a site whose theme carries apackage.jsonstill resolves to WordPress rather thanjavascript_node.src/frameworks/wordpress/— aFrameworkConfigmodelled on the Laravel one:usesPackageJson: false,composerPackageManager, version read from$wp_versioninwp-includes/version.phpand bucketed as6.4.x.wp-config.php,wp-load.php,wp-settings.php,wp-includes/version.phpwp-config-sample.phponlyroots/wordpress,johnpbloch/wordpress,wpackagist-*(Bedrock)Plugin Name:/Theme Name:headerweb/app/plugins), and any existing plugin entry file — so the agent extends that plugin instead of creating a second one.Where the WordPress rules live
Not here. An earlier commit had
getAdditionalContextLinescarrying the integration rules — plugin overfunctions.php, theABSPATHguard,esc_js()on the token, flush after capture. That was wrong: those are integration knowledge, which AGENTS.md places in context-mill, and they already exist in thewordpressblock ofcommandments.yamlin #279. Carrying them in both places would have drifted the first time either side was edited. They've been removed, and this config now passes only what the skill cannot know — the shape of the project this run is pointed at.Telemetry
analytics.getTagsreportsprojectType:site,plugin, ortheme. WordPress is the first CMS in the registry, and that split is the useful signal — whether people run the wizard against a whole site or inside a single plugin they're building. It surfaces alongsidedetected_frameworkwith no extra wiring.Cross-repo contract
variant-resolution.test.tsasserts every framework in theIntegrationenum resolves to a context-mill variant. AddingIntegration.wordpressfails that test until context-mill ships anintegration-wordpressvariant carryingframework: wordpress— which is exactly what PostHog/context-mill#279 adds. The pinnedskill-menu.jsonfixture here is updated to match.That test is why this PR waited in draft: merge order was context-mill#279 first, then this. #279 is now merged, so the order is satisfied.
Tests
9 new detection tests, including the negatives that matter — a Laravel project and a plain Composer PHP project must not be claimed by WordPress — plus an ordering test asserting a WordPress site beats the Node fallback.
Not included
No
wizard-workbenchtest app yet. The handbook's worked example forwizard mcp-analyticsputs test fixtures in the canonical set, so happy to add one there if you'd like this to go through the same end-to-end evaluation the other frameworks get.