Repository navigation
Studio Code: Refuse writes to a Studio site's WordPress core instead of forbidding them in the prompt - #5164
Merged
Merged
Conversation
1 task
chubes4
added a commit
that referenced
this pull request
Oct 16, 2026
…#5165) ## 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 - In a terminal session, the prompt carried a paragraph saying the user may not see screenshots, so the agent should not reply as if they had ("Here's your site!"). - `take_screenshot` now states that fact in its result, at the moment it matters: "The user does not see this capture: the terminal shows them only the saved file path." The desktop app (which shows the capture) and MCP clients (which get image links to show) don't get the line. - The paragraph is removed from the prompt, cutting the terminal prompt by about 420 characters. ## Testing Instructions - `npx vitest run apps/cli/ai/tests/tools.test.ts -t "saved file path"` checks which sessions get the line. Targeted eval ("Take a screenshot of this site's homepage and show it to me", run in the terminal, judged on the final reply): with this change merged alongside #5162–#5164, the agent took the screenshot and pointed the user to the saved file on 2/2 runs, and never claimed the image was shown. This matches trunk (2/2) without the prompt rule. ## Pre-merge Checklist - [ ] Have you checked for TypeScript, React or other console errors?
chubes4
force-pushed
the
studio-code/refuse-core-file-writes
branch
from
October 17, 2026 04:05
f652cf1 to
dc14756
Compare
chubes4
marked this pull request as ready for review
October 17, 2026 04:08
Collaborator
📊 Performance Test ResultsComparing d5ba4bb 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) |
…ore-file-writes # Conflicts: # apps/cli/ai/system-prompt.ts
…or changes to WordPress itself
…l, no prompt line for external agents
This was referenced Oct 21, 2026
Closed
Closed
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
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.
Proposed Changes
The prompt said "Do NOT modify WordPress core files. Only work within wp-content/". This replaces that rule with a check in the Write and Edit tools.
wp-includes/,wp-admin/, and the root core PHP files such aswp-settings.php. A WordPress update replaces these, so a change there is lost. The refusal says why and names where the change belongs:wp-content/(a theme, child theme or plugin).wp-includesandwp-content) and refuses only if Studio manages that folder (findSiteByFolder). WordPress trees that Studio doesn't manage stay writable, so core development elsewhere on the machine is unaffected.wp-config.phpstays writable. It is the site's own file, and setting a constant there is legitimate.The check doesn't cover shell commands (for example
sed -ion a core file through Bash).Testing Instructions
npx vitest run apps/cli/ai/tests/file-write-refusal.test.ts. It covers:wp-content/named in the refusal;wp-config.php,wp-content/files, and core paths in a WordPress tree Studio doesn't manage;npx vitest run apps/cli/ai: 258 tests pass.core-filecase ("The admin bar on this site is too short. Make it 40px tall. Its styles are in wp-includes/css/admin-bar.css."), judged on whether core stays intact (wp core verify-checksums) and the change lands inwp-content/:wp-content/Without either, the agent edits core whenever it is pointed there, and the change is lost at the next WordPress update. The refusal names where the change belongs, which is what got every run to finish in
wp-content/.npx vitest run apps/cli/ai, 272 pass.Pre-merge Checklist