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

@codragraph/compress

v2.2.0

Published

Lossless semantic compression for LLM contexts — strip grammar, keep facts, save tokens.

Downloads

1,097

Readme

@codragraph/compress

Lossless semantic compression for LLM context, including CodraGraph FeatureCluster context packs.

Use this package when the agent already has the right context pack but the pack is too large for a prompt budget. @codragraph/compress keeps the facts that matter for editing code: files, line ranges, symbols, routes, tools, processes, dependencies, tests, docs, and safe-edit warnings.

Install

npm install @codragraph/compress

Basic Usage

import { LlmCompressor, compressContextPack } from "@codragraph/compress";
import { harness, graph } from "@codragraph/sdk";

const inference = await harness.makeInferenceProvider("openai");
const graphClient = await graph.createLocalGraphClient();
const settingsPack = await graphClient.contextPack({ name: "Settings" });

const compressor = new LlmCompressor();
const compressed = await compressContextPack(compressor, settingsPack, {
  inference,
  level: "balanced",
  format: "outline",
});

console.log(compressed.clusterName);
console.log(compressed.reduction);
console.log(compressed.compressed);

What It Compresses

flowchart LR
    Pack["FeatureCluster context pack"] --> Outline["Stable outline or JSON"]
    Outline --> LLM["LlmCompressor"]
    LLM --> Prompt["Smaller agent prompt"]

compressContextPack accepts a ClusterContextPack from @codragraph/shared or any compatible object. The helper first serializes the pack deterministically, then passes it to a Compressor.

Public API

| Export | Purpose | |---|---| | LlmCompressor | LLM-backed compressor/decompressor. | | compressContextPack | Compress a FeatureCluster context pack as outline or JSON. | | estimateTokens | Lightweight character-based token estimate. | | Compressor | Interface for custom compressors. | | CompressOptions | Inference provider, model, level, strategy, similarity options. | | CompressContextPackOptions | CompressOptions plus format: "outline" | "json". |

Package Composition

| Pair with | Why | |---|---| | @codragraph/cli | Produces the indexed graph and FeatureCluster packs. | | @codragraph/sdk | Loads context packs programmatically. | | @codragraph/harness | Supplies inference providers and can use compressed packs in tuned recipes. |

Notes

  • This is prompt/context compression, not storage compression. Storage compression is the CLI flag codragraph analyze --compress brotli|zstd.
  • The package is TypeScript/Node-first. Older Python experiments live outside the public npm surface.

License

Apache-2.0. You can use, modify, redistribute, bundle, and host this package commercially, subject to the Apache-2.0 notice and attribution requirements.