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

Function XN1

package/cli.js:510–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

508
509`);else process.stderr.write(`
510`)}return K()}}function ww(){let q=Sf8(),K=j8();if(!K.projects)return hc6;let _=K.projects[q]??hc6;if(typeof _.allowedTools==="string")_.allowedTools=m5(_.allowedTools)??[];return _}function jw(q){let K=Sf8(),_=null;try{if(irq(XP(),Wi,(Y)=>{let $=Y.projects?.[K]??hc6,A=q($);if(A===$)return Y;return _={...Y,projects:{...Y.projects,[K]:A}},_})&&_)Lf8(_)}catch(z){N(`Failed to save config with lock: ${z}`,{level:"error"});let Y=Q$6(XP(),Wi);if(hf8(Y)){N("saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.",{level:"error"}),d("tengu_config_auth_loss_prevented",{});return}let $=Y.projects?.[K]??hc6,A=q($);if(A===$)return;_={...Y,projects:{...Y.projects,[K]:A}},nrq(XP(),_,Rf8),Lf8(_)}}function AF(){return c$6()!==null}function aG6(){return AF()&&!i6(process.env.FORCE_AUTOUPDATE_PLUGINS)}function Cc6(q){switch(q.type){case"development":return"development build";case"env":return`${q.envVar} set`;case"config":return"config"}}function c$6(){if(i6(process.env.DISABLE_AUTOUPDATER))return{type:"env",envVar:"DISABLE_AUTOUPDATER"};let q=fL7();if(q)return{type:"env",envVar:q};let K=j8();if(K.autoUpdates===!1&&(K.installMethod!=="native"||K.autoUpdatesProtectedForNative!==!0))return{type:"config"};return null}function CS(){let q=j8();if(q.userID)return q.userID;let K=vH_(32).toString("hex");return b8((_)=>({..._,userID:K})),K}function $N1(){if(!j8().firstStartTime){let K=new Date().toISOString();b8((_)=>({..._,firstStartTime:_.firstStartTime??K}))}}function l$6(q){let K=r1();switch(q){case"User":return $L(c1(),"CLAUDE.md");case"Local":return $L(K,"CLAUDE.local.md");case"Project":return $L(K,"CLAUDE.md");case"Managed":return $L(MP(),"CLAUDE.md");case"AutoMem":return Tf8()}return NH_.getTeamMemEntrypoint()}function Cf8(){return $L(MP(),".claude","rules")}function bf8(){return $L(c1(),"rules")}function pH_(q){YF.config=q,YF.mtime=q?Date.now():0}var NH_,sV1=!1,hc6,Rf8,drq,crq,lrq=!1,NNA,yNA,YF,Z16=null,Rc6=0,yf8=0,zN1=0,CH_=20,xH_=1000,tV1=!1,qN1=!1,Sf8,uH_,mH_;var V1=y(()=>{F4();c71();v8();rw();k8();I7();c9();_8();oY();y_();m8();y8();bK();e7();E5();vO();E8();dz();qI();l8();iV1();NH_=(YL(),Eq(Pi)),hc6={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasClaudeMdExternalIncludesApproved:!1,hasClaudeMdExternalIncludesWarningShown:!1};Rf8=Wi(),drq=["apiKeyHelper","installMethod","autoUpdates","autoUpdatesProtectedForNative","theme","verbose","preferredNotifChannel","shiftEnterKeyBindingInstalled","editorMode","hasUsedBackslashReturn","autoCompactEnabled","showTurnDuration","diffTool","env","tipsHistory","todoFeatureEnabled","showExpandedTodos","messageIdleNotifThresholdMs","autoConnectIde","autoInstallIdeExtension","fileCheckpointingEnabled","terminalProgressBarEnabled","showStatusInTerminalTab","taskCompleteNotifEnabled","inputNeededNotifEnabled","agentPushNotifEnabled","respectGitignore","claudeInChromeDefaultEnabled","hasCompletedClaudeInChromeOnboarding","lspRecommendationDisabled","lspRecommendationNeverPlugins","lspRecommendationIgnoredCount","copyFullResponse","copyOnSelect","permissionExplainerEnabled","prStatusFooterEnabled","remoteControlAtStartup","remoteDialogSeen"];crq=["allowedTools","hasTrustDialogAccepted","hasCompletedProjectOnboarding"];NNA={...Rf8,autoUpdates:!1},yNA={...hc6};YF={config:null,mtime:0};pq(async()=>{bH_()});Sf8=_1(()=>{let q=r1(),K=jH(q);if(K)return H_6(K);return H_6(Ef8(q))});uH_=Q$6,mH_=hf8});import{createHash as BH_}from"crypto";function rrq(q){return q.replace(/[A-Z]/g,(K)=>`_${K.toLowerCase()}`)}async function AN1(){if(bc6.length===0)return;let q=bc6;bc6=[];try{await $1.post(gH_,q,{headers:{"Content-Type":"application/json","DD-API-KEY":FH_},timeout:dH_})}catch(K){H6(K)}}function nH_(){if(Di)return;Di=setTimeout(()=>{Di=null,AN1()},aH_()).unref()}async function T16(){if(Di)clearTimeout(Di),Di=null;await AN1()}async function orq(q,K){if(E7()!=="firstParty")return;let _=xf8;if(_===null)_=await iH_();if(!_||!cH_.has(q))return;try{let z=await Mf8({model:K.model,betas:K.betas}),{envContext:Y,...$}=z,A={...$,...Y,...K,userBucket:oH_()};if(typeof A.toolName==="string"&&A.toolName.startsWith("mcp__"))A.toolName="mcp";if(typeof A.model==="string"){let H=bY(A.model.replace(/\[1m]$/i,""));A.model=H in UJ8?H:"other"}if(typeof A.version==="string")A.version=A.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,"$1");if(A.status!==void 0&&A.status!==null){let H=String(A.status);A.http_status=H;let J=H.charAt(0);if(J>="1"&&J<="5")A.http_status_range=`${J}xx`;delete A.status}let O=A,j={ddsource:"nodejs",ddtags:[`event:${q}`,...lH_.filter((H)=>O[H]!==void 0&&O[H]!==null).map((H)=>`${rrq(H)}:${O[H]}`)].join(","),message:q,service:"claude-code",hostname:"claude-code",env:"external"};for(let[H,J]of Object.entries(A))if(J!==void 0&&J!==null)j[rrq(H)]=J;if(bc6.push(j),bc6.length>=QH_){if(Di)clearTimeout(Di),Di=null;AN1()}else nH_()}catch(z){H6(z)}}function aH_(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||"",10)||UH_}var gH_="https://http-intake.logs.us5.datadoghq.com/api/v2/logs",FH_="pubbbf48e6d78dae54bceaa4acf463299bf",UH_=15000,QH_=100,dH_=5000,cH_,lH_,bc6,Di=null,xf8=null,iH_,rH_=30,oH_;var sG6=y(()=>{CK();F4();V1();E8();aq();Az();wn();H16();kj();cH_=new Set(["chrome_bridge_connection_succeeded","chrome_bridge_connection_failed","chrome_bridge_disconnected","chrome_bridge_tool_call_completed","chrome_bridge_tool_call_error","chrome_bridge_tool_call_started","chrome_bridge_tool_call_timeout","tengu_api_error","tengu_api_success","tengu_brief_mode_enabled","tengu_brief_mode_toggled","tengu_brief_send","tengu_cancel","tengu_compact_failed","tengu_exit","tengu_flicker","tengu_init","tengu_model_fallback_triggered","tengu_oauth_error","tengu_oauth_success","tengu_oauth_token_refresh_failure","tengu_oauth_token_refresh_success","tengu_oauth_token_refresh_lock_acquiring","tengu_oauth_token_refresh_lock_acquired","tengu_oauth_token_refresh_starting","tengu_oauth_token_refresh_completed","tengu_oauth_token_refresh_lock_releasing","tengu_oauth_token_refresh_lock_released","tengu_query_error","tengu_session_file_read","tengu_started","tengu_tool_use_error","tengu_tool_use_granted_in_prompt_permanent","tengu_tool_use_granted_in_prompt_temporary","tengu_tool_use_rejected_in_prompt","tengu_tool_use_success","tengu_uncaught_exception","tengu_unhandled_rejection","tengu_voice_recording_started","tengu_voice_toggled","tengu_team_mem_sync_pull","tengu_team_mem_sync_push","tengu_team_mem_sync_started","tengu_team_mem_entries_capped"]),lH_=["arch","clientType","errorType","http_status_range","http_status","kairosActive","model","platform","provider","skillMode","subscriptionType","toolName","userBucket","userType","version","versionBase"];bc6=[];iH_=_1(async()=>{if(j16())return xf8=!1,!1;try{return xf8=!0,!0}catch(q){return H6(q),xf8=!1,!1}});oH_=_1(()=>{let q=CS(),K=BH_("sha256").update(q).digest("hex");return parseInt(K.slice(0,8),16)%rH_})});function sH_(){if(cG6("datadog"))return!1;if(ON1!==void 0)return ON1;try{return tY(arq)}catch{return!1}}function srq(q,K){let _=BV1(q);if(_===0)return;let z=_!==null?{...K,sample_rate:_}:K;if(sH_())orq(q,f38(z));Tc6(q,z)}function tH_(q,K){return srq(q,K),Promise.resolve()}function trq(){ON1=tY(arq)}function tG6(){Cj7({logEvent:srq,logEventAsync:tH_})}var arq="tengu_log_datadog_events",ON1=void 0;var xc6=y(()=>{sG6();Hi();o1();k8();pV1()});function uf8(q){if(E7()==="vertex")return wN1;if(q?.isNonInteractive){if(q.hasAppendSystemPrompt)return erq;return qoq}return wN1}function qJ_(){if(k_(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER))return!1;return g8("tengu_attribution_header",!0)}function mf8(q){if(!qJ_())return"";let K=`${{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://code.claude.com/docs/en/overview",VERSION:"2.1.88",FEEDBACK_CHANNEL:"https://github.com/anthropics/claude-code/issues",BUILD_TIME:"2026-03-30T21:59:52Z"}.VERSION}.${q}`,_=process.env.CLAUDE_CODE_ENTRYPOINT??"unknown",z=" cch=00000;",Y=RD8(),$=Y?` cc_workload=${Y};`:"",A=`x-anthropic-billing-header: cc_version=${K}; cc_entrypoint=${_};${z}${$}`;return N(`attribution header ${A}`),A}var wN1="You are Claude Code, Anthropic's official CLI for Claude.",erq="You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.",qoq="You are a Claude agent, built on Anthropic's Claude Agent SDK.",eH_,If8;var pf8=y(()=>{o1();_8();m8();Az();D$6();eH_=[wN1,erq,qoq],If8=new Set(eH_)});function v16(q){return q.filter((K)=>K.data?.type!=="hook_progress")}function g_(q,K){return q.name===K||(q.aliases?.includes(K)??!1)}function L5(q,K){return q.find((_)=>g_(_,K))}function sq(q){return{...KJ_,userFacingName:()=>q.name,...q}}var MX=()=>({mode:"default",additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1}),KJ_;var Bq=y(()=>{KJ_={isEnabled:()=>!0,isConcurrencySafe:(q)=>!1,isReadOnly:(q)=>!1,isDestructive:(q)=>!1,checkPermissions:(q,K)=>Promise.resolve({behavior:"allow",updatedInput:q}),toAutoClassifierInput:(q)=>"",userFacingName:(q)=>""}});var n$6=m((eNA,Ff8)=>{function zoq(q){return Array.isArray(q)?q:[q]}var _J_=void 0,HN1="",Koq=" ",jN1="\\",zJ_=/^\s+$/,YJ_=/(?:[^\\]|^)\\$/,$J_=/^\\!/,AJ_=/^\\#/,OJ_=/\r?\n/g,wJ_=/^\.{0,2}\/|^\.{1,2}$/,jJ_=/\/$/,eG6="/",Yoq="node-ignore";if(typeof Symbol<"u")Yoq=Symbol.for("node-ignore");var $oq=Yoq,qT6=(q,K,_)=>{return Object.defineProperty(q,K,{value:_}),_},HJ_=/([0-z])-([0-z])/g,Aoq=()=>!1,JJ_=(q)=>q.replace(HJ_,(K,_,z)=>_.charCodeAt(0)<=z.charCodeAt(0)?K:HN1),MJ_=(q)=>{let{length:K}=q;return q.slice(0,K-K%2)},XJ_=[[/^\uFEFF/,()=>HN1],[/((?:\\\\)*?)(\\?\s+)$/,(q,K,_)=>K+(_.indexOf("\\")===0?Koq:HN1)],[/(\\+?)\s/g,(q,K)=>{let{length:_}=K;return K.slice(0,_-_%2)+Koq}],[/[\\$.|*+(){^]/g,(q)=>`\\${q}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(q,K,_)=>K+6<_.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(q,K,_)=>{let z=_.replace(/\\\*/g,"[^\\/]*");return K+z}],[/\\\\\\(?=[$.|*+(){^])/g,()=>jN1],[/\\\\/g,()=>jN1],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(q,K,_,z,Y)=>K===jN1?`\\[${_}${MJ_(z)}${Y}`:Y==="]"?z.length%2===0?`[${JJ_(_)}${z}]`:"[]":"[]"],[/(?:[^*])$/,(q)=>/\/$/.test(q)?`${q}$`:`${q}(?=$|\\/$)`]],PJ_=/(^|\\\/)?\\\*$/,Ic6="regex",Bf8="checkRegex",_oq="_",WJ_={[Ic6](q,K){return`${K?`${K}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Bf8](q,K){return`${K?`${K}[^/]*`:"[^/]*"}(?=$|\\/$)`}},DJ_=(q)=>XJ_.reduce((K,[_,z])=>K.replace(_,z.bind(q)),q),gf8=(q)=>typeof q==="string",fJ_=(q)=>q&&gf8(q)&&!zJ_.test(q)&&!YJ_.test(q)&&q.indexOf("#")!==0,ZJ_=(q)=>q.split(OJ_).filter(Boolean);class Ooq{constructor(q,K,_,z,Y,$){this.pattern=q,this.mark=K,this.negative=Y,qT6(this,"body",_),qT6(this,"ignoreCase",z),qT6(this,"regexPrefix",$)}get regex(){let q=_oq+Ic6;if(this[q])return this[q];return this._make(Ic6,q)}get checkRegex(){let q=_oq+Bf8;if(this[q])return this[q];return this._make(Bf8,q)}_make(q,K){let _=this.regexPrefix.replace(PJ_,WJ_[q]),z=this.ignoreCase?new RegExp(_,"i"):new RegExp(_);return qT6(this,K,z)}}var GJ_=({pattern:q,mark:K},_)=>{let z=!1,Y=q;if(Y.indexOf("!")===0)z=!0,Y=Y.substr(1);Y=Y.replace($J_,"!").replace(AJ_,"#");let $=DJ_(Y);return new Ooq(q,K,Y,_,z,$)};class woq{constructor(q){this._ignoreCase=q,this._rules=[]}_add(q){if(q&&q[$oq]){this._rules=this._rules.concat(q._rules._rules),this._added=!0;return}if(gf8(q))q={pattern:q};if(fJ_(q.pattern)){let K=GJ_(q,this._ignoreCase);this._added=!0,this._rules.push(K)}}add(q){return this._added=!1,zoq(gf8(q)?ZJ_(q):q).forEach(this._add,this),this._added}test(q,K,_){let z=!1,Y=!1,$;this._rules.forEach((O)=>{let{negative:w}=O;if(Y===w&&z!==Y||w&&!z&&!Y&&!K)return;if(!O[_].test(q))return;z=!w,Y=w,$=w?_J_:O});let A={ignored:z,unignored:Y};if($)A.rule=$;return A}}var TJ_=(q,K)=>{throw new K(q)},fi=(q,K,_)=>{if(!gf8(q))return _(`path must be a string, but got \`${K}\``,TypeError);if(!q)return _("path must not be empty",TypeError);if(fi.isNotRelative(q))return _(`path should be a \`path.relative()\`d string, but got "${K}"`,RangeError);return!0},joq=(q)=>wJ_.test(q);fi.isNotRelative=joq;fi.convert=(q)=>q;class Hoq{constructor({ignorecase:q=!0,ignoreCase:K=q,allowRelativePaths:_=!1}={}){qT6(this,$oq,!0),this._rules=new woq(K),this._strictPathCheck=!_,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(q){if(this._rules.add(q))this._initCache();return this}addPattern(q){return this.add(q)}_test(q,K,_,z){let Y=q&&fi.convert(q);return fi(Y,q,this._strictPathCheck?TJ_:Aoq),this._t(Y,K,_,z)}checkIgnore(q){if(!jJ_.test(q))return this.test(q);let K=q.split(eG6).filter(Boolean);if(K.pop(),K.length){let _=this._t(K.join(eG6)+eG6,this._testCache,!0,K);if(_.ignored)return _}return this._rules.test(q,!1,Bf8)}_t(q,K,_,z){if(q in K)return K[q];if(!z)z=q.split(eG6).filter(Boolean);if(z.pop(),!z.length)return K[q]=this._rules.test(q,_,Ic6);let Y=this._t(z.join(eG6)+eG6,K,_,z);return K[q]=Y.ignored?Y:this._rules.test(q,_,Ic6)}ignores(q){return this._test(q,this._ignoreCache,!1).ignored}createFilter(){return(q)=>!this.ignores(q)}filter(q){return zoq(q).filter(this.createFilter())}test(q){return this._test(q,this._testCache,!0)}}var JN1=(q)=>new Hoq(q),vJ_=(q)=>fi(q&&fi.convert(q),q,Aoq),Joq=()=>{let q=(_)=>/^\\\\\?\\/.test(_)||/["<>|\u0000-\u001F]+/u.test(_)?_:_.replace(/\\/g,"/");fi.convert=q;let K=/^[a-z]:\//i;fi.isNotRelative=(_)=>K.test(_)||joq(_)};if(typeof process<"u"&&process.platform==="win32")Joq();Ff8.exports=JN1;JN1.default=JN1;Ff8.exports.isPathValid=vJ_;qT6(Ff8.exports,Symbol.for("setupWindows"),Joq)});var foq=m((qyA,Doq)=>{var Woq=U6("child_process"),Moq=Woq.spawn,kJ_=Woq.exec;Doq.exports=function(q,K,_){if(typeof K==="function"&&_===void 0)_=K,K=void 0;if(q=parseInt(q),Number.isNaN(q))if(_)return _(Error("pid must be a number"));else throw Error("pid must be a number");var z={},Y={};switch(z[q]=[],Y[q]=1,process.platform){case"win32":kJ_("taskkill /pid "+q+" /T /F",_);break;case"darwin":MN1(q,z,Y,function($){return Moq("pgrep",["-P",$])},function(){Xoq(z,K,_)});break;default:MN1(q,z,Y,function($){return Moq("ps",["-o","pid","--no-headers","--ppid",$])},function(){Xoq(z,K,_)});break}};function Xoq(q,K,_){var z={};try{Object.keys(q).forEach(function(Y){if(q[Y].forEach(function($){if(!z[$])Poq($,K),z[$]=1}),!z[Y])Poq(Y,K),z[Y]=1})}catch(Y){if(_)return _(Y);else throw Y}if(_)return _()}function Poq(q,K){try{process.kill(parseInt(q,10),K)}catch(_){if(_.code!=="ESRCH")throw _}}function MN1(q,K,_,z,Y){var $=z(q),A="";$.stdout.on("data",function(j){var j=j.toString("ascii");A+=j});var O=function(w){if(delete _[q],w!=0){if(Object.keys(_).length==0)Y();return}A.match(/\d+/g).forEach(function(j){j=parseInt(j,10),K[q].push(j),K[j]=[],_[j]=1,MN1(j,K,_,z,Y)})};$.on("close",O)}});var _q="Bash";function XN1(){return`A powerful search tool built on ripgrep
511
512 Usage:
513 - ALWAYS use ${n3} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${_q} command. The ${n3} tool has been optimized for correct permissions and access.
514 - Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
515 - Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
516 - Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
517 - Use ${v4} tool for open-ended searches requiring multiple rounds
518 - Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
519 - Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
520`}var n3="Grep";var qM=y(()=>{Z$()});var X4="Edit",Uf8="/.claude/**",Qf8="~/.claude/**",df8="File has been unexpectedly modified. Read it again before attempting to write it.";function PN1(q){let K=q.trim();if(!K)return null;if(K.endsWith("-")){let $=parseInt(K.slice(0,-1),10);if(isNaN($)||$<1)return null;return{firstPage:$,lastPage:1/0}}let _=K.indexOf("-");if(_===-1){let $=parseInt(K,10);if(isNaN($)||$<1)return null;return{firstPage:$,lastPage:$}}let z=parseInt(K.slice(0,_),10),Y=parseInt(K.slice(_+1),10);if(isNaN(z)||isNaN(Y)||z<1||Y<1||Y<z)return null;return{firstPage:z,lastPage:Y}}function uc6(){return!D5().toLowerCase().includes("claude-3-haiku")}function KT6(q){let K=q.startsWith(".")?q.slice(1):q;return VJ_.has(K.toLowerCase())}var VJ_;var cf8=y(()=>{aq();VJ_=new Set(["pdf"])});function koq(q,K,_){return`Reads a file from the local filesystem. You can access any file directly by using this tool.
521Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
522
523Usage:

Callers 2

descriptionFunction · 0.85
promptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected