"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendBrowserToolArgs = void 0;
const claude_tool_args_1 = require("../claude-tool-args");
const claude_subcommand_detector_1 = require("../claude-subcommand-detector");
const APPEND_SYSTEM_PROMPT_FLAG = '--append-system-prompt';
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.';
function ensureBrowserSteeringPrompt(args) {
    const { optionArgs, trailingArgs } = (0, claude_tool_args_1.splitArgsAtTerminator)(args);
    if ((0, claude_tool_args_1.hasExactFlagValue)(optionArgs, APPEND_SYSTEM_PROMPT_FLAG, BROWSER_STEERING_PROMPT)) {
        return args;
    }
    return [...optionArgs, APPEND_SYSTEM_PROMPT_FLAG, BROWSER_STEERING_PROMPT, ...trailingArgs];
}
function appendBrowserToolArgs(args) {
    // Subcommands reject `--append-system-prompt`. Issue #1218.
    if ((0, claude_subcommand_detector_1.isClaudeSubcommandInvocation)(args))
        return args;
    return ensureBrowserSteeringPrompt(args);
}
exports.appendBrowserToolArgs = appendBrowserToolArgs;
//# sourceMappingURL=claude-tool-args.js.map