@unveil/compactor
v1.0.0
Published
Convert GitHub events into a compact strings optimized for LLM efficiency
Readme
compactor
Convert GitHub events into a compact strings optimized for LLM efficiency
Install
npm install @unveil/compactorUsage
import { compactor } from "@unveil/compactor";
const user = {}; // <-- `https://api.github.com/users/${username}`
const events = []; // <-- `https://api.github.com/users/${username}/events?per_page=100`
const jsonData = JSON.stringify({ events, user }, null, 2);
compactor(jsonData);Example
This is an example of 2000 lines of JSON that needs to be analyzed by the LLM.
Costs more of less 12267 tokens.
{
"user": {
"login": "joannwalsh",
"created_at": "2023-03-09T17:44:40Z",
"public_repos": 134
},
"events": [
{
"type": "PullRequestEvent",
"created_at": "2026-03-18T19:18:17Z",
"repo": {
"name": "repo-1"
},
"payload": {
"action": "merged"
}
},
{
"type": "DeleteEvent",
"created_at": "2026-03-16T18:24:34Z",
"repo": {
"name": "repo-2"
},
"payload": {
"ref_type": "branch"
}
},
...(1000+ more lines of JSON)
}
This is that same 2000 lines of JSON compressed in a format that LLM will still understand.
Costs more of less 425 tokens.
u:joannwalsh|j:2023-03-09|r:134
ev:
PR>repo-1@0318
D>repo-2@0316x2,repo-5@0315
DISC>repo-3@0310x3+0309,repo-1@0313x7
PUSH>repo-4@0315,repo-29@0313x2,repo-31@0313x3,repo-34@0313x2,repo-39@0313x5,repo-36@0313,repo-2@0313
IC>repo-6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27@0314|repo-32@0313x30,repo-1@0313x2
PRO>repo-28@0313x6,repo-32@0313x11,repo-33@0313x3,repo-35@0313x3,repo-37@0313x2,repo-30@0313x2,repo-1@0313x3
PRC>repo-33@0313x2,repo-35@0313,repo-32@0313x9
IO>repo-32@0313x15,repo-1@0313x7
IEC>repo-32@0313x11,repo-1@0313
F>repo-37,33,30,28,35,32@0313
PRV>repo-30@0313x2
B>repo-29@0313x4,repo-2@0313x2,repo-31@0313x9,repo-34@0313x3,repo-36@0313x3,repo-39@0313,repo-40@0313x3Issues and features requests
Please drop an issue, if you find something that doesn't work, or have an idea for something that works better.
