MCPcopy
hub / github.com/codeaashu/claude-code / resolveAgentOverrides

Function resolveAgentOverrides

src/tools/AgentTool/agentDisplay.ts:46–72  ·  view source on GitHub ↗
(
  allAgents: AgentDefinition[],
  activeAgents: AgentDefinition[],
)

Source from the content-addressed store, hash-verified

44 * where the same agent file is loaded from both the worktree and main repo.
45 */
46export function resolveAgentOverrides(
47 allAgents: AgentDefinition[],
48 activeAgents: AgentDefinition[],
49): ResolvedAgent[] {
50 const activeMap = new Map<string, AgentDefinition>()
51 for (const agent of activeAgents) {
52 activeMap.set(agent.agentType, agent)
53 }
54
55 const seen = new Set<string>()
56 const resolved: ResolvedAgent[] = []
57
58 // Iterate allAgents, annotating each with override info from activeAgents.
59 // Deduplicate by (agentType, source) to handle git worktree duplicates.
60 for (const agent of allAgents) {
61 const key = `${agent.agentType}:${agent.source}`
62 if (seen.has(key)) continue
63 seen.add(key)
64
65 const active = activeMap.get(agent.agentType)
66 const overriddenBy =
67 active && active.source !== agent.source ? active.source : undefined
68 resolved.push({ ...agent, overriddenBy })
69 }
70
71 return resolved
72}
73
74/**
75 * Resolve the display model string for an agent.

Callers 2

AgentsMenuFunction · 0.85
agentsHandlerFunction · 0.85

Calls 5

getMethod · 0.65
setMethod · 0.45
hasMethod · 0.45
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected