glintline 0.3.1 → 0.3.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/CHANGELOG.md +17 -1
- package/README.md +1 -0
- package/dist/glintline.js +6 -6
- package/glintline.example.json +3 -1
- package/package.json +1 -1
- package/src/config.ts +4 -1
- package/src/index.ts +1 -0
- package/src/render.ts +1 -0
- package/src/transcript.ts +22 -4
- package/src/widgets.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.2] - 2026-11-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `model.atis` widget (opt-in; put it right after `model`): `β 5aa6`
|
|
15
|
+
while the session is pinned to a server-side experiment — the last
|
|
16
|
+
`atis-latch` line Claude Code writes to the transcript before each request,
|
|
17
|
+
sent as the `x-cc-atis` header. Hidden for the standard cohort. A signed
|
|
18
|
+
`v1.<id>.…` token shows as its id, as Claude Code itself reads it.
|
|
19
|
+
`model.atisLabel` and `model.atisLength` (default `4`) shape it.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Every incremental transcript scan skipped the first newly appended line, so
|
|
24
|
+
cache totals ran low and an effort, fast-mode or experiment change could be
|
|
25
|
+
missed until the next one. The transcript cache is rebuilt once on upgrade.
|
|
26
|
+
|
|
10
27
|
## [0.3.1] - 2026-11-15
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -59,7 +76,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
59
76
|
`extra.onlyWhenActive`) reads stdin `fast_mode`. Parsing `Fast mode ON/OFF`
|
|
60
77
|
out of the transcript remains as the fallback for Claude Code versions that do
|
|
61
78
|
not send it.
|
|
62
|
-
|
|
63
79
|
- The published binary now carries a `#!/usr/bin/env node` shebang instead of
|
|
64
80
|
`bun`, so it installs and runs under plain Node as well. The shebang is what
|
|
65
81
|
picks the runtime — npm and Bun both link `bin` as a symlink to the file
|
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ No Bun? `npm install -g glintline` and use `"command": "glintline"`. More option
|
|
|
43
43
|
| `⊠ ■■■□□□□□□■ 153K/450K/50K` | Context used vs. the auto-compact point, with the compact buffer greyed out. Turns red as a compact gets close. |
|
|
44
44
|
| `cache 96% ⟳ 14:49` | Prompt cache hit rate and when the cache goes cold. Step away past 14:49 and the next message rebuilds it — `cold ↑28K` shows how many tokens that costs. |
|
|
45
45
|
| `✳ opus 5 1M ⁖ │ ∼ high fast` | Model, context size, effort, fast mode — what you're burning credits on. |
|
|
46
|
+
| `✳ opus 5 1M β 5aa6` | Your session is pinned to a server-side experiment — answers may not come from the usual setup. Hidden when you're not in one; opt in with the `model.atis` widget. |
|
|
46
47
|
| `⎘ feature-xyz ⎇ main (+42,-10)` | Worktree, branch, uncommitted diff. |
|
|
47
48
|
|
|
48
49
|
Mix them on as many lines as you like:
|
package/dist/glintline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}var Ht;var
|
|
4
|
-
`)
|
|
5
|
-
`)){let[c,f]=l.split("\t"),d=parseInt(c??"",10),b=parseInt(f??"",10);if(Number.isFinite(d))n+=d;if(Number.isFinite(b))r+=b}};try{i(S(["diff","--numstat"],t))}catch(a){p("git.diff",a)}try{i(S(["diff","--cached","--numstat"],t))}catch(a){p("git.diffCached",a)}try{if(S(["ls-files","--others","--exclude-standard"],t))o=!0}catch(a){p("git.untracked",a)}return{branch:e,added:n,removed:r,dirty:o}}var m=(t)=>`\x1B[38;5;${t}m`,s={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",gray:m(244),darkGray:m(240),darkestGray:m(236),lightGray:m(250),white:m(255),red:m(203),mutedRed:m(167),orange:m(214),yellow:m(220),mutedYellow:m(179),green:m(114),mutedGreen:m(108),cyan:m(73),mutedBlue:m(67),magenta:m(176),purple:m(141),lime:m(149),silver:m(251),pink:m(211),coral:m(209)},u=(t,e)=>`${t}${e}\x1B[0m`;function F(t){return t.replace(/\.0$/,"")}function h(t){if(t>=1e6){let e=t/1e6;return`${e>=10?e.toFixed(0):F(e.toFixed(1))}M`}if(t>=1000)return`${Math.round(t/1000)}K`;return String(t)}function G(t){if(t<=0)return"0m";let e=t/60;if(e<60)return`${Math.round(e)}m`;let n=e/60;if(n<24)return`${n>=10?Math.round(n):F(n.toFixed(1))}h`;let r=n/24;return`${r>=10?Math.round(r):F(r.toFixed(1))}d`}function yt(t){let e=new Date(t*1000);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function _(t,e=!1){if(t>=90)return e?s.mutedRed:s.red;if(t>=75)return e?s.mutedYellow:s.yellow;return e?s.mutedGreen:s.green}function P(t){if(t>=80)return s.green;if(t>=50)return s.yellow;return s.gray}function bt(t,e,n){let r=t+e+n;return r>0?t/r*100:null}var D={square:{full:"■",empty:"□"},circle:{full:"●",empty:"○"},bar:{full:"█",empty:"░"},ascii:{full:"#",empty:"-"},dots:{full:"⬢",empty:"⬡"}};function xt(t,e,n,r){if(e<=0)return"";let{full:o,empty:i,threshold:a,fillEmpty:l=!1,calm:c=!1}=r,f=Math.min(1,Math.max(0,t/e)),d=Math.round(f*n),b=l?o:i,g=l?s.darkestGray:s.darkGray;if(a!==void 0&&a>0&&a<e){let Wt=t/a*100,Ut=_(Wt,c),Mt=Math.round(a/e*n),V=Math.max(0,Mt-d),Rt=Math.max(0,n-d-V);return u(Ut,o.repeat(d))+u(g,b.repeat(V))+u(s.gray,o.repeat(Rt))}let Nt=Math.max(0,n-d),At=_(f*100,c);return u(At,o.repeat(d))+u(g,b.repeat(Nt))}var He={opus:s.purple,sonnet:s.cyan,haiku:s.silver,fable:s.coral},Je=[["opus",5,s.lime]];function Ke(t,e){let n=e?parseFloat(e):0;for(let[r,o,i]of Je)if(t===r&&n>=o)return i;return He[t]??s.white}function Ve(t){let{model:e}=t,n=t.config.model,r=Ke(e.family,e.version),o=[];if(n.showFamily)o.push(u(s.bold+r,e.family));let i=[];if(n.showVersion&&e.version)i.push(e.version);if(n.showContext&&e.context)i.push(e.context);if(i.length>0)o.push(u(r,i.join(" ")));if(n.showEffortIcon&&e.effort){let l=t.config.effort.icons[e.effort];if(l)o.push(u(Ct(e.effort),l))}if(o.length===0)return null;let a=o.join(" ");return n.label?u(s.lightGray,n.label)+" "+a:a}function Ct(t){if(t==="max")return s.pink;if(t==="xhigh")return s.orange;return s.yellow}function Ye(t){let e=t.model.effort;if(!e)return null;let n=u(Ct(e),e);if(t.model.fast)n+=" "+u(s.orange,"fast");let r=t.config.effort.label;return r?u(s.lightGray,r)+" "+n:n}function Xe(t){if(!t.context)return null;let{context:e}=t,n=t.config.context,r=t.config.calmColors,o=e.compactThreshold??e.total,i=o>0?e.used/o*100:0,a=[];if(n.showBar){let c=D[n.barStyle]??D.square,f=n.barChars??c;a.push(xt(e.used,e.total,n.barWidth,{full:f.full,empty:f.empty,threshold:e.compactThreshold,fillEmpty:n.fillEmpty,calm:r}))}if(n.showNumbers){let c=_(i,r),f;if(e.compactThreshold!==void 0&&e.compactThreshold<e.total){let d=e.total-e.compactThreshold;if(f=u(c,h(e.used))+u(s.gray,"/")+u(s.lightGray,h(e.compactThreshold)),n.showBufferTokens)f+=u(s.gray,"/")+u(s.gray,h(d))}else f=u(c,`${h(e.used)}/${h(e.total)}`);if(n.showPercent)f+=" "+u(s.gray,"(")+u(c,`${Math.round(i)}%`)+u(s.gray,")");a.push(f)}if(a.length===0)return null;let l=a.join(n.gap);return n.label?u(s.lightGray,n.label)+" "+l:l}var wt={"5h":18000,"7d":604800};function _t(t,e,n,r){if(t.resets_at<=0)return null;let o=(e-(t.resets_at-n))/n;if(o>=1)return null;let i=r?s.lightGray:null;if(o<0.1)return{icon:"~",color:i??s.gray};let a=t.utilization,l=a/o;if(l<=100){if(l<50)return{icon:"↓↓",color:i??s.mutedGreen};if(l<80)return{icon:"↓",color:i??s.mutedGreen};return{icon:"~",color:i??s.gray}}let c=1-o,d=1-(100-a)/a*o/c;if(d>0.5)return{icon:"↑↑",color:i??s.mutedRed};if(d>0.15)return{icon:"↑",color:i??s.mutedYellow};return{icon:"~",color:i??s.gray}}function j(t,e,n,r,o,i){if(!t)return null;let a=Math.round(t.utilization),l=e.mono?s.lightGray:_(a,r),c=u(s.lightGray,e.label)+u(s.gray,e.separator)+u(l,`${a}%`);if(e.showBurnRate){let f=_t(t,n,o,e.mono);if(f)c+=" "+u(f.color,f.icon)}if(i){let f=u(s.darkGray,`${Math.round(i.utilization)}%`);if(e.showBurnRate){let d=_t(i,n,o,e.mono);if(d)f+=" "+u(d.color,d.icon)}c+=" "+u(s.darkGray,"(")+f+u(s.darkGray,")")}if(e.showCountdown&&t.resets_at>0){let f=t.resets_at-n;if(f>0)c+=u(s.gray,` ⟳ ${G(f)}`)}return c}function qe(t){return j(t.usage?.five_hour,t.config.limit5h,t.nowSec,t.config.calmColors,wt["5h"])}function Ze(t){let e=t.config.limit7d,n=t.usage?.seven_day,r=wt["7d"],o=e.perModel?t.usage?.seven_day_scoped?.[t.model.family]:void 0;if(o){let i=`${e.label}-${t.model.family}`;return j(o,{...e,label:i},t.nowSec,t.config.calmColors,r,n)}return j(n,e,t.nowSec,t.config.calmColors,r)}function Qe(t){let e=t.usage?.extra;if(!e||!e.is_enabled)return null;if(t.config.extra.onlyWhenActive){let a=t.model.fast,l=(t.usage?.five_hour?.utilization??0)>=100,c=(t.usage?.seven_day?.utilization??0)>=100;if(!a&&!l&&!c)return null}let n=Math.round(e.utilization),r=t.config.extra.mono?s.lightGray:_(n,t.config.calmColors),o=(e.used_credits/100).toFixed(2),i=(e.monthly_limit/100).toFixed(0);return u(s.lightGray,t.config.extra.label)+u(s.gray,": ")+u(r,`$${o}`)+u(s.gray,`/$${i}`)+" "+u(s.gray,"(")+u(r,`${n}%`)+u(s.gray,")")}function tn(t){let e=t.input.workspace?.git_worktree??t.input.worktree?.name;if(!e)return null;let n=t.config.git.worktreeLabel;return u(s.cyan,n?`${n} ${e}`:e)}function en(t){if(!t.git||!t.git.branch)return null;return u(s.magenta,"⎇ ")+u(s.bold+s.magenta,t.git.branch)}function nn(t){if(!t.git)return null;let e=t.git;if(e.added>0||e.removed>0)return u(s.gray,"(")+u(s.green,`+${e.added}`)+u(s.gray,",")+u(s.red,`-${e.removed}`)+u(s.gray,")");if(e.dirty)return u(s.yellow,"*");return null}function rn(t){return u(s.darkGray,t.config.separator)}function on(){return" "}function B(t){if(!t)return null;let e=bt(t.cacheRead,t.cacheCreation,t.input);return e===null?null:Math.round(e)}function sn(t){let e=t.config.cache,n=t.input.prompt_cache;if(!e.showExpiry||!n?.caching_observed)return null;let r=n.expires_at??0;if(n.warm&&r>t.nowSec){let a=yt(r);return u(s.gray,e.expiryLabel?`${e.expiryLabel} ${a}`:a)}let o=[];if(e.coldLabel)o.push(u(e.mono?s.lightGray:s.mutedBlue,e.coldLabel));let i=n.recache_tokens_if_cold;if(i)o.push(u(e.mono?s.lightGray:s.yellow,`↑${h(i)}`));return o.length>0?o.join(" "):null}function an(t){let e=t.config.cache,n=[];if(e.window==="both"){let i=B(t.cacheLast),a=B(t.totals);if(i!==null)n.push(u(e.mono?s.lightGray:P(i),`${i}%`));if(a!==null)n.push(u(s.darkGray,`Σ${a}%`))}else{let i=B(e.window==="last"?t.cacheLast:t.totals);if(i!==null)n.push(u(e.mono?s.lightGray:P(i),`${i}%`))}if(n.length===0)return null;if(!e.showPercent)n.length=0;let r=sn(t);if(r)n.push(r);if(n.length===0)return null;return(e.label?u(s.lightGray,e.label)+" ":"")+n.join(" ")}function un(t){let e=t.totals;if(e.cacheRead===0&&e.cacheCreation===0)return null;return u(s.green,`↓${h(e.cacheRead)}`)+" "+u(s.yellow,`↑${h(e.cacheCreation)}`)}function ln(t){if(t.config.cost.onlyWhenFast&&!t.model.fast)return null;let e=t.input.cost?.total_cost_usd;if(e===void 0)return null;return u(s.green,`$${e.toFixed(t.config.cost.precision)}`)}function cn(t){let e=t.input.cost?.total_lines_added,n=t.input.cost?.total_lines_removed;if(e===void 0&&n===void 0)return null;return u(s.green,`+${e??0}`)+u(s.gray,"/")+u(s.red,`-${n??0}`)}function fn(t){let e=t.input.cost?.total_duration_ms;if(!e)return null;let n=t.config.session,r=n.mono?s.lightGray:s.cyan;return(n.label?u(s.gray,n.label)+" ":"")+u(r,G(e/1000))}function dn(t){let e=t.input.version;return e?u(s.darkGray,`v${e}`):null}function pn(t){let e=t.input.workspace?.current_dir??t.input.cwd;if(!e)return null;let n=t.config.cwd,r=u(s.mutedBlue,mn(e,n.format,n.maxLength));return n.label?u(s.lightGray,n.label)+" "+r:r}function mn(t,e,n){let r=process.env.HOME??"",o=r&&t.startsWith(r)?"~"+t.slice(r.length):t;if(e==="full")return t;if(e==="home")return o;if(e==="short")return o.split("/").slice(-2).join("/");if(o.length<=n)return o;let i=o.split("/");if(i.length<=2)return o;let a=i[0],l=i.slice(-2).join("/"),c=`${a}/…/${l}`;if(c.length<=n)return c;let f=i[i.length-1];return`${a}/…/${f}`}function gn(t){let e=t.input.session_id;if(!e)return null;let n=t.config.session,r=n.idLength>0?n.idLength:e.length,o=e.slice(0,r),i=n.mono?s.lightGray:s.gray;return(n.idLabel?u(s.lightGray,n.idLabel)+" ":"")+u(i,o)}var hn={model:Ve,effort:Ye,context:Xe,limit5h:qe,limit7d:Ze,extra:Qe,"git.worktree":tn,"git.branch":en,"git.diff":nn,cache:an,"cache.tokens":un,cost:ln,lines:cn,session:fn,"session.id":gn,version:dn,cwd:pn,sep:rn,space:on},E=new Set(["sep","space"]);function St(t,e){let n=hn[t];return n?n(e):null}function z(t=process.env){let e=Number.parseInt(t.COLUMNS??"",10);return Number.isFinite(e)&&e>0?e:null}var yn=[[4352,4447],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65072,65135],[65280,65376],[65504,65510],[127744,128591],[128640,128767],[129280,129535],[131072,262141]];function bn(t){return t>=768&&t<=879||t>=65024&&t<=65039||t>=8203&&t<=8205||t===65279}function xn(t){if(bn(t))return 0;for(let[e,n]of yn)if(t>=e&&t<=n)return 2;return 1}function H(t){let e=0;for(let n of t.replace(/\x1b\[[0-9;]*m/g,""))e+=xn(n.codePointAt(0));return e}function Et(t){let e=t.indexOf(".");return e>=0?t.slice(0,e):t}function _n(t,e){let n=u(s.darkGray,e),r=[],o=null;for(let i=0;i<t.length;i++){let a=t[i];if(!a.out)continue;if(o!==null){let l=Et(o)===Et(a.name)&&o!==a.name;r.push(l?{name:"space",out:" "}:{name:"sep",out:n})}r.push(a),o=a.name}return r}function Cn(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.out===null||r.out==="")continue;if(E.has(r.name)){let i=e[e.length-1];if(!i)continue;if(!t.slice(n+1).some((l)=>l.out&&!E.has(l.name)))continue;if(E.has(i.name)){e[e.length-1]=r;continue}}e.push(r)}return e.map((n)=>n.out)}function Tt(t,e,n){let r=t.map((a)=>({name:a,out:St(a,e)})),i=t.some((a)=>E.has(a))?r:_n(r,n);return Cn(i).join("")}var wn={"cache:session":(t)=>t.cache.window==="both"?{...t,cache:{...t.cache,window:"last"}}:t,"cache:percent":(t)=>({...t,cache:{...t.cache,showPercent:!1}}),"context:buffer":(t)=>({...t,context:{...t.context,showBufferTokens:!1}}),"context:numbers":(t)=>({...t,context:{...t.context,showNumbers:!1}})};function Sn(t,e,n,r){let o=Tt(t,e,n);if(r===null)return o;let i=t,a=e;for(let l of e.config.dropWhenNarrow){if(H(o)<=r)break;let c=wn[l];if(c){if(!i.includes(l.slice(0,l.indexOf(":"))))continue;a={...a,config:c(a.config)}}else{if(!i.includes(l))continue;i=i.filter((f)=>f!==l)}o=Tt(i,a,n)}return o}function En(t,e){return t===null?null:t-2*(2+Math.max(0,e))}function Ot(t){let e={...t,nowSec:Math.floor(Date.now()/1000)},n=En(t.columns,t.config.statusLinePadding);return t.config.widgets.map((r)=>Sn(r,e,t.config.separator,n)).filter((r)=>r.length>0).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`).map((d)=>({width:
|
|
2
|
+
var _=(t,e,n)=>()=>{if(t)try{e=t(t=0)}catch(r){n=[r]}if(n)throw n[0];return e};import{readFileSync as Ft}from"node:fs";import{homedir as Y}from"node:os";import{join as X}from"node:path";function I(t){return!!t&&Gt.test(t)}function k(t){if(!t)return"claude";for(let[e,n]of $t)if(e.test(t))return n;return t.toLowerCase().match(/[a-z]+/)?.[0]??t.toLowerCase()}function Pt(t){if(!t)return;let e=t.match(/(\d+)[.-](\d+)/);if(e)return`${e[1]}.${e[2]}`;return t.match(/(\d+)/)?.[1]}function Dt(t,e){let n=`${t??""} ${e??""}`;return I(n)?"1M":void 0}function Bt(){let t=[X(Y(),".claude","settings.local.json"),X(Y(),".claude","settings.json")];for(let e of t)try{let n=Ft(e,"utf8"),r=JSON.parse(n);if(typeof r.effortLevel==="string"&&r.effortLevel.length>0)return r.effortLevel}catch{}return null}function q(t){let{input:e,sessionEffort:n,fast:r}=t,o=e.model?.id,i=e.model?.display_name,a=i??o,u=k(a),c=Pt(a),f=Dt(o,i),d=jt(e,n,c);return{family:u,version:c,context:f,effort:d,effortSessionOnly:n?.sessionOnly,fast:typeof e.fast_mode==="boolean"?e.fast_mode:r}}function jt(t,e,n){let r=t.effort;if(r&&"level"in r)return typeof r.level==="string"?r.level.toLowerCase():void 0;let o=e?.level??Bt()??void 0;return zt(o,n)}function zt(t,e){if(t!=="xhigh")return t;return(e?parseFloat(e):0)>=4.7?t:"high"}var $t,Gt;var T=_(()=>{$t=[[/opus/i,"opus"],[/sonnet/i,"sonnet"],[/haiku/i,"haiku"],[/fable/i,"fable"]],Gt=/(?:\b|\[)1m\b|1[\s_-]?million/i});function p(t,e){if(!Ht)return;let n=e instanceof Error?e.message:String(e);process.stderr.write(`[glintline:${t}] ${n}
|
|
3
|
+
`)}var Ht;var h=_(()=>{Ht=process.env.GLINTLINE_DEBUG==="1"||process.env.GLINTLINE_DEBUG==="true"});import{mkdirSync as Jt,readFileSync as Kt,writeFileSync as Vt,statSync as Yt}from"node:fs";import{tmpdir as Xt}from"node:os";import{join as nt}from"node:path";import{createHash as qt}from"node:crypto";function Zt(){try{Jt(rt,{recursive:!0})}catch(t){p("cache.mkdir",t)}}function O(t){Zt();let e=qt("sha256").update(t).digest("hex").slice(0,16);return nt(rt,`${e}.json`)}function C(t,e){let n=O(t);try{let r=Yt(n);if((Date.now()-r.mtimeMs)/1000>e)return null;return JSON.parse(Kt(n,"utf8"))}catch{return null}}function y(t,e){let n=O(t);try{Vt(n,JSON.stringify(e))}catch(r){p("cache.write",r)}}var rt;var v=_(()=>{h();rt=nt(Xt(),"glintline-cache")});import{execFileSync as ge}from"node:child_process";import{readFileSync as me}from"node:fs";import{homedir as he,platform as ye}from"node:os";import{join as be}from"node:path";function _e(){try{let t=ge("security",["find-generic-password","-s",xe,"-w"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!t)return null;return JSON.parse(t).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.keychain",t),null}}function st(){try{let t=be(he(),".claude",".credentials.json"),e=me(t,"utf8");return JSON.parse(e).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.file",t),null}}function A(){if(ye()==="darwin")return _e()??st();return st()}var xe="Claude Code-credentials";var at=_(()=>{h()});import{createHash as lt}from"node:crypto";import{spawn as Ce}from"node:child_process";import{existsSync as we,unlinkSync as Se}from"node:fs";import{resolve as Ee}from"node:path";import{argv as Te,execPath as Oe}from"node:process";function Ae(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(!n||n.group!=="weekly")continue;let r=n.scope?.model?.display_name;if(typeof r!=="string")continue;let o=W({utilization:n.percent,resets_at:n.resets_at});if(o)e[k(r)]=o}return e}function ut(t){return"usage:"+lt("sha256").update(t).digest("hex").slice(0,16)}function U(t){return"usage-lock:"+lt("sha256").update(t).digest("hex").slice(0,16)}function We(t){if(!t)return 0;let e=Date.parse(t);return Number.isFinite(e)?Math.floor(e/1000):0}function W(t){if(!t||t.utilization===void 0)return;return{utilization:t.utilization,resets_at:We(t.resets_at)}}function Ue(t){if(!t||t.utilization===void 0)return;return{is_enabled:t.is_enabled??!1,monthly_limit:t.monthly_limit??0,used_credits:t.used_credits??0,utilization:t.utilization}}function Me(t){if(!t)return 1/0;return Math.floor(Date.now()/1000)-t.fetched_at}function ct(t){return C(U(t),Ne)!==null}function Re(t){y(U(t),{at:Math.floor(Date.now()/1000)})}function Fe(t){try{let e=O(U(t));if(we(e))Se(e)}catch(e){p("usage-api.lock",e)}}function $e(){let t=Te[1];if(!t)return;let e=Ee(t);try{Ce(Oe,[e,"--refresh-usage"],{detached:!0,stdio:"ignore"}).unref()}catch(n){p("usage-api.spawn",n)}}async function Ge(t){let e=new AbortController,n=setTimeout(()=>e.abort(),ve);try{let r=await fetch(Le,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${t}`,"anthropic-beta":"oauth-2025-04-20","User-Agent":"glintline/0.1"},signal:e.signal});if(!r.ok)return p("usage-api.fetch",`HTTP ${r.status}`),null;let o=await r.json(),i={five_hour:W(o.five_hour),seven_day:W(o.seven_day),seven_day_scoped:Ae(o.limits),extra:Ue(o.extra_usage),fetched_at:Math.floor(Date.now()/1000),source:"api"};return y(ut(t),i),i}catch(r){return p("usage-api.fetch",r),null}finally{clearTimeout(n)}}async function ft(){let t=A();if(!t)return;if(ct(t))return;Re(t);try{await Ge(t)}finally{Fe(t)}}function dt(){let t=A();if(!t)return null;let e=C(ut(t),ke);if(Me(e)>=Ie&&!ct(t))$e();return e?{...e,source:"cache"}:null}var Le="https://api.anthropic.com/api/oauth/usage",Ie=60,ke=86400,ve=8000,Ne=30;var M=_(()=>{at();T();v();h()});T();import{writeFileSync as vt}from"node:fs";function Z(t,e){let n=process.env[t];if(!n)return null;let r=parseFloat(n);if(!Number.isFinite(r)||r<=0)return null;return Math.min(r,e)}function Q(t,e){let n=Z("CLAUDE_CODE_AUTO_COMPACT_WINDOW",1e7)??t,r=Z("CLAUDE_AUTOCOMPACT_PCT_OVERRIDE",100);if(r===null)return{total:n};let o=Math.round(n*(r/100));if(e)return{total:n,compactThreshold:o};return{total:o}}function tt(t,e){if(!t)return null;return{used:t.used,...Q(t.total,e)}}function et(t,e){let n=t.context_window;if(!n)return null;let r=Q(n.context_window_size??200000,e),o=n.current_usage;if(o){let i=(o.input_tokens??0)+(o.cache_creation_input_tokens??0)+(o.cache_read_input_tokens??0);if(i>0)return{used:i,...r}}if(n.total_input_tokens&&n.total_input_tokens>0)return{used:n.total_input_tokens,...r};if(n.used_percentage!==void 0)return{used:Math.round(n.used_percentage/100*r.total),...r};return null}v();T();h();import{openSync as Qt,readSync as te,closeSync as ee,statSync as ne}from"node:fs";var ot=5,re=604800;function L(){return{v:ot,scannedUpTo:0,ppid:0,effort:null,context:null,fast:!1,totals:{input:0,output:0,cacheRead:0,cacheCreation:0},last:null,lastId:null,lastOutput:0,atis:null}}var oe=/Set effort level to ([a-z0-9-]+)(?:\s*\(([^)]*)\))?/i,ie=/\x1b\[[0-9;]*m/g,se=/Set model to .*?with ([a-z0-9-]+) effort/i,ae=/Fast mode (ON|OFF)/i,le=200000;function ue(t,e,n){if(n<=0)return"";let r=Qt(t,"r");try{let o=Buffer.alloc(n),i=te(r,o,0,n,e);return o.subarray(0,i).toString("utf8")}finally{ee(r)}}function ce(t){let e;if(typeof t==="string")e=t;else if(Array.isArray(t))e=t.map((r)=>typeof r==="object"&&r&&("text"in r)?String(r.text):"").join("");else return null;return e.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/)?.[1]??null}function fe(t){return I(t)?1e6:le}function de(t){let[e,n,...r]=t.split(".");return e==="v1"&&n&&r.length===3&&r.every((o)=>o!=="")?n:t}function pe(t,e){if(!t||t[0]!=="{")return;let n;try{n=JSON.parse(t)}catch{return}if(n.type==="atis-latch"){e.atis=typeof n.atis==="string"?de(n.atis):null;return}if(n.type==="user"&&n.message?.role==="user"){let o=ce(n.message.content)?.replace(ie,"");if(o){let i=o.match(oe);if(i){let u=(i[1]??"").toLowerCase(),c=(i[2]??"").toLowerCase();e.effort={level:u,sessionOnly:c.includes("this session only")||c.includes("session only")}}else{let u=o.match(se);if(u)e.effort={level:(u[1]??"").toLowerCase(),sessionOnly:!1}}let a=o.match(ae);if(a)e.fast=a[1].toUpperCase()==="ON"}}if(n.type==="assistant"&&n.message?.usage&&!n.isSidechain){let r=n.message.usage,o=r.input_tokens??0,i=r.output_tokens??0,a=r.cache_creation_input_tokens??0,u=r.cache_read_input_tokens??0,c=n.message.id??null;if(c!==null&&c===e.lastId&&e.last)e.totals.input-=e.last.input,e.totals.output-=e.lastOutput,e.totals.cacheRead-=e.last.cacheRead,e.totals.cacheCreation-=e.last.cacheCreation;e.totals.input+=o,e.totals.output+=i,e.totals.cacheRead+=u,e.totals.cacheCreation+=a,e.last={input:o,cacheRead:u,cacheCreation:a},e.lastId=c,e.lastOutput=i;let f=o+a+u;if(f>0)e.context={used:f,total:fe(n.message.model)}}}function N(t){return"transcript:"+t}function it(t){if(!t)return L();let e;try{e=ne(t).size}catch(d){return p("transcript.stat",d),L()}let n=C(N(t),re),r=n&&n.v===ot?n:L();if(r.scannedUpTo>e)r=L();let o=process.ppid;if(r.ppid!==0&&r.ppid!==o&&r.effort?.sessionOnly)r.effort=null;if(r.ppid=o,r.scannedUpTo===e)return y(N(t),r),r;let i=r.scannedUpTo,a=e-i,u;try{u=ue(t,i,a)}catch(d){return p("transcript.read",d),r}let c=u.split(`
|
|
4
|
+
`);for(let d=0;d<c.length-1;d++)pe(c[d]??"",r);let f=c[c.length-1]??"";return r.scannedUpTo=e-Buffer.byteLength(f,"utf8"),y(N(t),r),r}M();function Pe(t){if(t===void 0)return 0;if(typeof t==="number")return t;let e=Date.parse(t);return Number.isFinite(e)?Math.floor(e/1000):0}function pt(t){if(!t||t.used_percentage===void 0)return;return{utilization:t.used_percentage,resets_at:Pe(t.resets_at)}}function De(t){let e=t.rate_limits;if(!e)return null;let n=pt(e.five_hour),r=pt(e.seven_day);if(!n&&!r)return null;return{five_hour:n,seven_day:r,fetched_at:Math.floor(Date.now()/1000),source:"stdin"}}function Be(t,e){if(!e)return t;if(!t)return e;return{...e,five_hour:t.five_hour,seven_day:t.seven_day,source:t.source}}function gt(t,e){let n=De(t);if(!e)return n;return Be(n,dt())}var je=new Set(["extra"]);function mt(t){let e=(n)=>t.widgets.some((r)=>r.some(n));if(e((n)=>je.has(n)))return!0;return e((n)=>n==="limit7d")&&t.limit7d.perModel}h();import{execFileSync as ze}from"node:child_process";var He=1500;function w(t,e){return ze("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:He}).trim()}function ht(t){let e="";try{e=w(["symbolic-ref","--short","HEAD"],t)}catch{try{e=w(["rev-parse","--short","HEAD"],t)}catch{return null}}let n=0,r=0,o=!1,i=(a)=>{if(!a)return;o=!0;for(let u of a.split(`
|
|
5
|
+
`)){let[c,f]=u.split("\t"),d=parseInt(c??"",10),x=parseInt(f??"",10);if(Number.isFinite(d))n+=d;if(Number.isFinite(x))r+=x}};try{i(w(["diff","--numstat"],t))}catch(a){p("git.diff",a)}try{i(w(["diff","--cached","--numstat"],t))}catch(a){p("git.diffCached",a)}try{if(w(["ls-files","--others","--exclude-standard"],t))o=!0}catch(a){p("git.untracked",a)}return{branch:e,added:n,removed:r,dirty:o}}var g=(t)=>`\x1B[38;5;${t}m`,s={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",gray:g(244),darkGray:g(240),darkestGray:g(236),lightGray:g(250),white:g(255),red:g(203),mutedRed:g(167),orange:g(214),yellow:g(220),mutedYellow:g(179),green:g(114),mutedGreen:g(108),cyan:g(73),mutedBlue:g(67),magenta:g(176),purple:g(141),lime:g(149),silver:g(251),pink:g(211),coral:g(209)},l=(t,e)=>`${t}${e}\x1B[0m`;function R(t){return t.replace(/\.0$/,"")}function m(t){if(t>=1e6){let e=t/1e6;return`${e>=10?e.toFixed(0):R(e.toFixed(1))}M`}if(t>=1000)return`${Math.round(t/1000)}K`;return String(t)}function F(t){if(t<=0)return"0m";let e=t/60;if(e<60)return`${Math.round(e)}m`;let n=e/60;if(n<24)return`${n>=10?Math.round(n):R(n.toFixed(1))}h`;let r=n/24;return`${r>=10?Math.round(r):R(r.toFixed(1))}d`}function yt(t){let e=new Date(t*1000);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function b(t,e=!1){if(t>=90)return e?s.mutedRed:s.red;if(t>=75)return e?s.mutedYellow:s.yellow;return e?s.mutedGreen:s.green}function G(t){if(t>=80)return s.green;if(t>=50)return s.yellow;return s.gray}function bt(t,e,n){let r=t+e+n;return r>0?t/r*100:null}var P={square:{full:"■",empty:"□"},circle:{full:"●",empty:"○"},bar:{full:"█",empty:"░"},ascii:{full:"#",empty:"-"},dots:{full:"⬢",empty:"⬡"}};function xt(t,e,n,r){if(e<=0)return"";let{full:o,empty:i,threshold:a,fillEmpty:u=!1,calm:c=!1}=r,f=Math.min(1,Math.max(0,t/e)),d=Math.round(f*n),x=u?o:i,K=u?s.darkestGray:s.darkGray;if(a!==void 0&&a>0&&a<e){let Wt=t/a*100,Ut=b(Wt,c),Mt=Math.round(a/e*n),V=Math.max(0,Mt-d),Rt=Math.max(0,n-d-V);return l(Ut,o.repeat(d))+l(K,x.repeat(V))+l(s.gray,o.repeat(Rt))}let Nt=Math.max(0,n-d),At=b(f*100,c);return l(At,o.repeat(d))+l(K,x.repeat(Nt))}var Je={opus:s.purple,sonnet:s.cyan,haiku:s.silver,fable:s.coral},Ke=[["opus",5,s.lime]];function Ve(t,e){let n=e?parseFloat(e):0;for(let[r,o,i]of Ke)if(t===r&&n>=o)return i;return Je[t]??s.white}function Ye(t){let{model:e}=t,n=t.config.model,r=Ve(e.family,e.version),o=[];if(n.showFamily)o.push(l(s.bold+r,e.family));let i=[];if(n.showVersion&&e.version)i.push(e.version);if(n.showContext&&e.context)i.push(e.context);if(i.length>0)o.push(l(r,i.join(" ")));if(n.showEffortIcon&&e.effort){let u=t.config.effort.icons[e.effort];if(u)o.push(l(Ct(e.effort),u))}if(o.length===0)return null;let a=o.join(" ");return n.label?l(s.lightGray,n.label)+" "+a:a}function Xe(t){if(!t.atis)return null;let e=t.config.model,n=t.atis.slice(0,Math.max(1,e.atisLength));return l(s.pink,e.atisLabel?`${e.atisLabel} ${n}`:n)}function Ct(t){if(t==="max")return s.pink;if(t==="xhigh")return s.orange;return s.yellow}function qe(t){let e=t.model.effort;if(!e)return null;let n=l(Ct(e),e);if(t.model.fast)n+=" "+l(s.orange,"fast");let r=t.config.effort.label;return r?l(s.lightGray,r)+" "+n:n}function Ze(t){if(!t.context)return null;let{context:e}=t,n=t.config.context,r=t.config.calmColors,o=e.compactThreshold??e.total,i=o>0?e.used/o*100:0,a=[];if(n.showBar){let c=P[n.barStyle]??P.square,f=n.barChars??c;a.push(xt(e.used,e.total,n.barWidth,{full:f.full,empty:f.empty,threshold:e.compactThreshold,fillEmpty:n.fillEmpty,calm:r}))}if(n.showNumbers){let c=b(i,r),f;if(e.compactThreshold!==void 0&&e.compactThreshold<e.total){let d=e.total-e.compactThreshold;if(f=l(c,m(e.used))+l(s.gray,"/")+l(s.lightGray,m(e.compactThreshold)),n.showBufferTokens)f+=l(s.gray,"/")+l(s.gray,m(d))}else f=l(c,`${m(e.used)}/${m(e.total)}`);if(n.showPercent)f+=" "+l(s.gray,"(")+l(c,`${Math.round(i)}%`)+l(s.gray,")");a.push(f)}if(a.length===0)return null;let u=a.join(n.gap);return n.label?l(s.lightGray,n.label)+" "+u:u}var wt={"5h":18000,"7d":604800};function _t(t,e,n,r){if(t.resets_at<=0)return null;let o=(e-(t.resets_at-n))/n;if(o>=1)return null;let i=r?s.lightGray:null;if(o<0.1)return{icon:"~",color:i??s.gray};let a=t.utilization,u=a/o;if(u<=100){if(u<50)return{icon:"↓↓",color:i??s.mutedGreen};if(u<80)return{icon:"↓",color:i??s.mutedGreen};return{icon:"~",color:i??s.gray}}let c=1-o,d=1-(100-a)/a*o/c;if(d>0.5)return{icon:"↑↑",color:i??s.mutedRed};if(d>0.15)return{icon:"↑",color:i??s.mutedYellow};return{icon:"~",color:i??s.gray}}function B(t,e,n,r,o,i){if(!t)return null;let a=Math.round(t.utilization),u=e.mono?s.lightGray:b(a,r),c=l(s.lightGray,e.label)+l(s.gray,e.separator)+l(u,`${a}%`);if(e.showBurnRate){let f=_t(t,n,o,e.mono);if(f)c+=" "+l(f.color,f.icon)}if(i){let f=l(s.darkGray,`${Math.round(i.utilization)}%`);if(e.showBurnRate){let d=_t(i,n,o,e.mono);if(d)f+=" "+l(d.color,d.icon)}c+=" "+l(s.darkGray,"(")+f+l(s.darkGray,")")}if(e.showCountdown&&t.resets_at>0){let f=t.resets_at-n;if(f>0)c+=l(s.gray,` ⟳ ${F(f)}`)}return c}function Qe(t){return B(t.usage?.five_hour,t.config.limit5h,t.nowSec,t.config.calmColors,wt["5h"])}function tn(t){let e=t.config.limit7d,n=t.usage?.seven_day,r=wt["7d"],o=e.perModel?t.usage?.seven_day_scoped?.[t.model.family]:void 0;if(o){let i=`${e.label}-${t.model.family}`;return B(o,{...e,label:i},t.nowSec,t.config.calmColors,r,n)}return B(n,e,t.nowSec,t.config.calmColors,r)}function en(t){let e=t.usage?.extra;if(!e||!e.is_enabled)return null;if(t.config.extra.onlyWhenActive){let a=t.model.fast,u=(t.usage?.five_hour?.utilization??0)>=100,c=(t.usage?.seven_day?.utilization??0)>=100;if(!a&&!u&&!c)return null}let n=Math.round(e.utilization),r=t.config.extra.mono?s.lightGray:b(n,t.config.calmColors),o=(e.used_credits/100).toFixed(2),i=(e.monthly_limit/100).toFixed(0);return l(s.lightGray,t.config.extra.label)+l(s.gray,": ")+l(r,`$${o}`)+l(s.gray,`/$${i}`)+" "+l(s.gray,"(")+l(r,`${n}%`)+l(s.gray,")")}function nn(t){let e=t.input.workspace?.git_worktree??t.input.worktree?.name;if(!e)return null;let n=t.config.git.worktreeLabel;return l(s.cyan,n?`${n} ${e}`:e)}function rn(t){if(!t.git||!t.git.branch)return null;return l(s.magenta,"⎇ ")+l(s.bold+s.magenta,t.git.branch)}function on(t){if(!t.git)return null;let e=t.git;if(e.added>0||e.removed>0)return l(s.gray,"(")+l(s.green,`+${e.added}`)+l(s.gray,",")+l(s.red,`-${e.removed}`)+l(s.gray,")");if(e.dirty)return l(s.yellow,"*");return null}function sn(t){return l(s.darkGray,t.config.separator)}function an(){return" "}function D(t){if(!t)return null;let e=bt(t.cacheRead,t.cacheCreation,t.input);return e===null?null:Math.round(e)}function ln(t){let e=t.config.cache,n=t.input.prompt_cache;if(!e.showExpiry||!n?.caching_observed)return null;let r=n.expires_at??0;if(n.warm&&r>t.nowSec){let a=yt(r);return l(s.gray,e.expiryLabel?`${e.expiryLabel} ${a}`:a)}let o=[];if(e.coldLabel)o.push(l(e.mono?s.lightGray:s.mutedBlue,e.coldLabel));let i=n.recache_tokens_if_cold;if(i)o.push(l(e.mono?s.lightGray:s.yellow,`↑${m(i)}`));return o.length>0?o.join(" "):null}function un(t){let e=t.config.cache,n=[];if(e.window==="both"){let i=D(t.cacheLast),a=D(t.totals);if(i!==null)n.push(l(e.mono?s.lightGray:G(i),`${i}%`));if(a!==null)n.push(l(s.darkGray,`Σ${a}%`))}else{let i=D(e.window==="last"?t.cacheLast:t.totals);if(i!==null)n.push(l(e.mono?s.lightGray:G(i),`${i}%`))}if(n.length===0)return null;if(!e.showPercent)n.length=0;let r=ln(t);if(r)n.push(r);if(n.length===0)return null;return(e.label?l(s.lightGray,e.label)+" ":"")+n.join(" ")}function cn(t){let e=t.totals;if(e.cacheRead===0&&e.cacheCreation===0)return null;return l(s.green,`↓${m(e.cacheRead)}`)+" "+l(s.yellow,`↑${m(e.cacheCreation)}`)}function fn(t){if(t.config.cost.onlyWhenFast&&!t.model.fast)return null;let e=t.input.cost?.total_cost_usd;if(e===void 0)return null;return l(s.green,`$${e.toFixed(t.config.cost.precision)}`)}function dn(t){let e=t.input.cost?.total_lines_added,n=t.input.cost?.total_lines_removed;if(e===void 0&&n===void 0)return null;return l(s.green,`+${e??0}`)+l(s.gray,"/")+l(s.red,`-${n??0}`)}function pn(t){let e=t.input.cost?.total_duration_ms;if(!e)return null;let n=t.config.session,r=n.mono?s.lightGray:s.cyan;return(n.label?l(s.gray,n.label)+" ":"")+l(r,F(e/1000))}function gn(t){let e=t.input.version;return e?l(s.darkGray,`v${e}`):null}function mn(t){let e=t.input.workspace?.current_dir??t.input.cwd;if(!e)return null;let n=t.config.cwd,r=l(s.mutedBlue,hn(e,n.format,n.maxLength));return n.label?l(s.lightGray,n.label)+" "+r:r}function hn(t,e,n){let r=process.env.HOME??"",o=r&&t.startsWith(r)?"~"+t.slice(r.length):t;if(e==="full")return t;if(e==="home")return o;if(e==="short")return o.split("/").slice(-2).join("/");if(o.length<=n)return o;let i=o.split("/");if(i.length<=2)return o;let a=i[0],u=i.slice(-2).join("/"),c=`${a}/…/${u}`;if(c.length<=n)return c;let f=i[i.length-1];return`${a}/…/${f}`}function yn(t){let e=t.input.session_id;if(!e)return null;let n=t.config.session,r=n.idLength>0?n.idLength:e.length,o=e.slice(0,r),i=n.mono?s.lightGray:s.gray;return(n.idLabel?l(s.lightGray,n.idLabel)+" ":"")+l(i,o)}var bn={model:Ye,"model.atis":Xe,effort:qe,context:Ze,limit5h:Qe,limit7d:tn,extra:en,"git.worktree":nn,"git.branch":rn,"git.diff":on,cache:un,"cache.tokens":cn,cost:fn,lines:dn,session:pn,"session.id":yn,version:gn,cwd:mn,sep:sn,space:an},S=new Set(["sep","space"]);function St(t,e){let n=bn[t];return n?n(e):null}function j(t=process.env){let e=Number.parseInt(t.COLUMNS??"",10);return Number.isFinite(e)&&e>0?e:null}var xn=[[4352,4447],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65072,65135],[65280,65376],[65504,65510],[127744,128591],[128640,128767],[129280,129535],[131072,262141]];function _n(t){return t>=768&&t<=879||t>=65024&&t<=65039||t>=8203&&t<=8205||t===65279}function Cn(t){if(_n(t))return 0;for(let[e,n]of xn)if(t>=e&&t<=n)return 2;return 1}function z(t){let e=0;for(let n of t.replace(/\x1b\[[0-9;]*m/g,""))e+=Cn(n.codePointAt(0));return e}function Et(t){let e=t.indexOf(".");return e>=0?t.slice(0,e):t}function wn(t,e){let n=l(s.darkGray,e),r=[],o=null;for(let i=0;i<t.length;i++){let a=t[i];if(!a.out)continue;if(o!==null){let u=Et(o)===Et(a.name)&&o!==a.name;r.push(u?{name:"space",out:" "}:{name:"sep",out:n})}r.push(a),o=a.name}return r}function Sn(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.out===null||r.out==="")continue;if(S.has(r.name)){let i=e[e.length-1];if(!i)continue;if(!t.slice(n+1).some((u)=>u.out&&!S.has(u.name)))continue;if(S.has(i.name)){e[e.length-1]=r;continue}}e.push(r)}return e.map((n)=>n.out)}function Tt(t,e,n){let r=t.map((a)=>({name:a,out:St(a,e)})),i=t.some((a)=>S.has(a))?r:wn(r,n);return Sn(i).join("")}var En={"cache:session":(t)=>t.cache.window==="both"?{...t,cache:{...t.cache,window:"last"}}:t,"cache:percent":(t)=>({...t,cache:{...t.cache,showPercent:!1}}),"context:buffer":(t)=>({...t,context:{...t.context,showBufferTokens:!1}}),"context:numbers":(t)=>({...t,context:{...t.context,showNumbers:!1}})};function Tn(t,e,n,r){let o=Tt(t,e,n);if(r===null)return o;let i=t,a=e;for(let u of e.config.dropWhenNarrow){if(z(o)<=r)break;let c=En[u];if(c){if(!i.includes(u.slice(0,u.indexOf(":"))))continue;a={...a,config:c(a.config)}}else{if(!i.includes(u))continue;i=i.filter((f)=>f!==u)}o=Tt(i,a,n)}return o}function On(t,e){return t===null?null:t-2*(2+Math.max(0,e))}function Ot(t){let e={...t,nowSec:Math.floor(Date.now()/1000)},n=On(t.columns,t.config.statusLinePadding);return t.config.widgets.map((r)=>Tn(r,e,t.config.separator,n)).filter((r)=>r.length>0).join(`
|
|
6
|
+
`)}h();import{readFileSync as Ln}from"node:fs";import{homedir as H}from"node:os";import{join as J}from"node:path";var Lt={widgets:[["model","effort","cost","context","limit5h","limit7d","extra","git.worktree","git.branch","git.diff"],["session.id","cwd"]],separator:" │ ",calmColors:!1,dropWhenNarrow:[],statusLinePadding:0,model:{showFamily:!0,showVersion:!0,showContext:!0,showEffortIcon:!0,label:"✳",atisLabel:"β",atisLength:4},effort:{label:"∼",icons:{low:"·",medium:"⁚",high:"⁖",xhigh:"⁘",max:"⁙"}},context:{showBar:!0,showNumbers:!0,showPercent:!1,showCompactBuffer:!1,showBufferTokens:!0,fillEmpty:!0,barWidth:10,barStyle:"square",gap:" ",label:"⊠"},limit5h:{showCountdown:!0,separator:" ",label:"5h",mono:!1,showBurnRate:!0},limit7d:{showCountdown:!0,separator:" ",label:"7d",mono:!1,showBurnRate:!0,perModel:!1},cost:{precision:2,onlyWhenFast:!0},extra:{onlyWhenActive:!1,label:"extra",mono:!1},cache:{label:"cache",mono:!1,window:"session",showPercent:!0,showExpiry:!1,expiryLabel:"⟳",coldLabel:"cold"},git:{worktreeLabel:"⎘"},session:{label:"⏱︎",mono:!1,idLength:8,idLabel:"#"},cwd:{format:"smart",maxLength:40,label:"⊕"}};function In(){let t=process.env.GLINTLINE_CONFIG;if(t)return[t];return[J(H(),".config","glintline","settings.json"),J(H(),".config","glintline.json"),J(H(),".claude","glintline.json")]}function kn(t){try{return JSON.parse(Ln(t,"utf8"))}catch(e){if(e.code!=="ENOENT")p("config.read",e);return null}}function E(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}var vn=new Set(["__proto__","constructor","prototype"]);function It(t,e){if(!e)return t;if(!E(t)||!E(e))return t;let n={...t};for(let r of Object.keys(e)){if(vn.has(r))continue;let o=e[r],i=n[r];if(o===void 0)continue;if(E(o)&&E(i))n[r]=It(i,o);else n[r]=o}return n}function Nn(t){let e=t.widgets;if(Array.isArray(e)&&e.every((n)=>typeof n==="string"))return{...t,widgets:[e]};return t}function kt(){for(let t of In()){let e=kn(t);if(E(e))return Nn(It(Lt,e))}return Lt}h();async function An(){if(process.stdin.isTTY)return"";let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}function Wn(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}async function Un(){if(process.argv.includes("--refresh-usage")){await Promise.resolve().then(() => M());await ft();return}let t=await An(),e=process.env.GLINTLINE_DUMP_STDIN;if(e)try{vt(e,t)}catch(d){p("stdin.dump",d)}let n=process.env.GLINTLINE_DUMP_ENV,r=Wn(t),o=r.workspace?.current_dir??r.cwd??process.cwd(),i=kt(),a=it(r.transcript_path),u=gt(r,mt(i)),c=et(r,i.context.showCompactBuffer)??tt(a.context,i.context.showCompactBuffer),f=Ot({input:r,model:q({input:r,sessionEffort:a.effort,fast:a.fast}),context:c,usage:u,git:ht(o),totals:a.totals,cacheLast:a.last,atis:a.atis,config:i,columns:j()});if(n)try{vt(n,JSON.stringify({COLUMNS:process.env.COLUMNS??null,LINES:process.env.LINES??null,parsedColumns:j(),lines:f.split(`
|
|
7
|
+
`).map((d)=>({width:z(d),text:d.replace(/\x1b\[[0-9;]*m/g,"")}))},null,2))}catch(d){p("env.dump",d)}process.stdout.write(f)}Un().catch((t)=>{p("main",t),process.exit(0)});
|
package/glintline.example.json
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"showVersion": true,
|
|
13
13
|
"showContext": true,
|
|
14
14
|
"showEffortIcon": true,
|
|
15
|
-
"label": "✳"
|
|
15
|
+
"label": "✳",
|
|
16
|
+
"atisLabel": "β",
|
|
17
|
+
"atisLength": 4
|
|
16
18
|
},
|
|
17
19
|
"effort": { "label": "∼", "icons": { "low": "·", "medium": "⁚", "high": "⁖", "xhigh": "⁘", "max": "⁙" } },
|
|
18
20
|
"context": {
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -9,6 +9,9 @@ export interface ModelOpts {
|
|
|
9
9
|
showContext: boolean;
|
|
10
10
|
showEffortIcon: boolean;
|
|
11
11
|
label: string;
|
|
12
|
+
// `model.atis`: prefix and how many characters of the experiment id to show.
|
|
13
|
+
atisLabel: string;
|
|
14
|
+
atisLength: number;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export interface EffortOpts {
|
|
@@ -130,7 +133,7 @@ export const DEFAULT_CONFIG: Config = {
|
|
|
130
133
|
calmColors: false,
|
|
131
134
|
dropWhenNarrow: [],
|
|
132
135
|
statusLinePadding: 0,
|
|
133
|
-
model: { showFamily: true, showVersion: true, showContext: true, showEffortIcon: true, label: "✳" },
|
|
136
|
+
model: { showFamily: true, showVersion: true, showContext: true, showEffortIcon: true, label: "✳", atisLabel: "β", atisLength: 4 },
|
|
134
137
|
effort: { label: "∼", icons: { low: "·", medium: "⁚", high: "⁖", xhigh: "⁘", max: "⁙" } },
|
|
135
138
|
context: { showBar: true, showNumbers: true, showPercent: false, showCompactBuffer: false, showBufferTokens: true, fillEmpty: true, barWidth: 10, barStyle: "square", gap: " ", label: "⊠" },
|
|
136
139
|
limit5h: { showCountdown: true, separator: " ", label: "5h", mono: false, showBurnRate: true },
|
package/src/index.ts
CHANGED
package/src/render.ts
CHANGED
package/src/transcript.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { readCache, writeCache } from "./cache";
|
|
|
3
3
|
import { isOneMillionContext } from "./model";
|
|
4
4
|
import { debug } from "./debug";
|
|
5
5
|
|
|
6
|
-
const CACHE_VERSION =
|
|
6
|
+
const CACHE_VERSION = 5;
|
|
7
7
|
const CACHE_TTL_SEC = 7 * 24 * 3600;
|
|
8
8
|
|
|
9
9
|
export interface SessionTotals {
|
|
@@ -34,6 +34,9 @@ export interface TranscriptState {
|
|
|
34
34
|
// already counted instead of adding them again.
|
|
35
35
|
lastId: string | null;
|
|
36
36
|
lastOutput: number;
|
|
37
|
+
// Experiment pin from the last `atis-latch` line, as an id (see atisId); ""
|
|
38
|
+
// for the standard cohort, null when Claude Code never wrote one.
|
|
39
|
+
atis: string | null;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
function emptyState(): TranscriptState {
|
|
@@ -48,6 +51,7 @@ function emptyState(): TranscriptState {
|
|
|
48
51
|
last: null,
|
|
49
52
|
lastId: null,
|
|
50
53
|
lastOutput: 0,
|
|
54
|
+
atis: null,
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -60,6 +64,7 @@ interface TranscriptUsage {
|
|
|
60
64
|
|
|
61
65
|
interface JsonlLine {
|
|
62
66
|
type?: string;
|
|
67
|
+
atis?: unknown;
|
|
63
68
|
isSidechain?: boolean;
|
|
64
69
|
message?: {
|
|
65
70
|
role?: string;
|
|
@@ -111,6 +116,13 @@ function detectContextSize(model: string | undefined): number {
|
|
|
111
116
|
return isOneMillionContext(model) ? 1_000_000 : DEFAULT_CONTEXT;
|
|
112
117
|
}
|
|
113
118
|
|
|
119
|
+
// Claude Code's own reading of an atis value: a signed `v1.<id>.<a>.<b>.<c>`
|
|
120
|
+
// token stands for its <id>; anything else is the id itself.
|
|
121
|
+
export function atisId(raw: string): string {
|
|
122
|
+
const [version, id, ...rest] = raw.split(".");
|
|
123
|
+
return version === "v1" && id && rest.length === 3 && rest.every((p) => p !== "") ? id : raw;
|
|
124
|
+
}
|
|
125
|
+
|
|
114
126
|
function applyLine(line: string, state: TranscriptState): void {
|
|
115
127
|
if (!line || line[0] !== "{") return;
|
|
116
128
|
let parsed: JsonlLine;
|
|
@@ -120,6 +132,12 @@ function applyLine(line: string, state: TranscriptState): void {
|
|
|
120
132
|
return;
|
|
121
133
|
}
|
|
122
134
|
|
|
135
|
+
// Written before every request; the last one is the pin the session runs on.
|
|
136
|
+
if (parsed.type === "atis-latch") {
|
|
137
|
+
state.atis = typeof parsed.atis === "string" ? atisId(parsed.atis) : null;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
123
141
|
if (parsed.type === "user" && parsed.message?.role === "user") {
|
|
124
142
|
const rawStdout = extractStdout(parsed.message.content);
|
|
125
143
|
const stdout = rawStdout?.replace(ANSI_RE, "");
|
|
@@ -221,10 +239,10 @@ export function scanTranscript(path: string | undefined): TranscriptState {
|
|
|
221
239
|
return state;
|
|
222
240
|
}
|
|
223
241
|
|
|
242
|
+
// scannedUpTo always sits at the start of a line (see the tail below), so the
|
|
243
|
+
// chunk's first line is a whole new record, not the rest of a scanned one.
|
|
224
244
|
const lines = chunk.split("\n");
|
|
225
|
-
|
|
226
|
-
const start = skipFirst ? 1 : 0;
|
|
227
|
-
for (let i = start; i < lines.length - 1; i++) {
|
|
245
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
228
246
|
applyLine(lines[i] ?? "", state);
|
|
229
247
|
}
|
|
230
248
|
// The last split element is whatever follows the final "\n". If the chunk
|
package/src/widgets.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface WidgetCtx {
|
|
|
25
25
|
git: GitInfo | null;
|
|
26
26
|
totals: SessionTotals;
|
|
27
27
|
cacheLast: CacheUsage | null;
|
|
28
|
+
atis: string | null;
|
|
28
29
|
nowSec: number;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -75,6 +76,16 @@ function renderModel(ctx: WidgetCtx): string | null {
|
|
|
75
76
|
return opts.label ? wrap(c.lightGray, opts.label) + " " + body : body;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
// The experiment pin Claude Code sends as `x-cc-atis`. Empty for the standard
|
|
80
|
+
// cohort, so this only shows up while the session is pinned to a server-side
|
|
81
|
+
// experiment — the cue that responses may come from something other than usual.
|
|
82
|
+
function renderModelAtis(ctx: WidgetCtx): string | null {
|
|
83
|
+
if (!ctx.atis) return null;
|
|
84
|
+
const opts = ctx.config.model;
|
|
85
|
+
const id = ctx.atis.slice(0, Math.max(1, opts.atisLength));
|
|
86
|
+
return wrap(c.pink, opts.atisLabel ? `${opts.atisLabel} ${id}` : id);
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
function effortColor(level: string): string {
|
|
79
90
|
if (level === "max") return c.pink;
|
|
80
91
|
if (level === "xhigh") return c.orange;
|
|
@@ -387,6 +398,7 @@ function renderSessionId(ctx: WidgetCtx): string | null {
|
|
|
387
398
|
|
|
388
399
|
const REGISTRY: Record<string, (ctx: WidgetCtx) => string | null> = {
|
|
389
400
|
model: renderModel,
|
|
401
|
+
"model.atis": renderModelAtis,
|
|
390
402
|
effort: renderEffort,
|
|
391
403
|
context: renderContext,
|
|
392
404
|
limit5h: renderLimit5h,
|