ccgauge 1.1.5 → 1.1.6
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-build-manifest.json +19 -19
- package/.next/standalone/.next/app-path-routes-manifest.json +5 -5
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/blocks/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/export/usage/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/pricing/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/scan/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/usage/route_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/models/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/sessions/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page.js +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/usage/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +5 -5
- package/.next/standalone/.next/server/chunks/716.js +1 -1
- package/.next/standalone/.next/server/functions-config-manifest.json +3 -3
- package/.next/standalone/.next/server/middleware-manifest.json +5 -5
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/package.json +1 -1
- package/CHANGELOG.md +40 -0
- package/dist/mcp/server.mjs +2 -2
- package/dist/report/index.mjs +1 -1
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{GtWVWyG8mgmjwPOWjfTMr → T5Enhm7piIOmShjmQ31T5}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{GtWVWyG8mgmjwPOWjfTMr → T5Enhm7piIOmShjmQ31T5}/_ssgManifest.js +0 -0
package/dist/report/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var Gr=Object.create;var At=Object.defineProperty;var qr=Object.getOwnPropertyDe
|
|
|
5
5
|
`)!=-1,n=this._styles,D=n.length;D--;){var r=ce[n[D]];u=r.open+u.replace(r.closeRe,r.open)+r.close,t&&(u=u.replace(ls,function(o){return r.close+o+r.open}))}return u}E.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var u in e)(function(t){E[t]=function(n){if(typeof e[t]=="object"){var D=n;for(var r in e[t])D=E[e[t][r]](D);return D}return E[e[t]](n)}})(u)};function hs(){var e={};return Object.keys(jD).forEach(function(u){e[u]={get:function(){return WD([u])}}}),e}var Cs=function(u,t){var n=t.split("");return n=n.map(u),n.join("")};E.trap=kD();E.zalgo=TD();E.maps={};E.maps.america=vD()(E);E.maps.zebra=MD()(E);E.maps.rainbow=OD()(E);E.maps.random=ND()(E);for($D in E.maps)(function(e){E[e]=function(u){return Cs(E.maps[e],u)}})($D);var $D;UD(E,hs())});var VD=A((c0,HD)=>{var gs=qD();HD.exports=gs});var JD=A((l0,ou)=>{var{info:ms,debug:YD}=Du(),L=Zu(),ut=class e{constructor(u){this.setOptions(u),this.x=null,this.y=null}setOptions(u){["boolean","number","bigint","string"].indexOf(typeof u)!==-1&&(u={content:""+u}),u=u||{},this.options=u;let t=u.content;if(["boolean","number","bigint","string"].indexOf(typeof t)!==-1)this.content=String(t);else if(!t)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof t);this.colSpan=u.colSpan||1,this.rowSpan=u.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(u,t){this.cells=t;let n=this.options.chars||{},D=u.chars,r=this.chars={};Bs.forEach(function(s){et(n,D,s,r)}),this.truncate=this.options.truncate||u.truncate;let o=this.options.style=this.options.style||{},i=u.style;et(o,i,"padding-left",this),et(o,i,"padding-right",this),this.head=o.head||i.head,this.border=o.border||i.border,this.fixedWidth=u.colWidths[this.x],this.lines=this.computeLines(u),this.desiredWidth=L.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(u){let t=u.wordWrap||u.textWrap,{wordWrap:n=t}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let o=1;for(;o<this.colSpan;)this.fixedWidth+=u.colWidths[this.x+o],o++}let{wrapOnWordBoundary:D=!0}=u,{wrapOnWordBoundary:r=D}=this.options;return this.wrapLines(L.wordWrap(this.fixedWidth,this.content,r))}return this.wrapLines(this.content.split(`
|
|
6
6
|
`))}wrapLines(u){let t=L.colorizeLines(u);return this.href?t.map(n=>L.hyperlink(this.href,n)):t}init(u){let t=this.x,n=this.y;this.widths=u.colWidths.slice(t,t+this.colSpan),this.heights=u.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(zD,-1),this.height=this.heights.reduce(zD,-1),this.hAlign=this.options.hAlign||u.colAligns[t],this.vAlign=this.options.vAlign||u.rowAligns[n],this.drawRight=t+this.colSpan==u.colWidths.length}draw(u,t){if(u=="top")return this.drawTop(this.drawRight);if(u=="bottom")return this.drawBottom(this.drawRight);let n=L.truncate(this.content,10,this.truncate);u||ms(`${this.y}-${this.x}: ${this.rowSpan-u}x${this.colSpan} Cell ${n}`);let D=Math.max(this.height-this.lines.length,0),r;switch(this.vAlign){case"center":r=Math.ceil(D/2);break;case"bottom":r=D;break;default:r=0}if(u<r||u>=r+this.lines.length)return this.drawEmpty(this.drawRight,t);let o=this.lines.length>this.height&&u+1>=this.height;return this.drawLine(u-r,this.drawRight,o,t)}drawTop(u){let t=[];return this.cells?this.widths.forEach(function(n,D){t.push(this._topLeftChar(D)),t.push(L.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(t.push(this._topLeftChar(0)),t.push(L.repeat(this.chars[this.y==0?"top":"mid"],this.width))),u&&t.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",t.join(""))}_topLeftChar(u){let t=this.x+u,n;if(this.y==0)n=t==0?"topLeft":u==0?"topMid":"top";else if(t==0)n="leftMid";else if(n=u==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][t]instanceof e.ColSpanCell&&(n=u==0?"topMid":"mid"),u==0)){let r=1;for(;this.cells[this.y][t-r]instanceof e.ColSpanCell;)r++;this.cells[this.y][t-r]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(u,t){if(this[u]&&this[u].length)try{let n=VD();for(let D=this[u].length-1;D>=0;D--)n=n[this[u][D]];return n(t)}catch{return t}else return t}drawLine(u,t,n,D){let r=this.chars[this.x==0?"left":"middle"];if(this.x&&D&&this.cells){let f=this.cells[this.y+D][this.x-1];for(;f instanceof Pe;)f=this.cells[f.y][f.x-1];f instanceof Oe||(r=this.chars.rightMid)}let o=L.repeat(" ",this.paddingLeft),i=t?this.chars.right:"",s=L.repeat(" ",this.paddingRight),a=this.lines[u],F=this.width-(this.paddingLeft+this.paddingRight);n&&(a+=this.truncate||"\u2026");let c=L.truncate(a,F,this.truncate);return c=L.pad(c,F," ",this.hAlign),c=o+c+s,this.stylizeLine(r,c,i)}stylizeLine(u,t,n){return u=this.wrapWithStyleColors("border",u),n=this.wrapWithStyleColors("border",n),this.y===0&&(t=this.wrapWithStyleColors("head",t)),u+t+n}drawBottom(u){let t=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=L.repeat(this.chars.bottom,this.width),D=u?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",t+n+D)}drawEmpty(u,t){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&t&&this.cells){let o=this.cells[this.y+t][this.x-1];for(;o instanceof Pe;)o=this.cells[o.y][o.x-1];o instanceof Oe||(n=this.chars.rightMid)}let D=u?this.chars.right:"",r=L.repeat(" ",this.width);return this.stylizeLine(n,r,D)}},Pe=class{constructor(){}draw(u){return typeof u=="number"&&YD(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},Oe=class{constructor(u){this.originalCell=u}init(u){let t=this.y,n=this.originalCell.y;this.cellOffset=t-n,this.offset=Es(u.rowHeights,n,this.cellOffset)}draw(u){return u=="top"?this.originalCell.draw(this.offset,this.cellOffset):u=="bottom"?this.originalCell.draw("bottom"):(YD(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+u))}mergeTableOptions(){}};function KD(...e){return e.filter(u=>u!=null).shift()}function et(e,u,t,n){let D=t.split("-");D.length>1?(D[1]=D[1].charAt(0).toUpperCase()+D[1].substr(1),D=D.join(""),n[D]=KD(e[D],e[t],u[D],u[t])):n[t]=KD(e[t],u[t])}function Es(e,u,t){let n=e[u];for(let D=1;D<t;D++)n+=1+e[u+D];return n}function zD(e,u){return e+u+1}var Bs=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];ou.exports=ut;ou.exports.ColSpanCell=Pe;ou.exports.RowSpanCell=Oe});var QD=A((F0,ZD)=>{var{warn:bs,debug:As}=Du(),tt=JD(),{ColSpanCell:ys,RowSpanCell:xs}=tt;(function(){function e(d,l){return d[l]>0?e(d,l+1):l}function u(d){let l={};d.forEach(function(C,h){let p=0;C.forEach(function(g){g.y=h,g.x=h?e(l,p):p;let B=g.rowSpan||1,m=g.colSpan||1;if(B>1)for(let b=0;b<m;b++)l[g.x+b]=B;p=g.x+m}),Object.keys(l).forEach(g=>{l[g]--,l[g]<1&&delete l[g]})})}function t(d){let l=0;return d.forEach(function(C){C.forEach(function(h){l=Math.max(l,h.x+(h.colSpan||1))})}),l}function n(d){return d.length}function D(d,l){let C=d.y,h=d.y-1+(d.rowSpan||1),p=l.y,g=l.y-1+(l.rowSpan||1),B=!(C>g||p>h),m=d.x,b=d.x-1+(d.colSpan||1),k=l.x,se=l.x-1+(l.colSpan||1),S=!(m>se||k>b);return B&&S}function r(d,l,C){let h=Math.min(d.length-1,C),p={x:l,y:C};for(let g=0;g<=h;g++){let B=d[g];for(let m=0;m<B.length;m++)if(D(p,B[m]))return!0}return!1}function o(d,l,C,h){for(let p=C;p<h;p++)if(r(d,p,l))return!1;return!0}function i(d){d.forEach(function(l,C){l.forEach(function(h){for(let p=1;p<h.rowSpan;p++){let g=new xs(h);g.x=h.x,g.y=h.y+p,g.colSpan=h.colSpan,a(g,d[C+p])}})})}function s(d){for(let l=d.length-1;l>=0;l--){let C=d[l];for(let h=0;h<C.length;h++){let p=C[h];for(let g=1;g<p.colSpan;g++){let B=new ys;B.x=p.x+g,B.y=p.y,C.splice(h+1,0,B)}}}}function a(d,l){let C=0;for(;C<l.length&&l[C].x<d.x;)C++;l.splice(C,0,d)}function F(d){let l=n(d),C=t(d);As(`Max rows: ${l}; Max cols: ${C}`);for(let h=0;h<l;h++)for(let p=0;p<C;p++)if(!r(d,p,h)){let g={x:p,y:h,colSpan:1,rowSpan:1};for(p++;p<C&&!r(d,p,h);)g.colSpan++,p++;let B=h+1;for(;B<l&&o(d,B,g.x,g.x+g.colSpan);)g.rowSpan++,B++;let m=new tt(g);m.x=g.x,m.y=g.y,bs(`Missing cell at ${m.y}-${m.x}.`),a(m,d[h])}}function c(d){return d.map(function(l){if(!Array.isArray(l)){let C=Object.keys(l)[0];l=l[C],Array.isArray(l)?(l=l.slice(),l.unshift(C)):l=[C,l]}return l.map(function(C){return new tt(C)})})}function f(d){let l=c(d);return u(l),F(l),i(l),s(l),l}ZD.exports={makeTableLayout:f,layoutTable:u,addRowSpanCells:i,maxWidth:t,fillInTable:F,computeWidths:XD("colSpan","desiredWidth","x",1),computeHeights:XD("rowSpan","desiredHeight","y",1)}})();function XD(e,u,t,n){return function(D,r){let o=[],i=[],s={};r.forEach(function(a){a.forEach(function(F){(F[e]||1)>1?i.push(F):o[F[t]]=Math.max(o[F[t]]||0,F[u]||0,n)})}),D.forEach(function(a,F){typeof a=="number"&&(o[F]=a)});for(let a=i.length-1;a>=0;a--){let F=i[a],c=F[e],f=F[t],d=o[f],l=typeof D[f]=="number"?0:1;if(typeof d=="number")for(let C=1;C<c;C++)d+=1+o[f+C],typeof D[f+C]!="number"&&l++;else d=u==="desiredWidth"?F.desiredWidth-1:1,(!s[f]||s[f]<d)&&(s[f]=d);if(F[u]>d){let C=0;for(;l>0&&F[u]>d;){if(typeof D[f+C]!="number"){let h=Math.round((F[u]-d)/l);d+=h,o[f+C]+=h,l--}C++}}}Object.assign(D,o,s);for(let a=0;a<D.length;a++)D[a]=Math.max(n,D[a]||0)}}});var ur=A((d0,er)=>{var Z=Du(),Rs=Zu(),nt=QD(),iu=class extends Array{constructor(u){super();let t=Rs.mergeOptions(u);if(Object.defineProperty(this,"options",{value:t,enumerable:t.debug}),t.debug){switch(typeof t.debug){case"boolean":Z.setDebugLevel(Z.WARN);break;case"number":Z.setDebugLevel(t.debug);break;case"string":Z.setDebugLevel(parseInt(t.debug,10));break;default:Z.setDebugLevel(Z.WARN),Z.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof t.debug}`)}Object.defineProperty(this,"messages",{get(){return Z.debugMessages()}})}}toString(){let u=this,t=this.options.head&&this.options.head.length;t?(u=[this.options.head],this.length&&u.push.apply(u,this)):this.options.style.head=[];let n=nt.makeTableLayout(u);n.forEach(function(r){r.forEach(function(o){o.mergeTableOptions(this.options,n)},this)},this),nt.computeWidths(this.options.colWidths,n),nt.computeHeights(this.options.rowHeights,n),n.forEach(function(r){r.forEach(function(o){o.init(this.options)},this)},this);let D=[];for(let r=0;r<n.length;r++){let o=n[r],i=this.options.rowHeights[r];(r===0||!this.options.style.compact||r==1&&t)&&Dt(o,"top",D);for(let s=0;s<i;s++)Dt(o,s,D);r+1==n.length&&Dt(o,"bottom",D)}return D.join(`
|
|
7
7
|
`)}get width(){return this.toString().split(`
|
|
8
|
-
`)[0].length}};iu.reset=()=>Z.reset();function Dt(e,u,t){let n=[];e.forEach(function(r){n.push(r.draw(u))});let D=n.join("");D.length&&t.push(D)}er.exports=iu});var nr=A((f0,tr)=>{tr.exports=ur()});import He from"node:path";import eo from"node:os";import{createReadStream as Yr}from"node:fs";import Jr from"node:readline";var Eu=200;async function xt(e){let u=Yr(e,{encoding:"utf8"}),t=Jr.createInterface({input:u,crlfDelay:1/0}),n=[],D=[],r=[];for await(let o of t){if(!o.trim())continue;let i;try{i=JSON.parse(o)}catch{continue}if(!(!i||typeof i!="object")){if(i.uuid&&r.push([i.uuid,i.parentUuid??null]),i.type==="assistant"){let s=Xr(i,e);s&&n.push(s)}else if(i.type==="user"){let s=Zr(i,e);s&&D.push(s)}}}return{assistant:n,user:D,parentLinks:r}}function Xr(e,u){let t=e.message;if(!t)return null;let n=t.usage;if(!n)return null;let D=t.model??"";if(!D||D==="<synthetic>")return null;let r=t.id??e.uuid??"";if(!r&&!e.requestId)return null;let o=n.cache_creation,i=Array.isArray(t.content)?t.content:[],s=[],a=!1,F="";for(let c of i)c.type==="tool_use"&&typeof c.name=="string"?s.push(c.name):c.type==="thinking"?a=!0:c.type==="text"&&typeof c.text=="string"&&!F&&(F=c.text.slice(0,Eu));return{type:"assistant",source:"claude",uuid:e.uuid??r,parentUuid:e.parentUuid??null,timestamp:e.timestamp??new Date().toISOString(),sessionId:e.sessionId??"",requestId:e.requestId??"",cwd:e.cwd??"",gitBranch:e.gitBranch,version:e.version,model:D,messageId:r,usage:{input_tokens:Number(n.input_tokens)||0,output_tokens:Number(n.output_tokens)||0,cache_creation_input_tokens:Number(n.cache_creation_input_tokens)||0,cache_read_input_tokens:Number(n.cache_read_input_tokens)||0,cache_creation_5m:Number(o?.ephemeral_5m_input_tokens)||0,cache_creation_1h:Number(o?.ephemeral_1h_input_tokens)||0},toolNames:s,hasThinking:a,textPreview:F,filePath:u,isSidechain:e.isSidechain===!0?!0:void 0}}function Zr(e,u){if(!e.uuid)return null;let t=e.message,n="";if(t){let o=t.content;if(typeof o=="string")n=o.slice(0,Eu);else if(Array.isArray(o)){for(let i of o)if(i.type==="text"&&typeof i.text=="string"){n=i.text.slice(0,Eu);break}}}let D=e.isSidechain===!0,r=D||!!n&&Qr(n);return{type:"user",source:"claude",uuid:e.uuid,parentUuid:e.parentUuid??null,timestamp:e.timestamp??new Date().toISOString(),sessionId:e.sessionId??"",cwd:e.cwd??"",textPreview:n,isSynthetic:r,isSidechain:D?!0:void 0,filePath:u}}function Qr(e){let u=e.trimStart();return!!(u.startsWith("Base directory for this skill:")||u.startsWith("<system-reminder>")||u.startsWith("Caveat: The messages below were generated by")||u.startsWith("<task-notification>"))}var U={"claude-fable-5":{input:10,output:50,cacheCreation5m:12.5,cacheCreation1h:20,cacheRead:1},"claude-opus-4-8":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-7":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-6":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-5":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-sonnet-4-6":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-sonnet-4-5":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-haiku-4-5":{input:1,output:5,cacheCreation5m:1.25,cacheCreation1h:2,cacheRead:.1},"claude-haiku-3-5":{input:.8,output:4,cacheCreation5m:1,cacheCreation1h:1.6,cacheRead:.08},"claude-opus-4-1":{input:15,output:75,cacheCreation5m:18.75,cacheCreation1h:30,cacheRead:1.5},"claude-opus-4":{input:15,output:75,cacheCreation5m:18.75,cacheCreation1h:30,cacheRead:1.5},"claude-sonnet-4":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-sonnet-3-7":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-haiku-3":{input:.25,output:1.25,cacheCreation5m:.3,cacheCreation1h:.5,cacheRead:.03}},Rt={fable:U["claude-fable-5"],opus:U["claude-opus-4-8"],sonnet:U["claude-sonnet-4-6"],haiku:U["claude-haiku-4-5"]};function Be(e,u){if(!u)return{input:0,output:0,cacheCreation5m:0,cacheCreation1h:0,cacheRead:0,total:0,saved:0};let t=e.input_tokens/1e6*u.input,n=e.output_tokens/1e6*u.output,D=e.cache_creation_5m/1e6*u.cacheCreation5m,r=e.cache_creation_1h/1e6*u.cacheCreation1h;D+r===0&&e.cache_creation_input_tokens>0&&(D=e.cache_creation_input_tokens/1e6*u.cacheCreation5m);let o=e.cache_read_input_tokens/1e6*u.cacheRead,i=t+n+D+r+o,s=e.cache_read_input_tokens/1e6*(u.input-u.cacheRead);return{input:t,output:n,cacheCreation5m:D,cacheCreation1h:r,cacheRead:o,total:i,saved:s}}function wt(e){return e.replace(/\b\w/g,u=>u.toUpperCase())}function kt(e){if(!e)return"(unknown)";let u=e.replace(/-(\d{8})$/,"").replace(/^(vertex_ai|bedrock|anthropic)\//,"");u=u.replace(/^claude-/,"");let t=u.split("-");if(t.length>=2){let n=t[0],D=t.slice(1).join(".");return wt(n)+" "+D}return wt(u.replace(/-/g," "))}var uo=/-\d{8}$/,to=/^(vertex_ai|bedrock|anthropic)\//;function no(e){if(!e)return{pricing:null,matchType:"none",matchedKey:null};if(U[e])return{pricing:U[e],matchType:"exact",matchedKey:e};let u=e.replace(uo,"");if(U[u])return{pricing:U[u],matchType:"date-stripped",matchedKey:u};let t=u.replace(to,"");if(U[t])return{pricing:U[t],matchType:"prefix-stripped",matchedKey:t};for(let n of["fable","opus","sonnet","haiku"])if(e.toLowerCase().includes(n))return{pricing:Rt[n],matchType:"family-fallback",matchedKey:`claude-${n}-(latest)`};return{pricing:null,matchType:"none",matchedKey:null}}function Do(){let e=eo.homedir(),u=[He.join(e,".claude","projects"),He.join(e,".config","claude","projects")];return process.env.CCGAUGE_CONFIG_DIR&&u.push(He.join(process.env.CCGAUGE_CONFIG_DIR,"projects")),process.env.CLAUDE_CONFIG_DIR&&u.push(He.join(process.env.CLAUDE_CONFIG_DIR,"projects")),Array.from(new Set(u))}var St={id:"claude",displayName:{en:"Claude",zh:"Claude"},shortLabel:"C",color:{fg:"#b45309",bg:"#fef3c7"},logoSrc:"/claude-logo.webp",parserVersion:"claude-v5-task-notification-synthetic",capabilities:{hasCacheCreation:!0,hasReasoningTokens:!1,blockWindowMs:300*60*1e3},getDirs:Do,shouldSkipDir:e=>e==="tool-results"||e==="memory",parseFile:async e=>await xt(e),resolvePricing:no,shortenModel:kt,costFromUsage:Be,costFootnoteKey:null};import Ve from"node:path";import fo from"node:os";import{createReadStream as ro,promises as oo}from"node:fs";import io from"node:readline";var Bu=200;async function so(e){try{let u=await oo.stat(e);return new Date(u.mtimeMs).toISOString()}catch{return new Date().toISOString()}}function M(e){return typeof e=="string"?e:""}function ne(e){let u=Number(e);return Number.isFinite(u)?u:0}function bu(e){let u=e.message;if(typeof u=="string")return u;let t=e.content;if(typeof t=="string")return t;if(Array.isArray(t))for(let n of t){let D=n?.type;if((D==="input_text"||D==="output_text"||D==="text")&&typeof n.text=="string")return n.text}return""}async function Tt(e){let u=ro(e,{encoding:"utf8"}),t=io.createInterface({input:u,crlfDelay:1/0}),n=[],D=[],r=[],o="",i,s="",a=0,F=0,c=null,d=await so(e),l={turnId:null,cwd:"",model:"gpt-unknown",userUuid:null,toolNames:[],hasThinking:!1,pendingTextPreview:""};for await(let C of t){if(!C.trim())continue;let h;try{h=JSON.parse(C)}catch{continue}if(!h||typeof h!="object"||!h.type)continue;let p=h.payload??{},g=M(h.timestamp),B=g||d;if(g&&(d=g),h.type==="session_meta"){o=M(p.id),s=M(p.cwd),i=M(p.cli_version)||void 0;let m=M(p.timestamp);m&&(d=m),l.cwd||(l.cwd=s);continue}if(h.type==="turn_context"){l.turnId=M(p.turn_id)||l.turnId,l.cwd=M(p.cwd)||s;let m=M(p.model);m&&(l.model=m);let b=M(p.effort);b&&(l.effort=b),l.toolNames=[],l.hasThinking=!1,l.pendingTextPreview="";continue}if(h.type==="event_msg"){let m=M(p.type);if(m==="user_message"){let b=bu(p);if(!b)continue;let k=`${o}::u${a++}`;D.push({type:"user",source:"codex",uuid:k,parentUuid:null,timestamp:B,sessionId:o,cwd:l.cwd||s,textPreview:b.slice(0,Bu),filePath:e}),r.push([k,null]),l.userUuid=k;continue}if(m==="agent_message"){let b=bu(p);b&&!l.pendingTextPreview&&(l.pendingTextPreview=b.slice(0,Bu));continue}if(m==="agent_reasoning"){l.hasThinking=!0;continue}if(m==="token_count"){let b=p.info;if(!b)continue;let k=b.total_token_usage,se=b.last_token_usage,S=k?{input:ne(k.input_tokens),cached:ne(k.cached_input_tokens),output:ne(k.output_tokens),reasoning:ne(k.reasoning_output_tokens)}:null,ue,K,te,z;if(S){if(c===null?(ue=S.input,K=S.cached,te=S.output,z=S.reasoning):(ue=Math.max(0,S.input-c.input),K=Math.max(0,S.cached-c.cached),te=Math.max(0,S.output-c.output),z=Math.max(0,S.reasoning-c.reasoning)),ue===0&&K===0&&te===0&&z===0)continue;c===null?c={...S}:c={input:Math.max(c.input,S.input),cached:Math.max(c.cached,S.cached),output:Math.max(c.output,S.output),reasoning:Math.max(c.reasoning,S.reasoning)}}else if(se){if(ue=ne(se.input_tokens),K=ne(se.cached_input_tokens),te=ne(se.output_tokens),z=ne(se.reasoning_output_tokens),ue===0&&K===0&&te===0&&z===0)continue;c===null?c={input:ue,cached:K,output:te,reasoning:z}:c={input:c.input+ue,cached:c.cached+K,output:c.output+te,reasoning:c.reasoning+z}}else continue;let Bt=`${o}::a${F++}`,bt=l.turnId?`${l.turnId}::a${F}`:`${o}::a${F}`;n.push({type:"assistant",source:"codex",uuid:Bt,parentUuid:l.userUuid,timestamp:B,sessionId:o,requestId:bt,cwd:l.cwd||s,version:i,model:l.model||"gpt-unknown",messageId:bt,usage:{input_tokens:Math.max(0,ue-K),output_tokens:te+z,cache_creation_input_tokens:0,cache_read_input_tokens:K,cache_creation_5m:0,cache_creation_1h:0,reasoning_tokens:z},toolNames:[...l.toolNames],hasThinking:l.hasThinking,textPreview:l.pendingTextPreview,filePath:e,effort:l.effort}),r.push([Bt,l.userUuid]),l.toolNames=[],l.hasThinking=!1,l.pendingTextPreview="";continue}continue}if(h.type==="response_item"){let m=M(p.type);if(m==="function_call"||m==="custom_tool_call"){let b=M(p.name);b&&l.toolNames.push(b);continue}if(m==="reasoning"){l.hasThinking=!0;continue}if(m==="message"){if(M(p.role)==="assistant"){let k=bu(p);k&&!l.pendingTextPreview&&(l.pendingTextPreview=k.slice(0,Bu))}continue}continue}}return{assistant:n,user:D,parentLinks:r}}var De={"gpt-5":{input:1.25,output:10,cacheRead:.13,cacheCreation5m:0,cacheCreation1h:0},"gpt-5-mini":{input:.25,output:2,cacheRead:.025,cacheCreation5m:0,cacheCreation1h:0},"gpt-5-nano":{input:.05,output:.4,cacheRead:.005,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.4":{input:1.25,output:10,cacheRead:.13,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.5":{input:1.25,output:10,cacheRead:.13,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.5-mini":{input:.25,output:2,cacheRead:.025,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.5-nano":{input:.05,output:.4,cacheRead:.005,cacheCreation5m:0,cacheCreation1h:0},"gpt-4.1":{input:2,output:8,cacheRead:.5,cacheCreation5m:0,cacheCreation1h:0},"gpt-4.1-mini":{input:.4,output:1.6,cacheRead:.1,cacheCreation5m:0,cacheCreation1h:0},o3:{input:2,output:8,cacheRead:.5,cacheCreation5m:0,cacheCreation1h:0},"o4-mini":{input:1.1,output:4.4,cacheRead:.275,cacheCreation5m:0,cacheCreation1h:0}},_t={gpt:De["gpt-5"],o:De.o3},ao=/-\d{8}$/,co=/^(openai)\//;function vt(e){if(!e)return{pricing:null,matchType:"none",matchedKey:null};if(De[e])return{pricing:De[e],matchType:"exact",matchedKey:e};let u=e.replace(ao,"");if(De[u])return{pricing:De[u],matchType:"date-stripped",matchedKey:u};let t=u.replace(co,"");if(De[t])return{pricing:De[t],matchType:"prefix-stripped",matchedKey:t};let n=e.toLowerCase();return n.startsWith("gpt-")||n==="gpt"?{pricing:_t.gpt,matchType:"family-fallback",matchedKey:"gpt-(latest)"}:/^o\d/.test(n)?{pricing:_t.o,matchType:"family-fallback",matchedKey:"o-(latest)"}:{pricing:null,matchType:"none",matchedKey:null}}function lo(e){return e.replace(/\b\w/g,u=>u.toUpperCase())}var Fo={mini:"Mini",nano:"Nano",pro:"Pro",turbo:"Turbo",preview:"Preview"};function It(e){if(!e)return"(unknown)";let u=e.replace(/^openai\//,"");return u.toLowerCase().startsWith("gpt-")?"GPT-"+u.slice(4).split("-").map(D=>Fo[D.toLowerCase()]??D).join(" "):u.toLowerCase().startsWith("o")?u.toUpperCase():lo(u.replace(/-/g," "))}function po(){let e=fo.homedir(),u=[Ve.join(e,".codex","sessions"),Ve.join(e,".codex","archived_sessions")];return process.env.CCGAUGE_CODEX_DIR&&u.push(process.env.CCGAUGE_CODEX_DIR),process.env.CODEX_HOME&&(u.push(Ve.join(process.env.CODEX_HOME,"sessions")),u.push(Ve.join(process.env.CODEX_HOME,"archived_sessions"))),Array.from(new Set(u))}var Mt={id:"codex",displayName:{en:"Codex",zh:"Codex"},shortLabel:"X",color:{fg:"#047857",bg:"#d1fae5"},logoSrc:"/codex-logo.webp",parserVersion:"codex-v5-last-total-prev",capabilities:{hasCacheCreation:!1,hasReasoningTokens:!0,blockWindowMs:300*60*1e3},getDirs:po,shouldSkipDir:()=>!1,parseFile:Tt,resolvePricing:vt,shortenModel:It,costFromUsage:Be,costFootnoteKey:"cost.footnote.codex"};var Pt={claude:St,codex:Mt},Au=["claude","codex"];function re(e){return Pt[e]}function yu(){return Au.map(e=>Pt[e])}function Ot(e){return typeof e=="string"&&(e==="claude"||e==="codex")}import{promises as be,watch as bo}from"node:fs";import Vt from"node:path";function ho(e){let u=`${e.source}:`;return e.messageId&&e.requestId?`${u}${e.messageId}::${e.requestId}`:e.messageId?`${u}mid:${e.messageId}`:e.requestId?`${u}req:${e.requestId}`:`${u}uuid:${e.uuid}`}function Lt(e){let u=new Map;for(let t of e){let n=ho(t),D=u.get(n);if(!D){u.set(n,t);continue}t.timestamp<D.timestamp&&u.set(n,t)}return Array.from(u.values())}import{promises as Ke}from"node:fs";import xu from"node:path";import Co from"node:os";var ze=2,Fe="default";function go(){return process.env.CCGAUGE_STATE_DIR?process.env.CCGAUGE_STATE_DIR:xu.join(Co.homedir(),".ccgauge")}function Nt(e){let u=e===Fe?`index-v${ze}.json`:`index-${e}-v${ze}.json`;return xu.join(go(),"cache",u)}async function $t(e=Fe){let u=Nt(e);try{let t=await Ke.readFile(u,"utf8"),n=JSON.parse(t);return n.schemaVersion!==ze||!Array.isArray(n.files)?null:n}catch{return null}}async function Ut(e,u=Fe){let t=Nt(u),n=xu.dirname(t);await Ke.mkdir(n,{recursive:!0});let D={schemaVersion:ze,savedAt:e.savedAt,files:e.files},r=`${t}.tmp-${process.pid}`;await Ke.writeFile(r,JSON.stringify(D)),await Ke.rename(r,t)}var Wt=/[\\/]([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[\\/]subagents[\\/](?:[^\\/]+[\\/])*agent-[^\\/]+\.jsonl$/i,mo=/[\\/]subagents[\\/]workflows[\\/]/i;function Eo(e){let u=Wt.exec(e);return u?u[1]:null}function jt(e){return Wt.test(e)?mo.test(e)?"workflow":"task":null}function Gt({assistantRecords:e,userRecords:u,parentMap:t}){let n=new Map;for(let o of e){if(o.isSidechain||!o.sessionId)continue;let i=n.get(o.sessionId);i||(i=[],n.set(o.sessionId,i)),i.push(o)}for(let o of n.values())o.sort((i,s)=>i.timestamp<s.timestamp?-1:i.timestamp>s.timestamp?1:0);let D=new Map;for(let o of u){if(!o.isSidechain)continue;let i=D.get(o.filePath);(!i||o.timestamp<i.timestamp)&&D.set(o.filePath,o)}let r={subagentFiles:0,relinked:0,orphans:0,alreadyLinked:0};for(let[o,i]of D){let s=Eo(o);if(!s)continue;r.subagentFiles+=1;let a=t[i.uuid];if(a!=null){r.alreadyLinked+=1;continue}let F=n.get(s);if(!F||F.length===0){r.orphans+=1;continue}let c=i.timestamp,f;for(let d=F.length-1;d>=0;d-=1)if(F[d].timestamp<=c){f=F[d];break}f||(f=F[0]),t[i.uuid]=f.uuid,r.relinked+=1}return r}import{homedir as Bo}from"node:os";function qt(e){let u=Bo();if(!u)return e;let t=new Set([u]);process.platform==="win32"&&(t.add(u.replace(/\\/g,"/")),t.add(u.replace(/\\/g,"\\\\")),t.add("\\\\?\\"+u),t.add("\\\\?\\"+u.replace(/\\/g,"/")));let n=e;for(let D of t){let r=D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(r,"g"),"~")}return n}var Ao=200,yo=100,xo=3e4,Ro=2e3,wo=8,Ru=20,wu=class{cacheName;files=new Map;snapshot=null;watchers=new Map;pollTimer=null;snapshotRebuildTimer=null;persistTimer=null;fileDebouncers=new Map;initPromise=null;isIndexing=!1;lastIndexedAt=null;indexDurationMs=null;existingDirs=[];dirToProvider=new Map;errors=[];loadedFromDisk=!1;lastWorkStart=null;rescanPromise=null;mutationTail=Promise.resolve();constructor(u=Fe){this.cacheName=u}runExclusive(u){let t=this.mutationTail.then(u,u);return this.mutationTail=t.then(()=>{},()=>{}),t}init(){return this.initPromise||(this.initPromise=this.doInit()),this.initPromise}async doInit(){let u=Date.now();this.isIndexing=!0,this.lastWorkStart=u;try{await this.detectProviderDirs();let t=await $t(this.cacheName);this.loadedFromDisk=t!==null;let n=new Map;if(t)for(let D of t.files)n.set(D.filePath,D);await this.runExclusive(async()=>{await this.fullScan(n),this.rebuildSnapshotNow(),this.indexDurationMs=Date.now()-u,this.lastIndexedAt=new Date().toISOString(),this.schedulePersist()}),this.syncWatchersToDirs(),this.setupPolling()}finally{this.isIndexing=!1}}async detectProviderDirs(){let u=new Map,t=[];for(let r of yu())for(let o of r.getDirs())await ko(o)&&(u.has(o)||(u.set(o,r),t.push(o)));let n=[],D=[];for(let r of u.keys())this.dirToProvider.has(r)||n.push(r);for(let r of this.dirToProvider.keys())u.has(r)||D.push(r);return this.dirToProvider=u,this.existingDirs=t,{added:n,removed:D}}async fullScan(u){let t=[];for(let[D,r]of this.dirToProvider){let o=await Ht(D,r);for(let i of o)t.push({file:i,provider:r})}let n=new Set(t.map(D=>D.file));await Promise.all(t.map(async({file:D,provider:r})=>{try{let o=await be.stat(D),i=u.get(D);if(i&&i.source===r.id&&i.parserVersion===r.parserVersion&&i.mtimeMs===o.mtimeMs&&i.size===o.size){this.files.set(D,{source:r.id,parserVersion:r.parserVersion,mtimeMs:o.mtimeMs,size:o.size,assistantRecords:i.assistantRecords,userRecords:i.userRecords,parentLinks:i.parentLinks});return}let s=await r.parseFile(D);this.files.set(D,{source:r.id,parserVersion:r.parserVersion,mtimeMs:o.mtimeMs,size:o.size,assistantRecords:s.assistant,userRecords:s.user,parentLinks:s.parentLinks})}catch(o){this.recordError(`parse ${D}: ${o.message}`)}}));for(let D of Array.from(this.files.keys()))n.has(D)||this.files.delete(D)}syncWatchersToDirs(){for(let[u,t]of this.watchers)if(!this.dirToProvider.has(u)){try{t.close()}catch{}this.watchers.delete(u)}for(let[u,t]of this.dirToProvider)if(!this.watchers.has(u))try{let n=bo(u,{recursive:!0},(D,r)=>{if(!r||typeof r!="string"||!r.endsWith(".jsonl"))return;let o=Vt.join(u,r);this.scheduleFileReconcile(o,t)});n.on("error",D=>{this.recordError(`watcher ${u}: ${D.message}`)}),this.watchers.set(u,n)}catch(n){this.recordError(`watch ${u}: ${n.message}`)}}setupPolling(){this.pollTimer&&clearInterval(this.pollTimer);let u=this.cacheName==="mcp",t=process.env.CCGAUGE_POLL_FALLBACK;(t==="1"||t!=="0"&&!u)&&(this.pollTimer=setInterval(()=>{this.pollOnce().catch(D=>this.recordError(`poll: ${D.message}`))},xo),this.pollTimer.unref?.())}async pollOnce(){await this.runExclusive(async()=>{let u=Date.now(),t=await this.detectProviderDirs(),n=t.added.length>0||t.removed.length>0;n&&this.syncWatchersToDirs();let D=[];for(let[o,i]of this.dirToProvider){let s=await Ht(o,i);for(let a of s)D.push({file:a,provider:i})}let r=new Set(D.map(o=>o.file));await Promise.all(D.map(async({file:o,provider:i})=>{try{let s=await be.stat(o),a=this.files.get(o);if(a&&a.mtimeMs===s.mtimeMs&&a.size===s.size)return;let F=await i.parseFile(o);this.files.set(o,{source:i.id,parserVersion:i.parserVersion,mtimeMs:s.mtimeMs,size:s.size,assistantRecords:F.assistant,userRecords:F.user,parentLinks:F.parentLinks}),n=!0}catch(s){this.recordError(`poll-parse ${o}: ${s.message}`)}}));for(let o of Array.from(this.files.keys()))r.has(o)||(this.files.delete(o),n=!0);n&&(this.lastWorkStart=u,this.scheduleSnapshotRebuild(),this.schedulePersist())})}scheduleFileReconcile(u,t){let n=this.fileDebouncers.get(u);n&&clearTimeout(n);let D=setTimeout(()=>{this.fileDebouncers.delete(u),this.reconcileFile(u,t).catch(r=>this.recordError(`reconcile ${u}: ${r.message}`))},Ao);D.unref?.(),this.fileDebouncers.set(u,D)}async reconcileFile(u,t){await this.runExclusive(async()=>{let n=Date.now(),D=null;try{D=await be.stat(u)}catch{}if(!D||!D.isFile()){this.files.has(u)&&(this.files.delete(u),this.lastWorkStart=n,this.scheduleSnapshotRebuild(),this.schedulePersist());return}let r=this.files.get(u);if(!(r&&r.mtimeMs===D.mtimeMs&&r.size===D.size))try{let o=await t.parseFile(u);this.files.set(u,{source:t.id,parserVersion:t.parserVersion,mtimeMs:D.mtimeMs,size:D.size,assistantRecords:o.assistant,userRecords:o.user,parentLinks:o.parentLinks}),this.lastWorkStart=n,this.scheduleSnapshotRebuild(),this.schedulePersist()}catch(o){this.recordError(`parse ${u}: ${o.message}`)}})}scheduleSnapshotRebuild(){this.snapshotRebuildTimer&&clearTimeout(this.snapshotRebuildTimer),this.snapshotRebuildTimer=setTimeout(()=>{this.snapshotRebuildTimer=null,this.rebuildSnapshotNow()},yo),this.snapshotRebuildTimer.unref?.()}rebuildSnapshotNow(){let u=Date.now(),t=this.lastWorkStart??u,n=[],D=[],r={},o=0,i={claude:{source:"claude",filesScanned:0,recordsParsed:0,assistantRecords:0,scannedDirs:[]},codex:{source:"codex",filesScanned:0,recordsParsed:0,assistantRecords:0,scannedDirs:[]}};for(let[c,f]of this.dirToProvider)i[f.id].scannedDirs.push(c);for(let c of this.files.values()){n.push(...c.assistantRecords),D.push(...c.userRecords);for(let[f,d]of c.parentLinks)r[f]=d;o+=c.assistantRecords.length+c.userRecords.length,i[c.source].filesScanned+=1,i[c.source].recordsParsed+=c.assistantRecords.length+c.userRecords.length}let s=Lt(n).sort((c,f)=>c.timestamp.localeCompare(f.timestamp)),a=So(D).sort((c,f)=>c.timestamp.localeCompare(f.timestamp));Gt({assistantRecords:s,userRecords:a,parentMap:r});for(let c of s)c.isSidechain&&(c.isWorkflowSubagent=jt(c.filePath)==="workflow");for(let c of s)i[c.source].assistantRecords+=1;let F={filesScanned:this.files.size,recordsParsed:o,assistantRecords:s.length,durationMs:Date.now()-t,scannedDirs:this.existingDirs};this.snapshot={records:s,userRecords:a,parentMap:r,stats:F,bySource:Object.values(i)},this.lastWorkStart=null}getSnapshot(){if(!this.snapshot)throw new Error("Indexer not initialized \u2014 call init() first.");return this.snapshot}async forceRescan(){let u=!this.initPromise;if(await this.init(),u)return this.snapshot;if(this.rescanPromise)return this.rescanPromise;this.rescanPromise=this.runRescan();try{return await this.rescanPromise}finally{this.rescanPromise=null}}async runRescan(){this.isIndexing=!0;try{return await this.runExclusive(async()=>{let u=Date.now();return this.lastWorkStart=u,this.snapshotRebuildTimer&&(clearTimeout(this.snapshotRebuildTimer),this.snapshotRebuildTimer=null),this.persistTimer&&(clearTimeout(this.persistTimer),this.persistTimer=null),this.files.clear(),await this.detectProviderDirs(),await this.fullScan(new Map),this.rebuildSnapshotNow(),this.indexDurationMs=Date.now()-u,this.lastIndexedAt=new Date().toISOString(),this.syncWatchersToDirs(),this.schedulePersist(),this.snapshot})}finally{this.isIndexing=!1}}getStatus(){let u=this.snapshot;return{initialized:u!==null,isIndexing:this.isIndexing,lastIndexedAt:this.lastIndexedAt,indexDurationMs:this.indexDurationMs,filesIndexed:this.files.size,recordsIndexed:u?.stats.assistantRecords??0,bySource:u?.bySource??[],watchers:this.watchers.size,errors:this.errors.slice(-Ru),pendingReconciles:this.fileDebouncers.size,loadedFromDisk:this.loadedFromDisk}}schedulePersist(){this.persistTimer&&clearTimeout(this.persistTimer),this.persistTimer=setTimeout(()=>{this.persistTimer=null;let u=[];for(let[t,n]of this.files)u.push({filePath:t,source:n.source,parserVersion:n.parserVersion,mtimeMs:n.mtimeMs,size:n.size,assistantRecords:n.assistantRecords,userRecords:n.userRecords,parentLinks:n.parentLinks});Ut({savedAt:new Date().toISOString(),files:u},this.cacheName).catch(t=>this.recordError(`persist: ${t.message}`))},Ro),this.persistTimer.unref?.()}recordError(u){let t=`${new Date().toISOString()} ${qt(u)}`;this.errors.push(t),this.errors.length>Ru*2&&this.errors.splice(0,this.errors.length-Ru),process.env.CCGAUGE_DEBUG&&console.error(`[ccgauge:indexer] ${new Date().toISOString()} ${u}`)}disposeWatchers(){for(let u of this.watchers.values())try{u.close()}catch{}this.watchers.clear()}dispose(){this.disposeWatchers(),this.pollTimer&&clearInterval(this.pollTimer),this.snapshotRebuildTimer&&clearTimeout(this.snapshotRebuildTimer),this.persistTimer&&clearTimeout(this.persistTimer);for(let u of this.fileDebouncers.values())clearTimeout(u);this.fileDebouncers.clear()}};async function ko(e){try{return(await be.stat(e)).isDirectory()}catch{return!1}}async function Ht(e,u){let t=[];async function n(D,r){if(r>wo)return;let o;try{o=await be.readdir(D,{withFileTypes:!0})}catch{return}for(let i of o){let s=Vt.join(D,i.name);if(i.isDirectory()){if(u.shouldSkipDir(i.name))continue;await n(s,r+1)}else i.isFile()&&i.name.endsWith(".jsonl")&&t.push(s)}}return await n(e,0),t}function So(e){let u=new Set;return e.filter(t=>{let n=t.uuid;return n?u.has(n)?!1:(u.add(n),!0):!0})}function To(){return globalThis.__ccgaugeIndexers||(globalThis.__ccgaugeIndexers=new Map),globalThis.__ccgaugeIndexers}function Kt(e=Fe){let u=To(),t=u.get(e);return t||(t=new wu(e),u.set(e,t)),t}async function zt(e={}){let u=Kt();return e.force?u.forceRescan():(await u.init(),u.getSnapshot())}function oe(e){let u=re(e.source),{pricing:t}=u.resolvePricing(e.model);return u.costFromUsage(e.usage,t)}function Yt(e,u){return new Intl.NumberFormat("en-US",{maximumFractionDigits:u?.maxFrac??0}).format(e)}function v(e,u="en"){return Number.isFinite(e)?u==="zh"?e>=1e8?(e/1e8).toFixed(2)+"\u4EBF":e>=1e4?(e/1e4).toFixed(1)+"\u4E07":Yt(e):e>=1e9?(e/1e9).toFixed(2)+"B":e>=1e6?(e/1e6).toFixed(2)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":Yt(e):"0"}function N(e,u){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:u?.minFrac??2,maximumFractionDigits:u?.maxFrac??2}).format(e)}function de(e,u=1){return Number.isFinite(e)?`${(e*100).toFixed(u)}%`:"0%"}function Jt(e){if(e<1e3)return`${e}ms`;let u=Math.floor(e/1e3);if(u<60)return`${u}s`;let t=Math.floor(u/60);if(t<60){let r=u%60;return r?`${t}m ${r}s`:`${t}m`}let n=Math.floor(t/60),D=t%60;return D?`${n}h ${D}m`:`${n}h`}function Ae(e){if(!e)return"(unknown)";let t=e.replace(/[/\\]+$/,"").split(/[/\\]+/);return t[t.length-1]||e}import{readFileSync as _o,statSync as vo}from"node:fs";import{basename as Xt}from"node:path";var Zt=new Map,Io=/^(.+?)[/\\]\.git[/\\]worktrees[/\\]([^/\\]+)[/\\]?$/,Mo=/^(.+?)[/\\](?:\.git|\.claude)[/\\]worktrees[/\\]([^/\\]+)(?:[/\\].*)?$/;function Po(e){let u=Ae(e);if(!e)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let t=Mo.exec(e);if(t){let n=t[1],D=t[2],r=Xt(n)||n;return{label:`${r} (${D})`,isWorktree:!0,mainName:r,worktreeName:D,canonicalCwd:n}}try{let n=`${e}/.git`;if(!vo(n).isFile())return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let o=_o(n,"utf8").trim().split(/\r?\n/,1)[0]??"",i=/^gitdir:\s*(.+)$/.exec(o);if(!i)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let s=i[1].trim(),a=Io.exec(s);if(!a)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let F=a[1],c=a[2],f=Xt(F)||F;return{label:`${f} (${c})`,isWorktree:!0,mainName:f,worktreeName:c,canonicalCwd:F}}catch{return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e}}}function Qt(e){let u=Zt.get(e);if(u)return u.label;let t=Po(e);return Zt.set(e,t),t.label}var Oo=["hour","day","week","month"];function en(e){return typeof e=="string"&&Oo.includes(e)}function ku(e,u){let t=new Date(e),n=t.getFullYear(),D=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0");if(u==="hour")return{key:`${n}-${D}-${r}T${o}`,label:`${D}/${r} ${o}:00`};if(u==="day")return{key:`${n}-${D}-${r}`,label:`${D}/${r}`};if(u==="week"){let i=new Date(t),s=i.getDay()||7;i.setDate(i.getDate()-s+1);let a=String(i.getMonth()+1).padStart(2,"0"),F=String(i.getDate()).padStart(2,"0");return{key:`${i.getFullYear()}-W${a}${F}`,label:`Wk ${a}/${F}`}}return{key:`${n}-${D}`,label:`${n}-${D}`}}function ye(e){return{source:e.source,fromIso:e.from?.toISOString(),toIso:e.to?.toISOString(),models:e.models&&e.models.length?new Set(e.models):void 0,projects:e.projects&&e.projects.length?new Set(e.projects):void 0}}function xe(e,u){return!(e.source!==u.source||u.fromIso&&e.timestamp<u.fromIso||u.toIso&&e.timestamp>u.toIso||u.models&&!u.models.has(e.model)||u.projects&&!u.projects.has(e.cwd))}function un(e,u,t){let n=new Map,D=ye(t);for(let r of e){if(!xe(r,D))continue;let{key:o,label:i}=ku(r.timestamp,u),s=n.get(o);s||(s=Lo(o,i),n.set(o,s)),No(s,r)}return Array.from(n.values()).sort((r,o)=>r.key.localeCompare(o.key))}function Lo(e,u){return{key:e,label:u,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,requests:0,models:{}}}function No(e,u){let t=oe(u);e.inputTokens+=u.usage.input_tokens,e.outputTokens+=u.usage.output_tokens,e.cacheReadTokens+=u.usage.cache_read_input_tokens,e.cacheCreationTokens+=u.usage.cache_creation_input_tokens,e.totalTokens=e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreationTokens,e.cost+=t.total,e.saved+=t.saved,e.requests+=1;let n=e.models[u.model]??{tokens:0,cost:0,requests:0};n.tokens+=u.usage.input_tokens+u.usage.output_tokens+u.usage.cache_read_input_tokens+u.usage.cache_creation_input_tokens,n.cost+=t.total,n.requests+=1,e.models[u.model]=n}function tn(e,u){let t=new Map,n=ye(u);for(let D of e){if(!xe(D,n))continue;let r=t.get(D.model);if(!r){let{pricing:i,matchType:s}=re(D.source).resolvePricing(D.model);r={model:D.model,source:D.source,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,pricing:i,pricingResolved:s==="exact"||s==="date-stripped"||s==="prefix-stripped"},t.set(D.model,r)}let o=oe(D);r.requests+=1,r.inputTokens+=D.usage.input_tokens,r.outputTokens+=D.usage.output_tokens,r.cacheReadTokens+=D.usage.cache_read_input_tokens,r.cacheCreationTokens+=D.usage.cache_creation_input_tokens,r.totalTokens=r.inputTokens+r.outputTokens+r.cacheReadTokens+r.cacheCreationTokens,r.cost+=o.total,r.saved+=o.saved}return Array.from(t.values()).sort((D,r)=>r.cost-D.cost)}function nn(e,u){let t=new Map,n=new Map,D=ye(u);for(let r of e){if(!xe(r,D))continue;let o=r.cwd||"(unknown)",i=t.get(o);i||(i={source:u.source,cwd:o,projectName:Ae(o),sessions:0,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,firstActivity:r.timestamp,lastActivity:r.timestamp,models:[]},t.set(o,i),n.set(o,new Set)),n.get(o).add(r.sessionId);let s=oe(r);i.requests+=1,i.inputTokens+=r.usage.input_tokens,i.outputTokens+=r.usage.output_tokens,i.cacheReadTokens+=r.usage.cache_read_input_tokens,i.cacheCreationTokens+=r.usage.cache_creation_input_tokens,i.totalTokens=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreationTokens,i.cost+=s.total,i.saved+=s.saved,r.timestamp<i.firstActivity&&(i.firstActivity=r.timestamp),r.timestamp>i.lastActivity&&(i.lastActivity=r.timestamp),i.models.includes(r.model)||i.models.push(r.model)}for(let[r,o]of n){let i=t.get(r);i.sessions=o.size}return Array.from(t.values()).sort((r,o)=>o.cost-r.cost)}function Dn(e,u,t){let n=new Map,D=ye(t);for(let o of e){if(!xe(o,D))continue;let i=o.sessionId||o.uuid,s=n.get(i);s||(s={sessionId:i,source:o.source,cwd:o.cwd,projectName:Ae(o.cwd),projectLabel:Qt(o.cwd),startTime:o.timestamp,endTime:o.timestamp,durationMs:0,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,models:[],modelBreakdown:{}},n.set(i,s));let a=oe(o);s.requests+=1,s.inputTokens+=o.usage.input_tokens,s.outputTokens+=o.usage.output_tokens,s.cacheReadTokens+=o.usage.cache_read_input_tokens,s.cacheCreationTokens+=o.usage.cache_creation_input_tokens,s.totalTokens=s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreationTokens,s.cost+=a.total,s.saved+=a.saved,o.timestamp<s.startTime&&(s.startTime=o.timestamp),o.timestamp>s.endTime&&(s.endTime=o.timestamp),s.models.includes(o.model)||s.models.push(o.model);let F=s.modelBreakdown[o.model]??{tokens:0,cost:0,requests:0};F.tokens+=o.usage.input_tokens+o.usage.output_tokens+o.usage.cache_read_input_tokens+o.usage.cache_creation_input_tokens,F.cost+=a.total,F.requests+=1,s.modelBreakdown[o.model]=F}let r=new Map;for(let o of u){let i=r.get(o.sessionId);(!i||o.timestamp<i.timestamp)&&r.set(o.sessionId,o)}for(let o of n.values()){o.durationMs=Math.max(0,new Date(o.endTime).getTime()-new Date(o.startTime).getTime());let i=r.get(o.sessionId);i&&i.textPreview&&(o.firstUserMessage=i.textPreview,o.title=i.textPreview.slice(0,80))}return Array.from(n.values()).sort((o,i)=>i.endTime.localeCompare(o.endTime))}function rn(e,u){let t=0,n=0,D=0,r=0,o=0,i=0,s=0,a=ye(u);for(let F of e){if(!xe(F,a))continue;let c=oe(F);t+=F.usage.input_tokens,n+=F.usage.output_tokens,D+=F.usage.cache_read_input_tokens,r+=F.usage.cache_creation_input_tokens,o+=c.total,i+=c.saved,s+=1}return{inputTokens:t,outputTokens:n,cacheReadTokens:D,cacheCreationTokens:r,totalTokens:t+n+D+r,cost:o,saved:i,requests:s}}var $o=["1d","7d","30d","90d","all","custom"];function on(e){return typeof e=="string"&&$o.includes(e)}function sn(e){let u=new Date;if(e==="all"||e==="custom")return{};if(e==="1d")return{from:new Date(u.getFullYear(),u.getMonth(),u.getDate())};let t=e.match(/^(\d+)([dwm])$/);if(!t)return{};let n=parseInt(t[1],10),D=t[2],r=new Date(u);return D==="d"?r.setDate(r.getDate()-n):D==="w"?r.setDate(r.getDate()-n*7):D==="m"&&r.setMonth(r.getMonth()-n),{from:r}}function Uo(e,u,t){let n=new Map;for(let i of u)i.isSynthetic||i.textPreview&&i.textPreview.trim()&&n.set(i.uuid,i.textPreview);let D=new Map,r=new Map;function o(i){let s=[],a=i,F=null,c=0,f=new Set;for(;a&&c++<5e3&&!f.has(a);){f.add(a);let d=r.get(a);if(d){F=d;break}if(s.push(a),n.has(a)){F=a;break}a=t[a]??null}F||(F=i);for(let d of s)r.set(d,F);return F}for(let i of e)D.set(i.uuid,o(i.uuid));return D}function Re(e,u,t){let n=Uo(e,u,t),D=new Map;for(let r of e){let o=n.get(r.uuid)??r.uuid,i=D.get(o);(!i||r.timestamp<i.firstTimestamp)&&D.set(o,{turnId:o,firstTimestamp:r.timestamp,firstModel:r.model,cwd:r.cwd,sessionId:r.sessionId,source:r.source})}return D}import nu from"node:process";function Su({onlyFirst:e=!1}={}){let D="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(D,e?void 0:"g")}var Wo=Su();function Y(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(Wo,"")}var an=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],cn=12288,ln=65510,Fn=[12288,12288,65281,65376,65504,65510];var dn=4352,fn=262141,Tu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Ye=(e,u)=>{let t=0,n=Math.floor(e.length/2)-1;for(;t<=n;){let D=Math.floor((t+n)/2),r=D*2;if(u<e[r])n=D-1;else if(u>e[r+1])t=D+1;else return!0}return!1};var pn=19968,[qo,Ho]=Vo(Tu);function Vo(e){let u=e[0],t=e[1];for(let n=0;n<e.length;n+=2){let D=e[n],r=e[n+1];if(pn>=D&&pn<=r)return[D,r];r-D>t-u&&(u=D,t=r)}return[u,t]}var hn=e=>e<161||e>1114109?!1:Ye(an,e),we=e=>e<cn||e>ln?!1:Ye(Fn,e);var ke=e=>e>=qo&&e<=Ho?!0:e<dn||e>fn?!1:Ye(Tu,e);function Ko(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function J(e,{ambiguousAsWide:u=!1}={}){return Ko(e),we(e)||ke(e)||u&&hn(e)?2:1}var mn=le(gn(),1),zo=new Intl.Segmenter,Yo=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function P(e,u={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:n=!1}=u;if(n||(e=Y(e)),e.length===0)return 0;let D=0,r={ambiguousAsWide:!t};for(let{segment:o}of zo.segment(e)){let i=o.codePointAt(0);if(!(i<=31||i>=127&&i<=159)&&!(i>=8203&&i<=8207||i===65279)&&!(i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071)&&!(i>=55296&&i<=57343)&&!(i>=65024&&i<=65039)&&!Yo.test(o)){if((0,mn.default)().test(o)){D+=2;continue}D+=J(i,r)}}return D}var En=(e=0)=>u=>`\x1B[${u+e}m`,Bn=(e=0)=>u=>`\x1B[${38+e};5;${u}m`,bn=(e=0)=>(u,t,n)=>`\x1B[${38+e};2;${u};${t};${n}m`,y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},iF=Object.keys(y.modifier),Jo=Object.keys(y.color),Xo=Object.keys(y.bgColor),sF=[...Jo,...Xo];function Zo(){let e=new Map;for(let[u,t]of Object.entries(y)){for(let[n,D]of Object.entries(t))y[n]={open:`\x1B[${D[0]}m`,close:`\x1B[${D[1]}m`},t[n]=y[n],e.set(D[0],D[1]);Object.defineProperty(y,u,{value:t,enumerable:!1})}return Object.defineProperty(y,"codes",{value:e,enumerable:!1}),y.color.close="\x1B[39m",y.bgColor.close="\x1B[49m",y.color.ansi=En(),y.color.ansi256=Bn(),y.color.ansi16m=bn(),y.bgColor.ansi=En(10),y.bgColor.ansi256=Bn(10),y.bgColor.ansi16m=bn(10),Object.defineProperties(y,{rgbToAnsi256:{value(u,t,n){return u===t&&t===n?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(u){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(r=>r+r).join(""));let D=Number.parseInt(n,16);return[D>>16&255,D>>8&255,D&255]},enumerable:!1},hexToAnsi256:{value:u=>y.rgbToAnsi256(...y.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let t,n,D;if(u>=232)t=((u-232)*10+8)/255,n=t,D=t;else{u-=16;let i=u%36;t=Math.floor(u/36)/5,n=Math.floor(i/6)/5,D=i%6/5}let r=Math.max(t,n,D)*2;if(r===0)return 30;let o=30+(Math.round(D)<<2|Math.round(n)<<1|Math.round(t));return r===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(u,t,n)=>y.ansi256ToAnsi(y.rgbToAnsi256(u,t,n)),enumerable:!1},hexToAnsi:{value:u=>y.ansi256ToAnsi(y.hexToAnsi256(u)),enumerable:!1}}),y}var Qo=Zo(),W=Qo;import _u from"node:process";import ei from"node:os";import An from"node:tty";function $(e,u=globalThis.Deno?globalThis.Deno.args:_u.argv){let t=e.startsWith("-")?"":e.length===1?"-":"--",n=u.indexOf(t+e),D=u.indexOf("--");return n!==-1&&(D===-1||n<D)}var{env:x}=_u,Je;$("no-color")||$("no-colors")||$("color=false")||$("color=never")?Je=0:($("color")||$("colors")||$("color=true")||$("color=always"))&&(Je=1);function ui(){if("FORCE_COLOR"in x)return x.FORCE_COLOR==="true"?1:x.FORCE_COLOR==="false"?0:x.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(x.FORCE_COLOR,10),3)}function ti(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ni(e,{streamIsTTY:u,sniffFlags:t=!0}={}){let n=ui();n!==void 0&&(Je=n);let D=t?Je:n;if(D===0)return 0;if(t){if($("color=16m")||$("color=full")||$("color=truecolor"))return 3;if($("color=256"))return 2}if("TF_BUILD"in x&&"AGENT_NAME"in x)return 1;if(e&&!u&&D===void 0)return 0;let r=D||0;if(x.TERM==="dumb")return r;if(_u.platform==="win32"){let o=ei.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in x)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in x)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in x)||x.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(x.TEAMCITY_VERSION)?1:0;if(x.COLORTERM==="truecolor"||x.TERM==="xterm-kitty"||x.TERM==="xterm-ghostty"||x.TERM==="wezterm")return 3;if("TERM_PROGRAM"in x){let o=Number.parseInt((x.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(x.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(x.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(x.TERM)||"COLORTERM"in x?1:r}function yn(e,u={}){let t=ni(e,{streamIsTTY:e&&e.isTTY,...u});return ti(t)}var Di={stdout:yn({isTTY:An.isatty(1)}),stderr:yn({isTTY:An.isatty(2)})},xn=Di;function Rn(e,u,t){let n=e.indexOf(u);if(n===-1)return e;let D=u.length,r=0,o="";do o+=e.slice(r,n)+u+t,r=n+D,n=e.indexOf(u,r);while(n!==-1);return o+=e.slice(r),o}function wn(e,u,t,n){let D=0,r="";do{let o=e[n-1]==="\r";r+=e.slice(D,o?n-1:n)+u+(o?`\r
|
|
8
|
+
`)[0].length}};iu.reset=()=>Z.reset();function Dt(e,u,t){let n=[];e.forEach(function(r){n.push(r.draw(u))});let D=n.join("");D.length&&t.push(D)}er.exports=iu});var nr=A((f0,tr)=>{tr.exports=ur()});import He from"node:path";import eo from"node:os";import{createReadStream as Yr}from"node:fs";import Jr from"node:readline";var Eu=200;async function xt(e){let u=Yr(e,{encoding:"utf8"}),t=Jr.createInterface({input:u,crlfDelay:1/0}),n=[],D=[],r=[];for await(let o of t){if(!o.trim())continue;let i;try{i=JSON.parse(o)}catch{continue}if(!(!i||typeof i!="object")){if(i.uuid&&r.push([i.uuid,i.parentUuid??null]),i.type==="assistant"){let s=Xr(i,e);s&&n.push(s)}else if(i.type==="user"){let s=Zr(i,e);s&&D.push(s)}}}return{assistant:n,user:D,parentLinks:r}}function Xr(e,u){let t=e.message;if(!t)return null;let n=t.usage;if(!n)return null;let D=t.model??"";if(!D||D==="<synthetic>")return null;let r=t.id??e.uuid??"";if(!r&&!e.requestId)return null;let o=n.cache_creation,i=Array.isArray(t.content)?t.content:[],s=[],a=!1,F="";for(let c of i)c.type==="tool_use"&&typeof c.name=="string"?s.push(c.name):c.type==="thinking"?a=!0:c.type==="text"&&typeof c.text=="string"&&!F&&(F=c.text.slice(0,Eu));return{type:"assistant",source:"claude",uuid:e.uuid??r,parentUuid:e.parentUuid??null,timestamp:e.timestamp??new Date().toISOString(),sessionId:e.sessionId??"",requestId:e.requestId??"",cwd:e.cwd??"",gitBranch:e.gitBranch,version:e.version,model:D,messageId:r,usage:{input_tokens:Number(n.input_tokens)||0,output_tokens:Number(n.output_tokens)||0,cache_creation_input_tokens:Number(n.cache_creation_input_tokens)||0,cache_read_input_tokens:Number(n.cache_read_input_tokens)||0,cache_creation_5m:Number(o?.ephemeral_5m_input_tokens)||0,cache_creation_1h:Number(o?.ephemeral_1h_input_tokens)||0},toolNames:s,hasThinking:a,textPreview:F,filePath:u,isSidechain:e.isSidechain===!0?!0:void 0}}function Zr(e,u){if(!e.uuid)return null;let t=e.message,n="";if(t){let o=t.content;if(typeof o=="string")n=o.slice(0,Eu);else if(Array.isArray(o)){for(let i of o)if(i.type==="text"&&typeof i.text=="string"){n=i.text.slice(0,Eu);break}}}let D=e.isSidechain===!0,r=D||!!n&&Qr(n);return{type:"user",source:"claude",uuid:e.uuid,parentUuid:e.parentUuid??null,timestamp:e.timestamp??new Date().toISOString(),sessionId:e.sessionId??"",cwd:e.cwd??"",textPreview:n,isSynthetic:r,isSidechain:D?!0:void 0,filePath:u}}function Qr(e){let u=e.trimStart();return!!(u.startsWith("Base directory for this skill:")||u.startsWith("<system-reminder>")||u.startsWith("Caveat: The messages below were generated by")||u.startsWith("<task-notification>"))}var U={"claude-fable-5":{input:10,output:50,cacheCreation5m:12.5,cacheCreation1h:20,cacheRead:1},"claude-opus-4-8":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-7":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-6":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-opus-4-5":{input:5,output:25,cacheCreation5m:6.25,cacheCreation1h:10,cacheRead:.5},"claude-sonnet-4-6":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-sonnet-4-5":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-haiku-4-5":{input:1,output:5,cacheCreation5m:1.25,cacheCreation1h:2,cacheRead:.1},"claude-haiku-3-5":{input:.8,output:4,cacheCreation5m:1,cacheCreation1h:1.6,cacheRead:.08},"claude-opus-4-1":{input:15,output:75,cacheCreation5m:18.75,cacheCreation1h:30,cacheRead:1.5},"claude-opus-4":{input:15,output:75,cacheCreation5m:18.75,cacheCreation1h:30,cacheRead:1.5},"claude-sonnet-4":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-sonnet-3-7":{input:3,output:15,cacheCreation5m:3.75,cacheCreation1h:6,cacheRead:.3},"claude-haiku-3":{input:.25,output:1.25,cacheCreation5m:.3,cacheCreation1h:.5,cacheRead:.03}},Rt={fable:U["claude-fable-5"],opus:U["claude-opus-4-8"],sonnet:U["claude-sonnet-4-6"],haiku:U["claude-haiku-4-5"]};function Be(e,u){if(!u)return{input:0,output:0,cacheCreation5m:0,cacheCreation1h:0,cacheRead:0,total:0,saved:0};let t=e.input_tokens/1e6*u.input,n=e.output_tokens/1e6*u.output,D=e.cache_creation_5m/1e6*u.cacheCreation5m,r=e.cache_creation_1h/1e6*u.cacheCreation1h;D+r===0&&e.cache_creation_input_tokens>0&&(D=e.cache_creation_input_tokens/1e6*u.cacheCreation5m);let o=e.cache_read_input_tokens/1e6*u.cacheRead,i=t+n+D+r+o,s=e.cache_read_input_tokens/1e6*(u.input-u.cacheRead);return{input:t,output:n,cacheCreation5m:D,cacheCreation1h:r,cacheRead:o,total:i,saved:s}}function wt(e){return e.replace(/\b\w/g,u=>u.toUpperCase())}function kt(e){if(!e)return"(unknown)";let u=e.replace(/-(\d{8})$/,"").replace(/^(vertex_ai|bedrock|anthropic)\//,"");u=u.replace(/^claude-/,"");let t=u.split("-");if(t.length>=2){let n=t[0],D=t.slice(1).join(".");return wt(n)+" "+D}return wt(u.replace(/-/g," "))}var uo=/-\d{8}$/,to=/^(vertex_ai|bedrock|anthropic)\//;function no(e){if(!e)return{pricing:null,matchType:"none",matchedKey:null};if(U[e])return{pricing:U[e],matchType:"exact",matchedKey:e};let u=e.replace(uo,"");if(U[u])return{pricing:U[u],matchType:"date-stripped",matchedKey:u};let t=u.replace(to,"");if(U[t])return{pricing:U[t],matchType:"prefix-stripped",matchedKey:t};for(let n of["fable","opus","sonnet","haiku"])if(e.toLowerCase().includes(n))return{pricing:Rt[n],matchType:"family-fallback",matchedKey:`claude-${n}-(latest)`};return{pricing:null,matchType:"none",matchedKey:null}}function Do(){let e=eo.homedir(),u=[He.join(e,".claude","projects"),He.join(e,".config","claude","projects")];return process.env.CCGAUGE_CONFIG_DIR&&u.push(He.join(process.env.CCGAUGE_CONFIG_DIR,"projects")),process.env.CLAUDE_CONFIG_DIR&&u.push(He.join(process.env.CLAUDE_CONFIG_DIR,"projects")),Array.from(new Set(u))}var St={id:"claude",displayName:{en:"Claude",zh:"Claude"},shortLabel:"C",color:{fg:"#b45309",bg:"#fef3c7"},logoSrc:"/claude-logo.webp",parserVersion:"claude-v5-task-notification-synthetic",capabilities:{hasCacheCreation:!0,hasReasoningTokens:!1,blockWindowMs:300*60*1e3},getDirs:Do,shouldSkipDir:e=>e==="tool-results"||e==="memory",parseFile:async e=>await xt(e),resolvePricing:no,shortenModel:kt,costFromUsage:Be,costFootnoteKey:null};import Ve from"node:path";import fo from"node:os";import{createReadStream as ro,promises as oo}from"node:fs";import io from"node:readline";var Bu=200;async function so(e){try{let u=await oo.stat(e);return new Date(u.mtimeMs).toISOString()}catch{return new Date().toISOString()}}function M(e){return typeof e=="string"?e:""}function ne(e){let u=Number(e);return Number.isFinite(u)?u:0}function bu(e){let u=e.message;if(typeof u=="string")return u;let t=e.content;if(typeof t=="string")return t;if(Array.isArray(t))for(let n of t){let D=n?.type;if((D==="input_text"||D==="output_text"||D==="text")&&typeof n.text=="string")return n.text}return""}async function Tt(e){let u=ro(e,{encoding:"utf8"}),t=io.createInterface({input:u,crlfDelay:1/0}),n=[],D=[],r=[],o="",i,s="",a=0,F=0,c=null,d=await so(e),l={turnId:null,cwd:"",model:"gpt-unknown",userUuid:null,toolNames:[],hasThinking:!1,pendingTextPreview:""};for await(let C of t){if(!C.trim())continue;let h;try{h=JSON.parse(C)}catch{continue}if(!h||typeof h!="object"||!h.type)continue;let p=h.payload??{},g=M(h.timestamp),B=g||d;if(g&&(d=g),h.type==="session_meta"){o=M(p.id),s=M(p.cwd),i=M(p.cli_version)||void 0;let m=M(p.timestamp);m&&(d=m),l.cwd||(l.cwd=s);continue}if(h.type==="turn_context"){l.turnId=M(p.turn_id)||l.turnId,l.cwd=M(p.cwd)||s;let m=M(p.model);m&&(l.model=m);let b=M(p.effort);b&&(l.effort=b),l.toolNames=[],l.hasThinking=!1,l.pendingTextPreview="";continue}if(h.type==="event_msg"){let m=M(p.type);if(m==="user_message"){let b=bu(p);if(!b)continue;let k=`${o}::u${a++}`;D.push({type:"user",source:"codex",uuid:k,parentUuid:null,timestamp:B,sessionId:o,cwd:l.cwd||s,textPreview:b.slice(0,Bu),filePath:e}),r.push([k,null]),l.userUuid=k;continue}if(m==="agent_message"){let b=bu(p);b&&!l.pendingTextPreview&&(l.pendingTextPreview=b.slice(0,Bu));continue}if(m==="agent_reasoning"){l.hasThinking=!0;continue}if(m==="token_count"){let b=p.info;if(!b)continue;let k=b.total_token_usage,se=b.last_token_usage,S=k?{input:ne(k.input_tokens),cached:ne(k.cached_input_tokens),output:ne(k.output_tokens),reasoning:ne(k.reasoning_output_tokens)}:null,ue,K,te,z;if(S){if(c===null?(ue=S.input,K=S.cached,te=S.output,z=S.reasoning):(ue=Math.max(0,S.input-c.input),K=Math.max(0,S.cached-c.cached),te=Math.max(0,S.output-c.output),z=Math.max(0,S.reasoning-c.reasoning)),ue===0&&K===0&&te===0&&z===0)continue;c===null?c={...S}:c={input:Math.max(c.input,S.input),cached:Math.max(c.cached,S.cached),output:Math.max(c.output,S.output),reasoning:Math.max(c.reasoning,S.reasoning)}}else if(se){if(ue=ne(se.input_tokens),K=ne(se.cached_input_tokens),te=ne(se.output_tokens),z=ne(se.reasoning_output_tokens),ue===0&&K===0&&te===0&&z===0)continue;c===null?c={input:ue,cached:K,output:te,reasoning:z}:c={input:c.input+ue,cached:c.cached+K,output:c.output+te,reasoning:c.reasoning+z}}else continue;let Bt=`${o}::a${F++}`,bt=l.turnId?`${l.turnId}::a${F}`:`${o}::a${F}`;n.push({type:"assistant",source:"codex",uuid:Bt,parentUuid:l.userUuid,timestamp:B,sessionId:o,requestId:bt,cwd:l.cwd||s,version:i,model:l.model||"gpt-unknown",messageId:bt,usage:{input_tokens:Math.max(0,ue-K),output_tokens:te+z,cache_creation_input_tokens:0,cache_read_input_tokens:K,cache_creation_5m:0,cache_creation_1h:0,reasoning_tokens:z},toolNames:[...l.toolNames],hasThinking:l.hasThinking,textPreview:l.pendingTextPreview,filePath:e,effort:l.effort}),r.push([Bt,l.userUuid]),l.toolNames=[],l.hasThinking=!1,l.pendingTextPreview="";continue}continue}if(h.type==="response_item"){let m=M(p.type);if(m==="function_call"||m==="custom_tool_call"){let b=M(p.name);b&&l.toolNames.push(b);continue}if(m==="reasoning"){l.hasThinking=!0;continue}if(m==="message"){if(M(p.role)==="assistant"){let k=bu(p);k&&!l.pendingTextPreview&&(l.pendingTextPreview=k.slice(0,Bu))}continue}continue}}return{assistant:n,user:D,parentLinks:r}}var De={"gpt-5.5":{input:5,output:30,cacheRead:.5,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.4":{input:2.5,output:15,cacheRead:.25,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.4-mini":{input:.75,output:4.5,cacheRead:.075,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.4-nano":{input:.2,output:1.25,cacheRead:.02,cacheCreation5m:0,cacheCreation1h:0},"gpt-5.3-codex":{input:1.75,output:14,cacheRead:.175,cacheCreation5m:0,cacheCreation1h:0},"gpt-5":{input:2.5,output:15,cacheRead:.25,cacheCreation5m:0,cacheCreation1h:0},"gpt-5-mini":{input:.75,output:4.5,cacheRead:.075,cacheCreation5m:0,cacheCreation1h:0},"gpt-5-nano":{input:.2,output:1.25,cacheRead:.02,cacheCreation5m:0,cacheCreation1h:0},"gpt-5-codex":{input:1.75,output:14,cacheRead:.175,cacheCreation5m:0,cacheCreation1h:0},"gpt-4.1":{input:2,output:8,cacheRead:.5,cacheCreation5m:0,cacheCreation1h:0},"gpt-4.1-mini":{input:.4,output:1.6,cacheRead:.1,cacheCreation5m:0,cacheCreation1h:0},o3:{input:2,output:8,cacheRead:.5,cacheCreation5m:0,cacheCreation1h:0},"o4-mini":{input:1.1,output:4.4,cacheRead:.275,cacheCreation5m:0,cacheCreation1h:0}},_t={gpt:De["gpt-5.5"],o:De.o3},ao=/-\d{8}$/,co=/^(openai)\//;function vt(e){if(!e)return{pricing:null,matchType:"none",matchedKey:null};if(De[e])return{pricing:De[e],matchType:"exact",matchedKey:e};let u=e.replace(ao,"");if(De[u])return{pricing:De[u],matchType:"date-stripped",matchedKey:u};let t=u.replace(co,"");if(De[t])return{pricing:De[t],matchType:"prefix-stripped",matchedKey:t};let n=e.toLowerCase();return n.startsWith("gpt-")||n==="gpt"?{pricing:_t.gpt,matchType:"family-fallback",matchedKey:"gpt-(latest)"}:/^o\d/.test(n)?{pricing:_t.o,matchType:"family-fallback",matchedKey:"o-(latest)"}:{pricing:null,matchType:"none",matchedKey:null}}function lo(e){return e.replace(/\b\w/g,u=>u.toUpperCase())}var Fo={mini:"Mini",nano:"Nano",pro:"Pro",turbo:"Turbo",preview:"Preview"};function It(e){if(!e)return"(unknown)";let u=e.replace(/^openai\//,"");return u.toLowerCase().startsWith("gpt-")?"GPT-"+u.slice(4).split("-").map(D=>Fo[D.toLowerCase()]??D).join(" "):u.toLowerCase().startsWith("o")?u.toUpperCase():lo(u.replace(/-/g," "))}function po(){let e=fo.homedir(),u=[Ve.join(e,".codex","sessions"),Ve.join(e,".codex","archived_sessions")];return process.env.CCGAUGE_CODEX_DIR&&u.push(process.env.CCGAUGE_CODEX_DIR),process.env.CODEX_HOME&&(u.push(Ve.join(process.env.CODEX_HOME,"sessions")),u.push(Ve.join(process.env.CODEX_HOME,"archived_sessions"))),Array.from(new Set(u))}var Mt={id:"codex",displayName:{en:"Codex",zh:"Codex"},shortLabel:"X",color:{fg:"#047857",bg:"#d1fae5"},logoSrc:"/codex-logo.webp",parserVersion:"codex-v5-last-total-prev",capabilities:{hasCacheCreation:!1,hasReasoningTokens:!0,blockWindowMs:300*60*1e3},getDirs:po,shouldSkipDir:()=>!1,parseFile:Tt,resolvePricing:vt,shortenModel:It,costFromUsage:Be,costFootnoteKey:"cost.footnote.codex"};var Pt={claude:St,codex:Mt},Au=["claude","codex"];function re(e){return Pt[e]}function yu(){return Au.map(e=>Pt[e])}function Ot(e){return typeof e=="string"&&(e==="claude"||e==="codex")}import{promises as be,watch as bo}from"node:fs";import Vt from"node:path";function ho(e){let u=`${e.source}:`;return e.messageId&&e.requestId?`${u}${e.messageId}::${e.requestId}`:e.messageId?`${u}mid:${e.messageId}`:e.requestId?`${u}req:${e.requestId}`:`${u}uuid:${e.uuid}`}function Lt(e){let u=new Map;for(let t of e){let n=ho(t),D=u.get(n);if(!D){u.set(n,t);continue}t.timestamp<D.timestamp&&u.set(n,t)}return Array.from(u.values())}import{promises as Ke}from"node:fs";import xu from"node:path";import Co from"node:os";var ze=2,Fe="default";function go(){return process.env.CCGAUGE_STATE_DIR?process.env.CCGAUGE_STATE_DIR:xu.join(Co.homedir(),".ccgauge")}function Nt(e){let u=e===Fe?`index-v${ze}.json`:`index-${e}-v${ze}.json`;return xu.join(go(),"cache",u)}async function $t(e=Fe){let u=Nt(e);try{let t=await Ke.readFile(u,"utf8"),n=JSON.parse(t);return n.schemaVersion!==ze||!Array.isArray(n.files)?null:n}catch{return null}}async function Ut(e,u=Fe){let t=Nt(u),n=xu.dirname(t);await Ke.mkdir(n,{recursive:!0});let D={schemaVersion:ze,savedAt:e.savedAt,files:e.files},r=`${t}.tmp-${process.pid}`;await Ke.writeFile(r,JSON.stringify(D)),await Ke.rename(r,t)}var Wt=/[\\/]([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[\\/]subagents[\\/](?:[^\\/]+[\\/])*agent-[^\\/]+\.jsonl$/i,mo=/[\\/]subagents[\\/]workflows[\\/]/i;function Eo(e){let u=Wt.exec(e);return u?u[1]:null}function jt(e){return Wt.test(e)?mo.test(e)?"workflow":"task":null}function Gt({assistantRecords:e,userRecords:u,parentMap:t}){let n=new Map;for(let o of e){if(o.isSidechain||!o.sessionId)continue;let i=n.get(o.sessionId);i||(i=[],n.set(o.sessionId,i)),i.push(o)}for(let o of n.values())o.sort((i,s)=>i.timestamp<s.timestamp?-1:i.timestamp>s.timestamp?1:0);let D=new Map;for(let o of u){if(!o.isSidechain)continue;let i=D.get(o.filePath);(!i||o.timestamp<i.timestamp)&&D.set(o.filePath,o)}let r={subagentFiles:0,relinked:0,orphans:0,alreadyLinked:0};for(let[o,i]of D){let s=Eo(o);if(!s)continue;r.subagentFiles+=1;let a=t[i.uuid];if(a!=null){r.alreadyLinked+=1;continue}let F=n.get(s);if(!F||F.length===0){r.orphans+=1;continue}let c=i.timestamp,f;for(let d=F.length-1;d>=0;d-=1)if(F[d].timestamp<=c){f=F[d];break}f||(f=F[0]),t[i.uuid]=f.uuid,r.relinked+=1}return r}import{homedir as Bo}from"node:os";function qt(e){let u=Bo();if(!u)return e;let t=new Set([u]);process.platform==="win32"&&(t.add(u.replace(/\\/g,"/")),t.add(u.replace(/\\/g,"\\\\")),t.add("\\\\?\\"+u),t.add("\\\\?\\"+u.replace(/\\/g,"/")));let n=e;for(let D of t){let r=D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(r,"g"),"~")}return n}var Ao=200,yo=100,xo=3e4,Ro=2e3,wo=8,Ru=20,wu=class{cacheName;files=new Map;snapshot=null;watchers=new Map;pollTimer=null;snapshotRebuildTimer=null;persistTimer=null;fileDebouncers=new Map;initPromise=null;isIndexing=!1;lastIndexedAt=null;indexDurationMs=null;existingDirs=[];dirToProvider=new Map;errors=[];loadedFromDisk=!1;lastWorkStart=null;rescanPromise=null;mutationTail=Promise.resolve();constructor(u=Fe){this.cacheName=u}runExclusive(u){let t=this.mutationTail.then(u,u);return this.mutationTail=t.then(()=>{},()=>{}),t}init(){return this.initPromise||(this.initPromise=this.doInit()),this.initPromise}async doInit(){let u=Date.now();this.isIndexing=!0,this.lastWorkStart=u;try{await this.detectProviderDirs();let t=await $t(this.cacheName);this.loadedFromDisk=t!==null;let n=new Map;if(t)for(let D of t.files)n.set(D.filePath,D);await this.runExclusive(async()=>{await this.fullScan(n),this.rebuildSnapshotNow(),this.indexDurationMs=Date.now()-u,this.lastIndexedAt=new Date().toISOString(),this.schedulePersist()}),this.syncWatchersToDirs(),this.setupPolling()}finally{this.isIndexing=!1}}async detectProviderDirs(){let u=new Map,t=[];for(let r of yu())for(let o of r.getDirs())await ko(o)&&(u.has(o)||(u.set(o,r),t.push(o)));let n=[],D=[];for(let r of u.keys())this.dirToProvider.has(r)||n.push(r);for(let r of this.dirToProvider.keys())u.has(r)||D.push(r);return this.dirToProvider=u,this.existingDirs=t,{added:n,removed:D}}async fullScan(u){let t=[];for(let[D,r]of this.dirToProvider){let o=await Ht(D,r);for(let i of o)t.push({file:i,provider:r})}let n=new Set(t.map(D=>D.file));await Promise.all(t.map(async({file:D,provider:r})=>{try{let o=await be.stat(D),i=u.get(D);if(i&&i.source===r.id&&i.parserVersion===r.parserVersion&&i.mtimeMs===o.mtimeMs&&i.size===o.size){this.files.set(D,{source:r.id,parserVersion:r.parserVersion,mtimeMs:o.mtimeMs,size:o.size,assistantRecords:i.assistantRecords,userRecords:i.userRecords,parentLinks:i.parentLinks});return}let s=await r.parseFile(D);this.files.set(D,{source:r.id,parserVersion:r.parserVersion,mtimeMs:o.mtimeMs,size:o.size,assistantRecords:s.assistant,userRecords:s.user,parentLinks:s.parentLinks})}catch(o){this.recordError(`parse ${D}: ${o.message}`)}}));for(let D of Array.from(this.files.keys()))n.has(D)||this.files.delete(D)}syncWatchersToDirs(){for(let[u,t]of this.watchers)if(!this.dirToProvider.has(u)){try{t.close()}catch{}this.watchers.delete(u)}for(let[u,t]of this.dirToProvider)if(!this.watchers.has(u))try{let n=bo(u,{recursive:!0},(D,r)=>{if(!r||typeof r!="string"||!r.endsWith(".jsonl"))return;let o=Vt.join(u,r);this.scheduleFileReconcile(o,t)});n.on("error",D=>{this.recordError(`watcher ${u}: ${D.message}`)}),this.watchers.set(u,n)}catch(n){this.recordError(`watch ${u}: ${n.message}`)}}setupPolling(){this.pollTimer&&clearInterval(this.pollTimer);let u=this.cacheName==="mcp",t=process.env.CCGAUGE_POLL_FALLBACK;(t==="1"||t!=="0"&&!u)&&(this.pollTimer=setInterval(()=>{this.pollOnce().catch(D=>this.recordError(`poll: ${D.message}`))},xo),this.pollTimer.unref?.())}async pollOnce(){await this.runExclusive(async()=>{let u=Date.now(),t=await this.detectProviderDirs(),n=t.added.length>0||t.removed.length>0;n&&this.syncWatchersToDirs();let D=[];for(let[o,i]of this.dirToProvider){let s=await Ht(o,i);for(let a of s)D.push({file:a,provider:i})}let r=new Set(D.map(o=>o.file));await Promise.all(D.map(async({file:o,provider:i})=>{try{let s=await be.stat(o),a=this.files.get(o);if(a&&a.mtimeMs===s.mtimeMs&&a.size===s.size)return;let F=await i.parseFile(o);this.files.set(o,{source:i.id,parserVersion:i.parserVersion,mtimeMs:s.mtimeMs,size:s.size,assistantRecords:F.assistant,userRecords:F.user,parentLinks:F.parentLinks}),n=!0}catch(s){this.recordError(`poll-parse ${o}: ${s.message}`)}}));for(let o of Array.from(this.files.keys()))r.has(o)||(this.files.delete(o),n=!0);n&&(this.lastWorkStart=u,this.scheduleSnapshotRebuild(),this.schedulePersist())})}scheduleFileReconcile(u,t){let n=this.fileDebouncers.get(u);n&&clearTimeout(n);let D=setTimeout(()=>{this.fileDebouncers.delete(u),this.reconcileFile(u,t).catch(r=>this.recordError(`reconcile ${u}: ${r.message}`))},Ao);D.unref?.(),this.fileDebouncers.set(u,D)}async reconcileFile(u,t){await this.runExclusive(async()=>{let n=Date.now(),D=null;try{D=await be.stat(u)}catch{}if(!D||!D.isFile()){this.files.has(u)&&(this.files.delete(u),this.lastWorkStart=n,this.scheduleSnapshotRebuild(),this.schedulePersist());return}let r=this.files.get(u);if(!(r&&r.mtimeMs===D.mtimeMs&&r.size===D.size))try{let o=await t.parseFile(u);this.files.set(u,{source:t.id,parserVersion:t.parserVersion,mtimeMs:D.mtimeMs,size:D.size,assistantRecords:o.assistant,userRecords:o.user,parentLinks:o.parentLinks}),this.lastWorkStart=n,this.scheduleSnapshotRebuild(),this.schedulePersist()}catch(o){this.recordError(`parse ${u}: ${o.message}`)}})}scheduleSnapshotRebuild(){this.snapshotRebuildTimer&&clearTimeout(this.snapshotRebuildTimer),this.snapshotRebuildTimer=setTimeout(()=>{this.snapshotRebuildTimer=null,this.rebuildSnapshotNow()},yo),this.snapshotRebuildTimer.unref?.()}rebuildSnapshotNow(){let u=Date.now(),t=this.lastWorkStart??u,n=[],D=[],r={},o=0,i={claude:{source:"claude",filesScanned:0,recordsParsed:0,assistantRecords:0,scannedDirs:[]},codex:{source:"codex",filesScanned:0,recordsParsed:0,assistantRecords:0,scannedDirs:[]}};for(let[c,f]of this.dirToProvider)i[f.id].scannedDirs.push(c);for(let c of this.files.values()){n.push(...c.assistantRecords),D.push(...c.userRecords);for(let[f,d]of c.parentLinks)r[f]=d;o+=c.assistantRecords.length+c.userRecords.length,i[c.source].filesScanned+=1,i[c.source].recordsParsed+=c.assistantRecords.length+c.userRecords.length}let s=Lt(n).sort((c,f)=>c.timestamp.localeCompare(f.timestamp)),a=So(D).sort((c,f)=>c.timestamp.localeCompare(f.timestamp));Gt({assistantRecords:s,userRecords:a,parentMap:r});for(let c of s)c.isSidechain&&(c.isWorkflowSubagent=jt(c.filePath)==="workflow");for(let c of s)i[c.source].assistantRecords+=1;let F={filesScanned:this.files.size,recordsParsed:o,assistantRecords:s.length,durationMs:Date.now()-t,scannedDirs:this.existingDirs};this.snapshot={records:s,userRecords:a,parentMap:r,stats:F,bySource:Object.values(i)},this.lastWorkStart=null}getSnapshot(){if(!this.snapshot)throw new Error("Indexer not initialized \u2014 call init() first.");return this.snapshot}async forceRescan(){let u=!this.initPromise;if(await this.init(),u)return this.snapshot;if(this.rescanPromise)return this.rescanPromise;this.rescanPromise=this.runRescan();try{return await this.rescanPromise}finally{this.rescanPromise=null}}async runRescan(){this.isIndexing=!0;try{return await this.runExclusive(async()=>{let u=Date.now();return this.lastWorkStart=u,this.snapshotRebuildTimer&&(clearTimeout(this.snapshotRebuildTimer),this.snapshotRebuildTimer=null),this.persistTimer&&(clearTimeout(this.persistTimer),this.persistTimer=null),this.files.clear(),await this.detectProviderDirs(),await this.fullScan(new Map),this.rebuildSnapshotNow(),this.indexDurationMs=Date.now()-u,this.lastIndexedAt=new Date().toISOString(),this.syncWatchersToDirs(),this.schedulePersist(),this.snapshot})}finally{this.isIndexing=!1}}getStatus(){let u=this.snapshot;return{initialized:u!==null,isIndexing:this.isIndexing,lastIndexedAt:this.lastIndexedAt,indexDurationMs:this.indexDurationMs,filesIndexed:this.files.size,recordsIndexed:u?.stats.assistantRecords??0,bySource:u?.bySource??[],watchers:this.watchers.size,errors:this.errors.slice(-Ru),pendingReconciles:this.fileDebouncers.size,loadedFromDisk:this.loadedFromDisk}}schedulePersist(){this.persistTimer&&clearTimeout(this.persistTimer),this.persistTimer=setTimeout(()=>{this.persistTimer=null;let u=[];for(let[t,n]of this.files)u.push({filePath:t,source:n.source,parserVersion:n.parserVersion,mtimeMs:n.mtimeMs,size:n.size,assistantRecords:n.assistantRecords,userRecords:n.userRecords,parentLinks:n.parentLinks});Ut({savedAt:new Date().toISOString(),files:u},this.cacheName).catch(t=>this.recordError(`persist: ${t.message}`))},Ro),this.persistTimer.unref?.()}recordError(u){let t=`${new Date().toISOString()} ${qt(u)}`;this.errors.push(t),this.errors.length>Ru*2&&this.errors.splice(0,this.errors.length-Ru),process.env.CCGAUGE_DEBUG&&console.error(`[ccgauge:indexer] ${new Date().toISOString()} ${u}`)}disposeWatchers(){for(let u of this.watchers.values())try{u.close()}catch{}this.watchers.clear()}dispose(){this.disposeWatchers(),this.pollTimer&&clearInterval(this.pollTimer),this.snapshotRebuildTimer&&clearTimeout(this.snapshotRebuildTimer),this.persistTimer&&clearTimeout(this.persistTimer);for(let u of this.fileDebouncers.values())clearTimeout(u);this.fileDebouncers.clear()}};async function ko(e){try{return(await be.stat(e)).isDirectory()}catch{return!1}}async function Ht(e,u){let t=[];async function n(D,r){if(r>wo)return;let o;try{o=await be.readdir(D,{withFileTypes:!0})}catch{return}for(let i of o){let s=Vt.join(D,i.name);if(i.isDirectory()){if(u.shouldSkipDir(i.name))continue;await n(s,r+1)}else i.isFile()&&i.name.endsWith(".jsonl")&&t.push(s)}}return await n(e,0),t}function So(e){let u=new Set;return e.filter(t=>{let n=t.uuid;return n?u.has(n)?!1:(u.add(n),!0):!0})}function To(){return globalThis.__ccgaugeIndexers||(globalThis.__ccgaugeIndexers=new Map),globalThis.__ccgaugeIndexers}function Kt(e=Fe){let u=To(),t=u.get(e);return t||(t=new wu(e),u.set(e,t)),t}async function zt(e={}){let u=Kt();return e.force?u.forceRescan():(await u.init(),u.getSnapshot())}function oe(e){let u=re(e.source),{pricing:t}=u.resolvePricing(e.model);return u.costFromUsage(e.usage,t)}function Yt(e,u){return new Intl.NumberFormat("en-US",{maximumFractionDigits:u?.maxFrac??0}).format(e)}function v(e,u="en"){return Number.isFinite(e)?u==="zh"?e>=1e8?(e/1e8).toFixed(2)+"\u4EBF":e>=1e4?(e/1e4).toFixed(1)+"\u4E07":Yt(e):e>=1e9?(e/1e9).toFixed(2)+"B":e>=1e6?(e/1e6).toFixed(2)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":Yt(e):"0"}function N(e,u){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:u?.minFrac??2,maximumFractionDigits:u?.maxFrac??2}).format(e)}function de(e,u=1){return Number.isFinite(e)?`${(e*100).toFixed(u)}%`:"0%"}function Jt(e){if(e<1e3)return`${e}ms`;let u=Math.floor(e/1e3);if(u<60)return`${u}s`;let t=Math.floor(u/60);if(t<60){let r=u%60;return r?`${t}m ${r}s`:`${t}m`}let n=Math.floor(t/60),D=t%60;return D?`${n}h ${D}m`:`${n}h`}function Ae(e){if(!e)return"(unknown)";let t=e.replace(/[/\\]+$/,"").split(/[/\\]+/);return t[t.length-1]||e}import{readFileSync as _o,statSync as vo}from"node:fs";import{basename as Xt}from"node:path";var Zt=new Map,Io=/^(.+?)[/\\]\.git[/\\]worktrees[/\\]([^/\\]+)[/\\]?$/,Mo=/^(.+?)[/\\](?:\.git|\.claude)[/\\]worktrees[/\\]([^/\\]+)(?:[/\\].*)?$/;function Po(e){let u=Ae(e);if(!e)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let t=Mo.exec(e);if(t){let n=t[1],D=t[2],r=Xt(n)||n;return{label:`${r} (${D})`,isWorktree:!0,mainName:r,worktreeName:D,canonicalCwd:n}}try{let n=`${e}/.git`;if(!vo(n).isFile())return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let o=_o(n,"utf8").trim().split(/\r?\n/,1)[0]??"",i=/^gitdir:\s*(.+)$/.exec(o);if(!i)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let s=i[1].trim(),a=Io.exec(s);if(!a)return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e};let F=a[1],c=a[2],f=Xt(F)||F;return{label:`${f} (${c})`,isWorktree:!0,mainName:f,worktreeName:c,canonicalCwd:F}}catch{return{label:u,isWorktree:!1,mainName:u,worktreeName:"",canonicalCwd:e}}}function Qt(e){let u=Zt.get(e);if(u)return u.label;let t=Po(e);return Zt.set(e,t),t.label}var Oo=["hour","day","week","month"];function en(e){return typeof e=="string"&&Oo.includes(e)}function ku(e,u){let t=new Date(e),n=t.getFullYear(),D=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0");if(u==="hour")return{key:`${n}-${D}-${r}T${o}`,label:`${D}/${r} ${o}:00`};if(u==="day")return{key:`${n}-${D}-${r}`,label:`${D}/${r}`};if(u==="week"){let i=new Date(t),s=i.getDay()||7;i.setDate(i.getDate()-s+1);let a=String(i.getMonth()+1).padStart(2,"0"),F=String(i.getDate()).padStart(2,"0");return{key:`${i.getFullYear()}-W${a}${F}`,label:`Wk ${a}/${F}`}}return{key:`${n}-${D}`,label:`${n}-${D}`}}function ye(e){return{source:e.source,fromIso:e.from?.toISOString(),toIso:e.to?.toISOString(),models:e.models&&e.models.length?new Set(e.models):void 0,projects:e.projects&&e.projects.length?new Set(e.projects):void 0}}function xe(e,u){return!(e.source!==u.source||u.fromIso&&e.timestamp<u.fromIso||u.toIso&&e.timestamp>u.toIso||u.models&&!u.models.has(e.model)||u.projects&&!u.projects.has(e.cwd))}function un(e,u,t){let n=new Map,D=ye(t);for(let r of e){if(!xe(r,D))continue;let{key:o,label:i}=ku(r.timestamp,u),s=n.get(o);s||(s=Lo(o,i),n.set(o,s)),No(s,r)}return Array.from(n.values()).sort((r,o)=>r.key.localeCompare(o.key))}function Lo(e,u){return{key:e,label:u,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,requests:0,models:{}}}function No(e,u){let t=oe(u);e.inputTokens+=u.usage.input_tokens,e.outputTokens+=u.usage.output_tokens,e.cacheReadTokens+=u.usage.cache_read_input_tokens,e.cacheCreationTokens+=u.usage.cache_creation_input_tokens,e.totalTokens=e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreationTokens,e.cost+=t.total,e.saved+=t.saved,e.requests+=1;let n=e.models[u.model]??{tokens:0,cost:0,requests:0};n.tokens+=u.usage.input_tokens+u.usage.output_tokens+u.usage.cache_read_input_tokens+u.usage.cache_creation_input_tokens,n.cost+=t.total,n.requests+=1,e.models[u.model]=n}function tn(e,u){let t=new Map,n=ye(u);for(let D of e){if(!xe(D,n))continue;let r=t.get(D.model);if(!r){let{pricing:i,matchType:s}=re(D.source).resolvePricing(D.model);r={model:D.model,source:D.source,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,pricing:i,pricingResolved:s==="exact"||s==="date-stripped"||s==="prefix-stripped"},t.set(D.model,r)}let o=oe(D);r.requests+=1,r.inputTokens+=D.usage.input_tokens,r.outputTokens+=D.usage.output_tokens,r.cacheReadTokens+=D.usage.cache_read_input_tokens,r.cacheCreationTokens+=D.usage.cache_creation_input_tokens,r.totalTokens=r.inputTokens+r.outputTokens+r.cacheReadTokens+r.cacheCreationTokens,r.cost+=o.total,r.saved+=o.saved}return Array.from(t.values()).sort((D,r)=>r.cost-D.cost)}function nn(e,u){let t=new Map,n=new Map,D=ye(u);for(let r of e){if(!xe(r,D))continue;let o=r.cwd||"(unknown)",i=t.get(o);i||(i={source:u.source,cwd:o,projectName:Ae(o),sessions:0,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,firstActivity:r.timestamp,lastActivity:r.timestamp,models:[]},t.set(o,i),n.set(o,new Set)),n.get(o).add(r.sessionId);let s=oe(r);i.requests+=1,i.inputTokens+=r.usage.input_tokens,i.outputTokens+=r.usage.output_tokens,i.cacheReadTokens+=r.usage.cache_read_input_tokens,i.cacheCreationTokens+=r.usage.cache_creation_input_tokens,i.totalTokens=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreationTokens,i.cost+=s.total,i.saved+=s.saved,r.timestamp<i.firstActivity&&(i.firstActivity=r.timestamp),r.timestamp>i.lastActivity&&(i.lastActivity=r.timestamp),i.models.includes(r.model)||i.models.push(r.model)}for(let[r,o]of n){let i=t.get(r);i.sessions=o.size}return Array.from(t.values()).sort((r,o)=>o.cost-r.cost)}function Dn(e,u,t){let n=new Map,D=ye(t);for(let o of e){if(!xe(o,D))continue;let i=o.sessionId||o.uuid,s=n.get(i);s||(s={sessionId:i,source:o.source,cwd:o.cwd,projectName:Ae(o.cwd),projectLabel:Qt(o.cwd),startTime:o.timestamp,endTime:o.timestamp,durationMs:0,requests:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,totalTokens:0,cost:0,saved:0,models:[],modelBreakdown:{}},n.set(i,s));let a=oe(o);s.requests+=1,s.inputTokens+=o.usage.input_tokens,s.outputTokens+=o.usage.output_tokens,s.cacheReadTokens+=o.usage.cache_read_input_tokens,s.cacheCreationTokens+=o.usage.cache_creation_input_tokens,s.totalTokens=s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreationTokens,s.cost+=a.total,s.saved+=a.saved,o.timestamp<s.startTime&&(s.startTime=o.timestamp),o.timestamp>s.endTime&&(s.endTime=o.timestamp),s.models.includes(o.model)||s.models.push(o.model);let F=s.modelBreakdown[o.model]??{tokens:0,cost:0,requests:0};F.tokens+=o.usage.input_tokens+o.usage.output_tokens+o.usage.cache_read_input_tokens+o.usage.cache_creation_input_tokens,F.cost+=a.total,F.requests+=1,s.modelBreakdown[o.model]=F}let r=new Map;for(let o of u){let i=r.get(o.sessionId);(!i||o.timestamp<i.timestamp)&&r.set(o.sessionId,o)}for(let o of n.values()){o.durationMs=Math.max(0,new Date(o.endTime).getTime()-new Date(o.startTime).getTime());let i=r.get(o.sessionId);i&&i.textPreview&&(o.firstUserMessage=i.textPreview,o.title=i.textPreview.slice(0,80))}return Array.from(n.values()).sort((o,i)=>i.endTime.localeCompare(o.endTime))}function rn(e,u){let t=0,n=0,D=0,r=0,o=0,i=0,s=0,a=ye(u);for(let F of e){if(!xe(F,a))continue;let c=oe(F);t+=F.usage.input_tokens,n+=F.usage.output_tokens,D+=F.usage.cache_read_input_tokens,r+=F.usage.cache_creation_input_tokens,o+=c.total,i+=c.saved,s+=1}return{inputTokens:t,outputTokens:n,cacheReadTokens:D,cacheCreationTokens:r,totalTokens:t+n+D+r,cost:o,saved:i,requests:s}}var $o=["1d","7d","30d","90d","all","custom"];function on(e){return typeof e=="string"&&$o.includes(e)}function sn(e){let u=new Date;if(e==="all"||e==="custom")return{};if(e==="1d")return{from:new Date(u.getFullYear(),u.getMonth(),u.getDate())};let t=e.match(/^(\d+)([dwm])$/);if(!t)return{};let n=parseInt(t[1],10),D=t[2],r=new Date(u);return D==="d"?r.setDate(r.getDate()-n):D==="w"?r.setDate(r.getDate()-n*7):D==="m"&&r.setMonth(r.getMonth()-n),{from:r}}function Uo(e,u,t){let n=new Map;for(let i of u)i.isSynthetic||i.textPreview&&i.textPreview.trim()&&n.set(i.uuid,i.textPreview);let D=new Map,r=new Map;function o(i){let s=[],a=i,F=null,c=0,f=new Set;for(;a&&c++<5e3&&!f.has(a);){f.add(a);let d=r.get(a);if(d){F=d;break}if(s.push(a),n.has(a)){F=a;break}a=t[a]??null}F||(F=i);for(let d of s)r.set(d,F);return F}for(let i of e)D.set(i.uuid,o(i.uuid));return D}function Re(e,u,t){let n=Uo(e,u,t),D=new Map;for(let r of e){let o=n.get(r.uuid)??r.uuid,i=D.get(o);(!i||r.timestamp<i.firstTimestamp)&&D.set(o,{turnId:o,firstTimestamp:r.timestamp,firstModel:r.model,cwd:r.cwd,sessionId:r.sessionId,source:r.source})}return D}import nu from"node:process";function Su({onlyFirst:e=!1}={}){let D="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(D,e?void 0:"g")}var Wo=Su();function Y(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(Wo,"")}var an=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],cn=12288,ln=65510,Fn=[12288,12288,65281,65376,65504,65510];var dn=4352,fn=262141,Tu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Ye=(e,u)=>{let t=0,n=Math.floor(e.length/2)-1;for(;t<=n;){let D=Math.floor((t+n)/2),r=D*2;if(u<e[r])n=D-1;else if(u>e[r+1])t=D+1;else return!0}return!1};var pn=19968,[qo,Ho]=Vo(Tu);function Vo(e){let u=e[0],t=e[1];for(let n=0;n<e.length;n+=2){let D=e[n],r=e[n+1];if(pn>=D&&pn<=r)return[D,r];r-D>t-u&&(u=D,t=r)}return[u,t]}var hn=e=>e<161||e>1114109?!1:Ye(an,e),we=e=>e<cn||e>ln?!1:Ye(Fn,e);var ke=e=>e>=qo&&e<=Ho?!0:e<dn||e>fn?!1:Ye(Tu,e);function Ko(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function J(e,{ambiguousAsWide:u=!1}={}){return Ko(e),we(e)||ke(e)||u&&hn(e)?2:1}var mn=le(gn(),1),zo=new Intl.Segmenter,Yo=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function P(e,u={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:n=!1}=u;if(n||(e=Y(e)),e.length===0)return 0;let D=0,r={ambiguousAsWide:!t};for(let{segment:o}of zo.segment(e)){let i=o.codePointAt(0);if(!(i<=31||i>=127&&i<=159)&&!(i>=8203&&i<=8207||i===65279)&&!(i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071)&&!(i>=55296&&i<=57343)&&!(i>=65024&&i<=65039)&&!Yo.test(o)){if((0,mn.default)().test(o)){D+=2;continue}D+=J(i,r)}}return D}var En=(e=0)=>u=>`\x1B[${u+e}m`,Bn=(e=0)=>u=>`\x1B[${38+e};5;${u}m`,bn=(e=0)=>(u,t,n)=>`\x1B[${38+e};2;${u};${t};${n}m`,y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},iF=Object.keys(y.modifier),Jo=Object.keys(y.color),Xo=Object.keys(y.bgColor),sF=[...Jo,...Xo];function Zo(){let e=new Map;for(let[u,t]of Object.entries(y)){for(let[n,D]of Object.entries(t))y[n]={open:`\x1B[${D[0]}m`,close:`\x1B[${D[1]}m`},t[n]=y[n],e.set(D[0],D[1]);Object.defineProperty(y,u,{value:t,enumerable:!1})}return Object.defineProperty(y,"codes",{value:e,enumerable:!1}),y.color.close="\x1B[39m",y.bgColor.close="\x1B[49m",y.color.ansi=En(),y.color.ansi256=Bn(),y.color.ansi16m=bn(),y.bgColor.ansi=En(10),y.bgColor.ansi256=Bn(10),y.bgColor.ansi16m=bn(10),Object.defineProperties(y,{rgbToAnsi256:{value(u,t,n){return u===t&&t===n?u<8?16:u>248?231:Math.round((u-8)/247*24)+232:16+36*Math.round(u/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(u){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(r=>r+r).join(""));let D=Number.parseInt(n,16);return[D>>16&255,D>>8&255,D&255]},enumerable:!1},hexToAnsi256:{value:u=>y.rgbToAnsi256(...y.hexToRgb(u)),enumerable:!1},ansi256ToAnsi:{value(u){if(u<8)return 30+u;if(u<16)return 90+(u-8);let t,n,D;if(u>=232)t=((u-232)*10+8)/255,n=t,D=t;else{u-=16;let i=u%36;t=Math.floor(u/36)/5,n=Math.floor(i/6)/5,D=i%6/5}let r=Math.max(t,n,D)*2;if(r===0)return 30;let o=30+(Math.round(D)<<2|Math.round(n)<<1|Math.round(t));return r===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(u,t,n)=>y.ansi256ToAnsi(y.rgbToAnsi256(u,t,n)),enumerable:!1},hexToAnsi:{value:u=>y.ansi256ToAnsi(y.hexToAnsi256(u)),enumerable:!1}}),y}var Qo=Zo(),W=Qo;import _u from"node:process";import ei from"node:os";import An from"node:tty";function $(e,u=globalThis.Deno?globalThis.Deno.args:_u.argv){let t=e.startsWith("-")?"":e.length===1?"-":"--",n=u.indexOf(t+e),D=u.indexOf("--");return n!==-1&&(D===-1||n<D)}var{env:x}=_u,Je;$("no-color")||$("no-colors")||$("color=false")||$("color=never")?Je=0:($("color")||$("colors")||$("color=true")||$("color=always"))&&(Je=1);function ui(){if("FORCE_COLOR"in x)return x.FORCE_COLOR==="true"?1:x.FORCE_COLOR==="false"?0:x.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(x.FORCE_COLOR,10),3)}function ti(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ni(e,{streamIsTTY:u,sniffFlags:t=!0}={}){let n=ui();n!==void 0&&(Je=n);let D=t?Je:n;if(D===0)return 0;if(t){if($("color=16m")||$("color=full")||$("color=truecolor"))return 3;if($("color=256"))return 2}if("TF_BUILD"in x&&"AGENT_NAME"in x)return 1;if(e&&!u&&D===void 0)return 0;let r=D||0;if(x.TERM==="dumb")return r;if(_u.platform==="win32"){let o=ei.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in x)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in x)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in x)||x.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in x)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(x.TEAMCITY_VERSION)?1:0;if(x.COLORTERM==="truecolor"||x.TERM==="xterm-kitty"||x.TERM==="xterm-ghostty"||x.TERM==="wezterm")return 3;if("TERM_PROGRAM"in x){let o=Number.parseInt((x.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(x.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(x.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(x.TERM)||"COLORTERM"in x?1:r}function yn(e,u={}){let t=ni(e,{streamIsTTY:e&&e.isTTY,...u});return ti(t)}var Di={stdout:yn({isTTY:An.isatty(1)}),stderr:yn({isTTY:An.isatty(2)})},xn=Di;function Rn(e,u,t){let n=e.indexOf(u);if(n===-1)return e;let D=u.length,r=0,o="";do o+=e.slice(r,n)+u+t,r=n+D,n=e.indexOf(u,r);while(n!==-1);return o+=e.slice(r),o}function wn(e,u,t,n){let D=0,r="";do{let o=e[n-1]==="\r";r+=e.slice(D,o?n-1:n)+u+(o?`\r
|
|
9
9
|
`:`
|
|
10
10
|
`)+t,D=n+1,n=e.indexOf(`
|
|
11
11
|
`,D)}while(n!==-1);return r+=e.slice(D),r}var{stdout:kn,stderr:Sn}=xn,vu=Symbol("GENERATOR"),fe=Symbol("STYLER"),Se=Symbol("IS_EMPTY"),Tn=["ansi","ansi","ansi256","ansi16m"],pe=Object.create(null),ri=(e,u={})=>{if(u.level&&!(Number.isInteger(u.level)&&u.level>=0&&u.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=kn?kn.level:0;e.level=u.level===void 0?t:u.level},Xe=class{constructor(u){return _n(u)}},_n=e=>{let u=(...t)=>t.join(" ");return ri(u,e),Object.setPrototypeOf(u,Te.prototype),u};function Te(e){return _n(e)}Object.setPrototypeOf(Te.prototype,Function.prototype);for(let[e,u]of Object.entries(W))pe[e]={get(){let t=Ze(this,Mu(u.open,u.close,this[fe]),this[Se]);return Object.defineProperty(this,e,{value:t}),t}};pe.visible={get(){let e=Ze(this,this[fe],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var Iu=(e,u,t,...n)=>e==="rgb"?u==="ansi16m"?W[t].ansi16m(...n):u==="ansi256"?W[t].ansi256(W.rgbToAnsi256(...n)):W[t].ansi(W.rgbToAnsi(...n)):e==="hex"?Iu("rgb",u,t,...W.hexToRgb(...n)):W[t][e](...n),oi=["rgb","hex","ansi256"];for(let e of oi){pe[e]={get(){let{level:t}=this;return function(...n){let D=Mu(Iu(e,Tn[t],"color",...n),W.color.close,this[fe]);return Ze(this,D,this[Se])}}};let u="bg"+e[0].toUpperCase()+e.slice(1);pe[u]={get(){let{level:t}=this;return function(...n){let D=Mu(Iu(e,Tn[t],"bgColor",...n),W.bgColor.close,this[fe]);return Ze(this,D,this[Se])}}}}var ii=Object.defineProperties(()=>{},{...pe,level:{enumerable:!0,get(){return this[vu].level},set(e){this[vu].level=e}}}),Mu=(e,u,t)=>{let n,D;return t===void 0?(n=e,D=u):(n=t.openAll+e,D=u+t.closeAll),{open:e,close:u,openAll:n,closeAll:D,parent:t}},Ze=(e,u,t)=>{let n=(...D)=>si(n,D.length===1?""+D[0]:D.join(" "));return Object.setPrototypeOf(n,ii),n[vu]=e,n[fe]=u,n[Se]=t,n},si=(e,u)=>{if(e.level<=0||!u)return e[Se]?"":u;let t=e[fe];if(t===void 0)return u;let{openAll:n,closeAll:D}=t;if(u.includes("\x1B"))for(;t!==void 0;)u=Rn(u,t.close,t.open),t=t.parent;let r=u.indexOf(`
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|