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

Function aOY

package/cli.js:5317–5353  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5315
5316"${z}"
5317
5318These instructions take priority over the general rules below. Make sure your updates align with these specific guidelines.`:"";return BOY(Y,{docContents:q,docPath:K,docTitle:_,customInstructions:$})}var kTK=y(()=>{m8();e7()});function VTK(){w78.clear()}function UOY(q){let K=q.match(gOY);if(!K||!K[1])return null;let _=K[1].trim(),z=K.index+K[0].length,$=q.slice(z).match(/^\s*\n(?:\s*\n)?(.+?)(?:\n|$)/);if($&&$[1]){let O=$[1].match(FOY);if(O&&O[1]){let w=O[1].trim();return{title:_,instructions:w}}}return{title:_}}function QOY(){return{agentType:"magic-docs",whenToUse:"Update Magic Docs",tools:[X4],model:"sonnet",source:"built-in",baseDir:"built-in",getSystemPrompt:()=>""}}async function dOY(q,K){let{messages:_,systemPrompt:z,userContext:Y,systemContext:$,toolUseContext:A}=K,O=gu(A.readFileState);O.delete(q.path);let w={...A,readFileState:O},j="";try{let P=(await i_.call({file_path:q.path},w)).data;if(P.type==="text")j=P.file.content}catch(X){if(e3(X)||X instanceof Error&&X.message.startsWith("File does not exist")){w78.delete(q.path);return}throw X}let H=UOY(j);if(!H){w78.delete(q.path);return}let J=await vTK(j,q.path,H.title,H.instructions),M=async(X,P)=>{if(X.name===X4&&typeof P==="object"&&P!==null&&"file_path"in P){let W=P.file_path;if(typeof W==="string"&&W===q.path)return{behavior:"allow",updatedInput:P}}return{behavior:"deny",message:`only ${X4} is allowed for ${q.path}`,decisionReason:{type:"other",reason:`only ${X4} is allowed`}}};for await(let X of iN({agentDefinition:QOY(),promptMessages:[U8({content:J})],toolUseContext:w,canUseTool:M,isAsync:!0,forkContextMessages:_,querySource:"magic_docs",override:{systemPrompt:z,userContext:Y,systemContext:$},availableTools:w.options.tools}));}async function NTK(){}var gOY,FOY,w78,Fsw;var Sq7=y(()=>{i46();$p();y8();NG();Br6();i1();kTK();gOY=/^#\s*MAGIC\s+DOC:\s*(.+)$/im,FOY=/^[_*](.+?)[_*]\s*$/m,w78=new Map;Fsw=TB(async function(q){let{messages:K,querySource:_}=q;if(_!=="repl_main_thread")return;if(o18(K))return;if(w78.size===0)return;for(let $ of Array.from(w78.values()))await dOY($,q)})});var bq7={};T8(bq7,{clearSessionCaches:()=>Cq7});function Cq7(q=new Set){let K=q.size>0;if(bO.cache.clear?.(),tw.cache.clear?.(),XI1.cache.clear?.(),Jk8.cache.clear?.(),fTK(),tQ(),!K)vj4();if(LH4(null),BX6(null),Hp(),$h6(),Xr6("session_start"),KC4(),G5K(),!K)N7K();if(h41(),DZK(),!K)DP4();ci8(q),CR7(),QYK(),N3K(),VTK(),AzK(),Promise.resolve().then(() => (Ze1(),AjK)).then(({clearWebFetchCache:_})=>_()),Promise.resolve().then(() => (Uk8(),jJ4)).then(({clearToolSearchDescriptionCache:_})=>_()),Promise.resolve().then(() => (SP(),s24)).then(({clearAgentDefinitionsCache:_})=>_()),Promise.resolve().then(() => (yO6(),Kj4)).then(({clearPromptCache:_})=>_())}var Dg8=y(()=>{v8();yA();yk6();jN();O78();yE6();vr();Q76();Ax8();G18();OL6();Sq7();Ga();lP();SG();wM();mZ();Hl();Ko();XI8()});var Iq7={};T8(Iq7,{clearConversation:()=>xq7});import{randomUUID as cOY}from"crypto";async function xq7({setMessages:q,readFileState:K,discoveredSkillNames:_,loadedNestedMemoryPaths:z,getAppState:Y,setAppState:$,setConversationId:A}){let O=H78();await J78("clear",{getAppState:Y,setAppState:$,signal:AbortSignal.timeout(O),timeoutMs:O});let w=ub6();if(w)d("tengu_cache_eviction_hint",{scope:"conversation_clear",last_request_id:w});let j=new Set,H=[],J=(P)=>("isBackgrounded"in P)&&P.isBackgrounded===!1;if(Y)for(let P of Object.values(Y().tasks)){if(J(P))continue;if(EJ(P))j.add(P.agentId),H.push(P);else if(xH(P))j.add(P.identity.agentId)}if(q(()=>[]),A)A(cOY());if(Cq7(j),QO(r1()),K.clear(),_?.clear(),z?.clear(),$)$((P)=>{let W={};for(let[D,f]of Object.entries(P.tasks)){if(!J(f)){W[D]=f;continue}try{if(f.status==="running"){if(sv(f)){if(f.shellCommand?.kill(),f.shellCommand?.cleanup(),f.cleanupTimeoutId)clearTimeout(f.cleanupTimeoutId)}if("abortController"in f)f.abortController?.abort();if("unregisterCleanup"in f)f.unregisterCleanup?.()}}catch(G){H6(G)}Zw(D)}return{...P,tasks:W,attribution:yV6(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:P.mcp.pluginReconnectKey}}});C5K(),j78(),un8({setCurrentAsParent:!0}),await mb();for(let P of H){if(P.status!=="running")continue;zH6(P.id,c0(pO(P.agentId)))}let M=n2();if(M)Oy(M);let X=await xD("clear");if(X.length>0)q(()=>X)}var fg8=y(()=>{v8();k8();gP();M0();xr();y$();E8();SJ();tN();JK6();_K();Ij();d0();Dg8()});var ETK={};T8(ETK,{call:()=>lOY});var lOY=async(q,K)=>{return await xq7(K),{type:"text",value:""}};var LTK=y(()=>{fg8()});var nOY,Zg8;var RTK=y(()=>{nOY={type:"local",name:"clear",description:"Clear conversation history and free up context",aliases:["reset","new"],supportsNonInteractive:!1,load:()=>Promise.resolve().then(() => (LTK(),ETK))},Zg8=nOY});var hTK={};T8(hTK,{call:()=>rOY});async function rOY(q,K,_){if($Y())return q("Cannot set color: This session is a swarm teammate. Teammate colors are assigned by the team leader.",{display:"system"}),null;if(!_||_.trim()===""){let A=GJ.join(", ");return q(`Please provide a color. Available colors: ${A}, default`,{display:"system"}),null}let z=_.trim().toLowerCase();if(iOY.includes(z)){let A=N8(),O=Y$();return await Gg8(A,"default",O),K.setAppState((w)=>({...w,standaloneAgentContext:{...w.standaloneAgentContext,name:w.standaloneAgentContext?.name??"",color:void 0}})),q("Session color reset to default",{display:"system"}),null}if(!GJ.includes(z)){let A=GJ.join(", ");return q(`Invalid color "${z}". Available colors: ${A}, default`,{display:"system"}),null}let Y=N8(),$=Y$();return await Gg8(Y,z,$),K.setAppState((A)=>({...A,standaloneAgentContext:{...A.standaloneAgentContext,name:A.standaloneAgentContext?.name??"",color:z}})),q(`Session color set to: ${z}`,{display:"system"}),null}var iOY;var STK=y(()=>{v8();$0();_K();AY();iOY=["default","reset","none","gray","grey"]});var oOY,uq7;var CTK=y(()=>{oOY={type:"local-jsx",name:"color",description:"Set the prompt bar color for this session",immediate:!0,argumentHint:"<color|default>",load:()=>Promise.resolve().then(() => (STK(),hTK))},uq7=oOY});function aOY(){let{commit:q}=dR6();return`${""}## Context
5319
5320- Current git status: !\`git status\`
5321- Current git diff (staged and unstaged changes): !\`git diff HEAD\`
5322- Current branch: !\`git branch --show-current\`
5323- Recent commits: !\`git log --oneline -10\`
5324
5325## Git Safety Protocol
5326
5327- NEVER update the git config
5328- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
5329- CRITICAL: ALWAYS create NEW commits. NEVER use git commit --amend, unless the user explicitly requests it
5330- Do not commit files that likely contain secrets (.env, credentials.json, etc). Warn the user if they specifically request to commit those files
5331- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
5332- Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported
5333
5334## Your task
5335
5336Based on the above changes, create a single git commit:
5337
53381. Analyze all staged changes and draft a commit message:
5339 - Look at the recent commits above to follow this repository's commit message style
5340 - Summarize the nature of the changes (new feature, enhancement, bug fix, refactoring, test, docs, etc.)
5341 - Ensure the message accurately reflects the changes and their purpose (i.e. "add" means a wholly new feature, "update" means an enhancement to an existing feature, "fix" means a bug fix, etc.)
5342 - Draft a concise (1-2 sentences) commit message that focuses on the "why" rather than the "what"
5343
53442. Stage relevant files and create the commit using HEREDOC syntax:
5345\`\`\`
5346git commit -m "$(cat <<'EOF'
5347Commit message here.${q?`
5348
5349${q}`:""}
5350EOF
5351)"
5352\`\`\`
5353
5354You have the capability to call multiple tools in a single response. Stage and create the commit using a single message. Do not use any other tools or do anything else. Do not send any other text or messages besides these tool calls.`}var bTK,sOY,xTK;var ITK=y(()=>{sm8();uL6();jH6();bTK=["Bash(git add:*)","Bash(git status:*)","Bash(git commit:*)"];sOY={type:"prompt",name:"commit",description:"Create a git commit",allowedTools:bTK,contentLength:0,progressMessage:"creating commit",source:"builtin",async getPromptForCommand(q,K){let _=aOY();return[{type:"text",text:await pQ(_,{...K,getAppState(){let Y=K.getAppState();return{...Y,toolPermissionContext:{...Y.toolPermissionContext,alwaysAllowRules:{...Y.toolPermissionContext.alwaysAllowRules,command:bTK}}}}},"/commit")}]}},xTK=sOY});var UTK={};T8(UTK,{fileExtension:()=>gTK,collectRecentAssistantTexts:()=>BTK,call:()=>OwY});import{mkdir as tOY,writeFile as eOY}from"fs/promises";import{tmpdir as qwY}from"os";import{join as mTK}from"path";function _wY(q){let K=oz.lexer(sq6(q)),_=[];for(let z of K)if(z.type==="code"){let Y=z;_.push({code:Y.text,lang:Y.lang})}return _}function BTK(q){let K=[];for(let _=q.length-1;_>=0&&K.length<KwY;_--){let z=q[_];if(z?.type!=="assistant"||z.isApiErrorMessage)continue;let Y=z.message.content;if(!Array.isArray(Y))continue;let $=L3(Y,`
5355
5356`);if($)K.push($)}return K}function gTK(q){if(q){let K=q.replace(/[^a-zA-Z0-9]/g,"");if(K&&K!=="plaintext")return`.${K}`}return".txt"}async function FTK(q,K){let _=mTK(uTK,K);return await tOY(uTK,{recursive:!0}),await eOY(_,q,"utf-8"),_}async function mq7(q,K){let _=await XX(q);if(_)process.stdout.write(_);let z=G$(q,`

Callers 1

getPromptForCommandFunction · 0.85

Calls 1

dR6Function · 0.85

Tested by

no test coverage detected