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

Function p_Y

package/cli.js:4667–4669  ·  view source on GitHub ↗
(q,K)

Source from the content-addressed store, hash-verified

4665- If a list of recently-used tools is provided, do not select memories that are usage reference or API documentation for those tools (Claude Code is already exercising them). DO still select memories containing warnings, gotchas, or known issues about those tools — active use is exactly when those matter.
4666`;var HfK=y(()=>{_8();y8();aq();nq6();l8();P87()});import{readdir as PfK,stat as WfK}from"fs/promises";import{dirname as W17,parse as zB8,relative as ma,resolve as DfK}from"path";import{randomUUID as O_Y}from"crypto";async function H_Y(q,K,_,z,Y,$,A){if(i6(process.env.CLAUDE_CODE_DISABLE_ATTACHMENTS)||i6(process.env.CLAUDE_CODE_SIMPLE))return AB8(z);let O=P3(),w=setTimeout((f)=>f.abort(),1000,O),j={...K,abortController:O},H=!K.agentId,J=q?[w$("at_mentioned_files",()=>S_Y(q,j)),w$("mcp_resources",()=>b_Y(q,j)),w$("agent_mentions",()=>Promise.resolve(C_Y(q,K.options.agentDefinitions.activeAgents))),...[]]:[],M=await Promise.all(J),X=[w$("queued_commands",()=>AB8(z)),w$("date_change",()=>Promise.resolve(k_Y(Y))),w$("ultrathink_effort",()=>Promise.resolve(V_Y(q))),w$("deferred_tools_delta",()=>Promise.resolve(Sp8(K.options.tools,K.options.mainLoopModel,Y,{callSite:H?"attachments_main":"attachments_subagent",querySource:$}))),w$("agent_listing_delta",()=>Promise.resolve(Cp8(K,Y))),w$("mcp_instructions_delta",()=>Promise.resolve(bp8(K.options.mcpClients,K.options.tools,K.options.mainLoopModel,Y))),w$("changed_files",()=>x_Y(j)),w$("nested_memory",()=>I_Y(j)),w$("dynamic_skill",()=>g_Y(j)),w$("skill_listing",()=>F_Y(j)),w$("plan_mode",()=>D_Y(Y,K)),w$("plan_mode_exit",()=>f_Y(K)),w$("auto_mode",()=>T_Y(Y,K)),w$("auto_mode_exit",()=>v_Y(K)),w$("todo_reminders",()=>IH()?a_Y(Y,K):r_Y(Y,K)),...nq()?[...$==="session_memory"?[]:[w$("teammate_mailbox",async()=>e_Y(K))],w$("team_context",async()=>qzY(Y??[]))]:[],w$("agent_pending_messages",async()=>M_Y(K)),w$("critical_system_reminder",()=>Promise.resolve(N_Y(K)))],P=H?[w$("ide_selection",async()=>E_Y(_,K)),w$("ide_opened_file",async()=>h_Y(_,K)),w$("output_style",async()=>Promise.resolve(y_Y())),w$("diagnostics",async()=>c_Y(K)),w$("lsp_diagnostics",async()=>l_Y(K)),w$("unified_tasks",async()=>s_Y(K)),w$("async_hook_responses",async()=>t_Y()),w$("token_usage",async()=>Promise.resolve(KzY(Y??[],K.options.mainLoopModel))),w$("budget_usd",async()=>Promise.resolve(zzY(K.options.maxBudgetUsd))),w$("output_token_usage",async()=>Promise.resolve(_zY())),w$("verify_plan_reminder",async()=>$zY(Y,K))]:[],[W,D]=await Promise.all([Promise.all(X),Promise.all(P)]);return clearTimeout(w),[...M.flat(),...W.flat(),...D.flat()].filter((f)=>f!==void 0&&f!==null)}async function w$(q,K){let _=Date.now();try{let z=await K(),Y=Date.now()-_;if(Math.random()<0.05){let $=z.filter((A)=>A!==void 0&&A!==null).reduce((A,O)=>{return A+g6(O).length},0);d("tengu_attachment_compute_duration",{label:q,duration_ms:Y,attachment_size_bytes:$,attachment_count:z.length})}return z}catch(z){let Y=Date.now()-_;if(Math.random()<0.05)d("tengu_attachment_compute_duration",{label:q,duration_ms:Y,error:!0});return H6(z),OE(`Attachment error in ${q}`,z),[]}}async function AB8(q){if(!q)return[];let K=q.filter((_)=>J_Y.has(_.mode));return Promise.all(K.map(async(_)=>{let z=await X_Y(_.pastedContents),Y=_.value;if(z.length>0)Y=[{type:"text",text:typeof _.value==="string"?_.value:L3(_.value,`
4667`)},...z];return{type:"queued_command",prompt:Y,source_uuid:_.uuid,imagePasteIds:eDK(_.pastedContents),commandMode:_.mode,origin:_.origin,isMeta:_.isMeta}}))}function M_Y(q){let K=q.agentId;if(!K)return[];return QXK(K,q.getAppState,q.setAppStateForTasks??q.setAppState).map((z)=>({type:"queued_command",prompt:z,origin:{kind:"coordinator"},isMeta:!0}))}async function X_Y(q){if(!q)return[];let K=Object.values(q).filter(vH6);if(K.length===0)return[];return await Promise.all(K.map(async(z)=>{let Y={type:"image",source:{type:"base64",media_type:z.mediaType||"image/png",data:z.content}};return(await Tr(Y)).block}))}function P_Y(q){let K=0,_=!1;for(let z=q.length-1;z>=0;z--){let Y=q[z];if(Y?.type==="user"&&!Y.isMeta&&!TfK(Y.message.content))K++;else if(Y?.type==="attachment"&&(Y.attachment.type==="plan_mode"||Y.attachment.type==="plan_mode_reentry")){_=!0;break}}return{turnCount:K,foundPlanModeAttachment:_}}function W_Y(q){let K=0;for(let _=q.length-1;_>=0;_--){let z=q[_];if(z?.type==="attachment"){if(z.attachment.type==="plan_mode_exit")break;if(z.attachment.type==="plan_mode")K++}}return K}async function D_Y(q,K){if(K.getAppState().toolPermissionContext.mode!=="plan")return[];if(q&&q.length>0){let{turnCount:j,foundPlanModeAttachment:H}=P_Y(q);if(H&&j<JfK.TURNS_BETWEEN_ATTACHMENTS)return[]}let Y=nP(K.agentId),$=mX(K.agentId),A=[];if(sb6()&&$!==null)A.push({type:"plan_mode_reentry",planFilePath:Y}),qE(!1);let w=(W_Y(q??[])+1)%JfK.FULL_REMINDER_EVERY_N_ATTACHMENTS===1?"full":"sparse";return A.push({type:"plan_mode",reminderType:w,isSubAgent:!!K.agentId,planFilePath:Y,planExists:$!==null}),A}async function f_Y(q){if(!Bi8())return[];if(q.getAppState().toolPermissionContext.mode==="plan")return Ex(!1),[];Ex(!1);let _=nP(q.agentId),z=mX(q.agentId)!==null;return[{type:"plan_mode_exit",planFilePath:_,planExists:z}]}function Z_Y(q){let K=0,_=!1;for(let z=q.length-1;z>=0;z--){let Y=q[z];if(Y?.type==="user"&&!Y.isMeta&&!TfK(Y.message.content))K++;else if(Y?.type==="attachment"&&Y.attachment.type==="auto_mode"){_=!0;break}else if(Y?.type==="attachment"&&Y.attachment.type==="auto_mode_exit")break}return{turnCount:K,foundAutoModeAttachment:_}}function G_Y(q){let K=0;for(let _=q.length-1;_>=0;_--){let z=q[_];if(z?.type==="attachment"){if(z.attachment.type==="auto_mode_exit")break;if(z.attachment.type==="auto_mode")K++}}return K}async function T_Y(q,K){let z=K.getAppState().toolPermissionContext,Y=z.mode==="auto",$=z.mode==="plan"&&(ffK?.isAutoModeActive()??!1);if(!Y&&!$)return[];if(q&&q.length>0){let{turnCount:w,foundAutoModeAttachment:j}=Z_Y(q);if(j&&w<MfK.TURNS_BETWEEN_ATTACHMENTS)return[]}return[{type:"auto_mode",reminderType:(G_Y(q??[])+1)%MfK.FULL_REMINDER_EVERY_N_ATTACHMENTS===1?"full":"sparse"}]}async function v_Y(q){if(!gi8())return[];if(q.getAppState().toolPermissionContext.mode==="auto"||(ffK?.isAutoModeActive()??!1))return VZ(!1),[];return VZ(!1),[{type:"auto_mode_exit"}]}function k_Y(q){let K=Qi6(),_=oi8();if(_===null)return BX6(K),[];if(K===_)return[];return BX6(K),[{type:"date_change",newDate:K}]}function V_Y(q){if(!qr()||!q||!o54(q))return[];return d("tengu_ultrathink",{}),[{type:"ultrathink_effort",level:"high"}]}function Sp8(q,K,_,z){if(!V18())return[];if(!yL())return[];if(!k18(K))return[];if(!JH6(q))return[];let Y=a87(q,_??[],z);if(!Y)return[];return[{type:"deferred_tools_delta",...Y}]}function Cp8(q,K){if(!Z67())return[];if(!q.options.tools.some((J)=>g_(J,v4)))return[];let{activeAgents:_,allowedAgentTypes:z}=q.options.agentDefinitions,Y=new Set;for(let J of q.options.tools){let M=nT(J.name);if(M)Y.add(M.serverName)}let $=q.getAppState().toolPermissionContext,A=d88(ri6(_,[...Y]),$,v4);if(z)A=A.filter((J)=>z.includes(J.agentType));let O=new Set;for(let J of K??[]){if(J.type!=="attachment")continue;if(J.attachment.type!=="agent_listing_delta")continue;for(let M of J.attachment.addedTypes)O.add(M);for(let M of J.attachment.removedTypes)O.delete(M)}let w=new Set(A.map((J)=>J.agentType)),j=A.filter((J)=>!O.has(J.agentType)),H=[];for(let J of O)if(!w.has(J))H.push(J);if(j.length===0&&H.length===0)return[];return j.sort((J,M)=>J.agentType.localeCompare(M.agentType)),H.sort(),[{type:"agent_listing_delta",addedTypes:j.map((J)=>J.agentType),addedLines:j.map(f67),removedTypes:H,isInitial:O.size===0,showConcurrencyNote:yK()!=="pro"}]}function bp8(q,K,_,z){if(!_h6())return[];let Y=[];if(yL()&&k18(_)&&JH6(K))Y.push({serverName:yN,block:ep8});let $=qfK(q,z??[],Y);if(!$)return[];return[{type:"mcp_instructions_delta",...$}]}function N_Y(q){let K=q.criticalSystemReminder_EXPERIMENTAL;if(!K)return[];return[{type:"critical_system_reminder",content:K}]}function y_Y(){let K=Z7()?.outputStyle||"default";if(K==="default")return[];return[{type:"output_style",style:K}]}async function E_Y(q,K){let _=LE8(K.options.mcpClients);if(!_||q?.lineStart===void 0||!q.text||!q.filePath)return[];let z=K.getAppState();if(Yh6(q.filePath,z.toolPermissionContext))return[];return[{type:"selected_lines_in_ide",ideName:_,lineStart:q.lineStart,lineEnd:q.lineStart+q.lineCount-1,filename:q.filePath,content:q.text,displayPath:ma(Z8(),q.filePath)}]}function L_Y(q,K){let _=W17(DfK(q)),z=[],Y=_;while(Y!==K&&Y!==zB8(Y).root){if(Y.startsWith(K))z.push(Y);Y=W17(Y)}z.reverse();let $=[];Y=K;while(Y!==zB8(Y).root)$.push(Y),Y=W17(Y);return $.reverse(),{nestedDirs:z,cwdLevelDirs:$}}function R_Y(q){return q==="User"||q==="Project"||q==="Local"||q==="Managed"}function f17(q,K,_){let z=[],Y=Wr6();for(let $ of q){if(K.loadedNestedMemoryPaths?.has($.path))continue;if(!K.readFileState.has($.path)){if(z.push({type:"nested_memory",path:$.path,content:$,displayPath:ma(Z8(),$.path)}),K.loadedNestedMemoryPaths?.add($.path),K.readFileState.set($.path,{content:$.contentDiffersFromDisk?$.rawContent??$.content:$.content,timestamp:Date.now(),offset:void 0,limit:void 0,isPartialView:$.contentDiffersFromDisk}),Y&&R_Y($.type)){let A=$.globs?"path_glob_match":$.parent?"include":"nested_traversal";Dr6($.path,$.type,A,{globs:$.globs,triggerFilePath:_,parentFilePath:$.parent})}}}return z}async function ZfK(q,K,_){let z=[];try{if(!XL(q,_.toolPermissionContext))return z;let Y=new Set,$=r1(),A=await AI1(q,Y);z.push(...f17(A,K,q));let{nestedDirs:O,cwdLevelDirs:w}=L_Y(q,$),j=g8("tengu_paper_halyard",!1);for(let H of O){let J=(await OI1(H,q,Y)).filter((M)=>!j||M.type!=="Project"&&M.type!=="Local");z.push(...f17(J,K,q))}for(let H of w){let J=(await wI1(H,q,Y)).filter((M)=>!j||M.type!=="Project"&&M.type!=="Local");z.push(...f17(J,K,q))}}catch(Y){H6(Y)}return z}async function h_Y(q,K){if(!q?.filePath||q.text)return[];let _=K.getAppState();if(Yh6(q.filePath,_.toolPermissionContext))return[];return[...await ZfK(q.filePath,K,_),{type:"opened_file_in_ide",filename:q.filePath}]}async function S_Y(q,K){let _=U_Y(q);if(_.length===0)return[];let z=K.getAppState();return(await Promise.all(_.map(async($)=>{try{let{filename:A,lineStart:O,lineEnd:w}=d_Y($),j=lq(A);if(Yh6(j,z.toolPermissionContext))return null;try{if((await WfK(j)).isDirectory())try{let J=await PfK(j,{withFileTypes:!0}),M=1000,X=J.length>1000,P=J.slice(0,1000).map((D)=>D.name);if(X)P.push(`… and ${J.length-1000} more entries`);let W=P.join(`
4668`);return d("tengu_at_mention_extracting_directory_success",{}),{type:"directory",path:j,content:W,displayPath:ma(Z8(),j)}}catch{return null}}catch{}return await I87(j,K,"tengu_at_mention_extracting_filename_success","tengu_at_mention_extracting_filename_error","at-mention",{offset:O,limit:w&&O?w-O+1:void 0})}catch{d("tengu_at_mention_extracting_filename_error",{})}}))).filter(Boolean)}function C_Y(q,K){let _=vfK(q);if(_.length===0)return[];return _.map((Y)=>{let $=Y.replace("agent-",""),A=K.find((O)=>O.agentType===$);if(!A)return d("tengu_at_mention_agent_not_found",{}),null;return d("tengu_at_mention_agent_success",{}),{type:"agent_mention",agentType:A.agentType}}).filter((Y)=>Y!==null)}async function b_Y(q,K){let _=Q_Y(q);if(_.length===0)return[];let z=K.options.mcpClients||[];return(await Promise.all(_.map(async($)=>{try{let[A,...O]=$.split(":"),w=O.join(":");if(!A||!w)return d("tengu_at_mention_mcp_resource_error",{}),null;let j=z.find((M)=>M.name===A);if(!j||j.type!=="connected")return d("tengu_at_mention_mcp_resource_error",{}),null;let J=(K.options.mcpResources?.[A]||[]).find((M)=>M.uri===w);if(!J)return d("tengu_at_mention_mcp_resource_error",{}),null;try{let M=await j.client.readResource({uri:w});return d("tengu_at_mention_mcp_resource_success",{}),{type:"mcp_resource",server:A,uri:w,name:J.name||w,description:J.description,content:M}}catch(M){return d("tengu_at_mention_mcp_resource_error",{}),H6(M),null}}catch{return d("tengu_at_mention_mcp_resource_error",{}),null}}))).filter(($)=>$!==null)}async function x_Y(q){let K=d76(q.readFileState);if(K.length===0)return[];let _=q.getAppState();return(await Promise.all(K.map(async(Y)=>{let $=q.readFileState.get(Y);if(!$)return null;if($.offset!==void 0||$.limit!==void 0)return null;let A=lq(Y);if(Yh6(A,_.toolPermissionContext))return null;try{if(await zp6(A)<=$.timestamp)return null;let w={file_path:A};if(!(await i_.validateInput(w,q)).result)return null;let H=await i_.call(w,q);if(H.data.type==="text"){let J=p$K($.content,H.data.file.content);if(J==="")return null;return{type:"edited_text_file",filename:A,snippet:J}}if(H.data.type==="image")try{let J=await w17(A);return{type:"edited_image_file",filename:A,content:J}}catch(J){return H6(J),d("tengu_watched_file_compression_failed",{file:A}),null}return null}catch(O){if(_7(O))q.readFileState.delete(Y);return null}}))).filter((Y)=>Y!=null)}async function I_Y(q){if(!q.nestedMemoryAttachmentTriggers||q.nestedMemoryAttachmentTriggers.size===0)return[];let K=q.getAppState(),_=[];for(let z of q.nestedMemoryAttachmentTriggers){let Y=await ZfK(z,q,K);_.push(...Y)}return q.nestedMemoryAttachmentTriggers.clear(),_}async function u_Y(q,K,_,z,Y,$){let A=vfK(q).flatMap((J)=>{let M=J.replace("agent-",""),X=K.find((P)=>P.agentType===M);return X?.memory?[Nk6(M,X.memory)]:[]}),O=A.length>0?A:[Vj()],j=(await Promise.all(O.map((J)=>jfK(q,J,Y,z,$).catch(()=>[])))).flat().filter((J)=>!_.has(J.path)&&!$.has(J.path)).slice(0,5),H=await p_Y(j,Y);if(H.length===0)return[];return[{type:"relevant_memories",memories:H}]}function m_Y(q){let K=new Set,_=0;for(let z of q)if(z.type==="attachment"&&z.attachment.type==="relevant_memories")for(let Y of z.attachment.memories)K.add(Y.path),_+=Y.content.length;return{paths:K,totalBytes:_}}async function p_Y(q,K){return(await Promise.all(q.map(async({path:z,mtimeMs:Y})=>{try{let $=await lK6(z,0,D17,XfK,K,{truncateOnByteLimit:!0}),A=$.totalLines>D17||$.truncatedByBytes,O=A?$.content+`
4669
4670> This memory file was truncated (${$.truncatedByBytes?`${XfK} byte limit`:`first ${D17} lines`}). Use the ${Cq} tool to view the complete file at: ${z}`:$.content;return{path:z,content:O,mtimeMs:Y,header:G17(z,Y),limit:A?$.lineCount:void 0}}catch{return null}}))).filter((z)=>z!==null)}function G17(q,K){let _=Sx1(K);return _?`${_}
4671
4672Memory: ${q}:`:`Memory (saved ${Aj4(K)}): ${q}:`}function bWK(q,K){if(!l3()||!g8("tengu_moth_copse",!1))return;let _=q.findLast((j)=>j.type==="user"&&!j.isMeta);if(!_)return;let z=iw6(_);if(!z||!/\s/.test(z.trim()))return;let Y=m_Y(q);if(Y.totalBytes>=w_Y.MAX_SESSION_BYTES)return;let $=bC(K.abortController),A=Date.now(),O=u_Y(z,K.options.agentDefinitions.activeAgents,K.readFileState,B_Y(q,_),$.signal,Y.paths).catch((j)=>{if(!pH7(j))H6(j);return[]}),w={promise:O,settledAt:null,consumedOnIteration:-1,[Symbol.dispose](){$.abort(),d("tengu_memdir_prefetch_collected",{hidden_by_first_iteration:w.settledAt!==null&&w.consumedOnIteration===0,consumed_on_iteration:w.consumedOnIteration,latency_ms:(w.settledAt??Date.now())-A})}};return O.finally(()=>{w.settledAt=Date.now()}),w}function GfK(q){return typeof q==="object"&&q!==null&&q.type==="tool_result"&&typeof q.tool_use_id==="string"}function TfK(q){return Array.isArray(q)&&q.some(GfK)}function B_Y(q,K){let _=new Map,z=new Map;for(let A=q.length-1;A>=0;A--){let O=q[A];if(!O)continue;if(zh6(O)&&O!==K)break;if(O.type==="assistant"&&typeof O.message.content!=="string"){for(let w of O.message.content)if(w.type==="tool_use")_.set(w.id,w.name)}else if(O.type==="user"&&"message"in O&&Array.isArray(O.message.content)){for(let w of O.message.content)if(GfK(w))z.set(w.tool_use_id,w.is_error===!0)}}let Y=new Set,$=new Set;for(let[A,O]of _){let w=z.get(A);if(w===void 0)continue;if(w)Y.add(O);else $.add(O)}return[...$].filter((A)=>!Y.has(A))}function xWK(q,K){return q.map((_)=>{if(_.type!=="relevant_memories")return _;let z=_.memories.filter((Y)=>!K.has(Y.path));for(let Y of z)K.set(Y.path,{content:Y.content,timestamp:Y.mtimeMs,offset:void 0,limit:Y.limit});return z.length>0?{..._,memories:z}:null}).filter((_)=>_!==null)}async function g_Y(q){let K=[];if(q.dynamicSkillDirTriggers&&q.dynamicSkillDirTriggers.size>0){let _=await Promise.all(Array.from(q.dynamicSkillDirTriggers).map(async(z)=>{try{let $=(await PfK(z,{withFileTypes:!0})).filter((O)=>O.isDirectory()||O.isSymbolicLink()).map((O)=>O.name),A=await Promise.all($.map(async(O)=>{try{return await WfK(DfK(z,O,"SKILL.md")),O}catch{return null}}));return{skillDir:z,skillNames:A.filter((O)=>O!==null)}}catch{return{skillDir:z,skillNames:[]}}}));for(let{skillDir:z,skillNames:Y}of _)if(Y.length>0)K.push({type:"dynamic_skill",skillDir:z,skillNames:Y,displayPath:ma(Z8(),z)});q.dynamicSkillDirTriggers.clear()}return K}function $h6(){Z17.clear(),OB8=!1}function r5K(){OB8=!0}async function F_Y(q){if(!q.options.tools.some((J)=>g_(J,JM)))return[];let K=Fz(),_=await NC(K),z=kfK(q.getAppState().mcp.commands),Y=z.length>0?u2([..._,...z],"name"):_,$=q.agentId??"",A=Z17.get($);if(!A)A=new Set,Z17.set($,A);if(OB8){OB8=!1;for(let J of Y)A.add(J.name);return[]}let O=Y.filter((J)=>!A.has(J.name));if(O.length===0)return[];let w=A.size===0;for(let J of O)A.add(J.name);N(`Sending ${O.length} skills via attachment (${w?"initial":"dynamic"}, ${A.size} total sent)`);let j=lf(q.options.mainLoopModel,QM());return[{type:"skill_listing",content:yx1(O,j),skillCount:O.length,isInitial:w}]}function U_Y(q){let K=/(^|\s)@"([^"]+)"/g,_=/(^|\s)@([^\s]+)\b/g,z=[],Y=[],$;while(($=K.exec(q))!==null)if($[2]&&!$[2].endsWith(" (agent)"))z.push($[2]);return(q.match(_)||[]).forEach((O)=>{let w=O.slice(O.indexOf("@")+1);if(!w.startsWith('"'))Y.push(w)}),cJ([...z,...Y])}function Q_Y(q){let K=/(^|\s)@([^\s]+:[^\s]+)\b/g,_=q.match(K)||[];return cJ(_.map((z)=>z.slice(z.indexOf("@")+1)))}function vfK(q){let K=[],_=/(^|\s)@"([\w:.@-]+) \(agent\)"/g,z;while((z=_.exec(q))!==null)if(z[2])K.push(z[2]);let Y=/(^|\s)@(agent-[\w:.@-]+)/g,$=q.match(Y)||[];for(let A of $)K.push(A.slice(A.indexOf("@")+1));return cJ(K)}function d_Y(q){let K=q.match(/^([^#]+)(?:#L(\d+)(?:-(\d+))?)?(?:#[^#]*)?$/);if(!K)return{filename:q};let[,_,z,Y]=K,$=z?parseInt(z,10):void 0,A=Y?parseInt(Y,10):$;return{filename:_??q,lineStart:$,lineEnd:A}}async function c_Y(q){if(!q.options.tools.some((_)=>g_(_,_q)))return[];let K=await Ka.getNewDiagnostics();if(K.length===0)return[];return[{type:"diagnostics",files:K,isNew:!0}]}async function l_Y(q){if(!q.options.tools.some((K)=>g_(K,_q)))return[];N("LSP Diagnostics: getLSPDiagnosticAttachments called");try{let K=k3K();if(K.length===0)return[];N(`LSP Diagnostics: Found ${K.length} pending diagnostic set(s)`);let _=K.map(({files:z})=>({type:"diagnostics",files:z,isNew:!0}));if(K.length>0)V3K(),N(`LSP Diagnostics: Cleared ${K.length} delivered diagnostic(s) from registry`);return N(`LSP Diagnostics: Returning ${_.length} diagnostic attachment(s)`),_}catch(K){let _=x1(K);return H6(Error(`Failed to get LSP diagnostic attachments: ${_.message}`)),[]}}async function*nE6(q,K,_,z,Y,$,A){let O=await H_Y(q,K,_,z,Y,$,A);if(O.length===0)return;d("tengu_attachments",{attachment_types:O.map((w)=>w.type)});for(let w of O)yield V4(w)}async function n_Y(q){let K=zB8(q).ext.toLowerCase();if(!KT6(K))return null;try{let[_,z]=await Promise.all([X8().stat(q),rp8(q)]),Y=z??Math.ceil(_.size/102400);if(Y>Zk8)return d("tengu_pdf_reference_attachment",{pageCount:Y,fileSize:_.size,hadPdfinfo:z!==null}),{type:"pdf_reference",filename:q,pageCount:Y,fileSize:_.size,displayPath:ma(Z8(),q)}}catch{}return null}async function I87(q,K,_,z,Y,$){let{offset:A,limit:O}=$??{},w=K.getAppState();if(Yh6(q,w.toolPermissionContext))return null;if(Y==="at-mention"&&!d$8(q,GH6().maxSizeBytes)){let H=zB8(q).ext.toLowerCase();if(!KT6(H))try{let J=await X8().stat(q);return d("tengu_attachment_file_too_large",{size_bytes:J.size,mode:Y}),null}catch{}}if(Y==="at-mention"){let H=await n_Y(q);if(H)return H}let j=K.readFileState.get(q);if(j&&Y==="at-mention")try{let H=await zp6(q);if(j.timestamp<=H&&H===j.timestamp)return d(_,{}),{type:"already_read_file",filename:q,displayPath:ma(Z8(),q),content:{type:"text",file:{filePath:q,content:j.content,numLines:G$(j.content,`

Callers 1

u_YFunction · 0.85

Calls 3

lK6Function · 0.85
G17Function · 0.85
filterMethod · 0.80

Tested by

no test coverage detected