import { Command } from 'commander' import { createAgentCommand } from './commands/agent/index.js' import { createDaemonCommand } from './commands/daemon/index.js' import { createPermitCommand } from './commands/permit/index.js' import { createProviderCommand } from './commands/provider/index.js' import { createSpeechCommand } from './commands/speech/index.js' import { createWorktreeCommand } from './commands/worktree/index.js' import { startCommand as daemonStartCommand } from './commands/daemon/start.js' import { runStatusCommand as runDaemonStatusCommand } from './commands/daemon/status.js' import { runRestartCommand as runDaemonRestartCommand } from './commands/daemon/restart.js' import { runLsCommand } from './commands/agent/ls.js' import { runRunCommand } from './commands/agent/run.js' import { runLogsCommand } from './commands/agent/logs.js' import { runStopCommand } from './commands/agent/stop.js' import { runSendCommand } from './commands/agent/send.js' import { runInspectCommand } from './commands/agent/inspect.js' import { runWaitCommand } from './commands/agent/wait.js' import { runAttachCommand } from './commands/agent/attach.js' import { runUpdateCommand } from './commands/agent/update.js' import { withOutput } from './output/index.js' import { onboardCommand } from './commands/onboard.js' const VERSION = '0.1.0' // Helper function to collect multiple option values into an array function collectMultiple(value: string, previous: string[]): string[] { return previous.concat([value]) } export function createCli(): Command { const program = new Command() program .name('paseo') .description('Paseo CLI - control your AI coding agents from the command line') .version(VERSION, '-v, --version', 'output the version number') // Global output options .option('-o, --format ', 'output format: table, json, yaml', 'table') .option('--json', 'output in JSON format (alias for --format json)') .option('-q, --quiet', 'minimal output (IDs only)') .option('--no-headers', 'omit table headers') .option('--no-color', 'disable colored output') // Primary agent commands (top-level) program .command('ls') .description('List agents. By default excludes archived agents.') .option('-a, --all', 'Include archived agents') .option('-g, --global', 'Legacy no-op (kept for compatibility)') .option('--label ', 'Filter by label (can be used multiple times)', collectMultiple, []) .option('--json', 'Output in JSON format') .option('--host ', 'Daemon host:port (default: localhost:6767)') .action(withOutput(runLsCommand)) program .command('run') .description('Create and start an agent with a task') .argument('', 'The task/prompt for the agent') .option('-d, --detach', 'Run in background (detached)') .option('--name ', 'Assign a name/title to the agent') .option('--provider ', 'Agent provider: claude | codex | opencode', 'claude') .option('--model ', 'Model to use (e.g., claude-sonnet-4-20250514, claude-3-5-haiku-20241022)') .option('--mode ', 'Provider-specific mode (e.g., plan, default, bypass)') .option('--worktree ', 'Create agent in a new git worktree') .option('--base ', 'Base branch for worktree (default: current branch)') .option('--image ', 'Attach image(s) to the initial prompt (can be used multiple times)', collectMultiple, []) .option('--cwd ', 'Working directory (default: current)') .option('--label ', 'Add label(s) to the agent (can be used multiple times)', collectMultiple, []) .option('--ui', 'Mark as UI agent (equivalent to --label ui=true)') .option('--json', 'Output in JSON format') .option('--host ', 'Daemon host:port (default: localhost:6767)') .action(withOutput(runRunCommand)) program .command('attach') .description("Attach to a running agent's output stream") .argument('', 'Agent ID (or prefix)') .option('--host ', 'Daemon host:port (default: localhost:6767)') .action(runAttachCommand) program .command('logs') .description('View agent activity/timeline') .argument('', 'Agent ID (or prefix)') .option('-f, --follow', 'Follow log output (streaming)') .option('--tail ', 'Show last n entries') .option('--filter ', 'Filter by event type (tools, text, errors, permissions)') .option('--since