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

Function A5Y

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

Source from the content-addressed store, hash-verified

4073- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments`}function cR6(q){if(!q||q.length===0)return q;return[...new Set(q)]}function dKY(){if(!M7.isSandboxingEnabled())return"";let q=M7.getFsReadConfig(),K=M7.getFsWriteConfig(),_=M7.getNetworkRestrictionConfig(),z=M7.getAllowUnixSockets(),Y=M7.getIgnoreViolations(),$=M7.areUnsandboxedCommandsAllowed(),A=AC(),O=(X)=>[...new Set(X)].map((P)=>P===A?"$TMPDIR":P),w={read:{denyOnly:cR6(q.denyOnly),...q.allowWithinDeny&&{allowWithinDeny:cR6(q.allowWithinDeny)}},write:{allowOnly:O(K.allowOnly),denyWithinAllow:cR6(K.denyWithinAllow)}},j={..._?.allowedHosts&&{allowedHosts:cR6(_.allowedHosts)},..._?.deniedHosts&&{deniedHosts:cR6(_.deniedHosts)},...z&&{allowUnixSockets:cR6(z)}},H=[];if(Object.keys(w).length>0)H.push(`Filesystem: ${g6(w)}`);if(Object.keys(j).length>0)H.push(`Network: ${g6(j)}`);if(Y)H.push(`Ignored violations: ${g6(Y)}`);let M=[...$?["You should always default to running commands within the sandbox. Do NOT attempt to set `dangerouslyDisableSandbox: true` unless:",["The user *explicitly* asks you to bypass sandbox","A specific command just failed and you see evidence of sandbox restrictions causing the failure. Note that commands can fail for many reasons unrelated to the sandbox (missing files, wrong arguments, network issues, etc.)."],"Evidence of sandbox-caused failures includes:",['"Operation not permitted" errors for file/network operations',"Access denied to specific paths outside allowed directories","Network connection failures to non-whitelisted hosts","Unix socket connection errors"],"When you see evidence of sandbox-caused failure:",["Immediately retry with `dangerouslyDisableSandbox: true` (don't ask, just do it)","Briefly explain what sandbox restriction likely caused the failure. Be sure to mention that the user can use the `/sandbox` command to manage restrictions.","This will prompt the user for permission"],"Treat each command you execute with `dangerouslyDisableSandbox: true` individually. Even if you have recently run a command with this setting, you should default to running future commands within the sandbox.","Do not suggest adding sensitive paths like ~/.bashrc, ~/.zshrc, ~/.ssh/*, or credential files to the sandbox allowlist."]:["All commands MUST run in sandbox mode - the `dangerouslyDisableSandbox` parameter is disabled by policy.","Commands cannot run outside the sandbox under any circumstances.","If a command fails due to sandbox restrictions, work with the user to adjust sandbox settings instead."],"For temporary files, always use the `$TMPDIR` environment variable. TMPDIR is automatically set to the correct sandbox-writable directory in sandbox mode. Do NOT use `/tmp` directly - use `$TMPDIR` instead."];return["","## Command sandbox","By default, your command will be run in a sandbox. This sandbox controls which directories and network hosts commands may access or modify without an explicit override.","","The sandbox has the following restrictions:",H.join(`
4074`),"",...wp(M)].join(`
4075`)}function WPK(){let q=Nj(),K=[...q?[]:[`File search: Use ${i9} (NOT find or ls)`,`Content search: Use ${n3} (NOT grep or rg)`],`Read files: Use ${Cq} (NOT cat/head/tail)`,`Edit files: Use ${X4} (NOT sed/awk)`,`Write files: Use ${tK} (NOT echo >/cat <<EOF)`,"Communication: Output text directly (NOT echo/printf)"],_=q?"`cat`, `head`, `tail`, `sed`, `awk`, or `echo`":"`find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo`",z=[`If the commands are independent and can run in parallel, make multiple ${_q} tool calls in a single message. Example: if you need to run "git status" and "git diff", send a single message with two ${_q} tool calls in parallel.`,`If the commands depend on each other and must run sequentially, use a single ${_q} call with '&&' to chain them together.`,"Use ';' only when you need to run commands sequentially but don't care if earlier commands fail.","DO NOT use newlines to separate commands (newlines are ok in quoted strings)."],Y=["Prefer to create a new commit rather than amending an existing commit.","Before running destructive operations (e.g., git reset --hard, git push --force, git checkout --), consider whether there is a safer alternative that achieves the same goal. Only use destructive operations when they are truly the best approach.","Never skip hooks (--no-verify) or bypass signing (--no-gpg-sign, -c commit.gpgsign=false) unless the user has explicitly asked for it. If a hook fails, investigate and fix the underlying issue."],$=["Do not sleep between commands that can run immediately — just run them.","If your command is long running and you would like to be notified when it finishes — use `run_in_background`. No sleep needed.","Do not retry failing commands in a sleep loop — diagnose the root cause.","If waiting for a background task you started with `run_in_background`, you will be notified when it completes — do not poll.","If you must poll an external process, use a check command (e.g. `gh run view`) rather than sleeping first.","If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user."],A=QKY(),O=["If your command will create new directories or files, first use this tool to run `ls` to verify the parent directory exists and is the correct location.",'Always quote file paths that contain spaces with double quotes in your command (e.g., cd "path with spaces/file.txt")',"Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of `cd`. You may use `cd` if the User explicitly requests it.",`You may specify an optional timeout in milliseconds (up to ${em8()}ms / ${em8()/60000} minutes). By default, your command will timeout after ${tm8()}ms (${tm8()/60000} minutes).`,...A!==null?[A]:[],"When issuing multiple commands:",z,"For git commands:",Y,"Avoid unnecessary `sleep` commands:",$,...q?["When using `find -regex` with alternation, put the longest alternative first. Example: use `'.*\\.\\(tsx\\|ts\\)'` not `'.*\\.\\(ts\\|tsx\\)'` — the second form silently skips `.tsx` files."]:[]];return["Executes a given bash command and returns its output.","","The working directory persists between commands, but shell state does not. The shell environment is initialized from the user's profile (bash or zsh).","",`IMPORTANT: Avoid using this tool to run ${_} commands, unless explicitly instructed or after you have verified that a dedicated tool cannot accomplish your task. Instead, use the appropriate dedicated tool as this will provide a much better experience for the user:`,"",...wp(K),`While the ${_q} tool can do similar things, it’s better to use the built-in tools as they provide a better user experience and make it easier to review tool calls and give permission.`,"","# Instructions",...wp(O),dKY(),...PPK()?["",PPK()]:[]].join(`
4076`)}var DPK=y(()=>{rL();sm8();ju();m8();JI1();Tz();K$();l8();jH6();Z$();IY();E2();qM();q68()});import{copyFile as lKY,stat as nKY,truncate as iKY,link as rKY}from"fs/promises";function q5Y(q){let K;try{K=LV6(q)}catch{return{isSearch:!1,isRead:!1,isList:!1}}if(K.length===0)return{isSearch:!1,isRead:!1,isList:!1};let _=!1,z=!1,Y=!1,$=!1,A=!1;for(let O of K){if(A){A=!1;continue}if(O===">"||O===">>"||O===">&"){A=!0;continue}if(O==="||"||O==="&&"||O==="|"||O===";")continue;let w=O.trim().split(/\s+/)[0];if(!w)continue;if(vPK.has(w))continue;$=!0;let j=aKY.has(w),H=sKY.has(w),J=tKY.has(w);if(!j&&!H&&!J)return{isSearch:!1,isRead:!1,isList:!1};if(j)_=!0;if(H)z=!0;if(J)Y=!0}if(!$)return{isSearch:!1,isRead:!1,isList:!1};return{isSearch:_,isRead:z,isList:Y}}function K5Y(q){let K;try{K=LV6(q)}catch{return!1}if(K.length===0)return!1;let _=!1,z=null,Y=!1;for(let $ of K){if(Y){Y=!1;continue}if($===">"||$===">>"||$===">&"){Y=!0;continue}if($==="||"||$==="&&"||$==="|"||$===";"){z=$;continue}let A=$.trim().split(/\s+/)[0];if(!A)continue;if(z==="||"&&vPK.has(A))continue;if(_=!0,!eKY.has(A))return!1}return _}function d67(q){let K=F2(q);if(K.length===0)return"other";for(let _ of K){let z=_.split(" ")[0]||"";if(z5Y.includes(z))return z}return"other"}function $5Y(q){let K=F2(q);if(K.length===0)return!0;let _=K[0]?.trim();if(!_)return!0;return!_5Y.includes(_)}async function A5Y(q,K,_){let{filePath:z,newContent:Y}=q,$=lq(z),A=X8(),O=b$8($),w;try{w=await A.readFile($,{encoding:O})}catch(H){if(_7(H))return{data:{stdout:"",stderr:`sed: ${z}: No such file or directory
4077Exit code 1`,interrupted:!1}};throw H}if(e$()&&_)await OK6(K.updateFileHistoryState,$,_.uuid);let j=TR7($);return me($,Y,O,j),Mq6($,w,Y),K.readFileState.set($,{content:Y,timestamp:ik($),offset:void 0,limit:void 0}),{data:{stdout:"",stderr:"",interrupted:!1}}}async function*O5Y({input:q,abortController:K,setAppState:_,setToolJSX:z,preventCwdChanges:Y,isMainThread:$,toolUseId:A,agentId:O}){let{command:w,description:j,timeout:H,run_in_background:J}=q,M=H||tm8(),X="",P="",W=0,D=0,f=void 0,G=!1,Z=null;function T(){return new Promise((B)=>{Z=()=>B(null)})}let v=!qp8&&$5Y(w),V=await TL6(w,K.signal,"bash",{timeout:M,onProgress(B,p,C,g,F){P=B,X=p,W=C,D=F?g:0;let U=Z;if(U)Z=null,U()},preventCwdChanges:Y,shouldUseSandbox:Gb(q),shouldAutoBackground:v}),E=V.result;async function S(){return(await QI8({command:w,description:j||w,shellCommand:V,toolUseId:A,agentId:O},{abortController:K,getAppState:()=>{throw Error("getAppState not available in runShellCommand context")},setAppState:_})).taskId}function R(B,p){if(I){if(!cI8(I,V,j||w,_,A))return;f=I,d(B,{command_type:d67(w)}),p?.(I);return}S().then((C)=>{f=C;let g=Z;if(g)Z=null,g();if(d(B,{command_type:d67(w)}),p)p(C)})}if(V.onTimeout&&v)V.onTimeout((B)=>{R("tengu_bash_command_timeout_backgrounded",B)});if(J===!0&&!qp8){let B=await S();return d("tengu_bash_command_explicitly_backgrounded",{command_type:d67(w)}),{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:B}}let x=Date.now(),I=void 0;{let B=await Promise.race([E,new Promise((p)=>{setTimeout((g)=>g(null),ZPK,p).unref()})]);if(B!==null)return V.cleanup(),B;if(f)return{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:f,assistantAutoBackgrounded:G}}JO.startPolling(V.taskOutput.taskId);try{while(!0){let B=T(),p=await Promise.race([E,B]);if(p!==null){if(p.backgroundTaskId!==void 0){lI8(p.backgroundTaskId,_);let F={...p,backgroundTaskId:void 0},{taskOutput:U}=V;if(U.stdoutToFile&&!U.outputFileRedundant)F.outputFilePath=U.path,F.outputFileSize=U.outputFileSize,F.outputTaskId=U.taskId;return V.cleanup(),F}if(I)nI8(I,_);return V.cleanup(),p}if(f)return{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:f,assistantAutoBackgrounded:G};if(I){if(V.status==="backgrounded")return{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:I,backgroundedByUser:!0}}let C=Date.now()-x,g=Math.floor(C/1000);if(!qp8&&f===void 0&&g>=ZPK/1000&&z){if(!I)I=dI8({command:w,description:j||w,shellCommand:V,agentId:O},_,A);z({jsx:c67.createElement(NL6,null),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})}yield{type:"progress",fullOutput:X,output:P,elapsedTimeSeconds:g,totalLines:W,totalBytes:D,taskId:V.taskOutput.taskId,...H?{timeoutMs:M}:void 0}}}finally{JO.stopPolling(V.taskOutput.taskId)}}var c67,fPK=`
4078`,ZPK=2000,oKY=15000,aKY,sKY,tKY,vPK,eKY,_5Y,qp8,GPK,TPK,z5Y,Y5Y,R4;var p0=y(()=>{x7();v8();k8();VV6();Bq();vK6();Rm1();SG();b68();QB1();m8();y8();bK();oN();U7();e7();dz();wI8();tN();K$();TK6();B68();Ij();ZL6();kw6();IG();hs1();Q68();DN();iXK();DPK();am1();g68();IL6();fI8();NI8();c67=O6(D6(),1),aKY=new Set(["find","grep","rg","ag","ack","locate","which","whereis"]),sKY=new Set(["cat","head","tail","less","more","wc","stat","file","strings","jq","awk","cut","sort","uniq","tr"]),tKY=new Set(["ls","tree","du"]),vPK=new Set(["echo","printf","true","false",":"]),eKY=new Set(["mv","cp","rm","mkdir","rmdir","chmod","chown","chgrp","touch","ln","cd","export","unset","wait"]);_5Y=["sleep"],qp8=i6(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS),GPK=B6(()=>L.strictObject({command:L.string().describe("The command to execute"),timeout:eN(L.number().optional()).describe(`Optional timeout in milliseconds (max ${em8()})`),description:L.string().optional().describe(`Clear, concise description of what this command does in active voice. Never use words like "complex" or "risk" in the description - just describe what it does.
4079

Callers 1

callFunction · 0.85

Calls 12

lqFunction · 0.85
X8Function · 0.85
b$8Function · 0.85
_7Function · 0.85
e$Function · 0.85
OK6Function · 0.85
TR7Function · 0.85
meFunction · 0.85
Mq6Function · 0.85
ikFunction · 0.85
readFileMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected