MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / buildDepTree

Function buildDepTree

cli/src/components/agent-checklist.tsx:49–78  ·  view source on GitHub ↗
(
  agentId: string,
  agents: LocalAgentInfo[],
  agentDefinitions: Map<string, { spawnableAgents?: string[] }>,
  localAgentIds: Set<string>,
  ancestorIds: Set<string>,
)

Source from the content-addressed store, hash-verified

47}
48
49function buildDepTree(
50 agentId: string,
51 agents: LocalAgentInfo[],
52 agentDefinitions: Map<string, { spawnableAgents?: string[] }>,
53 localAgentIds: Set<string>,
54 ancestorIds: Set<string>,
55): DepTreeNode[] {
56 const definition = agentDefinitions.get(agentId)
57 const spawnableAgents = definition?.spawnableAgents ?? []
58
59 const newAncestorIds = new Set(ancestorIds)
60 newAncestorIds.add(agentId)
61
62 const children: DepTreeNode[] = []
63 for (const spawnableId of spawnableAgents) {
64 const simpleId = getSimpleAgentId(spawnableId)
65 if (localAgentIds.has(simpleId) && !newAncestorIds.has(simpleId)) {
66 const agent = agents.find((a) => a.id === simpleId)
67 if (agent) {
68 children.push({
69 id: agent.id,
70 displayName: agent.displayName,
71 children: buildDepTree(simpleId, agents, agentDefinitions, localAgentIds, newAncestorIds),
72 })
73 }
74 }
75 }
76
77 return children
78}
79
80// Render dependency tree recursively
81const DepTree: React.FC<{

Callers 1

AgentChecklistFunction · 0.85

Calls 2

getSimpleAgentIdFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected