UNPKG

@reliverse/rse-sdk

Version:

@reliverse/rse-sdk allows you to create new plugins for @reliverse/rse CLI, interact with reliverse.org, and even extend your own CLI functionality (you may also try @reliverse/dler-sdk for this case).

33 lines (32 loc) 906 B
import { inputPrompt } from "@reliverse/rempts"; import { ensureOpenAIKey } from "./ai-auth.js"; import { AGENT_NAMES } from "./ai-const.js"; import { agentRelinter } from "./relinter/relinter.js"; export async function aiAgenticTool({ config, agent, isKeyEnsured, memory, target }) { if (!AGENT_NAMES.includes(agent)) { throw new Error("Invalid agent specified."); } if (!isKeyEnsured && memory === void 0) { throw new Error("Memory is undefined"); } if (!isKeyEnsured && memory !== void 0) { await ensureOpenAIKey(memory); } if (agent === "relinter") { let targetPath = target; if (!targetPath) { 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); } }