Commit Graph

246 Commits

Author SHA1 Message Date
N. Taylor Mullen f2a8d39f42
refactor: Centralize tool scheduling logic and simplify React hook (#670) 2025-06-01 14:16:24 -07:00
Scott Densmore c414512f19
Fix: Make file path case-insensitive in @-command (#659) 2025-05-31 16:19:14 -07:00
Taylor Mullen 1a84d8f674 Test: Add comprehensive tests for useToolScheduler hook
- Introduces a suite of tests for the  hook, covering various scenarios including:
  - Successful tool execution
  - Tool not found errors
  - Errors during
  - Errors during tool execution
  - Tool confirmation (approved and cancelled) - (currently skipped)
  - Live output updates - (currently skipped)
  - Cancellation of tool calls (before execution and during approval) - (currently skipped)
  - Execution of multiple tool calls
  - Preventing scheduling while other calls are running - (currently skipped)
- Includes tests for the  utility function to ensure correct mapping of tool call states to display objects.
- Mocks dependencies like , , and individual  instances.
- Uses fake timers to control asynchronous operations.

Note: Some tests involving complex asynchronous interactions (confirmations, live output, cancellations) are currently skipped due to challenges in reliably testing these scenarios with the current setup. These will be addressed in future work.
2025-05-31 02:55:36 -07:00
Scott Densmore bda7ec94df
Fix: Update git branch watcher to use .git/logs/HEAD (#643) 2025-05-30 21:08:56 -07:00
Tommaso Sciortino 21fba832d1
Rename server->core (#638) 2025-05-30 18:25:47 -07:00
Jacob Richman 01768d7759
feat: add --show_memory_usage flag to display memory usage in status bar (#606) 2025-05-30 15:18:01 -07:00
Olcan 1a5fd2ccb2
add flags for markdown rendering and live updating to Tool to avoid special-casing shell tool by name, and open door for other tools to specify their rendering/updating (#629) 2025-05-30 13:59:05 -07:00
Brandon Keiji cf82b6e127
fix(sandbox): prepare package.json before building sandbox image (#626) 2025-05-30 19:57:46 +00:00
Olcan a0ba65944f
disable markdown rendering of shell tool output (#625) 2025-05-30 12:43:59 -07:00
Olcan a3b557222a
tweaks to shell abort logic based on feedback (#618) 2025-05-30 01:35:03 -07:00
Olcan 8935a248f6
allow aborting of shell mode (!) commands, similar to shell tool commands. fix bug that prevented aborts after first abort. more robust killing logic (#616) 2025-05-30 00:46:43 -07:00
Olcan b0aeeb53b1
update shell output at an interval to reduce flicker (#614) 2025-05-30 00:02:30 -07:00
Jacob Richman dab7517622
Refactor read-file and support images. (#480) 2025-05-29 15:30:18 -07:00
Allen Hutchison 9ee5eadac0
fix(cli): Support multiple @file references in atCommandProcessor (#590) 2025-05-28 17:08:05 -07:00
Brandon Keiji fd6f6b02ea
feat: add git branch name to footer (#589) 2025-05-28 16:30:05 -07:00
Olcan 0d99398689
much improved support for background processes, avoiding termination (via SIGPIPE) or eventual blocking (e.g. due to filled OS buffers) (#586) 2025-05-28 14:45:46 -07:00
DeWitt Clinton 27a773d5b2
Display git commit info in the /about section. (#567)
This change detects the most recent git commit short hash and writes it to the `GIT_COMMIT_INFO` constant in `packages/cli/src/generated/git-commit.sh`, optionally appending the string "(local modifications)" if additional local changes after that commit are detected.

If set, this string is displayed in the `/about` dialog as well as passed into the `/bug` template.

Example:

```
> /about

╭───────────────────────────────────────────────────────────────────────────╮
│                                                                           │
│ About Gemini CLI                                                          │
│                                                                           │
│ CLI Version               development                                     │
│ Git Commit                43370ab (local modifications)                   │
│ Model                     gemini-2.5-pro-preview-05-06                    │
│ Sandbox                   sandbox-exec (minimal)                          │
│ OS                        darwin v23.11.0                                 │
│                                                                           │
╰───────────────────────────────────────────────────────────────────────────╯
```

Additionally, this change updates `.gitignore` to ignore the generated files, `scripts/clean.sh` to remove them, and adds a `npm run generate` stage for this and any other generators we need to write.
2025-05-28 00:04:26 -07:00
Taylor Mullen f2f2ecf9d8 feat: Allow cancellation of in-progress Gemini requests and pre-execution checks
- Implements cancellation for Gemini requests while they are actively being processed by the model.
- Extends cancellation support to the  logic within tools. This allows users to cancel operations during the phase where the system is determining if a tool execution requires user confirmation, which can include potentially long-running pre-flight checks or LLM-based corrections.
- Underlying LLM calls for edit corrections (within  and ) and next speaker checks can now also be cancelled.
- Previously, cancellation of the main request was not possible until text started streaming, and pre-execution checks were not cancellable.
- This change leverages the updated SDK's ability to accept an abort token and threads s throughout the request, tool execution, and pre-execution check lifecycle.

Fixes https://github.com/google-gemini/gemini-cli/issues/531
2025-05-27 23:46:37 -07:00
Olcan bfeaac8441
live output from shell tool (#573) 2025-05-27 15:40:18 -07:00
Olcan 0d5f7686d7
fix tool cancellation while executing (#575) 2025-05-27 15:22:30 -07:00
Taylor Mullen 480549e02e Refactor(chat): Introduce custom Chat class for future modifications
- Copied the `Chat` class from `@google/genai` into `packages/server/src/core/geminiChat.ts`.
- This change is in preparation for future modifications to the chat handling logic.
- Updated relevant files to use the new `GeminiChat` class.

Part of https://github.com/google-gemini/gemini-cli/issues/551
2025-05-26 14:20:28 -07:00
Taylor Mullen 8440b971f5 Fix(cli): Prevent premature input box reactivation during tool confirmation
- Introduced a 'validating' state for tool calls to prevent the input box from reappearing while waiting for a tool's `shouldConfirmExecute` method to complete.
- When a tool call is initiated, it's now immediately set to a 'validating' status. This ensures the UI remains in a busy/responding state.
- `useGeminiStream` now considers the 'validating' state as part of `StreamingState.Responding`.
- `useToolScheduler` has been updated to:
    - Set the initial status of new tool calls to 'validating'.
    - Asynchronously perform the `shouldConfirmExecute` check.
    - Transition to 'awaiting_approval' or 'scheduled' based on the check's outcome.
- This resolves an issue where a slow `shouldConfirmExecute` could lead to the input prompt becoming active again before the tool call lifecycle was fully determined. While 'validating' is currently treated similarly to 'executing' in the UI, this new state provides a foundation for more customized user experiences during this phase in the future.

Fixes https://github.com/google-gemini/gemini-cli/issues/527
2025-05-25 16:06:33 -07:00
Jacob Richman b4c16d1f56
Code review comment fixes and some refactors. (#525)
No intentional different behavior aside for tweaks suggested from the code review of #506 Refactor: Extract console message logic to custom hook

This commit refactors the console message handling from App.tsx into a new custom hook useConsoleMessages.

This change improves the testability of the console message logic and declutters the main App component.

Created useConsoleMessages.ts to encapsulate console message state and update logic.
Updated App.tsx to utilize the new useConsoleMessages hook.
Added unit tests for useConsoleMessages.ts to ensure its functionality.
I deleted and started over on LoadingIndicator.test.tsx as I spent way too much time trying to fix it before just regenerating the tests as the code was easier to write tests for from scratch and the existing tests were not that good (I added them in the previous pull request).
2025-05-24 00:44:17 -07:00
Jacob Richman 1c3d9d7623
Make console message support more robust to logging in the middle of rendering. (#521) 2025-05-23 22:51:47 -07:00
Miguel Solorio 6247cb8ddd Update packages/cli/src/ui/hooks/slashCommandProcessor.ts
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-23 16:14:37 -07:00
Miguel Solorio 221370acc5 Add `/about` command 2025-05-23 16:14:37 -07:00
Jacob Richman 91ee02898a
feat: Modify loading indicator to support a paused state (#506) 2025-05-23 10:25:17 -07:00
Jacob Richman a96ff934ea
Fix bug updating the cursor after navigating history. (#507) 2025-05-23 09:40:01 -07:00
Allen Hutchison a008d81780
Refactor(server): Centralize GEMINI.md discovery logic in server (#498) 2025-05-23 08:53:22 -07:00
Allen Hutchison f8c4276e69
Refactor(cli): Move memory add logic to server tool call (#493) 2025-05-23 08:47:19 -07:00
Taylor Mullen 7c3591f641 Refactor: Update streaming state logic to hide loader during confirmation
- The streaming state logic in `useGeminiStream.ts` has been updated.
- Previously, the loading indicator was displayed even when the system was
waiting for user confirmation on a tool call.
- This change introduces a `WaitingForConfirmation` state to ensure the
loading indicator is hidden during these confirmation prompts, improving
the user experience.
2025-05-23 00:39:05 -07:00
Brandon Keiji 01971741e0
feat: add emphasis to tool confirmations (#502) 2025-05-23 05:28:31 +00:00
Allen Hutchison 581709df80
Refactor: Streamline memoryUtils and update slash commands (#478) 2025-05-22 10:57:06 -07:00
Brandon Keiji fb1d13d600
fix: cancel parallel tool calls mid-execution (#489) 2025-05-22 03:02:45 -07:00
Brandon Keiji a8bfdf2d56
fix: synchronization between executed tools and turn loops (#488) 2025-05-22 02:51:07 -07:00
Brandon Keiji 4e3ba687a6
fix: forward entire tool call confirmation object through useToolScheduler (#481) 2025-05-22 06:00:36 +00:00
Brandon Keiji 02eec5c8ca
feat: useToolScheduler hook to manage parallel tool calls (#448) 2025-05-21 22:57:53 -07:00
Allen Hutchison a0761f0c41
Fix: Resolve CLI version reporting in /bug command (#455) 2025-05-21 13:31:18 -07:00
Olcan 00ab1905e0
use pending history item for shell mode, update as output is received (#471) 2025-05-21 13:16:50 -07:00
Olcan 01dbc61d1c
space outputs in shell mode (#469) 2025-05-21 12:59:23 -07:00
DeWitt Clinton 01c28df8b2
Add globbing support to @-command file suggestions and resolution. (#462)
Implements recursive glob-based file search for both suggestions and execution of the `@` command.

- When typing `@filename`, suggestions will now include files matching `filename` in nested directories.
- Suggestions are sorted by path depth (shallowest first), then directories before files, then alphabetically.
- The maximum recursion depth for suggestions is set to 10.
- When executing an `@filename` command, if the file is not found directly, a recursive search (using the glob tool) is performed to locate the file.

This addresses the first request in issue #461 by allowing users to quickly reference deeply nested files without typing the full path. Also addresses b/416292478.
2025-05-21 12:22:18 -07:00
Brandon Keiji e1a64b41e8
feat: create tool scheduler hook (#468) 2025-05-21 10:35:40 -07:00
Olcan 2ad666a484
switch to spawn for shell mode (#467) 2025-05-21 09:31:13 -07:00
Olcan 8a70b98d1d
fix exit code for shell mode also (#466) 2025-05-21 09:00:54 -07:00
Seth Troisi cd13c5881b
Add Logger for command history (#435) 2025-05-21 00:36:22 -07:00
Taylor Mullen bda472f147 fix(cli): Prevent request cancellation after multiple Esc presses
- Ensures `abortControllerRef` is reset after a request is aborted or completed.
- Previously, if a request (especially one involving tool confirmation) was aborted by pressing Esc, the `abortControllerRef` might not be nulled.
- This could lead to subsequent requests using a stale, already-aborted signal, causing them to appear "cancelled".
- The fix unconditionally sets `abortControllerRef.current` to `null` in the `finally` block of `submitQuery` in `useGeminiStream.ts`.
- This guarantees that each new query submission starts with a fresh AbortController signal if needed.
- Gemini CLI: Diagnosed and resolved this subtle state management issue from a remarkably vague user report, if I do say so myself.

Fixes https://buganizer.corp.google.com/issues/418496499
2025-05-20 23:58:53 -07:00
Jacob Richman 716f7875a2
Support Images and PDFs (#447) 2025-05-20 13:02:41 -07:00
Taylor Mullen 6ca446bded fix(cli): Prevent truncation of first character in shell commands
- The shell command processor was incorrectly truncating the first
  character of the command (e.g., 'ls' became 's') due to an
  erroneous `slice(1)` operation, likely introduced during a
  previous merge. This change removes the slice, ensuring the full
  command is processed.
- Introduces unit tests for the shellCommandProcessor hook.
- Fixes a minor grammatical issue in the display of GEMINI.md file count.
2025-05-20 00:23:12 -07:00
Allen Hutchison 28acb8d495
feat(cli): Implement /bug command and add open dependency (#428) 2025-05-19 16:56:32 -07:00
Taylor Mullen 323b1298f9 fix: Ensure user written `!` is treated opaquely if not in shell mode\n\n- Addresses an issue where commands prefixed with `!` (e.g., `!ls`) were incorrectly handled by the shell command processor if the `!` was added after initially typing the command.\n- Ensures that such commands are correctly forwarded to the Gemini model.\n- Updates `useGeminiStream` to be aware of shell mode to properly manage streaming state.\n\nFixes https://buganizer.corp.google.com/issues/418761305 2025-05-19 16:16:47 -07:00
Olcan a756489f86
switch from console.warn to info item (#440) 2025-05-19 15:21:31 -07:00
Olcan 96387aba83
warn on cd in shell mode. done robustly based on lessons from shell tool. logs to console.warn for now, and does not restore (but see comment on how to restore) (#438) 2025-05-19 14:51:54 -07:00
Taylor Mullen e4d978da7c feat(cli): Introduce toggleable shell mode with enhanced UI
- Implements a toggleable shell mode, removing the need to prefix every command with `!`.
- Users can now enter and exit shell mode by typing `!` as the first character in an empty input prompt.
- The input prompt visually indicates active shell mode with a distinct color and `! ` prefix.
- Shell command history items (`user_shell`) are now visually differentiated from regular user messages.
- This provides a cleaner and more streamlined user experience for frequent shell interactions.

Fixes https://b.corp.google.com/issues/418509745
2025-05-18 01:25:50 -07:00
Taylor Mullen aca27709df feat: Add auto-accept indicator and toggle
- This commit introduces a visual indicator in the CLI to show when auto-accept for tool confirmations is enabled. Users can now also toggle this setting on/off using Shift + Tab.
- This addresses user feedback for better visibility and control over the auto-accept feature, improving the overall user experience.
- This behavior is similar to Claude Code, providing a familiar experience for users transitioning from that environment.
- Added tests for the new auto indicator hook.

Fixes https://b.corp.google.com/issues/413740468
2025-05-17 22:27:22 -07:00
DeWitt Clinton 13a6a9a690
Introduce a small easter egg. Woof. (#412)
Also changes auto-completion and /help to skip over slash commands that don't contain a description to avoid spoiling the surprise.
2025-05-17 21:57:27 -07:00
Allen Hutchison 1bdec55fe1
feat: Implement CLI and model memory management (#371)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-16 16:36:50 -07:00
Taylor Mullen 968e09f0b5 fix: Ensure filename is available for diff rendering in write-file
This commit resolves a bug where the `write-file` operation could fail to render content due to a missing filename.

The fix involves:
- Ensuring `fileName` is consistently passed to `DiffRenderer.tsx` through `ToolConfirmationMessage.tsx`, `ToolMessage.tsx`, and `useGeminiStream.ts`.
- Modifying `edit.ts` and `write-file.ts` to include `fileName` in the `FileDiff` object.
- Expanding the `FileDiff` interface in `tools.ts` to include `fileName`.

Additionally, this commit enhances the diff rendering by:
- Adding syntax highlighting based on file extension in `DiffRenderer.tsx`.
- Adding more language mappings to `getLanguageFromExtension` in `DiffRenderer.tsx`.
- Added lots of tests for all the above.

Fixes https://b.corp.google.com/issues/418125982
2025-05-16 10:13:13 -07:00
Brandon Keiji 458fd86429
refactor: derive streaming state from tool calls and isresponding state (#376) 2025-05-16 09:45:58 -07:00
Brandon Keiji c6bca64499
refactor: remove unused props clearItems, openThemeDialog, onSubmit (#357) 2025-05-15 09:12:15 -07:00
Seth Troisi 39d57ead1a Have /clear also clear the console. 2025-05-15 10:21:01 +00:00
Miguel Solorio 416813452e
Improvements to suggestions & slash commands (#344)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-14 16:01:29 -07:00
Brandon Keiji 521708e294
refactor: break submitQuery into smaller functions (#350) 2025-05-14 15:14:15 -07:00
Allen Hutchison 1245fe4885
This commit introduces the hierarchical memory feature, allowing GEMI… (#327) 2025-05-14 12:37:17 -07:00
Brandon Keiji 7116ab9c29
fix: pass startup warnings to app as prop (#342) 2025-05-13 17:12:04 -07:00
Brandon Keiji d3303fd3a0
refactor: move nested debugmessage and slashcommand hooks outside of useGeminiStream (#341) 2025-05-13 16:55:49 -07:00
Taylor Mullen c4c11f1d65 Prevent flickering on confirmation decline.
- When larger confirmations were shown and then declined you'd typicaly get large chunks of content flickering upon typing or sending a subsequent request. This was primarily due to us leaving the latest confirmation as "updateable" / pending. This changeset addresses that by flushing any pending confirmation to the static container.

Part of https://b.corp.google.com/issues/414196943
2025-05-13 16:36:28 -07:00
Jacob Richman e2c3611c63
Multiline editor (#302)
Co-authored-by: Taylor Mullen <ntaylormullen@google.com>
2025-05-13 11:24:04 -07:00
Taylor Mullen df74594b8f When an error occurs stop processing. 2025-05-12 00:06:20 -07:00
Taylor Mullen 2970f0a06c feat: Integrate centralized error reporting for API interactions
Implements robust error handling for Gemini API calls, integrating with the centralized error reporting system.

- API errors are now caught and reported to dedicated log files, providing detailed diagnostics without cluttering the user interface.
- A concise error message is surfaced to the user in the UI, indicating an API issue.
- Ensures any pending UI updates are processed before an API error is displayed.

This change improves our ability to diagnose API-related problems by capturing rich error context centrally, while maintaining a clean user experience.

Signed-off-by: Gemini <YourFriendlyNeighborhoodAI@example.com>
2025-05-11 13:55:55 -07:00
Taylor Mullen c0eab31c02 Show model decline/cancellation states.
- Upon decline / cancellation we weren't showing the model the cancellation status or states. Therefore it didn't know why things would or wouldn't happen

Fixes https://b.corp.google.com/issues/416797704
2025-05-10 00:26:18 -07:00
Taylor Mullen 6b518dc9e4 Enable tools to cancel active execution.
- Plumbed abort signals through to tools
- Updated the shell tool to properly cancel active requests by killing the entire child process tree of the underlying shell process and then report that the shell itself was canceled.

Fixes https://b.corp.google.com/issues/416829935
2025-05-10 00:21:09 -07:00
Taylor Mullen 090198a7d6 Make cancel not explode.
- We were console.erroring, throwing and early aborting. Instead we now treat cancels like a normal user message and show an indicator in the UI

Fixes https://b.corp.google.com/issues/416515841
2025-05-09 22:49:32 -07:00
Allen Hutchison 4a6d0717a1
fix for b/414940078 (#306) 2025-05-09 15:38:19 -07:00
Taylor Mullen b8fa38a6e8 feat: Improve theme not found handling
Modify  to return a boolean instead of throwing an error when a theme is not found. Update CLI startup and  hook to handle the boolean return value for more graceful error handling.
2025-05-09 10:28:20 -07:00
Amir Hardon 1c486a4050 Fix: Prevent CLI from crashing when a configured theme is not found
Previously, if a theme specified in the user's settings was not found, the CLI would crash during startup. This was particularly affecting users upgrading from older versions as the "ANSI colors only" theme was renamed to "ANSI".

This commit adds error handling to catch the theme not found error during initial loading and when setting themes later. Instead of crashing, the application now logs a warning, displays an error message in the UI, and opens the theme selection dialog to allow the user to choose a valid theme.
2025-05-08 22:33:46 -07:00
Miguel Solorio a685597b70
UI Polish for theme selector (#294) 2025-05-08 16:00:55 -07:00
Tae Hyung Kim 448a24746c init 2025-05-07 23:47:58 -07:00
Taylor Mullen 6989032414 Remove unnecessary sleep.
- Code review comment: https://github.com/google-gemini/gemini-code/pull/271#pullrequestreview-2821741430
2025-05-07 23:46:57 -07:00
Tae Hyung Kim 13eadcea45
Fix bugs from useGeminiStream refactor (#284) 2025-05-07 21:15:41 -07:00
Tae Hyung Kim 0a7f461d39
Fix flicker in iterm2 (#266) 2025-05-07 12:57:19 -07:00
Allen Hutchison 6b3ef9f939
Refactor: Enhance @-command, Autocomplete, and Input Stability (#279) 2025-05-07 12:30:32 -07:00
Taylor Mullen a588d5cd10 Prevent UI hang on long tool confirmations.
Problem:
When a tool confirmation dialog appeared for a potentially long-running
operation (e.g., `npm install`), accepting the confirmation would cause
the UI to appear to hang. The confirmation dialog would remain visible,
and no further UI updates would occur until the long-running task
completed. This provided a poor user experience as the application
seemed unresponsive.

Fix:
This change addresses the issue by ensuring the UI is updated to remove
the confirmation dialog *before* the long-running operation begins.
It also marks the tool as executing so a spinner can be shown.

Fixes https://b.corp.google.com/issues/415844994

Signed, sealed, delivered, it's yours!
   - Gemini, your friendly neighborhood code-slinger
2025-05-06 22:38:30 -07:00
Taylor Mullen 782686bcf3 Fix edit confirmation re-submission.
- This broke in [this commit](7d13f24288 (diff-e257a7e5e02896371ce002da8963abdb91f5c77990d38e3d2f7ea07e5b19e32eR428))
2025-05-06 22:12:27 -07:00
Allen Hutchison 7d13f24288
refactor(cli): Centralize history management via useHistoryManager hook (#261) 2025-05-06 16:20:28 -07:00
Allen Hutchison adeda6a5b3
Refactor: Memoize hook callbacks, update dependencies, and fix lint errors (#268)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-06 14:48:49 -07:00
Brandon Keiji c5182d5ca4
fix: use flat config for react eslint plugin (#265) 2025-05-06 08:48:26 -07:00
Seth Troisi 2cd976987e slash command altnames and support for ? 2025-05-05 22:33:22 +00:00
Seth Troisi bb52149a06 Move Intro to Help and only display after help command. 2025-05-05 20:54:12 +00:00
Seth Troisi 415b757d4a
Remove passthroughCommands (#252) 2025-05-05 10:57:06 -07:00
Seth Troisi a0bed3e716
Have /clear clear <Static> content by remounting (#250) 2025-05-05 10:52:29 -07:00
Allen Hutchison 74f8f5eaa9
feat(cli): add useHistoryManager hook for chat history (#234)
Co-authored-by: Brandon Keiji <brandonkeiji@google.com>
2025-05-05 09:44:59 -07:00
Jacob Richman 0556358560
Cleanup low value comments. (#248) 2025-05-02 14:39:39 -07:00
Seth Troisi cc838fad44 Add autocomplete for slash commands 2025-05-02 20:58:53 +00:00
Olcan a7679db6e9
sandbox setting and argument (#243) 2025-05-02 08:15:46 -07:00
Jacob Richman 53ac7952c7
Support escaping spaces in file paths. (#241) 2025-05-01 18:02:04 -07:00
Olcan ca53565240
prevent crash on empty shell cmd with $ or ! (#240) 2025-05-01 20:41:00 +00:00
Jacob Richman 7e8f379dfb
Save settings to ~/.gemini/settings.json and optionally /your/workspace/.gemini/settings.json (#237) 2025-05-01 10:34:07 -07:00
Seth Troisi 2616e965a7 Moved theme to slashCommand 2025-04-30 22:32:29 +00:00
Seth Troisi 5f5edb4c9b Added bang(!) commands as a shell passthrough 2025-04-30 22:17:08 +00:00
Allen Hutchison 3ec00d1689
Fix the generation of globs by using the filesystem instead of a heuristic. (#227) 2025-04-30 09:09:01 -07:00
Allen Hutchison 9f20c5f95e
Add @ command suggestions in the UI. (#219) 2025-04-30 08:31:32 -07:00
Seth Troisi fb23321514 Add Intro text with list of /commands 2025-04-29 17:20:38 -07:00
Seth Troisi 19bdc441d6 Add /help 2025-04-29 15:50:24 -07:00
Allen Hutchison 889200d400
Add @ command handling to useGeminiStream (#217)
* First integration of at commands into useGeminiStream.ts

* feat: Integrate @ command for file/directory reading

   - Adds support for `@<path>` 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 `@<path>` 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.
2025-04-29 15:39:36 -07:00
Allen Hutchison 28767b369f
Refactor useGeminiStream to pull slash commands and passthrough comma… (#215)
* Refactor useGeminiStream to pull slash commands and passthrough commands into their own processors.

* whitespace lint errors.

* Add sugestions from code review.
2025-04-29 13:29:57 -07:00
Allen Hutchison e0de69f384
First four independent files for @ commands. (#205) 2025-04-29 08:29:09 -07:00
Seth Troisi dfa46df474
Refactor hardcoded slash commands (#179) 2025-04-28 12:38:07 -07:00
Taylor Mullen 5be89befef feat: Fix flickering in iTerm + scrolling + performance issues.
- Refactors history display using Ink's <Static> component to prevent flickering and improve performance by rendering completed items statically.
- Introduces ConsolePatcher component to capture and display console.log, console.warn, and console.error output within the Ink UI, addressing native handling issues.
- Introduce a new content splitting mechanism to work better for static items. Basically when content gets too long we will now split content into multiple blocks for Gemini messages to ensure that we can statically cache larger pieces of history.

Fixes:
- https://b.corp.google.com/issues/411450097
- https://b.corp.google.com/issues/412716309
2025-04-26 16:08:05 -07:00
Seth Troisi a5ba681f8d Add /exit and /quit commands 2025-04-25 14:29:00 -07:00
Seth Troisi ed12a2e133 Pulled manual commands to seperate function 2025-04-25 14:29:00 -07:00
Brandon Keiji 1a64268bb0
fix: remove extra initError (#173) 2025-04-25 13:15:05 -07:00
Jacob Richman 5790a5d7cf
Add a theme preview and update the theme when highlight changes. (#151) 2025-04-24 11:36:34 -07:00
Taylor Mullen 4c2a5045a0 Add theming support.
- Added a number of common themes to our support matrix:
 - AtomOneDark
 - Dracula
 - VS
 - GitHub
 - GoogleCode
 - XCode
 - ... Admittedly these all were randomly picked, we could probably curate these better...
- Added a new `ThemeDialog` UI that can be accessed via `/theme`. It shows your currentlyt available themes and allows you to change them freely. It does **not**:
 - Save the theme between sessions
 - Allow you to hit escape
 - Show a preview prior to selection.
- These themes are from reacts highlight js library.

Fixes https://b.corp.google.com/issues/412797985
2025-04-22 22:08:13 -07:00
Allen Hutchison 9bc9c6e6c5
Question flag (#125) 2025-04-22 18:32:03 -07:00
Allen Hutchison 8cfd915960 Fix the case where passthrough tools weren't using the correct CWD from -d 2025-04-22 15:19:40 -07:00
Jaana Dogan 8e0fb9ee2f Initiate the GeminiClient with a config
Also address the open readability improvement comments from #104.
2025-04-22 11:20:19 -07:00
Taylor Mullen 3db2a796ec Fix Tool -> Text -> Confirmation bu that results in disordered history
- We weren't reseting the tool group inbetween content which meant we'd start a new group on the first tool call, and if regular textual content followed it'd effectively close that group; however, we weren't updating our state to really close that group. Meaning, any subsequent tool calls or confirmations would get grouped with the original grouping.
  - When we see textual content from Gemini we now reset the tool call group.

Fixes https://b.corp.google.com/issues/412605330
2025-04-22 10:33:36 -04:00
Taylor Mullen 80b04dc505 Update UI of tool messages
- Bring tool messages in line with original envisioned UI of: https://screenshot.googleplex.com/9yZCX636LzpMrgc
  - In particular this represents more descriptive names. FWIW we already had this tech we just weren't passing around information correctly (`displayName` vs. `name`)
 - Add gray to our list of color pallete's and removed Background (unused)
 - Re-enabled representing canceled messages
 - Migrated back towards a cleaner tool message design of status symbols & border colors vs. overly verbose text.
 - Removed border from confirmation diffs.
Fixes https://b.corp.google.com/issues/412598909
2025-04-22 08:05:30 -04:00
Allen Hutchison 1a167b2ea5
Piped input (#104)
* New method for handling stdin. Bypass Ink, and output to stdout. Makes the CLI work like a typical Unix application when called with piped input.

* Fixing a few post-merge errors.

* Format code.

* Clean up lint and format errors.
2025-04-21 17:41:44 -07:00
Jaana Dogan baf39042c8
Remove duplicate CLI tools module, remove the global tool registry (#89) 2025-04-21 12:59:31 -07:00
Jaana Dogan 53a5728009
Remove redundant else branches (#86)
Else branches are an anti pattern especially if you can easily return from the previous branch. Over time, else branches cause deep nesting and make code unreadable and unmaintainable. Remove elses where possible.
2025-04-21 12:15:47 -07:00
Jaana Dogan 651a543403
Remove gemini-stream.ts (#84)
This module is no longer needed and the types can be provided from types.
2025-04-21 11:49:46 -07:00
Taylor Mullen 738c2692fb Fix confirmations.
- This fixes what it means to get confirmations in GC. Prior to this they had just been accidentally unwired as part of all of the refactorings to turns + to server/core.
  - The key piece of this is that we wrap the onConfirm in the gemini stream hook in order to resubmit function responses. This isn't 100% ideal but gets the job done for now.
- Fixed history not updating properly with confirmations.

Fixes https://b.corp.google.com/issues/412323656
2025-04-21 14:47:17 -04:00
Taylor Mullen 81f0f618f7 Fix Gemini Code's (GC) smarts.
- The tl;dr; is that GC couldn't see what the user was saying when tool call events happened in response. The rason why this was happening was because we were instantly invoking tools that the model told us to invoke and then instantly re-requesting. This resulted in the bug because the genai APIs can't update the chat history before a full response has been completed (doesn't know how to update if it's incomplete).
- To address the above issue I had to do quite the large refactor. The gist is that now turns truly drive everything on the server (vs. a server client split). This ensured that when we got tool invocations we could control when/how re-requesting would happen and then also ensure that history was updated. This change also meant that the server would act as an event publisher to enable the client to react to events rather than try and weave in complex logic between the events.
- A BIG change that this changeset incudes is the removal of all of the CLI tools in favor of the server tools.
- Removed some dead code as part of this
- **NOTE: Confirmations are still broken (they were broken prior to this); however, I've set them up to be able to work in the future, I'll dot hat in a follow up to be less breaking to others.**

Fixes https://b.corp.google.com/issues/412320087
2025-04-21 11:07:09 -04:00
Taylor Mullen 63f864cdd7 Fix read-file from exploding with path not found error.
- There were a few hiccups here. Somehow 2.5-flash wasn't actually abiding by our tool schema. Instead it was inferring `path`. To semi-combat this I've renamed `file_path` -> `path`.
- We weren't elevating errors that were created via schema validation. Instead both the `glob` and `read-file.ts` now surface this.
- In error scenarios (like failing schema) we were improperly surfacing these as success cases because we were overriding tool status.
2025-04-20 22:13:55 -04:00
Tyler d55168f51f
add linter for checking license headers (and eslint --fix target to match, and fix missing license headers while we're here) (#62) 2025-04-20 17:16:25 -07:00
Juliette Love 8180ed9a68
Add terminal clear (#69) 2025-04-20 21:13:32 +01:00
Juliette Love a76d9b4dcf
Adds shell command allowlist (#68)
* Wire through passthrough commands

* Add default passthrough commands

* Clean up config passing to useGeminiStream
2025-04-20 21:06:22 +01:00
Juliette Love a66ad2e2af
Simple debug mode for CLI side (#66)
* Adds debug mode config flag.

* Wire through debug lines

* Add debug mode logging example

* Run format

* Run format again
2025-04-20 20:20:40 +01:00
Evan Senter 3fce6cea27
Starting to modularize into separate cli / server packages. (#55)
* Starting to move a lot of code into packages/server

* More of the massive refactor, builds and runs, some issues though.

* Fixing outstanding issue with double messages.

* Fixing a minor UI issue.

* Fixing the build post-merge.

* Running formatting.

* Addressing comments.
2025-04-19 19:45:42 +01:00
Evan Senter 75ecb4a81f
Adding in a history buffer (#38)
Up and down arrows traverse the command history.
2025-04-19 14:31:59 +01:00
jlove29 2f5f6baf0f fix format 2025-04-19 11:08:50 +01:00
jlove29 d2ef83bc60 Add direct execution of shell commands 2025-04-19 11:07:39 +01:00
Tyler 4354458cad
Add apache2 SPDX headers to all source files (#48) 2025-04-18 17:44:24 -07:00
Allen Hutchison e75f0722e7
All the pipes (#47)
* Bump the character limit to web fetch.

* Piped Input Hook. First step in bringing in STDIN piping.

* Fix linting errors.

* Remove incorrect comment.
2025-04-18 17:12:14 -07:00
Taylor Mullen 40e11e053c Fix remaining tslint errors (YAY).
- Also updated ci.yml to ensure that linting failures will break the build.

Fully fixes https://b.corp.google.com/issues/411384603
2025-04-18 19:14:36 -04:00
Taylor Mullen 383b917784 Run `npm run format`
- This has the entirety of the changes.

Part of https://b.corp.google.com/issues/411720532
2025-04-18 18:10:57 -04:00
Taylor Mullen e7fa39112a Manually fix hooks and utils linting errors (partial)
- More changes are to come, this is truly a partial change in order to not disrupt as many people as possible.

Part of https://b.corp.google.com/issues/411384603
2025-04-18 17:51:16 -04:00
Evan Senter 482aeaff10
Warn if `npm run start` is out of date. (#20)
* Adding some wiring to allow the Ink app to warn if there are local development changes that haven't been captured in the recent build of the Gemini CLI.

* Adding a new useAppEffects.ts file that wores some useEffect handlers in.

* Updating package-lock.json to resolve `npm ci` issues.

* Updating package-lock.json and package.json to resolve `npm ci` issues.
2025-04-18 21:55:02 +01:00
Jaana Dogan 3afaa8033b
Introduce a config module to manage configuration (#22)
* Introduce a config module to manage configuration

* Remove public modifier
2025-04-18 11:12:18 -07:00
Evan Senter dbf4c3a37c Revert "Including a test harness for it, and making sure the cursor is always at the end."
This reverts commit 97db77997f.
2025-04-18 18:36:33 +01:00
Evan Senter 97db77997f Including a test harness for it, and making sure the cursor is always at the end. 2025-04-18 18:16:52 +01:00
Taylor Mullen e0339993ae Initial auto-fixing of linting errors.
- This is the result of runing `npm lint -- -fix`
2025-04-18 12:41:02 -04:00
Taylor Mullen cfc697a96d Run `npm run format`
- Also updated README.md accordingly.

Part of https://b.corp.google.com/issues/411384603
2025-04-17 15:29:34 -07:00
Jaana Dogan 81ba61df7f Improve readability issues
This is only the first change of many changes.

* Remove redundant autogenerated comments
* Use the recommended file name style
* Use camelCase for variable names
* Don't introduce submodules for relevant types
* Don't introduce constants like modules, these are implementation details
* Remove empty files
2025-04-17 14:15:20 -07:00
Taylor Mullen add233c504 Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.

The code was migrated from a previous git repository as a single squashed commit.

Core Features & Components:

*   **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
*   **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
*   **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
    *   File system listing (`ls`)
    *   File reading (`read-file`)
    *   Content searching (`grep`)
    *   File globbing (`glob`)
    *   File editing (`edit`)
    *   File writing (`write-file`)
    *   Executing bash commands (`terminal`)
*   **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
*   **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
*   **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.

This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.

---
Created by yours truly: __Gemini Code__
2025-04-17 13:19:55 -04:00