From 09774da43c16c8408eefd94952a700db4533b872 Mon Sep 17 00:00:00 2001 From: Mahima Shanware Date: Thu, 26 Mar 2026 16:51:49 +0000 Subject: [PATCH] feat(cli): add /btw command architecture and types --- .../cli/src/services/BuiltinCommandLoader.ts | 2 ++ packages/cli/src/ui/commands/btwCommand.ts | 33 +++++++++++++++++++ packages/cli/src/ui/commands/types.ts | 8 ++++- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 packages/cli/src/ui/commands/btwCommand.ts diff --git a/packages/cli/src/services/BuiltinCommandLoader.ts b/packages/cli/src/services/BuiltinCommandLoader.ts index c1cbd5621e..0089a6ab65 100644 --- a/packages/cli/src/services/BuiltinCommandLoader.ts +++ b/packages/cli/src/services/BuiltinCommandLoader.ts @@ -21,6 +21,7 @@ import { import { aboutCommand } from '../ui/commands/aboutCommand.js'; import { agentsCommand } from '../ui/commands/agentsCommand.js'; import { authCommand } from '../ui/commands/authCommand.js'; +import { btwCommand } from '../ui/commands/btwCommand.js'; import { bugCommand } from '../ui/commands/bugCommand.js'; import { chatCommand, debugCommand } from '../ui/commands/chatCommand.js'; import { clearCommand } from '../ui/commands/clearCommand.js'; @@ -120,6 +121,7 @@ export class BuiltinCommandLoader implements ICommandLoader { aboutCommand, ...(this.config?.isAgentsEnabled() ? [agentsCommand] : []), authCommand, + btwCommand, bugCommand, { ...chatCommand, diff --git a/packages/cli/src/ui/commands/btwCommand.ts b/packages/cli/src/ui/commands/btwCommand.ts new file mode 100644 index 0000000000..c39904cb2f --- /dev/null +++ b/packages/cli/src/ui/commands/btwCommand.ts @@ -0,0 +1,33 @@ +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { CommandKind, type SlashCommand } from './types.js'; + +export const btwCommand: SlashCommand = { + name: 'btw', + description: 'Ask a side question without affecting history (ephemeral)', + kind: CommandKind.BUILT_IN, + autoExecute: true, + isSafeConcurrent: true, + action: (context, args) => { + const query = args.trim(); + if (!query) { + return { + type: 'command_output', + value: [ + { + text: 'Please provide a question, e.g. /btw what is this regex doing?', + }, + ], + }; + } + + return { + type: 'btw', + query, + }; + }, +}; diff --git a/packages/cli/src/ui/commands/types.ts b/packages/cli/src/ui/commands/types.ts index 466e70c994..2a9ee5914e 100644 --- a/packages/cli/src/ui/commands/types.ts +++ b/packages/cli/src/ui/commands/types.ts @@ -166,6 +166,11 @@ export interface LogoutActionReturn { type: 'logout'; } +export interface BtwActionReturn { + type: 'btw'; + query: string; +} + export type SlashCommandActionReturn = | CommandActionReturn | QuitActionReturn @@ -173,7 +178,8 @@ export type SlashCommandActionReturn = | ConfirmShellCommandsActionReturn | ConfirmActionReturn | OpenCustomDialogActionReturn - | LogoutActionReturn; + | LogoutActionReturn + | BtwActionReturn; export enum CommandKind { BUILT_IN = 'built-in',