Skip to content

Studio Code: Read wp_cli --post_content quoting the way a shell does - #5312

Merged
chubes4 merged 1 commit into
trunkfrom
studio-code/wp-cli-post-content-quoting
Oct 23, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
studio-code/wp-cli-post-content-quoting

Conversation

@chubes4

@chubes4 chubes4 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Related issues

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_cli now reads a quoted --post_content value the way a shell would, in the two forms agents used where it didn't before:

  • Backslash-escaped quotes inside double quotes: --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.
  • Quotes around the whole argument: '--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_content writes 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.ts covers both forms with a trailing --porcelain. Both tests fail on trunk, and the existing quoting tests still pass.
  • Replay on a real site: the two commands from the Studio Code: Refuse wp_cli --post_content JSON that does not parse #5310 eval, run unchanged through wp_cli on the global-styles-db-override site, now save the intended JSON (post get 5 --field=post_content returns it). The front end renders the new #1e2a44 background, and the user's line height 1.7 is kept.
  • npx vitest run apps/cli/ai apps/cli/lib/tests/wp-cli-post-content.test.ts passes. Lint passes, and the typecheck shows only the existing errors in commands/export.ts and commands/push.ts.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@chubes4
chubes4 merged commit a54e115 into trunk Oct 23, 2026
13 checks passed
@chubes4
chubes4 deleted the studio-code/wp-cli-post-content-quoting branch October 23, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant