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

@domphy/doctor

v0.19.0

Published

Domphy Doctor - static analyzer that flags non-idiomatic Domphy element trees (AI self-correction)

Readme

@domphy/doctor

domphy.com · Docs · npm

A static analyzer for Domphy element trees. It walks the plain-object tree and flags non-idiomatic patterns, giving humans — and especially AI agents — a feedback loop to self-correct generated code.

Because Domphy UIs are plain objects, the doctor can inspect them directly (no parser, no build step), including the output of reactive (listener) => … functions.

Install

npm install @domphy/doctor @domphy/core

@domphy/core is a peer dependency (the doctor reads its tag tables).

Usage

import { diagnose, format } from "@domphy/doctor"

const App = {
  div: [
    { p: "Hello", style: { fontSize: "20px" } },   // inline typography
    { input: "oops" },                              // void tag with content
    { dvi: "typo" },                                // unknown tag
  ],
}

const issues = diagnose(App)
console.log(format(issues))
// ⚠ [inline-typography] div > p
//   Inline `fontSize` — avoid inline typography styles.
//   → Use a typography patch (paragraph()/heading()/…) via $.
// ✗ [void-content] div > input
//   Void tag "input" must have null content (got string).
// ⚠ [unknown-tag] div
//   "dvi" is not a known HTML/SVG tag — likely a typo.

diagnose(element, options?) returns Diagnostic[]:

interface Diagnostic {
  rule: string          // one of the 18 rule ids below, e.g. "inline-typography"
  severity: "error" | "warning" | "info"
  category?: string     // "structure" | "key" | "theme" | "typography" | "data-attr" | "visual"
  path: string          // "div > ul > li"
  message: string
  hint?: string
}

Rules

The doctor implements 18 rules:

| Rule | Severity | Catches | | --- | --- | --- | | missing-key | warning | a dynamic list (from a reactive function) of element children missing _key | | unstable-key | warning | a dynamic list whose _keys are the array index (0, 1, 2, …) — unstable across reorders | | duplicate-key | error | two sibling elements sharing the same _key value | | unknown-tag | warning | an element whose first key isn't a valid HTML/SVG tag (typo) | | void-content | error | a void tag (input, img, br, …) with non-null content | | inline-typography | warning | fontSize/lineHeight/fontWeight/letterSpacing/fontFamily/textDecoration literals in style — use a typography patch | | raw-theme-value | info | a literal color (#hex, rgb()/rgba(), CSS named colors like "red") in a color style prop — use themeColor() | | raw-spacing-value | info | a literal rem/em/px spacing value in a spacing style prop — use themeSpacing() | | low-opacity | warning/info | style.opacity < 0.6 on a control; info if hover-restore pattern (&:hover: { opacity: '1' }) is detected | | tone-background-inherit | warning | style.backgroundColor resolves to a fixed shifted tone var instead of the inherit tone — use dataTone to shift the surface, not backgroundColor | | missing-color | warning | element uses themeColor() for at least one styled prop but has no style.color — text color won't re-evaluate when the tone context shifts | | low-contrast | warning | style.color and style.backgroundColor are both reactive theme vars but their shift-step gap is < 9 (insufficient contrast) | | dataTone-surface-contract | warning | element sets dataTone but is missing backgroundColor and/or color — a tone context surface must declare both so children can guarantee readable contrast | | color-shift-minimum | warning | element with dataTone sets style.color to a tone step < 9 — below the minimum for legible body text | | unknown-tone | warning | a dataTone that isn't valid tone grammar, or whose offset is out of the 18-step ramp (0–17). Valid grammar includes the semantic aliases surface/hover/border/border-strong/muted/text | | middle-surface-anchor | warning | a dataTone of shift-4shift-13 (mid-ramp surface anchor) that may collapse child contrast | | unknown-density | warning/error | a dataDensity that isn't valid grammar, or whose offset is out of the 5-step range (0–4) | | unknown-size | warning/error | a dataSize that isn't valid grammar, or whose offset is out of the 8-step range (0–7) |

By default the doctor invokes reactive content functions with a no-op listener to inspect their output (this is how missing-key is detected). Pass { runReactive: false } if your reactive functions have side effects.

CLI

@domphy/doctor ships a domphy-doctor binary that scans .ts/.tsx/.js/.mjs files or directories, extracts every exported Domphy element, and runs diagnose() on each:

npx domphy-doctor src/

Flags: --only <rules>, --exclude <rules>, --no-reactive, --no-output (skip Layer 4, see below), --format text|json. Exit code 1 when any error-severity diagnostic is found, 2 on a CLI/usage error. See the configuration docs for the full flag reference.

Layer 4: HTML/CSS output linting

auditOutput(node, options?) is an optional fourth layer: it builds the real HTML/CSS a Domphy ElementNode would render and runs it through htmlhint (structural/a11y) and stylelint (CSS quality). Both linters are optional peer deps — npm install --save-dev htmlhint stylelint to enable them; auditOutput() silently skips a linter that isn't installed. The domphy-doctor CLI calls this automatically (disable with --no-output).

import { ElementNode } from "@domphy/core"
import { auditOutput, type Layer4Options } from "@domphy/doctor"

const diags = await auditOutput(new ElementNode(MyApp), { path: "MyApp" })

For AI agents

Run diagnose() on generated Domphy code and feed format() back to the model — it will fix the issues itself. This is the self-correction loop that lets agents write correct Domphy despite having little training data for it. See the repo AGENTS.md and llms.txt for the rules the doctor enforces.