-
Notifications
You must be signed in to change notification settings - Fork 86
Differentiate preview sites from connected WordPress.com remote sites #3677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sejas
merged 14 commits into
trunk
from
stu-1775-differentiate-preview-sites-from-wordpresscom-remote-sites
Jun 25, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e6f7132
fix: differentiate preview sites from connected WordPress.com sites
sejas 5ec416d
Merge branch 'trunk' of github.com:Automattic/studio into stu-1775-di…
sejas 4ba22f0
Merge remote-tracking branch 'origin/trunk' into stu-1775-differentia…
sejas 05c2cf1
fix: correct preview-vs-remote eval grading, drop redundant prompt
sejas dd16f94
test: use realistic studio.wp.build preview URLs in eval and unit seeds
sejas fb81f08
Merge branch 'trunk' into stu-1775-differentiate-preview-sites-from-w…
sejas f802c99
feat: treat temporary/temporal site as synonym for preview site
sejas 0a730f6
Merge remote-tracking branch 'origin/HEAD' into stu-1775-differentiat…
sejas d8d5384
Merge remote-tracking branch 'origin/stu-1775-differentiate-preview-s…
sejas 591adc9
test: use relative future date for preview expiry test
sejas 1e8543a
Remove synonyms from system promopt in favor of tools description
sejas 77c2cb1
Merge remote-tracking branch 'origin/trunk' into stu-1775-differentia…
sejas 693c56e
Merge remote-tracking branch 'origin/trunk' into stu-1775-differentia…
sejas 18b3566
Undo the eval filter pattern in eval README
sejas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,48 @@ | ||
| import { snapshotSchema } from '@studio/common/types/snapshot'; | ||
| import { Type } from 'typebox'; | ||
| import { z } from 'zod'; | ||
| import { runCommand as runListPreviewCommand } from 'cli/commands/preview/list'; | ||
| import { isSnapshotExpired } from 'cli/lib/snapshots'; | ||
| import { defineTool } from './define-tool'; | ||
| import { runPreviewCommand } from './preview-helpers'; | ||
| import { resolveSite } from './utils'; | ||
| import { captureConsoleOutput, resolveSite, textResult } from './utils'; | ||
|
|
||
| // Enrich the raw snapshot JSON the CLI command emits with an explicit category | ||
| // discriminator and an expiry flag, so the agent never mistakes a temporary | ||
| // preview site for a durable connected WordPress.com remote site. | ||
| export function enrichPreviewListOutput( rawJson: string ): string { | ||
| const snapshots = z.array( snapshotSchema ).parse( JSON.parse( rawJson ) ); | ||
| const enriched = snapshots.map( ( snapshot ) => ( { | ||
| type: 'preview' as const, | ||
| name: snapshot.name, | ||
| url: `https://${ snapshot.url }`, | ||
| atomicSiteId: snapshot.atomicSiteId, | ||
| localSiteId: snapshot.localSiteId, | ||
| date: snapshot.date, | ||
| isExpired: isSnapshotExpired( snapshot ), | ||
| } ) ); | ||
| return JSON.stringify( enriched, null, 2 ); | ||
| } | ||
|
|
||
| export const listPreviewsTool = defineTool( | ||
| 'preview_list', | ||
| 'Lists WordPress.com preview sites associated with a local Studio site. Requires WordPress.com authentication.', | ||
| 'Lists preview sites for a local Studio site. A preview site is a TEMPORARY, expiring hosted preview created from a local site — it is NOT a connected WordPress.com remote site and must never be described as one. Each entry is tagged with "type": "preview". Requires WordPress.com authentication.', | ||
| { | ||
| nameOrPath: Type.String( { description: 'The local site name or file system path' } ), | ||
| }, | ||
| async ( args ) => { | ||
| return runPreviewCommand( | ||
| async () => { | ||
| const site = await resolveSite( args.nameOrPath ); | ||
| await runListPreviewCommand( site.path, 'json' ); | ||
| }, | ||
| `No preview sites found for "${ args.nameOrPath }".`, | ||
| 'Failed to list preview sites' | ||
| ); | ||
| try { | ||
| const site = await resolveSite( args.nameOrPath ); | ||
| const rawJson = ( | ||
| await captureConsoleOutput( () => runListPreviewCommand( site.path, 'json' ) ) | ||
| ).trim(); | ||
| const normalizedJson = rawJson && rawJson !== 'undefined' ? rawJson : '[]'; | ||
| return textResult( enrichPreviewListOutput( normalizedJson ) ); | ||
| } catch ( error ) { | ||
| throw new Error( | ||
| `Failed to list preview sites: ${ | ||
| error instanceof Error ? error.message : String( error ) | ||
| }` | ||
| ); | ||
| } | ||
| } | ||
| ); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good idea to remove the WordPress.com reference from there as this can be quite confusing for the agents. I am wondering if we should mention where the preview sites are hosted or it might not be necessary. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, on a second thought, it might not be necessary for an agent to have that information since it does not really impact user's workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, the synonym disambiguation ("temporary site", "temporal site", "share link") is repeated in both the tool description and the system prompt. Would it make sense to keep the tool description short and defer to the system prompt for synonym mapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferred to remove the duplication from the system prompt in favor of the tool description.
1e8543a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed it is still working:
