( allAgents: AgentDefinition[], activeAgents: AgentDefinition[], )
| 44 | * where the same agent file is loaded from both the worktree and main repo. |
| 45 | */ |
| 46 | export 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. |
no test coverage detected