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

Function groupConsecutiveBlocks

cli/src/utils/implementor-helpers.ts:119–137  ·  view source on GitHub ↗
(
  blocks: ContentBlock[],
  startIndex: number,
  predicate: (block: ContentBlock) => block is T,
)

Source from the content-addressed store, hash-verified

117 * Returns the group and the next index to process.
118 */
119export function groupConsecutiveBlocks<T extends ContentBlock>(
120 blocks: ContentBlock[],
121 startIndex: number,
122 predicate: (block: ContentBlock) => block is T,
123): { group: T[]; nextIndex: number } {
124 const group: T[] = []
125 let i = startIndex
126
127 while (i < blocks.length) {
128 const block = blocks[i]
129 if (!predicate(block)) {
130 break
131 }
132 group.push(block)
133 i++
134 }
135
136 return { group, nextIndex: i }
137}
138
139/**
140 * Group consecutive implementor agents from a blocks array.

Calls

no outgoing calls

Tested by

no test coverage detected