npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-ready-pw-codegen

v1.1.3

Published

AI-Ready PW Codegen — offline Playwright recorder with snapshots for AI-powered test generation

Readme

AI-Ready PW Codegen

npm version playwright license

Offline Playwright recorder. Captures each user action with accessibility tree, cleaned DOM, screenshot, and console logs — packages everything into an archive for AI-powered test generation.

Record on any machine. Generate tests with AI later.

Quick Start

npm install -g ai-ready-pw-codegen
ai-ready-pw-codegen https://your-app.com

A Chromium browser opens with Playwright's recorder UI. Interact with the page. Close the browser — the recording is archived automatically.

🎭 AI-Ready PW Codegen
   URL: https://your-app.com
   Output: ./recordings/test-2026-03-23T15-08-06

Recording... Close the browser to stop.
●●●●●●●●●●
Recorded 10 actions
Archive: ./recordings/test-2026-03-23T15-08-06.tar.gz
✅ Done! Send the archive to AI for analysis.

Why?

Problem: AI tools (Claude Code, Cursor, Gemini CLI) can generate tests, but they need page context — DOM structure, accessibility tree, selectors. Getting this context manually is tedious.

Solution: Record once, capture everything, send to AI. Works offline — no AI connection needed during recording.

What gets captured per action:

  • Accessibility tree (roles, names, states)
  • Cleaned DOM (test-relevant attributes only, max depth 30)
  • Screenshot
  • Console logs (errors, warnings)
  • Full codegen data (selector, position, modifiers, generated code)

CLI Options

ai-ready-pw-codegen <URL> [options]

  --no-screenshots     Disable screenshots
  --no-archive         Skip .tar.gz creation
  --no-console         Disable console log capture
  --headless           Run in headless mode
  --max-actions <N>    Stop after N actions
  --output-dir <path>  Output directory (default: ./recordings)
  --width <number>     Viewport width (default: 1280)
  --height <number>    Viewport height (default: 720)

URL protocol is auto-detected: tries http:// first, falls back to https://. Explicit protocol (http://... or https://...) is used as-is.

Output

recordings/test-YYYY-MM-DDTHH-mm-ss/
├── SESSION.md              # AI reads this first — session metadata
├── DATA_FORMAT.md          # Data format reference
├── TEST_GUIDE.md           # Test generation guidelines
├── actions.jsonl           # One action per line — primary data
├── snapshots.jsonl         # Cleaned DOM per action — read on demand
└── screenshots/
    ├── 001-navigate.png
    └── 002-click.png

actions.jsonl

{
  "index": 2,
  "timestamp": "2026-03-23T15:08:07.123Z",
  "url": "https://your-app.com/dashboard",
  "action": {
    "type": "click",
    "selector": "[data-testid=\"submit-btn\"]",
    "codegenCode": "await page.getByTestId('submit-btn').click()",
    "position": { "x": 150, "y": 320 },
    "button": "left"
  },
  "accessibilityTree": { "role": "WebArea", "children": [...] },
  "screenshotFile": "screenshots/002-click.png",
  "consoleLogs": [
    { "level": "error", "text": "Failed to fetch /api/data", "timestamp": "..." }
  ]
}

snapshots.jsonl

DOM snapshots are large — separated from actions to save AI context window. Each line: {"index": 2, "cleanedDom": "<body>...</body>"}. Read only when accessibility tree lacks details about DOM hierarchy or test attributes.

Using with AI

# 1. Record
ai-ready-pw-codegen https://your-app.com

# 2. Extract
tar -xzf recordings/test-*.tar.gz

# 3. Point AI to the directory
# Claude Code / Cursor / Gemini CLI reads SESSION.md first,
# then actions.jsonl → screenshots → generates tests

See docs/DATA_FORMAT.md and docs/TEST_GUIDE.md for detailed instructions on how AI should process recordings and generate tests. Both files are automatically included in every archive.

How It Works

  1. Launches headed Chromium with Playwright's built-in codegen recorder UI
  2. Hooks into codegen events (actionAdded/actionUpdated) via internal _enableRecorder API
  3. On each action: captures accessibility tree + cleaned DOM + screenshot + console logs
  4. On browser close: writes JSONL files, generates SESSION.md, archives into .tar.gz

Uses Playwright internal API (underscore-prefixed). Playwright version pinned to 1.58.2.

Development

git clone https://github.com/winst0niuss/ai-ready-pw-codegen.git
cd ai-ready-pw-codegen
npm install
npm run build          # Build to dist/
npx tsc --noEmit       # Type check
npx ts-node src/main.ts https://example.com  # Run from source

License

MIT