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

Function computeDependencies

cli/src/components/publish-confirmation.tsx:22–51  ·  view source on GitHub ↗
(
  selectedAgentIds: Set<string>,
  agentDefinitions: Map<string, { spawnableAgents?: string[] }>,
  localAgentIds: Set<string>,
)

Source from the content-addressed store, hash-verified

20
21// Compute all dependencies (agents that the selected agents spawn)
22function computeDependencies(
23 selectedAgentIds: Set<string>,
24 agentDefinitions: Map<string, { spawnableAgents?: string[] }>,
25 localAgentIds: Set<string>,
26): Set<string> {
27 const dependencies = new Set<string>()
28 const visited = new Set<string>()
29
30 function collectDependencies(agentId: string) {
31 if (visited.has(agentId)) return
32 visited.add(agentId)
33
34 const definition = agentDefinitions.get(agentId)
35 const spawnableAgents = definition?.spawnableAgents ?? []
36
37 for (const spawnableId of spawnableAgents) {
38 const simpleId = getSimpleAgentId(spawnableId)
39 if (localAgentIds.has(simpleId) && !selectedAgentIds.has(simpleId)) {
40 dependencies.add(simpleId)
41 collectDependencies(simpleId)
42 }
43 }
44 }
45
46 for (const agentId of selectedAgentIds) {
47 collectDependencies(agentId)
48 }
49
50 return dependencies
51}
52
53// Compute all dependents (agents that spawn the selected agents - reverse dependencies)
54// This finds agents that directly or transitively spawn the selected agents

Callers 1

PublishConfirmationFunction · 0.85

Calls 1

collectDependenciesFunction · 0.85

Tested by

no test coverage detected