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

mdi-llmkit

v1.1.3

Published

Utilities for managing multi-shot conversations and structured data handling in LLM applications

Readme

mdi-llmkit (TypeScript)

Utilities for managing LLM chat conversations and structured JSON responses with OpenAI's Responses API.

Installation

npm install mdi-llmkit openai

Quick Start

gptSubmit

import OpenAI from 'openai';
import { gptSubmit } from 'mdi-llmkit';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const reply = await gptSubmit(
  [{ role: 'user', content: 'Say hello.' }],
  client
);

console.log(reply);

GptConversation

import OpenAI from 'openai';
import { GptConversation } from 'mdi-llmkit';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const conversation = new GptConversation([], { openaiClient: client });

const reply = await conversation.submitUserMessage(
  'Give me three project name ideas.'
);
console.log(reply);

JSONSchemaFormat

import { JSONSchemaFormat, JSON_INTEGER, gptSubmit } from 'mdi-llmkit';

const responseFormat = JSONSchemaFormat(
  'answer_payload',
  {
    answer: 'The final answer',
    confidence: ['Confidence score', [0, 100], []],
    rank: JSON_INTEGER,
  },
  'Structured answer payload'
);

const result = await gptSubmit(
  [{ role: 'user', content: 'Return answer as structured JSON.' }],
  client,
  { jsonResponse: responseFormat }
);

jsonSurgery

jsonSurgery applies iterative, model-guided edits to a JSON-compatible object using structured JSON-path operations (assign, append, insert, delete, rename).

import { jsonSurgery } from 'mdi-llmkit/jsonSurgery';
  • It deep-copies the input object and returns the modified copy.
  • It supports optional schema guidance and key-skipping for model-visible context.
  • It supports validation/progress callbacks and soft iteration/time limits.

compareItemLists (semanticMatch)

compareItemLists performs a semantic diff between a "before" list and an "after" list, including LLM-assisted rename/add/remove decisions.

Types:

  • SemanticallyComparableListItem
    • string
    • { name: string; description?: string }
  • ItemComparisonResult
    • Removed | Added | Renamed | Unchanged
  • OnComparingItemCallback
    • (item, isFromBeforeList, isStarting, result, newName, error, totalProcessedSoFar, totalLeftToProcess) => void

Behavior notes:

  • Item matching is name-based and case-insensitive.
  • description provides extra model context but is not identity.
  • Names are expected to be unique within each list (case-insensitive).
  • Progress callback is fired at item start (isStarting=true) and finish (isStarting=false).

Example:

import OpenAI from 'openai';
import {
  compareItemLists,
  ItemComparisonResult,
  type OnComparingItemCallback,
} from 'mdi-llmkit/semanticMatch';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const onComparingItem: OnComparingItemCallback = (
  item,
  isFromBeforeList,
  isStarting,
  result,
  newName,
  error,
  processed,
  left
) => {
  if (error) {
    console.warn('Comparison warning:', error);
  }
  if (!isStarting && result === ItemComparisonResult.Renamed) {
    console.log('Renamed:', item, '->', newName);
  }
  console.log({ isFromBeforeList, isStarting, result, processed, left });
};

const comparison = await compareItemLists(
  client,
  [{ name: 'Widget A', description: 'Legacy widget' }, 'Widget B'],
  [
    { name: 'Widget Alpha', description: 'Migrated name for Widget A' },
    'Widget B',
  ],
  'Widgets migrated from legacy catalog to new naming standards.',
  onComparingItem
);

console.log(comparison);

JSON Response Mode

import OpenAI from 'openai';
import { gptSubmit } from 'mdi-llmkit';

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const result = await gptSubmit(
  [{ role: 'user', content: 'Return JSON with keys a and b.' }],
  client,
  { jsonResponse: true }
);

console.log(result);

CI and Release

  • Unified CI + release workflow: .github/workflows/typescript-release.yml
    • Runs CI on pull requests and on pushes to main when TypeScript package files change.
    • Executes npm ci, npm test, and npm run build in packages/typescript-mdi-llmkit.
    • On push to main, publishes to npm only if package.json version changed and that version is not already published.
    • Uses repository secret NPM_TOKEN for npm authentication.