Skip to content

Commit 3a863ab

Browse files
committed
chore(agents): render tool names
1 parent 3afe7ba commit 3a863ab

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

packages/playwright/src/agents/generateAgents.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function saveAsClaudeCode(agent: Agent): string {
129129
lines.push(`color: ${agent.header.color}`);
130130
lines.push(`---`);
131131
lines.push('');
132-
lines.push(agent.instructions);
132+
lines.push(renderInstructions(agent, { toolName: asClaudeTool }));
133133
return lines.join('\n');
134134
}
135135

@@ -244,7 +244,7 @@ function saveAsVSCodeChatmode(agent: Agent): string {
244244
lines.push(`tools: [${tools}]`);
245245
lines.push(`---`);
246246
lines.push('');
247-
lines.push(agent.instructions);
247+
lines.push(renderInstructions(agent, { toolName: v => asVscodeTool(v) as string }));
248248
for (const example of agent.examples)
249249
lines.push(`<example>${example}</example>`);
250250

@@ -289,10 +289,23 @@ export async function initOpencodeRepo() {
289289

290290
await fs.promises.mkdir('.opencode/prompts', { recursive: true });
291291
for (const agent of agents) {
292-
const prompt = [agent.instructions];
292+
const prompt = [];
293+
prompt.push(renderInstructions(agent, {
294+
toolName: tool => {
295+
const [first, second] = tool.split('/');
296+
return `${first}*${second}`;
297+
}
298+
}));
293299
prompt.push('');
294300
prompt.push(...agent.examples.map(example => `<example>${example}</example>`));
295301
await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join('\n'));
296302
}
297303
await writeFile('opencode.json', saveAsOpencodeJson(agents));
298304
}
305+
306+
function renderInstructions(agent: Agent, { toolName }: { toolName: (v: string) => string }): string {
307+
let instructions = agent.instructions;
308+
for (const tool of agent.header.tools)
309+
instructions = instructions.replace(`%${tool}%`, toolName(tool));
310+
return instructions;
311+
}

packages/playwright/src/agents/healer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ resolving Playwright test failures. Your mission is to systematically identify,
2424
broken Playwright tests using a methodical approach.
2525

2626
Your workflow:
27-
1. **Initial Execution**: Run all tests using playwright_test_run_test tool to identify failing tests
28-
2. **Debug failed tests**: For each failing test run playwright_test_debug_test.
27+
1. **Initial Execution**: Run all tests using %playwright-test/test_run% tool to identify failing tests
28+
2. **Debug failed tests**: For each failing test run %playwright-test/test_debug%.
2929
3. **Error Investigation**: When the test pauses on errors, use available Playwright MCP tools to:
3030
- Examine the error details
3131
- Capture page snapshot to understand the context

tests/mcp/init-agents.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ test('init claude agents', async ({ }) => {
8686
});
8787
expect(fs.existsSync(path.join(baseDir, '.claude', 'agents', 'playwright-test-planner.md'))).toBe(true);
8888
expect(fs.existsSync(path.join(baseDir, '.claude', 'agents', 'playwright-test-generator.md'))).toBe(true);
89-
expect(fs.existsSync(path.join(baseDir, '.claude', 'agents', 'playwright-test-healer.md'))).toBe(true);
89+
90+
const healer = fs.readFileSync(path.join(baseDir, '.claude', 'agents', 'playwright-test-healer.md'), 'utf-8');
91+
expect(healer).toContain('Run all tests using mcp__playwright-test__test_run tool');
9092
});
9193

9294
test('init vscode agents', async ({ }) => {
@@ -102,7 +104,11 @@ test('init vscode agents', async ({ }) => {
102104
});
103105
expect(fs.existsSync(path.join(baseDir, '.github', 'chatmodes', '🎭 generator.chatmode.md'))).toBe(true);
104106
expect(fs.existsSync(path.join(baseDir, '.github', 'chatmodes', ' 🎭 planner.chatmode.md'))).toBe(true);
105-
expect(fs.existsSync(path.join(baseDir, '.github', 'chatmodes', '🎭 healer.chatmode.md'))).toBe(true);
107+
108+
const healer = fs.readFileSync(path.join(baseDir, '.github', 'chatmodes', '🎭 healer.chatmode.md'), 'utf-8');
109+
expect(healer).toContain('Run all tests using playwright-test/test_run tool');
110+
expect(healer).toContain('For each failing test run playwright-test/test_debug');
111+
106112
expect(fs.existsSync(path.join(baseDir, '.vscode', 'mcp.json'))).toBe(true);
107113
});
108114

@@ -119,6 +125,9 @@ test('init opencode agents', async ({ }) => {
119125
});
120126
expect(fs.existsSync(path.join(baseDir, '.opencode', 'prompts', 'playwright-test-planner.md'))).toBe(true);
121127
expect(fs.existsSync(path.join(baseDir, '.opencode', 'prompts', 'playwright-test-generator.md'))).toBe(true);
122-
expect(fs.existsSync(path.join(baseDir, '.opencode', 'prompts', 'playwright-test-healer.md'))).toBe(true);
128+
129+
const healer = fs.readFileSync(path.join(baseDir, '.opencode', 'prompts', 'playwright-test-healer.md'), 'utf-8');
130+
expect(healer).toContain('Run all tests using playwright-test*test_run tool');
131+
123132
expect(fs.existsSync(path.join(baseDir, 'opencode.json'))).toBe(true);
124133
});

0 commit comments

Comments
 (0)