Repository navigation
Studio Code: Read wp_cli --post_content quoting the way a shell does - #5312
Merged
Merged
Conversation
1 task done
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
--post_contentJSON that doesn't parse. In the Studio Code: Refuse wp_cli --post_content JSON that does not parse #5310 eval, both refusals were valid JSON thatwp_clihad broken while splitting the command. This PR splits those commands correctly, so they save as written. It is independent of Studio Code: Refuse wp_cli --post_content JSON that does not parse #5310 and can merge in either order.How AI was used
Claude (via the Pi coding agent in a Roadie session) found the two quoting forms in eval transcripts, wrote the change and tests, and ran the checks below. I reviewed the diff and the results.
Proposed Changes
wp_clinow reads a quoted--post_contentvalue the way a shell would, in the two forms agents used where it didn't before:--post_content="{\"styles\":…}". The value used to stop at the first\", so{\was saved as the post content. Inside double quotes, a backslash now escapes",\,$and backticks. Single-quoted values stay literal.'--post_content={"styles":…}'. The closing'used to become part of the content. A quote just before--post_content=now wraps the whole value.In both cases WP-CLI saved the broken content and printed
Success: Updated post 5.. Global Styles JSON that doesn't parse is ignored by WordPress, so the background change never showed and the agent started debugging.What else changes: in 118 inline
--post_contentwrites from 535 local agent transcripts, these two forms appear only in the two eval runs above. No double-quoted value contains any other backslash, so content written in the forms agents already use splits as before.Testing Instructions
npx vitest run apps/cli/ai/tests/tools.test.tscovers both forms with a trailing--porcelain. Both tests fail on trunk, and the existing quoting tests still pass.wp_clion theglobal-styles-db-overridesite, now save the intended JSON (post get 5 --field=post_contentreturns it). The front end renders the new#1e2a44background, and the user's line height1.7is kept.npx vitest run apps/cli/ai apps/cli/lib/tests/wp-cli-post-content.test.tspasses. Lint passes, and the typecheck shows only the existing errors incommands/export.tsandcommands/push.ts.Pre-merge Checklist