diff options
Diffstat (limited to 'packages/cli/src/ui')
| -rw-r--r-- | packages/cli/src/ui/commands/types.ts | 11 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.ts | 17 |
2 files changed, 24 insertions, 4 deletions
diff --git a/packages/cli/src/ui/commands/types.ts b/packages/cli/src/ui/commands/types.ts index df7b2f21..9a1088fd 100644 --- a/packages/cli/src/ui/commands/types.ts +++ b/packages/cli/src/ui/commands/types.ts @@ -14,6 +14,15 @@ import { SessionStatsState } from '../contexts/SessionContext.js'; // Grouped dependencies for clarity and easier mocking export interface CommandContext { + // Invocation properties for when commands are called. + invocation?: { + /** The raw, untrimmed input string from the user. */ + raw: string; + /** The primary name of the command that was matched. */ + name: string; + /** The arguments string that follows the command name. */ + args: string; + }; // Core services and configuration services: { // TODO(abhipatel12): Ensure that config is never null. @@ -132,7 +141,7 @@ export interface SlashCommand { // The action to run. Optional for parent commands that only group sub-commands. action?: ( context: CommandContext, - args: string, + args: string, // TODO: Remove args. CommandContext now contains the complete invocation. ) => | void | SlashCommandActionReturn diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index 48be0470..fa2b0b12 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -238,7 +238,18 @@ export const useSlashCommandProcessor = ( const args = parts.slice(pathIndex).join(' '); if (commandToExecute.action) { - const result = await commandToExecute.action(commandContext, args); + const fullCommandContext: CommandContext = { + ...commandContext, + invocation: { + raw: trimmed, + name: commandToExecute.name, + args, + }, + }; + const result = await commandToExecute.action( + fullCommandContext, + args, + ); if (result) { switch (result.type) { @@ -288,9 +299,9 @@ export const useSlashCommandProcessor = ( await config ?.getGeminiClient() ?.setHistory(result.clientHistory); - commandContext.ui.clear(); + fullCommandContext.ui.clear(); result.history.forEach((item, index) => { - commandContext.ui.addItem(item, index); + fullCommandContext.ui.addItem(item, index); }); return { type: 'handled' }; } |
