"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const event_capture_1 = require("../walls/01-context/sessions/event-capture");
const database_1 = require("../walls/06-memory/database/database");
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
describe('Cross-Memory Event Capture (Phase 3)', () => {
    let originalHome;
    let tmpHome;
    beforeAll(() => {
        tmpHome = path.join(os.tmpdir(), 'fivo-cell-event-cap-' + Date.now());
        fs.mkdirSync(tmpHome, { recursive: true });
        originalHome = process.env.USERPROFILE;
        process.env.USERPROFILE = tmpHome;
        try {
            (0, database_1.closeDb)();
        }
        catch { /* ignore */ }
        (0, database_1.initializeDatabase)();
    });
    afterAll(() => {
        process.env.USERPROFILE = originalHome;
        try {
            (0, database_1.closeDb)();
        }
        catch { /* ignore */ }
        try {
            fs.rmSync(tmpHome, { recursive: true, force: true });
        }
        catch { /* ignore */ }
    });
    beforeEach(() => {
        try {
            (0, database_1.closeDb)();
        }
        catch { /* ignore */ }
        (0, database_1.initializeDatabase)();
        try {
            const db = (0, database_1.getDb)();
            db.exec('DELETE FROM live_events;');
        }
        catch { /* ignore */ }
    });
    // ─── ALL_EVENT_TYPES coverage ─────────────────────────────────────────
    describe('event type registry', () => {
        it('exports all 22 event types', () => {
            expect(event_capture_1.ALL_EVENT_TYPES.length).toBe(22);
        });
        it('includes file events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_save');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_create');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_delete');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_rename');
        });
        it('includes editor events (cursor + focus)', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('cursor_move');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_focus');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('file_blur');
        });
        it('includes terminal events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('terminal_command');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('terminal_command_done');
        });
        it('includes build/test events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('test_run');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('test_pass');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('test_fail');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('build_start');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('build_end');
        });
        it('includes git events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('git_commit');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('git_branch');
        });
        it('includes AI events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('ai_prompt');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('ai_response');
        });
        it('includes session lifecycle events', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('session_start');
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('session_end');
        });
        it('includes error event', () => {
            expect(event_capture_1.ALL_EVENT_TYPES).toContain('error');
        });
    });
    // ─── File events ─────────────────────────────────────────────────────
    describe('file events', () => {
        it('records file_save with file path', () => {
            const id = (0, event_capture_1.recordFileSave)({ project: 'fivo-cell', filePath: 'src/api/users.ts' });
            expect(id).toBeGreaterThan(0);
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events.length).toBe(1);
            expect(events[0].eventType).toBe('file_save');
            expect(events[0].filePath).toBe('src/api/users.ts');
        });
        it('records file_create', () => {
            const id = (0, event_capture_1.recordFileCreate)({ project: 'fivo-cell', filePath: 'src/new-file.ts' });
            expect(id).toBeGreaterThan(0);
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('file_create');
        });
        it('records file_delete', () => {
            (0, event_capture_1.recordFileDelete)({ project: 'fivo-cell', filePath: 'src/old.ts' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('file_delete');
        });
        it('records file_rename with newPath in metadata', () => {
            (0, event_capture_1.recordFileRename)({ project: 'fivo-cell', filePath: 'src/old.ts', newPath: 'src/new.ts' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('file_rename');
            expect(events[0].metadata.newPath).toBe('src/new.ts');
        });
    });
    // ─── Editor events (cursor + focus) ───────────────────────────────────
    describe('editor events', () => {
        it('records cursor_move with line + column', () => {
            (0, event_capture_1.recordCursorMove)({
                project: 'fivo-cell',
                filePath: 'src/api/auth.ts',
                line: 47,
                column: 12,
                selectionLength: 8,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('cursor_move');
            expect(events[0].line).toBe(47);
            expect(events[0].column).toBe(12);
            expect(events[0].metadata.selectionLength).toBe(8);
        });
        it('records file_focus with previousFile in metadata', () => {
            (0, event_capture_1.recordFileFocus)({
                project: 'fivo-cell',
                filePath: 'src/api/users.ts',
                previousFile: 'src/api/auth.ts',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('file_focus');
            expect(events[0].metadata.previousFile).toBe('src/api/auth.ts');
        });
        it('records file_blur', () => {
            (0, event_capture_1.recordFileBlur)({ project: 'fivo-cell', filePath: 'src/api/users.ts' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('file_blur');
        });
    });
    // ─── Terminal events ─────────────────────────────────────────────────
    describe('terminal events', () => {
        it('records terminal_command with command + cwd', () => {
            (0, event_capture_1.recordTerminalCommand)({
                project: 'fivo-cell',
                command: 'npm test',
                cwd: 'C:\\Users\\ss\\project',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('terminal_command');
            expect(events[0].command).toBe('npm test');
            expect(events[0].filePath).toBe('C:\\Users\\ss\\project');
        });
        it('records terminal_command_done with exit code + duration', () => {
            (0, event_capture_1.recordTerminalCommandDone)({
                project: 'fivo-cell',
                command: 'npm test',
                cwd: 'C:\\proj',
                exitCode: 0,
                durationMs: 12345,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('terminal_command_done');
            expect(events[0].exitCode).toBe(0);
            expect(events[0].durationMs).toBe(12345);
            expect(events[0].success).toBe(1);
        });
        it('records non-zero exit as failure', () => {
            (0, event_capture_1.recordTerminalCommandDone)({
                project: 'fivo-cell',
                command: 'npm test',
                cwd: 'C:\\proj',
                exitCode: 1,
                durationMs: 5000,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].success).toBe(0);
        });
    });
    // ─── Test events ─────────────────────────────────────────────────────
    describe('test events', () => {
        it('records test_run (no file)', () => {
            (0, event_capture_1.recordTestRun)({ project: 'fivo-cell' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('test_run');
        });
        it('records test_pass with duration', () => {
            (0, event_capture_1.recordTestPass)({
                project: 'fivo-cell',
                testFile: 'tests/api/auth.test.ts',
                testName: 'should validate email',
                durationMs: 234,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('test_pass');
            expect(events[0].filePath).toBe('tests/api/auth.test.ts');
            expect(events[0].command).toBe('should validate email');
            expect(events[0].success).toBe(1);
        });
        it('records test_fail with error message', () => {
            (0, event_capture_1.recordTestFail)({
                project: 'fivo-cell',
                testFile: 'tests/api/auth.test.ts',
                testName: 'should hash password',
                errorMessage: 'Expected bcrypt to be defined',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('test_fail');
            expect(events[0].success).toBe(0);
            expect(events[0].metadata.errorMessage).toBe('Expected bcrypt to be defined');
        });
    });
    // ─── Build events ────────────────────────────────────────────────────
    describe('build events', () => {
        it('records build_start with build type', () => {
            (0, event_capture_1.recordBuildStart)({ project: 'fivo-cell', buildType: 'tsc' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('build_start');
            expect(events[0].command).toBe('tsc');
        });
        it('records build_end with success + duration + error count', () => {
            (0, event_capture_1.recordBuildEnd)({
                project: 'fivo-cell',
                buildType: 'tsc',
                durationMs: 4500,
                success: false,
                errorCount: 3,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('build_end');
            expect(events[0].success).toBe(0);
            expect(events[0].durationMs).toBe(4500);
            expect(events[0].metadata.errorCount).toBe(3);
        });
    });
    // ─── Error events ────────────────────────────────────────────────────
    describe('error events', () => {
        it('records runtime error with stack trace', () => {
            (0, event_capture_1.recordError)({
                project: 'fivo-cell',
                errorMessage: 'Cannot read property of undefined',
                errorType: 'runtime',
                filePath: 'src/api/users.ts',
                line: 47,
                stackTrace: 'at users.ts:47\nat router.ts:12',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('error');
            expect(events[0].filePath).toBe('src/api/users.ts');
            expect(events[0].line).toBe(47);
            expect(events[0].command).toBe('runtime');
            expect(events[0].metadata.errorMessage).toBe('Cannot read property of undefined');
            expect(events[0].metadata.stackTrace).toContain('users.ts:47');
        });
    });
    // ─── Git events ──────────────────────────────────────────────────────
    describe('git events', () => {
        it('records git_commit with hash + branch', () => {
            (0, event_capture_1.recordGitCommit)({
                project: 'fivo-cell',
                commitHash: 'a3f4b2c',
                message: 'refactor: extract cross-memory capture',
                branch: 'main',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('git_commit');
            expect(events[0].command).toBe('refactor: extract cross-memory capture');
            expect(events[0].metadata.commitHash).toBe('a3f4b2c');
            expect(events[0].metadata.branch).toBe('main');
        });
        it('records git_branch with from + to + reason', () => {
            (0, event_capture_1.recordGitBranch)({
                project: 'fivo-cell',
                fromBranch: 'main',
                toBranch: 'feature/cross-memory',
                reason: 'checkout',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('git_branch');
            expect(events[0].filePath).toBe('feature/cross-memory');
            expect(events[0].command).toBe('main');
            expect(events[0].metadata.reason).toBe('checkout');
        });
    });
    // ─── AI events ───────────────────────────────────────────────────────
    describe('AI events', () => {
        it('records ai_prompt with tool + task + prompt', () => {
            (0, event_capture_1.recordAIPrompt)({
                project: 'fivo-cell',
                toolName: 'claude-code',
                taskType: 'refactor',
                prompt: 'Extract the event capture logic into a separate module',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('ai_prompt');
            expect(events[0].command).toBe('claude-code');
            expect(events[0].metadata.prompt).toContain('Extract the event capture');
        });
        it('records ai_response with accepted + duration', () => {
            (0, event_capture_1.recordAIResponse)({
                project: 'fivo-cell',
                toolName: 'claude-code',
                taskType: 'refactor',
                accepted: true,
                durationMs: 12500,
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('ai_response');
            expect(events[0].success).toBe(1);
            expect(events[0].durationMs).toBe(12500);
        });
    });
    // ─── Session lifecycle events ────────────────────────────────────────
    describe('session events', () => {
        it('records session_start and session_end', () => {
            (0, event_capture_1.recordSessionStart)({ project: 'fivo-cell', sessionId: 1, toolName: 'cursor' });
            (0, event_capture_1.recordSessionEnd)({ project: 'fivo-cell', sessionId: 1, toolName: 'cursor' });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events.length).toBe(2);
            expect(events[0].eventType).toBe('session_start');
            expect(events[1].eventType).toBe('session_end');
            expect(events[0].command).toBe('cursor');
        });
    });
    // ─── Package change events ───────────────────────────────────────────
    describe('package change', () => {
        it('records package_change with old + new version', () => {
            (0, event_capture_1.recordPackageChange)({
                project: 'fivo-cell',
                packageName: 'better-sqlite3',
                oldVersion: '12.0.0',
                newVersion: '12.10.0',
            });
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events[0].eventType).toBe('package_change');
            expect(events[0].command).toBe('better-sqlite3');
            expect(events[0].metadata.oldVersion).toBe('12.0.0');
            expect(events[0].metadata.newVersion).toBe('12.10.0');
        });
    });
    // ─── Timeline queries ────────────────────────────────────────────────
    describe('timeline queries', () => {
        beforeEach(() => {
            (0, event_capture_1.recordFileSave)({ project: 'fivo-cell', filePath: 'src/a.ts' });
            (0, event_capture_1.recordFileSave)({ project: 'fivo-cell', filePath: 'src/b.ts' });
            (0, event_capture_1.recordCursorMove)({ project: 'fivo-cell', filePath: 'src/a.ts', line: 10, column: 5 });
            (0, event_capture_1.recordTerminalCommand)({ project: 'fivo-cell', command: 'npm test', cwd: '/proj' });
            (0, event_capture_1.recordTestFail)({ project: 'fivo-cell', testFile: 'tests/a.test.ts', testName: 'test1', errorMessage: 'fail' });
            (0, event_capture_1.recordError)({ project: 'fivo-cell', errorMessage: 'oops', errorType: 'runtime' });
        });
        it('returns events in chronological order', () => {
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell' });
            expect(events.length).toBe(6);
            const times = events.map(e => e.createdAt);
            const sorted = [...times].sort();
            expect(times).toEqual(sorted);
        });
        it('filters by event type', () => {
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell', eventTypes: ['cursor_move'] });
            expect(events.length).toBe(1);
            expect(events[0].eventType).toBe('cursor_move');
        });
        it('filters by multiple event types', () => {
            const events = (0, event_capture_1.getTimeline)({
                project: 'fivo-cell',
                eventTypes: ['cursor_move', 'terminal_command', 'test_fail', 'error'],
            });
            expect(events.length).toBe(4);
        });
        it('filters by exact file path', () => {
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell', filePath: 'src/a.ts' });
            expect(events.length).toBe(2);
            events.forEach(e => expect(e.filePath).toBe('src/a.ts'));
        });
        it('filters by file pattern (LIKE)', () => {
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell', filePattern: 'src/%' });
            expect(events.length).toBe(3);
        });
        it('limits result count', () => {
            const events = (0, event_capture_1.getTimeline)({ project: 'fivo-cell', limit: 2 });
            expect(events.length).toBe(2);
        });
    });
    // ─── Event counts ────────────────────────────────────────────────────
    describe('event counts', () => {
        it('returns zero for all types on empty project', () => {
            const counts = (0, event_capture_1.getEventCounts)('empty-project');
            expect(counts.file_save).toBe(0);
            expect(counts.cursor_move).toBe(0);
            expect(counts.terminal_command).toBe(0);
            expect(counts.error).toBe(0);
        });
        it('counts each event type correctly', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts' });
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'b.ts' });
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'c.ts' });
            (0, event_capture_1.recordCursorMove)({ project: 'p1', filePath: 'a.ts', line: 1, column: 1 });
            (0, event_capture_1.recordError)({ project: 'p1', errorMessage: 'e1', errorType: 'runtime' });
            const counts = (0, event_capture_1.getEventCounts)('p1');
            expect(counts.file_save).toBe(3);
            expect(counts.cursor_move).toBe(1);
            expect(counts.error).toBe(1);
            expect(counts.terminal_command).toBe(0);
        });
    });
    // ─── Get last event for file ─────────────────────────────────────────
    describe('last event for file', () => {
        it('returns null for untouched file', () => {
            const ev = (0, event_capture_1.getLastEventForFile)('p1', 'nope.ts');
            expect(ev).toBeNull();
        });
        it('returns most recent event for file', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts' });
            (0, event_capture_1.recordCursorMove)({ project: 'p1', filePath: 'a.ts', line: 5, column: 0 });
            const ev = (0, event_capture_1.getLastEventForFile)('p1', 'a.ts');
            expect(ev).not.toBeNull();
            expect(ev.eventType).toBe('cursor_move');
        });
    });
    // ─── Get most recent events ──────────────────────────────────────────
    describe('most recent events', () => {
        it('returns newest first', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts' });
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'b.ts' });
            const events = (0, event_capture_1.getMostRecentEvents)('p1', 10);
            expect(events.length).toBe(2);
            expect(events[0].filePath).toBe('b.ts');
            expect(events[1].filePath).toBe('a.ts');
        });
    });
    // ─── Session linkage ─────────────────────────────────────────────────
    describe('session linkage', () => {
        it('links unlinked recent events to a session', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts' });
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'b.ts' });
            const linked = (0, event_capture_1.linkSessionToRecentEvents)('p1', 99);
            expect(linked).toBe(2);
            const events = (0, event_capture_1.getTimeline)({ project: 'p1', sessionId: 99 });
            expect(events.length).toBe(2);
        });
        it('does not re-link already linked events', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts', sessionId: 1 });
            const linked = (0, event_capture_1.linkSessionToRecentEvents)('p1', 99);
            expect(linked).toBe(0);
        });
        it('unlinks events from a session', () => {
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'a.ts', sessionId: 1 });
            (0, event_capture_1.recordFileSave)({ project: 'p1', filePath: 'b.ts', sessionId: 1 });
            const unlinked = (0, event_capture_1.unlinkSessionEvents)(1);
            expect(unlinked).toBe(2);
            const events = (0, event_capture_1.getTimeline)({ project: 'p1', sessionId: 1 });
            expect(events.length).toBe(0);
        });
    });
    // ─── Integration: full session lifecycle ─────────────────────────────
    describe('integration: full session flow', () => {
        it('records complete session: start → work → build → test → AI → end', () => {
            const sessionId = 42;
            (0, event_capture_1.recordSessionStart)({ project: 'p1', sessionId, toolName: 'cursor' });
            (0, event_capture_1.recordFileFocus)({ project: 'p1', sessionId, filePath: 'src/api/users.ts' });
            (0, event_capture_1.recordCursorMove)({ project: 'p1', sessionId, filePath: 'src/api/users.ts', line: 23, column: 4 });
            (0, event_capture_1.recordFileSave)({ project: 'p1', sessionId, filePath: 'src/api/users.ts' });
            (0, event_capture_1.recordTerminalCommand)({ project: 'p1', sessionId, command: 'npm test', cwd: '/p1' });
            (0, event_capture_1.recordTestRun)({ project: 'p1', sessionId });
            (0, event_capture_1.recordTestFail)({ project: 'p1', sessionId, testFile: 'tests/users.test.ts', testName: 'should hash', errorMessage: 'fail' });
            (0, event_capture_1.recordAIPrompt)({ project: 'p1', sessionId, toolName: 'cursor', taskType: 'debug', prompt: 'why test fail?' });
            (0, event_capture_1.recordAIResponse)({ project: 'p1', sessionId, toolName: 'cursor', taskType: 'debug', accepted: true, durationMs: 5000 });
            (0, event_capture_1.recordError)({ project: 'p1', sessionId, errorMessage: 'still failing', errorType: 'test' });
            (0, event_capture_1.recordBuildStart)({ project: 'p1', sessionId, buildType: 'tsc' });
            (0, event_capture_1.recordBuildEnd)({ project: 'p1', sessionId, buildType: 'tsc', durationMs: 3000, success: false, errorCount: 2 });
            (0, event_capture_1.recordGitCommit)({ project: 'p1', sessionId, commitHash: 'abc123', message: 'wip: debug test', branch: 'main' });
            (0, event_capture_1.recordSessionEnd)({ project: 'p1', sessionId, toolName: 'cursor' });
            const events = (0, event_capture_1.getTimeline)({ project: 'p1', sessionId });
            expect(events.length).toBe(14);
            const types = events.map(e => e.eventType);
            expect(types[0]).toBe('session_start');
            expect(types[types.length - 1]).toBe('session_end');
            expect(types).toContain('cursor_move');
            expect(types).toContain('file_save');
            expect(types).toContain('terminal_command');
            expect(types).toContain('test_fail');
            expect(types).toContain('ai_prompt');
            expect(types).toContain('ai_response');
            expect(types).toContain('build_start');
            expect(types).toContain('build_end');
            expect(types).toContain('git_commit');
        });
    });
});
//# sourceMappingURL=cross-memory-event-capture.test.js.map