From 889200d400c4dec60de0d7b5cdd77261bbb63edb Mon Sep 17 00:00:00 2001 From: Allen Hutchison Date: Tue, 29 Apr 2025 15:39:36 -0700 Subject: Add @ command handling to useGeminiStream (#217) * First integration of at commands into useGeminiStream.ts * feat: Integrate @ command for file/directory reading - Adds support for `@` commands in the CLI UI to read file or directory contents using the `read_many_files` tool. - Refactors `useGeminiStream` hook to handle slash, passthrough, and @ commands before sending queries to the Gemini API. - Improves history item ID generation to prevent React duplicate key warnings. * fix: Handle additional text after @ command path - Modifies the `@` command processor to parse text following the file/directory path (e.g., `@README.md explain this`). - Includes both the fetched file content and the subsequent text in the query sent to the Gemini API. - Resolves the TODO item in `atCommandProcessor.ts`. * feat: Allow @ command anywhere in query and fix build - Update `atCommandProcessor` to correctly parse `@` commands regardless of their position in the input string using regex. This enables queries like "Explain @README.md to me". - Fix build error in `useGeminiStream` by importing the missing `findSafeSplitPoint` function. * rename isPotentiallyAtCommand to isAtCommand * respond to review comments. --- packages/cli/src/ui/utils/commandUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/cli/src/ui/utils') diff --git a/packages/cli/src/ui/utils/commandUtils.ts b/packages/cli/src/ui/utils/commandUtils.ts index 4f731bb3..89e207d9 100644 --- a/packages/cli/src/ui/utils/commandUtils.ts +++ b/packages/cli/src/ui/utils/commandUtils.ts @@ -12,7 +12,7 @@ * @param query The input query string. * @returns True if the query looks like an '@' command, false otherwise. */ -export const isPotentiallyAtCommand = (query: string): boolean => +export const isAtCommand = (query: string): boolean => // Check if starts with @ OR has a space, then @, then a non-space character. query.startsWith('@') || /\s@\S/.test(query); -- cgit v1.2.3