Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: render agents nicely in vscode (#37548)

Pavel Feldmand981aa957dd6
diff --git a/docs/src/test-agents-js.md b/docs/src/test-agents-js.md
index 3b7c7d4670..2130fa3ed6 100644
--- a/docs/src/test-agents-js.md
+++ b/docs/src/test-agents-js.md
@@ -27,7 +27,7 @@ You need to run this command for each agentic loop you will be using:
```bash
# Generate agent files for each agentic loop
# Visual Studio Code
-npx playwright init-agents --loop=vscode
+npx playwright init-agents --loop=code
# Claude Code
npx playwright init-agents --loop=claude
# opencode
diff --git a/packages/playwright/src/agents/generateAgents.ts b/packages/playwright/src/agents/generateAgents.ts
index eac59189a6..63ab8663f0 100644
--- a/packages/playwright/src/agents/generateAgents.ts
+++ b/packages/playwright/src/agents/generateAgents.ts
@@ -122,7 +122,7 @@ function saveAsClaudeCode(agent: Agent): string {
const lines: string[] = [];
lines.push(`---`);
- lines.push(`name: ${agent.header.name}`);
+ lines.push(`name: playwright-test-${agent.header.name}`);
lines.push(`description: ${agent.header.description}. Examples: ${agent.examples.map(example => `<example>${example}</example>`).join('')}`);
lines.push(`tools: ${agent.header.tools.map(tool => asClaudeTool(tool)).join(', ')}`);
lines.push(`model: ${agent.header.model}`);
@@ -161,10 +161,10 @@ function saveAsOpencodeJson(agents: Agent[]): string {
result['agent'] = {};
for (const agent of agents) {
const tools: Record<string, boolean> = {};
- result['agent'][agent.header.name] = {
+ result['agent']['playwright-test-' + agent.header.name] = {
description: agent.header.description,
mode: 'subagent',
- prompt: `{file:.opencode/prompts/${agent.header.name}.md}`,
+ prompt: `{file:.opencode/prompts/playwright-test-${agent.header.name}.md}`,
tools,
};
for (const tool of agent.header.tools)
@@ -197,7 +197,7 @@ export async function initClaudeCodeRepo() {
await fs.promises.mkdir('.claude/agents', { recursive: true });
for (const agent of agents)
- await writeFile(`.claude/agents/${agent.header.name}.md`, saveAsClaudeCode(agent));
+ await writeFile(`.claude/agents/playwright-test-${agent.header.name}.md`, saveAsClaudeCode(agent));
await writeFile('.mcp.json', JSON.stringify({
mcpServers: {
@@ -218,6 +218,7 @@ const vscodeToolMap = new Map<string, string[]>([
]);
const vscodeToolsOrder = ['createFile', 'createDirectory', 'editFiles', 'fileSearch', 'textSearch', 'listDirectory', 'readFile'];
const vscodeToolPrefix = 'test_'; // FIXME: this is ugly, fix VSCode!
+
function saveAsVSCodeChatmode(agent: Agent): string {
function asVscodeTool(tool: string): string | string[] {
const [first, second] = tool.split('/');
@@ -256,7 +257,7 @@ export async function initVSCodeRepo() {
await fs.promises.mkdir('.github/chatmodes', { recursive: true });
for (const agent of agents)
- await writeFile(`.github/chatmodes/${agent.header.name}.chatmode.md`, saveAsVSCodeChatmode(agent));
+ await writeFile(`.github/chatmodes/${agent.header.name === 'planner' ? ' ' : ''}🎭 ${agent.header.name}.chatmode.md`, saveAsVSCodeChatmode(agent));
await fs.promises.mkdir('.vscode', { recursive: true });
@@ -290,7 +291,7 @@ export async function initOpencodeRepo() {
const prompt = [agent.instructions];
prompt.push('');
prompt.push(...agent.examples.map(example => `<example>${example}</example>`));
- await writeFile(`.opencode/prompts/${agent.header.name}.md`, prompt.join('\n'));
+ await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join('\n'));
}
await writeFile('opencode.json', saveAsOpencodeJson(agents));
}
diff --git a/packages/playwright/src/agents/generator.md b/packages/playwright/src/agents/generator.md
index 3479c03a32..d448d42d51 100644
--- a/packages/playwright/src/agents/generator.md
+++ b/packages/playwright/src/agents/generator.md
@@ -1,5 +1,5 @@
---
-name: playwright-test-generator
+name: generator
description: Use this agent when you need to create automated browser tests using Playwright
model: sonnet
color: blue
@@ -104,9 +104,9 @@ Your process is methodical and thorough:
Context: User wants to test a login flow on their web application.
user: 'I need a test that logs into my app at localhost:3000 with username [email protected] and password 123456, then
verifies the dashboard page loads'
- assistant: 'I'll use the playwright-test-generator agent to create and validate this login test for you'
+ assistant: 'I'll use the generator agent to create and validate this login test for you'
<commentary>
- The user needs a specific browser automation test created, which is exactly what the playwright-test-generator agent
+ The user needs a specific browser automation test created, which is exactly what the generator agent
is designed for.
</commentary>
</example>
@@ -114,9 +114,9 @@ Your process is methodical and thorough:
Context: User has built a new checkout flow and wants to ensure it works correctly.
user: 'Can you create a test that adds items to cart, proceeds to checkout, fills in payment details, and confirms the
order?'
- assistant: 'I'll use the playwright-test-generator agent to build a comprehensive checkout flow test'
+ assistant: 'I'll use the generator agent to build a comprehensive checkout flow test'
<commentary>
- This is a complex user journey that needs to be automated and tested, perfect for the playwright-test-generator
+ This is a complex user journey that needs to be automated and tested, perfect for the generator
agent.
</commentary>
</example>
diff --git a/packages/playwright/src/agents/healer.md b/packages/playwright/src/agents/healer.md
index 3b25a39b7b..0f7e728958 100644
--- a/packages/playwright/src/agents/healer.md
+++ b/packages/playwright/src/agents/healer.md
@@ -1,5 +1,5 @@
---
-name: playwright-test-healer
+name: healer
description: Use this agent when you need to debug and fix failing Playwright tests
color: red
model: sonnet
@@ -58,17 +58,17 @@ Key principles:
<example>
Context: A developer has a failing Playwright test that needs to be debugged and fixed.
user: 'The login test is failing, can you fix it?'
- assistant: 'I'll use the playwright-test-healer agent to debug and fix the failing login test.'
+ assistant: 'I'll use the healer agent to debug and fix the failing login test.'
<commentary>
The user has identified a specific failing test that needs debugging and fixing, which is exactly what the
- playwright-test-healer agent is designed for.
+ healer agent is designed for.
</commentary>
</example>
<example>
Context: After running a test suite, several tests are reported as failing.
user: 'Test user-registration.spec.ts is broken after the recent changes'
- assistant: 'Let me use the playwright-test-healer agent to investigate and fix the user-registration test.'
+ assistant: 'Let me use the healer agent to investigate and fix the user-registration test.'
<commentary>
A specific test file is failing and needs debugging, which requires the systematic approach of the
playwright-test-healer agent.
diff --git a/packages/playwright/src/agents/planner.md b/packages/playwright/src/agents/planner.md
index 9c2a0ce8b3..46a269bd6e 100644
--- a/packages/playwright/src/agents/planner.md
+++ b/packages/playwright/src/agents/planner.md
@@ -1,5 +1,5 @@
---
-name: playwright-test-planner
+name: planner
description: Use this agent when you need to create comprehensive test plan for a web application or website
model: sonnet
color: green
@@ -117,19 +117,19 @@ professional formatting suitable for sharing with development and QA teams.
<example>
Context: User wants to test a new e-commerce checkout flow.
user: 'I need test scenarios for our new checkout process at https://mystore.com/checkout'
- assistant: 'I'll use the playwright-test-planner agent to navigate to your checkout page and create comprehensive test
+ assistant: 'I'll use the planner agent to navigate to your checkout page and create comprehensive test
scenarios.'
<commentary>
- The user needs test planning for a specific web page, so use the playwright-test-planner agent to explore and create
+ The user needs test planning for a specific web page, so use the planner agent to explore and create
test scenarios.
</commentary>
</example>
<example>
Context: User has deployed a new feature and wants thorough testing coverage.
user: 'Can you help me test our new user dashboard at https://app.example.com/dashboard?'
- assistant: 'I'll launch the playwright-test-planner agent to explore your dashboard and develop detailed test
+ assistant: 'I'll launch the planner agent to explore your dashboard and develop detailed test
scenarios.'
<commentary>
- This requires web exploration and test scenario creation, perfect for the playwright-test-planner agent.
+ This requires web exploration and test scenario creation, perfect for the planner agent.
</commentary>
</example>
diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts
index 3f7561a4a3..81f285fd4b 100644
--- a/packages/playwright/src/program.ts
+++ b/packages/playwright/src/program.ts
@@ -178,12 +178,12 @@ function addInitAgentsCommand(program: Command) {
const command = program.command('init-agents', { hidden: true });
command.description('Initialize repository agents for the Claude Code');
const option = command.createOption('--loop <loop>', 'Agentic loop provider');
- option.choices(['claude', 'opencode', 'vscode']);
+ option.choices(['code', 'claude', 'opencode']);
command.addOption(option);
command.action(async opts => {
if (opts.loop === 'opencode')
await initOpencodeRepo();
- else if (opts.loop === 'vscode')
+ else if (opts.loop === 'code')
await initVSCodeRepo();
else if (opts.loop === 'claude')
await initClaudeCodeRepo();