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

browsecraft-ai

v0.6.3

Published

AI-powered self-healing, test generation, and visual regression for Browsecraft

Readme

browsecraft-ai

AI-powered self-healing, test generation, and visual regression for Browsecraft.

Uses the GitHub Models API — free with any GitHub account. All features degrade gracefully when no token is available, falling back to heuristic-based approaches.

Install

npm install browsecraft-ai

Setup

Set a GitHub personal access token with the models scope:

export GITHUB_TOKEN=ghp_...

Everything works without a token — AI just makes it better.

Features

Self-Healing Selectors

When a CSS selector breaks, suggests a replacement using page context.

import { healSelector } from 'browsecraft-ai';

const result = await healSelector('.old-button-class', {
  url: 'https://example.com',
  title: 'My Page',
  elements: [
    { tag: 'button', text: 'Submit', attributes: { class: 'new-btn', id: 'submit' } },
    // ... page elements
  ],
});

console.log(result.selector);   // '.new-btn' or '#submit'
console.log(result.confidence); // 0.0 - 1.0
console.log(result.method);    // 'ai' | 'text-similarity' | 'attribute-match'

Without AI: Uses Levenshtein distance and attribute similarity heuristics. With AI: Sends page snapshot to GitHub Models for intelligent matching.

Test Generation

Generates Browsecraft test code from a natural-language description.

import { generateTest } from 'browsecraft-ai';

const result = await generateTest({
  description: 'Log in and verify the dashboard loads',
  url: 'https://myapp.com/login',
  style: 'script', // 'browsecraft' | 'script'
});

console.log(result.code);        // Complete, runnable test code
console.log(result.aiGenerated); // true if AI was used

Without AI: Generates a template skeleton with TODO comments.

Visual Regression

Compares screenshots pixel-by-pixel, with optional AI semantic analysis.

import { compareScreenshots } from 'browsecraft-ai';

const result = await compareScreenshots('baseline.png', 'current.png', {
  maxDiffPercent: 1.0,
  diffOutputPath: 'diff.png',
  useAI: true,           // optional: use GPT-4o vision for semantic comparison
  antiAlias: true,        // ignore anti-aliasing differences
  ignoreRegions: [        // ignore dynamic content areas
    { x: 0, y: 0, width: 200, height: 50 },
  ],
});

console.log(result.match);       // true/false
console.log(result.diffPercent); // 0.42
console.log(result.aiAnalysis);  // AI explanation (if useAI: true)

Zero external dependencies — uses a built-in PNG decoder/encoder.

AI Failure Diagnosis

Analyze test failures with page context to get actionable fix suggestions.

import { diagnoseFailure } from 'browsecraft-ai';

const diagnosis = await diagnoseFailure(error, {
  url: 'https://example.com',
  title: 'Login Page',
  pageSnapshot: '<html>...</html>',
});

if (diagnosis) {
  console.log(diagnosis.suggestion);  // "The button is disabled. Wait for form validation."
  console.log(diagnosis.confidence);  // 0.85
}

Returns null when no AI provider is configured — never throws.

Persistent AI Cache

AI results are cached on disk to avoid redundant API calls. Cache entries are keyed by input hash and automatically reused across test runs.

API Reference

Functions

| Function | Description | |----------|-------------| | healSelector(failedSelector, snapshot, options?) | Suggest a replacement for a broken CSS selector | | diagnoseFailure(error, context?) | AI-powered failure analysis with fix suggestions | | generateTest(options) | Generate test code from natural language | | compareScreenshots(baseline, current, options?) | Pixel-by-pixel screenshot comparison | | isGitHubModelsAvailable(token?) | Check if the GitHub Models API is reachable | | detectCapabilities(token?) | Discover available AI capabilities | | githubModelsChat(messages, options?) | Send a chat completion request | | githubModelsGenerate(prompt, options?) | Generate text from a prompt | | resolveToken(token?) | Resolve a GitHub token from env or explicit value |

License

MIT