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

TypeScript★ 4,694+191 that day#9 on trending

Analyzed November 8, 2026 at 354e21e (master) with jscpd v5 in 4.3s.

D46.3/100
Project health579,631 lines of code (L)
Duplication26
16.5% in typescript, javascript, python, powershell, bash, docker
Dead code89
1.2%
Complexity43
61.4%

The score is jscpd's own --health model: markup, data and text left out, tests kept. The numbers below are the trending scan's.

2.74%duplicated code · 5,586 of 203,630 lines
445clones in code
449code files of 2,052 scanned
16.18%duplicated over all files · 8,152 clones

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 atomically
    
    214if (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 tokens
    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
Largest clones over all files, tests and data included
By format, code only
FormatFilesLinesClonesDuplicated linesDuplication
typescript411193,6824345,4352.81%
javascript337,555111512%
python22,143000%
powershell2217000%
bash133000%
By format, all files
FormatFilesLinesClonesDuplicated linesDuplication
typescript1,737569,0627,96995,35416.76%
json347,234902,96841.03%
yaml427,741387529.71%
javascript398,411253043.61%
markdown15321,689134061.87%
markup141,0681117416.29%
txt4243411346.5%
bash122822217.45%
python22,143000%
css1281000%

Trending appearances

DayRankStarsFilesLinesClonesAll filesCodeHealthCommit
Nov 8, 2026#94,694 (+191)2,052618,4918,15216.18%2.74%D 46.3354e21e

Want this for your own project? Install jscpd and run jscpd ., or measure it the way the baselines were measured.