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.ts1865 cx
- src/plugin.ts1850 cx
- verif/symbolic.ts1779 cx
- tests/launcher.test.ts1533 cx
- src/server.ts1025 cx
- src/persist.ts998 cx
- src/preflight.ts950 cx
- src/plugin-install.ts940 cx
- src/config.ts879 cx
- src/server/handle.ts869 cx
Dead code 1.25% unused · 376 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
- 64 lines in 2 placestypescript534 tokens
205const turn = core.processTurn({ messages: renderMsgs, state: session.state, config: loopConfig, tokenCount, tokenCountSource, renderTags: renderStrategy, conte… 206session.state = turn.state; 207adoptContentStore(session, turn.contentStore); 208// #4528: split the kernel pass from its post-processing scan passes so 209// each is a bounded synchronous stretch rather than one long block. 210await yieldToEventLoop(); 211// The fold from last turn's compress has now materialized in state — 212// future usage reports are post-fold reality, drop the credit. 213session.stats.compressCreditTokens = 0; 214if (foldCoveredBefore !== null && !isTitleGen && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) {First 10 of 64 lines.
- 58 lines in 2 placestypescript483 tokens
375if (foldCoveredBefore !== null && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) { 376 const gap = foldCoverage(foldCoveredBefore, msgs.map((m) => m.id)); 377 if (gap) log("warn", `[${sessionId}] [acp-drift] fold coverage mismatch: ${gap.matched}/${gap.expected} covered message id(s) present in resent history — $… 378} 379storeEffectiveAbsorb(session, loopConfig); 380storeEffectiveRules(session, config); 381turn.messages = applyAbsorbView(turn.messages, session.state, loopConfig, tokenCount); 382turn.messages = attachSubagentSessions(turn.messages, session); 383// Drop sub-viability fragments before any consumer sees them: a tiny 384// range in the list makes batched compress attempts fail atomically214if (foldCoveredBefore !== null && !isTitleGen && msgs.length >= REWRITE_MIN_INCOMING_TOTAL) { 215 const gap = foldCoverage(foldCoveredBefore, msgs.map((m) => m.id)); 216 if (gap) log("warn", `[${sessionId}] [acp-drift] fold coverage mismatch: ${gap.matched}/${gap.expected} covered message id(s) present in resent history — $… 217} 218storeEffectiveAbsorb(session, loopConfig); 219storeEffectiveRules(session, config); 220turn.messages = applyAbsorbView(turn.messages, session.state, loopConfig, tokenCount); 221turn.messages = attachSubagentSessions(turn.messages, session); 222// #3204: also drop DEAD-ref-bracketing spans at this single point so 223// every downstream consumer (decision prompt + directive, prose nudge,First 10 of 58 lines, the second copy on the right.
- 9 lines in 5 placestypescript77 tokenssrc/server/admin.ts:811–819src/server/admin.ts:846–854src/server/admin.ts:859–867src/server/admin.ts:870–878src/server/admin.ts:883–897
811 handlePluginRegister(body.toString("utf8"), res); 812 return; 813 } catch (err) { 814 res.writeHead(err instanceof BodyTooLargeError ? 413 : 400, { "content-type": "application/json" }); 815 res.end(JSON.stringify({ ok: false, error: String(err) })); 816 return; 817 } 818} 819if (req.method === "POST" && req.url === "/__bili/agent-providers") {846 handlePluginRuntimeInfo(body.toString("utf8"), res); 847 return; 848 } catch (err) { 849 res.writeHead(err instanceof BodyTooLargeError ? 413 : 400, { "content-type": "application/json" }); 850 res.end(JSON.stringify({ ok: false, error: String(err) })); 851 return; 852 } 853} 854if (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
- 40 lines in 2 placestypescript267 tokens
- 38 lines in 2 placestypescript266 tokens
- 31 lines in 2 placestypescript266 tokens
Largest clones over all files, tests and data included
- 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:127–136tests/e2e-issue3900-overflow-teaches.test.ts:172–181and 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}); - 12 lines in 23 placestypescripttests118 tokenstests/acp-status-estimator.test.ts:9–20tests/compress-credit.test.ts:21–32tests/compress-fingerprint-refold.test.ts:25–36tests/compress-observability.test.ts:22–33tests/compress-reject-reasons.test.ts:19–30and 18 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.
- 164 lines in 2 placesmarkdowndocs and examples2,413 tokens
1845| Env var | Config key | Default | 1846|---------|------------|--------| 1847| `ACP_AUTO_RESTART_ON_UPDATE` | `autoRestartOnUpdate` | false | 1848| `ACP_AUTO_UPDATE` | `autoUpdate` | true | 1849| `ACP_COMPRESS_NUDGE` | `compress.injectNudge` | true | 1850| `ACP_COMPRESS_PROTOCOL` | `diagnostics.compressProtocol` | "tools" | 1851| `ACP_COMPRESS_TOOL` | `compress.injectTool` | true | 1852| `ACP_COUNT_TOKENS_PASSTHROUGH` | `diagnostics.countTokensPassthrough` | false | 1853| `ACP_DEBUG` | `debug` | false | 1854| `ACP_DUMP_BODY` | `diagnostics.dumpBody` | false |First 10 of 164 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 | 411 | 193,682 | 434 | 5,435 | 2.81% |
| javascript | 33 | 7,555 | 11 | 151 | 2% |
| python | 2 | 2,143 | 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,737 | 569,062 | 7,969 | 95,354 | 16.76% |
| json | 34 | 7,234 | 90 | 2,968 | 41.03% |
| yaml | 42 | 7,741 | 38 | 752 | 9.71% |
| javascript | 39 | 8,411 | 25 | 304 | 3.61% |
| markdown | 153 | 21,689 | 13 | 406 | 1.87% |
| markup | 14 | 1,068 | 11 | 174 | 16.29% |
| txt | 4 | 243 | 4 | 113 | 46.5% |
| bash | 12 | 282 | 2 | 21 | 7.45% |
| python | 2 | 2,143 | 0 | 0 | 0% |
| css | 1 | 281 | 0 | 0 | 0% |
Trending appearances
| Day | Rank | Stars | Files | Lines | Clones | All files | Code | Health | Commit |
|---|---|---|---|---|---|---|---|---|---|
| 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.