import { checkPreflight } from "../steps/preflight.js"; import { installHomebrew } from "../steps/homebrew.js"; import { installOllama } from "../steps/llama.js"; import { downloadModels } from "../steps/models.js"; import { installTools } from "../steps/tools.js"; import { createLauncherScripts } from "../steps/scripts.js"; import { writeTuiConfig } from "../steps/aider-config.js"; import { addToPath } from "../steps/shell-path.js"; import { OLLAMA_PORT } from "../config.js"; import { getActiveChatModel, getActiveAutocompleteModel, getActiveTui, } from "../runtime-config.js"; const BOLD = "\x1b[1m"; const GREEN = "\x1b[0;32m"; const RESET = "\x1b[0m"; function printSummary(): void { const chatModel = getActiveChatModel(); const autocompleteModel = getActiveAutocompleteModel(); const tui = getActiveTui(); const shellRC = process.env.SHELL?.endsWith("/zsh") !== false ? "~/.zshrc" : process.env.SHELL?.endsWith("/bash") ? "~/.bashrc" : "~/.profile"; console.log(""); console.log( `${GREEN}${BOLD}═══════════════════════════════════════════════════${RESET}`, ); console.log(`${GREEN}${BOLD} Setup complete!${RESET}`); console.log( `${GREEN}${BOLD}═══════════════════════════════════════════════════${RESET}`, ); console.log(""); console.log(` ${BOLD}Backend:${RESET} Ollama on port ${OLLAMA_PORT}`); console.log( ` Chat: ${chatModel.name} (${chatModel.ollamaTag})`, ); console.log( ` Autocomplete: ${autocompleteModel.name} (${autocompleteModel.ollamaTag})`, ); console.log(""); console.log(` ${BOLD}Active TUI:${RESET} ${tui.name}`); console.log(""); console.log(` ${BOLD}Usage:${RESET}`); console.log(` ${BOLD}localcode${RESET} Launch ${tui.name} in current directory`); console.log(` ${BOLD}localcode start${RESET} Start Ollama + pull models`); console.log(` ${BOLD}localcode stop${RESET} Stop Ollama`); console.log(` ${BOLD}localcode status${RESET} Show config and server health`); console.log(""); console.log( ` Run ${BOLD}source ${shellRC}${RESET} or open a new terminal to get started.`, ); console.log(""); } export async function runSetup(): Promise { console.log( `\n${BOLD}Local AI Coding Environment Installer (Ollama)${RESET}\n`, ); checkPreflight(); installHomebrew(); installOllama(); downloadModels(); installTools(); await createLauncherScripts(); await writeTuiConfig(); addToPath(); printSummary(); }