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

contextr

v1.0.17

Published

A lightweight library that packages your project's code files into structured context for LLMs. Enables single-shot code context generation and supports dynamic packaging for LLM agents.

Readme

Contextr

npm version Build Status License: MIT TypeScript

Contextr is a lightweight library that packages your project’s code files into structured context—ready to be consumed by Large Language Models (LLMs). It enables single-shot code context generation for LLM prompting and supports dynamic packaging for LLM agents that require iterative file submission.

🎯 Why We Built It: LLM Workflows Need Precision, Not Guesswork

Copilot, Replit, and other AI-assisted IDEs attempt to provide context, but they fall short in critical ways:

  • Limited & Unpredictable Context: They typically rely on open file editors or recent edits, meaning you don’t fully control what gets sent to the AI.
  • Potentially Leaking Sensitive Files: Without fine-grained selection, they may include files unintentionally, exposing sensitive or unnecessary data.
  • No Granular Control: Customizing context in each tool’s own way is inconsistent and time-consuming, making AI-driven development slower, not faster.

Why Contextr?

AI-assisted development needs a precise, structured way to send LLMs exactly what they need—nothing more, nothing less.

✅ Absolute Control Over Context: Hand-pick the exact files the AI sees, at the level of granularity of individual files.

✅ Works for Both Single-Shot & Automated Workflows: Whether working manually with LLMs or integrating AI-driven coding agents, pre-built context is faster and more reliable.

✅ Fits AI-Assisted Development Best Practices: Small files (under 200 lines, ideally 100) encourage modular design. This tool solves the problem of gathering multiple related files efficiently.

✅ Handles Distributed Code: Critical logic is often spread across shared/, providers/, schemas/, client/, and server/. This builder ensures you can package exactly what the AI needs for an end-to-end flow.

Build and send the precise LLM context you need, with full control, and stop relying on your IDE to do the guesswork.

🚀 Getting Started

1️⃣   Install the Library

You can install Contextr directly from GitHub:

yarn add contextr  

Or if you prefer npm:

npm i contextr

2️⃣   Define Your Context Configuration

Use a simple JSON-based config to select files for inclusion.

import {
  FileContextBuilder,
  FileCollectorConfig,
  ConsoleRenderer,
  JsonRenderer,
} from "contextr";

const config: FileCollectorConfig = {
  name: "MyProjectFileContext",
  showContents: true, // Include file contents
  showMeta: true,     // Include metadata (file paths, sizes, etc.)
  includeDirs: [
    {
      path: "./src",
      include: ["**/*.ts"], // Include all TypeScript files
      recursive: true,
    },
  ],
  includeFiles: ["README.md", "package.json"],
};

(async () => {
  const builder = new FileContextBuilder(config);
  const context = await builder.build();

  // Render as a console-friendly string
  const consoleRenderer = new ConsoleRenderer();
  console.log(consoleRenderer.render(context));

  // Render as a strongly-typed object literal.
  const jsonRenderer = new JsonRenderer();
  const output = jsonRenderer.render(context);
  console.log(output);
})();

🛠️ Extending the Output

Use Different Renderers

By default, two renderers are provided:

  • ConsoleRenderer → Outputs human-readable file trees and summaries.
  • JsonRenderer → Outputs structured JSON for LLM consumption.

You can create custom renderers by implementing the Renderer interface:

export interface Renderer<T = unknown> {
  render(context: FileContext): T;
}

🤝 Contributing

See CONTRIBUTING.md for details on how to submit issues, bug fixes, and new features.

🔏 Code of Conduct

See CODE_OF_CONDUCT.md for Code of Conduct.

Publishing

npm run test npm run release

📄 License

Contextr is licensed under the MIT License.