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

Function sessionToJSON

scripts/tmux/tmux-viewer/session-loader.ts:212–233  ·  view source on GitHub ↗
(data: SessionData)

Source from the content-addressed store, hash-verified

210 * Convert session data to JSON format for AI consumption
211 */
212export function sessionToJSON(data: SessionData): SessionJSON {
213 const timeline = buildTimeline(data.commands, data.captures)
214
215 return {
216 session: data.sessionInfo,
217 commands: data.commands,
218 captures: data.captures.map((cap) => ({
219 sequence: cap.frontMatter.sequence,
220 label: cap.frontMatter.label,
221 timestamp: cap.frontMatter.timestamp,
222 after_command: cap.frontMatter.after_command,
223 dimensions: cap.frontMatter.dimensions,
224 path: cap.path,
225 content: cap.content,
226 })),
227 timeline: timeline.map((entry) => ({
228 timestamp: entry.timestamp,
229 type: entry.type,
230 data: entry.type === 'command' ? entry.command! : entry.capture!,
231 })),
232 }
233}

Callers 2

runViewerFunction · 0.90
handleJsonOutputFunction · 0.90

Calls 1

buildTimelineFunction · 0.85

Tested by

no test coverage detected