Skip to content

Commit 3033a1d

Browse files
committed
use short tool name
1 parent 3a863ab commit 3033a1d

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

packages/playwright/src/agents/generateAgents.ts

Lines changed: 5 additions & 10 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(renderInstructions(agent, { toolName: asClaudeTool }));
132+
lines.push(renderInstructions(agent));
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(renderInstructions(agent, { toolName: v => asVscodeTool(v) as string }));
247+
lines.push(renderInstructions(agent));
248248
for (const example of agent.examples)
249249
lines.push(`<example>${example}</example>`);
250250

@@ -290,22 +290,17 @@ export async function initOpencodeRepo() {
290290
await fs.promises.mkdir('.opencode/prompts', { recursive: true });
291291
for (const agent of agents) {
292292
const prompt = [];
293-
prompt.push(renderInstructions(agent, {
294-
toolName: tool => {
295-
const [first, second] = tool.split('/');
296-
return `${first}*${second}`;
297-
}
298-
}));
293+
prompt.push(renderInstructions(agent));
299294
prompt.push('');
300295
prompt.push(...agent.examples.map(example => `<example>${example}</example>`));
301296
await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join('\n'));
302297
}
303298
await writeFile('opencode.json', saveAsOpencodeJson(agents));
304299
}
305300

306-
function renderInstructions(agent: Agent, { toolName }: { toolName: (v: string) => string }): string {
301+
function renderInstructions(agent: Agent): string {
307302
let instructions = agent.instructions;
308303
for (const tool of agent.header.tools)
309-
instructions = instructions.replace(`%${tool}%`, toolName(tool));
304+
instructions = instructions.replace(`%${tool}%`, tool.split('/')[1]);
310305
return instructions;
311306
}

tests/mcp/init-agents.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test('init claude agents', async ({ }) => {
8888
expect(fs.existsSync(path.join(baseDir, '.claude', 'agents', 'playwright-test-generator.md'))).toBe(true);
8989

9090
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');
91+
expect(healer).toContain('Run all tests using test_run tool');
9292
});
9393

9494
test('init vscode agents', async ({ }) => {
@@ -106,8 +106,8 @@ test('init vscode agents', async ({ }) => {
106106
expect(fs.existsSync(path.join(baseDir, '.github', 'chatmodes', ' 🎭 planner.chatmode.md'))).toBe(true);
107107

108108
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');
109+
expect(healer).toContain('Run all tests using test_run tool');
110+
expect(healer).toContain('For each failing test run test_debug');
111111

112112
expect(fs.existsSync(path.join(baseDir, '.vscode', 'mcp.json'))).toBe(true);
113113
});
@@ -127,7 +127,7 @@ test('init opencode agents', async ({ }) => {
127127
expect(fs.existsSync(path.join(baseDir, '.opencode', 'prompts', 'playwright-test-generator.md'))).toBe(true);
128128

129129
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');
130+
expect(healer).toContain('Run all tests using test_run tool');
131131

132132
expect(fs.existsSync(path.join(baseDir, 'opencode.json'))).toBe(true);
133133
});

0 commit comments

Comments
 (0)