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

fast-jev-compaction

v0.4.1

Published

Continuous, verbatim context compaction for LLM agents using TypeSafe's Jev model.

Readme

License: MIT npm Fork of tamaratran/fast-jev-compaction no TypeSafe key

fast-jev-compaction

Claude Code plugin that replaces the compaction summary with Jev decisions: every tool call and result is scored in one fast request, stale ones are dropped or truncated, everything kept stays verbatim. Also usable as an npm library.

Tool suite (this repo + two companion packages)

| CLI | Package | Purpose | |---|---|---| | jev-compact / jev-gate | fast-jev-compaction (here) | Verbatim context compaction / dangerous-command gate | | jev-qa, jev-find | fast-jev-compaction (here) | Fast repo QA scan / semantic file search | | jev-enhance | jev-prompt-enhancer | Prompt refinement for vague/voice-transcribed input | | jev-skill-router | jev-skill-router | Route a request to the right tool/skill |

Install for any agent (one command)

npx jev-setup <claude|opencode|codex|hermes|generic>

Installs all CLIs globally and wires the chosen agent: Claude Code (plugin marketplace), OpenCode (session hook), Codex (AGENTS.md), Hermes (plugin), or a generic AGENTS.md. Requires only OPENROUTER_API_KEY.

Agent-friendly: give your agent this repo link — it reads SKILL.md and installs everything itself:

"Install Jev tools from https://github.com/aleksvega/fast-jev-compaction"

Fork additions: jev-compact + jev-gate (OpenRouter, no TypeSafe key)

This fork (github.com/aleksvega) adds two small CLI tools in cli/ that run Jev through OpenRouter's /api/alpha/decisions (model typesafe/jev-1.13), so only an OPENROUTER_API_KEY is required — no TypeSafe API key. The upstream library and Claude Code plugin below are unchanged; to point them at OpenRouter instead, set baseUrl (library option) or TYPESAFE_BASE_URL + TYPESAFE_MODEL=typesafe/jev-1.13.

Setup

npm install && npm run build
export OPENROUTER_API_KEY="sk-or-..."   # your key; never commit it

jev-compact — verbatim session compaction

node cli/jev-compact.mjs transcript.json -o dump.md

Input: a JSON array of {role, text, toolUses, toolResults}. One batched Jev request decides, per tool call, whether the call and/or its result must stay verbatim; the rest is dropped. Typical run: 62→6 messages, 41K→4.6K chars, ~$0.00002, output begins with a stats line.

jev-gate — confidence-gated pre-push guardrail

python cli/jev-gate.py /path/to/repo              # exit 0 = ALLOW, 1 = BLOCK
python cli/jev-gate.py /path/to/repo --threshold 0.9

