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-gui/plugin-optics

v0.29.2

Published

Ray-optics teaching figures for AIGUI — lenses, mirrors and refraction, with the image position and the rays computed from the conditions.

Readme

@ai-gui/plugin-optics

Ray-optics teaching figures for AIGUI. The model names the element and the object; the image, the rays and the conclusion are computed here.

Install

pnpm add @ai-gui/plugin-optics

No runtime dependency beyond @ai-gui/core. The output is an SVG string.

Usage

import { optics } from "@ai-gui/plugin-optics"
<AIRenderer plugins={[optics()]} />
buildSystemPrompt({ registry, plugins: [optics()], locale: "zh-CN" })
```optics
{
  "element": "convex-lens",
  "focal": 10,
  "object": { "distance": 30, "height": 4, "label": "AB" },
  "caption": "物距大于二倍焦距时的成像"
}
```

The conclusion is generated, not quoted

This is what makes this plugin different from the other figure plugins. Where the image lands is one thing a model gets wrong; writing “倒立、缩小、实像” under a figure where the image is upright and enlarged is worse, because that sentence is what a reader takes away and nothing checks it.

The plugin computes v and the magnification, so it writes that line itself:

正立、放大、虚像(像距 15,放大率 2.5)

It comes from the same numbers the rays are drawn from, so the two cannot disagree. A model caption that says otherwise is contradicted in place rather than quietly believed — and the protocol asks the model not to state the result at all, refusing a definition that carries imageDistance, magnification or refractionAngle.

Sign convention

Light travels left to right; the element sits at the origin; the object is on the left and its distance is positive. A converging element (convex lens, concave mirror) has a positive focal; a diverging one (concave lens, convex mirror) a negative one — and the wrong sign is refused rather than drawn, because a question quotes “焦距 12 cm” as a magnitude and a diverging element drawn with a positive focal length converges, which is the opposite figure.

A mirror sends light back the way it came, so its real image forms in front of it while a lens forms one behind. Getting that backwards puts the image on the wrong side of a figure that otherwise looks entirely reasonable.

Supported

| | | | --- | --- | | Imaging | convex-lens, concave-lens, concave-mirror, convex-mirror, plane-mirror | | Rays | the three characteristic rays, constructed from the rules rather than from the answer; virtual extensions dashed | | Refraction | interface with media: [n1, n2] and an incidence angle — Snell's law, with total internal reflection detected and the critical angle reported |

Not in this version, and the prompt spec tells the model to explain them in prose: more than one element, prisms and dispersion, interference, diffraction, polarisation, aberration, and repeated reflection in a fibre.

Testing note

src/fixtures/ holds the figures a model produced when given this plugin's prompt spec and twenty textbook questions. They are part of the test suite.

See the root README for the full plugin list.