From b9a7dcce92de433c1bb3b21647c7f4d352b12298 Mon Sep 17 00:00:00 2001 From: jedarden Date: Fri, 20 Mar 2026 00:34:07 -0400 Subject: [PATCH] feat(bd-4ka): Wire replay command into analytics pipeline Feed replay events into the store's analytics pipeline via store.add() in the onEvent callback, enabling worker analytics, error grouping, cross-reference tracking, collision detection, and semantic narrative generation during replay sessions. Print analytics summary on replay end. Co-Authored-By: Claude Code (glm-5-turbo) --- src/cli.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 518196c..299e5d2 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -10,16 +10,11 @@ */ import { Command } from 'commander'; -import blessed from 'blessed'; import { VERSION } from './index.js'; import { LogTailer, tailLogFile } from './tailer.js'; import { formatEvent } from './parser.js'; import { getStore } from './store.js'; -import { createTuiApp } from './tui/index.js'; import { createWebServer } from './web/index.js'; -import { SessionReplay } from './tui/components/SessionReplay.js'; -import { SessionDigestGenerator, formatDigestAsMarkdown } from './sessionDigest.js'; -import { getCostTracker } from './tui/utils/costTracking.js'; import * as fs from 'fs'; import type { LogLevel, EventFilter } from './types.js'; @@ -38,6 +33,7 @@ program const filePath = options.file.replace('~', process.env.HOME || ''); try { + const { createTuiApp } = await import('./tui/index.js'); const store = getStore(); const app = createTuiApp(store, { logPath: filePath }); @@ -243,6 +239,9 @@ program } try { + const blessed = (await import('blessed')).default; + const { SessionReplay } = await import('./tui/components/SessionReplay.js'); + // Create blessed screen const screen = blessed.screen({ smartCSR: true, @@ -250,6 +249,9 @@ program fullUnicode: true, }); + // Create store for analytics pipeline integration + const store = getStore(); + // Create session replay component const replay = new SessionReplay({ parent: screen, @@ -258,11 +260,12 @@ program width: '100%', height: '100%', onEvent: (event, index, total) => { - // Could emit to store if needed + store.add(event); }, onStateChange: (state) => { if (state === 'ended') { - // Show ended message + const summary = store.getAnalyticsSummary(); + console.error(`\nReplay complete. ${summary}`); } }, }); @@ -359,6 +362,8 @@ program console.error(`Loaded ${eventCount} events`); // Generate digest + const { SessionDigestGenerator, formatDigestAsMarkdown } = await import('./sessionDigest.js'); + const { getCostTracker } = await import('./tui/utils/costTracking.js'); const costTracker = getCostTracker(); const generator = new SessionDigestGenerator(store, costTracker);