ranxianglei/billion-context
A context-compression plugin for month-long single sessions (billions of tokens) ,small context windows (a 100K context is enough) and token savings (5x fewer tokens) .上下文压缩插件,月级长会话会话, 兼顾小窗口(100k上下文足矣)省token(省5倍token) . billion-context is all you need
The score is jscpd's own --health model: markup, data and text left out, tests kept. The numbers below are the trending scan's.
Most complex files
- src/launcher.ts1987 cx
- src/plugin.ts1935 cx
- verif/symbolic.ts1779 cx
- tests/launcher.test.ts1535 cx
- src/server.ts1028 cx
- src/persist.ts1008 cx
- src/preflight.ts970 cx
- src/plugin-install.ts949 cx
- src/server/handle.ts914 cx
- src/config.ts888 cx
Dead code 1.2% unused · 382 findings
- verif/symbolic.tsunused-file
- verif/subset-guard.tsunused-file
- verif/terms.tsunused-file
- scripts/update-storage-corpus.tsunused-file
- src/persona-anchor.tsunused-file
- verif/solve.tsunused-file
- kernel/src/search/algorithms/semantic.tsunused-file
- verif/exceptions.tsunused-file
- scripts/check-dist-external-zod.mjsunused-file
- verif/drivers/responses-ingress-driver.tsunused-file
The code number leaves out tests, fixtures, docs, examples, data files, styles, translations and vendored code, and 2 generated files: src/web/favicon.ts, src/zcode/json-edit.ts.
Largest clones in the code
- 66 lines in 2 placestypescript579 tokens
202const turn = core.processTurn({ messages: renderMsgs, state: session.state, config: loopConfig, tokenCount, tokenCountSource, renderTags: renderStrategy, conte… 203session.state = turn.state; 204adoptContentStore(session, turn.contentStore); 205// #4528: split the kernel pass from its post-processing scan passes so 206// each is a bounded synchronous stretch rather than one long block. 207await yieldToEventLoop(); 208// The fold from last turn's compress has now materialized in state — 209// future usage reports are post-fold reality, drop the credit. 210session.stats.compressCreditTokens = 0; 211if (foldCoveredBefore !== null && !isTitleGen && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) {First 10 of 66 lines.
- 60 lines in 2 placestypescript528 tokens
372if (foldCoveredBefore !== null && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) { 373 const gap = foldCoverage(foldCoveredBefore, msgs.map((m) => m.id)); 374 if (gap) log("warn", `[${sessionId}] [acp-drift] fold coverage mismatch: ${gap.matched}/${gap.expected} covered message id(s) present in resent history — $… 375} 376storeEffectiveAbsorb(session, loopConfig); 377storeEffectiveRules(session, config); 378turn.messages = applyAbsorbView(turn.messages, session.state, loopConfig, tokenCount); 379turn.messages = attachSubagentSessions(turn.messages, session); 380// Drop sub-viability fragments before any consumer sees them: a tiny 381// range in the list makes batched compress attempts fail atomically211if (foldCoveredBefore !== null && !isTitleGen && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) { 212 const gap = foldCoverage(foldCoveredBefore, msgs.map((m) => m.id)); 213 if (gap) log("warn", `[${sessionId}] [acp-drift] fold coverage mismatch: ${gap.matched}/${gap.expected} covered message id(s) present in resent history — $… 214} 215storeEffectiveAbsorb(session, loopConfig); 216storeEffectiveRules(session, config); 217turn.messages = applyAbsorbView(turn.messages, session.state, loopConfig, tokenCount); 218turn.messages = attachSubagentSessions(turn.messages, session); 219// #3204: also drop DEAD-ref-bracketing spans at this single point so 220// every downstream consumer (decision prompt + directive, prose nudge,First 10 of 60 lines, the second copy on the right.
- 9 lines in 5 placestypescript77 tokenssrc/server/admin.ts:816–824src/server/admin.ts:851–859src/server/admin.ts:864–872src/server/admin.ts:875–883src/server/admin.ts:888–902
816 handlePluginRegister(body.toString("utf8"), res); 817 return; 818 } catch (err) { 819 res.writeHead(err instanceof BodyTooLargeError ? 413 : 400, { "content-type": "application/json" }); 820 res.end(JSON.stringify({ ok: false, error: String(err) })); 821 return; 822 } 823} 824if (req.method === "POST" && req.url === "/__bili/agent-providers") {851 handlePluginRuntimeInfo(body.toString("utf8"), res); 852 return; 853 } catch (err) { 854 res.writeHead(err instanceof BodyTooLargeError ? 413 : 400, { "content-type": "application/json" }); 855 res.end(JSON.stringify({ ok: false, error: String(err) })); 856 return; 857 } 858} 859if (req.method === "POST" && req.url === "/__bili/plugin/attribution") {
7 more
- 30 lines in 2 placestypescript300 tokens
- 28 lines in 3 placestypescript150 tokens
- 38 lines in 2 placestypescript299 tokens
- 22 lines in 2 placestypescript293 tokens
- 14 lines in 3 placestypescript134 tokens
- 40 lines in 2 placestypescript267 tokens
- 38 lines in 2 placestypescript266 tokens
Largest clones over all files, tests and data included
- 12 lines in 25 placestypescripttests118 tokenstests/acp-status-estimator.test.ts:9–20tests/anthropic-round2-thinking-hold.test.ts:68–79tests/compress-credit.test.ts:21–32tests/compress-fingerprint-refold.test.ts:25–36tests/compress-observability.test.ts:22–33and 20 more
9id: `test-${Math.random().toString(36).slice(2)}`, 10meta: {}, 11stats: { requests: 0, tokensSaved: 0, inputTokens: 0, cachedTokens: 0, outputTokens: 0, cacheSamples: 0, lastInputTokens: 0, compressCreditTokens: 0, contextTo… 12metadata: {}, 13state: createInitialState(), 14createdAt: Date.now(), 15lastSeen: Date.now(), 16blockContents: new Map(), 17inFlight: 0, 18persisted: false,First 10 of 12 lines.
- 10 lines in 53 placestypescripttests51 tokenstests/compaction-trigger-finality.test.ts:137–146tests/e2e-issue3450-stated-counts.test.ts:167–176tests/e2e-issue3450-stated-counts.test.ts:246–255tests/e2e-issue3900-overflow-teaches.test.ts:135–144tests/e2e-issue3900-overflow-teaches.test.ts:180–189and 48 more
137 assert.ok(bodies[bodies.length - 1].includes("Context limit reached"), "nudge still injected on a normal request"); 138 } finally { 139 proxy.close(); 140 proxy.closeIdleConnections?.(); 141 await once(proxy, "close"); 142 upstream.close(); 143 upstream.closeIdleConnections?.(); 144 await once(upstream, "close"); 145 } 146}); - 169 lines in 2 placesmarkdowndocs and examples2,501 tokens
1903| Env var | Config key | Default | 1904|---------|------------|--------| 1905| `` | `pi.commands` | ["acp", "acp-cache"] | 1906| `ACP_AUTO_RESTART_ON_UPDATE` | `autoRestartOnUpdate` | false | 1907| `ACP_AUTO_UPDATE` | `autoUpdate` | true | 1908| `ACP_COMPRESS_NUDGE` | `compress.injectNudge` | true | 1909| `ACP_COMPRESS_PROTOCOL` | `diagnostics.compressProtocol` | "tools" | 1910| `ACP_COMPRESS_TOOL` | `compress.injectTool` | true | 1911| `ACP_COUNT_TOKENS_PASSTHROUGH` | `diagnostics.countTokensPassthrough` | false | 1912| `ACP_DEBUG` | `debug` | false |First 10 of 169 lines.
- 34 lines in 10 placesyamldata files265 tokens
- 48 lines in 3 placestxttests1,114 tokens
By format, code only
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| typescript | 424 | 202,099 | 451 | 5,636 | 2.79% |
| javascript | 34 | 7,726 | 11 | 151 | 1.95% |
| python | 2 | 2,165 | 0 | 0 | 0% |
| powershell | 2 | 217 | 0 | 0 | 0% |
| bash | 1 | 33 | 0 | 0 | 0% |
By format, all files
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| typescript | 1,814 | 592,390 | 8,240 | 98,442 | 16.62% |
| json | 35 | 7,261 | 90 | 2,968 | 40.88% |
| yaml | 42 | 7,827 | 41 | 779 | 9.95% |
| javascript | 40 | 8,610 | 25 | 307 | 3.57% |
| markup | 30 | 1,661 | 19 | 278 | 16.74% |
| markdown | 178 | 23,791 | 15 | 464 | 1.95% |
| txt | 4 | 243 | 4 | 113 | 46.5% |
| bash | 13 | 350 | 3 | 89 | 25.43% |
| python | 2 | 2,165 | 0 | 0 | 0% |
| css | 1 | 281 | 0 | 0 | 0% |
Trending appearances
| Day | Rank | Stars | Files | Lines | Clones | All files | Code | Health | Commit |
|---|---|---|---|---|---|---|---|---|---|
| Nov 11, 2026 | #9 | 6,464 (+375) | 2,173 | 644,916 | 8,437 | 16.04% | 2.73% | D 46.6 | e3220ad |
| Nov 8, 2026 | #9 | 4,694 (+191) | 2,052 | 618,491 | 8,152 | 16.18% | 2.74% | D 46.3 | 354e21e |
Want this for your own project? Install jscpd and run jscpd ., or measure it the way the baselines were measured.