UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

55 lines • 2.44 kB
/** `satisfies` makes a new `PackageCommand` member a compile error here instead of a dead route. */ const PACKAGE_COMMAND_ARGV = { install: true, remove: true, update: true, list: true, }; /** `parsePackageCommand()` maps this alias onto `remove`. */ const PACKAGE_COMMAND_ALIAS = "uninstall"; export const CONFIG_COMMAND_ARGV = "config"; export const HOST_COMMAND_ARGV = "host"; export const SCHEDULE_COMMAND_ARGV = "schedule"; /** True when argv[0] selects a package-manager verb, matching `parsePackageCommand()`. */ export function isPackageCommandArgv(args) { const command = args[0] ?? ""; return Object.hasOwn(PACKAGE_COMMAND_ARGV, command) || command === PACKAGE_COMMAND_ALIAS; } export async function dispatchPackageCommand(args, runtimeOptions = {}) { if (!isPackageCommandArgv(args)) return false; const { handlePackageCommand } = await import("../package-manager-cli.js"); return await handlePackageCommand(args, runtimeOptions); } export async function dispatchConfigCommand(args, runtimeOptions = {}) { if (args[0] !== CONFIG_COMMAND_ARGV) return false; const { handleConfigCommand } = await import("../package-manager-cli.js"); return await handleConfigCommand(args, runtimeOptions); } /** * The daemon command answers with an EXIT CODE rather than a boolean: `senpi host` classifies its * outcome (refused, fallback, unusable spec) in that code, and a caller parses it without reading * the JSON line. `undefined` means this argv is not a host command at all. */ export async function dispatchHostCommand(args) { if (args[0] !== HOST_COMMAND_ARGV) return undefined; if (args[1] === "session") { const { runHostSessionCommand } = await import("./host-session-command.js"); return await runHostSessionCommand(args.slice(2)); } const { runHostCommand } = await import("./host-command.js"); return await runHostCommand(args.slice(1)); } /** * `senpi schedule` fires durable scheduled prompts out of process; like `host` it answers with an * exit code, and `undefined` means this argv is not a schedule command. */ export async function dispatchScheduleCommand(args) { if (args[0] !== SCHEDULE_COMMAND_ARGV) return undefined; const { runScheduleCommand } = await import("./schedule-command.js"); return await runScheduleCommand(args.slice(1)); } //# sourceMappingURL=deferred-commands.js.map