Skip to content

SuperInstance/context-compactor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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

Strategy Description Best for
extractive Top-N sentences by TF scoring General compression
sliding Windowed chunk summaries Very long documents
keyphrase Top bigrams as keyphrases Keyword 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

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%