import { describe, it, expect } from 'vitest'; import { Command } from 'commander'; import { registerMemoryCommand } from './cli.js'; /** * Smoke test — only verifies command wiring. * Does NOT open a database connection. */ describe('registerMemoryCommand', () => { function buildProgram(): Command { const program = new Command('mosaic'); program.exitOverride(); // prevent process.exit during tests registerMemoryCommand(program); return program; } it('registers a "memory" subcommand', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory'); expect(memory).toBeDefined(); }); it('registers "memory search"', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory')!; const search = memory.commands.find((c) => c.name() === 'search'); expect(search).toBeDefined(); }); it('registers "memory stats"', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory')!; const stats = memory.commands.find((c) => c.name() === 'stats'); expect(stats).toBeDefined(); }); it('registers "memory insights list"', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory')!; const insights = memory.commands.find((c) => c.name() === 'insights'); expect(insights).toBeDefined(); const list = insights!.commands.find((c) => c.name() === 'list'); expect(list).toBeDefined(); }); it('registers "memory preferences list"', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory')!; const preferences = memory.commands.find((c) => c.name() === 'preferences'); expect(preferences).toBeDefined(); const list = preferences!.commands.find((c) => c.name() === 'list'); expect(list).toBeDefined(); }); it('"memory search" has --limit and --agent options', () => { const program = buildProgram(); const memory = program.commands.find((c) => c.name() === 'memory')!; const search = memory.commands.find((c) => c.name() === 'search')!; const optNames = search.options.map((o) => o.long); expect(optNames).toContain('--limit'); expect(optNames).toContain('--agent'); }); });