Skip to content

Repository files navigation

context-compactor

Cloudflare Worker that compresses long text to fit memory limits — no external API calls required.

What This Gives You

  • Extractive summarization — scores sentences by word frequency, keeps the most informative ones
  • Sliding window compression — chunks text into summary segments with configurable window size
  • Keyphrase extraction — pulls top bigrams as a compact representation
  • Zero dependencies — runs entirely on-Worker, no LLM or third-party API
  • KV-cached results — SHA-256 keyed cache with 24-hour TTL

Quick Start

# Deploy to Cloudflare Workers
wrangler deploy
# Compress text via API
curl -X POST https://context-compactor.<your-subdomain>.workers.dev/api/compact \
-H "Content-Type: application/json" \
-d '{"text": "Your long text here...", "strategy": "extractive", "ratio": 0.3}'

Strategies

StrategyDescriptionBest for
extractiveTop-N sentences by TF scoringGeneral compression
slidingWindowed chunk summariesVery long documents
keyphraseTop bigrams as keyphrasesKeyword extraction

Response

{
"compacted": "Compressed text...",
"strategy": "extractive",
"inputLength": 5000,
"outputLength": 1500,
"compressionRatio": 0.3
}

How It Fits

A Cocapn Fleet vessel. Part of the SuperInstance ecosystem for distributed AI operations.

Related repos:

License

Apache 2.0

About

Text compression utility for fleet vessels — no external API calls

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages