aico-cli 2.0.24 → 2.0.26

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/cli.js CHANGED
@@ -3661,7 +3661,7 @@ Expecting one of '${Q.join("', '")}'`);let Z=`${A}Help`;return this.on(Z,(G)=>{l
3661
3661
  `)}),this}_outputHelpIfRequested(A){let B=this._getHelpOption();if(B&&A.find((Z)=>B.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function lgQ(A){return A.map((B)=>{if(!B.startsWith("--inspect"))return B;let Q,Z="127.0.0.1",G="9229",Y;if((Y=B.match(/^(--inspect(-brk)?)$/))!==null)Q=Y[1];else if((Y=B.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Q=Y[1],/^\d+$/.test(Y[3]))G=Y[3];else Z=Y[3];else if((Y=B.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Q=Y[1],Z=Y[3],G=Y[4];if(Q&&G!=="0")return`${Q}=${Z}:${parseInt(G)+1}`;return B})}_u8.Command=Kt0});var rgQ=U((bu8)=>{var{Argument:ngQ}=Q00(),{Command:Dt0}=igQ(),{CommanderError:xu8,InvalidArgumentError:agQ}=C$1(),{Help:vu8}=Wt0(),{Option:sgQ}=Xt0();bu8.program=new Dt0;bu8.createCommand=(A)=>new Dt0(A);bu8.createOption=(A,B)=>new sgQ(A,B);bu8.createArgument=(A,B)=>new ngQ(A,B);bu8.Command=Dt0;bu8.Option=sgQ;bu8.Argument=ngQ;bu8.Help=vu8;bu8.CommanderError=xu8;bu8.InvalidArgumentError=agQ;bu8.InvalidOptionArgumentError=agQ});var tgQ=U((Zq,ogQ)=>{var _O=rgQ();Zq=ogQ.exports={};Zq.program=new _O.Command;Zq.Argument=_O.Argument;Zq.Command=_O.Command;Zq.CommanderError=_O.CommanderError;Zq.Help=_O.Help;Zq.InvalidArgumentError=_O.InvalidArgumentError;Zq.InvalidOptionArgumentError=_O.InvalidArgumentError;Zq.Option=_O.Option;Zq.createCommand=(A)=>new _O.Command(A);Zq.createOption=(A,B)=>new _O.Option(A,B);Zq.createArgument=(A,B)=>new _O.Argument(A,B)});var egQ,BtZ,QtZ,ZtZ,GtZ,YtZ,JtZ,WtZ,AuQ,XtZ,uH,ItZ;var BuQ=R(()=>{egQ=A1(tgQ(),1),{program:BtZ,createCommand:QtZ,createArgument:ZtZ,createOption:GtZ,CommanderError:YtZ,InvalidArgumentError:JtZ,InvalidOptionArgumentError:WtZ,Command:AuQ,Argument:XtZ,Option:uH,Help:ItZ}=egQ.default});function QuQ({isFocused:A,isSelected:B,children:Q}){return U$1.default.createElement(S,{gap:1,paddingLeft:A?0:2},A&&U$1.default.createElement($,{color:"suggestion"},K0.pointer),U$1.default.createElement($,{color:B?"success":A?"suggestion":void 0},Q),B&&U$1.default.createElement($,{color:"success"},K0.tick))}var U$1;var ZuQ=R(async()=>{oQ();await p1();U$1=A1(V1(),1)});var Z00;var GuQ=R(()=>{Z00=class Z00 extends Map{first;constructor(A){let B=[],Q,Z,G=0;for(let Y of A){let J={...Y,previous:Z,next:void 0,index:G};if(Z)Z.next=J;Q||=J,B.push([Y.value,J]),G++,Z=J}super(B);this.first=Q}}});import{isDeepStrictEqual as YuQ}from"node:util";var Gq,au8=(A,B)=>{switch(B.type){case"focus-next-option":{if(!A.focusedValue)return A;let Q=A.optionMap.get(A.focusedValue);if(!Q)return A;let Z=Q.next;if(!Z)return A;if(!(Z.index>=A.visibleToIndex))return{...A,focusedValue:Z.value};let Y=Math.min(A.optionMap.size,A.visibleToIndex+1),J=Y-A.visibleOptionCount;return{...A,focusedValue:Z.value,visibleFromIndex:J,visibleToIndex:Y}}case"focus-previous-option":{if(!A.focusedValue)return A;let Q=A.optionMap.get(A.focusedValue);if(!Q)return A;let Z=Q.previous;if(!Z)return A;if(!(Z.index<=A.visibleFromIndex))return{...A,focusedValue:Z.value};let Y=Math.max(0,A.visibleFromIndex-1),J=Y+A.visibleOptionCount;return{...A,focusedValue:Z.value,visibleFromIndex:Y,visibleToIndex:J}}case"toggle-focused-option":{if(!A.focusedValue)return A;if(A.value.includes(A.focusedValue)){let Q=new Set(A.value);return Q.delete(A.focusedValue),{...A,previousValue:A.value,value:[...Q]}}return{...A,previousValue:A.value,value:[...A.value,A.focusedValue]}}case"reset":return B.state}},JuQ=({visibleOptionCount:A,defaultValue:B,options:Q})=>{let Z=typeof A==="number"?Math.min(A,Q.length):Q.length,G=new Z00(Q),Y=B??[];return{optionMap:G,visibleOptionCount:Z,focusedValue:G.first?.value,visibleFromIndex:0,visibleToIndex:Z,previousValue:Y,value:Y}},WuQ=({visibleOptionCount:A=5,options:B,defaultValue:Q,onChange:Z,onSubmit:G})=>{let[Y,J]=Gq.useReducer(au8,{visibleOptionCount:A,defaultValue:Q,options:B},JuQ),[W,X]=Gq.useState(B);if(B!==W&&!YuQ(B,W))J({type:"reset",state:JuQ({visibleOptionCount:A,defaultValue:Q,options:B})}),X(B);let I=Gq.useCallback(()=>{J({type:"focus-next-option"})},[]),F=Gq.useCallback(()=>{J({type:"focus-previous-option"})},[]),V=Gq.useCallback(()=>{J({type:"toggle-focused-option"})},[]),K=Gq.useCallback(()=>{G?.(Y.value)},[Y.value,G]),D=Gq.useMemo(()=>{return B.map((H,z)=>({...H,index:z})).slice(Y.visibleFromIndex,Y.visibleToIndex)},[B,Y.visibleFromIndex,Y.visibleToIndex]);return Gq.useEffect(()=>{if(!YuQ(Y.previousValue,Y.value))Z?.(Y.value)},[Y.previousValue,Y.value,B,Z]),{focusedValue:Y.focusedValue,visibleFromIndex:Y.visibleFromIndex,visibleToIndex:Y.visibleToIndex,value:Y.value,visibleOptions:D,focusNextOption:I,focusPreviousOption:F,toggleFocusedOption:V,submit:K}};var XuQ=R(()=>{GuQ();Gq=A1(V1(),1)});var IuQ=({isDisabled:A=!1,state:B})=>{u0((Q,Z)=>{if(Z.downArrow)B.focusNextOption();if(Z.upArrow)B.focusPreviousOption();if(Q===" ")B.toggleFocusedOption();if(Z.return)B.submit()},{isActive:!A})};var FuQ=R(async()=>{await p1()});function G00({isDisabled:A=!1,visibleOptionCount:B=5,highlightText:Q,options:Z,defaultValue:G,onChange:Y,onSubmit:J}){let W=WuQ({visibleOptionCount:B,options:Z,defaultValue:G,onChange:Y,onSubmit:J});return IuQ({isDisabled:A,state:W}),X31.default.createElement(S,{flexDirection:"column"},W.visibleOptions.map((X)=>{let I=X.label;if(Q&&X.label.includes(Q)){let F=X.label.indexOf(Q);I=X31.default.createElement(X31.default.Fragment,null,X.label.slice(0,F),X31.default.createElement($,{bold:!0},Q),X.label.slice(F+Q.length))}return X31.default.createElement(QuQ,{key:X.value,isFocused:!A&&W.focusedValue===X.value,isSelected:W.value.includes(X.value)},I)}))}var X31;var Ht0=R(async()=>{XuQ();await W1([p1(),ZuQ(),FuQ()]);X31=A1(V1(),1)});function VuQ({servers:A,scope:B,onDone:Q}){let Z=Object.keys(A),[G,Y]=oX.useState({});oX.useEffect(()=>{kP().then(({servers:V})=>Y(V))},[]);let J=Z.filter((V)=>G[V]!==void 0);function W(V){let K=0;for(let D of V){let H=A[D];if(H){let z=D;if(G[z]!==void 0){let C=1;while(G[`${D}_${C}`]!==void 0)C++;z=`${D}_${C}`}$n(z,H,B),K++}}F(K)}let X=Z2();u0((V,K)=>{if(K.escape){F(0);return}});let[I]=xB();function F(V){if(V>0)vF(`
3662
3662
  ${S2("success",I)(`Successfully imported ${V} MCP server${V!==1?"s":""} to ${B} config.`)}
3663
3663
  `);else vF(`
3664
- No servers were imported.`);Q(),j5()}return oX.default.createElement(oX.default.Fragment,null,oX.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"success"},oX.default.createElement($,{bold:!0,color:"success"},"Import MCP Servers from Claude Desktop"),oX.default.createElement($,null,"Found ",Z.length," MCP server",Z.length!==1?"s":""," in Claude Desktop."),J.length>0&&oX.default.createElement($,{color:"warning"},"Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix."),oX.default.createElement($,null,"Please select the servers you want to import:"),oX.default.createElement(G00,{options:Z.map((V)=>({label:`${V}${J.includes(V)?" (already exists)":""}`,value:V})),defaultValue:Z.filter((V)=>!J.includes(V)),onSubmit:W})),oX.default.createElement(S,{marginLeft:3},oX.default.createElement($,{dimColor:!0},X.pending?oX.default.createElement(oX.default.Fragment,null,"Press ",X.keyName," again to exit"):oX.default.createElement(oX.default.Fragment,null,"Space to select · Enter to confirm · Esc to cancel"))))}var oX;var KuQ=R(async()=>{await W1([p1(),Ht0(),T9(),Ow(),B7()]);oX=A1(V1(),1)});import*as zt0 from"path";import*as DuQ from"os";function su8(){let A=b2();if(!M50.includes(A))throw Error(`Unsupported platform: ${A} - Claude Desktop integration only works on macOS and WSL.`);if(A==="macos")return zt0.join(DuQ.homedir(),"Library","Application Support","Claude","claude_desktop_config.json");let B=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,"/"):null;if(B){let Z=`/mnt/c${B.replace(/^[A-Z]:/,"")}/AppData/Roaming/Claude/claude_desktop_config.json`;if(N1().existsSync(Z))return Z}try{if(N1().existsSync("/mnt/c/Users")){let Z=N1().readdirSync("/mnt/c/Users");for(let G of Z){if(G.name==="Public"||G.name==="Default"||G.name==="Default User"||G.name==="All Users")continue;let Y=zt0.join("/mnt/c/Users",G.name,"AppData","Roaming","Claude","claude_desktop_config.json");if(N1().existsSync(Y))return Y}}}catch(Q){J1(Q instanceof Error?Q:Error(String(Q)),zZA)}throw Error("Could not find Claude Desktop config file in Windows. Make sure Claude Desktop is installed on Windows.")}function HuQ(){if(!M50.includes(b2()))throw Error("Unsupported platform - Claude Desktop integration only works on macOS and WSL.");try{let A=su8();if(!N1().existsSync(A))return{};let B=N1().readFileSync(A,{encoding:"utf8"}),Q=JZ(B);if(!Q||typeof Q!=="object")return{};let Z=Q.mcpServers;if(!Z||typeof Z!=="object")return{};let G={};for(let[Y,J]of Object.entries(Z)){if(!J||typeof J!=="object")continue;let W=HT0.safeParse(J);if(W.success)G[Y]=W.data}return G}catch(A){return J1(A instanceof Error?A:Error(String(A)),CZA),{}}}var zuQ=R(async()=>{gQ1();oA();await W1([SD(),s0(),_3()])});function Y00({customApiKeyTruncated:A,onDone:B}){function Q(G){let Y=w0();switch(G){case"yes":{lA({...Y,customApiKeyResponses:{...Y.customApiKeyResponses,approved:[...Y.customApiKeyResponses?.approved??[],A]}}),B();break}case"no":{lA({...Y,customApiKeyResponses:{...Y.customApiKeyResponses,rejected:[...Y.customApiKeyResponses?.rejected??[],A]}}),B();break}}}let Z=Z2();return HD.default.createElement(HD.default.Fragment,null,HD.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"warning"},HD.default.createElement($,{bold:!0,color:"warning"},"Detected a custom API key in your environment"),HD.default.createElement($,null,HD.default.createElement($,{bold:!0},"ANTHROPIC_API_KEY"),HD.default.createElement($,null,": sk-ant-...",A)),HD.default.createElement($,null,"Do you want to use this API key?"),HD.default.createElement(EA,{defaultValue:"no",focusValue:"no",options:[{label:"Yes",value:"yes"},{label:`No (${t1.bold("recommended")})`,value:"no"}],onChange:(G)=>Q(G),onCancel:()=>Q("no")})),HD.default.createElement(S,{marginLeft:3},HD.default.createElement($,{dimColor:!0},Z.pending?HD.default.createElement(HD.default.Fragment,null,"Press ",Z.keyName," again to exit"):HD.default.createElement(HD.default.Fragment,null,"Enter to confirm ",K0.dot," Esc to cancel"))))}var HD;var Ct0=R(async()=>{tQ();oQ();await W1([p1(),g2(),Z8(),T9()]);HD=A1(V1(),1)});async function ru8(){try{let A=["https://api.anthropic.com/api/hello","https://console.anthropic.com/v1/oauth/hello"],B=async(G)=>{try{let Y=await p2.get(G,{headers:{"User-Agent":Oh()}});if(Y.status!==200)return{success:!1,error:`Failed to connect to ${new URL(G).hostname}: Status ${Y.status}`};return{success:!0}}catch(Y){return{success:!1,error:`Failed to connect to ${new URL(G).hostname}: ${Y instanceof Error?Y.code||Y.message:String(Y)}`}}},Z=(await Promise.all(A.map(B))).find((G)=>!G.success);if(Z)Z1("tengu_preflight_check_failed",{isConnectivityError:!1,hasErrorMessage:!!Z.error});return Z||{success:!0}}catch(A){return J1(A,gGA),Z1("tengu_preflight_check_failed",{isConnectivityError:!0}),{success:!1,error:`Connectivity check error: ${A instanceof Error?A.code||A.message:String(A)}`}}}function CuQ({onSuccess:A}){let[B,Q]=LF.useState(null),[Z,G]=LF.useState(!0),Y=qe1(1000)&&Z;return LF.useEffect(()=>{async function J(){let W=await ru8();Q(W),G(!1)}J()},[]),LF.useEffect(()=>{if(B?.success)A();else if(B&&!B.success){let J=setTimeout(()=>process.exit(1),100);return()=>clearTimeout(J)}},[B,A]),LF.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},Z&&Y?LF.default.createElement(S,{paddingLeft:1},LF.default.createElement(W6,null),LF.default.createElement($,null,"Checking connectivity...")):!B?.success&&!Z&&LF.default.createElement(S,{flexDirection:"column",gap:1},LF.default.createElement($,{color:"error"},"Unable to connect to Anthropic services"),LF.default.createElement($,{color:"error"},B?.error),LF.default.createElement(S,{flexDirection:"column",gap:1},LF.default.createElement($,null,"Please check your internet connection and network settings."),LF.default.createElement($,null,"Note: AICO might not be available in your country. Check supported countries at"," ",LF.default.createElement($,{color:"suggestion"},"https://anthropic.com/supported-countries")))))}var LF;var UuQ=R(async()=>{pa0();g7();await W1([p1(),oL(),s0(),QX(),KA()]);LF=A1(V1(),1)});function W00(){let[A]=xB(),B="Welcome to AICO";if(kA.terminal==="Apple_Terminal")return DA.default.createElement(ou8,{theme:A,welcomeMessage:"Welcome to AICO"});if(["light","light-daltonized","light-ansi"].includes(A))return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},"Welcome to AICO"," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," ░░░░░░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ "),DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," "),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░"),DA.default.createElement($,null," ██ ")),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░"),DA.default.createElement($,null," ██▒▒██ ")),DA.default.createElement($,null," ▒▒ ██ ▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ▒▒░░▒▒ ▒ ▒▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body",backgroundColor:"clawd_background"},"██▄█████▄██")," ▒▒ ▒▒ "),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ░ ▒ "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{color:"clawd_body"},"█ █ █ █"),"……………………………………………………………………░…………………………▒…………")));return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},"Welcome to AICO"," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," * █████▓▓░ "),DA.default.createElement($,null," * ███▓░ ░░ "),DA.default.createElement($,null," ░░░░░░ ███▓░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ ███▓░ "),DA.default.createElement($,null,DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ██▓░░ ▓ ")),DA.default.createElement($,null," ░▓▓███▓▓░ "),DA.default.createElement($,{dimColor:!0}," * ░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ",DA.default.createElement($,{dimColor:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"██▄█████▄██"),DA.default.createElement($,null," "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," * "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{color:"clawd_body"},"█ █ █ █"),"………………………………………………………………………………………………………………")))}function ou8({theme:A,welcomeMessage:B}){if(["light","light-daltonized","light-ansi"].includes(A))return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},B," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," ░░░░░░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ "),DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," "),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░"),DA.default.createElement($,null," ██ ")),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░"),DA.default.createElement($,null," ██▒▒██ ")),DA.default.createElement($,null," ▒▒ ██ ▒"),DA.default.createElement($,null," ▒▒░░▒▒ ▒ ▒▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"▗"),DA.default.createElement($,{color:"clawd_background",backgroundColor:"clawd_body"}," ","▗"," ","▖"," "),DA.default.createElement($,{color:"clawd_body"},"▖")," ▒▒ ▒▒ "),DA.default.createElement($,null," ",DA.default.createElement($,{backgroundColor:"clawd_body"}," ".repeat(9))," ░ ▒ "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),"……………………………………………………………………░…………………………▒…………")));return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},B," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," * █████▓▓░ "),DA.default.createElement($,null," * ███▓░ ░░ "),DA.default.createElement($,null," ░░░░░░ ███▓░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ ███▓░ "),DA.default.createElement($,null,DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ██▓░░ ▓ ")),DA.default.createElement($,null," ░▓▓███▓▓░ "),DA.default.createElement($,{dimColor:!0}," * ░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," ",DA.default.createElement($,{dimColor:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"▗"),DA.default.createElement($,{color:"clawd_background",backgroundColor:"clawd_body"}," ","▗"," ","▖"," "),DA.default.createElement($,{color:"clawd_body"},"▖"),DA.default.createElement($,null," "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{backgroundColor:"clawd_body"}," ".repeat(9))," * "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),"………………………………………………………………………………………………………………")))}var DA,J00=58;var Ut0=R(async()=>{$5();await p1();DA=A1(V1(),1)});function $uQ({onDone:A}){let[B,Q]=c4.useState(0),Z=m$(),[G,Y]=xB();c4.useEffect(()=>{Z1("tengu_began_setup",{oauthEnabled:Z})},[Z]);function J(){if(B<D.length-1){let H=B+1;Q(H),Z1("tengu_onboarding_step",{oauthEnabled:Z,stepId:D[H]?.id})}else A()}function W(H){Y(H),J()}let X=Z2();u0(async(H,z)=>{let C=D[B];if(z.return&&C&&C.id==="security")if(B===D.length-1){A();return}else J();else if(z.escape&&C?.id==="terminal-setup")J()});let I=c4.default.createElement(Ri1,{initialTheme:G,onThemeSelect:W,showIntroText:!0,helpText:"To change this later, run /theme",hideEscToCancel:!0,skipExitHandling:!0}),F=c4.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},c4.default.createElement($,{bold:!0},"Security notes:"),c4.default.createElement(S,{flexDirection:"column",width:70},c4.default.createElement(oV1,null,c4.default.createElement(oV1.Item,null,c4.default.createElement($,null,"Claude can make mistakes"),c4.default.createElement($,{dimColor:!0,wrap:"wrap"},"You should always review Claude's responses, especially when",c4.default.createElement(uZ,null),"running code.",c4.default.createElement(uZ,null))),c4.default.createElement(oV1.Item,null,c4.default.createElement($,null,"Due to prompt injection risks, only use it with code you trust"),c4.default.createElement($,{dimColor:!0,wrap:"wrap"},"For more details see:",c4.default.createElement(uZ,null),c4.default.createElement(p6,{url:"https://docs.claude.com/s/claude-code-security"}))))),c4.default.createElement(gi1,null)),V=c4.default.createElement(CuQ,{onSuccess:J}),K=c4.useMemo(()=>{if(!process.env.ANTHROPIC_API_KEY)return"";let H=j$(process.env.ANTHROPIC_API_KEY);if(o10(H)==="new")return H},[]),D=[];if(Z)D.push({id:"preflight",component:V});if(D.push({id:"theme",component:I}),Z)D.push({id:"oauth",component:c4.default.createElement(um,{onDone:J})});if(K)D.push({id:"api-key",component:c4.default.createElement(Y00,{customApiKeyTruncated:K,onDone:J})});if(D.push({id:"security",component:F}),AK1())D.push({id:"terminal-setup",component:c4.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},c4.default.createElement($,{bold:!0},"Use AICO's terminal setup?"),c4.default.createElement(S,{flexDirection:"column",width:70,gap:1},c4.default.createElement($,null,"For the optimal coding experience, enable the recommended settings",c4.default.createElement(uZ,null),"for your terminal:"," ",kA.terminal==="Apple_Terminal"?"Option+Enter for newlines and visual bell":"Shift+Enter for newlines"),c4.default.createElement(EA,{options:[{label:"Yes, use recommended settings",value:"install"},{label:"No, maybe later with /terminal-setup",value:"no"}],onChange:(H)=>{if(H==="install")Ay0(G).then(()=>{J()});else J()},onCancel:()=>J()}),c4.default.createElement($,{dimColor:!0},X.pending?c4.default.createElement(c4.default.Fragment,null,"Press ",X.keyName," again to exit"):c4.default.createElement(c4.default.Fragment,null,"Enter to confirm · Esc to skip"))))});return c4.default.createElement(S,{flexDirection:"column"},c4.default.createElement(Qf,{items:[c4.default.createElement(W00,{key:"welcome"})]},(H)=>H),c4.default.createElement(S,{flexDirection:"column",marginTop:1},D[B]?.component,X.pending&&c4.default.createElement(S,{padding:1},c4.default.createElement($,{dimColor:!0},"Press ",X.keyName," again to exit"))))}var c4;var quQ=R(async()=>{LD1();$5();await W1([p1(),g2(),aS0(),T9(),yz1(),Ct0(),A9(),NH(),wv0(),UuQ(),Iv0(),KA(),r8(),h91(),Ut0()]);c4=A1(V1(),1)});import{sep as $t0}from"path";function qt0(A){let B=Ju();if(A===B.HOME)return"home";if(A===B.DESKTOP||A.startsWith(B.DESKTOP+$t0))return"desktop";if(A===B.DOCUMENTS||A.startsWith(B.DOCUMENTS+$t0))return"documents";if(A===B.DOWNLOADS||A.startsWith(B.DOWNLOADS+$t0))return"downloads";return"other"}function EuQ(A){if(A===null||A.disableAllHooks)return!1;if(A.statusLine)return!0;if(!A.hooks)return!1;for(let B of Object.values(A.hooks))if(B.length>0)return!0;return!1}function OuQ(){let A=[],B=EQ("projectSettings");if(EuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(EuQ(Q))A.push(".claude/settings.local.json");return A}function wuQ(A){return A.some((B)=>B.ruleBehavior==="allow"&&(B.ruleValue.toolName===_4||B.ruleValue.toolName.startsWith(_4+"(")))}function RuQ(){let A=[],B=bL1("projectSettings");if(wuQ(B))A.push(".claude/settings.json");let Q=bL1("localSettings");if(wuQ(Q))A.push(".claude/settings.local.json");return A}function $$1(A,B){if(A.length===0)return"";let Q=B===0?void 0:B;if(!Q||A.length<=Q){if(A.length===1)return A[0];if(A.length===2)return`${A[0]} and ${A[1]}`;let Y=A[A.length-1];return`${A.slice(0,-1).join(", ")}, and ${Y}`}let Z=A.slice(0,Q),G=A.length-Q;if(Z.length===1)return`${Z[0]} and ${G} more`;return`${Z.join(", ")}, and ${G} more`}function NuQ(A){return!!A?.otelHeadersHelper}function TuQ(){let A=[],B=EQ("projectSettings");if(NuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(NuQ(Q))A.push(".claude/settings.local.json");return A}function LuQ(A){return!!A?.apiKeyHelper}function PuQ(){let A=[],B=EQ("projectSettings");if(LuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(LuQ(Q))A.push(".claude/settings.local.json");return A}function MuQ(A){return!!(A?.awsAuthRefresh||A?.awsCredentialExport)}function juQ(){let A=[],B=EQ("projectSettings");if(MuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(MuQ(Q))A.push(".claude/settings.local.json");return A}var SuQ=R(async()=>{await W1([ke(),tB(),_V1()])});var yuQ;var _uQ=R(()=>{yuQ={control:{title:"Do you trust the files in this folder?",bodyText:null,showDetailedPermissions:!0,learnMoreText:"Learn more",yesButtonLabel:"Yes, proceed",noButtonLabel:"No, exit"},variant_positive_attitude:{title:"Ready to code here?",bodyText:`I'll need permission to work with your files.
3664
+ No servers were imported.`);Q(),j5()}return oX.default.createElement(oX.default.Fragment,null,oX.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"success"},oX.default.createElement($,{bold:!0,color:"success"},"Import MCP Servers from Claude Desktop"),oX.default.createElement($,null,"Found ",Z.length," MCP server",Z.length!==1?"s":""," in Claude Desktop."),J.length>0&&oX.default.createElement($,{color:"warning"},"Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix."),oX.default.createElement($,null,"Please select the servers you want to import:"),oX.default.createElement(G00,{options:Z.map((V)=>({label:`${V}${J.includes(V)?" (already exists)":""}`,value:V})),defaultValue:Z.filter((V)=>!J.includes(V)),onSubmit:W})),oX.default.createElement(S,{marginLeft:3},oX.default.createElement($,{dimColor:!0},X.pending?oX.default.createElement(oX.default.Fragment,null,"Press ",X.keyName," again to exit"):oX.default.createElement(oX.default.Fragment,null,"Space to select · Enter to confirm · Esc to cancel"))))}var oX;var KuQ=R(async()=>{await W1([p1(),Ht0(),T9(),Ow(),B7()]);oX=A1(V1(),1)});import*as zt0 from"path";import*as DuQ from"os";function su8(){let A=b2();if(!M50.includes(A))throw Error(`Unsupported platform: ${A} - Claude Desktop integration only works on macOS and WSL.`);if(A==="macos")return zt0.join(DuQ.homedir(),"Library","Application Support","Claude","claude_desktop_config.json");let B=process.env.USERPROFILE?process.env.USERPROFILE.replace(/\\/g,"/"):null;if(B){let Z=`/mnt/c${B.replace(/^[A-Z]:/,"")}/AppData/Roaming/Claude/claude_desktop_config.json`;if(N1().existsSync(Z))return Z}try{if(N1().existsSync("/mnt/c/Users")){let Z=N1().readdirSync("/mnt/c/Users");for(let G of Z){if(G.name==="Public"||G.name==="Default"||G.name==="Default User"||G.name==="All Users")continue;let Y=zt0.join("/mnt/c/Users",G.name,"AppData","Roaming","Claude","claude_desktop_config.json");if(N1().existsSync(Y))return Y}}}catch(Q){J1(Q instanceof Error?Q:Error(String(Q)),zZA)}throw Error("Could not find Claude Desktop config file in Windows. Make sure Claude Desktop is installed on Windows.")}function HuQ(){if(!M50.includes(b2()))throw Error("Unsupported platform - Claude Desktop integration only works on macOS and WSL.");try{let A=su8();if(!N1().existsSync(A))return{};let B=N1().readFileSync(A,{encoding:"utf8"}),Q=JZ(B);if(!Q||typeof Q!=="object")return{};let Z=Q.mcpServers;if(!Z||typeof Z!=="object")return{};let G={};for(let[Y,J]of Object.entries(Z)){if(!J||typeof J!=="object")continue;let W=HT0.safeParse(J);if(W.success)G[Y]=W.data}return G}catch(A){return J1(A instanceof Error?A:Error(String(A)),CZA),{}}}var zuQ=R(async()=>{gQ1();oA();await W1([SD(),s0(),_3()])});function Y00({customApiKeyTruncated:A,onDone:B}){function Q(G){let Y=w0();switch(G){case"yes":{lA({...Y,customApiKeyResponses:{...Y.customApiKeyResponses,approved:[...Y.customApiKeyResponses?.approved??[],A]}}),B();break}case"no":{lA({...Y,customApiKeyResponses:{...Y.customApiKeyResponses,rejected:[...Y.customApiKeyResponses?.rejected??[],A]}}),B();break}}}let Z=Z2();return HD.default.createElement(HD.default.Fragment,null,HD.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"warning"},HD.default.createElement($,{bold:!0,color:"warning"},"Detected a custom API key in your environment"),HD.default.createElement($,null,HD.default.createElement($,{bold:!0},"ANTHROPIC_API_KEY"),HD.default.createElement($,null,": sk-ant-...",A)),HD.default.createElement($,null,"Do you want to use this API key?"),HD.default.createElement(EA,{defaultValue:"no",focusValue:"no",options:[{label:"Yes",value:"yes"},{label:`No (${t1.bold("recommended")})`,value:"no"}],onChange:(G)=>Q(G),onCancel:()=>Q("no")})),HD.default.createElement(S,{marginLeft:3},HD.default.createElement($,{dimColor:!0},Z.pending?HD.default.createElement(HD.default.Fragment,null,"Press ",Z.keyName," again to exit"):HD.default.createElement(HD.default.Fragment,null,"Enter to confirm ",K0.dot," Esc to cancel"))))}var HD;var Ct0=R(async()=>{tQ();oQ();await W1([p1(),g2(),Z8(),T9()]);HD=A1(V1(),1)});async function ru8(){try{let A=["https://api.anthropic.com/api/hello","https://console.anthropic.com/v1/oauth/hello"],B=async(G)=>{try{let Y=await p2.get(G,{headers:{"User-Agent":Oh()}});if(Y.status!==200)return{success:!1,error:`Failed to connect to ${new URL(G).hostname}: Status ${Y.status}`};return{success:!0}}catch(Y){return{success:!1,error:`Failed to connect to ${new URL(G).hostname}: ${Y instanceof Error?Y.code||Y.message:String(Y)}`}}},Z=(await Promise.all(A.map(B))).find((G)=>!G.success);if(Z)Z1("tengu_preflight_check_failed",{isConnectivityError:!1,hasErrorMessage:!!Z.error});return Z||{success:!0}}catch(A){return J1(A,gGA),Z1("tengu_preflight_check_failed",{isConnectivityError:!0}),{success:!1,error:`Connectivity check error: ${A instanceof Error?A.code||A.message:String(A)}`}}}function CuQ({onSuccess:A}){let[B,Q]=LF.useState(null),[Z,G]=LF.useState(!0),Y=qe1(1000)&&Z;return LF.useEffect(()=>{async function J(){let W=await ru8();Q(W),G(!1)}J()},[]),LF.useEffect(()=>{if(B?.success)A();else if(B&&!B.success){let J=setTimeout(()=>process.exit(1),100);return()=>clearTimeout(J)}},[B,A]),LF.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},Z&&Y?LF.default.createElement(S,{paddingLeft:1},LF.default.createElement(W6,null),LF.default.createElement($,null,"Checking connectivity...")):!B?.success&&!Z&&LF.default.createElement(S,{flexDirection:"column",gap:1},LF.default.createElement($,{color:"error"},"Unable to connect to Anthropic services"),LF.default.createElement($,{color:"error"},B?.error),LF.default.createElement(S,{flexDirection:"column",gap:1},LF.default.createElement($,null,"Please check your internet connection and network settings."),LF.default.createElement($,null,"Note: AICO might not be available in your country. Check supported countries at"," ",LF.default.createElement($,{color:"suggestion"},"https://anthropic.com/supported-countries")))))}var LF;var UuQ=R(async()=>{pa0();g7();await W1([p1(),oL(),s0(),QX(),KA()]);LF=A1(V1(),1)});function W00(){let[A]=xB(),B="Welcome to AICO";if(kA.terminal==="Apple_Terminal")return DA.default.createElement(ou8,{theme:A,welcomeMessage:"Welcome to AICO"});if(["light","light-daltonized","light-ansi"].includes(A))return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},"Welcome to AICO"," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," ░░░░░░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ "),DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," "),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░"),DA.default.createElement($,null," ██ ")),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░"),DA.default.createElement($,null," ██▒▒██ ")),DA.default.createElement($,null," ▒▒ ██ ▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ▒▒░░▒▒ ▒ ▒▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body",backgroundColor:"clawd_background"},"██▄█████▄██")," ▒▒ ▒▒ "),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ░ ▒ "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{color:"clawd_body"},"█ █ █ █"),"……………………………………………………………………░…………………………▒…………")));return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},"Welcome to AICO"," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," * █████▓▓░ "),DA.default.createElement($,null," * ███▓░ ░░ "),DA.default.createElement($,null," ░░░░░░ ███▓░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ ███▓░ "),DA.default.createElement($,null,DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ██▓░░ ▓ ")),DA.default.createElement($,null," ░▓▓███▓▓░ "),DA.default.createElement($,{dimColor:!0}," * ░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," ",DA.default.createElement($,{dimColor:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"██▄█████▄██"),DA.default.createElement($,null," "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"}," █████████ ")," * "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{color:"clawd_body"},"█ █ █ █"),"………………………………………………………………………………………………………………")))}function ou8({theme:A,welcomeMessage:B}){if(["light","light-daltonized","light-ansi"].includes(A))return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},B," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," "),DA.default.createElement($,null," ░░░░░░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ "),DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," "),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░"),DA.default.createElement($,null," ██ ")),DA.default.createElement($,null,DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░"),DA.default.createElement($,null," ██▒▒██ ")),DA.default.createElement($,null," ▒▒ ██ ▒"),DA.default.createElement($,null," ▒▒░░▒▒ ▒ ▒▒"),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"▗"),DA.default.createElement($,{color:"clawd_background",backgroundColor:"clawd_body"}," ","▗"," ","▖"," "),DA.default.createElement($,{color:"clawd_body"},"▖")," ▒▒ ▒▒ "),DA.default.createElement($,null," ",DA.default.createElement($,{backgroundColor:"clawd_body"}," ".repeat(9))," ░ ▒ "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),"……………………………………………………………………░…………………………▒…………")));return DA.default.createElement(S,{width:J00},DA.default.createElement($,null,DA.default.createElement($,null,DA.default.createElement($,{color:"claude"},B," "),DA.default.createElement($,{dimColor:!0},"v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION," ")),DA.default.createElement($,null,"…………………………………………………………………………………………………………………………………………………………"),DA.default.createElement($,null," "),DA.default.createElement($,null," * █████▓▓░ "),DA.default.createElement($,null," * ███▓░ ░░ "),DA.default.createElement($,null," ░░░░░░ ███▓░ "),DA.default.createElement($,null," ░░░ ░░░░░░░░░░ ███▓░ "),DA.default.createElement($,null,DA.default.createElement($,null," ░░░░░░░░░░░░░░░░░░░ "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ██▓░░ ▓ ")),DA.default.createElement($,null," ░▓▓███▓▓░ "),DA.default.createElement($,{dimColor:!0}," * ░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░ "),DA.default.createElement($,{dimColor:!0}," ░░░░░░░░░░░░░░░░ "),DA.default.createElement($,null," ",DA.default.createElement($,{dimColor:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{color:"clawd_body"},"▗"),DA.default.createElement($,{color:"clawd_background",backgroundColor:"clawd_body"}," ","▗"," ","▖"," "),DA.default.createElement($,{color:"clawd_body"},"▖"),DA.default.createElement($,null," "),DA.default.createElement($,{bold:!0},"*"),DA.default.createElement($,null," ")),DA.default.createElement($,null," ",DA.default.createElement($,{backgroundColor:"clawd_body"}," ".repeat(9))," * "),DA.default.createElement($,null,"…………………",DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),DA.default.createElement($,null," "),DA.default.createElement($,{backgroundColor:"clawd_body"}," "),"………………………………………………………………………………………………………………")))}var DA,J00=58;var Ut0=R(async()=>{$5();await p1();DA=A1(V1(),1)});function $uQ({onDone:A}){let[B,Q]=c4.useState(0),Z=m$(),[G,Y]=xB();c4.useEffect(()=>{Z1("tengu_began_setup",{oauthEnabled:Z})},[Z]);function J(){if(B<D.length-1){let H=B+1;Q(H),Z1("tengu_onboarding_step",{oauthEnabled:Z,stepId:D[H]?.id})}else A()}function W(H){Y(H),J()}let X=Z2();u0(async(H,z)=>{let C=D[B];if(z.return&&C&&C.id==="security")if(B===D.length-1){A();return}else J();else if(z.escape&&C?.id==="terminal-setup")J()});let I=c4.default.createElement(Ri1,{initialTheme:G,onThemeSelect:W,showIntroText:!0,helpText:"To change this later, run /theme",hideEscToCancel:!0,skipExitHandling:!0}),F=c4.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},c4.default.createElement($,{bold:!0},"Security notes:"),c4.default.createElement(S,{flexDirection:"column",width:70},c4.default.createElement(oV1,null,c4.default.createElement(oV1.Item,null,c4.default.createElement($,null,"Claude can make mistakes"),c4.default.createElement($,{dimColor:!0,wrap:"wrap"},"You should always review Claude's responses, especially when",c4.default.createElement(uZ,null),"running code.",c4.default.createElement(uZ,null))),c4.default.createElement(oV1.Item,null,c4.default.createElement($,null,"Due to prompt injection risks, only use it with code you trust"),c4.default.createElement($,{dimColor:!0,wrap:"wrap"},"For more details see:",c4.default.createElement(uZ,null),c4.default.createElement(p6,{url:"https://docs.claude.com/s/claude-code-security"}))))),c4.default.createElement(gi1,null)),V=c4.default.createElement(CuQ,{onSuccess:J}),K=c4.useMemo(()=>{if(!process.env.ANTHROPIC_API_KEY)return"";let H=j$(process.env.ANTHROPIC_API_KEY);if(o10(H)==="new")return H},[]),D=[];if(Z)D.push({id:"preflight",component:V});if(D.push({id:"theme",component:I}),Z)D.push({id:"oauth",component:c4.default.createElement(um,{onDone:J})});if(K)D.push({id:"api-key",component:c4.default.createElement(Y00,{customApiKeyTruncated:K,onDone:J})});if(D.push({id:"security",component:F}),AK1())D.push({id:"terminal-setup",component:c4.default.createElement(S,{flexDirection:"column",gap:1,paddingLeft:1},c4.default.createElement($,{bold:!0},"Use AICO's terminal setup?"),c4.default.createElement(S,{flexDirection:"column",width:70,gap:1},c4.default.createElement($,null,"For the optimal coding experience, enable the recommended settings",c4.default.createElement(uZ,null),"for your terminal:"," ",kA.terminal==="Apple_Terminal"?"Option+Enter for newlines and visual bell":"Shift+Enter for newlines"),c4.default.createElement(EA,{options:[{label:"Yes, use recommended settings",value:"install"},{label:"No, maybe later with /terminal-setup",value:"no"}],onChange:(H)=>{if(H==="install")Ay0(G).then(()=>{J()});else J()},onCancel:()=>J()}),c4.default.createElement($,{dimColor:!0},X.pending?c4.default.createElement(c4.default.Fragment,null,"Press ",X.keyName," again to exit"):c4.default.createElement(c4.default.Fragment,null,"Enter to confirm · Esc to skip"))))});return c4.default.createElement(S,{flexDirection:"column"},c4.default.createElement(Qf,{items:[c4.default.createElement(W00,{key:"welcome"})]},(H)=>H),c4.default.createElement(S,{flexDirection:"column",marginTop:1},D[B]?.component,X.pending&&c4.default.createElement(S,{padding:1},c4.default.createElement($,{dimColor:!0},"Press ",X.keyName," again to exit"))))}var c4;var quQ=R(async()=>{LD1();$5();await W1([p1(),g2(),aS0(),T9(),yz1(),Ct0(),A9(),NH(),wv0(),UuQ(),Iv0(),KA(),r8(),h91(),Ut0()]);c4=A1(V1(),1)});import{sep as $t0}from"path";function qt0(A){let B=Ju();if(A===B.HOME)return"home";if(A===B.DESKTOP||A.startsWith(B.DESKTOP+$t0))return"desktop";if(A===B.DOCUMENTS||A.startsWith(B.DOCUMENTS+$t0))return"documents";if(A===B.DOWNLOADS||A.startsWith(B.DOWNLOADS+$t0))return"downloads";return"other"}function EuQ(A){if(A===null||A.disableAllHooks)return!1;if(A.statusLine)return!0;if(!A.hooks)return!1;for(let B of Object.values(A.hooks))if(B.length>0)return!0;return!1}function OuQ(){let A=[],B=EQ("projectSettings");if(EuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(EuQ(Q))A.push(".claude/settings.local.json");return A}function wuQ(A){return A.some((B)=>B.ruleBehavior==="allow"&&(B.ruleValue.toolName===_4||B.ruleValue.toolName.startsWith(_4+"(")))}function RuQ(){let A=[],B=bL1("projectSettings");if(wuQ(B))A.push(".claude/settings.json");let Q=bL1("localSettings");if(wuQ(Q))A.push(".claude/settings.local.json");return A}function $$1(A,B){if(A.length===0)return"";let Q=B===0?void 0:B;if(!Q||A.length<=Q){if(A.length===1)return A[0];if(A.length===2)return`${A[0]} and ${A[1]}`;let Y=A[A.length-1];return`${A.slice(0,-1).join(", ")}, and ${Y}`}let Z=A.slice(0,Q),G=A.length-Q;if(Z.length===1)return`${Z[0]} and ${G} more`;return`${Z.join(", ")}, and ${G} more`}function NuQ(A){return!!A?.otelHeadersHelper}function TuQ(){let A=[],B=EQ("projectSettings");if(NuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(NuQ(Q))A.push(".claude/settings.local.json");return A}function LuQ(A){return!!A?.apiKeyHelper}function PuQ(){let A=[],B=EQ("projectSettings");if(LuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(LuQ(Q))A.push(".claude/settings.local.json");return A}function MuQ(A){return!!(A?.awsAuthRefresh||A?.awsCredentialExport)}function juQ(){let A=[],B=EQ("projectSettings");if(MuQ(B))A.push(".claude/settings.json");let Q=EQ("localSettings");if(MuQ(Q))A.push(".claude/settings.local.json");return A}var SuQ=R(async()=>{await W1([ke(),tB(),_V1()])});var yuQ;var _uQ=R(()=>{yuQ={control:{title:"Do you trust the files in this folder?",bodyText:null,showDetailedPermissions:!0,learnMoreText:"Learn more",yesButtonLabel:"同意并点回车键继续",noButtonLabel:"不同意,退出"},variant_positive_attitude:{title:"Ready to code here?",bodyText:`I'll need permission to work with your files.
3665
3665
 
3666
3666
  This means I can:
3667
3667
  - Read any file in this folder
@@ -3673,7 +3673,7 @@ AICO'll be able to read, edit, and execute files here.`,showDetailedPermissions:
3673
3673
 
3674
3674
  If this folder has malicious code or untrusted scripts, AICO could run them while trying to help.
3675
3675
 
3676
- Only continue if this is your code or a project you trust.`,showDetailedPermissions:!1,learnMoreText:"Security details",yesButtonLabel:"Yes, continue",noButtonLabel:"No, exit"}}});import{homedir as kuQ}from"os";function xuQ({onDone:A,commands:B}){let{servers:Q}=rW("project"),Z=XY("trust_folder_dialog_copy","variant","control"),G=yuQ[Z],Y=Object.keys(Q).length>0,J=OuQ(),W=J.length>0,X=RuQ(),I=PuQ(),F=I.length>0,V=juQ(),K=V.length>0,D=TuQ(),H=D.length>0,z=[...new Set([...J,...X,...I,...V,...D])],C=B?.filter((c)=>c.type==="prompt"&&c.source==="projectSettings"&&!c.isSkill&&c.allowedTools?.some((e)=>e===_4||e.startsWith(_4+"(")))??[],q=B?.filter((c)=>c.type==="prompt"&&c.source==="localSettings"&&c.isSkill&&c.allowedTools?.some((e)=>e===_4||e.startsWith(_4+"(")))??[],N=C.length>0,L=q.length>0,O=C.map((c)=>c.name),T=q.map((c)=>c.name),P=X.length>0||N||L,_=oW(W||P||F||K||H),k=[{name:"MCP servers",shouldShowWarning:()=>Y,onChange:()=>{let c={enabledMcpjsonServers:Object.keys(Q),enableAllProjectMcpServers:!0};SQ("localSettings",c)}},{name:"hooks",shouldShowWarning:()=>W},{name:"bash commands",shouldShowWarning:()=>P},{name:"OpenTelemetry headers helper commands",shouldShowWarning:()=>H}].filter((c)=>c.shouldShowWarning()),l=new Set(k.map((c)=>c.name)),g=Object.keys(Q);function t(){let c=["files"];if(l.has("MCP servers"))c.push("MCP servers");if(l.has("hooks"))c.push("hooks");if(l.has("bash commands"))c.push("bash commands");if(l.has("OpenTelemetry headers helper commands"))c.push("OpenTelemetry headers helper commands");return $$1(c)}U6.default.useEffect(()=>{let c=kuQ()===YA();Z1("tengu_trust_dialog_shown",{isHomeDir:c,hasMcpServers:Y,hasHooks:W,hasBashExecution:P,hasApiKeyHelper:F,hasAwsCommands:K,hasOtelHeadersHelper:H,folderType:qt0(YA()),copyVariant:Z})},[Y,W,P,F,K,H,Z]);function d(c){let e=g4();if(c==="exit"){P6(1);return}let Q1=kuQ()===YA();if(Z1("tengu_trust_dialog_accept",{isHomeDir:Q1,hasMcpServers:Y,hasHooks:W,hasBashExecution:P,hasApiKeyHelper:F,hasAwsCommands:K,hasOtelHeadersHelper:H,enableMcp:!0,folderType:qt0(YA()),copyVariant:Z}),!Q1)SG({...e,hasTrustDialogAccepted:!0});k.forEach((T1)=>{if(T1.onChange!==void 0)T1.onChange()}),A()}let y=Z2();if(u0((c,e)=>{if(e.escape){P6(0);return}}),_)return setTimeout(A),null;return U6.default.createElement(U6.default.Fragment,null,U6.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"warning"},U6.default.createElement($,{bold:!0,color:"warning"},G.title),U6.default.createElement($,{bold:!0},N1().cwd()),U6.default.createElement(S,{flexDirection:"column",gap:1},G.bodyText!==null?U6.default.createElement($,null,G.bodyText):U6.default.createElement($,null,"AICO may read, write, or execute files contained in this directory. This can pose security risks, so only use"," ",t()," from trusted sources."),G.showDetailedPermissions&&(Y||W||P||F||K||H)&&U6.default.createElement(S,{flexDirection:"column",gap:1},U6.default.createElement($,{dimColor:!0},"Execution allowed by:"),Y&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".mcp.json"),g.length>0&&U6.default.createElement($,{dimColor:!0}," ","(",$$1(g,3),")"))),z.length>0&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},z.join(", ")))),N&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".claude/commands"),U6.default.createElement($,{dimColor:!0}," ","(",$$1(O,3),")"))),L&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".claude/skills"),U6.default.createElement($,{dimColor:!0}," ","(",$$1(T,3),")")))),U6.default.createElement($,{dimColor:!0},G.learnMoreText," ("," ",U6.default.createElement(p6,{url:"https://docs.claude.com/s/claude-code-security"},"https://docs.claude.com/s/claude-code-security")," ",")")),U6.default.createElement(EA,{options:[{label:G.yesButtonLabel,value:"enable_all"},{label:G.noButtonLabel,value:"exit"}],onChange:(c)=>d(c),onCancel:()=>d("exit")})),U6.default.createElement(S,{marginLeft:3},U6.default.createElement($,{dimColor:!0},y.pending?U6.default.createElement(U6.default.Fragment,null,"Press ",y.keyName," again to exit"):U6.default.createElement(U6.default.Fragment,null,"Enter to confirm · Esc to exit"))))}var U6;var vuQ=R(async()=>{hQ();oA();_uQ();await W1([p1(),Z8(),g2(),Ow(),tB(),KA(),T9(),NH(),B7(),SuQ()]);U6=A1(V1(),1)});var q$1;var buQ=R(async()=>{await W1([p1(),M6()]);q$1=A1(V1(),1)});var Et0;var fuQ=R(async()=>{await W1([Lr1(),buQ(),s0(),s0(),B7()]);Et0=A1(V1(),1)});function huQ({context:A,commands:B,logs:Q,initialTools:Z,mcpClients:G,dynamicMcpConfig:Y,appState:J,onChangeAppState:W,debug:X,strictMcpConfig:I=!1,systemPrompt:F,appendSystemPrompt:V}){let{rows:K}=qB(),D=Q.filter((C)=>!C.isSidechain);Z2();function H(){process.exit(1)}async function z(C){let q=Q[C];if(!q)return;try{A.unmount?.();let N=await pm(q,void 0,Z);if(!N)throw Error("Failed to load conversation");await DY(),f5(X00.default.createElement(G7,{initialState:J,onChangeAppState:W},X00.default.createElement(o81,{initialPrompt:"",debug:X,commands:B,initialTools:Z,initialMessages:N.messages,initialCheckpoints:N.checkpoints,initialFileHistorySnapshots:N.fileHistorySnapshots,mcpClients:G,dynamicMcpConfig:Y,strictMcpConfig:I,systemPrompt:F,appendSystemPrompt:V})),{exitOnCtrlC:!1})}catch(N){throw J1(N,lGA),N}}return X00.default.createElement(vz1,{logs:D,maxHeight:K,onCancel:H,onSelect:z})}var X00;var guQ=R(async()=>{await W1([p1(),D10(),Lr1(),s0(),a_(),T9(),s9(),E51(),M6()]);X00=A1(V1(),1)});var uuQ,wt0;var muQ=R(()=>{oO0();oz();uuQ=A1(NR0(),1);wt0=class wt0 extends hF1{constructor(A,B){var Q;super(B);this._serverInfo=A,this._capabilities=(Q=B===null||B===void 0?void 0:B.capabilities)!==null&&Q!==void 0?Q:{},this._instructions=B===null||B===void 0?void 0:B.instructions,this.setRequestHandler(bO0,(Z)=>this._oninitialize(Z)),this.setNotificationHandler(sg1,()=>{var Z;return(Z=this.oninitialized)===null||Z===void 0?void 0:Z.call(this)})}registerCapabilities(A){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=Au1(this._capabilities,A)}assertCapabilityForMethod(A){var B,Q,Z;switch(A){case"sampling/createMessage":if(!((B=this._clientCapabilities)===null||B===void 0?void 0:B.sampling))throw Error(`Client does not support sampling (required for ${A})`);break;case"elicitation/create":if(!((Q=this._clientCapabilities)===null||Q===void 0?void 0:Q.elicitation))throw Error(`Client does not support elicitation (required for ${A})`);break;case"roots/list":if(!((Z=this._clientCapabilities)===null||Z===void 0?void 0:Z.roots))throw Error(`Client does not support listing roots (required for ${A})`);break;case"ping":break}}assertNotificationCapability(A){switch(A){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${A})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${A})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${A})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${A})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(A){switch(A){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${A})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${A})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${A})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${A})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${A})`);break;case"ping":case"initialize":break}}async _oninitialize(A){let B=A.params.protocolVersion;return this._clientCapabilities=A.params.capabilities,this._clientVersion=A.params.clientInfo,{protocolVersion:pg1.includes(B)?B:kg,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Bk)}async createMessage(A,B){return this.request({method:"sampling/createMessage",params:A},iO0,B)}async elicitInput(A,B){let Q=await this.request({method:"elicitation/create",params:A},nO0,B);if(Q.action==="accept"&&Q.content)try{let Z=new uuQ.default,G=Z.compile(A.requestedSchema);if(!G(Q.content))throw new YH(GH.InvalidParams,`Elicitation response content does not match requested schema: ${Z.errorsText(G.errors)}`)}catch(Z){if(Z instanceof YH)throw Z;throw new YH(GH.InternalError,`Error validating elicitation response: ${Z}`)}return Q}async listRoots(A,B){return this.request({method:"roots/list",params:A},rO0,B)}async sendLoggingMessage(A){return this.notification({method:"notifications/message",params:A})}async sendResourceUpdated(A){return this.notification({method:"notifications/resources/updated",params:A})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});import duQ from"node:process";class Nt0{constructor(A=duQ.stdin,B=duQ.stdout){this._stdin=A,this._stdout=B,this._readBuffer=new uF1,this._started=!1,this._ondata=(Q)=>{this._readBuffer.append(Q),this.processReadBuffer()},this._onerror=(Q)=>{var Z;(Z=this.onerror)===null||Z===void 0||Z.call(this,Q)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var A,B;while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;(A=this.onmessage)===null||A===void 0||A.call(this,Q)}catch(Q){(B=this.onerror)===null||B===void 0||B.call(this,Q)}}async close(){var A;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),(A=this.onclose)===null||A===void 0||A.call(this)}send(A){return new Promise((B)=>{let Q=Eu1(A);if(this._stdout.write(Q))B();else this._stdout.once("drain",B)})}}var cuQ=R(()=>{LR0()});async function luQ(A,B,Q){let G=n_(100);Iw(A);let Y=new wt0({name:"claude/tengu",version:{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION},{capabilities:{tools:{}}});Y.setRequestHandler(pO0,async()=>{let W=OL(),X=Aq(W);return{tools:await Promise.all(X.map(async(I)=>({...I,description:await I.prompt({getToolPermissionContext:async()=>W,tools:X,agents:[]}),inputSchema:Cf(I.inputSchema),outputSchema:I.outputSchema?Cf(I.outputSchema):void 0})))}}),Y.setRequestHandler(lO0,async({params:{name:W,arguments:X}})=>{let I=OL(),F=Aq(I),V=F.find((K)=>K.name===W);if(!V)throw Error(`Tool ${W} not found`);try{if(!V.isEnabled())throw Error(`Tool ${W} is not enabled`);let K=v3(),D=await V.validateInput?.(X??{},{abortController:b4(),options:{commands:puQ,tools:F,mainLoopModel:K,maxThinkingTokens:0,mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,debug:B,verbose:Q,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:async()=>ju(),setAppState:()=>{},messages:[],setMessages:()=>{},messageQueueManager:qO(),readFileState:G,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},agentId:W2()});if(D&&!D.result)throw Error(`Tool ${W} input is invalid: ${D.message}`);let H=V.call(X??{},{abortController:b4(),options:{commands:puQ,tools:F,mainLoopModel:v3(),maxThinkingTokens:0,mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,debug:B,verbose:Q,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:async()=>ju(),setAppState:()=>{},messages:[],setMessages:()=>{},messageQueueManager:qO(),readFileState:G,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},agentId:W2()},QN,jH({content:[]})),z=await Bw(H);if(z.type!=="result")throw Error(`Tool ${W} did not return a result`);return{content:Array.isArray(z)?z.map((C)=>({type:"text",text:"text"in C?C.text:JSON.stringify(C)})):[{type:"text",text:typeof z==="string"?z:JSON.stringify(z.data)}]}}catch(K){return J1(K instanceof Error?K:Error(String(K)),KGA),{isError:!0,content:[{type:"text",text:(K instanceof Error?Ea0(K):[String(K)]).filter(Boolean).join(`
3676
+ Only continue if this is your code or a project you trust.`,showDetailedPermissions:!1,learnMoreText:"Security details",yesButtonLabel:"Yes, continue",noButtonLabel:"No, exit"}}});import{homedir as kuQ}from"os";function xuQ({onDone:A,commands:B}){let{servers:Q}=rW("project"),Z=XY("trust_folder_dialog_copy","variant","control"),G=yuQ[Z],Y=Object.keys(Q).length>0,J=OuQ(),W=J.length>0,X=RuQ(),I=PuQ(),F=I.length>0,V=juQ(),K=V.length>0,D=TuQ(),H=D.length>0,z=[...new Set([...J,...X,...I,...V,...D])],C=B?.filter((c)=>c.type==="prompt"&&c.source==="projectSettings"&&!c.isSkill&&c.allowedTools?.some((e)=>e===_4||e.startsWith(_4+"(")))??[],q=B?.filter((c)=>c.type==="prompt"&&c.source==="localSettings"&&c.isSkill&&c.allowedTools?.some((e)=>e===_4||e.startsWith(_4+"(")))??[],N=C.length>0,L=q.length>0,O=C.map((c)=>c.name),T=q.map((c)=>c.name),P=X.length>0||N||L,_=oW(W||P||F||K||H),k=[{name:"MCP servers",shouldShowWarning:()=>Y,onChange:()=>{let c={enabledMcpjsonServers:Object.keys(Q),enableAllProjectMcpServers:!0};SQ("localSettings",c)}},{name:"hooks",shouldShowWarning:()=>W},{name:"bash commands",shouldShowWarning:()=>P},{name:"OpenTelemetry headers helper commands",shouldShowWarning:()=>H}].filter((c)=>c.shouldShowWarning()),l=new Set(k.map((c)=>c.name)),g=Object.keys(Q);function t(){let c=["files"];if(l.has("MCP servers"))c.push("MCP servers");if(l.has("hooks"))c.push("hooks");if(l.has("bash commands"))c.push("bash commands");if(l.has("OpenTelemetry headers helper commands"))c.push("OpenTelemetry headers helper commands");return $$1(c)}U6.default.useEffect(()=>{let c=kuQ()===YA();Z1("tengu_trust_dialog_shown",{isHomeDir:c,hasMcpServers:Y,hasHooks:W,hasBashExecution:P,hasApiKeyHelper:F,hasAwsCommands:K,hasOtelHeadersHelper:H,folderType:qt0(YA()),copyVariant:Z})},[Y,W,P,F,K,H,Z]);function d(c){let e=g4();if(c==="exit"){P6(1);return}let Q1=kuQ()===YA();if(Z1("tengu_trust_dialog_accept",{isHomeDir:Q1,hasMcpServers:Y,hasHooks:W,hasBashExecution:P,hasApiKeyHelper:F,hasAwsCommands:K,hasOtelHeadersHelper:H,enableMcp:!0,folderType:qt0(YA()),copyVariant:Z}),!Q1)SG({...e,hasTrustDialogAccepted:!0});k.forEach((T1)=>{if(T1.onChange!==void 0)T1.onChange()}),A()}let y=Z2();if(u0((c,e)=>{if(e.escape){P6(0);return}}),_)return setTimeout(A),null;return U6.default.createElement(U6.default.Fragment,null,U6.default.createElement(S,{flexDirection:"column",gap:1,padding:1,borderStyle:"round",borderColor:"warning"},U6.default.createElement($,{bold:!0,color:"warning"},G.title),U6.default.createElement($,{bold:!0},N1().cwd()),U6.default.createElement(S,{flexDirection:"column",gap:1},G.bodyText!==null?U6.default.createElement($,null,G.bodyText):U6.default.createElement($,null,"AICO可能会读取、写入或执行此目录中包含的文件。"," ",t()," from trusted sources."),G.showDetailedPermissions&&(Y||W||P||F||K||H)&&U6.default.createElement(S,{flexDirection:"column",gap:1},U6.default.createElement($,{dimColor:!0},"Execution allowed by:"),Y&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".mcp.json"),g.length>0&&U6.default.createElement($,{dimColor:!0}," ","(",$$1(g,3),")"))),z.length>0&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},z.join(", ")))),N&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".claude/commands"),U6.default.createElement($,{dimColor:!0}," ","(",$$1(O,3),")"))),L&&U6.default.createElement(S,{paddingLeft:2},U6.default.createElement($,null,U6.default.createElement($,{dimColor:!0},"• "),U6.default.createElement($,{bold:!0},".claude/skills"),U6.default.createElement($,{dimColor:!0}," ","(",$$1(T,3),")")))),U6.default.createElement($,{dimColor:!0},G.learnMoreText," ("," ",U6.default.createElement(p6,{url:"https://docs.claude.com/s/claude-code-security"},"https://docs.claude.com/s/claude-code-security")," ",")")),U6.default.createElement(EA,{options:[{label:G.yesButtonLabel,value:"enable_all"},{label:G.noButtonLabel,value:"exit"}],onChange:(c)=>d(c),onCancel:()=>d("exit")})),U6.default.createElement(S,{marginLeft:3},U6.default.createElement($,{dimColor:!0},y.pending?U6.default.createElement(U6.default.Fragment,null,"Press ",y.keyName," again to exit"):U6.default.createElement(U6.default.Fragment,null,"Enter to confirm · Esc to exit"))))}var U6;var vuQ=R(async()=>{hQ();oA();_uQ();await W1([p1(),Z8(),g2(),Ow(),tB(),KA(),T9(),NH(),B7(),SuQ()]);U6=A1(V1(),1)});var q$1;var buQ=R(async()=>{await W1([p1(),M6()]);q$1=A1(V1(),1)});var Et0;var fuQ=R(async()=>{await W1([Lr1(),buQ(),s0(),s0(),B7()]);Et0=A1(V1(),1)});function huQ({context:A,commands:B,logs:Q,initialTools:Z,mcpClients:G,dynamicMcpConfig:Y,appState:J,onChangeAppState:W,debug:X,strictMcpConfig:I=!1,systemPrompt:F,appendSystemPrompt:V}){let{rows:K}=qB(),D=Q.filter((C)=>!C.isSidechain);Z2();function H(){process.exit(1)}async function z(C){let q=Q[C];if(!q)return;try{A.unmount?.();let N=await pm(q,void 0,Z);if(!N)throw Error("Failed to load conversation");await DY(),f5(X00.default.createElement(G7,{initialState:J,onChangeAppState:W},X00.default.createElement(o81,{initialPrompt:"",debug:X,commands:B,initialTools:Z,initialMessages:N.messages,initialCheckpoints:N.checkpoints,initialFileHistorySnapshots:N.fileHistorySnapshots,mcpClients:G,dynamicMcpConfig:Y,strictMcpConfig:I,systemPrompt:F,appendSystemPrompt:V})),{exitOnCtrlC:!1})}catch(N){throw J1(N,lGA),N}}return X00.default.createElement(vz1,{logs:D,maxHeight:K,onCancel:H,onSelect:z})}var X00;var guQ=R(async()=>{await W1([p1(),D10(),Lr1(),s0(),a_(),T9(),s9(),E51(),M6()]);X00=A1(V1(),1)});var uuQ,wt0;var muQ=R(()=>{oO0();oz();uuQ=A1(NR0(),1);wt0=class wt0 extends hF1{constructor(A,B){var Q;super(B);this._serverInfo=A,this._capabilities=(Q=B===null||B===void 0?void 0:B.capabilities)!==null&&Q!==void 0?Q:{},this._instructions=B===null||B===void 0?void 0:B.instructions,this.setRequestHandler(bO0,(Z)=>this._oninitialize(Z)),this.setNotificationHandler(sg1,()=>{var Z;return(Z=this.oninitialized)===null||Z===void 0?void 0:Z.call(this)})}registerCapabilities(A){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=Au1(this._capabilities,A)}assertCapabilityForMethod(A){var B,Q,Z;switch(A){case"sampling/createMessage":if(!((B=this._clientCapabilities)===null||B===void 0?void 0:B.sampling))throw Error(`Client does not support sampling (required for ${A})`);break;case"elicitation/create":if(!((Q=this._clientCapabilities)===null||Q===void 0?void 0:Q.elicitation))throw Error(`Client does not support elicitation (required for ${A})`);break;case"roots/list":if(!((Z=this._clientCapabilities)===null||Z===void 0?void 0:Z.roots))throw Error(`Client does not support listing roots (required for ${A})`);break;case"ping":break}}assertNotificationCapability(A){switch(A){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${A})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${A})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${A})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${A})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(A){switch(A){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${A})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${A})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${A})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${A})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${A})`);break;case"ping":case"initialize":break}}async _oninitialize(A){let B=A.params.protocolVersion;return this._clientCapabilities=A.params.capabilities,this._clientVersion=A.params.clientInfo,{protocolVersion:pg1.includes(B)?B:kg,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Bk)}async createMessage(A,B){return this.request({method:"sampling/createMessage",params:A},iO0,B)}async elicitInput(A,B){let Q=await this.request({method:"elicitation/create",params:A},nO0,B);if(Q.action==="accept"&&Q.content)try{let Z=new uuQ.default,G=Z.compile(A.requestedSchema);if(!G(Q.content))throw new YH(GH.InvalidParams,`Elicitation response content does not match requested schema: ${Z.errorsText(G.errors)}`)}catch(Z){if(Z instanceof YH)throw Z;throw new YH(GH.InternalError,`Error validating elicitation response: ${Z}`)}return Q}async listRoots(A,B){return this.request({method:"roots/list",params:A},rO0,B)}async sendLoggingMessage(A){return this.notification({method:"notifications/message",params:A})}async sendResourceUpdated(A){return this.notification({method:"notifications/resources/updated",params:A})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});import duQ from"node:process";class Nt0{constructor(A=duQ.stdin,B=duQ.stdout){this._stdin=A,this._stdout=B,this._readBuffer=new uF1,this._started=!1,this._ondata=(Q)=>{this._readBuffer.append(Q),this.processReadBuffer()},this._onerror=(Q)=>{var Z;(Z=this.onerror)===null||Z===void 0||Z.call(this,Q)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var A,B;while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;(A=this.onmessage)===null||A===void 0||A.call(this,Q)}catch(Q){(B=this.onerror)===null||B===void 0||B.call(this,Q)}}async close(){var A;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),(A=this.onclose)===null||A===void 0||A.call(this)}send(A){return new Promise((B)=>{let Q=Eu1(A);if(this._stdout.write(Q))B();else this._stdout.once("drain",B)})}}var cuQ=R(()=>{LR0()});async function luQ(A,B,Q){let G=n_(100);Iw(A);let Y=new wt0({name:"claude/tengu",version:{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://docs.claude.com/s/claude-code",VERSION:"2.0.24"}.VERSION},{capabilities:{tools:{}}});Y.setRequestHandler(pO0,async()=>{let W=OL(),X=Aq(W);return{tools:await Promise.all(X.map(async(I)=>({...I,description:await I.prompt({getToolPermissionContext:async()=>W,tools:X,agents:[]}),inputSchema:Cf(I.inputSchema),outputSchema:I.outputSchema?Cf(I.outputSchema):void 0})))}}),Y.setRequestHandler(lO0,async({params:{name:W,arguments:X}})=>{let I=OL(),F=Aq(I),V=F.find((K)=>K.name===W);if(!V)throw Error(`Tool ${W} not found`);try{if(!V.isEnabled())throw Error(`Tool ${W} is not enabled`);let K=v3(),D=await V.validateInput?.(X??{},{abortController:b4(),options:{commands:puQ,tools:F,mainLoopModel:K,maxThinkingTokens:0,mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,debug:B,verbose:Q,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:async()=>ju(),setAppState:()=>{},messages:[],setMessages:()=>{},messageQueueManager:qO(),readFileState:G,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},agentId:W2()});if(D&&!D.result)throw Error(`Tool ${W} input is invalid: ${D.message}`);let H=V.call(X??{},{abortController:b4(),options:{commands:puQ,tools:F,mainLoopModel:v3(),maxThinkingTokens:0,mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,hasAppendSystemPrompt:!1,debug:B,verbose:Q,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:async()=>ju(),setAppState:()=>{},messages:[],setMessages:()=>{},messageQueueManager:qO(),readFileState:G,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},agentId:W2()},QN,jH({content:[]})),z=await Bw(H);if(z.type!=="result")throw Error(`Tool ${W} did not return a result`);return{content:Array.isArray(z)?z.map((C)=>({type:"text",text:"text"in C?C.text:JSON.stringify(C)})):[{type:"text",text:typeof z==="string"?z:JSON.stringify(z.data)}]}}catch(K){return J1(K instanceof Error?K:Error(String(K)),KGA),{isError:!0,content:[{type:"text",text:(K instanceof Error?Ea0(K):[String(K)]).filter(Boolean).join(`
3677
3677
  `).trim()||"Error"}]}}});async function J(){let W=new Nt0;await Y.connect(W)}return await J()}var puQ;var iuQ=R(async()=>{muQ();cuQ();oz();ER1();UM();K2();Qw();gY();await W1([$7(),CP(),pQ(),s0(),nC1(),$c0(),UB(),Hd(),s9()]);puQ=[Mr1]});function Lt0(A,B,Q){let Z="";if(Object.keys(Q?.enabledPlugins||{}).forEach((G)=>{if(G===A||G===B.name||G.startsWith(`${B.name}@`))Z=G}),!Z)Z=A.includes("@")?A:B.name;return Z}function nuQ(A){if(A.includes("@")){let B=A.split("@");return{name:B[0]||"",marketplace:B[1]}}return{name:A}}function Mt0(A,B){let{name:Q,marketplace:Z}=nuQ(A);return B.find((G)=>{if(G.name===A||G.name===Q)return!0;if(Z&&G.source)return G.name===Q&&G.source.includes(`@${Z}`);return!1})}function Ot0(A,B,Q){let G={...EQ("userSettings")?.enabledPlugins};Object.keys(G).forEach((Y)=>{if(Y===A||Y===Q.name||Y.startsWith(`${Q.name}@`))G[Y]=B}),SQ("userSettings",{enabledPlugins:G}),wF()}function I00(A,B){J1(A instanceof Error?A:Error(String(A)),Qp),console.error(`${K0.cross} Failed to ${B}: ${A instanceof Error?A.message:String(A)}`),process.exit(1)}async function auQ(A){try{let{name:B,marketplace:Q}=nuQ(A),Z=await AJ(),G,Y;for(let[I]of Object.entries(Z)){if(Q&&I!==Q)continue;let V=(await WH(I)).plugins.find((K)=>K.name===B);if(V){G=V,Y=I;break}}if(!G||!Y){let I=Q?`marketplace "${Q}"`:"any configured marketplace";throw Error(`Plugin "${B}" not found in ${I}`)}if(typeof G.source!=="string")console.log(`Installing plugin "${B}" from marketplace "${Y}"...`),await Hw(G.source,{manifest:{name:G.name}});let J=`${G.name}@${Y}`,X={...EQ("userSettings")?.enabledPlugins,[J]:!0};SQ("userSettings",{enabledPlugins:X}),wF(),console.log(`${K0.tick} Successfully installed plugin: ${J}`),Z1("tengu_plugin_installed_cli",{plugin_id:J,marketplace_name:Y}),process.exit(0)}catch(B){I00(B,`install plugin "${A}"`)}}async function suQ(A){try{let{enabled:B,disabled:Q}=await CY(),Z=[...B,...Q],G=Mt0(A,Z);if(!G)throw Error(`Plugin "${A}" not found in installed plugins`);let Y=EQ("userSettings"),J=Lt0(A,G,Y);if(Y?.enabledPlugins?.[J]===!1)throw Error(`Plugin "${A}" is already uninstalled`);Ot0(J,!1,G),console.log(`${K0.tick} Successfully uninstalled plugin: ${G.name}`),Z1("tengu_plugin_uninstalled_cli",{plugin_id:J}),process.exit(0)}catch(B){I00(B,`uninstall plugin "${A}"`)}}async function ruQ(A){try{let{disabled:B}=await CY(),Q=Mt0(A,B);if(!Q)throw Error(`Plugin "${A}" not found in disabled plugins`);let Z=EQ("userSettings"),G=Lt0(A,Q,Z);Ot0(G,!0,Q),console.log(`${K0.tick} Successfully enabled plugin: ${Q.name}`),Z1("tengu_plugin_enabled_cli",{plugin_id:G}),process.exit(0)}catch(B){I00(B,`enable plugin "${A}"`)}}async function ouQ(A){try{let{enabled:B}=await CY(),Q=Mt0(A,B);if(!Q)throw Error(`Plugin "${A}" not found in enabled plugins`);let Z=EQ("userSettings"),G=Lt0(A,Q,Z);Ot0(G,!1,Q),console.log(`${K0.tick} Successfully disabled plugin: ${Q.name}`),Z1("tengu_plugin_disabled_cli",{plugin_id:G}),process.exit(0)}catch(B){I00(B,`disable plugin "${A}"`)}}var tuQ=R(async()=>{oQ();await W1([s0(),KA(),QC(),BC(),tB(),Cr()])});import{join as $S}from"path";function F00(){let Q=((yA()||{}).cleanupPeriodDays??tu8)*24*60*60*1000;return new Date(Date.now()-Q)}function eu8(A,B){return{messages:A.messages+B.messages,errors:A.errors+B.errors}}function Am8(A){let B=A.split(".")[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,"T$1:$2:$3.$4Z");return new Date(B)}function euQ(A,B,Q){let Z={messages:0,errors:0};try{let G=N1().readdirSync(A);for(let Y of G)try{if(Am8(Y.name)<B)if(N1().unlinkSync($S(A,Y.name)),Q)Z.messages++;else Z.errors++}catch(J){J1(J,$ZA)}}catch(G){if(G instanceof Error&&"code"in G&&G.code!=="ENOENT")J1(G,UZA)}return Z}async function Bm8(){let A=N1(),B=F00(),Q=mj.errors(),Z=mj.baseLogs(),G=euQ(Q,B,!1);try{if(A.existsSync(Z)){let J=A.readdirSync(Z).filter((W)=>W.isDirectory()&&W.name.startsWith("mcp-logs-")).map((W)=>$S(Z,W.name));for(let W of J){G=eu8(G,euQ(W,B,!0));try{if(A.isDirEmptySync(W))A.rmdirSync(W)}catch{}}}}catch(Y){if(Y instanceof Error&&"code"in Y&&Y.code!=="ENOENT")J1(Y,qQ0)}return G}function AmQ(A,B,Q,Z){let G={messages:0,errors:0};if(!Z.existsSync(A))return G;let J=Z.readdirSync(A).filter((W)=>W.isFile()&&W.name.endsWith(Q));for(let W of J)try{let X=$S(A,W.name);if(Z.statSync(X).mtime<B)Z.unlinkSync(X),G.messages++}catch{G.errors++}try{if(Z.isDirEmptySync(A))Z.rmdirSync(A)}catch{G.errors++}return G}function Qm8(){let A=F00(),B={messages:0,errors:0},Q=G$1(),Z=N1();try{if(!Z.existsSync(Q))return B;let Y=Z.readdirSync(Q).filter((J)=>J.isDirectory()).map((J)=>$S(Q,J.name));for(let J of Y)try{let W=AmQ(J,A,".jsonl",Z);B.messages+=W.messages,B.errors+=W.errors;let X=$S(J,"bash-outputs");if(Z.existsSync(X))try{let I=Z.readdirSync(X);for(let F of I)if(F.isDirectory()){let V=$S(X,F.name),K=AmQ(V,A,".txt",Z);B.messages+=K.messages,B.errors+=K.errors}if(Z.isDirEmptySync(X))Z.rmdirSync(X)}catch{B.errors++}try{if(Z.isDirEmptySync(J))Z.rmdirSync(J)}catch{}}catch{B.errors++;continue}}catch{B.errors++}return B}function Zm8(){let A=F00(),B={messages:0,errors:0},Q=N1();try{let Z=IB(),G=$S(Z,"file-history");if(!Q.existsSync(G))return B;let J=Q.readdirSync(G).filter((W)=>W.isDirectory()).map((W)=>$S(G,W.name));for(let W of J)try{if(!Q.existsSync(W))continue;if(Q.statSync(W).mtime<A)Q.rmSync(W,{recursive:!0,force:!0}),B.messages++}catch{B.errors++}try{if(Q.isDirEmptySync(G))Q.rmdirSync(G)}catch{}}catch(Z){J1(Z,vYA)}return B}function Gm8(){let A=F00(),B={messages:0,errors:0},Q=N1();try{let Z=IB(),G=$S(Z,"session-env");if(!Q.existsSync(G))return B;let J=Q.readdirSync(G).filter((W)=>W.isDirectory()).map((W)=>$S(G,W.name));for(let W of J)try{if(!Q.existsSync(W))continue;if(Q.statSync(W).mtime<A)Q.rmSync(W,{recursive:!0,force:!0}),B.messages++}catch{B.errors++}try{if(Q.isDirEmptySync(G))Q.rmdirSync(G)}catch{}}catch(Z){J1(Z,qQ0)}return B}function BmQ(){setImmediate(()=>{Bm8(),Qm8(),Zm8(),Gm8()}).unref()}var tu8=30;var QmQ=R(async()=>{oA();HB();await W1([s0(),k4(),tB(),rF()])});import{join as GmQ,basename as Ym8}from"path";function Wm8(){let A=XV(),B=FR(A);if(B<=ZmQ)return Math.floor(B*0.8);return B-ZmQ}function Xm8(A){return pJ(A).map((B)=>{if(B.type==="user"){if(typeof B.message.content==="string")return`User: ${B.message.content}`;else if(Array.isArray(B.message.content))return`User: ${B.message.content.filter((Q)=>Q.type==="text").map((Q)=>Q.type==="text"?Q.text:"").join(`
3678
3678
  `).trim()}`}else if(B.type==="assistant"){let Q=pu(B);if(Q)return`Claude: ${NF1(Q).trim()}`}return null}).filter((B)=>B!==null).join(`
