From 7c3809b1d4d2f561e488ae578b982519b56c26dd Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Sun, 16 Nov 2025 14:59:28 +0100 Subject: [PATCH] better prompt --- playwriter/scripts/extension-server.ts | 4 ++-- playwriter/src/mcp.ts | 6 +++--- playwriter/src/prompt.md | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/playwriter/scripts/extension-server.ts b/playwriter/scripts/extension-server.ts index 72f5cd7..74caaae 100644 --- a/playwriter/scripts/extension-server.ts +++ b/playwriter/scripts/extension-server.ts @@ -1,7 +1,7 @@ -import { startRelayServer } from '../src/extension/cdp-relay.js' +import { startPlayWriterCDPRelayServer } from '../src/extension/cdp-relay.js' async function main() { - const server = await startRelayServer({ port: 19988 }) + const server = await startPlayWriterCDPRelayServer({ port: 19988 }) console.log('Server running. Press Ctrl+C to stop.') diff --git a/playwriter/src/mcp.ts b/playwriter/src/mcp.ts index 595ce58..c9df4c1 100644 --- a/playwriter/src/mcp.ts +++ b/playwriter/src/mcp.ts @@ -169,7 +169,7 @@ server.tool( code: z .string() .describe( - 'JavaScript code to execute with page, state, context in scope. Should be one line, using ; to execute multiple statements. To execute complex actions call execute multiple times. ', + 'js playwright code, has {page, state, context} in scope. Should be one line, using ; to execute multiple statements. you MUST call execute multiple times instead of writing complex scripts in a single tool call.', ), timeout: z.number().default(3000).describe('Timeout in milliseconds for code execution (default: 3000ms)'), }, @@ -221,9 +221,9 @@ server.tool( accessibilitySnapshot, resetPlaywright: async () => { const { page: newPage, context: newContext } = await resetConnection() - + Object.keys(state).forEach(key => delete state[key]) - + const resetObj: VMContext = { page: newPage, context: newContext, diff --git a/playwriter/src/prompt.md b/playwriter/src/prompt.md index 7e6f34b..418703c 100644 --- a/playwriter/src/prompt.md +++ b/playwriter/src/prompt.md @@ -4,6 +4,10 @@ if you get an error Extension not running tell user to install and enable the pl execute tool let you run playwright js code snippets to control user Chrome window, these js code snippets are preferred to be in a single line to make them more readable in agent interface. separating statements with semicolons +you MUST use multiple execute tool calls for running complex logic. this ensures +- you have clear understanding of intermediate state between interactions +- you can split finding an element from interacting with it. making it simpler to understand what is the issue when an action is not successful + it will control an existing user Chrome window. The js code will be run in a sandbox with some variables in context: - state: an object shared between runs that you can mutate to persist functions and objects. for example `state.requests = []` to monitor network requests between runs