Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: refactor init-agents (#37877)
Pavel Feldmandeca3acca8e2
diff --git a/examples/todomvc/.claude/agents/playwright-test-generator.md b/examples/todomvc/.claude/agents/playwright-test-generator.mdindex b82e9bc3a1..276b2d737f 100644--- a/examples/todomvc/.claude/agents/playwright-test-generator.md+++ b/examples/todomvc/.claude/agents/playwright-test-generator.md@@ -1,7 +1,7 @@---name: playwright-test-generatordescription: Use this agent when you need to create automated browser tests using Playwright. Examples: <example>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 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 generator agent is designed for. </commentary></example><example>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 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 generator agent. </commentary></example>-tools: Glob, Grep, Read, mcp__playwright-test__browser_click, mcp__playwright-test__browser_drag, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_file_upload, mcp__playwright-test__browser_handle_dialog, mcp__playwright-test__browser_hover, mcp__playwright-test__browser_navigate, mcp__playwright-test__browser_press_key, mcp__playwright-test__browser_select_option, mcp__playwright-test__browser_snapshot, mcp__playwright-test__browser_type, mcp__playwright-test__browser_verify_element_visible, mcp__playwright-test__browser_verify_list_visible, mcp__playwright-test__browser_verify_text_visible, mcp__playwright-test__browser_verify_value, mcp__playwright-test__browser_wait_for, mcp__playwright-test__generator_read_log, mcp__playwright-test__generator_setup_page, mcp__playwright-test__generator_write_test+tools: Read, Glob, Grep, mcp__playwright-test__browser_click, mcp__playwright-test__browser_drag, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_file_upload, mcp__playwright-test__browser_handle_dialog, mcp__playwright-test__browser_hover, mcp__playwright-test__browser_navigate, mcp__playwright-test__browser_press_key, mcp__playwright-test__browser_select_option, mcp__playwright-test__browser_snapshot, mcp__playwright-test__browser_type, mcp__playwright-test__browser_verify_element_visible, mcp__playwright-test__browser_verify_list_visible, mcp__playwright-test__browser_verify_text_visible, mcp__playwright-test__browser_verify_value, mcp__playwright-test__browser_wait_for, mcp__playwright-test__generator_read_log, mcp__playwright-test__generator_setup_page, mcp__playwright-test__generator_write_testmodel: sonnetcolor: blue---diff --git a/examples/todomvc/.claude/agents/playwright-test-healer.md b/examples/todomvc/.claude/agents/playwright-test-healer.mdindex 0a31a92a52..18cd979974 100644--- a/examples/todomvc/.claude/agents/playwright-test-healer.md+++ b/examples/todomvc/.claude/agents/playwright-test-healer.md@@ -1,7 +1,7 @@---name: playwright-test-healerdescription: Use this agent when you need to debug and fix failing Playwright tests. Examples: <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 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 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 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. </commentary></example>-tools: Glob, Grep, Read, Write, Edit, MultiEdit, mcp__playwright-test__browser_console_messages, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_generate_locator, mcp__playwright-test__browser_network_requests, mcp__playwright-test__browser_snapshot, mcp__playwright-test__test_debug, mcp__playwright-test__test_list, mcp__playwright-test__test_run+tools: Read, Glob, Grep, Write, Edit, MultiEdit, mcp__playwright-test__browser_console_messages, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_generate_locator, mcp__playwright-test__browser_network_requests, mcp__playwright-test__browser_snapshot, mcp__playwright-test__test_debug, mcp__playwright-test__test_list, mcp__playwright-test__test_runmodel: sonnetcolor: red---diff --git a/examples/todomvc/.claude/agents/playwright-test-planner.md b/examples/todomvc/.claude/agents/playwright-test-planner.mdindex 283a88d7fe..afca58af3a 100644--- a/examples/todomvc/.claude/agents/playwright-test-planner.md+++ b/examples/todomvc/.claude/agents/playwright-test-planner.md@@ -1,7 +1,7 @@---name: playwright-test-plannerdescription: Use this agent when you need to create comprehensive test plan for a web application or website. Examples: <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 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 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 planner agent to explore your dashboard and develop detailed test scenarios.' <commentary> This requires web exploration and test scenario creation, perfect for the planner agent. </commentary></example>-tools: Glob, Grep, Read, Write, mcp__playwright-test__browser_click, mcp__playwright-test__browser_close, mcp__playwright-test__browser_console_messages, mcp__playwright-test__browser_drag, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_file_upload, mcp__playwright-test__browser_handle_dialog, mcp__playwright-test__browser_hover, mcp__playwright-test__browser_navigate, mcp__playwright-test__browser_navigate_back, mcp__playwright-test__browser_network_requests, mcp__playwright-test__browser_press_key, mcp__playwright-test__browser_select_option, mcp__playwright-test__browser_snapshot, mcp__playwright-test__browser_take_screenshot, mcp__playwright-test__browser_type, mcp__playwright-test__browser_wait_for, mcp__playwright-test__planner_setup_page+tools: Read, Glob, Grep, Write, mcp__playwright-test__browser_click, mcp__playwright-test__browser_close, mcp__playwright-test__browser_console_messages, mcp__playwright-test__browser_drag, mcp__playwright-test__browser_evaluate, mcp__playwright-test__browser_file_upload, mcp__playwright-test__browser_handle_dialog, mcp__playwright-test__browser_hover, mcp__playwright-test__browser_navigate, mcp__playwright-test__browser_navigate_back, mcp__playwright-test__browser_network_requests, mcp__playwright-test__browser_press_key, mcp__playwright-test__browser_select_option, mcp__playwright-test__browser_snapshot, mcp__playwright-test__browser_take_screenshot, mcp__playwright-test__browser_type, mcp__playwright-test__browser_wait_for, mcp__playwright-test__planner_setup_pagemodel: sonnetcolor: green---diff --git a/examples/todomvc/prompt.claudecode.md b/examples/todomvc/prompt.claudecode.mddeleted file mode 100644index 21ee6db859..0000000000--- a/examples/todomvc/prompt.claudecode.md+++ /dev/null@@ -1,14 +0,0 @@-## Objective-Test basic functionality of todo app.--## Test setup: tests/template.spec.ts:11--## Steps-- Use `playwright-test-planner` subagent to create a test plan for "Basic operations".- Use seed test from `tests/seed.spec.ts` to init page. Save the test plan as `specs/basic-operations.md`.--- For each scenario in `specs/basic-operations.md`, use `playwright-test-generator`- subagent to perform the scenario and generate the test source code into `tests/` folder.- Process all scenarios sequentially, do not run in parallel.--- Use `playwright-test-healer` subagent to fix the failing tests.diff --git a/packages/playwright/src/agents/generateAgents.ts b/packages/playwright/src/agents/generateAgents.tsindex b349ad9234..6754573756 100644--- a/packages/playwright/src/agents/generateAgents.ts+++ b/packages/playwright/src/agents/generateAgents.ts@@ -31,8 +31,8 @@ interface AgentHeader {tools: string[];}-interface Agent {+ source: string;header: AgentHeader;instructions: string;examples: string[];@@ -41,11 +41,16 @@ interface Agent {/* eslint-disable no-console */class AgentParser {+ static async loadAgents(): Promise<Agent[]> {+ const files = await fs.promises.readdir(__dirname);+ return Promise.all(files.filter(file => file.endsWith('.md')).map(file => AgentParser.parseFile(path.join(__dirname, file))));+ }+static async parseFile(filePath: string): Promise<Agent> {- const rawMarkdown = await fs.promises.readFile(filePath, 'utf-8');- const { header, content } = this.extractYamlAndContent(rawMarkdown);+ const source = await fs.promises.readFile(filePath, 'utf-8');+ const { header, content } = this.extractYamlAndContent(source);const { instructions, examples } = this.extractInstructionsAndExamples(content);- return { header, instructions, examples };+ return { source, header, instructions, examples };}static extractYamlAndContent(markdown: string): { header: AgentHeader; content: string } {@@ -102,95 +107,241 @@ class AgentParser {}}-const claudeToolMap = new Map<string, string[]>([- ['ls', ['Glob']],- ['grep', ['Grep']],- ['read', ['Read']],- ['edit', ['Edit', 'MultiEdit']],- ['write', ['Write']],-]);--// Common MCP server configurations-const commonMcpServers = {- playwrightTest: {- type: 'local',- command: 'npx',- args: ['playwright', 'run-test-mcp-server']- }-};--function saveAsClaudeCode(agent: Agent): string {- function asClaudeTool(tool: string): string {- const [first, second] = tool.split('/');- if (!second)- return (claudeToolMap.get(first) || [first]).join(', ');- return `mcp__${first}__${second}`;+export class ClaudeGenerator {+ static async init(config: FullConfigInternal, projectName: string) {+ await initRepo(config, projectName);++ const agents = await AgentParser.loadAgents();++ await fs.promises.mkdir('.claude/agents', { recursive: true });+ for (const agent of agents)+ await writeFile(`.claude/agents/${agent.header.name}.md`, ClaudeGenerator.agentSpec(agent), 'π€', 'agent definition');++ await writeFile('.mcp.json', JSON.stringify({+ mcpServers: {+ 'playwright-test': {+ command: 'npx',+ args: ['playwright', 'run-test-mcp-server'],+ }+ }+ }, null, 2), 'π§', 'mcp configuration');++ initRepoDone();}- const lines: string[] = [];- lines.push(`---`);- 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}`);- lines.push(`color: ${agent.header.color}`);- lines.push(`---`);- lines.push('');- lines.push(agent.instructions);- return lines.join('\n');+ static agentSpec(agent: Agent): string {+ const claudeToolMap = new Map<string, string[]>([+ ['search', ['Glob', 'Grep']],+ ['read', ['Read']],+ ['edit', ['Edit', 'MultiEdit']],+ ['write', ['Write']],+ ]);++ function asClaudeTool(tool: string): string {+ const [first, second] = tool.split('/');+ if (!second)+ return (claudeToolMap.get(first) || [first]).join(', ');+ return `mcp__${first}__${second}`;+ }++ const lines: string[] = [];+ lines.push(`---`);+ lines.push(`name: ${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}`);+ lines.push(`color: ${agent.header.color}`);+ lines.push(`---`);+ lines.push('');+ lines.push(agent.instructions);+ return lines.join('\n');+ }}-const opencodeToolMap = new Map<string, string[]>([- ['ls', ['ls', 'glob']],- ['grep', ['grep']],- ['read', ['read']],- ['edit', ['edit']],- ['write', ['write']],-]);--function saveAsOpencodeJson(agents: Agent[]): string {- function asOpencodeTool(tools: Record<string, boolean>, tool: string): void {- const [first, second] = tool.split('/');- if (!second) {- for (const tool of opencodeToolMap.get(first) || [first])- tools[tool] = true;- } else {- tools[`${first}*${second}`] = true;+export class OpencodeGenerator {+ static async init(config: FullConfigInternal, projectName: string) {+ await initRepo(config, projectName);++ const agents = await AgentParser.loadAgents();++ await fs.promises.mkdir('.opencode/prompts', { recursive: true });+ for (const agent of agents) {+ 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'), 'π€', 'agent definition');}+ await writeFile('opencode.json', OpencodeGenerator.configuration(agents), 'π§', 'opencode configuration');++ initRepoDone();}- const result: Record<string, any> = {};- result['$schema'] = 'https://opencode.ai/config.json';- result['mcp'] = {};- result['tools'] = {- 'playwright*': false,- };- result['agent'] = {};- for (const agent of agents) {- const tools: Record<string, boolean> = {};- result['agent']['playwright-test-' + agent.header.name] = {- description: agent.header.description,- mode: 'subagent',- prompt: `{file:.opencode/prompts/playwright-test-${agent.header.name}.md}`,- tools,+ static configuration(agents: Agent[]): string {+ const opencodeToolMap = new Map<string, string[]>([+ ['search', ['ls', 'glob', 'grep']],+ ['read', ['read']],+ ['edit', ['edit']],+ ['write', ['write']],+ ]);++ const asOpencodeTool = (tools: Record<string, boolean>, tool: string) => {+ const [first, second] = tool.split('/');+ if (!second) {+ for (const tool of opencodeToolMap.get(first) || [first])+ tools[tool] = true;+ } else {+ tools[`${first}*${second}`] = true;+ }+ };++ const result: Record<string, any> = {};+ result['$schema'] = 'https://opencode.ai/config.json';+ result['mcp'] = {};+ result['tools'] = {+ 'playwright*': false,};- for (const tool of agent.header.tools)- asOpencodeTool(tools, tool);+ result['agent'] = {};+ for (const agent of agents) {+ const tools: Record<string, boolean> = {};+ result['agent'][agent.header.name] = {+ description: agent.header.description,+ mode: 'subagent',+ prompt: `{file:.opencode/prompts/${agent.header.name}.md}`,+ tools,+ };+ for (const tool of agent.header.tools)+ asOpencodeTool(tools, tool);+ }++ result['mcp']['playwright-test'] = {+ type: 'local',+ command: ['npx', 'playwright', 'run-test-mcp-server'],+ enabled: true,+ };++ return JSON.stringify(result, null, 2);}+}+export class AgentGenerator {+ static async init(config: FullConfigInternal, projectName: string) {+ const agentsFolder = process.env.AGENTS_FOLDER;+ if (!agentsFolder) {+ console.error('AGENTS_FOLDER environment variable is not set');+ return;+ }- const server = commonMcpServers.playwrightTest;- result['mcp']['playwright-test'] = {- type: server.type,- command: [server.command, ...server.args],- enabled: true,- };+ await initRepo(config, projectName);++ const agents = await AgentParser.loadAgents();++ await fs.promises.mkdir(agentsFolder, { recursive: true });+ for (const agent of agents)+ await writeFile(`${agentsFolder}/${agent.header.name}.md`, agent.source, 'π€', 'agent definition');++ console.log('π§ MCP configuration');+ console.log(JSON.stringify({+ mcpServers: {+ 'playwright-test': {+ type: 'stdio',+ command: 'npx',+ args: [+ `--prefix=${path.resolve(process.cwd())}`,+ 'playwright',+ 'run-test-mcp-server',+ `--headless`,+ `--config=${path.resolve(process.cwd())}`,+ ],+ tools: ['*']+ }+ }+ }, null, 2));- return JSON.stringify(result, null, 2);+ initRepoDone();+ }}-async function loadAgents(): Promise<Agent[]> {- const files = await fs.promises.readdir(__dirname);- return Promise.all(files.filter(file => file.endsWith('.md')).map(file => AgentParser.parseFile(path.join(__dirname, file))));+export class VSCodeGenerator {+ static async init(config: FullConfigInternal, projectName: string) {+ await initRepo(config, projectName);+ const agents = await AgentParser.loadAgents();++ const nameMap = new Map<string, string>([+ ['playwright-test-planner', ' π planner'],+ ['playwright-test-generator', 'π generator'],+ ['playwright-test-healer', 'π healer'],+ ]);++ await fs.promises.mkdir('.github/chatmodes', { recursive: true });+ for (const agent of agents)+ await writeFile(`.github/chatmodes/${nameMap.get(agent.header.name)}.chatmode.md`, VSCodeGenerator.agentSpec(agent), 'π€', 'chatmode definition');++ await fs.promises.mkdir('.vscode', { recursive: true });++ const mcpJsonPath = '.vscode/mcp.json';+ let mcpJson: any = {+ servers: {},+ inputs: []+ };+ try {+ mcpJson = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf8'));+ } catch {+ }++ if (!mcpJson.servers)+ mcpJson.servers = {};++ mcpJson.servers['playwright-test'] = {+ type: 'stdio',+ command: 'npx',+ args: ['playwright', 'run-test-mcp-server'],+ cwd: '${workspaceFolder}',+ };+ await writeFile(mcpJsonPath, JSON.stringify(mcpJson, null, 2), 'π§', 'mcp configuration');++ initRepoDone();+ }++ static agentSpec(agent: Agent): string {+ const vscodeToolMap = new Map<string, string[]>([+ ['search', ['search/listDirectory', 'search/fileSearch', 'search/textSearch']],+ ['read', ['search/readFile']],+ ['edit', ['edit/editFiles']],+ ['write', ['edit/createFile', 'edit/createDirectory']],+ ]);+ const vscodeToolsOrder = ['edit/createFile', 'edit/createDirectory', 'edit/editFiles', 'search/fileSearch', 'search/textSearch', 'search/listDirectory', 'search/readFile'];+ const vscodeMcpName = 'playwright-test';++ function asVscodeTool(tool: string): string | string[] {+ const [first, second] = tool.split('/');+ if (second)+ return `${vscodeMcpName}/${second}`;+ return vscodeToolMap.get(first) || first;+ }+ const tools = agent.header.tools.map(asVscodeTool).flat().sort((a, b) => {+ // VSCode insists on the specific tools order when editing agent config.+ const indexA = vscodeToolsOrder.indexOf(a);+ const indexB = vscodeToolsOrder.indexOf(b);+ if (indexA === -1 && indexB === -1)+ return a.localeCompare(b);+ if (indexA === -1)+ return 1;+ if (indexB === -1)+ return -1;+ return indexA - indexB;+ }).map(tool => `'${tool}'`).join(', ');++ const lines: string[] = [];+ lines.push(`---`);+ lines.push(`description: ${agent.header.description}.`);+ lines.push(`tools: [${tools}]`);+ lines.push(`---`);+ lines.push('');+ lines.push(agent.instructions);+ for (const example of agent.examples)+ lines.push(`<example>${example}</example>`);++ return lines.join('\n');+ }}async function writeFile(filePath: string, content: string, icon: string, description: string) {@@ -234,120 +385,6 @@ function initRepoDone() {console.log('β Done.');}-export async function initClaudeCodeRepo(config: FullConfigInternal, projectName: string) {- await initRepo(config, projectName);-- const agents = await loadAgents();-- await fs.promises.mkdir('.claude/agents', { recursive: true });- for (const agent of agents)- await writeFile(`.claude/agents/playwright-test-${agent.header.name}.md`, saveAsClaudeCode(agent), 'π€', 'agent definition');-- await writeFile('.mcp.json', JSON.stringify({- mcpServers: {- 'playwright-test': {- command: commonMcpServers.playwrightTest.command,- args: commonMcpServers.playwrightTest.args,- }- }- }, null, 2), 'π§', 'mcp configuration');-- initRepoDone();-}--const vscodeToolMap = new Map<string, string[]>([- ['ls', ['search/listDirectory', 'search/fileSearch']],- ['grep', ['search/textSearch']],- ['read', ['search/readFile']],- ['edit', ['edit/editFiles']],- ['write', ['edit/createFile', 'edit/createDirectory']],-]);-const vscodeToolsOrder = ['edit/createFile', 'edit/createDirectory', 'edit/editFiles', 'search/fileSearch', 'search/textSearch', 'search/listDirectory', 'search/readFile'];-const vscodeMcpName = 'playwright-test';-function saveAsVSCodeChatmode(agent: Agent): string {- function asVscodeTool(tool: string): string | string[] {- const [first, second] = tool.split('/');- if (second)- return `${vscodeMcpName}/${second}`;- return vscodeToolMap.get(first) || first;- }- const tools = agent.header.tools.map(asVscodeTool).flat().sort((a, b) => {- // VSCode insists on the specific tools order when editing agent config.- const indexA = vscodeToolsOrder.indexOf(a);- const indexB = vscodeToolsOrder.indexOf(b);- if (indexA === -1 && indexB === -1)- return a.localeCompare(b);- if (indexA === -1)- return 1;- if (indexB === -1)- return -1;- return indexA - indexB;- }).map(tool => `'${tool}'`).join(', ');-- const lines: string[] = [];- lines.push(`---`);- lines.push(`description: ${agent.header.description}.`);- lines.push(`tools: [${tools}]`);- lines.push(`---`);- lines.push('');- lines.push(agent.instructions);- for (const example of agent.examples)- lines.push(`<example>${example}</example>`);-- return lines.join('\n');-}--export async function initVSCodeRepo(config: FullConfigInternal, projectName: string) {- await initRepo(config, projectName);- const agents = await loadAgents();-- await fs.promises.mkdir('.github/chatmodes', { recursive: true });- for (const agent of agents)- await writeFile(`.github/chatmodes/${agent.header.name === 'planner' ? ' ' : ''}π ${agent.header.name}.chatmode.md`, saveAsVSCodeChatmode(agent), 'π€', 'chatmode definition');-- await fs.promises.mkdir('.vscode', { recursive: true });-- const mcpJsonPath = '.vscode/mcp.json';- let mcpJson: any = {- servers: {},- inputs: []- };- try {- mcpJson = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf8'));- } catch {- }-- if (!mcpJson.servers)- mcpJson.servers = {};-- mcpJson.servers['playwright-test'] = {- type: 'stdio',- command: commonMcpServers.playwrightTest.command,- args: commonMcpServers.playwrightTest.args,- cwd: '${workspaceFolder}',- };- await writeFile(mcpJsonPath, JSON.stringify(mcpJson, null, 2), 'π§', 'mcp configuration');-- initRepoDone();-}--export async function initOpencodeRepo(config: FullConfigInternal, projectName: string) {- await initRepo(config, projectName);-- const agents = await loadAgents();-- await fs.promises.mkdir('.opencode/prompts', { recursive: true });- for (const agent of agents) {- const prompt = [agent.instructions];- prompt.push('');- prompt.push(...agent.examples.map(example => `<example>${example}</example>`));- await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join('\n'), 'π€', 'agent definition');- }- await writeFile('opencode.json', saveAsOpencodeJson(agents), 'π§', 'opencode configuration');-- initRepoDone();-}-const coveragePrompt = (seedFile: string) => `# Produce test coverage@@ -356,7 +393,7 @@ Parameters:- Seed file (optional): the seed file to use, defaults to ${path.relative(process.cwd(), seedFile)}- Test plan file (optional): the test plan file to write, under specs/ folder.-1. Call #planner subagent with prompt:+1. Call #playwright-test-planner subagent with prompt:<plan><task><!-- the task --></task>@@ -364,7 +401,7 @@ Parameters:<plan-file><!-- test plan file --></plan-file></plan>-2. For each test case from the test plan file (1.1, 1.2, ...), Call #generator subagent with prompt:+2. For each test case from the test plan file (1.1, 1.2, ...), Call #playwright-test-generator subagent with prompt:<generate><test-file><!-- Name of the file to save the test into, should be unique for test --></test-file>@@ -374,7 +411,7 @@ Parameters:<body><!-- Test case content including steps and expectations --></body></generate>-3. Call #healer subagent with prompt:+3. Call #playwright-test-healer subagent with prompt:<heal>Run all tests and fix the failing ones one after another.</heal>`;diff --git a/packages/playwright/src/agents/generator.md b/packages/playwright/src/agents/generator.mdindex 3e83d145e7..4a313bf56d 100644--- a/packages/playwright/src/agents/generator.md+++ b/packages/playwright/src/agents/generator.md@@ -1,12 +1,11 @@----name: generator+name: playwright-test-generatordescription: Use this agent when you need to create automated browser tests using Playwrightmodel: sonnetcolor: bluetools:- - ls- - grep- read+ - search- playwright-test/browser_click- playwright-test/browser_drag- playwright-test/browser_evaluatediff --git a/packages/playwright/src/agents/healer.md b/packages/playwright/src/agents/healer.mdindex ee07a6cb17..92e08e86fd 100644--- a/packages/playwright/src/agents/healer.md+++ b/packages/playwright/src/agents/healer.md@@ -1,12 +1,11 @@----name: healer+name: playwright-test-healerdescription: Use this agent when you need to debug and fix failing Playwright tests-color: redmodel: sonnet+color: redtools:- - ls- - grep- read+ - search- write- edit- playwright-test/browser_console_messagesdiff --git a/packages/playwright/src/agents/planner.md b/packages/playwright/src/agents/planner.mdindex 192962b296..ae58a7bfeb 100644--- a/packages/playwright/src/agents/planner.md+++ b/packages/playwright/src/agents/planner.md@@ -1,12 +1,11 @@----name: planner+name: playwright-test-plannerdescription: Use this agent when you need to create comprehensive test plan for a web application or websitemodel: sonnetcolor: greentools:- - ls- - grep- read+ - search- write- playwright-test/browser_click- playwright-test/browser_closediff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.tsindex cd9c8e801b..707550c15a 100644--- a/packages/playwright/src/program.ts+++ b/packages/playwright/src/program.ts@@ -37,7 +37,7 @@ import { ServerBackendFactory, runMainBackend } from './mcp/sdk/exports';import { TestServerBackend } from './mcp/test/testBackend';import { decorateCommand } from './mcp/program';import { setupExitWatchdog } from './mcp/browser/watchdog';-import { initClaudeCodeRepo, initOpencodeRepo, initVSCodeRepo } from './agents/generateAgents';+import { ClaudeGenerator, OpencodeGenerator, VSCodeGenerator, AgentGenerator } from './agents/generateAgents';import type { ConfigCLIOverrides } from './common/ipc';import type { TraceMode } from '../types/test';@@ -183,18 +183,20 @@ function addInitAgentsCommand(program: Command) {const command = program.command('init-agents');command.description('Initialize repository agents');const option = command.createOption('--loop <loop>', 'Agentic loop provider');- option.choices(['vscode', 'claude', 'opencode']);+ option.choices(['vscode', 'claude', 'opencode', 'generic']);command.addOption(option);command.option('-c, --config <file>', `Configuration file to find a project to use for seed test`);command.option('--project <project>', 'Project to use for seed test');command.action(async opts => {const config = await loadConfigFromFile(opts.config);if (opts.loop === 'opencode') {- await initOpencodeRepo(config, opts.project);+ await OpencodeGenerator.init(config, opts.project);} else if (opts.loop === 'vscode') {- await initVSCodeRepo(config, opts.project);+ await VSCodeGenerator.init(config, opts.project);} else if (opts.loop === 'claude') {- await initClaudeCodeRepo(config, opts.project);+ await ClaudeGenerator.init(config, opts.project);+ } else if (opts.loop === 'generic') {+ await AgentGenerator.init(config, opts.project);} else {command.help();return;