feat(coding-agent): extension command argument autocomplete

This commit is contained in:
Rafał Krzyważnia 2026-01-16 02:30:55 +01:00 committed by Mario Zechner
parent f900eb591d
commit 35e48ca018
5 changed files with 25 additions and 2 deletions

View file

@ -150,7 +150,7 @@ function createExtensionAPI(
});
},
registerCommand(name: string, options: { description?: string; handler: RegisteredCommand["handler"] }): void {
registerCommand(name: string, options: Omit<RegisteredCommand, "name">): void {
extension.commands.set(name, { name, ...options });
},

View file

@ -16,6 +16,7 @@ import type {
} from "@mariozechner/pi-agent-core";
import type { ImageContent, Model, TextContent, ToolResultMessage } from "@mariozechner/pi-ai";
import type {
AutocompleteItem,
Component,
EditorComponent,
EditorTheme,
@ -655,6 +656,7 @@ export type MessageRenderer<T = unknown> = (
export interface RegisteredCommand {
name: string;
description?: string;
getArgumentCompletions?: (argumentPrefix: string) => AutocompleteItem[] | null;
handler: (args: string, ctx: ExtensionCommandContext) => Promise<void>;
}
@ -714,7 +716,7 @@ export interface ExtensionAPI {
// =========================================================================
/** Register a custom command. */
registerCommand(name: string, options: { description?: string; handler: RegisteredCommand["handler"] }): void;
registerCommand(name: string, options: Omit<RegisteredCommand, "name">): void;
/** Register a keyboard shortcut. */
registerShortcut(

View file

@ -319,6 +319,7 @@ export class InteractiveMode {
(cmd) => ({
name: cmd.name,
description: cmd.description ?? "(extension command)",
getArgumentCompletions: cmd.getArgumentCompletions,
}),
);