UNPKG

pyb-ts

Version:

PYB-CLI - Minimal AI Agent with multi-model support and CLI interface

85 lines (84 loc) 2.62 kB
import bug from "./commands/bug.js"; import clear from "./commands/clear.js"; import compact from "./commands/compact.js"; import config from "./commands/config.js"; import cost from "./commands/cost.js"; import ctx_viz from "./commands/ctx_viz.js"; import doctor from "./commands/doctor.js"; import help from "./commands/help.js"; import init from "./commands/init.js"; import listen from "./commands/listen.js"; import login from "./commands/login.js"; import logout from "./commands/logout.js"; import mcp from "./commands/mcp.js"; import * as model from "./commands/model.js"; import modelstatus from "./commands/modelstatus.js"; import onboarding from "./commands/onboarding.js"; import pr_comments from "./commands/pr_comments.js"; import refreshCommands from "./commands/refreshCommands.js"; import releaseNotes from "./commands/release-notes.js"; import review from "./commands/review.js"; import terminalSetup from "./commands/terminalSetup.js"; import resume from "./commands/resume.js"; import agents from "./commands/agents.js"; import { getMCPCommands } from "./services/mcpClient.js"; import { loadCustomCommands } from "./services/customCommands.js"; import { memoize } from "lodash-es"; import { isAnthropicAuthEnabled } from "./utils/auth.js"; const INTERNAL_ONLY_COMMANDS = [ctx_viz, resume, listen]; const COMMANDS = memoize(() => [ agents, clear, compact, config, cost, doctor, help, init, mcp, model, modelstatus, onboarding, pr_comments, refreshCommands, releaseNotes, bug, review, terminalSetup, ...isAnthropicAuthEnabled() ? [logout, login()] : [], ...INTERNAL_ONLY_COMMANDS ]); const getCommands = memoize(async () => { const [mcpCommands, customCommands] = await Promise.all([ getMCPCommands(), loadCustomCommands() ]); return [...mcpCommands, ...customCommands, ...COMMANDS()].filter( (_) => _.isEnabled ); }); function hasCommand(commandName, commands) { return commands.some( (_) => _.userFacingName() === commandName || _.aliases?.includes(commandName) ); } function getCommand(commandName, commands) { const command = commands.find( (_) => _.userFacingName() === commandName || _.aliases?.includes(commandName) ); if (!command) { throw ReferenceError( `Command ${commandName} not found. Available commands: ${commands.map((_) => { const name = _.userFacingName(); return _.aliases ? `${name} (aliases: ${_.aliases.join(", ")})` : name; }).join(", ")}` ); } return command; } export { getCommand, getCommands, hasCommand }; //# sourceMappingURL=commands.js.map