New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@codragraph/compress

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codragraph/compress

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

latest
Source
npmnpm
Version
2.2.0
Version published
Weekly downloads
5
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

@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

ExportPurpose
LlmCompressorLLM-backed compressor/decompressor.
compressContextPackCompress a FeatureCluster context pack as outline or JSON.
estimateTokensLightweight character-based token estimate.
CompressorInterface for custom compressors.
CompressOptionsInference provider, model, level, strategy, similarity options.
CompressContextPackOptionsCompressOptions plus `format: "outline"

Package Composition

Pair withWhy
@codragraph/cliProduces the indexed graph and FeatureCluster packs.
@codragraph/sdkLoads context packs programmatically.
@codragraph/harnessSupplies 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.

Keywords

codragraph

FAQs

Package last updated on 14 Jun 2026

Related posts