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

iterai

v0.2.0

Published

A local-first, graph-based LLM refinement engine with transparent planning, diff-based evolution, and multi-model synthesis.

Readme

IterAI (TypeScript/JavaScript)

A local-first, graph-based LLM refinement engine with transparent planning, diff-based evolution, and multi-model synthesis.

This is the TypeScript/JavaScript port of the IterAI Python library.

Features

  • 🌳 DAG-based refinement: Create, refine, and synthesize LLM outputs in a directed acyclic graph
  • 📋 Transparent planning: Every node generates a structured List<Step> plan before output
  • 🔄 Diff tracking: Automatic diff generation between parent and child nodes
  • 🔀 Multi-model synthesis: Combine outputs from different models or refinement strategies
  • 💾 Local-first storage: Uses browser localStorage (or in-memory fallback)
  • 🔌 Browser & Node.js: Works in both environments

Installation

npm install iterai
# or
yarn add iterai
# or
pnpm add iterai

Quick Start

import { IterAI } from "iterai";

// Initialize with your OpenAI API key
const iterai = new IterAI(undefined, "your-openai-api-key");

// Create a root node
const root = await iterai.createRoot(
  "Write a technical blog post about async programming",
  "gpt-4o-mini"
);

console.log("Plan:", root.plan); // List of Step objects
console.log("Output:", root.output);

// Refine the output
const refined = await iterai.refine(
  root,
  "gpt-4o",
  "Make this more concise and punchy"
);

console.log("Diff:", refined.diff);

// Create alternative refinement
const altRefined = await iterai.refine(
  root,
  "gpt-4o",
  "Make this more technical and detailed"
);

// Synthesize both refinements
const synthesized = await iterai.synthesize(
  [refined, altRefined],
  "gpt-4o",
  "Combine clarity from first with depth from second"
);

// Evaluate all nodes
await iterai.evaluateAll([root, refined, altRefined, synthesized]);

console.log("Scores:", {
  root: root.score,
  refined: refined.score,
  altRefined: altRefined.score,
  synthesized: synthesized.score,
});

Core Concepts

Node

A node represents a single LLM generation with:

  • plan: Step[] - Structured steps the LLM plans to take
  • output: string - The actual generated content
  • diff: string - Unified diff from parent(s)
  • score: number | null - Optional quality score

Step

A single step in a plan:

class Step {
  order: number;
  text: string;
}

DAG (Directed Acyclic Graph)

Manages the graph of nodes and their relationships:

  • Tracks parent-child relationships
  • Computes diffs automatically
  • Persists to storage

IterAI

Main API for creating and managing iterative workflows:

  • createRoot() - Create initial node
  • refine() - Create refinement of a node
  • synthesize() - Merge multiple nodes
  • evaluateAll() - Score nodes with LLM

Configuration

import { Config, setGlobalConfig } from "iterai";

const config = new Config({
  models: {
    default: "gpt-4o",
  },
  storage: {
    path: "my-project-storage",
  },
  api: {
    openai_key: "your-key-here",
    base_url: "https://api.openai.com/v1",
  },
});

setGlobalConfig(config);

Plan Comparison

// Simple text-based diff
const diff = node1.diffPlan(node2, "simple");

// LLM-based semantic comparison
const semanticDiff = await node1.diffPlanAsync(node2, "llm");

Storage

The library uses browser localStorage by default. In Node.js or when localStorage is unavailable, it falls back to in-memory storage.

// Custom storage path
const iterai = new IterAI("my-custom-storage");

// Access storage directly
iterai.dag.storage.saveNode(node.id, node.toDict());
const loadedNode = iterai.dag.storage.loadNode(node.id);

Browser Extension Usage

Perfect for Chrome/Firefox extensions:

// background.ts
import { IterAI } from "iterai";

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  if (request.action === "refine") {
    const iterai = new IterAI(undefined, request.apiKey);
    iterai.createRoot(request.prompt).then((node) => {
      sendResponse({ node: node.toDict() });
    });
    return true;
  }
});

API Compatibility

This library uses OpenAI-compatible APIs. You can use it with:

  • OpenAI (GPT-4, GPT-4o, etc.)
  • Anthropic (via proxy)
  • Local models (via LM Studio, Ollama, etc.)

Just set the baseUrl in config or constructor.

License

MIT

Related