Skip to content

Studio Code: Refuse wp and studio commands in Bash, naming the tool to use - #5163

Closed
chubes4 wants to merge 1 commit into
trunkfrom
studio-code/bash-refuses-wp-and-site-commands
Closed

chubes4 wants to merge 1 commit into
trunkfrom
studio-code/bash-refuses-wp-and-site-commands

Conversation

@chubes4

@chubes4 chubes4 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude (via the Pi coding agent in a Roadie session) went through the system prompt rule by rule looking for rules a tool can enforce, then wrote the change and its tests and ran the checks below. Opened as a draft for human review.

Proposed Changes

  • The prompt told Studio Code never to run wp in Bash and never to create, start or stop sites from the shell. Now Bash refuses those commands and names the tool to use instead:
    • wp … and wp-cli.phar are refused with a pointer to wp_cli.
    • studio … is refused with the site tools (site_create, site_start, site_stop, …).
  • The guard checks the first word of every command in the line, after &&, ;, | or inside $( ). Quoted text and arguments are ignored, so grep "wp option" and ls wp-content still run.
  • The rule is removed from Studio Code's prompt. External agents over MCP run their own shell, which Studio cannot guard, so they get a one-line version of it.

Testing Instructions

  • npx vitest run apps/cli/ai/tests/bash-command-refusal.test.ts covers the commands that are refused and the ones that still run.

Pre-merge Checklist

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

@chubes4

chubes4 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #5166. Rather than refusing wp in Bash, #5166 makes wp in the agent's shell run Studio's WP-CLI (same runtime as wp_cli), and removes the prompt rule the same way. This PR's rule dates from when sites ran in PHP-WASM.

Comment written by Claude (via the Pi coding agent in a Roadie session) at the maintainer's direction.

@chubes4 chubes4 closed this Oct 16, 2026
@chubes4
chubes4 deleted the studio-code/bash-refuses-wp-and-site-commands branch October 16, 2026 22:40
chubes4 added a commit that referenced this pull request Oct 16, 2026
…fusals already carry (#5162)

## Related issues

- Related to #5146: one of a series of small changes that move system
prompt rules into tool structure

## How AI was used in this PR

Claude (via the Pi coding agent in a Roadie session) went through the
system prompt rule by rule looking for rules a tool can enforce, then
wrote the change and its tests and ran the checks below. Opened as a
draft for human review.

## Proposed Changes

- The Working cadence section listed the Write, Edit and Bash payload
limits and warned against heredocs and Python scripts. The tools already
enforce all of this: an oversized call is refused, and the refusal says
how to split the work (a skeleton plus Edit calls) and not to fall back
to heredocs or scripts.
- That prompt text is removed, cutting the prompt by about 340
characters. The ~8KB-per-Edit target the agent actually uses is in the
`block-content` skill's recipes, where the long files are written.
- `STUDIO_EDIT_CALL_TARGET_BYTES` was only used by that text, so it is
removed too.

## Testing Instructions

- `npx vitest run apps/cli/ai` passes. The pi runtime tests still check
that oversized Write, Edit and Bash calls are refused.

Targeted eval (one prompt asking for a ~24 KB plugin file, judged on the
resulting site): with this change merged alongside #5163–#5165, the
first oversized `Write` was refused on every run, and the agent built
the file with smaller edits, as on trunk. Pass rate matched trunk (1/2
on each arm; the failing run on both arms is the same assertion issue,
unrelated to this change).

## Pre-merge Checklist

- [ ] Have you checked for TypeScript, React or other console errors?
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