"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cli_repl_1 = require("../walls/07-runtime/cli/cli-repl");
describe('repl (interactive mode)', () => {
    describe('replCompleter', () => {
        it('returns all commands when user types just /', () => {
            const [matches, original] = (0, cli_repl_1.replCompleter)('/');
            expect(matches).toEqual(cli_repl_1.REPL_COMMAND_NAMES);
            expect(original).toBe('/');
        });
        it('filters commands by prefix after /', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/s');
            expect(matches).toContain('start');
            expect(matches).toContain('setup');
            expect(matches).toContain('scan');
            expect(matches).toContain('stop');
            expect(matches).toContain('status');
            expect(matches).toContain('session');
            expect(matches).not.toContain('help');
            expect(matches).not.toContain('exit');
        });
        it('narrows to a single match for exact prefix', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/set');
            expect(matches).toEqual(['setup']);
        });
        it('falls back to all commands when no match', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/xyz');
            expect(matches).toEqual(cli_repl_1.REPL_COMMAND_NAMES);
        });
        it('returns no matches when input does not start with /', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('scan');
            expect(matches).toEqual([]);
        });
        it('handles /help', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/help');
            expect(matches).toEqual(['help']);
        });
        it('handles /exit', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/exit');
            expect(matches).toEqual(['exit']);
        });
        it('handles /context (multi-char match)', () => {
            const [matches] = (0, cli_repl_1.replCompleter)('/co');
            expect(matches).toContain('community');
            expect(matches).toContain('context');
            expect(matches).not.toContain('start');
        });
    });
    describe('REPL_COMMANDS registry', () => {
        it('contains all 19 top-level commands', () => {
            expect(cli_repl_1.REPL_COMMANDS.length).toBe(28);
        });
        it('every entry has a non-empty name and description', () => {
            for (const [name, desc] of cli_repl_1.REPL_COMMANDS) {
                expect(name).toBeTruthy();
                expect(desc).toBeTruthy();
                expect(name.length).toBeGreaterThan(0);
                expect(desc.length).toBeGreaterThan(5);
            }
        });
        it('names are unique', () => {
            const names = cli_repl_1.REPL_COMMANDS.map(([n]) => n);
            expect(new Set(names).size).toBe(names.length);
        });
        it('REPL_COMMAND_NAMES matches REPL_COMMANDS in order', () => {
            const fromPairs = cli_repl_1.REPL_COMMANDS.map(([n]) => n);
            expect(cli_repl_1.REPL_COMMAND_NAMES).toEqual(fromPairs);
        });
        it('includes all major commands', () => {
            const required = ['start', 'stop', 'setup', 'scan', 'status', 'watch', 'context', 'mcp-config', 'help', 'exit'];
            for (const r of required) {
                expect(cli_repl_1.REPL_COMMAND_NAMES).toContain(r);
            }
        });
    });
});
//# sourceMappingURL=repl.test.js.map