CLI: Add self-hosted WordPress site support via Application Passwords - #3105
CLI: Add self-hosted WordPress site support via Application Passwords#3105youknowriad wants to merge 4 commits into
Conversation
… Passwords Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I would love to manage my self-hosted sites from Studio. |
|
My Claude review found these notable items: Pass 1 — CRITICALHTTP scheme accepted; Basic Auth sent in cleartext.
Fix: Require
Prompt injection via untrusted site name.
The connect probe reads data.name from Fix: Strip control characters / newlines, length-cap (e.g. 80 chars), and consider treating it as a quoted data field (e.g. No fetch timeout — agent can hang.
Both the connection probe and every Fix: Backspace-as-delete is a footgun.
On the self-hosted tab, when search query is empty, backspace immediately enters a delete-confirm flow. Hint text mentions it, but a stray keystroke + accidental "Yes" wipes credentials. The mismatch with the WP.com tab (where backspace does nothing destructive) makes it especially surprising. Fix: Bind delete to an explicit key (d or Delete), and/or require typing the site name to confirm. Error response body forwarded into LLM context unbounded.
On non-2xx, Fix: Cap body length (e.g. 4 KB), parse JSON and surface only code/message when possible. wp_request path traversal escapes the /wp/v2/ namespace.
Fix: Reject paths containing |
|
Should we at least require self-hosted sites to have Jetpack installed to connect with Studio? |
|
In my opinion, Studio should remain generic and not have any blockers for self-hosted sites. For example, I don't (currently) use Jetpack on my sites so this would block me from developing with Studio. I think it would be best to make Studio so useful as a general-purpose WordPress development environment that everyone who uses WP wants to use Studio for everything, regardless of whether or not they use our other products. I would love to take self-hosted support even further and include direct SSH access via Studio Code so users can execute remote commands on their live sites. |
|
I agree that ideally we don't require anything at first (for basic modifications and using the agent), an application password like this PR requests should be enough. That said, I do believe that later we could ask the users to install Jetpack if they trigger "push" or things like that, because these features will be provided by Jetpack and not available by default in WP sites. |
|
If anyone would like to take over this PR and push it, please do, I'm a little bit on other stuff at the moment. |
The original branch predates the pi-coding-agent runtime: agent.ts and tools.ts no longer exist, tools are one-per-file under ai/tools/, and endpoint guidance lives in skills instead of the system prompt. The self-hosted feature is re-integrated accordingly: wp_request is a defineTool-based tool with staged body-file support, credentials are resolved from cli.json at turn time instead of being carried on SiteInfo, connection validation hits an authenticated endpoint, and a self-hosted-remote-management skill replaces the inline endpoint docs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Revived this PR by merging Architecture port
Improvements over the original branch
Verified: Known limitations / follow-up candidates
|
I think I had this similar issue with Telex. |
📊 Performance Test ResultsComparing 9435b5e vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
…nk self-hosted sites work Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Looked into this. Added a discovery for api base URL. Would we want this to show in UI too? |
|
@draganescu probably as a follow-up yeah. This is being discussed in https://a8c.slack.com/archives/C08LZ79MKG9/p1783336369753759 |
|
@youknowriad is this being replaced by #4104? Besides that, I'm marking it as a draft until conflicts are fixed. |
|
Both have their place IMO. Both PRs can be shipped quickly but at this point, it's about whether we want them or not. It seems for now the answer is "no". So I'm just leaving them for later. |
|
Thanks for confirming that @youknowriad - let's keep them as drafts then. |
Related issues
How AI was used in this PR
This PR was co-authored with Claude. All code was reviewed and approved by the developer.
Proposed Changes
wp_requestagent tool that talks to the site's own WordPress REST API via Basic Auth — the self-hosted counterpart ofwpcom_request, including stagedbodyFile/bodyFilespayloads for large generated content and plugin namespaces (e.g.wc/v3)self-hosted-remote-managementskill, mirroring how WordPress.com remote guidance is deliveredcli.jsonand resolved at turn time — they are never persisted in session transcripts, so resumed sessions reconnect safelyTesting Instructions
npm run cli:build && node apps/cli/dist/cli/main.mjs code--resume) and verify the agent still operates on the self-hosted sitePre-merge Checklist