import { TUIS, getTuiById } from "../registry/tuis.js"; import { loadConfig, saveConfig, getActiveTui } from "../runtime-config.js"; import { createLauncherScripts } from "../steps/scripts.js"; import { writeTuiConfig } from "../steps/aider-config.js"; import { commandExists, runPassthrough } from "../util.js"; import { log, err } from "../log.js"; const BOLD = "\x1b[1m"; const GREEN = "\x1b[0;32m"; const DIM = "\x1b[2m"; const RESET = "\x1b[0m"; export function listTuis(): void { const activeId = getActiveTui().id; console.log(`\n${BOLD}Available TUIs:${RESET}`); for (const t of TUIS) { const active = t.id === activeId ? ` ${GREEN}<- active${RESET}` : ""; const installed = commandExists(t.checkCmd) ? "" : ` ${DIM}(not installed)${RESET}`; console.log(` ${BOLD}${t.id}${RESET} ${t.name}${active}${installed}`); } console.log(""); } export async function setTui(id: string): Promise { const tui = getTuiById(id); if (!tui) { err( `Unknown TUI: ${id}\nAvailable: ${TUIS.map((t) => t.id).join(", ")}`, ); } // Install if needed if (!commandExists(tui.checkCmd)) { log(`Installing ${tui.name}...`); runPassthrough(tui.installCmd); } const config = loadConfig(); config.tui = id; saveConfig(config); log(`Active TUI set to ${tui.name}`); // Regenerate scripts and configs await createLauncherScripts(); await writeTuiConfig(); log("Launcher scripts and configs regenerated."); }