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-me-chat/nextjs

v0.4.0

Published

AI-Me Next.js integration — route handler factory, auto-discovery, and proxy

Readme

@ai-me-chat/nextjs

Next.js integration for AI-Me — route handler factory with auto-discovery, filtering, and auth forwarding.

Installation

npm install @ai-me-chat/nextjs

Quick Start

Important: Use an optional catch-all route so sub-paths (/tools, /health) are handled:

app/api/ai-me/[[...path]]/route.ts    <-- correct
app/api/ai-me/route.ts                <-- won't handle /tools or /health

Create app/api/ai-me/[[...path]]/route.ts:

import { createAIMeHandler } from "@ai-me-chat/nextjs";
import { openai } from "@ai-sdk/openai";

const handler = createAIMeHandler({
  model: openai("gpt-4o"),

  discovery: {
    mode: "filesystem",
    include: ["/api/**"],
    exclude: ["/api/ai-me/**"],
  },

  getSession: async (req) => {
    // your auth logic
    return { user: { id: "user-1", role: "admin" } };
  },

  systemPrompt: "You are a helpful AI assistant for this app.",
});

export { handler as GET, handler as POST };

Features

  • Filesystem discovery — auto-scans app/api/ routes at startup, with src/app auto-detection
  • OpenAPI discovery — generate tools from an OpenAPI 3.x spec (inline or remote URL)
  • Route filtering — include/exclude patterns with glob support
  • Auth forwarding — forwards cookies and authorization headers to your routes
  • Write confirmation — POST/PUT/PATCH/DELETE require user confirmation by default
  • Dynamic system prompt — inject user-specific context via a function

Endpoints

| Path | Method | Purpose | Auth | |------|--------|---------|------| | /api/ai-me | POST | Chat endpoint | Required | | /api/ai-me/tools | GET | List discovered tools | Required | | /api/ai-me/health | GET | Health check | No |

The health endpoint does NOT require authentication — use it for liveness probes and monitoring.

App Directory Detection

When using mode: "filesystem", the handler automatically locates your Next.js app directory:

  1. src/app — checked first (default for npx create-next-app)
  2. app — fallback for projects without a src/ layout

You can override this by setting appDir in the discovery config:

discovery: {
  mode: "filesystem",
  appDir: "src/app",       // relative to project root, or absolute
}

OpenAPI Discovery Mode

Instead of scanning the filesystem, provide an OpenAPI 3.x spec (inline or remote):

createAIMeHandler({
  discovery: {
    mode: "openapi",
    spec: {
      openapi: "3.0.3",
      info: { title: "My API", version: "1.0.0" },
      paths: {
        "/api/users": {
          get: {
            operationId: "listUsers",
            summary: "List all users",
            parameters: [
              { name: "q", in: "query", schema: { type: "string" }, description: "Search by name" }
            ],
            responses: { "200": { description: "User list" } }
          }
        }
      }
    }
  },
  ...
})

Or fetch from a remote URL:

discovery: {
  mode: "openapi",
  specUrl: "http://localhost:3000/api/openapi.json"
}

When to use OpenAPI mode:

  • Your app uses src/app and filesystem detection fails
  • You want custom tool names via operationId
  • You want rich parameter descriptions for better AI understanding
  • You want to expose only specific endpoints (include/exclude still work)

Dynamic System Prompt

Inject user-specific context by passing a function:

createAIMeHandler({
  systemPrompt: async (session) => {
    const settings = await db.settings.findUnique({ where: { userId: session.user.id } });
    return `You are an assistant for ${settings.companyName}. The user is ${session.user.name}.`;
  },
})

Peer Dependencies

| Package | Version | |---------|---------| | ai | ^6.0.0 | | next | ^16.0.0 | | react | ^19.0.0 |

Documentation

Full setup guide and API reference: github.com/aselims/ai-me-chat

License

MIT