aegiscode 5.1.3 → 5.1.5
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/bin/cli.js +2 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1059,7 +1059,7 @@ ${N}`,metadata:{serverName:I,toolName:G.name,mcpResult:n}}}catch(n){let Z=n.mess
|
|
|
1059
1059
|
`;await dn.appendFile(this.filePath,G,"utf-8")}async appendBatch(I){if(I.length===0)return;await dn.mkdir(q_.dirname(this.filePath),{recursive:!0});let G=I.map(c=>JSON.stringify(c)).join(`
|
|
1060
1060
|
`)+`
|
|
1061
1061
|
`;await dn.appendFile(this.filePath,G,"utf-8")}async readAll(){if(!this.exists())return[];let G=(await dn.readFile(this.filePath,"utf-8")).split(`
|
|
1062
|
-
`).filter(e=>e.trim().length>0),c=[];for(let e of G)try{c.push(JSON.parse(e))}catch{console.warn(`[JSONLStore] \u89E3\u6790 JSON \u884C\u5931\u8D25: ${e.substring(0,100)}...`)}return c}async readStream(I){return new Promise((G,c)=>{if(!this.exists()){G();return}let e=Ptl(this.filePath,{encoding:"utf-8"}),t=_tl({input:e,crlfDelay:Number.POSITIVE_INFINITY}),a=async n=>{let Z=n.trim();if(Z.length!==0)try{let N=JSON.parse(Z);await I(N)}catch{console.warn(`[JSONLStore] \u89E3\u6790\u5931\u8D25: ${Z.substring(0,50)}...`)}};t.on("line",n=>{a(n).catch(c)}),t.on("close",()=>G()),t.on("error",c),e.on("error",c)})}async readLast(I){return(await this.readAll()).slice(-I)}async filter(I){return(await this.readAll()).filter(I)}async count(){if(!this.exists())return 0;let I=0;return await this.readStream(()=>{I++}),I}async readAfterCompaction(){let I=await this.readAll(),G=-1;for(let c=I.length-1;c>=0;c--)if(I[c].subtype==="compact_boundary"){G=c;break}return G===-1?I:I.slice(G)}async clear(){this.exists()&&await dn.writeFile(this.filePath,"","utf-8")}async delete(){this.exists()&&await dn.unlink(this.filePath)}async getFileSize(){return this.exists()?(await dn.stat(this.filePath)).size:0}}});var qvI={};qG(qvI,{default:()=>$_});var $_,__=L(()=>{$_={name:"aegiscode",version:"5.1.
|
|
1062
|
+
`).filter(e=>e.trim().length>0),c=[];for(let e of G)try{c.push(JSON.parse(e))}catch{console.warn(`[JSONLStore] \u89E3\u6790 JSON \u884C\u5931\u8D25: ${e.substring(0,100)}...`)}return c}async readStream(I){return new Promise((G,c)=>{if(!this.exists()){G();return}let e=Ptl(this.filePath,{encoding:"utf-8"}),t=_tl({input:e,crlfDelay:Number.POSITIVE_INFINITY}),a=async n=>{let Z=n.trim();if(Z.length!==0)try{let N=JSON.parse(Z);await I(N)}catch{console.warn(`[JSONLStore] \u89E3\u6790\u5931\u8D25: ${Z.substring(0,50)}...`)}};t.on("line",n=>{a(n).catch(c)}),t.on("close",()=>G()),t.on("error",c),e.on("error",c)})}async readLast(I){return(await this.readAll()).slice(-I)}async filter(I){return(await this.readAll()).filter(I)}async count(){if(!this.exists())return 0;let I=0;return await this.readStream(()=>{I++}),I}async readAfterCompaction(){let I=await this.readAll(),G=-1;for(let c=I.length-1;c>=0;c--)if(I[c].subtype==="compact_boundary"){G=c;break}return G===-1?I:I.slice(G)}async clear(){this.exists()&&await dn.writeFile(this.filePath,"","utf-8")}async delete(){this.exists()&&await dn.unlink(this.filePath)}async getFileSize(){return this.exists()?(await dn.stat(this.filePath)).size:0}}});var qvI={};qG(qvI,{default:()=>$_});var $_,__=L(()=>{$_={name:"aegiscode",version:"5.1.5",description:"AEGIS CLI \u2014 AI-powered coding assistant",type:"module",bin:{aegis:"bin/cli.js","aegis-cli":"bin/cli.js",aegiscli:"bin/cli.js",aegiscode:"bin/cli.js"},scripts:{preinstall:"node scripts/ensure-node-version.mjs",build:"node esbuild.mjs","build:publish":"npm run build && node scripts/make-bin.mjs",dev:"NODE_NO_WARNINGS=1 tsx src/main.tsx",start:"node --no-deprecation dist/main.js",typecheck:"tsc --noEmit","test:prompts":"tsx src/prompts/test.ts","test:tools":"tsx src/tools/test.ts","test:pipeline":"tsx src/tools/execution/test.ts","test:context":"tsx src/context/test.ts","test:mcp":"tsx src/mcp/test.ts","test:store":"tsx src/store/test.ts"},keywords:["cli","ai","coding-agent","llm","openai","gpt","claude","copilot","assistant","terminal","developer-tools"],author:"Niklas Borneklint",license:"MIT",repository:{type:"git",url:"git+https://github.com/aegisinfo/aegiscode.git"},homepage:"https://github.com/aegisinfo/aegiscode#readme",bugs:{url:"https://github.com/aegisinfo/aegiscode/issues"},files:["bin/","scripts/","README.md","LICENSE"],engines:{node:">=18.0.0"},dependencies:{"@huggingface/transformers":"^3.8.1","@modelcontextprotocol/sdk":"^1.25.3",chalk:"^5.4.1",dotenv:"^17.4.2","fuse.js":"^7.4.1",glob:"^13.0.0",ink:"^7.0.5","ink-text-input":"^6.0.0","js-tiktoken":"^1.0.21",lowlight:"^3.3.0",minimatch:"^10.1.1",nanoid:"^5.1.6",openai:"^4.77.0",react:"^19.2.7","react-dom":"^19.2.7","sql.js":"^1.14.1","string-width":"^7.2.0",uuid:"^14.0.0",yaml:"^2.8.2",yargs:"^17.7.2",zod:"^3.24.2","zod-to-json-schema":"^3.25.1",zustand:"^5.0.14"},devDependencies:{"@types/node":"^22.19.19","@types/react":"^19.2.17","@types/sql.js":"^1.4.11","@types/yargs":"^17.0.35",esbuild:"^0.28.0",tsx:"^4.22.4",typescript:"^5.7.2"},overrides:{"string-width":"^7.2.0","slice-ansi":"^7.1.2","cli-truncate":"^4.0.0","cli-boxes":"^3.0.0"}}});var PvI,GV,_vI=L(async()=>{"use strict";is();P_();vg();PvI="0.1.0";try{PvI=(await Promise.resolve().then(()=>(__(),qvI))).default.version||"0.1.0"}catch{}GV=class{projectPath;maxSessions;version;constructor(I=process.cwd(),G=100){this.projectPath=I,this.maxSessions=G,this.version=PvI}getStore(I){let G=Qg(this.projectPath,I);return new lV(G)}async saveMessage(I,G,c,e=null,t){let a=this.getStore(I),n={uuid:_c(),parentUuid:e,sessionId:I,timestamp:new Date().toISOString(),type:G,cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:G,content:c,...t||{}}};return await a.append(n),n.uuid}async saveToolUse(I,G,c,e,t=null){let a=this.getStore(I),n={uuid:_c(),parentUuid:t,sessionId:I,timestamp:new Date().toISOString(),type:"tool_use",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"assistant",content:""},tool:{id:G,name:c,input:e}};return await a.append(n),n.uuid}async saveToolResult(I,G,c,e,t=null){let a=this.getStore(I),n={uuid:_c(),parentUuid:t,sessionId:I,timestamp:new Date().toISOString(),type:"tool_result",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"assistant",content:""},toolResult:{id:G,output:c,error:e}};return await a.append(n),n.uuid}async saveCompaction(I,G,c,e=null){let t=this.getStore(I),a={uuid:_c(),parentUuid:e,sessionId:I,timestamp:new Date().toISOString(),type:"system",subtype:"compact_boundary",cwd:this.projectPath,gitBranch:MW(this.projectPath),version:this.version,message:{role:"system",content:"=== \u4E0A\u4E0B\u6587\u538B\u7F29\u8FB9\u754C ==="},compactMetadata:c};await t.append(a);let n={uuid:_c(),parentUuid:a.uuid,sessionId:I,timestamp:new Date().toISOString(),type:"user",isCompactSummary:!0,cwd:this.projectPath,version:this.version,message:{role:"user",content:G},compactMetadata:c};return await t.append(n),n.uuid}async loadSession(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAll();if(c.length===0)return null;let e=c[0];return{sessionId:I,preferences:{},startTime:new Date(e.timestamp).getTime()}}async loadConversation(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAfterCompaction(),e=[],t=0;for(let a of c){let n=new Date(a.timestamp).getTime();n>t&&(t=n),a.subtype!=="compact_boundary"&&(a.type==="user"||a.type==="assistant"||a.type==="system")&&e.push({id:a.uuid,role:a.message.role,content:typeof a.message.content=="string"?a.message.content:JSON.stringify(a.message.content),timestamp:n,metadata:a.isCompactSummary?{isCompactSummary:!0}:void 0})}return{messages:e,topics:[],lastActivity:t}}async listSessions(){let{readdir:I}=await import("node:fs/promises"),{getProjectStoragePath:G}=await Promise.resolve().then(()=>(vg(),nrI)),c=G(this.projectPath);try{return(await I(c)).filter(t=>t.endsWith(".jsonl")).map(t=>t.replace(".jsonl",""))}catch{return[]}}async deleteSession(I){await this.getStore(I).delete()}async getSessionStats(I){let G=this.getStore(I);if(!G.exists())return null;let c=await G.readAll(),e=await G.getFileSize();return c.length===0?{messageCount:0,fileSize:e,createdAt:null,lastUpdatedAt:null}:{messageCount:c.length,fileSize:e,createdAt:new Date(c[0].timestamp),lastUpdatedAt:new Date(c[c.length-1].timestamp)}}}});var cV,$vI=L(()=>{"use strict";cV=class{cache=new Map;maxSize;defaultTtl;constructor(I=100,G=300*1e3){this.maxSize=I,this.defaultTtl=G}set(I,G,c){this.cache.size>=this.maxSize&&!this.cache.has(I)&&this.evictLRU();let e=Date.now();this.cache.set(I,{value:G,createdAt:e,lastAccessedAt:e,ttl:c??this.defaultTtl})}get(I){let G=this.cache.get(I);if(!G)return;let c=Date.now();if(c-G.createdAt>G.ttl){this.cache.delete(I);return}return G.lastAccessedAt=c,G.value}has(I){let G=this.cache.get(I);return G?Date.now()-G.createdAt>G.ttl?(this.cache.delete(I),!1):!0:!1}delete(I){return this.cache.delete(I)}async getOrSet(I,G,c){let e=this.get(I);if(e!==void 0)return e;let t=await G();return this.set(I,t,c),t}evictLRU(){let I=null,G=1/0;for(let[c,e]of this.cache)e.lastAccessedAt<G&&(G=e.lastAccessedAt,I=c);I&&this.cache.delete(I)}cleanup(){let I=Date.now(),G=0;for(let[c,e]of this.cache)I-e.createdAt>e.ttl&&(this.cache.delete(c),G++);return G}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size,maxSize:this.maxSize}}}});var I$=L(async()=>{"use strict";TvI();await _vI();$vI();P_();vg()});import*as lA from"node:fs/promises";import{existsSync as l$}from"node:fs";import*as qo from"node:path";var eV,G$=L(()=>{"use strict";eV=class{static MAX_FILES=5;static MAX_LINES_PER_FILE=1e3;static MAX_CHARS_PER_FILE=5e4;static analyzeFiles(I){let G=new Map;return I.forEach((c,e)=>{if(c.content){let t=typeof c.content=="string"?c.content:JSON.stringify(c.content);this.extractFilePathsFromContent(t).forEach(n=>{this.updateFileReference(G,n,e,!1)})}if(c.tool_calls&&Array.isArray(c.tool_calls))for(let t of c.tool_calls){let a=this.extractFilePathsFromToolCall(t),n=["Write","Edit"].includes(t.function?.name||"");a.forEach(Z=>{this.updateFileReference(G,Z,e,n)})}}),Array.from(G.values()).filter(c=>this.isValidFilePath(c.path)).sort((c,e)=>c.wasModified!==e.wasModified?c.wasModified?-1:1:c.mentions!==e.mentions?e.mentions-c.mentions:e.lastMentioned-c.lastMentioned).slice(0,this.MAX_FILES)}static extractFilePathsFromContent(I){let G=[],c=[/(?:^|\s|["'`])(\/?(?:[\w.-]+\/)+[\w.-]+\.[a-zA-Z]{1,10})(?:\s|$|["'`]|:)/gm,/(?:^|\s|["'`])(\.\/(?:[\w.-]+\/)*[\w.-]+\.[a-zA-Z]{1,10})(?:\s|$|["'`]|:)/gm,/```\d+:\d+:([\w./-]+)/gm];for(let e of c){let t;for(;(t=e.exec(I))!==null;){let a=t[1];a&&!G.includes(a)&&G.push(a)}}return G}static extractFilePathsFromToolCall(I){let G=[],c=I.function?.name,e={};try{typeof I.function?.arguments=="string"?e=JSON.parse(I.function.arguments):I.function?.arguments&&(e=I.function.arguments)}catch{return G}if(["Read","Write","Edit","Glob","Grep","NotebookEdit"].includes(c||"")){let a=["file_path","path","notebook_path","filePath"];for(let n of a)e[n]&&typeof e[n]=="string"&&G.push(e[n])}return G}static updateFileReference(I,G,c,e){let t=I.get(G);t?(t.mentions++,t.lastMentioned=Math.max(t.lastMentioned,c),t.wasModified=t.wasModified||e):I.set(G,{path:G,mentions:1,lastMentioned:c,wasModified:e})}static isValidFilePath(I){let G=[/^https?:\/\//,/^node_modules\//,/^\.git\//,/\.(png|jpg|jpeg|gif|svg|ico|webp|mp4|mp3|wav|pdf|zip|tar|gz)$/i];for(let c of G)if(c.test(I))return!1;try{let c=qo.isAbsolute(I)?I:qo.join(process.cwd(),I);return l$(c)}catch{return!1}}static async readFilesContent(I){let G=[];for(let c of I)try{let e=qo.isAbsolute(c)?c:qo.join(process.cwd(),c);if(!l$(e))continue;let t=await lA.readFile(e,"utf-8"),a=t.split(`
|
|
1063
1063
|
`),n=!1,Z=t;a.length>this.MAX_LINES_PER_FILE&&(Z=a.slice(0,this.MAX_LINES_PER_FILE).join(`
|
|
1064
1064
|
`),n=!0),Z.length>this.MAX_CHARS_PER_FILE&&(Z=Z.substring(0,this.MAX_CHARS_PER_FILE),n=!0),n&&(Z+=`
|
|
1065
1065
|
|
|
@@ -1954,7 +1954,7 @@ ${R.join(`
|
|
|
1954
1954
|
\u2554\u2550\u2557\u2554\u2550\u2557\u2554\u2550\u2557\u2566\u2554\u2550\u2557
|
|
1955
1955
|
\u2560\u2550\u2563\u2551\u2563 \u2551 \u2566\u2551\u255A\u2550\u2557
|
|
1956
1956
|
\u2569 \u2569\u255A\u2550\u255D\u255A\u2550\u255D\u2569\u255A\u2550\u255D`}),(0,la.jsx)(rI,{marginLeft:2,children:(0,la.jsxs)(cI,{color:I.colors.text.muted,dimColor:!0,children:["v",$_.version]})}),(0,la.jsxs)(rI,{marginLeft:2,children:[(0,la.jsx)(cI,{color:I.colors.primary,bold:!0,children:"\xC6GIS "}),(0,la.jsx)(cI,{color:I.colors.text.muted,dimColor:!0,children:"\xB7 terminal coding agent"})]}),(0,la.jsx)(rI,{marginLeft:2,children:(0,la.jsx)(cI,{color:I.colors.text.muted,dimColor:!0,children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"})})]}),(0,la.jsx)(rI,{flexDirection:"column",marginTop:0,marginLeft:2,children:pyI.map(({cmd:e,desc:t},a)=>(0,la.jsx)(OZl,{cmd:e,desc:t,delayMs:G+a*100},e))}),(0,la.jsx)(rI,{marginTop:0,marginLeft:2,children:(0,la.jsx)(cI,{color:I.colors.text.muted,dimColor:!0,children:"Ctrl+Z exit \xB7 Ctrl+F search \xB7 Alt+C copy last"})}),!process.env.CLAUDE_CODE_OAUTH_TOKEN&&(0,la.jsx)(rI,{marginTop:0,marginLeft:2,children:(0,la.jsx)(cI,{color:I.colors.text.muted,dimColor:!0,children:"Have Claude Pro/Max? Run aegis login --claude-pro to use your subscription"})})]})});wII.displayName="WelcomeMessage";var kG=OI(Jl(),1);await Kt();gt();h2();Qh();zd();var Nm=OI(ac(),1),MZl=.18,jZl=.5;function RA(l,I){if(!l)return 0;let G=Math.max(I,20),c=l.split(`
|
|
1957
|
-
`),e=0;for(let t of c){let a=t.length;e+=a===0?1:Math.max(1,Math.ceil(a/G))}return e}function uyI(l,I,G,c){let e=1;if(I&&I.length>0&&(e+=1,e+=RA(I,G)),c&&c.length>0){for(let t of c)switch(t.type){case"thinking":e+=1,e+=RA(t.thinking||"",G);break;case"text":e+=RA(t.text||"",G);break;case"tool_use":e+=2;break;case"tool_result":e+=Math.min(RA(t.content||"",G),6);break}return e}return e+=RA(l,G),e}var SZl=16,KZl=1,DZl=8,TZl=6,hyI=5e4;var qZl=500,PZl=1.6,_Zl=.25,EII=kG.default.memo(({terminalWidth:l,terminalHeight:I,onScrolledUpChange:G,onRenderLatency:c,pendingCommandCount:e=0,extraOverheadLines:t=0})=>{let[a,n]=(0,kG.useState)(()=>FG().session.messages),[Z,N]=(0,kG.useState)(()=>$d.getState().app.showAllThinking),[p,u]=(0,kG.useState)(0),[h,Y]=(0,kG.useState)(0),[R,F]=(0,kG.useState)(0),X=(0,kG.useRef)(0),H=(0,kG.useRef)(!1),g=(0,kG.useRef)(null),[A,C]=(0,kG.useState)(!0),y=(0,kG.useRef)(A);y.current=A;let J=(0,kG.useRef)(a);J.current=a;let M=(0,kG.useRef)(Z);M.current=Z;let f=(0,kG.useRef)(l);f.current=l;let z=(0,kG.useRef)(I);z.current=I;let S=(0,kG.useRef)(G);S.current=G;let K=(0,kG.useRef)(c);K.current=c;let j=(0,kG.useRef)(h);j.current=h;let II=(0,kG.useRef)(0),$=(0,kG.useRef)(0),q=(0,kG.useRef)(null),T=(0,kG.useRef)(0);function GI(){if(!H.current)return;let UI=X.current,nl=j.current,ol=nl-UI;if(Math.abs(ol)<=jZl){X.current=nl,F(nl),H.current=!1,g.current=null;return}let PI=UI+ol*MZl;X.current=PI,F(PI),g.current=requestAnimationFrame(GI)}function eI(UI){Y(UI),H.current||(H.current=!0,GI())}function wI(UI){H.current=!1,g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),X.current=UI,F(UI),Y(UI)}let JI=Math.max(I-TZl-t,5),pI=a.filter(UI=>!UI.isStreaming),RI=pI.length>hyI?pI.slice(-hyI):pI,xI=a.find(UI=>UI.isStreaming&&ew(UI)),XI=xI?_Y():null,KI=(0,kG.useMemo)(()=>RI.map(UI=>uyI(UI.content,UI.thinking,l,UI.contentBlocks)),[RI,l]),zI=(0,kG.useMemo)(()=>{let UI=[0];for(let nl=0;nl<KI.length;nl++)UI.push(UI[nl]+KI[nl]);return UI},[KI]),jI=xI&&XI?uyI(xI.content+XI.content,(xI.thinking||"")+XI.thinking,l,xI.contentBlocks):0,ll=(zI[zI.length-1]||0)+jI,VI=Math.max(0,ll-JI);II.current=VI;let _I=A?0:Math.min(R,VI),yl=A?VI:_I,Pl=yl>=VI,nG=(0,kG.useMemo)(()=>{if(zI.length<=1)return 0;let UI=0,nl=zI.length-1;for(;UI<nl;){let ol=Math.floor((UI+nl+1)/2);zI[ol]<=yl?UI=ol:nl=ol-1}return UI},[yl,zI]);(0,kG.useEffect)(()=>{Y(UI=>Math.min(UI,VI)),F(UI=>Math.min(UI,VI))},[VI]);let gl=ll>JI,_=RI,tI=!1;if(gl){_=[];let UI=JI;for(let ol=nG;ol<RI.length&&UI>0;ol++)_.push(RI[ol]),UI-=KI[ol];let nl=_.length>0&&_[_.length-1].id===RI[RI.length-1]?.id;if(!nl&&RI.length>0){let ol=RI[RI.length-1];if(_.length>0){let PI=KI[RI.indexOf(_[_.length-1])];UI+=PI,_[_.length-1]=ol,UI-=KI[RI.length-1]}else _.push(ol)}tI=!Pl&&RI.length>0&&!nl}let EI=(0,kG.useRef)(!1);(0,kG.useEffect)(()=>{let UI=gl&&!Pl;UI!==EI.current&&(EI.current=UI,S.current?.(UI))},[gl,Pl]);function lI(UI,nl){let ol=performance.now();(nl!==q.current||ol-$.current>qZl)&&(T.current=0),q.current=nl,$.current=ol,T.current+=1;let PI=Math.min(Math.pow(PZl,T.current-1),10),il=Math.round(UI*PI),pl=Math.max(1,Math.floor(JI*_Zl));return Math.min(il,pl)}let sI=(0,kG.useCallback)(UI=>{let nl=lI(UI,"up"),ol=y.current?II.current:j.current,PI=Math.max(0,ol-nl);C(!1),eI(PI)},[JI]),TI=(0,kG.useCallback)(UI=>{let nl=lI(UI,"down"),ol=y.current?II.current:j.current,PI=II.current,il=Math.min(PI,ol+nl);eI(il),il>=PI&&C(!0)},[JI]);function LI(){q.current=null,T.current=0}je((UI,nl)=>{if(nl.pageUp||nl.ctrl&&UI===""){sI(JI);return}if(nl.pageDown||nl.ctrl&&UI===""){TI(JI);return}if(nl.ctrl&&UI===""){sI(Math.max(1,Math.floor(JI/2)));return}if(nl.ctrl&&UI===""){TI(Math.max(1,Math.floor(JI/2)));return}if(nl.upArrow&&nl.ctrl){sI(1);return}if(nl.downArrow&&nl.ctrl){TI(1);return}if(nl.home){LI(),C(!1),wI(0);return}if(nl.end){LI(),wI(II.current),C(!0);return}LI()});let $I=(0,kG.useRef)(null),_l=(0,kG.useRef)({}),yG=(0,kG.useRef)(!1),Jc=(0,kG.useRef)(null),al=(0,kG.useRef)(0);function Rl(){if(yG.current)return;yG.current=!0;let UI=nl=>{if(!yG.current)return;if(nl-al.current<SZl){Jc.current=requestAnimationFrame(UI);return}if(al.current=nl,$I.current){let uI=$I.current;$I.current=null,n(uI)}let ol=_Y(),il=$d.getState().session.messages.find(uI=>uI.isStreaming&&ew(uI));if(ol&&il){let uI=_l.current[il.id]||{content:0,thinking:0};(uI.content>ol.content.length||uI.thinking>ol.thinking.length)&&(_l.current[il.id]={content:0,thinking:0});let SI=_l.current[il.id]||{content:0,thinking:0},Zl=ol.content.length-SI.content,Fl=ol.thinking.length-SI.thinking,GG=SI.thinking===0&&ol.thinking.length>0;if(Zl>=KZl||Fl>=DZl||GG){_l.current[il.id]={content:ol.content.length,thinking:ol.thinking.length},u(zG=>zG+1);let Ul=oM();Ul>30&&K.current?.(Ul)}}let pl=$I.current!==null,hG=$d.getState().session.messages.find(uI=>uI.isStreaming&&ew(uI)),x=!!(_Y()&&hG);pl||x?Jc.current=requestAnimationFrame(UI):(yG.current=!1,Jc.current=null)};Jc.current=requestAnimationFrame(UI)}return(0,kG.useEffect)(()=>{let UI=$d.subscribe(nl=>{let ol=nl.session.messages,PI=nl.app.showAllThinking,il=J.current,pl=!1;if(ol.length!==il.length)pl=!0;else for(let $l=0;$l<ol.length;$l++){let hG=il[$l],x=ol[$l];if(hG.id!==x.id||hG.isStreaming!==x.isStreaming||hG.content!==x.content||hG.thinking!==x.thinking||hG.contentBlocks!==x.contentBlocks){pl=!0;break}}if(pl){let $l=il.length,hG=ol.length;if(hG>$l){let x=ol[hG-1];x?.role==="user"||x?.isStreaming?(eI(II.current),C(!0)):y.current&&C(!0)}$I.current=[...ol],Rl()}ol.length>0&&ol[ol.length-1].isStreaming&&Rl(),PI!==M.current&&N(PI),ol.forEach($l=>{$l.isStreaming||delete _l.current[$l.id]})});return()=>{yG.current=!1,Jc.current!==null&&cancelAnimationFrame(Jc.current),Jc.current=null,H.current=!1,g.current!==null&&cancelAnimationFrame(g.current),g.current=null,UI()}},[]),(0,Nm.jsxs)(rI,{flexDirection:"column",children:[(0,Nm.jsx)(rI,{height:1,flexShrink:0,children:gl&&!Pl&&!xI?(0,Nm.jsxs)(cI,{color:_G.getTheme().colors.text.muted,dimColor:!0,children:["\u2191 ",yl," lines above"]}):(0,Nm.jsx)(cI,{children:" "})}),_.map(UI=>(0,Nm.jsx)(pV,{content:UI.content,role:UI.role,terminalWidth:l,showPrefix:!0,thinking:UI.thinking,isStreaming:!1,showAllThinking:Z,contentBlocks:UI.contentBlocks},UI.id)),xI&&(()=>{let UI=XI?xI.content+XI.content:xI.content,nl=XI?(xI.thinking||"")+XI.thinking:xI.thinking,ol=xI.contentBlocks||[],PI=XI?Fh():[],pl=ol.map(hG=>{if(hG.type==="tool_use"){let x=PI.find(uI=>uI.id===hG.id);if(x&&x.arguments)return{...hG,input:x.arguments}}return hG}).filter(hG=>hG.type!=="text"&&hG.type!=="thinking"),$l=[];return nl&&$l.push({type:"thinking",thinking:nl}),UI&&$l.push({type:"text",text:UI}),$l.push(...pl),(0,Nm.jsx)(pV,{content:UI,role:xI.role,terminalWidth:l,showPrefix:!0,thinking:nl,isStreaming:!0,showAllThinking:Z,contentBlocks:$l},xI.id)})(),(0,Nm.jsxs)(rI,{flexDirection:"column",flexShrink:0,children:[tI&&(0,Nm.jsx)(rI,{height:1,flexShrink:0,children:(0,Nm.jsx)(cI,{color:_G.getTheme().colors.text.muted,dimColor:!0,children:"\u22EF latest (End to jump here) \u22EF"})}),tI&&(0,Nm.jsx)(pV,{content:RI[RI.length-1].content,role:RI[RI.length-1].role,terminalWidth:l,showPrefix:!0,thinking:RI[RI.length-1].thinking,isStreaming:!1,showAllThinking:Z,contentBlocks:RI[RI.length-1].contentBlocks},"last-"+RI[RI.length-1].id)]})]})});EII.displayName="MessageList";var oyI=OI(Jl(),1);await Kt();zd();var lZ=OI(ac(),1),$Zl={building:"#22c55e",refactoring:"#f59e0b",debugging:"#ef4444",testing:"#3b82f6",planning:"#7c6fd4"};function Iml(l){let I=l.toLowerCase().trim();for(let[G,c]of Object.entries($Zl))if(I.includes(G)||G.includes(I))return c;return _G.getTheme().colors.primary}var gII=oyI.default.memo(({workflow:l})=>{let I=_G.getTheme();if(!l.visible)return null;let G=Iml(l.phase),c=`\u25CF ${l.phase} ${l.target}`,e=`${l.currentStepIndex}/${l.totalSteps}`,t=l.steps.map((n,Z)=>{let N=n.status==="active"?"\u25C9":n.status==="done"?"\u25CF":"\u25CB",p=n.status==="active"?G:n.status==="done"?I.colors.success:I.colors.text.muted;return(0,lZ.jsxs)(cI,{color:p,children:[N," ",n.label,Z<l.steps.length-1&&(0,lZ.jsx)(cI,{color:I.colors.text.muted,children:" \xB7 "})]},Z)}),a=I.colors.border.light;return(0,lZ.jsxs)(rI,{flexDirection:"column",marginTop:0,marginBottom:0,children:[(0,lZ.jsxs)(rI,{children:[(0,lZ.jsx)(cI,{color:a,children:"\u2500"}),(0,lZ.jsx)(cI,{children:" "}),(0,lZ.jsx)(cI,{color:G,bold:!0,children:c}),(0,lZ.jsxs)(cI,{color:I.colors.text.muted,children:[" \xB7 ",e]})]}),(0,lZ.jsx)(rI,{marginLeft:1,children:t}),(0,lZ.jsx)(rI,{children:(0,lZ.jsx)(cI,{color:a,children:"\u2500"})})]})});gII.displayName="ContextBar";var iyI=OI(Jl(),1);await Kt();zd();var $e=OI(ac(),1),YyI=({details:l,onResponse:I})=>{let[G,c]=(0,iyI.useState)(0),e=_G.getTheme(),t=hw("confirmation-prompt"),a=[{key:"y",label:"allow",scope:"once",approved:!0},{key:"a",label:"always",scope:"session",approved:!0},{key:"n",label:"deny",scope:"once",approved:!1},{key:"d",label:"never",scope:"session",approved:!1}];je((h,Y)=>{if(Y.upArrow)c(R=>R>0?R-1:a.length-1);else if(Y.downArrow)c(R=>R<a.length-1?R+1:0);else if(Y.return){let R=a[G];I({approved:R.approved,scope:R.scope,reason:R.approved?void 0:"denied"})}else h==="y"||h==="Y"?I({approved:!0,scope:"once"}):h==="a"||h==="A"?I({approved:!0,scope:"session"}):h==="n"||h==="N"?I({approved:!1,scope:"once",reason:"denied"}):(h==="d"||h==="D")&&I({approved:!1,scope:"session",reason:"denied for this session"})},{isActive:t});let n=l.title.replace(/^.*:\s*/,""),Z=["Bash","Shell"].includes(n)&&l.details?.includes("**Command:**"),{label:N,highlight:p,extra:u}=lml(l.details);return(0,$e.jsxs)(rI,{flexDirection:"column",paddingX:1,children:[!Z&&(0,$e.jsxs)(rI,{children:[(0,$e.jsx)(cI,{color:e.colors.warning,bold:!0,children:"? "}),(0,$e.jsx)(cI,{bold:!0,children:n}),l.message&&l.message!==l.title&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[" \xB7 ",l.message]})]}),Z&&p&&(0,$e.jsxs)(rI,{children:[(0,$e.jsx)(cI,{color:e.colors.warning,bold:!0,children:"? "}),N&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[N," "]}),(0,$e.jsx)(cI,{color:e.colors.accent,wrap:"wrap",children:p})]}),!Z&&p&&(0,$e.jsxs)(rI,{marginLeft:2,children:[N&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[N," "]}),(0,$e.jsx)(cI,{color:e.colors.accent,wrap:"wrap",children:p})]}),u.length>0&&(0,$e.jsx)(rI,{flexDirection:"column",marginLeft:2,children:u.map((h,Y)=>(0,$e.jsx)(cI,{color:e.colors.text.muted,dimColor:!0,wrap:"wrap",children:h},Y))}),l.affectedFiles&&l.affectedFiles.length>0&&(0,$e.jsx)(rI,{marginLeft:2,children:(0,$e.jsx)(cI,{color:e.colors.info,dimColor:!0,children:l.affectedFiles.join(", ")})}),l.risks&&l.risks.length>0&&(0,$e.jsx)(rI,{marginLeft:2,children:(0,$e.jsx)(cI,{color:e.colors.text.muted,dimColor:!0,children:l.risks.join(" \xB7 ")})}),(0,$e.jsx)(rI,{flexDirection:"column",marginLeft:2,marginTop:1,children:a.map((h,Y)=>{let R=Y===G;return(0,$e.jsxs)(rI,{children:[(0,$e.jsxs)(cI,{color:R?e.colors.success:e.colors.text.muted,bold:R,dimColor:!R,children:[R?"> ":" ",h.label]}),(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[" (",h.key,")"]})]},h.key)})})]})};function lml(l){if(!l)return{label:"",highlight:"",extra:[]};let I=N=>N.replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),G=l.split(`
|
|
1957
|
+
`),e=0;for(let t of c){let a=t.length;e+=a===0?1:Math.max(1,Math.ceil(a/G))}return e}function uyI(l,I,G,c){let e=1;if(I&&I.length>0&&(e+=1,e+=RA(I,G)),c&&c.length>0){for(let t of c)switch(t.type){case"thinking":e+=1,e+=RA(t.thinking||"",G);break;case"text":e+=RA(t.text||"",G);break;case"tool_use":e+=2;break;case"tool_result":e+=Math.min(RA(t.content||"",G),6);break}return e}return e+=RA(l,G),e}var SZl=16,KZl=1,DZl=8,TZl=6,hyI=5e4;var qZl=500,PZl=1.6,_Zl=.25,EII=kG.default.memo(({terminalWidth:l,terminalHeight:I,onScrolledUpChange:G,onRenderLatency:c,pendingCommandCount:e=0,extraOverheadLines:t=0})=>{let[a,n]=(0,kG.useState)(()=>FG().session.messages),[Z,N]=(0,kG.useState)(()=>$d.getState().app.showAllThinking),[p,u]=(0,kG.useState)(0),[h,Y]=(0,kG.useState)(0),[R,F]=(0,kG.useState)(0),X=(0,kG.useRef)(0),H=(0,kG.useRef)(!1),g=(0,kG.useRef)(null),[A,C]=(0,kG.useState)(!0),y=(0,kG.useRef)(A);y.current=A;let J=(0,kG.useRef)(a);J.current=a;let M=(0,kG.useRef)(Z);M.current=Z;let f=(0,kG.useRef)(l);f.current=l;let z=(0,kG.useRef)(I);z.current=I;let S=(0,kG.useRef)(G);S.current=G;let K=(0,kG.useRef)(c);K.current=c;let j=(0,kG.useRef)(h);j.current=h;let II=(0,kG.useRef)(0),$=(0,kG.useRef)(0),q=(0,kG.useRef)(null),T=(0,kG.useRef)(0);function GI(){if(!H.current)return;let UI=X.current,nl=j.current,ol=nl-UI;if(Math.abs(ol)<=jZl){X.current=nl,F(nl),H.current=!1,g.current=null;return}let PI=UI+ol*MZl;X.current=PI,F(PI),g.current=requestAnimationFrame(GI)}function eI(UI){j.current=UI,Y(UI),H.current||(H.current=!0,GI())}function wI(UI){H.current=!1,g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),X.current=UI,F(UI),Y(UI)}let JI=Math.max(I-TZl-t,5),pI=a.filter(UI=>!UI.isStreaming),RI=pI.length>hyI?pI.slice(-hyI):pI,xI=a.find(UI=>UI.isStreaming&&ew(UI)),XI=xI?_Y():null,KI=(0,kG.useMemo)(()=>RI.map(UI=>uyI(UI.content,UI.thinking,l,UI.contentBlocks)),[RI,l]),zI=(0,kG.useMemo)(()=>{let UI=[0];for(let nl=0;nl<KI.length;nl++)UI.push(UI[nl]+KI[nl]);return UI},[KI]),jI=xI&&XI?uyI(xI.content+XI.content,(xI.thinking||"")+XI.thinking,l,xI.contentBlocks):0,ll=(zI[zI.length-1]||0)+jI,VI=Math.max(0,ll-JI);II.current=VI;let _I=A?0:Math.min(R,VI),yl=A?VI:_I,Pl=yl>=VI,nG=(0,kG.useMemo)(()=>{if(zI.length<=1)return 0;let UI=0,nl=zI.length-1;for(;UI<nl;){let ol=Math.floor((UI+nl+1)/2);zI[ol]<=yl?UI=ol:nl=ol-1}return UI},[yl,zI]);(0,kG.useEffect)(()=>{Y(UI=>Math.min(UI,VI)),F(UI=>Math.min(UI,VI))},[VI]);let gl=ll>JI,_=RI,tI=!1;if(gl){_=[];let UI=JI;for(let ol=nG;ol<RI.length&&UI>0;ol++)_.push(RI[ol]),UI-=KI[ol];let nl=_.length>0&&_[_.length-1].id===RI[RI.length-1]?.id;if(!nl&&RI.length>0){let ol=RI[RI.length-1];if(_.length>0){let PI=KI[RI.indexOf(_[_.length-1])];UI+=PI,_[_.length-1]=ol,UI-=KI[RI.length-1]}else _.push(ol)}tI=!Pl&&RI.length>0&&!nl}let EI=(0,kG.useRef)(!1);(0,kG.useEffect)(()=>{let UI=gl&&!Pl;UI!==EI.current&&(EI.current=UI,S.current?.(UI))},[gl,Pl]);function lI(UI,nl){let ol=performance.now();(nl!==q.current||ol-$.current>qZl)&&(T.current=0),q.current=nl,$.current=ol,T.current+=1;let PI=Math.min(Math.pow(PZl,T.current-1),10),il=Math.round(UI*PI),pl=Math.max(1,Math.floor(JI*_Zl));return Math.min(il,pl)}let sI=(0,kG.useCallback)(UI=>{let nl=lI(UI,"up"),ol=y.current?II.current:j.current,PI=Math.max(0,ol-nl);C(!1),eI(PI)},[JI]),TI=(0,kG.useCallback)(UI=>{let nl=lI(UI,"down"),ol=y.current?II.current:j.current,PI=II.current,il=Math.min(PI,ol+nl);eI(il),il>=PI&&C(!0)},[JI]);function LI(){q.current=null,T.current=0}je((UI,nl)=>{if(nl.pageUp||nl.ctrl&&UI===""){sI(JI);return}if(nl.pageDown||nl.ctrl&&UI===""){TI(JI);return}if(nl.ctrl&&UI===""){sI(Math.max(1,Math.floor(JI/2)));return}if(nl.ctrl&&UI===""){TI(Math.max(1,Math.floor(JI/2)));return}if(nl.upArrow&&nl.ctrl){sI(1);return}if(nl.downArrow&&nl.ctrl){TI(1);return}if(nl.home){LI(),C(!1),wI(0);return}if(nl.end){LI(),wI(II.current),C(!0);return}LI()});let $I=(0,kG.useRef)(null),_l=(0,kG.useRef)({}),yG=(0,kG.useRef)(!1),Jc=(0,kG.useRef)(null),al=(0,kG.useRef)(0);function Rl(){if(yG.current)return;yG.current=!0;let UI=nl=>{if(!yG.current)return;if(nl-al.current<SZl){Jc.current=requestAnimationFrame(UI);return}if(al.current=nl,$I.current){let uI=$I.current;$I.current=null,n(uI)}let ol=_Y(),il=$d.getState().session.messages.find(uI=>uI.isStreaming&&ew(uI));if(ol&&il){let uI=_l.current[il.id]||{content:0,thinking:0};(uI.content>ol.content.length||uI.thinking>ol.thinking.length)&&(_l.current[il.id]={content:0,thinking:0});let SI=_l.current[il.id]||{content:0,thinking:0},Zl=ol.content.length-SI.content,Fl=ol.thinking.length-SI.thinking,GG=SI.thinking===0&&ol.thinking.length>0;if(Zl>=KZl||Fl>=DZl||GG){_l.current[il.id]={content:ol.content.length,thinking:ol.thinking.length},u(zG=>zG+1);let Ul=oM();Ul>30&&K.current?.(Ul)}}let pl=$I.current!==null,hG=$d.getState().session.messages.find(uI=>uI.isStreaming&&ew(uI)),x=!!(_Y()&&hG);pl||x?Jc.current=requestAnimationFrame(UI):(yG.current=!1,Jc.current=null)};Jc.current=requestAnimationFrame(UI)}return(0,kG.useEffect)(()=>{let UI=$d.subscribe(nl=>{let ol=nl.session.messages,PI=nl.app.showAllThinking,il=J.current,pl=!1;if(ol.length!==il.length)pl=!0;else for(let $l=0;$l<ol.length;$l++){let hG=il[$l],x=ol[$l];if(hG.id!==x.id||hG.isStreaming!==x.isStreaming||hG.content!==x.content||hG.thinking!==x.thinking||hG.contentBlocks!==x.contentBlocks){pl=!0;break}}if(pl){let $l=il.length,hG=ol.length;if(hG>$l){let x=ol[hG-1];x?.role==="user"||x?.isStreaming?(eI(II.current),C(!0)):y.current&&C(!0)}$I.current=[...ol],Rl()}ol.length>0&&ol[ol.length-1].isStreaming&&Rl(),PI!==M.current&&N(PI),ol.forEach($l=>{$l.isStreaming||delete _l.current[$l.id]})});return()=>{yG.current=!1,Jc.current!==null&&cancelAnimationFrame(Jc.current),Jc.current=null,H.current=!1,g.current!==null&&cancelAnimationFrame(g.current),g.current=null,UI()}},[]),(0,Nm.jsxs)(rI,{flexDirection:"column",children:[(0,Nm.jsx)(rI,{height:1,flexShrink:0,children:gl&&!Pl&&!xI?(0,Nm.jsxs)(cI,{color:_G.getTheme().colors.text.muted,dimColor:!0,children:["\u2191 ",yl," lines above"]}):(0,Nm.jsx)(cI,{children:" "})}),_.map(UI=>(0,Nm.jsx)(pV,{content:UI.content,role:UI.role,terminalWidth:l,showPrefix:!0,thinking:UI.thinking,isStreaming:!1,showAllThinking:Z,contentBlocks:UI.contentBlocks},UI.id)),xI&&(()=>{let UI=XI?xI.content+XI.content:xI.content,nl=XI?(xI.thinking||"")+XI.thinking:xI.thinking,ol=xI.contentBlocks||[],PI=XI?Fh():[],pl=ol.map(hG=>{if(hG.type==="tool_use"){let x=PI.find(uI=>uI.id===hG.id);if(x&&x.arguments)return{...hG,input:x.arguments}}return hG}).filter(hG=>hG.type!=="text"&&hG.type!=="thinking"),$l=[];return nl&&$l.push({type:"thinking",thinking:nl}),UI&&$l.push({type:"text",text:UI}),$l.push(...pl),(0,Nm.jsx)(pV,{content:UI,role:xI.role,terminalWidth:l,showPrefix:!0,thinking:nl,isStreaming:!0,showAllThinking:Z,contentBlocks:$l},xI.id)})(),(0,Nm.jsxs)(rI,{flexDirection:"column",flexShrink:0,children:[tI&&(0,Nm.jsx)(rI,{height:1,flexShrink:0,children:(0,Nm.jsx)(cI,{color:_G.getTheme().colors.text.muted,dimColor:!0,children:"\u22EF latest (End to jump here) \u22EF"})}),tI&&(0,Nm.jsx)(pV,{content:RI[RI.length-1].content,role:RI[RI.length-1].role,terminalWidth:l,showPrefix:!0,thinking:RI[RI.length-1].thinking,isStreaming:!1,showAllThinking:Z,contentBlocks:RI[RI.length-1].contentBlocks},"last-"+RI[RI.length-1].id)]})]})});EII.displayName="MessageList";var oyI=OI(Jl(),1);await Kt();zd();var lZ=OI(ac(),1),$Zl={building:"#22c55e",refactoring:"#f59e0b",debugging:"#ef4444",testing:"#3b82f6",planning:"#7c6fd4"};function Iml(l){let I=l.toLowerCase().trim();for(let[G,c]of Object.entries($Zl))if(I.includes(G)||G.includes(I))return c;return _G.getTheme().colors.primary}var gII=oyI.default.memo(({workflow:l})=>{let I=_G.getTheme();if(!l.visible)return null;let G=Iml(l.phase),c=`\u25CF ${l.phase} ${l.target}`,e=`${l.currentStepIndex}/${l.totalSteps}`,t=l.steps.map((n,Z)=>{let N=n.status==="active"?"\u25C9":n.status==="done"?"\u25CF":"\u25CB",p=n.status==="active"?G:n.status==="done"?I.colors.success:I.colors.text.muted;return(0,lZ.jsxs)(cI,{color:p,children:[N," ",n.label,Z<l.steps.length-1&&(0,lZ.jsx)(cI,{color:I.colors.text.muted,children:" \xB7 "})]},Z)}),a=I.colors.border.light;return(0,lZ.jsxs)(rI,{flexDirection:"column",marginTop:0,marginBottom:0,children:[(0,lZ.jsxs)(rI,{children:[(0,lZ.jsx)(cI,{color:a,children:"\u2500"}),(0,lZ.jsx)(cI,{children:" "}),(0,lZ.jsx)(cI,{color:G,bold:!0,children:c}),(0,lZ.jsxs)(cI,{color:I.colors.text.muted,children:[" \xB7 ",e]})]}),(0,lZ.jsx)(rI,{marginLeft:1,children:t}),(0,lZ.jsx)(rI,{children:(0,lZ.jsx)(cI,{color:a,children:"\u2500"})})]})});gII.displayName="ContextBar";var iyI=OI(Jl(),1);await Kt();zd();var $e=OI(ac(),1),YyI=({details:l,onResponse:I})=>{let[G,c]=(0,iyI.useState)(0),e=_G.getTheme(),t=hw("confirmation-prompt"),a=[{key:"y",label:"allow",scope:"once",approved:!0},{key:"a",label:"always",scope:"session",approved:!0},{key:"n",label:"deny",scope:"once",approved:!1},{key:"d",label:"never",scope:"session",approved:!1}];je((h,Y)=>{if(Y.upArrow)c(R=>R>0?R-1:a.length-1);else if(Y.downArrow)c(R=>R<a.length-1?R+1:0);else if(Y.return){let R=a[G];I({approved:R.approved,scope:R.scope,reason:R.approved?void 0:"denied"})}else h==="y"||h==="Y"?I({approved:!0,scope:"once"}):h==="a"||h==="A"?I({approved:!0,scope:"session"}):h==="n"||h==="N"?I({approved:!1,scope:"once",reason:"denied"}):(h==="d"||h==="D")&&I({approved:!1,scope:"session",reason:"denied for this session"})},{isActive:t});let n=l.title.replace(/^.*:\s*/,""),Z=["Bash","Shell"].includes(n)&&l.details?.includes("**Command:**"),{label:N,highlight:p,extra:u}=lml(l.details);return(0,$e.jsxs)(rI,{flexDirection:"column",paddingX:1,children:[!Z&&(0,$e.jsxs)(rI,{children:[(0,$e.jsx)(cI,{color:e.colors.warning,bold:!0,children:"? "}),(0,$e.jsx)(cI,{bold:!0,children:n}),l.message&&l.message!==l.title&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[" \xB7 ",l.message]})]}),Z&&p&&(0,$e.jsxs)(rI,{children:[(0,$e.jsx)(cI,{color:e.colors.warning,bold:!0,children:"? "}),N&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[N," "]}),(0,$e.jsx)(cI,{color:e.colors.accent,wrap:"wrap",children:p})]}),!Z&&p&&(0,$e.jsxs)(rI,{marginLeft:2,children:[N&&(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[N," "]}),(0,$e.jsx)(cI,{color:e.colors.accent,wrap:"wrap",children:p})]}),u.length>0&&(0,$e.jsx)(rI,{flexDirection:"column",marginLeft:2,children:u.map((h,Y)=>(0,$e.jsx)(cI,{color:e.colors.text.muted,dimColor:!0,wrap:"wrap",children:h},Y))}),l.affectedFiles&&l.affectedFiles.length>0&&(0,$e.jsx)(rI,{marginLeft:2,children:(0,$e.jsx)(cI,{color:e.colors.info,dimColor:!0,children:l.affectedFiles.join(", ")})}),l.risks&&l.risks.length>0&&(0,$e.jsx)(rI,{marginLeft:2,children:(0,$e.jsx)(cI,{color:e.colors.text.muted,dimColor:!0,children:l.risks.join(" \xB7 ")})}),(0,$e.jsx)(rI,{flexDirection:"column",marginLeft:2,marginTop:1,children:a.map((h,Y)=>{let R=Y===G;return(0,$e.jsxs)(rI,{children:[(0,$e.jsxs)(cI,{color:R?e.colors.success:e.colors.text.muted,bold:R,dimColor:!R,children:[R?"> ":" ",h.label]}),(0,$e.jsxs)(cI,{color:e.colors.text.muted,dimColor:!0,children:[" (",h.key,")"]})]},h.key)})})]})};function lml(l){if(!l)return{label:"",highlight:"",extra:[]};let I=N=>N.replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1").trim(),G=l.split(`
|
|
1958
1958
|
`).filter(N=>N.trim()),c="",e="",t=[],a=[],n=!1,Z=/^(Command|File|Directory|Content Preview|Before|After):\s*/;for(let N of G){let p=I(N);p==="```"||p.startsWith("```")||(/^Command:\s*/.test(p)?(c="Command:",t.push(p.replace(/^Command:\s*/,"")),n=!0):/^File:\s*/.test(p)?(c="File:",t.push(p.replace(/^File:\s*/,"")),n=!0):/^(Directory|Content Preview|Before|After):\s*/.test(p)?(n=!1,a.push(p)):n?t.push(p):p&&a.push(p))}return e=t.join(`
|
|
1959
1959
|
`),{label:c,highlight:e,extra:a}}var au=OI(Jl(),1);await Kt();zd();var Bd=OI(ac(),1);function ryI({title:l,options:I,onSelect:G,onCancel:c,initialIndex:e=0,focusId:t="selector",maxVisible:a=10}){let n=_G.getTheme(),[Z,N]=(0,au.useState)(()=>{let X=I.findIndex(H=>H.isCurrent);return X>=0?X:e}),[p,u]=(0,au.useState)(0),h=(0,au.useRef)(!1);(0,au.useEffect)(()=>{h.current=!1},[I]),(0,au.useEffect)(()=>{u(X=>Z<X?Z:Z>=X+a?Z-a+1:X)},[Z,a]),je((X,H)=>{Un.getCurrentFocus()===t&&(H.upArrow||X==="k"?N(g=>g>0?g-1:I.length-1):H.downArrow||X==="j"?N(g=>g<I.length-1?g+1:0):H.pageUp?N(g=>Math.max(0,g-a)):H.pageDown?N(g=>Math.min(I.length-1,g+a)):H.return?h.current||(h.current=!0,G(I[Z].value)):(H.escape||X==="q")&&c())}),(0,au.useEffect)(()=>{Z>=I.length&&N(0)},[I.length,Z]);let Y=I.slice(p,p+a),R=p>0,F=p+a<I.length;return(0,Bd.jsxs)(rI,{flexDirection:"column",borderStyle:"round",borderColor:n.colors.primary,paddingX:2,paddingY:1,children:[(0,Bd.jsxs)(rI,{marginBottom:1,flexDirection:"row",justifyContent:"space-between",children:[(0,Bd.jsx)(cI,{bold:!0,color:n.colors.primary,children:l}),I.length>a&&(0,Bd.jsxs)(cI,{color:n.colors.text.muted,dimColor:!0,children:[Z+1,"/",I.length]})]}),R&&(0,Bd.jsx)(rI,{children:(0,Bd.jsxs)(cI,{color:n.colors.text.muted,dimColor:!0,children:[" \u2191 ",p," more"]})}),(0,Bd.jsx)(rI,{flexDirection:"column",children:Y.map((X,H)=>{let A=p+H===Z;return(0,Bd.jsxs)(rI,{flexDirection:"row",children:[(0,Bd.jsxs)(cI,{color:A?n.colors.primary:n.colors.text.primary,bold:A,children:[A?"\u25B8 ":" ",X.label,X.isCurrent?" \u2713":""]}),X.description&&(0,Bd.jsxs)(cI,{color:n.colors.text.muted,dimColor:!0,children:[" - ",X.description]})]},String(X.value))})}),F&&(0,Bd.jsx)(rI,{children:(0,Bd.jsxs)(cI,{color:n.colors.text.muted,dimColor:!0,children:[" \u2193 ",I.length-p-a," more"]})}),(0,Bd.jsx)(rI,{marginTop:1,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderColor:n.colors.border.light,children:(0,Bd.jsx)(cI,{color:n.colors.text.muted,dimColor:!0,children:"\u2191/\u2193 navigate PgUp/PgDn page Enter confirm Esc cancel"})})]})}var du=OI(Jl(),1);await Kt();zd();gt();var Ql=OI(ac(),1);import*as bu from"node:fs";import*as yII from"node:path";import*as AII from"node:os";var jx=[{id:"anthropic",label:"Anthropic (Claude)",envVar:"ANTHROPIC_API_KEY",keyUrl:"console.anthropic.com/settings/keys"},{id:"openai",label:"OpenAI (GPT)",envVar:"OPENAI_API_KEY",keyUrl:"platform.openai.com/api-keys"},{id:"deepseek",label:"DeepSeek",envVar:"DEEPSEEK_API_KEY",keyUrl:"platform.deepseek.com/api_keys"},{id:"groq",label:"Groq",envVar:"GROQ_API_KEY",keyUrl:"console.groq.com/keys"},{id:"gemini",label:"Google Gemini",envVar:"GEMINI_API_KEY",keyUrl:"aistudio.google.com/app/apikey"},{id:"ollama",label:"Ollama (local)",envVar:"",keyUrl:"",noKey:!0}];function VyI(l){let I={};if(!bu.existsSync(l))return I;for(let G of bu.readFileSync(l,"utf-8").split(`
|
|
1960
1960
|
`)){let c=G.indexOf("=");c<0||G.trim().startsWith("#")||(I[G.slice(0,c).trim()]=G.slice(c+1).trim())}return I}function Gml(l,I){let G=Object.entries(I).map(([c,e])=>`${c}=${e}`);bu.writeFileSync(l,G.join(`
|