Remove allowDuringStreaming flag - commands always run immediately

Hook commands now always execute immediately, even during streaming.
If a command needs to interact with the LLM, it uses pi.sendMessage()
which handles queueing automatically.

This simplifies the API and eliminates the issue of queued slash
commands being sent to the LLM instead of executing.
This commit is contained in:
Mario Zechner 2025-12-28 16:54:43 +01:00
parent f8352bb7d7
commit 575c875475
5 changed files with 66 additions and 78 deletions

View file

@ -442,8 +442,7 @@ export interface HookCommandContext {
export interface RegisteredCommand {
name: string;
description?: string;
/** If true, command runs during streaming instead of being queued */
allowDuringStreaming?: boolean;
handler: (ctx: HookCommandContext) => Promise<void>;
}
@ -456,9 +455,9 @@ export interface HookAPI {
on(event: "session", handler: HookHandler<SessionEvent, SessionEventResult | void>): void;
// biome-ignore lint/suspicious/noConfusingVoidType: void allows handlers to not return anything
on(event: "context", handler: HookHandler<ContextEvent, ContextEventResult | void>): void;
// biome-ignore lint/suspicious/noConfusingVoidType: void allows handlers to not return anything
on(
event: "before_agent_start",
// biome-ignore lint/suspicious/noConfusingVoidType: void allows handlers to not return anything
handler: HookHandler<BeforeAgentStartEvent, BeforeAgentStartEventResult | void>,
): void;
on(event: "agent_start", handler: HookHandler<AgentStartEvent>): void;
@ -527,10 +526,7 @@ export interface HookAPI {
* Register a custom slash command.
* Handler receives HookCommandContext.
*/
registerCommand(
name: string,
options: { description?: string; allowDuringStreaming?: boolean; handler: RegisteredCommand["handler"] },
): void;
registerCommand(name: string, options: { description?: string; handler: RegisteredCommand["handler"] }): void;
/**
* Execute a shell command and return stdout/stderr/code.