From 91da59beffa4cbf903559acf8f7134f3823be946 Mon Sep 17 00:00:00 2001 From: alok-108 <166419621+alok-108@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:58:14 +0530 Subject: [PATCH] chore(scripts): auto-update config schema and env docs in README Fixes: https://github.com/microsoft/playwright-cli/issues/550 --- .claude/skills/dev/roll.md | 1 + README.md | 224 +++++++++++++++++++++++++++++++++---- scripts/update.js | 159 ++++++++++++++++++++++++-- 3 files changed, 353 insertions(+), 31 deletions(-) diff --git a/.claude/skills/dev/roll.md b/.claude/skills/dev/roll.md index 14762051..7ce657e5 100644 --- a/.claude/skills/dev/roll.md +++ b/.claude/skills/dev/roll.md @@ -18,6 +18,7 @@ - Runs `node playwright-cli.js install --skills` to regenerate skills from the new Playwright version. - Copies the generated skills from `.claude/skills/playwright-cli/` into `skills/playwright-cli/`. - Cleans up the generated `.claude/skills/` directory. + - Regenerates the configuration file schema and `PLAYWRIGHT_MCP_*` environment variables sections in `README.md`. 3. **Update README.md** with relevant changes from the updated skill at `skills/playwright-cli/SKILL.md`. Compare the skill file with the README and update any sections that are out of date (commands, flags, default behaviors, examples). diff --git a/README.md b/README.md index 8b3a3770..edec9df4 100644 --- a/README.md +++ b/README.md @@ -465,6 +465,8 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so
Configuration file schema + + ```typescript { /** @@ -484,6 +486,7 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so /** * Path to a user data directory for browser profile persistence. * Temporary directory is created by default. + * Relative paths are resolved against the config file's directory. */ userDataDir?: string; @@ -492,6 +495,7 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so * @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context * * This is useful for settings options like `channel`, `headless`, `executablePath`, etc. + * Relative paths are resolved against the config file's directory. */ launchOptions?: playwright.LaunchOptions; @@ -499,6 +503,7 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so * Context options for the browser context. * * This is useful for settings options like `viewport`. + * Relative paths are resolved against the config file's directory. */ contextOptions?: playwright.BrowserContextOptions; @@ -518,39 +523,128 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so cdpTimeout?: number; /** - * Remote endpoint to connect to an existing Playwright server. + * Remote endpoint to connect to an existing Playwright server. May be a + * WebSocket URL string, or a [ConnectOptions] object that mirrors the + * `connectOptions` shape used by the test runner. When passed as an object, + * `exposeNetwork`, `headers`, `slowMo`, and `timeout` are forwarded to the + * underlying connect call. */ - remoteEndpoint?: string; + remoteEndpoint?: string | playwright.ConnectOptions & { endpoint: string }; /** * Paths to TypeScript files to add as initialization scripts for Playwright page. + * Relative paths are resolved against the config file's directory. */ initPage?: string[]; /** * Paths to JavaScript files to add as initialization scripts. * The scripts will be evaluated in every page before any of the page's scripts. + * Relative paths are resolved against the config file's directory. */ initScript?: string[]; }, /** - * If specified, saves the Playwright video of the session into the output directory. + * Connect to a running browser instance (Edge/Chrome only). If specified, `browser` + * config is ignored. + * Requires the "Playwright Extension" to be installed. */ - saveVideo?: { - width: number; - height: number; - }; + extension?: boolean; + + /** + * Group controlled tabs when using the extension. Defaults to true. + */ + tabGroup?: boolean; + + /** + * Name of the session. With the extension, it is the title of the tab group for controlled tabs, + * which defaults to "Playwright ยท ". + */ + sessionName?: string; + + /** + * Color of the session: blue, red, yellow, green, pink, purple, cyan or orange. With the extension, + * it is the color of the tab group for controlled tabs, which defaults to the first color that no other client uses. + */ + sessionColor?: string; + + /** + * Do not activate controlled tabs or focus the browser window when using the extension. + * Defaults to false. + */ + background?: boolean; + + server?: { + /** + * The port to listen on for SSE or MCP transport. + */ + port?: number; + + /** + * The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces. + */ + host?: string; + + /** + * The hosts this server is allowed to serve from. Defaults to localhost, loopback IPs and the host passed via --host; other hosts must be listed explicitly. + * This is not for CORS, but rather for the DNS rebinding protection. + */ + allowedHosts?: string[]; + }, + + /** + * List of enabled tool capabilities. Possible values: + * - 'core': Core browser automation features. + * - 'pdf': PDF generation and manipulation. + * - 'vision': Coordinate-based interactions. + * - 'devtools': Developer tools features. + */ + capabilities?: ToolCapability[]; + + /** + * Whether to save the Playwright session into the output directory. + */ + saveSession?: boolean; + + /** + * Whether to collect and expose the tools that a page registers through the + * experimental WebMCP API. Enabled by default. + */ + webmcp?: boolean; + + /** + * Reuse the same browser context between all connected HTTP clients. + */ + sharedBrowserContext?: boolean; + + /** + * Secrets are used to replace matching plain text in the tool responses to prevent the LLM + * from accidentally getting sensitive data. It is a convenience and not a security feature, + * make sure to always examine information coming in and from the tool on the client. + */ + secrets?: Record; /** - * The directory to save output files. + * Names of URL query and fragment parameters, for example `access_token` or `code`, whose values + * are replaced with `` in the tool responses. Use it for session and grant values that + * are minted at runtime and cannot be listed in `secrets`. Like `secrets`, it is a convenience + * and not a security feature. + */ + redactUrlParams?: string[]; + + /** + * The directory for automatically named output files, for example a screenshot taken without an + * explicit file name. Files with an explicit name are resolved against the workspace root instead + * and are not affected by this option. + * Relative paths are resolved against the config file's directory. */ outputDir?: string; /** - * Whether to save snapshots, console messages, network logs and other session logs to a file or to the standard output. Defaults to "stdout". + * Threshold for evicting old output files, in bytes. */ - outputMode?: 'file' | 'stdout'; + outputMaxSize?: number; console?: { /** @@ -562,11 +656,19 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so network?: { /** * List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked. + * + * Supported formats: + * - Full origin: `https://example.com:8080` - matches only that origin + * - Wildcard port: `http://localhost:*` - matches any port on localhost with http protocol */ allowedOrigins?: string[]; /** * List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked. + * + * Supported formats: + * - Full origin: `https://example.com:8080` - matches only that origin + * - Wildcard port: `http://localhost:*` - matches any port on localhost with http protocol */ blockedOrigins?: string[]; }; @@ -586,63 +688,137 @@ Playwright CLI will load config from `.playwright/cli.config.json` by default so * Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms. */ navigation?: number; + + /** + * Configures default expect timeout: https://playwright.dev/docs/test-timeouts#expect-timeout. Defaults to 5000ms. + */ + expect?: number; + + /** + * How long to wait after each action for triggered work (navigations, requests) to settle before responding. Defaults to 500ms. + */ + settle?: number; + + /** + * Close the browser after this many milliseconds without a tool call, and relaunch it on the next one. + * Defaults to one hour for headless browsers Playwright launched, and to no timeout for headed or attached ones. Pass 0 to disable. + * The CLI shuts the whole session down instead of relaunching. + */ + idle?: number; + }; + + /** + * Whether to send image responses to the client. Can be "allow", "omit", or "only". Defaults to "allow". + * With "only", a response that carries an image consists of the image parts alone, without the text part. + */ + imageResponses?: 'allow' | 'omit' | 'only'; + + /** + * How file paths are rendered in tool results. Can be "relative" to the workspace root or "absolute". Defaults to "relative". + */ + filePaths?: 'relative' | 'absolute'; + + snapshot?: { + /** + * When taking snapshots for responses, specifies the mode to use. + */ + mode?: 'full' | 'none'; + + /** + * Whether to include each element's bounding box as [box=x,y,width,height] in snapshots. + * Coordinates are viewport-relative, in CSS pixels (Element.getBoundingClientRect). + */ + boxes?: boolean; }; /** - * Whether to allow file uploads from anywhere on the file system. - * By default (false), file uploads are restricted to paths within the MCP roots only. + * allowUnrestrictedFileAccess acts as a guardrail to prevent the LLM from accidentally + * wandering outside its intended workspace. It is a convenience defense to catch unintended + * file access, not a secure boundary; a deliberate attempt to reach other directories can be + * easily worked around, so always rely on client-level permissions for true security. */ allowUnrestrictedFileAccess?: boolean; + /** + * Do not ask the client for its workspace roots, use the current working directory + * as the workspace root instead. Use this with clients that advertise roots, but + * can not answer the roots request. + */ + ignoreRoots?: boolean; + /** * Specify the language to use for code generation. */ - codegen?: 'typescript' | 'none'; + codegen?: 'typescript' | 'python' | 'java' | 'csharp' | 'none'; } ``` + +
Configuration via env + + | Environment | |-------------| -| `PLAYWRIGHT_MCP_ALLOWED_HOSTS` comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check. | -| `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: *does not* serve as a security boundary and *does not* affect redirects. | | `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked. | -| `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects. | +| `PLAYWRIGHT_MCP_ALLOWED_HOSTS` comma-separated list of hosts this server is allowed to serve from. Defaults to localhost, loopback IPs and the host passed via --host; other hosts must be listed explicitly. Pass '*' to disable the host check. | +| `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: *does not* serve as a security boundary and *does not* affect redirects. | +| `PLAYWRIGHT_MCP_BACKGROUND` do not activate controlled tabs or focus the browser window when using --extension. | | `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` block service workers | +| `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: *does not* serve as a security boundary and *does not* affect redirects. | | `PLAYWRIGHT_MCP_BROWSER` browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge. | -| `PLAYWRIGHT_MCP_CAPS` comma-separated list of additional capabilities to enable, possible values: vision, pdf. | +| `PLAYWRIGHT_MCP_CAPS` comma-separated list of additional capabilities to enable, possible values: vision, pdf, devtools. | | `PLAYWRIGHT_MCP_CDP_ENDPOINT` CDP endpoint to connect to. | | `PLAYWRIGHT_MCP_CDP_HEADERS` CDP headers to send with the connect request, multiple can be specified. | -| `PLAYWRIGHT_MCP_CDP_TIMEOUT` timeout for the CDP connection. | +| `PLAYWRIGHT_MCP_CDP_TIMEOUT` timeout in milliseconds for connecting to CDP endpoint, defaults to 30000ms | +| `PLAYWRIGHT_MCP_CODEGEN` specify the language to use for code generation, possible values: "typescript", "python", "java", "csharp", "none". Default is "typescript". | | `PLAYWRIGHT_MCP_CONFIG` path to the configuration file. | | `PLAYWRIGHT_MCP_CONSOLE_LEVEL` level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels. | | `PLAYWRIGHT_MCP_DEVICE` device to emulate, for example: "iPhone 15" | | `PLAYWRIGHT_MCP_EXECUTABLE_PATH` path to the browser executable. | -| `PLAYWRIGHT_MCP_EXTENSION` Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed. | +| `PLAYWRIGHT_MCP_EXTENSION` Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright Extension" to be installed. | +| `PLAYWRIGHT_MCP_FILE_PATHS` how file paths are rendered in tool results, "relative" to the workspace root or "absolute". Default is "relative". | | `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write". | | `PLAYWRIGHT_MCP_HEADLESS` whether to run browser in headless mode, headless by default. | +| `PLAYWRIGHT_MCP_HOST` host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces. | +| `PLAYWRIGHT_MCP_IDLE_TIMEOUT` close the browser after this many milliseconds without a completed tool call, the next tool call relaunches it. Defaults to one hour for headless browsers, never for headed ones, 0 disables. | | `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` ignore https errors | +| `PLAYWRIGHT_MCP_IGNORE_ROOTS` do not ask the client for its workspace roots, use the current working directory as the workspace root instead. Use this with clients that advertise roots, but can not answer the roots request. | +| `PLAYWRIGHT_MCP_IMAGE_RESPONSES` whether to send image responses to the client. Can be "allow", "omit" or "only". With "only", a response that carries an image consists of the image parts alone, without the text part. Defaults to "allow". | | `PLAYWRIGHT_MCP_INIT_PAGE` path to TypeScript file to evaluate on Playwright page object | | `PLAYWRIGHT_MCP_INIT_SCRIPT` path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times. | | `PLAYWRIGHT_MCP_ISOLATED` keep the browser profile in memory, do not save it to disk. | -| `PLAYWRIGHT_MCP_SANDBOX` whether to enable the browser sandbox. | -| `PLAYWRIGHT_MCP_OUTPUT_DIR` path to the directory for output files. | +| `PLAYWRIGHT_MCP_MOBILE` emulate a generic mobile device (Pixel 10 for Chromium, iPhone 17 for WebKit). Mobile pages are usually lighter, which saves tokens. Cannot be combined with --device. | +| `PLAYWRIGHT_MCP_NO_TAB_GROUP` do not group controlled tabs when using --extension. | +| `PLAYWRIGHT_MCP_OUTPUT_DIR` path to the directory for automatically named output files, for example a screenshot taken without an explicit file name. Files with an explicit name are resolved against the workspace root instead and are not affected by this option. | +| `PLAYWRIGHT_MCP_OUTPUT_MAX_SIZE` Threshold for evicting old output files, in bytes. | +| `PLAYWRIGHT_MCP_PORT` port to listen on for SSE transport. | +| `PLAYWRIGHT_MCP_PROFILE_DIR_NAME` name of the profile directory in the user data dir to connect to with --extension, for example "Profile 1". Defaults to the last used profile that has the extension installed. | | `PLAYWRIGHT_MCP_PROXY_BYPASS` comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com" | -| `PLAYWRIGHT_MCP_PROXY_SERVER` specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080" | -| `PLAYWRIGHT_MCP_SAVE_TRACE` Whether to save the Playwright Trace of the session into the output directory. | -| `PLAYWRIGHT_MCP_SAVE_VIDEO` Whether to save the video of the session into the output directory. For example "--save-video=800x600" | +| `PLAYWRIGHT_MCP_PROXY_SERVER` specify proxy server, for example "http://myproxy:3128", "http://user:password@myproxy:3128" or "socks5://myproxy:8080" | +| `PLAYWRIGHT_MCP_REDACT_URL_PARAMS` comma-separated list of URL query and fragment parameter names, for example "access_token,code", whose values are replaced with in the tool responses. | +| `PLAYWRIGHT_MCP_REMOTE_HEADERS` headers to send with the remote endpoint connect request, multiple can be specified. | +| `PLAYWRIGHT_MCP_SANDBOX` enable the sandbox for all process types that are normally not sandboxed. | +| `PLAYWRIGHT_MCP_SANDBOX=false` disable the sandbox for all process types that are normally sandboxed. | | `PLAYWRIGHT_MCP_SECRETS_FILE` path to a file containing secrets in the dotenv format | +| `PLAYWRIGHT_MCP_SESSION_COLOR` color of the session: blue, red, yellow, green, pink, purple, cyan or orange. With --extension, it is the color of the tab group for controlled tabs. | +| `PLAYWRIGHT_MCP_SESSION_NAME` name of the session. With --extension, it is the title of the tab group for controlled tabs. | | `PLAYWRIGHT_MCP_STORAGE_STATE` path to the storage state file for isolated sessions. | | `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` specify the attribute to use for test ids, defaults to "data-testid" | | `PLAYWRIGHT_MCP_TIMEOUT_ACTION` specify action timeout in milliseconds, defaults to 5000ms | | `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` specify navigation timeout in milliseconds, defaults to 60000ms | +| `PLAYWRIGHT_MCP_TIMEOUT_SETTLE` how long to wait after each action for triggered work to settle, in milliseconds, defaults to 500ms | | `PLAYWRIGHT_MCP_USER_AGENT` specify user agent string | | `PLAYWRIGHT_MCP_USER_DATA_DIR` path to the user data directory. If not specified, a temporary directory will be created. | | `PLAYWRIGHT_MCP_VIEWPORT_SIZE` specify browser viewport size in pixels, for example "1280x720" | +| `PLAYWRIGHT_MCP_WEBMCP=false` do not collect or expose the tools that a page registers through the WebMCP API. | + + +
## Specific tasks diff --git a/scripts/update.js b/scripts/update.js index 1bdb0544..edd51c05 100644 --- a/scripts/update.js +++ b/scripts/update.js @@ -1,38 +1,183 @@ -const { execSync } = require('child_process'); +const { execFileSync, execSync } = require('child_process'); const fs = require('fs/promises'); +const fsSync = require('fs'); const path = require('path'); +const { tools } = require('playwright-core/lib/coreBundle'); +const { program } = require('playwright-core/lib/utilsBundle'); + const rootDir = path.resolve(__dirname, '..'); const skillsDir = path.join(rootDir, 'skills'); +const ENV_NAME_OVERRIDES = { + 'secrets': 'PLAYWRIGHT_MCP_SECRETS_FILE', + 'cdp-header': 'PLAYWRIGHT_MCP_CDP_HEADERS', + 'remote-header': 'PLAYWRIGHT_MCP_REMOTE_HEADERS', + 'no-sandbox': 'PLAYWRIGHT_MCP_SANDBOX=false', + 'no-webmcp': 'PLAYWRIGHT_MCP_WEBMCP=false', +}; + +const ENV_DESCRIPTION_OVERRIDES = { + // CLI launches headless unless --headed or PLAYWRIGHT_MCP_HEADLESS=false is set. + 'headless': 'whether to run browser in headless mode, headless by default.', +}; + function run(command, options = {}) { console.log(`Running: ${command}`); execSync(command, { stdio: 'inherit', cwd: rootDir, ...options }); } -async function main() { - // 2. Run playwright-cli install-skills +async function updateSkills() { console.log('\n=== Running playwright-cli install --skills ===\n'); - run('node playwright-cli.js install --skills'); + run('node playwright-cli.js install --skills', { + env: { ...process.env, NO_UPDATE_NOTIFIER: '1' }, + }); - // 3. Move generated skills into the existing skills folder console.log('\n=== Updating skills folder ===\n'); const generatedSkillsDir = path.join(rootDir, '.claude', 'skills', 'playwright-cli'); const targetSkillsDir = path.join(skillsDir, 'playwright-cli'); try { await fs.access(generatedSkillsDir); - // Remove existing skills and copy new ones await fs.rm(targetSkillsDir, { recursive: true, force: true }); await fs.cp(generatedSkillsDir, targetSkillsDir, { recursive: true }); console.log(`Copied skills from ${generatedSkillsDir} to ${targetSkillsDir}`); - // Clean up generated skills directory await fs.rm(generatedSkillsDir, { recursive: true }); console.log('Cleaned up generated skills directory'); } catch { console.warn('Warning: Generated skills directory not found at', generatedSkillsDir); } +} + +/** + * Replaces content between startMarker and endMarker in README.md. + */ +function updateSection(content, startMarker, endMarker, generatedLines) { + const startMarkerIndex = content.indexOf(startMarker); + const endMarkerIndex = content.indexOf(endMarker); + if (startMarkerIndex === -1 || endMarkerIndex === -1) + throw new Error(`Markers not found in README.md: ${startMarker}`); + + return [ + content.slice(0, startMarkerIndex + startMarker.length), + '', + generatedLines.join('\n'), + '', + content.slice(endMarkerIndex), + ].join('\n'); +} + +/** + * Resolves upstream config.d.ts matching the pinned playwright-core version. + */ +async function readUpstreamConfigDts() { + const corePkg = require('playwright-core/package.json'); + const siblingPlaywrightDir = path.join(rootDir, '..', 'playwright'); + const configRelPath = 'packages/playwright-core/src/tools/mcp/config.d.ts'; + + let gitHead = corePkg.gitHead; + if (!gitHead) { + try { + gitHead = execFileSync('npm', ['view', `playwright-core@${corePkg.version}`, 'gitHead', '--no-update-notifier'], { + cwd: rootDir, + encoding: 'utf-8', + shell: process.platform === 'win32', + }).trim(); + } catch { + gitHead = ''; + } + } + + if (gitHead && fsSync.existsSync(path.join(siblingPlaywrightDir, '.git'))) { + try { + return execFileSync('git', ['-C', siblingPlaywrightDir, 'show', `${gitHead}:${configRelPath}`], { + encoding: 'utf-8', + }); + } catch { + } + } + + if (gitHead) { + const url = `https://raw.githubusercontent.com/microsoft/playwright/${gitHead}/${configRelPath}`; + const response = await fetch(url); + if (response.ok) + return await response.text(); + console.warn(`Warning: Failed to fetch ${url} (${response.status})`); + } + + const localConfigPath = path.join(siblingPlaywrightDir, configRelPath); + if (fsSync.existsSync(localConfigPath)) + return await fs.readFile(localConfigPath, 'utf-8'); + + throw new Error(`Could not resolve ${configRelPath} for playwright-core@${corePkg.version}`); +} + +async function updateConfigSection(content) { + console.log('Updating config schema in README.md...'); + const configContent = await readUpstreamConfigDts(); + const configTypeMatch = configContent.match(/export type Config = (\{[\s\S]*?\n\});/); + if (!configTypeMatch) + throw new Error('Config type not found in config.d.ts'); + + const startMarker = ''; + const endMarker = ''; + return updateSection(content, startMarker, endMarker, [ + '```typescript', + configTypeMatch[1].replace(/\r\n/g, '\n'), + '```', + ]); +} + +function updateEnvSection(content) { + console.log('Updating environment variables table in README.md...'); + const coreBundlePath = require.resolve('playwright-core/lib/coreBundle'); + const coreBundleSource = fsSync.readFileSync(coreBundlePath, 'utf-8'); + const supportedEnvVars = new Set(coreBundleSource.match(/\bPLAYWRIGHT_MCP_[A-Z0-9_]+\b/g) || []); + if (!supportedEnvVars.size) + throw new Error(`No PLAYWRIGHT_MCP_* environment variables found in ${coreBundlePath}`); + + const command = new program.constructor(); + tools.decorateMCPCommand(command, '0.0.0'); + const rows = []; + for (const option of command.options) { + const longName = option.long?.replace(/^--/, ''); + if (!longName || longName === 'version' || longName === 'help') + continue; + const envName = ENV_NAME_OVERRIDES[longName] ?? `PLAYWRIGHT_MCP_${longName.toUpperCase().replace(/-/g, '_')}`; + if (!supportedEnvVars.has(envName.split('=')[0])) + continue; + const description = ENV_DESCRIPTION_OVERRIDES[longName] ?? option.description.replace(/\s+/g, ' ').trim(); + rows.push({ envName, description }); + } + rows.sort((a, b) => a.envName.localeCompare(b.envName)); + + const table = [ + '| Environment |', + '|-------------|', + ...rows.map(row => `| \`${row.envName}\` ${row.description} |`), + ]; + + const startMarker = ''; + const endMarker = ''; + return updateSection(content, startMarker, endMarker, table); +} + +async function updateReadme() { + console.log('\n=== Updating README.md ===\n'); + const readmePath = path.join(rootDir, 'README.md'); + const raw = await fs.readFile(readmePath, 'utf-8'); + const eol = raw.includes('\r\n') ? '\r\n' : '\n'; + let content = raw.replace(/\r\n/g, '\n'); + content = await updateConfigSection(content); + content = updateEnvSection(content); + await fs.writeFile(readmePath, content.replace(/\n/g, eol), 'utf-8'); + console.log('Updated README.md'); +} + +async function main() { + await updateSkills(); + await updateReadme(); console.log('\n=== Update complete! ===\n'); }