4 views

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★ 6,464+375 that day#9 on trending

Analyzed November 11, 2026 at e3220ad (master) with jscpd v5 in 4.4s. Code duplication went from 2.74% on Nov 8 to 2.73% on Nov 11.

D46.6/100
Project health603,180 lines of code (L)
Duplication26
16.4% in typescript, javascript, python, powershell, bash, docker
Dead code89
1.2%
Complexity43
61.3%

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.73%duplicated code · 5,787 of 212,240 lines
462clones in code
463code files of 2,173 scanned
16.04%duplicated over all files · 8,437 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

  • 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 atomically
    
    211if (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 tokens
    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
Largest clones over all files, tests and data included
By format, code only
FormatFilesLinesClonesDuplicated linesDuplication
typescript424202,0994515,6362.79%
javascript347,726111511.95%
python22,165000%
powershell2217000%
bash133000%
By format, all files
FormatFilesLinesClonesDuplicated linesDuplication
typescript1,814592,3908,24098,44216.62%
json357,261902,96840.88%
yaml427,827417799.95%
javascript408,610253073.57%
markup301,6611927816.74%
markdown17823,791154641.95%
txt4243411346.5%
bash1335038925.43%
python22,165000%
css1281000%

Trending appearances

DayRankStarsFilesLinesClonesAll filesCodeHealthCommit
Nov 11, 2026#96,464 (+375)2,173644,9168,43716.04%2.73%D 46.6e3220ad
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.