import chalk from "chalk"; import { loadConfig, getApiBase } from "../auth/config.js"; import { createClient } from "../auth/client.js"; import { startRepl } from "../repl/repl.js"; export async function chatCommand(options: { model?: string; stream?: boolean; }) { const config = loadConfig(); if (!config.apiKey) { console.log(chalk.red('No API key configured. Run "llmtune login" first.')); process.exit(1); } const client = createClient(); const model = options.model || (config.defaultModel as string) || "z-ai/GLM-5.1"; const stream = options.stream !== false; console.log(chalk.cyan(`\nLLMTune CLI`)); console.log(chalk.dim(`Connected to ${getApiBase()}`)); console.log(chalk.dim(`Model: ${model}`)); console.log(chalk.dim(`Stream: ${stream}`)); console.log(chalk.dim(`Type /help for commands, /exit to quit\n`)); await startRepl({ client, model, stream }); }