/** * Slash Command Registry for Zoe CLI. * * Flat namespace of `/command` handlers with alias support. * * Consistent contract: every handler returns a `CommandResult` describing what * to render (`output`) and whether to terminate (`exit`). Handlers never write * to stdout directly — the adapter renders the result (readline prints it; the * TUI appends it to the feed). Lookup order: exact match → alias → skill * invocation → unknown. * * `interactive` marks handlers that take over stdin/stdout themselves (inquirer * wizards, ora spinners). They keep working in the readline REPL but cannot run * under the TUI's stdin ownership — the TUI defers them. */ import type { Agent } from '../agent.js'; import type { SkillRegistry } from '../../../skills/types.js'; export interface CommandContext { agent: Agent; args: string; config: any; } /** * A handler's outcome. `output` is the text the adapter renders (undefined if * the handler produced none). `exit` signals the session should terminate. */ export interface CommandResult { output?: string; exit?: boolean; } export type CommandHandler = (ctx: CommandContext) => Promise; export interface CommandEntry { name: string; handler: CommandHandler; description: string; aliases: string[]; hidden?: boolean; /** Handler owns stdin/stdout (inquirer/ora) — TUI-deferred, readline-only. */ interactive?: boolean; } export type DispatchStatus = 'handled' | 'fallthrough' | 'exit'; export interface DispatchResult { status: DispatchStatus; output?: string; } export declare class CommandRegistry { private commands; private aliasMap; register(name: string, handler: CommandHandler, options: { description: string; aliases?: string[]; hidden?: boolean; interactive?: boolean; }): void; /** Resolve a raw input string to its command entry (exact or alias), or null. */ resolveCommand(input: string): CommandEntry | null; /** * Dispatch a raw user input string. Handlers return their output; the caller * renders it. Returns `fallthrough` for non-commands and unmatched skills. */ dispatch(input: string, ctx: CommandContext, skillRegistry: SkillRegistry | null): Promise; /** * Generate help text. * @param showAll If true, include hidden commands and aliases. * @param skillRegistry If provided, list loaded skills. */ help(showAll?: boolean, skillRegistry?: SkillRegistry | null): string; /** Get all registered command entries. */ getAll(): CommandEntry[]; }