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

Function splitByAgentSize

cli/src/utils/block-processor.ts:74–100  ·  view source on GitHub ↗
(
  items: T[],
  getAgentType: (item: T) => string,
)

Source from the content-addressed store, hash-verified

72 * so it renders at full width.
73 */
74export function splitByAgentSize<T>(
75 items: T[],
76 getAgentType: (item: T) => string,
77): T[][] {
78 if (items.length <= 1) return [items]
79
80 const subGroups: T[][] = []
81 let currentSmallGroup: T[] = []
82
83 for (const item of items) {
84 if (shouldCollapseByDefault(getAgentType(item))) {
85 currentSmallGroup.push(item)
86 } else {
87 if (currentSmallGroup.length > 0) {
88 subGroups.push(currentSmallGroup)
89 currentSmallGroup = []
90 }
91 subGroups.push([item])
92 }
93 }
94
95 if (currentSmallGroup.length > 0) {
96 subGroups.push(currentSmallGroup)
97 }
98
99 return subGroups
100}
101
102/** Convenience wrapper for splitting AgentContentBlock arrays by size. */
103export function splitAgentsBySize(

Callers 2

splitAgentsBySizeFunction · 0.85

Calls 1

shouldCollapseByDefaultFunction · 0.90

Tested by

no test coverage detected