Repository navigation
feat: add tools.playwright.mode (mcp/cli) and enable cli mode in smoke-copilot #29840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
52a235c
feat: add tools.playwright.mode: mcp/cli and enable cli mode in smoke…
Copilot e8e252d
fix: address code review feedback - nil safety and formatting
Copilot f5a30ee
Merge remote-tracking branch 'origin/main' into copilot/add-tools-pla…
Copilot 4be3a8f
chore: merge main and recompile all workflows
Copilot 92a5734
fix: address code review - HasMCPServers CLI mode, Node.js setup, Cod…
Copilot 4c2ba4e
Add changeset
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package workflow | ||
|
|
||
| // Package workflow provides support for Playwright CLI mode. | ||
| // | ||
| // # Playwright CLI Mode | ||
| // | ||
| // When tools.playwright.mode is set to "cli", the compiler installs the | ||
| // @playwright/cli npm package instead of launching the Docker-based MCP server. | ||
| // This is a token-efficient alternative for coding agents that prefer CLI-based | ||
| // workflows over MCP: CLI invocations avoid loading large tool schemas and verbose | ||
| // accessibility trees into the model context. | ||
| // | ||
| // See https://github.com/microsoft/playwright-cli for details. | ||
| // | ||
| // In CLI mode: | ||
| // - The mcr.microsoft.com/playwright/mcp Docker image is NOT pulled. | ||
| // - playwright is NOT registered as an MCP server in the gateway config. | ||
| // - @playwright/cli is installed via npm (global) before the agent runs. | ||
| // - playwright-cli install --skills installs agent skill files so the coding | ||
| // agent can discover and use the available playwright-cli commands. | ||
| // - The agent uses `playwright-cli <command>` directly via bash. | ||
| // | ||
| // Example workflow frontmatter: | ||
| // | ||
| // tools: | ||
| // playwright: | ||
| // mode: cli | ||
|
|
||
| import ( | ||
| "github.com/github/gh-aw/pkg/constants" | ||
| "github.com/github/gh-aw/pkg/logger" | ||
| ) | ||
|
|
||
| var playwrightCLILog = logger.New("workflow:playwright_cli") | ||
|
|
||
| // isPlaywrightCLIMode returns true when the playwright tool in the given tools map | ||
| // is configured with mode: cli. | ||
| func isPlaywrightCLIMode(tools map[string]any) bool { | ||
| playwrightTool, ok := tools["playwright"] | ||
| if !ok || playwrightTool == false { | ||
| return false | ||
| } | ||
| config := parsePlaywrightTool(playwrightTool) | ||
| return config != nil && config.IsCLIMode() | ||
| } | ||
|
|
||
| // generatePlaywrightCLIInstallSteps returns npm install steps for @playwright/cli | ||
| // when playwright is configured in CLI mode. Returns nil if playwright is in MCP mode. | ||
| // | ||
| // Node.js setup is intentionally omitted here because all supported engines | ||
| // (copilot, claude, codex, gemini) include a Node.js setup step in their own | ||
| // installation steps, which run before this function is called. | ||
| func generatePlaywrightCLIInstallSteps(workflowData *WorkflowData) []GitHubActionStep { | ||
| if !isPlaywrightCLIMode(workflowData.Tools) { | ||
| return nil | ||
| } | ||
|
|
||
| playwrightCLILog.Print("Generating @playwright/cli install steps (CLI mode)") | ||
|
|
||
| version := string(constants.DefaultPlaywrightCLIVersion) | ||
| // Use version override from playwright config if provided | ||
| if playwrightTool, ok := workflowData.Tools["playwright"]; ok { | ||
| config := parsePlaywrightTool(playwrightTool) | ||
| if config != nil && config.Version != "" { | ||
| version = config.Version | ||
| playwrightCLILog.Printf("Using playwright CLI version from config: %s", version) | ||
| } | ||
| } | ||
|
|
||
| // Install @playwright/cli globally. | ||
| // runInstallScripts is true because playwright's postinstall script may set up | ||
| // browser binaries needed at runtime. | ||
| steps := GenerateNpmInstallStepsWithScope( | ||
| "@playwright/cli", | ||
| version, | ||
| "Install Playwright CLI", | ||
| "playwright-cli", | ||
| false, // Node.js is already set up by the engine install steps | ||
| true, // Global install so playwright-cli is on PATH | ||
| true, // Allow install scripts for browser setup | ||
| ) | ||
|
|
||
| // Install playwright-cli skills so the coding agent can discover available commands. | ||
| installSkillsStep := GitHubActionStep{ | ||
| " - name: Install Playwright CLI skills", | ||
| " run: playwright-cli install --skills", | ||
| } | ||
| steps = append(steps, installSkillsStep) | ||
|
|
||
| playwrightCLILog.Printf("Generated %d Playwright CLI install steps", len(steps)) | ||
| return steps | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition of
DefaultPlaywrightCLIVersion. Consider also adding a minimum version guard or a comment explaining why0.1.11was chosen as the baseline for CLI mode support.