One batched call (3 Noul + 1 Score over the last commit's diff): hardcoded secrets, syntax errors, breaking changes, test-failure risk. Blocks at probability ≥ threshold (default 0.85) or score ≥ 3; an API failure also blocks (fail-safe). ~400 ms, ~$0.00005. Verified: clean diff → ALLOW; diff containing an sk-... key → BLOCK at p=0.99.

MIT, upstream credit: tamaratran/fast-jev-compaction.

What and why

Most context compaction asks an LLM to summarize old turns. A summary is lossy: a file path, exact error, constraint, or command can disappear even when it matters later. This library never rewrites anything. It only deletes tool calls and tool results Jev says are no longer needed, and it asks Jev while showing it the whole conversation. User and assistant text stays verbatim and in order.

The repository is both an npm package (src/) and a Claude Code plugin (hooks/, .claude-plugin/) that uses the package to replace Claude Code's built-in compaction summary with the original messages.

How it works

  1. Every tool_use is paired with its tool_result by tool_use_id. Calls in the first message or in the newest preserveRecentMessages messages are pinned and never touched.
  2. The state sent to Jev is the whole conversation so far, oldest first, with every tool result replaced by a short note (ok, 4213 chars (omitted)). Tool inputs are included, texts are included, nothing is summarized.
  3. The state is fitted into maxStateTokens (25k by default) in stages, each applied only if the previous one was not enough: tool inputs truncated to 1000, then 200, then 60 characters; long texts abridged to head + tail, oldest non-pinned messages first; old non-pinned messages collapsed to a [… N chars omitted …] note; old tool calls reduced to one line each (t12 Read file_path=src/a.ts → ok 480ch); old call-less messages left out; runs of old call-only messages folded into one entry. If it still does not fit, compaction throws. Tokens are estimated without a tokenizer (a word per six letters, half a token per digit, ~one per other symbol), calibrated to land a little above the counts Jev reports.
  4. For every non-pinned call Jev gets two noul questions: should the call stay (knowing it was made, with its input, still matters), and should the result stay verbatim (its contents are still needed and re-running the tool would not do).
  5. Questions are split into as many requests as needed so state plus questions stays under maxRequestTokens (30k by default, under Jev's 32k request limit). The same full state is resent with every request; requests run concurrently and their answers are merged.
  6. Decisions per call, against keepThreshold:
    • keepResult ≥ threshold → keep call and result;
    • else keepCall ≥ threshold → keep the call, truncate the result to its first truncateHeadChars characters plus a one-line note;
    • else → remove the call together with its result.
  7. The message list is rebuilt: a message that loses all its content is removed, untouched messages are returned as the same objects, and no result is ever left without its call.

Jev failures, malformed answers, a missing key, or a history that cannot be fitted throw; the caller (or the Claude Code hook) decides what to fall back to.

hermes-compact - OpenAI-chat transcripts (Hermes-compatible)

npm install -g jev-compact
OPENROUTER_API_KEY=... hermes-compact transcript.json -o compacted.json

Input: JSON array / {"messages":[...]} / JSONL of OpenAI-chat messages (string or array content, nested or flat tool_calls). Output: compacted transcript JSON with verbatim kept messages and stats. Adapter semantics ported from deadczarvc/hermes-jev-compaction (MIT) - thanks! Difference: this build needs no TypeSafe key (OpenRouter backend).

Install and usage (upstream — TypeSafe endpoint)

The upstream library targets the official TypeSafe API. This fork does not need a TypeSafe key: use the OpenRouter setup in the "Fork additions" section above (OPENROUTER_API_KEY only, model typesafe/jev-1.13:latest via https://openrouter.ai/api/alpha/decisions).

npm install fast-jev-compaction
export TYPESAFE_API_KEY=...   # only needed for the upstream/official endpoint
import { compactMessages, reductionRatio, type Message } from 'fast-jev-compaction';

const transcript: Message[] = [
  { role: 'user', text: 'Fix the failing test. Never edit src/generated.', toolUses: [] },
  {
    role: 'assistant',
    text: '',
    toolUses: [{ tool_use_id: 'toolu_1', tool: 'Read', input: { file_path: 'src/a.ts' } }],
  },
  { role: 'user', text: '', toolUses: [], toolResults: [{ tool_use_id: 'toolu_1', text: '…file…' }] },
  // …
];

const result = await compactMessages(transcript, { preserveRecentMessages: 4 });
console.log(result.messages, result.decisions, result.stats);
if (reductionRatio(result) < 0.25) {
  // not worth it: keep the original transcript, or summarize instead
}

Message is a subset of Claude Code's SessionMessage, so a session transcript can be passed in as is.

To bring your own transport, implement JevAsker (one ask(state, questions) method) and call compact(messages, asker, options); buildJevRequest and parseJevResponse give you the HTTP request body and response validation. The building blocks (collectToolCalls, fitState, batchCalls, decideCall, applyDecisions) are exported too.

apiKey defaults to process.env.TYPESAFE_API_KEY. Never commit the key or put it in a source file.

Options

| Option | Default | Description | | --- | --- | --- | | apiKey | TYPESAFE_API_KEY | TypeSafe API key (compactMessages/JevClient) | | model | jev-latest | Jev model name | | baseUrl | https://api.typesafe.ai/v1/systemone | System One endpoint | | fetch | native fetch | Injectable fetch implementation for tests | | goal | last 3 user prompts | Ongoing task description included in the state | | keepThreshold | 0.5 | Minimum keep probability for a call or result to stay | | preserveRecentMessages | 6 | Newest messages never touched (the first is always kept) | | maxStateTokens | 25000 | Estimated token ceiling for the state | | maxRequestTokens | 30000 | Estimated ceiling for state plus one batch of questions | | truncateHeadChars | 300 | Characters of a dropped tool result retained before its note |

result.stats reports message and character counts before and after, the per-reason decision counts, the state size in estimated tokens, which fitting stage was needed, and the number of requests.

Limitations

  • Only tool calls and results are candidates; text messages are never removed or shortened in the output (they are only abridged in the state Jev sees).
  • Token sizes are estimates from character counts, not a tokenizer.
  • Calibration is at the request level; a probability is not a proof that a result is safe to delete. The assistant can always re-run the tool.
  • The full state is repeated with every request, so a history near the state ceiling costs one request per handful of questions.

Claude Code plugin

The repository root is a Claude Code function-hook plugin: hooks/fast-jev.ts is a thin adapter that feeds session.compact transcripts through src/ and falls back to Claude Code's built-in summary on errors or insufficient reduction. See hooks/README.md for configuration and the Claude Code 2.1.274 type reference.

Install in Claude Code

Function hooks are an early-access Claude Code feature (2.1.274+), so the opt-in flag must be set wherever Claude Code runs, e.g. in ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1", "TYPESAFE_API_KEY": "<your key>" } }

Then add this repository as a plugin marketplace and install the plugin, either from the shell or as slash commands inside a session:

claude plugin marketplace add aleksvega/fast-jev-compaction
claude plugin install fast-jev-compaction@fast-jev-compaction

The install prompts for the plugin options (API key, thresholds, truncateHeadChars, …); leave them at their defaults to use TYPESAFE_API_KEY from the environment. Restart Claude Code or run /reload-plugins. From then on /compact (and auto-compaction) goes through Jev: the toast reads fast-jev-compaction: kept N/M messages, no summary (…) when the pruned history replaced the built-in summary, or fallback to built-in summary (…) when Jev could not remove enough (short sessions, or when it fails).

To run from a checkout without installing: CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude --plugin-dir . from the repository root. No publishing step is required; the marketplace is just the repo's .claude-plugin/marketplace.json.

Development

npm install
npm run typecheck        # library + hook
npm test
npm run build
npm run validate:plugin  # claude plugin validate
TYPESAFE_API_KEY="$(cat ~/.typesafe_key)" npm run demo

The unit tests use a fake Jev and never contact TypeSafe. The demo is the live network check.

Animated demo (macOS)

demo/JevDemo is a small native SwiftUI app that plays a scripted, dramatized version of the compaction flow inside a Claude Code-style terminal: the tool calls of a canned transcript are scored, results and calls Jev lets go turn red and collapse away, and the rest stays verbatim. It never calls the API; it exists to be screen recorded.

demo/JevDemo/build.sh   # builds demo/JevDemo/build/JevDemo.app and launches it

Press space in the app to replay from the start.

jev-qa — fast repo QA scan

Finds code errors in seconds: stage 1 — free syntax checks (py_compile / node --check), stage 2 — Jev semantic review per file (bugs, error-handling, security, logic — all questions in one batched request, parallel).

OPENROUTER_API_KEY=... jev-qa <repo> [--diff] [--out report.md] [--max N]

Measured on our test set: 15 files in 5.4 s, ~$0.001; a file with a planted bug scored has_bug 0.95 / logic 0.90 vs 0.2–0.6 for clean files.

jev-find — natural-language file search

Find code by meaning, not by name: a Jev walker ensemble walks the repo and reports where walkers landed.

jev-find "where is authentication handled?" ./src --walkers 20

Cheap (~$0.0005/search) and fast (~1-2 s on small repos). Pattern credit: ellipsis-dev/blink.