3679
3679
 
@@ -13,7 +13,7 @@ import { join as join$1 } from 'node:path';
13
13
  import { join, dirname, basename } from 'pathe';
14
14
  import { fileURLToPath } from 'node:url';
15
15
 
16
- const version = "2.0.24";
16
+ const version = "2.0.26";
17
17
 
18
18
  function displayBanner(subtitle) {
19
19
  const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
@@ -5284,7 +5284,8 @@ class InstallationComposer {
5284
5284
  }
5285
5285
  /**
5286
5286
  * 公司配置安装
5287
- * 包含:Claude Code + 固定API配置 + CCometixLine + MCP + Workflow
5287
+ * 包含:固定API配置 + CCometixLine + MCP + Workflow
5288
+ * Claude Code 由 startClaudeCodeEditor 函数自动安装
5288
5289
  * 公司配置不需要安装 CCR
5289
5290
  */
5290
5291
  async installCompanySetup(options = {}) {
@@ -5310,7 +5311,6 @@ class InstallationComposer {
5310
5311
  const configType = configCheckResult?.data?.configType;
5311
5312
  if (configType === "none" || options.force) {
5312
5313
  const companySteps = [
5313
- INSTALLER_NAMES.CLAUDE_CODE,
5314
5314
  INSTALLER_NAMES.CONFIG,
5315
5315
  INSTALLER_NAMES.CCOMETIX_LINE,
5316
5316
  INSTALLER_NAMES.MCP
@@ -5323,7 +5323,6 @@ class InstallationComposer {
5323
5323
  } else {
5324
5324
  console.log(ansis.yellow(`\u26A0 \u68C0\u6D4B\u5230${configType === "company" ? "\u516C\u53F8" : "\u4E2A\u4EBA"}\u914D\u7F6E\uFF0C\u5C06\u5F3A\u5236\u6267\u884C\u5B8C\u6574\u516C\u53F8\u914D\u7F6E`));
5325
5325
  const companySteps = [
5326
- INSTALLER_NAMES.CLAUDE_CODE,
5327
5326
  INSTALLER_NAMES.CONFIG,
5328
5327
  INSTALLER_NAMES.CCOMETIX_LINE,
5329
5328
  INSTALLER_NAMES.MCP
@@ -5337,12 +5336,12 @@ class InstallationComposer {
5337
5336
  }
5338
5337
  /**
5339
5338
  * 个人配置安装
5340
- * 包含:Claude Code + CCR + 配置备份应用 + CCometixLine + MCP + Workflow
5339
+ * 包含:CCR + 配置备份应用 + CCometixLine + MCP + Workflow
5340
+ * Claude Code 由 startClaudeCodeEditor 函数自动安装
5341
5341
  */
5342
5342
  async installPersonalSetup(options = {}) {
5343
5343
  console.log(ansis.cyan("\n\u{1F464} \u5F00\u59CB\u4E2A\u4EBA\u914D\u7F6E\u5B89\u88C5...\n"));
5344
5344
  const installationSteps = [
5345
- INSTALLER_NAMES.CLAUDE_CODE,
5346
5345
  INSTALLER_NAMES.CCR,
5347
5346
  INSTALLER_NAMES.CONFIG,
5348
5347
  INSTALLER_NAMES.CCOMETIX_LINE,
package/dist/cli.mjs CHANGED
@@ -176,10 +176,7 @@ class ProcessManager extends EventEmitter {
176
176
  unregisterProcess(pid) {
177
177
  const info = this.processes.get(pid);
178
178
  if (info) {
179
- this.log(`\u6CE8\u9500\u8FDB\u7A0B: ${info.name} (PID: ${pid})`, "info");
180
179
  this.processes.delete(pid);
181
- } else {
182
- this.log(`\u5C1D\u8BD5\u6CE8\u9500\u4E0D\u5B58\u5728\u7684\u8FDB\u7A0B (PID: ${pid})`, "warning");
183
180
  }
184
181
  }
185
182
  /**
@@ -202,60 +199,83 @@ class ProcessManager extends EventEmitter {
202
199
  this.log("\u7528\u6237\u8BF7\u6C42\u5F3A\u5236\u5173\u95ED\uFF0C\u7ACB\u5373\u7EC8\u6B62\u6240\u6709\u8FDB\u7A0B...", "warning");
203
200
  };
204
201
  process.once("SIGINT", forceShutdownHandler);
205
- let runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
206
- if (runningProcesses.length > 0) {
207
- this.log(`\u5411 ${runningProcesses.length} \u4E2A\u8FD0\u884C\u4E2D\u7684\u8FDB\u7A0B\u53D1\u9001SIGTERM\u4FE1\u53F7...`, "info");
208
- for (const info of runningProcesses) {
209
- try {
210
- info.process.kill("SIGTERM");
211
- info.status = "killed";
212
- } catch (error) {
213
- this.log(`\u65E0\u6CD5\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid}): ${error}`, "error");
202
+ try {
203
+ let runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
204
+ if (runningProcesses.length > 0) {
205
+ for (const info of runningProcesses) {
206
+ try {
207
+ info.process.kill("SIGTERM");
208
+ info.status = "killed";
209
+ } catch (error) {
210
+ this.log(`\u65E0\u6CD5\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid}): ${error}`, "error");
211
+ }
214
212
  }
215
- }
216
- const maxWaitTime = 1e3;
217
- const checkInterval = 100;
218
- let waitedTime = 0;
219
- while (waitedTime < maxWaitTime && !forceShutdownRequested) {
220
- await new Promise((resolve) => setTimeout(resolve, checkInterval));
221
- waitedTime += checkInterval;
222
- runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
223
- if (runningProcesses.length === 0) {
224
- break;
213
+ const maxWaitTime = 1e3;
214
+ const checkInterval = 100;
215
+ let waitedTime = 0;
216
+ while (waitedTime < maxWaitTime && !forceShutdownRequested) {
217
+ await new Promise((resolve) => setTimeout(resolve, checkInterval));
218
+ waitedTime += checkInterval;
219
+ runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
220
+ if (runningProcesses.length === 0) {
221
+ break;
222
+ }
225
223
  }
226
224
  }
227
- }
228
- process.removeListener("SIGINT", forceShutdownHandler);
229
- runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
230
- if (runningProcesses.length > 0) {
231
- this.log(`\u5F3A\u5236\u7EC8\u6B62 ${runningProcesses.length} \u4E2A\u4ECD\u5728\u8FD0\u884C\u7684\u8FDB\u7A0B...`, "warning");
232
- for (const info of runningProcesses) {
233
- try {
234
- info.process.kill("SIGKILL");
235
- this.log(`\u5F3A\u5236\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid})`, "warning");
236
- } catch (error) {
237
- this.log(`\u65E0\u6CD5\u5F3A\u5236\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid}): ${error}`, "error");
225
+ process.removeListener("SIGINT", forceShutdownHandler);
226
+ runningProcesses = Array.from(this.processes.values()).filter((p) => p.status === "running");
227
+ if (runningProcesses.length > 0) {
228
+ this.log(`\u5F3A\u5236\u7EC8\u6B62 ${runningProcesses.length} \u4E2A\u4ECD\u5728\u8FD0\u884C\u7684\u8FDB\u7A0B...`, "warning");
229
+ for (const info of runningProcesses) {
230
+ try {
231
+ info.process.kill("SIGKILL");
232
+ this.log(`\u5F3A\u5236\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid})`, "warning");
233
+ } catch (error) {
234
+ this.log(`\u65E0\u6CD5\u5F3A\u5236\u7EC8\u6B62\u8FDB\u7A0B ${info.name} (PID: ${info.pid}): ${error}`, "error");
235
+ }
238
236
  }
239
237
  }
238
+ const totalTime = Date.now() - firstSignalTime;
239
+ this.log(`\u5173\u95ED\u5B8C\u6210\uFF0C\u8017\u65F6 ${totalTime}ms`, "success");
240
+ } catch (error) {
241
+ this.log(`\u5173\u95ED\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF: ${error}`, "error");
242
+ } finally {
243
+ this.cleanup();
244
+ setTimeout(() => {
245
+ process.exit(0);
246
+ }, 100);
240
247
  }
241
- const totalTime = Date.now() - firstSignalTime;
242
- this.log(`\u5173\u95ED\u5B8C\u6210\uFF0C\u8017\u65F6 ${totalTime}ms`, "success");
243
- this.cleanup();
244
- process.exit(0);
245
248
  }
246
249
  /**
247
250
  * 清理所有进程
248
251
  */
249
252
  cleanup() {
250
- for (const [pid, info] of this.processes) {
251
- if (info.status === "running") {
252
- try {
253
- info.process.kill("SIGKILL");
254
- } catch {
253
+ try {
254
+ let cleanedCount = 0;
255
+ for (const [pid, info] of this.processes) {
256
+ if (info.status === "running") {
257
+ try {
258
+ if (info.process.kill("SIGTERM")) {
259
+ this.log(`\u5DF2\u53D1\u9001 SIGTERM \u4FE1\u53F7\u7ED9\u8FDB\u7A0B ${info.name} (PID: ${pid})`, "info");
260
+ cleanedCount++;
261
+ }
262
+ } catch (error) {
263
+ this.log(`\u53D1\u9001 SIGTERM \u4FE1\u53F7\u7ED9\u8FDB\u7A0B ${info.name} (PID: ${pid}) \u5931\u8D25: ${error}`, "warning");
264
+ try {
265
+ if (info.process.kill("SIGKILL")) {
266
+ this.log(`\u5DF2\u53D1\u9001 SIGKILL \u4FE1\u53F7\u7ED9\u8FDB\u7A0B ${info.name} (PID: ${pid})`, "warning");
267
+ cleanedCount++;
268
+ }
269
+ } catch (killError) {
270
+ this.log(`\u53D1\u9001 SIGKILL \u4FE1\u53F7\u7ED9\u8FDB\u7A0B ${info.name} (PID: ${pid}) \u5931\u8D25: ${killError}`, "error");
271
+ }
272
+ }
255
273
  }
256
274
  }
275
+ this.processes.clear();
276
+ } catch (error) {
277
+ this.log(`\u8FDB\u7A0B\u6E05\u7406\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF: ${error}`, "error");
257
278
  }
258
- this.processes.clear();
259
279
  }
260
280
  /**
261
281
  * 获取当前运行的进程数量
@@ -532,6 +552,118 @@ promisify$1(exec$1);
532
552
 
533
553
  promisify$1(exec$1);
534
554
 
555
+ async function checkLocalClaudeCode() {
556
+ try {
557
+ const fs = await import('fs');
558
+ let globalPackagePath;
559
+ try {
560
+ const { createRequire } = await import('module');
561
+ const require = createRequire(import.meta.url);
562
+ globalPackagePath = require.resolve("aico-cli/package.json");
563
+ globalPackagePath = path.dirname(globalPackagePath);
564
+ } catch (resolveError) {
565
+ const isWindows = process.platform === "win32";
566
+ try {
567
+ const { spawnSync } = await import('child_process');
568
+ const result = spawnSync("npm", ["config", "get", "prefix"], {
569
+ encoding: "utf8",
570
+ timeout: 5e3
571
+ });
572
+ if (result.status === 0 && result.stdout) {
573
+ const npmPrefix = result.stdout.trim();
574
+ globalPackagePath = path.join(
575
+ npmPrefix,
576
+ isWindows ? "" : "lib",
577
+ "node_modules",
578
+ "aico-cli"
579
+ );
580
+ } else {
581
+ throw new Error("npm config get prefix failed");
582
+ }
583
+ } catch (npmError) {
584
+ const npmPrefix = process.env.npm_config_prefix || process.env.NVM_BIN ? path.dirname(path.dirname(process.env.NVM_BIN)) : isWindows ? process.env.APPDATA + "/npm" : "/usr/local";
585
+ globalPackagePath = path.join(
586
+ npmPrefix,
587
+ isWindows ? "" : "lib",
588
+ "node_modules",
589
+ "aico-cli"
590
+ );
591
+ }
592
+ }
593
+ const claudeEditorPath = path.join(globalPackagePath, "bin/cli/cli.js");
594
+ if (fs.existsSync(claudeEditorPath)) {
595
+ const stats = fs.statSync(claudeEditorPath);
596
+ return {
597
+ exists: true,
598
+ path: claudeEditorPath,
599
+ size: stats.size,
600
+ type: "global-package"
601
+ };
602
+ }
603
+ return {
604
+ exists: false,
605
+ path: claudeEditorPath,
606
+ type: "global-package"
607
+ };
608
+ } catch (error) {
609
+ return {
610
+ exists: false,
611
+ path: "\u5168\u5C40\u5305\u4E2D\u7684 bin/cli/cli.js",
612
+ error: error instanceof Error ? error.message : String(error),
613
+ type: "global-package"
614
+ };
615
+ }
616
+ }
617
+ async function checkGlobalClaudeCode() {
618
+ try {
619
+ const isWindows = process.platform === "win32";
620
+ const command = isWindows ? "claude.cmd" : "claude";
621
+ const { spawnSync } = await import('child_process');
622
+ const whichCommand = isWindows ? "where" : "which";
623
+ const result = spawnSync(whichCommand, [command], {
624
+ stdio: "pipe",
625
+ timeout: 5e3
626
+ // 5秒超时
627
+ });
628
+ if (result.status === 0 && result.stdout) {
629
+ const output = result.stdout.toString().trim();
630
+ return {
631
+ installed: true,
632
+ command: output.split("\n")[0]
633
+ // 返回第一个匹配的路径
634
+ };
635
+ }
636
+ return {
637
+ installed: false,
638
+ error: result.stderr?.toString() || "\u547D\u4EE4\u672A\u627E\u5230"
639
+ };
640
+ } catch (error) {
641
+ return {
642
+ installed: false,
643
+ error: error instanceof Error ? error.message : String(error)
644
+ };
645
+ }
646
+ }
647
+ async function performHealthCheck() {
648
+ const localCheck = await checkLocalClaudeCode();
649
+ if (localCheck.exists) {
650
+ console.log(ansis.cyan("\u{1F680} \u6B63\u5728\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668..."));
651
+ console.log(ansis.gray(` \u4F7F\u7528\u5168\u5C40\u5305\u4E2D\u7684\u7F16\u8F91\u5668: ${localCheck.path}`));
652
+ } else {
653
+ console.log(ansis.yellow(`\u26A0\uFE0F \u6CA1\u6709\u68C0\u6D4B\u5230\u5168\u5C40\u5305\u4E2D\u7684\u7F16\u8F91\u5668: ${localCheck.path}`));
654
+ if (localCheck.error) {
655
+ console.log(ansis.gray(` \u9519\u8BEF\u8BE6\u60C5: ${localCheck.error}`));
656
+ }
657
+ console.log(ansis.yellow("\u{1F4A1} \u5C06\u5C1D\u8BD5\u5176\u4ED6\u542F\u52A8\u65B9\u5F0F..."));
658
+ }
659
+ const globalCheck = await checkGlobalClaudeCode();
660
+ if (!globalCheck.installed) {
661
+ if (globalCheck.error) {
662
+ console.log(ansis.gray(` \u5168\u5C40\u547D\u4EE4\u68C0\u67E5: ${globalCheck.error}`));
663
+ }
664
+ }
665
+ }
666
+
535
667
  async function tryStartClaude(command, args, options) {
536
668
  process.platform === "win32";
537
669
  const spawnOptions = {
@@ -545,7 +677,7 @@ async function tryStartClaude(command, args, options) {
545
677
  }
546
678
  async function startClaudeCodeEditor(_lang) {
547
679
  try {
548
- console.log(ansis.cyan("\u{1F680} \u6B63\u5728\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668..."));
680
+ await performHealthCheck();
549
681
  const isWindows = process.platform === "win32";
550
682
  const spawnOptions = {
551
683
  stdio: "inherit",
@@ -556,14 +688,16 @@ async function startClaudeCodeEditor(_lang) {
556
688
  // 禁用shell模式,避免进程泄漏(Windows和Unix都适用)
557
689
  };
558
690
  try {
559
- const localClaudePath = path.resolve(__dirname, "../../bin/cli/cli.js");
560
- console.log(ansis.gray(`\u{1F4C1} \u5C1D\u8BD5\u4F7F\u7528\u672C\u5730 Claude Code: ${localClaudePath}`));
691
+ const localCheck = await checkLocalClaudeCode();
692
+ if (!localCheck.exists) {
693
+ throw new Error(`\u672C\u5730 aico\u8FD0\u884C\u547D\u4EE4 \u6587\u4EF6\u4E0D\u5B58\u5728: ${localCheck.path}${localCheck.error ? ` (${localCheck.error})` : ""}`);
694
+ }
561
695
  const command = isWindows ? "node.exe" : "node";
562
- const args = [localClaudePath];
696
+ const args = [localCheck.path];
563
697
  await tryStartClaude(command, args, spawnOptions);
564
698
  return;
565
699
  } catch (localError) {
566
- console.log(ansis.yellow("\u26A0\uFE0F \u672C\u5730 Claude Code \u8C03\u7528\u5931\u8D25\uFF0C\u5C1D\u8BD5\u81EA\u52A8\u5B89\u88C5\u5E76\u542F\u52A8..."));
700
+ console.log(ansis.yellow("\u{1F4A1} \u5C1D\u8BD5\u81EA\u52A8\u5B89\u88C5\u5E76\u542F\u52A8..."));
567
701
  try {
568
702
  const installed = await isClaudeCodeInstalled();
569
703
  if (!installed) {
@@ -573,6 +707,7 @@ async function startClaudeCodeEditor(_lang) {
573
707
  }
574
708
  const command = isWindows ? "claude.cmd" : "claude";
575
709
  const args = [];
710
+ console.log(ansis.gray(`\u{1F527} \u4F7F\u7528\u5168\u5C40\u547D\u4EE4: ${command}`));
576
711
  if (isWindows) {
577
712
  await tryStartClaude(command, args, spawnOptions);
578
713
  } else {
@@ -580,9 +715,11 @@ async function startClaudeCodeEditor(_lang) {
580
715
  }
581
716
  return;
582
717
  } catch (installError) {
583
- console.log(ansis.yellow("\u26A0\uFE0F \u5B89\u88C5\u540E\u542F\u52A8\u5931\u8D25\uFF0C\u5C1D\u8BD5\u4F7F\u7528 npx..."));
718
+ console.log(ansis.yellow("\u26A0\uFE0F \u5B89\u88C5\u540E\u542F\u52A8\u5931\u8D25: "), ansis.gray(installError.message));
719
+ console.log(ansis.yellow("\u{1F4A1} \u5C1D\u8BD5\u4F7F\u7528 npx \u542F\u52A8..."));
584
720
  try {
585
721
  const npxArgs = ["@anthropic-ai/claude-code"];
722
+ console.log(ansis.gray(`\u{1F527} \u4F7F\u7528 npx \u547D\u4EE4: npx ${npxArgs.join(" ")}`));
586
723
  if (isWindows) {
587
724
  await tryStartClaude("npx.cmd", npxArgs, spawnOptions);
588
725
  } else {
@@ -590,40 +727,58 @@ async function startClaudeCodeEditor(_lang) {
590
727
  }
591
728
  return;
592
729
  } catch (npxError) {
593
- throw installError;
730
+ console.log(ansis.yellow("\u26A0\uFE0F npx \u542F\u52A8\u4E5F\u5931\u8D25: "), ansis.gray(npxError.message));
731
+ throw new Error(`\u6240\u6709\u542F\u52A8\u65B9\u5F0F\u5747\u5931\u8D25:
732
+ - \u672C\u5730\u542F\u52A8: ${localError.message}
733
+ - \u5168\u5C40\u542F\u52A8: ${installError.message || "\u8DF3\u8FC7"}
734
+ - npx\u542F\u52A8: ${npxError.message}`);
594
735
  }
595
736
  }
596
737
  }
597
738
  } catch (error) {
598
739
  console.error(ansis.red("\u274C \u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\u5931\u8D25:"));
599
740
  const isWindows = process.platform === "win32";
741
+ console.error(ansis.yellow("\u{1F4CB} \u8BE6\u7EC6\u8BCA\u65AD\u4FE1\u606F:"));
742
+ console.error(ansis.gray(` \u9519\u8BEF\u7C7B\u578B: ${error.name || "Unknown"}`));
743
+ console.error(ansis.gray(` \u9519\u8BEF\u4EE3\u7801: ${error.code || "\u65E0"}`));
744
+ console.error(ansis.gray(` \u9519\u8BEF\u6D88\u606F: ${error.message || error}`));
745
+ console.error(ansis.gray(` \u5F53\u524D\u76EE\u5F55: ${process.cwd()}`));
746
+ console.error(ansis.gray(` \u64CD\u4F5C\u7CFB\u7EDF: ${process.platform}`));
747
+ console.error(ansis.gray(` Node.js \u7248\u672C: ${process.version}`));
748
+ console.error(ansis.gray(` \u5185\u5B58\u4F7F\u7528: ${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`));
600
749
  if (error.code === "ENOENT" || error.message?.includes("command not found") || error.message?.includes("ENOENT")) {
601
750
  console.error(ansis.yellow("\u{1F4A1} \u53EF\u80FD\u7684\u539F\u56E0:"));
602
751
  console.error(ansis.gray(" 1. \u672C\u5730 Claude Code \u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u8DEF\u5F84\u9519\u8BEF"));
603
752
  console.error(ansis.gray(" 2. \u81EA\u52A8\u5B89\u88C5 Claude Code \u5931\u8D25"));
604
753
  console.error(ansis.gray(" 3. Node.js \u73AF\u5883\u95EE\u9898"));
754
+ console.error(ansis.gray(" 4. PATH \u73AF\u5883\u53D8\u91CF\u914D\u7F6E\u95EE\u9898"));
605
755
  console.error(ansis.yellow("\u{1F4A1} \u89E3\u51B3\u65B9\u6848:"));
606
756
  console.error(ansis.gray(" - \u786E\u4FDD\u9879\u76EE\u5DF2\u6B63\u786E\u6784\u5EFA\uFF0Cbin/cli/cli.js \u6587\u4EF6\u5B58\u5728"));
607
757
  console.error(ansis.gray(" - \u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\uFF0C\u786E\u4FDD\u53EF\u4EE5\u8BBF\u95EE npm \u4ED3\u5E93"));
608
758
  console.error(ansis.gray(" - \u624B\u52A8\u5B89\u88C5: npm install -g @anthropic-ai/claude-code"));
759
+ console.error(ansis.gray(" - \u68C0\u67E5 Node.js \u548C npm \u7248\u672C\u517C\u5BB9\u6027"));
609
760
  if (isWindows) {
610
761
  console.error(ansis.yellow("\u{1F4A1} Windows \u7528\u6237\u989D\u5916\u63D0\u793A:"));
611
762
  console.error(ansis.gray(" 1. \u91CD\u542F\u547D\u4EE4\u884C\u7A97\u53E3\u4EE5\u5237\u65B0 PATH \u73AF\u5883\u53D8\u91CF"));
612
763
  console.error(ansis.gray(" 2. \u786E\u8BA4 npm \u5168\u5C40\u5B89\u88C5\u8DEF\u5F84\u5728 PATH \u4E2D"));
613
764
  console.error(ansis.gray(" 3. \u5C1D\u8BD5\u4F7F\u7528 npx.cmd @anthropic-ai/claude-code --dangerously-skip-permissions"));
614
765
  console.error(ansis.gray(" 4. \u68C0\u67E5\u662F\u5426\u5B89\u88C5\u4E86 Node.js \u548C npm"));
766
+ console.error(ansis.gray(" 5. \u5C1D\u8BD5\u4EE5\u7BA1\u7406\u5458\u6743\u9650\u8FD0\u884C"));
615
767
  }
616
768
  } else if (error.message?.includes("spawn") || error.message?.includes("\u8FDB\u7A0B")) {
617
769
  console.error(ansis.yellow("\u{1F4A1} \u8FDB\u7A0B\u542F\u52A8\u5931\u8D25\uFF0C\u53EF\u80FD\u662F\u8FDB\u7A0B\u7BA1\u7406\u95EE\u9898:"));
618
770
  console.error(ansis.gray(" 1. \u68C0\u67E5\u7CFB\u7EDF\u662F\u5426\u6709\u8DB3\u591F\u7684\u8D44\u6E90"));
619
771
  console.error(ansis.gray(" 2. \u5C1D\u8BD5\u5173\u95ED\u5176\u4ED6\u5E94\u7528\u7A0B\u5E8F\u91CA\u653E\u5185\u5B58"));
772
+ console.error(ansis.gray(" 3. \u68C0\u67E5\u8FDB\u7A0B\u7BA1\u7406\u5668\u72B6\u6001"));
620
773
  if (isWindows) {
621
- console.error(ansis.gray(" 3. Windows\u7528\u6237: \u5C1D\u8BD5\u4EE5\u7BA1\u7406\u5458\u6743\u9650\u8FD0\u884C"));
622
- console.error(ansis.gray(" 4. Windows\u7528\u6237: \u68C0\u67E5\u9632\u75C5\u6BD2\u8F6F\u4EF6\u662F\u5426\u963B\u6B62\u4E86\u8FDB\u7A0B\u542F\u52A8"));
774
+ console.error(ansis.gray(" 4. Windows\u7528\u6237: \u5C1D\u8BD5\u4EE5\u7BA1\u7406\u5458\u6743\u9650\u8FD0\u884C"));
775
+ console.error(ansis.gray(" 5. Windows\u7528\u6237: \u68C0\u67E5\u9632\u75C5\u6BD2\u8F6F\u4EF6\u662F\u5426\u963B\u6B62\u4E86\u8FDB\u7A0B\u542F\u52A8"));
623
776
  }
624
777
  } else {
625
- console.error(ansis.gray(` \u9519\u8BEF\u4FE1\u606F: ${error.message || error}`));
626
- console.error(ansis.gray(` \u9519\u8BEF\u4EE3\u7801: ${error.code || "\u65E0"}`));
778
+ console.error(ansis.yellow("\u{1F4A1} \u672A\u77E5\u9519\u8BEF\u7C7B\u578B\uFF0C\u8BF7\u68C0\u67E5\u4EE5\u4E0B\u5185\u5BB9:"));
779
+ console.error(ansis.gray(" 1. \u67E5\u770B\u5B8C\u6574\u7684\u9519\u8BEF\u5806\u6808\u4FE1\u606F"));
780
+ console.error(ansis.gray(" 2. \u68C0\u67E5\u7CFB\u7EDF\u65E5\u5FD7"));
781
+ console.error(ansis.gray(" 3. \u5C1D\u8BD5\u91CD\u542F\u7CFB\u7EDF"));
627
782
  }
628
783
  try {
629
784
  const processCount = processManager.getProcessCount();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "2.0.24",
3
+ "version": "2.0.26",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {
@@ -2,15 +2,6 @@
2
2
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
3
  "hooks": {
4
4
  "PreToolUse": [
5
- {
6
- "matcher": "Bash",
7
- "hooks": [
8
- {
9
- "type": "command",
10
- "command": "if [ \"$OS\" = \"Windows_NT\" ]; then powershell -File \"$env:USERPROFILE/.claude/hooks/scripts/PreToolUse/powershell/command-logger.ps1\"; else ~/.claude/hooks/scripts/PreToolUse/bash/command-logger.sh; fi"
11
- }
12
- ]
13
- },
14
5
  {
15
6
  "matcher": "Edit|Write",
16
7
  "hooks": [
@@ -1,95 +1,125 @@
1
- # Stop Hook - 会话摘要
2
- # Claude Code停止响应时记录会话摘要
3
-
4
- # 加载跨平台工具模块
5
- . "$PSScriptRoot\..\..\..\utils\crossplatform-detector.ps1"
6
-
7
- # 获取当前时间信息
8
- $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
9
- $sessionFile = "$(Get-HooksDirectory)\session-summary.txt"
10
-
11
- # 确保日志目录存在
12
- $logDir = Split-Path -Parent $sessionFile
13
- if (-not (Test-Path $logDir)) {
14
- New-Item -ItemType Directory -Path $logDir -Force | Out-Null
1
+ # Stop Hook - Session Summary
2
+ # Record session summary when Claude Code stops
3
+
4
+ # Set error handling preference
5
+ $ErrorActionPreference = "Continue"
6
+
7
+ # Simple OS detection
8
+ function Get-OperatingSystem {
9
+ if ($env:OS -eq "Windows_NT") {
10
+ return "windows"
11
+ } elseif ($IsLinux) {
12
+ return "linux"
13
+ } elseif ($IsMacOS) {
14
+ return "macos"
15
+ } else {
16
+ return "unknown"
17
+ }
15
18
  }
16
19
 
17
- # 创建会话摘要的函数
18
- function New-SessionSummary {
19
- $summary = @"
20
- === Claude Code 会话摘要 ===
21
- 结束时间: $timestamp
22
- 工作目录: $(Get-ProjectDirectory)
23
- 操作系统: $(Get-OperatingSystem)
20
+ # Simple log function
21
+ function Write-HookLog {
22
+ param(
23
+ [string]$Level,
24
+ [string]$Message
25
+ )
26
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
27
+ Write-Host "[$timestamp] [$Level] $Message"
28
+ }
24
29
 
25
- "@
30
+ # Send stop notification function
31
+ function Send-StopNotification {
32
+ $osType = Get-OperatingSystem
33
+ $message = "Claude Code session ended"
34
+ $title = "Claude Code"
26
35
 
27
- # 统计最近的命令执行情况
28
- $commandLog = "$(Get-HooksDirectory)\bash-command-log.txt"
29
- if (Test-Path $commandLog) {
30
- $today = Get-Date -Format "yyyy-MM-dd"
31
- $todayCommands = (Get-Content $commandLog | Where-Object { $_ -match $today }).Count
32
- $summary += "今日执行命令数: $todayCommands`r`n"
33
-
34
- # 显示最近的几个命令
35
- $summary += "最近执行的命令:`r`n"
36
- $recentCommands = Get-Content $commandLog | Select-Object -Last 5
37
- $summary += ($recentCommands -join "`r`n") + "`r`n"
38
- } else {
39
- $summary += "今日执行命令数: 0`r`n"
36
+ Write-HookLog "INFO" "Detected OS: $osType"
37
+
38
+ try {
39
+ # Simplified notification logic
40
+ switch ($osType) {
41
+ "windows" {
42
+ # Windows simplified notification
43
+ Write-Host "=== $title ===" -ForegroundColor Green
44
+ Write-Host $message -ForegroundColor White
45
+
46
+ # Play simple system sound
47
+ try {
48
+ [System.Media.SystemSounds]::Asterisk.Play()
49
+ Write-HookLog "INFO" "Played system sound successfully"
50
+ } catch {
51
+ Write-HookLog "WARN" "Failed to play system sound: $($_.Exception.Message)"
52
+ }
53
+ }
54
+ default {
55
+ Write-HookLog "INFO" "Using console output for notification"
56
+ Write-Host "=== $title ===" -ForegroundColor Green
57
+ Write-Host $message -ForegroundColor White
58
+ }
59
+ }
60
+ } catch {
61
+ Write-HookLog "ERROR" "Error during notification: $($_.Exception.Message)"
62
+ Write-Host "[$Title] $message" -ForegroundColor Cyan
40
63
  }
41
64
 
42
- $summary += "`r`n---`r`n`r`n"
65
+ Write-HookLog "INFO" "Stop notification sent"
66
+ }
43
67
 
44
- # 写入文件
45
- Add-Content -Path $sessionFile -Value $summary
68
+ # Simple session summary function
69
+ function Write-SimpleSessionSummary {
70
+ try {
71
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
72
+ $summary = @"
73
+ === Claude Code Session Summary ===
74
+ End Time: $timestamp
75
+ Working Directory: $(Get-Location)
76
+ OS: $(Get-OperatingSystem)
46
77
 
47
- # 记录到主日志
48
- Write-HookLog "INFO" "Claude Code会话结束,已生成摘要"
49
- }
78
+ Session Summary: Claude Code session ended normally
50
79
 
51
- # 创建会话摘要
52
- New-SessionSummary
80
+ ---
53
81
 
54
- # 发送完成通知的函数
55
- function Send-CompletionNotification {
56
- $osType = Get-OperatingSystem
57
- $message = "Claude Code 会话已结束"
58
- $title = "Claude Code"
82
+ "@
59
83
 
60
- switch ($osType) {
61
- "windows" {
62
- # Windows 使用系统通知
63
- try {
64
- Add-Type -AssemblyName System.Windows.Forms
65
- $result = [System.Windows.Forms.MessageBox]::Show($Message, $Title, [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
66
-
67
- # 播放完成声音
68
- $soundFile = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Windows) + "\Media\tada.wav"
69
- if (Test-Path $soundFile) {
70
- $player = New-Object Media.SoundPlayer $soundFile
71
- $player.Play()
72
- }
73
- } catch {
74
- Write-Host "通知发送失败: $_"
75
- }
84
+ # Write to file
85
+ try {
86
+ $userProfile = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::UserProfile)
87
+ $sessionFile = "$userProfile\.claude\hooks\session-summary.txt"
88
+ Write-HookLog "INFO" "Session file path: $sessionFile"
89
+ } catch {
90
+ Write-HookLog "ERROR" "Failed to get user profile path: $($_.Exception.Message)"
91
+ # Fallback to a simpler path
92
+ $sessionFile = ".\session-summary.txt"
93
+ Write-HookLog "WARN" "Using fallback path: $sessionFile"
76
94
  }
77
- default {
78
- # Unix/Linux/macOS 系统通知
79
- if (Test-CommandExists "notify-send") {
80
- notify-send $Title $Message
81
- }
82
95
 
83
- # 播放完成声音
84
- if (Test-CommandExists "paplay") {
85
- paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>$null
86
- }
96
+ try {
97
+ Add-Content -Path $sessionFile -Value $summary
98
+ Write-HookLog "INFO" "Session summary written to file"
99
+ } catch {
100
+ Write-HookLog "WARN" "Failed to write session summary: $($_.Exception.Message)"
87
101
  }
102
+ } catch {
103
+ Write-HookLog "ERROR" "Error creating session summary: $($_.Exception.Message)"
88
104
  }
89
105
  }
90
106
 
91
- # 发送完成通知
92
- Send-CompletionNotification
93
-
94
- # 继续执行
95
- exit 0
107
+ # Main execution
108
+ try {
109
+ Write-HookLog "INFO" "Starting Stop hook"
110
+
111
+ # Create session summary
112
+ Write-SimpleSessionSummary
113
+
114
+ # Send completion notification
115
+ Send-StopNotification
116
+
117
+ Write-HookLog "INFO" "Stop hook completed successfully"
118
+ exit 0
119
+ } catch {
120
+ Write-HookLog "ERROR" "Stop hook failed: $($_.Exception.Message)"
121
+ Write-HookLog "ERROR" "Exception type: $($_.Exception.GetType().FullName)"
122
+ Write-HookLog "ERROR" "Stack trace: $($_.Exception.StackTrace)"
123
+ # Even if there's an error, exit with success code to avoid disrupting the main process
124
+ exit 0
125
+ }
@@ -1,61 +1,33 @@
1
- # UserPromptSubmit Hook - 输入通知器
2
- # 当用户提交输入时发送通知
1
+ # UserPromptSubmit Hook - Input Notifier
2
+ # Send notification when user submits input
3
3
 
4
- # 设置错误处理策略
4
+ # Set error handling preference
5
5
  $ErrorActionPreference = "Continue"
6
6
 
7
- # 尝试加载跨平台工具模块
8
- $utilsPath = Join-Path $PSScriptRoot "../../utils/crossplatform-detector.ps1"
9
- if (Test-Path $utilsPath) {
10
- try {
11
- . $utilsPath
12
- Write-Host "[INFO] 成功加载跨平台工具模块"
13
- } catch {
14
- Write-Host "[WARN] 加载跨平台工具模块失败: $($_.Exception.Message)"
15
- }
16
- } else {
17
- Write-Host "[WARN] 跨平台工具模块不存在: $utilsPath"
18
- }
19
-
20
- # 如果模块加载失败,提供备用函数
21
- if (-not (Get-Command "Write-HookLog" -ErrorAction SilentlyContinue)) {
22
- function Write-HookLog {
23
- param(
24
- [string]$Level,
25
- [string]$Message
26
- )
27
- $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
28
- Write-Host "[$timestamp] [$Level] $Message"
29
- }
30
- }
31
-
32
- if (-not (Get-Command "Test-CommandExists" -ErrorAction SilentlyContinue)) {
33
- function Test-CommandExists {
34
- param([string]$Command)
35
- try {
36
- Get-Command $Command -ErrorAction Stop > $null
37
- return $true
38
- } catch {
39
- return $false
40
- }
7
+ # Simple OS detection
8
+ function Get-OperatingSystem {
9
+ if ($env:OS -eq "Windows_NT") {
10
+ return "windows"
11
+ } elseif ($IsLinux) {
12
+ return "linux"
13
+ } elseif ($IsMacOS) {
14
+ return "macos"
15
+ } else {
16
+ return "unknown"
41
17
  }
42
18
  }
43
19
 
44
- if (-not (Get-Command "Get-OperatingSystem" -ErrorAction SilentlyContinue)) {
45
- function Get-OperatingSystem {
46
- if ($env:OS -eq "Windows_NT") {
47
- return "windows"
48
- } elseif ($IsLinux) {
49
- return "linux"
50
- } elseif ($IsMacOS) {
51
- return "macos"
52
- } else {
53
- return "unknown"
54
- }
55
- }
20
+ # Simple log function
21
+ function Write-HookLog {
22
+ param(
23
+ [string]$Level,
24
+ [string]$Message
25
+ )
26
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
27
+ Write-Host "[$timestamp] [$Level] $Message"
56
28
  }
57
29
 
58
- # 发送通知的函数
30
+ # Send notification function
59
31
  function Send-Notification {
60
32
  param(
61
33
  [string]$Title,
@@ -63,84 +35,51 @@ function Send-Notification {
63
35
  )
64
36
 
65
37
  $osType = Get-OperatingSystem
66
- Write-HookLog "INFO" "检测到操作系统: $osType"
38
+ Write-HookLog "INFO" "Detected OS: $osType"
67
39
 
68
40
  try {
69
- # 简化通知逻辑 - 使用控制台输出作为主要方式
41
+ # Simplified notification logic
70
42
  switch ($osType) {
71
43
  "windows" {
72
- # Windows 简化通知 - 只使用控制台输出
44
+ # Windows simplified notification
73
45
  Write-Host "=== $Title ===" -ForegroundColor Yellow
74
46
  Write-Host $Message -ForegroundColor White
75
47
 
76
- # 播放简单的系统声音
48
+ # Play simple system sound
77
49
  try {
78
50
  [System.Media.SystemSounds]::Beep.Play()
79
- Write-HookLog "INFO" "播放系统蜂鸣声成功"
51
+ Write-HookLog "INFO" "Played system beep successfully"
80
52
  } catch {
81
- Write-HookLog "WARN" "系统声音播放失败: $($_.Exception.Message)"
82
- }
83
- }
84
- "linux" {
85
- # Linux 简化通知
86
- Write-Host "=== $Title ===" -ForegroundColor Yellow
87
- Write-Host $Message -ForegroundColor White
88
-
89
- # 如果可用,使用系统通知
90
- if (Test-CommandExists "notify-send") {
91
- try {
92
- Start-Process -FilePath "notify-send" -ArgumentList $Title, $Message -NoNewWindow -Wait
93
- Write-HookLog "INFO" "发送 Linux 桌面通知"
94
- } catch {
95
- Write-HookLog "WARN" "notify-send 失败,使用控制台输出"
96
- }
97
- }
98
- }
99
- "macos" {
100
- # macOS 简化通知
101
- Write-Host "=== $Title ===" -ForegroundColor Yellow
102
- Write-Host $Message -ForegroundColor White
103
-
104
- # 如果可用,使用系统通知
105
- if (Test-CommandExists "osascript") {
106
- try {
107
- $script = "display notification \"$Message\" with title \"$Title\""
108
- Start-Process -FilePath "osascript" -ArgumentList "-e", $script -NoNewWindow -Wait
109
- Write-HookLog "INFO" "发送 macOS 桌面通知"
110
- } catch {
111
- Write-HookLog "WARN" "osascript 失败,使用控制台输出"
112
- }
53
+ Write-HookLog "WARN" "Failed to play system sound: $($_.Exception.Message)"
113
54
  }
114
55
  }
115
56
  default {
116
- Write-HookLog "WARN" "未知操作系统,使用控制台输出"
57
+ Write-HookLog "INFO" "Using console output for notification"
117
58
  Write-Host "=== $Title ===" -ForegroundColor Yellow
118
59
  Write-Host $Message -ForegroundColor White
119
60
  }
120
61
  }
121
62
  } catch {
122
- Write-HookLog "ERROR" "通知发送过程中发生错误: $($_.Exception.Message)"
123
- # 确保总是有某种形式的输出
63
+ Write-HookLog "ERROR" "Error during notification: $($_.Exception.Message)"
124
64
  Write-Host "[$Title] $Message" -ForegroundColor Cyan
125
65
  }
126
66
 
127
- Write-HookLog "INFO" "通知发送完成: $Message"
67
+ Write-HookLog "INFO" "Notification sent: $Message"
128
68
  }
129
69
 
130
- # 主执行逻辑
70
+ # Main execution
131
71
  try {
132
- Write-HookLog "INFO" "开始执行 UserPromptSubmit hook"
72
+ Write-HookLog "INFO" "Starting UserPromptSubmit hook"
133
73
 
134
- $message = "Claude Code 等待您的输入"
74
+ $message = "Claude Code is waiting for your input"
135
75
  $title = "Claude Code"
136
76
 
137
- # 发送通知
77
+ # Send notification
138
78
  Send-Notification -Title $title -Message $message
139
79
 
140
- Write-HookLog "INFO" "UserPromptSubmit hook 执行成功"
80
+ Write-HookLog "INFO" "UserPromptSubmit hook completed successfully"
141
81
  exit 0
142
82
  } catch {
143
- Write-HookLog "ERROR" "UserPromptSubmit hook 执行失败: $($_.Exception.Message)"
144
- # 即使失败也返回成功状态码,避免影响主流程
83
+ Write-HookLog "ERROR" "UserPromptSubmit hook failed: $($_.Exception.Message)"
145
84
  exit 0
146
85
  }