MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / FHK

Function FHK

package/cli.js:3346–3373  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33445. Design a concrete implementation strategy
33456. When ready, use ExitPlanMode to present your plan for approval
3346
3347Remember: DO NOT write or edit any files yet. This is a read-only exploration and planning phase.`,tool_use_id:K}}})});function Yp(q,K){return{name:q,compute:K,cacheBreak:!1}}function BHK(q,K,_){return{name:q,compute:K,cacheBreak:!0}}async function gHK(q){let K=ni8();return Promise.all(q.map(async(_)=>{if(!_.cacheBreak&&K.has(_.name))return K.get(_.name)??null;let z=await _.compute();return ii8(_.name,z),z}))}function La(){ri8(),Or8()}var kR6=y(()=>{v8()});function FHK(){return`Use this tool ONLY when the user explicitly asks to work in a worktree. This tool creates an isolated git worktree and switches the current session into it.
3348
3349## When to Use
3350
3351- The user explicitly says "worktree" (e.g., "start a worktree", "work in a worktree", "create a worktree", "use a worktree")
3352
3353## When NOT to Use
3354
3355- The user asks to create a branch, switch branches, or work on a different branch — use git commands instead
3356- The user asks to fix a bug or work on a feature — use normal git workflow unless they specifically mention worktrees
3357- Never use this tool unless the user explicitly mentions "worktree"
3358
3359## Requirements
3360
3361- Must be in a git repository, OR have WorktreeCreate/WorktreeRemove hooks configured in settings.json
3362- Must not already be in a worktree
3363
3364## Behavior
3365
3366- In a git repository: creates a new git worktree inside \`.claude/worktrees/\` with a new branch based on HEAD
3367- Outside a git repository: delegates to WorktreeCreate/WorktreeRemove hooks for VCS-agnostic isolation
3368- Switches the session's working directory to the new worktree
3369- Use ExitWorktree to leave the worktree mid-session (keep or remove). On session exit, if still in the worktree, the user will be prompted to keep or remove it
3370
3371## Parameters
3372
3373- \`name\` (optional): A name for the worktree. If not provided, a random name is generated.
3374`}function UHK(){return"Creating worktree…"}function QHK(q,K,_){return Ra.createElement(u,{flexDirection:"column"},Ra.createElement(k,null,"Switched to worktree on branch ",Ra.createElement(k,{bold:!0},q.worktreeBranch)),Ra.createElement(k,{dimColor:!0},q.worktreePath))}var Ra;var dHK=y(()=>{s6();Ra=O6(D6(),1)});var P7Y,W7Y,cHK;var lHK=y(()=>{x7();v8();kR6();k8();Bq();wM();I7();E5();SJ();tN();_K();d0();dHK();P7Y=B6(()=>L.strictObject({name:L.string().superRefine((q,K)=>{try{VR6(q)}catch(_){K.addIssue({code:"custom",message:_.message})}}).optional().describe('Optional name for the worktree. Each "/"-separated segment may contain only letters, digits, dots, underscores, and dashes; max 64 chars total. A random name is generated if not provided.')})),W7Y=B6(()=>L.object({worktreePath:L.string(),worktreeBranch:L.string().optional(),message:L.string()})),cHK=sq({name:cN8,searchHint:"create an isolated git worktree and switch into it",maxResultSizeChars:1e5,async description(){return"Creates an isolated worktree (via git or configured hooks) and switches the session into it"},async prompt(){return FHK()},get inputSchema(){return P7Y()},get outputSchema(){return W7Y()},userFacingName(){return"Creating worktree"},shouldDefer:!0,toAutoClassifierInput(q){return q.name??""},renderToolUseMessage:UHK,renderToolResultMessage:QHK,async call(q){if(n2())throw Error("Already in a worktree session");let K=jH(Z8());if(K&&K!==Z8())process.chdir(K),QO(K);let _=q.name??CQ(),z=await b88(N8(),_);process.chdir(z.worktreePath),QO(z.worktreePath),aR(Z8()),Oy(z),La(),wN(),hA.cache.clear?.(),d("tengu_worktree_created",{mid_session:!0});let Y=z.worktreeBranch?` on branch ${z.worktreeBranch}`:"";return{data:{worktreePath:z.worktreePath,worktreeBranch:z.worktreeBranch,message:`Created worktree at ${z.worktreePath}${Y}. The session is now working in the worktree. Use ExitWorktree to leave mid-session, or exit the session to be prompted.`}}},mapToolResultToToolResultBlockParam({message:q},K){return{type:"tool_result",content:q,tool_use_id:K}}})});function nHK(){return`Exit a worktree session created by EnterWorktree and return the session to the original working directory.
3375
3376## Scope

Callers 1

promptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected