tokenskyline 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/template.html +40 -17
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Reads local logs from Claude Code, Codex, Gemini CLI / Antigravity, Hermes Agent
|
|
|
20
20
|
|
|
21
21
|
- **All tools stacked in one grid**: each day's cell is split by how much each tool used that day.
|
|
22
22
|
- **Each tool on its own row**, on the same timeline, so you can see when you switched tools.
|
|
23
|
-
- **3D skyline or flat grid**:
|
|
23
|
+
- **3D skyline or flat grid**: bars on a plinth, height = real usage. The view angle is picked to make the chart as large as your screen allows; drag to rotate and look behind tall bars, double-click to reset. Add `#flat` to the URL for the grid, where nothing hides anything.
|
|
24
24
|
- **Three measures**: total tokens, tokens without cache reads (cache reads are often 90%+ of the total), estimated cost in USD.
|
|
25
25
|
- **A local ledger** at `~/.tokenskyline/ledger.json`: every run saves each day's totals, so days stay counted after the tools delete their logs.
|
|
26
26
|
- **One file, about 50 KB**. Send it to anyone, open it on a phone.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenskyline",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Your year of AI coding as a 3D token skyline. One command reads local logs of Claude Code, Codex, Gemini/Antigravity, Hermes, Cursor, OpenCode and 60+ tools and writes a single HTML file: GitHub-style contribution graph, flat or 3D.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/template.html
CHANGED
|
@@ -36,7 +36,7 @@ h1,h2{font-family:var(--f-display);font-weight:700;margin:0;text-wrap:balance}
|
|
|
36
36
|
.heroR{flex:1 1 420px;min-width:0;display:grid;gap:10px;align-content:end}
|
|
37
37
|
.heroR .legend{margin-inline:-9px}
|
|
38
38
|
.chartbox{display:grid;grid-template-columns:minmax(0,1fr)}
|
|
39
|
-
.chartbox.side{grid-template-columns:minmax(
|
|
39
|
+
.chartbox.side{grid-template-columns:minmax(240px,270px) minmax(0,1fr);gap:8px;align-items:center}
|
|
40
40
|
.kpiOver .kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 18px}
|
|
41
41
|
.kpiOver .kpi b{font-size:18px}
|
|
42
42
|
.kpiOver .kpi .sub{font-size:10.5px}
|
|
@@ -76,7 +76,8 @@ button:focus-visible{outline:2px solid var(--hl);outline-offset:1px}
|
|
|
76
76
|
/* 主图 */
|
|
77
77
|
.main{display:grid;gap:10px}
|
|
78
78
|
.scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}
|
|
79
|
-
#cv3{display:block}
|
|
79
|
+
#cv3{display:block;cursor:grab;touch-action:pan-y}
|
|
80
|
+
#cv3:active{cursor:grabbing}
|
|
80
81
|
.scale{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);justify-content:flex-end}
|
|
81
82
|
.scale i{width:11px;height:11px;display:inline-block}
|
|
82
83
|
.note{font-size:12px;color:var(--muted)}
|
|
@@ -169,7 +170,7 @@ const L=ZH?{
|
|
|
169
170
|
gView:"视图", gMetric:"口径", gRange:"时间范围",
|
|
170
171
|
usd:"估算美元", none:"未选", estCost:"按官方价估算", perDay:"日均", cacheShare:"缓存读占", allTok:"全部 token",
|
|
171
172
|
days:n=>n+" 天", activeDays:"有用量的日子", since:d=>d+" 起有记录", streak:"最长连续", peak:"最猛一天", led:n=>n+"主导",
|
|
172
|
-
scale2d:"格内分段 = 各家当天占比 · 深浅按分位五档", cuts:"分界", scale3d:"柱高 = 当天真实用量 · 柱内分段 = 各家当天占比",
|
|
173
|
+
scale2d:"格内分段 = 各家当天占比 · 深浅按分位五档", cuts:"分界", scale3d:"拖动旋转 · 双击复位 · 柱高 = 当天真实用量 · 柱内分段 = 各家当天占比",
|
|
173
174
|
rowTip:n=>"点击:在图 1 里加上或去掉 "+n, more:n=>"+"+n+" 家", from:d=>d+" 起", main:"主力", total:"合计", noRec:"没有记录",
|
|
174
175
|
wd:["一","","三","","五","","日"], weekStart:1,
|
|
175
176
|
foot:(cover,gap)=>`
|
|
@@ -184,7 +185,7 @@ const L=ZH?{
|
|
|
184
185
|
gView:"View", gMetric:"Measure", gRange:"Range",
|
|
185
186
|
usd:"est. USD", none:"none", estCost:"at list prices", perDay:"per day", cacheShare:"cache reads", allTok:"all tokens",
|
|
186
187
|
days:n=>n+(n===1?" day":" days"), activeDays:"active days", since:d=>"since "+d, streak:"longest streak", peak:"busiest day", led:n=>"mostly "+n,
|
|
187
|
-
scale2d:"cell split = each tool's share that day · shade = quintile", cuts:"cuts", scale3d:"bar height = real usage that day · segments = each tool's share",
|
|
188
|
+
scale2d:"cell split = each tool's share that day · shade = quintile", cuts:"cuts", scale3d:"drag to rotate · double-click to reset · bar height = real usage that day · segments = each tool's share",
|
|
188
189
|
rowTip:n=>"Click to add or remove "+n+" in fig. 1", more:n=>"+"+n+" more", from:d=>"since "+d, main:"top model", total:"Total", noRec:"no usage",
|
|
189
190
|
wd:["","Mon","","Wed","","Fri",""], weekStart:0,
|
|
190
191
|
foot:(cover,gap)=>`
|
|
@@ -344,25 +345,34 @@ function gridSVG(svg,dates,set,opt){
|
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
// ---------- 立体(canvas 平行轴测) ----------
|
|
347
|
-
let hexes=[];
|
|
348
|
+
let hexes=[], lastAng={a:20,e:32};
|
|
348
349
|
function draw3D(dates){
|
|
349
350
|
const cv=$("cv3"), box=$("mainScroll");
|
|
350
351
|
const weeks=Math.ceil(dates.length/7);
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const W=Math.max(480,box.clientWidth), padL=40, padR=72;
|
|
354
|
-
let step=(W-padL-padR)/(weeks*uxW+7*Math.abs(uxD));
|
|
355
|
-
// 一屏放下:格子和柱高一起缩,直到整张图塞进"图顶到窗口底"的剩余高度
|
|
352
|
+
const W=Math.max(480,box.clientWidth), padL=40, padR=72, plDepth=6;
|
|
353
|
+
// 一屏放下:图顶到窗口底剩多高,整张图就只能多高
|
|
356
354
|
const top=box.getBoundingClientRect().top+scrollY;
|
|
357
355
|
const budget=Math.max(220,innerHeight-top-62);
|
|
358
|
-
const mhCap=Math.max(200,budget*.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
356
|
+
const mhCap=Math.max(200,budget*.5);
|
|
357
|
+
// 视角不写死:在一组好看的角度里挑格子最大的那个——周数少就转平、横着铺满宽度
|
|
358
|
+
// 拖动旋转时用拖到的角度;否则自动挑。俯视角下限抬到 28°,前排高柱少挡后排
|
|
359
|
+
const As=S.rot?[S.rot.a]:[12,14,16,18,20,22,24,26,28,30], Es=S.rot?[S.rot.e]:[28,30,32,34,36,38,40];
|
|
360
|
+
let best=null;
|
|
361
|
+
for(const k of [5.5,4.75,4])for(const a of As)for(const e of Es){
|
|
362
|
+
const mh=s=>Math.min(mhCap,Math.max(70,s*k));
|
|
363
|
+
const az_=a*Math.PI/180, el_=e*Math.PI/180;
|
|
364
|
+
const wSpan=weeks*Math.cos(az_)+7*Math.sin(az_), depth=weeks*Math.sin(az_)*Math.sin(el_)+7*Math.cos(az_)*Math.sin(el_);
|
|
365
|
+
let s=(W-padL-padR)/wSpan;
|
|
366
|
+
while(s>6&&depth*s+mh(s)+plDepth+60>budget)s*=.97;
|
|
367
|
+
const score=s*(1-Math.abs(e-32)*.004)*(1-(5.5-k)*.05); // 同样大小时偏向 32° 俯视、柱子更高
|
|
368
|
+
if(!best||score>best.score)best={score,s,az_,el_,k};
|
|
369
|
+
}
|
|
370
|
+
const az=best.az_, el=best.el_; lastAng={a:az*180/Math.PI,e:el*180/Math.PI};
|
|
371
|
+
const uxW=Math.cos(az), uyW=Math.sin(az)*Math.sin(el), uxD=-Math.sin(az), uyD=Math.cos(az)*Math.sin(el);
|
|
372
|
+
let step=best.s;
|
|
373
|
+
const mhOf=s=>Math.min(mhCap,Math.max(70,s*best.k));
|
|
364
374
|
const span=step*(weeks*uxW+7*Math.abs(uxD));
|
|
365
|
-
const cR=.
|
|
375
|
+
const cR=.72, plD=plDepth, pad=.35; // 柱子占格子 72%,留缝能看到后排
|
|
366
376
|
const vals=dates.map(d=>dayParts(ymd(d),S.on).reduce((s,p)=>s+p[1],0));
|
|
367
377
|
const maxV=Math.max(...vals,0);
|
|
368
378
|
const maxH=mhOf(step);
|
|
@@ -482,9 +492,22 @@ document.addEventListener("pointermove",e=>{
|
|
|
482
492
|
if(el&&el.closest("svg"))ds=el.getAttribute("data-d");
|
|
483
493
|
else if(e.target.id==="cv3"){const r=e.target.getBoundingClientRect(),x=e.clientX-r.left,y=e.clientY-r.top;
|
|
484
494
|
for(let i=hexes.length-1;i>=0;i--){if(inPoly(x,y,hexes[i].pts)){ds=hexes[i].ds;break}}}
|
|
495
|
+
if(drag&&drag.moved)return;
|
|
485
496
|
if(ds)showTip(ds,e);else tip.style.display="none";
|
|
486
497
|
});
|
|
487
498
|
|
|
499
|
+
// ---------- 拖动旋转(双击复位) ----------
|
|
500
|
+
let drag=null, raf=0;
|
|
501
|
+
const cv3=$("cv3");
|
|
502
|
+
cv3.addEventListener("pointerdown",e=>{drag={x:e.clientX,y:e.clientY,a:lastAng.a,e:lastAng.e,moved:false};cv3.setPointerCapture(e.pointerId)});
|
|
503
|
+
cv3.addEventListener("pointermove",e=>{if(!drag)return;const dx=e.clientX-drag.x,dy=e.clientY-drag.y;
|
|
504
|
+
if(Math.abs(dx)+Math.abs(dy)>3)drag.moved=true; if(!drag.moved)return;
|
|
505
|
+
S.rot={a:Math.min(70,Math.max(6,drag.a-dx*.25)),e:Math.min(70,Math.max(15,drag.e+dy*.25))};
|
|
506
|
+
tip.style.display="none"; cancelAnimationFrame(raf); raf=requestAnimationFrame(()=>draw3D(rangeDates()))});
|
|
507
|
+
const endDrag=()=>{drag=null};
|
|
508
|
+
cv3.addEventListener("pointerup",endDrag);cv3.addEventListener("pointercancel",endDrag);
|
|
509
|
+
cv3.addEventListener("dblclick",()=>{S.rot=null;render()});
|
|
510
|
+
|
|
488
511
|
// ---------- 文案 + 控件 ----------
|
|
489
512
|
["h1","fig1","h2","h2note","v3d","v2d","mTotal","mNoCache","mCost","rData","rYear"].forEach(id=>$(id).textContent=L[id]);
|
|
490
513
|
["gView","gMetric","gRange"].forEach(id=>$(id).setAttribute("aria-label",L[id]));
|