MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / S7Y

Function S7Y

package/cli.js:3403–3403  ·  view source on GitHub ↗
(q,K)

Source from the content-addressed store, hash-verified

3401- If a tmux session was attached to the worktree: killed on \`remove\`, left running on \`keep\` (its name is returned so the user can reattach)
3402- Once exited, EnterWorktree can be called again to create a fresh worktree
3403`}function iHK(){return"Exiting worktree…"}function rHK(q,K,_){let z=q.action==="keep"?"Kept worktree":"Removed worktree";return wy.createElement(u,{flexDirection:"column"},wy.createElement(k,null,z,q.worktreeBranch?wy.createElement(wy.Fragment,null," ","(branch ",wy.createElement(k,{bold:!0},q.worktreeBranch),")"):null),wy.createElement(k,{dimColor:!0},"Returned to ",q.originalCwd))}var wy;var oHK=y(()=>{s6();wy=O6(D6(),1)});async function aHK(q,K){let _=await a8("git",["-C",q,"status","--porcelain"]);if(_.code!==0)return null;let z=$7(_.stdout.split(`
3404`),(A)=>A.trim()!=="");if(!K)return null;let Y=await a8("git",["-C",q,"rev-list","--count",`${K}..HEAD`]);if(Y.code!==0)return null;let $=parseInt(Y.stdout.trim(),10)||0;return{changedFiles:z,commits:$}}function sHK(q,K){if(QO(q),aR(q),K)bb6(q),eE6();Oy(null),La(),wN(),hA.cache.clear?.()}var D7Y,f7Y,tHK;var eHK=y(()=>{x7();v8();kR6();k8();Bq();wM();XK();Vj6();SJ();tN();_K();d0();oHK();D7Y=B6(()=>L.strictObject({action:L.enum(["keep","remove"]).describe('"keep" leaves the worktree and branch on disk; "remove" deletes both.'),discard_changes:L.boolean().optional().describe('Required true when action is "remove" and the worktree has uncommitted files or unmerged commits. The tool will refuse and list them otherwise.')})),f7Y=B6(()=>L.object({action:L.enum(["keep","remove"]),originalCwd:L.string(),worktreePath:L.string(),worktreeBranch:L.string().optional(),tmuxSessionName:L.string().optional(),discardedFiles:L.number().optional(),discardedCommits:L.number().optional(),message:L.string()}));tHK=sq({name:lN8,searchHint:"exit a worktree session and return to the original directory",maxResultSizeChars:1e5,async description(){return"Exits a worktree session created by EnterWorktree and restores the original working directory"},async prompt(){return nHK()},get inputSchema(){return D7Y()},get outputSchema(){return f7Y()},userFacingName(){return"Exiting worktree"},shouldDefer:!0,isDestructive(q){return q.action==="remove"},toAutoClassifierInput(q){return q.action},async validateInput(q){let K=n2();if(!K)return{result:!1,message:"No-op: there is no active EnterWorktree session to exit. This tool only operates on worktrees created by EnterWorktree in the current session — it will not touch worktrees created manually or in a previous session. No filesystem changes were made.",errorCode:1};if(q.action==="remove"&&!q.discard_changes){let _=await aHK(K.worktreePath,K.originalHeadCommit);if(_===null)return{result:!1,message:`Could not verify worktree state at ${K.worktreePath}. Refusing to remove without explicit confirmation. Re-invoke with discard_changes: true to proceed — or use action: "keep" to preserve the worktree.`,errorCode:3};let{changedFiles:z,commits:Y}=_;if(z>0||Y>0){let $=[];if(z>0)$.push(`${z} uncommitted ${z===1?"file":"files"}`);if(Y>0)$.push(`${Y} ${Y===1?"commit":"commits"} on ${K.worktreeBranch??"the worktree branch"}`);return{result:!1,message:`Worktree has ${$.join(" and ")}. Removing will discard this work permanently. Confirm with the user, then re-invoke with discard_changes: true — or use action: "keep" to preserve the worktree.`,errorCode:2}}}return{result:!0}},renderToolUseMessage:iHK,renderToolResultMessage:rHK,async call(q){let K=n2();if(!K)throw Error("Not in a worktree session");let{originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:$,originalHeadCommit:A}=K,O=Fz()===r1(),{changedFiles:w,commits:j}=await aHK(z,A)??{changedFiles:0,commits:0};if(q.action==="keep"){await yR6(),sHK(_,O),d("tengu_worktree_kept",{mid_session:!0,commits:j,changed_files:w});let M=$?` Tmux session ${$} is still running; reattach with: tmux attach -t ${$}`:"";return{data:{action:"keep",originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:$,message:`Exited worktree. Your work is preserved at ${z}${Y?` on branch ${Y}`:""}. Session is now back in ${_}.${M}`}}}if($)await NR6($);await ER6(),sHK(_,O),d("tengu_worktree_removed",{mid_session:!0,commits:j,changed_files:w});let H=[];if(j>0)H.push(`${j} ${j===1?"commit":"commits"}`);if(w>0)H.push(`${w} uncommitted ${w===1?"file":"files"}`);let J=H.length>0?` Discarded ${H.join(" and ")}.`:"";return{data:{action:"remove",originalCwd:_,worktreePath:z,worktreeBranch:Y,discardedFiles:w,discardedCommits:j,message:`Exited and removed worktree at ${z}.${J} Session is now back in ${_}.`}}},mapToolResultToToolResultBlockParam({message:q},K){return{type:"tool_result",content:q,tool_use_id:K}}})});var qJK="Config";function Em8(q=!1){if(d7())return{value:null,label:"Default (recommended)",description:F06(q)};let K=E7()!=="firstParty";return{value:null,label:"Default (recommended)",description:`Use the default model (currently ${UF6(KG())})${K?"":` · ${wS(Eg)}`}`}}function Z7Y(){let q=E7()!=="firstParty",K=process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;if(q&&K){let _=cE(K);return{value:"sonnet",label:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" with 1M context":""}`} (${K})`}}}function G7Y(){let q=E7()!=="firstParty";return{value:q?n9().sonnet46:"sonnet",label:"Sonnet",description:`Sonnet 4.6 · Best for everyday tasks${q?"":` · ${wS(Eg)}`}`,descriptionForModel:"Sonnet 4.6 - best for everyday tasks. Generally recommended for most coding tasks"}}function T7Y(){let q=E7()!=="firstParty",K=process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;if(q&&K){let _=cE(K);return{value:"opus",label:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" with 1M context":""}`} (${K})`}}}function v7Y(){return{value:"opus",label:"Opus 4.1",description:"Opus 4.1 · Legacy",descriptionForModel:"Opus 4.1 - legacy version"}}function KJK(q=!1){return{value:E7()!=="firstParty"?n9().opus46:"opus",label:"Opus",description:`Opus 4.6 · Most capable for complex work${Hn(q)}`,descriptionForModel:"Opus 4.6 - most capable for complex work"}}function _JK(){let q=E7()!=="firstParty";return{value:q?n9().sonnet46+"[1m]":"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 for long sessions${q?"":` · ${wS(Eg)}`}`,descriptionForModel:"Sonnet 4.6 with 1M context window - for long sessions with large codebases"}}function zJK(q=!1){return{value:E7()!=="firstParty"?n9().opus46+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.6 for long sessions${Hn(q)}`,descriptionForModel:"Opus 4.6 with 1M context window - for long sessions with large codebases"}}function k7Y(){let q=E7()!=="firstParty",K=process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;if(q&&K)return{value:"haiku",label:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model",descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model"} (${K})`}}function OJK(){return{value:"haiku",label:"Haiku",description:`Haiku 4.5 · Fastest for quick answers${E7()!=="firstParty"?"":` · ${wS(BX1)}`}`,descriptionForModel:"Haiku 4.5 - fastest for quick answers. Lower cost but less capable than Sonnet 4.6."}}function V7Y(){return{value:"haiku",label:"Haiku",description:`Haiku 3.5 for simple tasks${E7()!=="firstParty"?"":` · ${wS(pX1)}`}`,descriptionForModel:"Haiku 3.5 - faster and lower cost, but less capable than Sonnet. Use for simple tasks."}}function N7Y(){return g06()===n9().haiku45?OJK():V7Y()}function wJK(q=!1){return{value:"opus",label:"Opus",description:`Opus 4.6 · Most capable for complex work${q?Hn(!0):""}`}}function YJK(){let q=E7()!=="firstParty";return{value:"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 with 1M context${d7()?" · Billed as extra usage":""}${q?"":` · ${wS(Eg)}`}`}}function $JK(q=!1){return{value:"opus[1m]",label:"Opus (1M context)",description:`Opus 4.6 with 1M context${d7()?" · Billed as extra usage":""}${Hn(q)}`}}function ne1(q=!1){let K=E7()!=="firstParty";return{value:K?n9().opus46+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.6 with 1M context · Most capable for complex work${!K&&q?Hn(q):""}`,descriptionForModel:"Opus 4.6 with 1M context - most capable for complex work"}}function E7Y(){return{value:"opusplan",label:"Opus Plan Mode",description:"Use Opus 4.6 in plan mode, Sonnet 4.6 otherwise"}}function L7Y(q=!1){if(d7()){if(HS()||_86()){let A=[Em8(q)];if(!HJ()&&wo())A.push($JK(q));if(A.push(y7Y),jo())A.push(YJK());return A.push(AJK),A}let $=[Em8(q)];if(jo())$.push(YJK());if(HJ())$.push(ne1(q));else if($.push(wJK(q)),wo())$.push($JK(q));return $.push(AJK),$}if(E7()==="firstParty"){let $=[Em8(q)];if(jo())$.push(_JK());if(HJ())$.push(ne1(q));else if($.push(KJK(q)),wo())$.push(zJK(q));return $.push(OJK()),$}let K=[Em8(q)],_=Z7Y();if(_!==void 0)K.push(_);else if(K.push(G7Y()),jo())K.push(_JK());let z=T7Y();if(z!==void 0)K.push(z);else if(K.push(v7Y()),K.push(KJK(q)),wo())K.push(zJK(q));let Y=k7Y();if(Y!==void 0)K.push(Y);else K.push(N7Y());return K}function R7Y(q){let K=bY(q);if(K.includes("claude-sonnet-4-6")||K.includes("claude-sonnet-4-5")||K.includes("claude-sonnet-4-")||K.includes("claude-3-7-sonnet")||K.includes("claude-3-5-sonnet")){let _=Jn(Av());if(_)return{alias:"Sonnet",currentVersionName:_}}if(K.includes("claude-opus-4")){let _=Jn(NV());if(_)return{alias:"Opus",currentVersionName:_}}if(K.includes("claude-haiku")||K.includes("claude-3-5-haiku")){let _=Jn(g06());if(_)return{alias:"Haiku",currentVersionName:_}}return null}function h7Y(q){let K=Jn(q);if(!K)return null;let _=R7Y(q);if(!_)return{value:q,label:K,description:q};if(K!==_.currentVersionName)return{value:q,label:K,description:`Newer version available · select ${_.alias} for ${_.currentVersionName}`};return{value:q,label:K,description:q}}function BK6(q=!1){let K=L7Y(q),_=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;if(_&&!K.some((A)=>A.value===_))K.push({value:_,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??_,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${_})`});for(let A of j8().additionalModelOptionsCache??[])if(!K.some((O)=>O.value===A.value))K.push(A);let z=null,Y=jS(),$=hX6();if(Y!==void 0&&Y!==null)z=Y;else if($!==null)z=$;if(z===null||K.some((A)=>A.value===z))return x88(K);else if(z==="opusplan")return x88([...K,E7Y()]);else if(z==="opus"&&E7()==="firstParty")return x88([...K,wJK(q)]);else if(z==="opus[1m]"&&E7()==="firstParty")return x88([...K,ne1(q)]);else{let A=h7Y(z);if(A)K.push(A);else K.push({value:z,label:z,description:"Custom model"});return x88(K)}}function x88(q){if(!(Z7()||{}).availableModels)return q;return q.filter((_)=>_.value===null||_.value!==null&&K86(_.value))}var y7Y,AJK;var I88=y(()=>{v8();G7();Yn();wn();U1();mL8();Az();FF6();aq();fP();V1();y7Y={value:"sonnet",label:"Sonnet",description:"Sonnet 4.6 · Best for everyday tasks"},AJK={value:"haiku",label:"Haiku",description:"Haiku 4.5 · Fastest for quick answers"}});var ie1={};T8(ie1,{isVoiceModeEnabled:()=>KH6,isVoiceGrowthBookEnabled:()=>gK6,hasVoiceAuth:()=>Lm8});function gK6(){return!g8("tengu_amber_quartz_disabled",!1)}function Lm8(){if(!WJ())return!1;let q=Kq();return Boolean(q?.accessToken)}function KH6(){return Lm8()&&gK6()}var FK6=y(()=>{o1();G7()});async function LR6(q){let K=q.trim();if(!K)return{valid:!1,error:"Model name cannot be empty"};if(!K86(K))return{valid:!1,error:`Model '${K}' is not in the list of available models`};let _=K.toLowerCase();if(Fz6.includes(_))return{valid:!0};if(K===process.env.ANTHROPIC_CUSTOM_MODEL_OPTION)return{valid:!0};if(jJK.has(K))return{valid:!0};try{return await CN({model:K,max_tokens:1,maxRetries:0,querySource:"model_validation",messages:[{role:"user",content:[{type:"text",text:"Hi",cache_control:{type:"ephemeral"}}]}]}),jJK.set(K,!0),{valid:!0}}catch(z){return S7Y(z,K)}}function S7Y(q,K){if(q instanceof K96){let z=C7Y(K),Y=z?`. Try '${z}' instead`:"";return{valid:!1,error:`Model '${K}' not found${Y}`}}if(q instanceof Qq){if(q instanceof q96)return{valid:!1,error:"Authentication failed. Please check your API credentials."};if(q instanceof wf)return{valid:!1,error:"Network error. Please check your internet connection."};let z=q.error;if(z&&typeof z==="object"&&"type"in z&&z.type==="not_found_error"&&"message"in z&&typeof z.message==="string"&&z.message.includes("model:"))return{valid:!1,error:`Model '${K}' not found`};return{valid:!1,error:`API error: ${q.message}`}}return{valid:!1,error:`Unable to validate model: ${q instanceof Error?q.message:String(q)}`}}function C7Y(q){if(E7()==="firstParty")return;let K=q.toLowerCase();if(K.includes("opus-4-6")||K.includes("opus_4_6"))return n9().opus41;if(K.includes("sonnet-4-6")||K.includes("sonnet_4_6"))return n9().sonnet45;if(K.includes("sonnet-4-5")||K.includes("sonnet_4_5"))return n9().sonnet40;return}var jJK;var Rm8=y(()=>{B06();FF6();Az();nq6();LZ();Yn();jJK=new Map});function HJK(q){return q in RR6}function JJK(q){return RR6[q]}function hm8(q){let K=RR6[q];if(!K)return;if(K.options)return[...K.options];if(K.getOptions)return K.getOptions();return}function MJK(q){return RR6[q]?.path??q.split(".")}var RR6;var re1=y(()=>{V1();iV1();I88();Rm8();Tu();RR6={theme:{source:"global",type:"string",description:"Color theme for the UI",options:jL1},editorMode:{source:"global",type:"string",description:"Key binding mode",options:kf8},verbose:{source:"global",type:"boolean",description:"Show detailed debug output",appStateKey:"verbose"},preferredNotifChannel:{source:"global",type:"string",description:"Preferred notification channel",options:vf8},autoCompactEnabled:{source:"global",type:"boolean",description:"Auto-compact when context is full"},autoMemoryEnabled:{source:"settings",type:"boolean",description:"Enable auto-memory"},autoDreamEnabled:{source:"settings",type:"boolean",description:"Enable background memory consolidation"},fileCheckpointingEnabled:{source:"global",type:"boolean",description:"Enable file checkpointing for code rewind"},showTurnDuration:{source:"global",type:"boolean",description:'Show turn duration message after responses (e.g., "Cooked for 1m 6s")'},terminalProgressBarEnabled:{source:"global",type:"boolean",description:"Show OSC 9;4 progress indicator in supported terminals"},todoFeatureEnabled:{source:"global",type:"boolean",description:"Enable todo/task tracking"},model:{source:"settings",type:"string",description:"Override the default model",appStateKey:"mainLoopModel",getOptions:()=>{try{return BK6().filter((q)=>q.value!==null).map((q)=>q.value)}catch{return["sonnet","opus","haiku"]}},validateOnWrite:(q)=>LR6(String(q)),formatOnRead:(q)=>q===null?"default":q},alwaysThinkingEnabled:{source:"settings",type:"boolean",description:"Enable extended thinking (false to disable)",appStateKey:"thinkingEnabled"},"permissions.defaultMode":{source:"settings",type:"string",description:"Default permission mode for tool usage",options:["default","plan","acceptEdits","dontAsk","auto"]},language:{source:"settings",type:"string",description:'Preferred language for Claude responses and voice dictation (e.g., "japanese", "spanish")'},teammateMode:{source:"global",type:"string",description:'How to spawn teammates: "tmux" for traditional tmux, "in-process" for same process, "auto" to choose automatically',options:Irq},...{},...{voiceEnabled:{source:"settings",type:"boolean",description:"Enable voice dictation (hold-to-talk)"}},...{remoteControlAtStartup:{source:"global",type:"boolean",description:"Enable Remote Control for all sessions (true | false | default)",formatOnRead:()=>$F()}},...{}}});function PJK(){let q=[],K=[];for(let[z,Y]of Object.entries(RR6)){if(z==="model")continue;if(z==="voiceEnabled"&&!gK6())continue;let $=hm8(z),A=`- ${z}`;if($)A+=`: ${$.map((O)=>`"${O}"`).join(", ")}`;else if(Y.type==="boolean")A+=": true/false";if(A+=` - ${Y.description}`,Y.source==="global")q.push(A);else K.push(A)}let _=b7Y();return`Get or set Claude Code configuration settings.
3405
3406 View or change Claude Code settings. Use when the user requests configuration changes, asks about current settings, or when adjusting a setting would benefit them.

Callers 1

LR6Function · 0.85

Calls 2

C7YFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected