UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

41 lines (40 loc) 1.44 kB
import { inputPrompt, selectPrompt } from "@reliverse/rempts"; import { experimental } from "../utils/badgeNotifiers.js"; import { ensureOpenAIKey } from "./ai-impl/ai-auth.js"; import { aiChat } from "./ai-impl/ai-chat.js"; import { agentRelinter } from "./ai-impl/relinter/relinter.js"; const RANDOM_HINTS = [ "You can always exit by typing thing like 'bye', 'exit', or just by pressing Ctrl+C.", "While chatting, use @relinter with paths to lint specific files or directories." ]; export async function aiMenu(config, isKeyEnsured, memory) { if (!isKeyEnsured && memory === void 0) { throw new Error("Memory is undefined"); } if (!isKeyEnsured && memory !== void 0) { await ensureOpenAIKey(memory); } const choice = await selectPrompt({ title: "rse AI", content: `Random hint: ${RANDOM_HINTS[Math.floor(Math.random() * RANDOM_HINTS.length)]}`, options: [ { label: "Talk to rse", value: "chat" }, { label: "Use Relinter Agent", value: "relinter", hint: experimental }, { label: "Exit", value: "exit" } ] }); if (choice === "chat") { await aiChat(config); } else if (choice === "relinter") { const targetPath = await inputPrompt({ title: "Relinter", content: "Enter the path to the file or directory to lint:" }); const userPaths = targetPath.split(/\s+/).filter(Boolean); await agentRelinter(config, userPaths); } }