#!/usr/bin/env node import { Command } from 'commander'; import { registerStartCommand } from './start.js'; import { registerSendCommand } from './send.js'; import { registerSessionsCommand } from './sessions.js'; import { registerDoctorCommand } from './doctor.js'; import { registerConfigCommand } from './config-cmd.js'; import { registerTuiCommand } from './tui.js'; export function createProgram(): Command { const program = new Command(); program .name('flynn') .description('Flynn — self-hosted personal AI agent') .version('0.1.0'); registerStartCommand(program); registerTuiCommand(program); registerSendCommand(program); registerSessionsCommand(program); registerDoctorCommand(program); registerConfigCommand(program); return program; } // Only run when executed directly (not imported in tests) const isDirectRun = process.argv[1] && (process.argv[1].endsWith('/cli/index.js') || process.argv[1].endsWith('/cli/index.ts')); if (isDirectRun) { const program = createProgram(); program.parse(process.argv); }