Studio Code: run a WordPress language server (wp-lsp) alongside the agent - #4618
Draft
draganescu wants to merge 1 commit into
Draft
Studio Code: run a WordPress language server (wp-lsp) alongside the agent#4618draganescu wants to merge 1 commit into
draganescu wants to merge 1 commit into
Conversation
…pool, post-edit PHP diagnostics Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
This is an idea which I am not sure if worth exploring - grep is fine and fast. |
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.
Related issues
How AI was used in this PR
Built end-to-end in a Claude Code session (Fable 5): the model read the wp-lsp README and the agent runtime, proposed the integration architecture, implemented it, and wrote the tests. The integration test it wrote against the real server caught one real bug during development (a TDZ crash in the server pool that would have silently disabled the whole feature). I steered and reviewed the direction; line-by-line human review is still pending — one more reason this is a draft.
Proposed Changes
WordPress is held together by strings.
add_action( 'init', 'my_func' )names a function nothing calls directly;register_post_type( 'book' )creates a slug that turns up in a query three files away; a block's identity is spread acrossblock.json, PHP, and JS. None of that is visible to grep — and grep is what Studio Code does today when it needs to understand a site's code.This PR runs wp-lsp, a WordPress language server, next to the agent — one server per site, on Studio's bundled PHP, shipped with the CLI the same way phpMyAdmin is. The agent gets two things out of it:
Lsptool for exact answers instead of text matches: every callback attached to a hook (in priority order, including[ $this, 'method' ]ones), where a post type slug is registered, which files make up a block, where a script handle is enqueued.add_action( 'ini', … ), the warning — Unknown hook 'ini'. Did you mean 'init'? — lands directly in the Edit result, and the agent corrects itself in the same turn, before the user (or a screenshot loop) ever sees the bug. Same for wrong callback argument counts, deprecated hooks, and text-domain mismatches.Where the hopes are:
docs/design-docs/wp-lsp-agent.mddescribes concrete ways to measure the impact — A/B evals through the existing promptfoo runner (theSTUDIO_WP_LSP_PATHoverride doubles as a clean off-switch), grading finished sites with wp-lsp itself as an independent defect counter, and proposed Tracks counters including a "self-correction rate" (diagnostics reported vs. resolved within the session).Trade-offs and behavior notes:
Testing Instructions
Setup
npm install(postinstall downloads wp-lsp v0.2.0 intowp-files/).npm run cli:buildnode apps/cli/dist/cli/main.mjsWatch the agent catch its own bug
add_action( 'ini', 'demo_setup' );and an emptydemo_setup()function to my theme's functions.php, spelled exactly like that.Use the Lsp tool
wp_headin this site.postpost type registered? — to see it reach for Lsp on its own.Confirm the fallback is clean
mkdir -p /tmp/empty && STUDIO_WP_LSP_PATH=/tmp/empty node apps/cli/dist/cli/main.mjsAutomated tests
npm test -- apps/cli/ai/lsp/tests/— 41 tests; the integration test drives the real wp-lsp binary over stdio (needsphpon PATH, auto-skips without it).npm run typecheckPre-merge Checklist
🤖 Generated with Claude Code