"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const database_1 = require("../walls/06-memory/database/database");
beforeAll(() => {
    (0, database_1.initializeDatabase)();
});
describe('CLI command modules — smoke test', () => {
    it('failure-memory: SQLite persistence works', () => {
        const { recordFailure, getFailureStats, clearFailures } = require('../walls/03-knowledge/decisions/failure-memory');
        clearFailures();
        const p = { patternId: 'smoke-test', description: 'test', from: 'A', to: 'B', category: 'test', confidence: { distribution: 'beta', alpha: 1, beta: 1, mean: 0.5, ci95: [0.1, 0.9] }, conditions: [], signals: { positive: 0, negative: 0, total: 0, lastSignal: 0 }, attribution: { primaryCondition: 'test', conditionConfidence: 0.5, sourceFiles: [], note: '' }, scope: 'project', survivedDays: 0, meta: { language: 'ts', subcategory: 'general', complexity: 'low', risk: 'low', source: 'test' }, lifecycle: { firstSeen: 0, lastSeen: 0, version: 1, history: [] }, quality: { score: 0.5, reuseRate: 0, successRate: 0, failureRate: 0, acceptanceRate: 0, daysSinceLastSignal: 0, age: 0 }, relationships: { related: [], conflicting: [], complementary: [], dependencies: [] }, ranking: { score: 0.5, rank: 1, factors: { confidence: 0.5, quality: 0.5, usage: 0, recency: 0, acceptance: 0 } } };
        recordFailure(p, true, 'ts');
        recordFailure(p, true, 'ts');
        recordFailure(p, false, 'ts');
        const stats = getFailureStats();
        expect(stats.totalTracked).toBeGreaterThanOrEqual(1);
        clearFailures();
    });
    it('ai-bridge: generateAnalysisPrompts returns prompts', () => {
        const { generateAnalysisPrompts } = require('../walls/03-knowledge/decisions/ai-bridge');
        const prompts = generateAnalysisPrompts(process.cwd());
        expect(Array.isArray(prompts)).toBe(true);
    });
    it('ai-bridge: saveAIInsight + getAIInsights', () => {
        const { saveAIInsight, getAIInsights } = require('../walls/03-knowledge/decisions/ai-bridge');
        const testProject = `smoke-test-${Date.now()}`;
        saveAIInsight(testProject, 'test-category', 'test insight content');
        const insights = getAIInsights(testProject);
        expect(insights.length).toBeGreaterThanOrEqual(1);
        expect(insights[0].category).toBe('test-category');
    });
    it('focus-report: buildFocusReport returns valid structure', () => {
        const { buildFocusReport } = require('../walls/03-knowledge/decisions/focus-report');
        const report = buildFocusReport(process.cwd());
        expect(report).toHaveProperty('totalProjects');
        expect(report).toHaveProperty('active');
        expect(report).toHaveProperty('stalled');
        expect(report).toHaveProperty('abandoned');
        expect(report).toHaveProperty('topPicks');
        expect(report).toHaveProperty('overallAdvice');
    });
    it('focus-report: renderFocusMd produces markdown', () => {
        const { buildFocusReport, renderFocusMd } = require('../walls/03-knowledge/decisions/focus-report');
        const report = buildFocusReport(process.cwd());
        const md = renderFocusMd(report);
        expect(md).toContain('Focus Report');
    });
    it('behavioral-tracker: decisions are SQLite-backed', () => {
        const db = (0, database_1.getDb)();
        const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='decision_log'").get();
        expect(tables).toBeDefined();
    });
    it('stack_history table exists', () => {
        const db = (0, database_1.getDb)();
        const table = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='stack_history'").get();
        expect(table).toBeDefined();
    });
    it('cell why — decision search queries work', () => {
        const db = (0, database_1.getDb)();
        const decisions = db.prepare("SELECT COUNT(*) as c FROM decisions").get();
        const decisionOutcomes = db.prepare("SELECT COUNT(*) as c FROM decision_outcomes").get();
        const decisionLog = db.prepare("SELECT COUNT(*) as c FROM decision_log").get();
        expect(typeof decisions.c).toBe('number');
        expect(typeof decisionOutcomes.c).toBe('number');
        expect(typeof decisionLog.c).toBe('number');
    });
    it('REPL commands include focus + why', () => {
        const { REPL_COMMAND_NAMES } = require('../walls/07-runtime/cli/cli-repl');
        expect(REPL_COMMAND_NAMES).toContain('focus');
        expect(REPL_COMMAND_NAMES).toContain('why');
        expect(REPL_COMMAND_NAMES).toContain('replay');
        expect(REPL_COMMAND_NAMES).toContain('continue');
        expect(REPL_COMMAND_NAMES).toContain('bridge');
        expect(REPL_COMMAND_NAMES).toContain('lessons');
        expect(REPL_COMMAND_NAMES).toContain('evolution');
        expect(REPL_COMMAND_NAMES).toContain('switch-back');
    });
});
//# sourceMappingURL=cli-smoke.test.js.map