diff --git a/dotfiles/agents/skills/playwright-cli/SKILL.md b/dotfiles/agents/skills/playwright-cli/SKILL.md new file mode 100644 index 00000000..51755db2 --- /dev/null +++ b/dotfiles/agents/skills/playwright-cli/SKILL.md @@ -0,0 +1,47 @@ +--- +name: playwright-cli +description: Automate browser interactions from the shell using Playwright via the `playwright-cli` command (open/goto/snapshot/click/type/screenshot, tabs/storage/network). Use when you need deterministic browser automation for web testing, form filling, screenshots/PDFs, or data extraction. +--- + +# Browser Automation With playwright-cli + +This system provides `playwright-cli` via Nix (see `nixos/overlay.nix` and `nixos/code.nix`), so it’s available on `PATH` without any `npm -g` installs. + +## Quick Start + +```bash +# First run (downloads browser bits used by Playwright) +playwright-cli install-browser + +# Open a new browser session (optionally with a URL) +playwright-cli open +playwright-cli open https://example.com/ + +# Navigate, inspect, and interact +playwright-cli goto https://playwright.dev +playwright-cli snapshot +playwright-cli click e15 +playwright-cli type "search query" +playwright-cli press Enter + +# Save artifacts +playwright-cli screenshot --filename=page.png +playwright-cli pdf --filename=page.pdf + +# Close the browser +playwright-cli close +``` + +## Practical Workflow + +1. `playwright-cli open` (or `open `) +2. `playwright-cli snapshot` +3. Use element refs (`e1`, `e2`, ...) from the snapshot with `click`, `fill`, `hover`, `check`, etc. +4. Take `screenshot`/`pdf` as needed +5. `playwright-cli close` + +## Tips + +- Use `playwright-cli state-save auth.json` / `state-load auth.json` to persist login state across runs. +- Use named sessions with `-s=mysession` when you need multiple concurrent browsers. +- Set `PLAYWRIGHT_CLI_PACKAGE` to pin the npm package (default is `@playwright/cli@latest`). diff --git a/dotfiles/agents/skills/playwright-cli/agents/openai.yaml b/dotfiles/agents/skills/playwright-cli/agents/openai.yaml new file mode 100644 index 00000000..cf20e1ff --- /dev/null +++ b/dotfiles/agents/skills/playwright-cli/agents/openai.yaml @@ -0,0 +1,5 @@ +interface: + display_name: "Playwright CLI" + short_description: "Automate browser interactions" + default_prompt: "Use playwright-cli to automate browser actions (open/goto/snapshot/click/type/screenshot) and save useful artifacts (screenshots, PDFs, auth state)." + diff --git a/nixos/code.nix b/nixos/code.nix index f40f190e..e2f9bea6 100644 --- a/nixos/code.nix +++ b/nixos/code.nix @@ -18,6 +18,7 @@ makeEnable config "myModules.code" true { github-mcp-server gitea-mcp-server playwright-mcp + playwright-cli # C clang diff --git a/nixos/overlay.nix b/nixos/overlay.nix index 36d93696..eb669b8b 100644 --- a/nixos/overlay.nix +++ b/nixos/overlay.nix @@ -264,6 +264,34 @@ in in final.python3.withPackages my-python-packages; + playwright-cli = final.buildNpmPackage rec { + pname = "playwright-cli"; + version = "0.1.0"; + + src = final.fetchFromGitHub { + owner = "microsoft"; + repo = "playwright-cli"; + rev = "v${version}"; + hash = "sha256-9LuLQ2klYz91rEkxNDwcx0lYgE6GPoTJkwgxI/4EHgg="; + }; + + # Hash of dependencies produced from package-lock.json (lockfileVersion = 3). + # To recompute: + # nix build nixpkgs#prefetch-npm-deps -o /tmp/prefetch-npm-deps + # /tmp/prefetch-npm-deps/bin/prefetch-npm-deps package-lock.json + npmDepsHash = "sha256-DvorQ40CCNQJNQdTPFyMBErFNicSWkNT/e6S8cfZlRA="; + + # No build step; the published CLI is just a Node entrypoint + deps. + dontNpmBuild = true; + + meta = with final.lib; { + description = "Playwright CLI (playwright-cli) for browser automation and Playwright MCP terminal commands"; + homepage = "https://github.com/microsoft/playwright-cli"; + license = licenses.asl20; + mainProgram = "playwright-cli"; + }; + }; + pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ ( python-final: python-prev: {