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

Function H5Y

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

Source from the content-addressed store, hash-verified

4087- git reset --hard origin/main → "Discard all local changes and match remote main"
4088- curl -s url | jq '.data[]'"Fetch JSON from URL and extract data array elements"`),run_in_background:BX(L.boolean().optional()).describe("Set to true to run this command in the background. Use Read to read the output later."),dangerouslyDisableSandbox:BX(L.boolean().optional()).describe("Set this to true to dangerously override sandbox mode and run commands without sandboxing."),_simulatedSedEdit:L.object({filePath:L.string(),newContent:L.string()}).optional().describe("Internal: pre-computed sed edit result from preview")})),TPK=B6(()=>qp8?GPK().omit({run_in_background:!0,_simulatedSedEdit:!0}):GPK().omit({_simulatedSedEdit:!0})),z5Y=["npm","yarn","pnpm","node","python","python3","go","cargo","make","docker","terraform","webpack","vite","jest","pytest","curl","wget","build","test","serve","watch","dev"];Y5Y=B6(()=>L.object({stdout:L.string().describe("The standard output of the command"),stderr:L.string().describe("The standard error output of the command"),rawOutputPath:L.string().optional().describe("Path to raw output file for large MCP tool outputs"),interrupted:L.boolean().describe("Whether the command was interrupted"),isImage:L.boolean().optional().describe("Flag to indicate if stdout contains image data"),backgroundTaskId:L.string().optional().describe("ID of the background task if command is running in background"),backgroundedByUser:L.boolean().optional().describe("True if the user manually backgrounded the command with Ctrl+B"),assistantAutoBackgrounded:L.boolean().optional().describe("True if assistant-mode auto-backgrounded a long-running blocking command"),dangerouslyDisableSandbox:L.boolean().optional().describe("Flag to indicate if sandbox mode was overridden"),returnCodeInterpretation:L.string().optional().describe("Semantic interpretation for non-error exit codes with special meaning"),noOutputExpected:L.boolean().optional().describe("Whether the command is expected to produce no output on success"),structuredContent:L.array(L.any()).optional().describe("Structured content blocks"),persistedOutputPath:L.string().optional().describe("Path to the persisted full output in tool-results dir (set when output is too large for inline)"),persistedOutputSize:L.number().optional().describe("Total size of the output in bytes (set when output is too large for inline)")}));R4=sq({name:_q,searchHint:"execute shell commands",maxResultSizeChars:30000,strict:!0,async description({description:q}){return q||"Run shell command"},async prompt(){return WPK()},isConcurrencySafe(q){return this.isReadOnly?.(q)??!1},isReadOnly(q){let K=ko6(q.command);return hN8(q,K).behavior==="allow"},toAutoClassifierInput(q){return q.command},async preparePermissionMatcher({command:q}){let K=await eV4(q);if(K.kind!=="simple")return()=>!0;let _=K.commands.map((z)=>z.argv.join(" "));return(z)=>{let Y=kPK(z);return _.some(($)=>{if(Y!==null)return $===Y||$.startsWith(`${Y} `);return s88(z,$)})}},isSearchOrReadCommand(q){let K=TPK().safeParse(q);if(!K.success)return{isSearch:!1,isRead:!1,isList:!1};return q5Y(K.data.command)},get inputSchema(){return TPK()},get outputSchema(){return Y5Y()},userFacingName(q){if(!q)return"Bash";if(q.command){let K=VL6(q.command);if(K)return Tu8({file_path:K.filePath,old_string:"x"})}return i6(process.env.CLAUDE_CODE_BASH_SANDBOX_SHOW_INDICATOR)&&Gb(q)?"SandboxedBash":"Bash"},getToolUseSummary(q){if(!q?.command)return null;let{command:K,description:_}=q;if(_)return _;return d5(K,PN)},getActivityDescription(q){if(!q?.command)return"Running command";return`Running ${q.description??d5(q.command,PN)}`},async validateInput(q){return{result:!0}},async checkPermissions(q,K){return l67(q,K)},renderToolUseMessage:LzK,renderToolUseProgressMessage:RzK,renderToolUseQueuedMessage:hzK,renderToolResultMessage:SzK,extractSearchText({stdout:q,stderr:K}){return K?`${q}
4089${K}`:q},mapToolResultToToolResultBlockParam({interrupted:q,stdout:K,stderr:_,isImage:z,backgroundTaskId:Y,backgroundedByUser:$,assistantAutoBackgrounded:A,structuredContent:O,persistedOutputPath:w,persistedOutputSize:j},H){if(O&&O.length>0)return{tool_use_id:H,type:"tool_result",content:O};if(z){let P=TI8(K,H);if(P)return P}let J=K;if(K)J=K.replace(/^(\s*\n)+/,""),J=J.trimEnd();if(w){let P=Xa6(J,WN6);J=DN6({filepath:w,originalSize:j??0,isJson:!1,preview:P.preview,hasMore:P.hasMore})}let M=_.trim();if(q){if(_)M+=fPK;M+="<error>Command was aborted before completion</error>"}let X="";if(Y){let P=sz(Y);if(A)X=`Command exceeded the assistant-mode blocking budget (${oKY/1000}s) and was moved to the background with ID: ${Y}. It is still running — you will be notified when it completes. Output is being written to: ${P}. In assistant mode, delegate long-running work to a subagent or use run_in_background to keep this conversation responsive.`;else if($)X=`Command was manually backgrounded by user with ID: ${Y}. Output is being written to: ${P}`;else X=`Command running in background with ID: ${Y}. Output is being written to: ${P}`}return{tool_use_id:H,type:"tool_result",content:[J,M,X].filter(Boolean).join(`
4090`),is_error:q}},async call(q,K,_,z,Y){if(q._simulatedSedEdit)return A5Y(q._simulatedSedEdit,K,z);let{abortController:$,getAppState:A,setAppState:O,setToolJSX:w}=K,j=new kp6,H="",J,M=0,X=!1,P,W=!K.agentId,D=!W;try{let B=O5Y({input:q,abortController:$,setAppState:K.setAppStateForTasks??O,setToolJSX:w,preventCwdChanges:D,isMainThread:W,toolUseId:K.toolUseId,agentId:K.agentId}),p;do if(p=await B.next(),!p.done&&Y){let F=p.value;Y({toolUseID:`bash-progress-${M++}`,data:{type:"bash_progress",output:F.output,fullOutput:F.fullOutput,elapsedTimeSeconds:F.elapsedTimeSeconds,totalLines:F.totalLines,totalBytes:F.totalBytes,taskId:F.taskId,timeoutMs:F.timeoutMs}})}while(!p.done);P=p.value,yI8(q.command,P.code,P.stdout);let C=P.interrupted&&$.signal.reason==="interrupt";if(j.append((P.stdout||"").trimEnd()+fPK),J=nXK(q.command,P.code,P.stdout||"",""),P.stdout&&P.stdout.includes(".git/index.lock': File exists"))d("tengu_git_index_lock_error",{});if(J.isError&&!C){if(P.code!==0)j.append(`Exit code ${P.code}`)}if(!D){let F=A();if(VI8(F.toolPermissionContext))H=kI8("")}let g=M7.annotateStderrWithSandboxFailures(q.command,P.stdout||"");if(P.preSpawnError)throw Error(P.preSpawnError);if(J.isError&&!C)throw new AE("",g,P.code,P.interrupted);X=P.interrupted}finally{if(w)w(null)}let f=j.toString(),G=67108864,Z,T;if(P.outputFilePath&&P.outputTaskId)try{let B=await nKY(P.outputFilePath);T=B.size,await Cw6();let p=Ma6(P.outputTaskId,!1);if(B.size>G)await iKY(P.outputFilePath,G);try{await rKY(P.outputFilePath,p)}catch{await lKY(P.outputFilePath,p)}Z=p}catch{}let v=q.command.split(" ")[0];d("tengu_bash_tool_command_executed",{command_type:v,stdout_length:f.length,stderr_length:0,exit_code:P.code,interrupted:X});let V=jh4(q.command);if(V)d("tengu_code_indexing_tool_used",{tool:V,source:"cli",success:P.code===0});let E=GI8(f),S=C68(E,q.command);if(E=S.stripped,W&&S.hints.length>0)for(let B of S.hints)x68(B);let R=U68(E),x=E;if(R){let B=await vI8(E,P.outputFilePath,T);if(B)x=B;else R=!1}return{data:{stdout:x,stderr:H,interrupted:X,isImage:R,returnCodeInterpretation:J?.message,noOutputExpected:K5Y(q.command),backgroundTaskId:P.backgroundTaskId,backgroundedByUser:P.backgroundedByUser,assistantAutoBackgrounded:P.assistantAutoBackgrounded,dangerouslyDisableSandbox:"dangerouslyDisableSandbox"in q?q.dangerouslyDisableSandbox:void 0,persistedOutputPath:Z,persistedOutputSize:T}}},renderToolUseErrorMessage:CzK,isResultTruncated(q){return UC(q.stdout)||UC(q.stderr)}})});async function w5Y(q,K,_,z){if(K.filter((H)=>{let J=H.trim();return z.isNormalizedCdCommand(J)}).length>1){let H={type:"other",reason:"Multiple directory changes in one command require approval for clarity"};return{behavior:"ask",decisionReason:H,message:f_(R4.name,H)}}{let H=!1,J=!1;for(let M of K){let X=F2(M);for(let P of X){let W=P.trim();if(z.isNormalizedCdCommand(W))H=!0;if(z.isNormalizedGitCommand(W))J=!0}}if(H&&J){let M={type:"other",reason:"Compound commands with cd and git require approval to prevent bare repository attacks"};return{behavior:"ask",decisionReason:M,message:f_(R4.name,M)}}}let $=new Map;for(let H of K){let J=H.trim();if(!J)continue;let M=await _({...q,command:J});$.set(J,M)}let A=Array.from($.entries()).find(([,H])=>H.behavior==="deny");if(A){let[H,J]=A;return{behavior:"deny",message:J.behavior==="deny"?J.message:`Permission denied for: ${H}`,decisionReason:{type:"subcommandResults",reasons:$}}}if(Array.from($.values()).every((H)=>H.behavior==="allow"))return{behavior:"allow",updatedInput:q,decisionReason:{type:"subcommandResults",reasons:$}};let w=[];for(let[,H]of $)if(H.behavior!=="allow"&&"suggestions"in H&&H.suggestions)w.push(...H.suggestions);let j={type:"subcommandResults",reasons:$};return{behavior:"ask",message:f_(R4.name,j),decisionReason:j,suggestions:w.length>0?w:void 0}}async function j5Y(q){if(!q.includes(">"))return q;return(await Aw6.parse(q))?.withoutOutputRedirections()??q}async function VPK(q,K,_,z){let Y=z&&z!==eO6?nm1(q.command,z):await Aw6.parse(q.command);if(!Y)return{behavior:"passthrough",message:"Failed to parse command"};return H5Y(q,K,_,Y)}async function H5Y(q,K,_,z){let Y=z.getTreeSitterAnalysis();if(Y?Y.compoundStructure.hasSubshell||Y.compoundStructure.hasCommandGroup:yPK(q.command)){let w=await yN8(q.command),j={type:"other",reason:w.behavior==="ask"&&w.message?w.message:"This command uses shell operators that require approval for safety"};return{behavior:"ask",message:f_(R4.name,j),decisionReason:j}}let A=z.getPipeSegments();if(A.length<=1)return{behavior:"passthrough",message:"No pipes found in command"};let O=await Promise.all(A.map((w)=>j5Y(w)));return w5Y(q,O,K,_)}var NPK=y(()=>{SG();im1();qw6();Fj();p0();EN8()});function M5Y(q){return J5Y.includes(q)}function X5Y(q,K){let _=q.trim(),[z]=_.split(/\s+/);if(!z)return{behavior:"passthrough",message:"Base command not found"};if(K.mode==="acceptEdits"&&M5Y(z))return{behavior:"allow",updatedInput:{command:q},decisionReason:{type:"mode",mode:"acceptEdits"}};return{behavior:"passthrough",message:`No mode-specific handling for '${z}' in ${K.mode} mode`}}function EPK(q,K){if(K.mode==="bypassPermissions")return{behavior:"passthrough",message:"Bypass mode is handled in main permission flow"};if(K.mode==="dontAsk")return{behavior:"passthrough",message:"DontAsk mode is handled in main permission flow"};let _=F2(q.command);for(let z of _){let Y=X5Y(z,K);if(Y.behavior!=="passthrough")return Y}return{behavior:"passthrough",message:"No mode-specific validation required"}}var J5Y;var LPK=y(()=>{SG();J5Y=["mkdir","touch","rm","rmdir","mv","cp","sed"]});function hPK(q,K,_,z){return}function Kp8(q){let K=q.trim().split(/\s+/).filter(Boolean);if(K.length===0)return null;let _=0;while(_<K.length&&o67.test(K[_])){let $=K[_].split("=")[0],A=!1;if(!_p8.has($))return null;_++}let z=K.slice(_);if(z.length<2)return null;let Y=z[1];if(!/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(Y))return null;return z.slice(0,2).join(" ")}function CPK(q){let K=q.trim().split(/\s+/).filter(Boolean),_=0;while(_<K.length&&o67.test(K[_])){let Y=K[_].split("=")[0],$=!1;if(!_p8.has(Y))return null;_++}let z=K[_];if(!z)return null;if(!/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(z))return null;if(W5Y.has(z))return null;return z}function lR6(q){let K=D5Y(q);if(K)return Jo6(R4.name,K);if(q.includes(`
4091`)){let z=q.split(`
4092`)[0].trim();if(z)return Jo6(R4.name,z)}let _=Kp8(q);if(_)return Jo6(R4.name,_);return DN8(R4.name,q)}function D5Y(q){if(!q.includes("<<"))return null;let K=q.indexOf("<<");if(K<=0)return null;let _=q.substring(0,K).trim();if(!_)return null;let z=Kp8(_);if(z)return z;let Y=_.split(/\s+/).filter(Boolean),$=0;while($<Y.length&&o67.test(Y[$])){let A=Y[$].split("=")[0],O=!1;if(!_p8.has(A))return null;$++}if($>=Y.length)return null;return Y.slice($,$+2).join(" ")||null}function bPK(q){return Jo6(R4.name,q)}function s88(q,K){return lv(q,K)}function i67(q){let _=q.split(`

Callers 1

VPKFunction · 0.85

Calls 7

yPKFunction · 0.85
yN8Function · 0.85
f_Function · 0.85
j5YFunction · 0.85
w5YFunction · 0.85
getTreeSitterAnalysisMethod · 0.65
getPipeSegmentsMethod · 0.65

Tested by

no test coverage detected