mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 10:16:49 +00:00
新增 browser MCP 安装、Chrome 复用与运行时接线, 实现 navigate、click、type、take_screenshot 四个 phase-1 工具并补齐相关单测。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import { appendBrowserToolArgs } from '../../../../src/utils/browser/claude-tool-args';
|
|
|
|
const BROWSER_STEERING_PROMPT =
|
|
'For DOM/screenshots/elements/page actions, prefer the CCS MCP Browser tool, reuse the configured running Chrome context whenever possible, and if the tool or context is unavailable, explain that clearly instead of pretending page state is available.';
|
|
|
|
describe('appendBrowserToolArgs', () => {
|
|
it('appends the browser steering prompt when it is missing', () => {
|
|
expect(appendBrowserToolArgs(['navigate'])).toEqual([
|
|
'navigate',
|
|
'--append-system-prompt',
|
|
BROWSER_STEERING_PROMPT,
|
|
]);
|
|
});
|
|
|
|
it('does not append the prompt when it already exists in equals form', () => {
|
|
expect(
|
|
appendBrowserToolArgs([
|
|
'navigate',
|
|
`--append-system-prompt=${BROWSER_STEERING_PROMPT}`,
|
|
])
|
|
).toEqual(['navigate', `--append-system-prompt=${BROWSER_STEERING_PROMPT}`]);
|
|
});
|
|
|
|
it('does not append the prompt when it already exists in split-flag form', () => {
|
|
expect(
|
|
appendBrowserToolArgs([
|
|
'navigate',
|
|
'--append-system-prompt',
|
|
BROWSER_STEERING_PROMPT,
|
|
])
|
|
).toEqual(['navigate', '--append-system-prompt', BROWSER_STEERING_PROMPT]);
|
|
});
|
|
|
|
it('inserts the prompt before the end-of-options terminator', () => {
|
|
expect(appendBrowserToolArgs(['--', 'take screenshot'])).toEqual([
|
|
'--append-system-prompt',
|
|
BROWSER_STEERING_PROMPT,
|
|
'--',
|
|
'take screenshot',
|
|
]);
|
|
});
|
|
});
|