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

@rulekitai/ui

v0.5.0

Published

React hooks and styled chat components for a grounded rules assistant.

Readme

@rulekitai/ui

React hooks and styled chat components for a grounded rules assistant.

Part of rulekit.

Install

pnpm add @rulekitai/ui @rulekitai/rulekit

react is a peer dependency.

Use

import { useAskStream } from "@rulekitai/ui/use-ask-stream"
import { Chat } from "@rulekitai/ui/chat"
import { RuleKitProvider } from "@rulekitai/ui/provider"
import "@rulekitai/ui/styles.css"

function Assistant() {
  const { messages, loading, streaming, ask } = useAskStream({
    endpoint: "/api/ask",
  })

  return (
    <RuleKitProvider>
      <Chat
        messages={messages}
        loading={loading}
        streaming={streaming}
        onAsk={ask}
      />
    </RuleKitProvider>
  )
}

Chat holds no state and opens no connection. It renders what you give it, so the hook above supplies the messages. RuleKitProvider must be a parent, because the components read the card link scheme and the legal note from it.

Every component and every hook has its own subpath, as above. An application that wants the hooks alone never loads the styled components, so there is no root import: import ... from "@rulekitai/ui" throws a message that names the subpaths instead.

The hooks carry no styling, so you can use them without the components. The components read CSS variables, so your theme controls their appearance.

Say something true under each answer

disclaimer takes a node, or a function. Take the function. It receives three facts, and each one changes what is true of the answer above it.

import { answerSource, type ReadSource } from "@rulekitai/ui/message"

<RuleKitProvider
  disclaimer={(servedBy: string, sources: ReadSource[], source?: string) => {
    const base =
      answerSource(servedBy, source) === "model"
        ? "Written by an AI from the rules data."
        : "Read from the rules data, with no AI."
    return sources.length
      ? `${base} It also read ${sources.map((s) => s.name).join(", ")}, outside the rules data.`
      : base
  }}
/>

servedBy is the stage that served the answer. Most answers come from the free stages, where no model runs. One fixed sentence about an AI therefore states the opposite of what happened, and it contradicts the trace line above it.

source is where the facts came from, which is NOT the stage that served them. PASS BOTH TO answerSource, as above. A cache hit serves an answer a model wrote earlier, and servedBy then reads "cache". Reading the stage alone labels a model's own words "no AI wrote this", on every repeated question, which is every question a cache exists for. answerSource reads the origin first and falls back to the stage, so a one-argument call still compiles and still gets this wrong.

sources names any website that the answer read. It is empty for almost every answer. It holds a name only when the server was given reference sites. See reference sites.

Marking a claim from outside the corpus

A trace step that read a website carries a source object: the site name, the exact address, and whether the site is official.

AnswerTrace renders it already. The open list names the site and links to the page. The closed summary says that the answer read a source outside the rules data. A reader who never opens the trace is the one who most needs to know. Both marks use the --rk-warning CSS variable, so your theme controls them.

To build your own mark, call readSources(message.steps). It returns one entry for each SITE, and not for each page: three pages of one site is still one source to weigh.

Read this from the trace, and never from the answer text. The model writes the answer text, and the model is the thing that your reader checks. A mark inside that text therefore proves nothing.

Documentation

Licence

Apache 2.0. See the LICENSE file beside this one.