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

Function getImplementorIndex

cli/src/utils/implementor-helpers.ts:90–113  ·  view source on GitHub ↗
(
  currentAgent: AgentContentBlock,
  siblingBlocks: ContentBlock[],
)

Source from the content-addressed store, hash-verified

88 * Returns the 0-based index among all implementor agents of the same type.
89 */
90export const getImplementorIndex = (
91 currentAgent: AgentContentBlock,
92 siblingBlocks: ContentBlock[],
93): number | undefined => {
94 if (!isImplementorAgent(currentAgent)) return undefined
95
96 // Filter to only implementor agents of the same type
97 const implementorSiblings = siblingBlocks.filter(
98 (block): block is AgentContentBlock =>
99 block.type === 'agent' &&
100 isImplementorAgent(block) &&
101 block.agentType === currentAgent.agentType,
102 )
103
104 // If there's only one, don't show an index
105 if (implementorSiblings.length <= 1) {
106 return undefined
107 }
108
109 // Find the index of the current agent
110 return implementorSiblings.findIndex(
111 (block) => block.agentId === currentAgent.agentId,
112 )
113}
114
115/**
116 * Group consecutive blocks from a blocks array that match the predicate.

Calls 1

isImplementorAgentFunction · 0.85

Tested by

no test coverage detected