import type { Static, TSchema } from "@earendil-works/pi-ai"; import type { ExtensionAPI, ExtensionCommandContext, ExtensionUIDialogOptions, RegisteredCommand, } from "@earendil-works/pi-coding-agent"; import type { AutocompleteItem } from "@earendil-works/pi-tui"; import type { PiToolShell } from "../types.ts"; /** Executes a Pi slash command with parsed command parameters. */ export type CommandExecute = ( params: TParams, ctx?: PiCommandContext, ) => Promise | PiToolShell; /** Completion item returned by Pi slash-command argument completion handlers. */ export type PiCommandCompletion = AutocompleteItem; /** Supplies argument completions for a Pi slash command. */ export type CommandArgumentCompletions = NonNullable; /** Parses a raw Pi slash-command argument string into typed command parameters. */ export type CommandArgumentParser = (args: string) => TParams; /** Public Pi command definition for Gemini ACP slash commands. */ export interface GeminiCommand { name: `gemini-${string}`; description: string; parameters: TParameters; getArgumentCompletions?: CommandArgumentCompletions; parseArgs?: CommandArgumentParser>; execute: CommandExecute>; } /** Options accepted by Pi UI dialog methods. */ export type PiUIDialogOptions = ExtensionUIDialogOptions; /** Minimal subset of the real Pi extension command context the handler relies on. */ export type PiCommandContext = Partial< Omit, "ui"> > & { session?: unknown; settings?: unknown; auth?: unknown; ui?: Partial>; }; /** Slash command handler shape expected by the Pi host. */ export type PiCommandHandler = (args: string, ctx: PiCommandContext) => Promise; /** Options accepted by `pi.registerCommand`, mirroring the host's signature. */ export type PiCommandOptions = Omit; /** Pi host surface needed to register slash commands (host signature: name + options). */ export type PiCommandRegistrar = Pick; /** Preserves generic schema inference for Gemini command definitions. */ export function defineGeminiCommand( command: GeminiCommand, ): GeminiCommand { return command; }