MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / groupIntoTurns

Function groupIntoTurns

apps/kimi-code/src/tui/utils/export-markdown.ts:114–129  ·  view source on GitHub ↗
(history: readonly ContextMessage[])

Source from the content-addressed store, hash-verified

112}
113
114export function groupIntoTurns(history: readonly ContextMessage[]): ContextMessage[][] {
115 const turns: ContextMessage[][] = [];
116 let current: ContextMessage[] = [];
117
118 for (const msg of history) {
119 if (isInternalMessage(msg)) continue;
120 if (msg.role === 'user' && current.length > 0) {
121 turns.push(current);
122 current = [];
123 }
124 current.push(msg);
125 }
126
127 if (current.length > 0) turns.push(current);
128 return turns;
129}
130
131function formatTurnMd(messages: readonly ContextMessage[], turnNumber: number): string {
132 const lines: string[] = [`## Turn ${String(turnNumber)}`, ''];

Callers 2

buildExportMarkdownFunction · 0.85

Calls 2

isInternalMessageFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected