Commit Graph

716 Commits

Author SHA1 Message Date
jerop b4a6b16227 Test: Verify concatenated env var resolution in settings
Adds a test case to `settings.test.ts` to specifically verify
the correct resolution of multiple environment variables concatenated
within a single string value (e.g., ${HOST}:${PORT} ).
2025-06-06 11:47:37 -04:00
jerop 8c28250bb3 Refactor: Improve env var resolution in settings
Refactors the `resolveEnvVarsInObject` function in settings to
explicitly handle primitive types (null, undefined, boolean, number)
at the beginning of the function. This clarifies the logic for
subsequent string, array, and object processing.
2025-06-06 11:47:37 -04:00
jerop 4e9d365407 feat: Enable environment variable substitution in settings
This commit introduces the ability to use system environment variables
within the settings files (e.g., `settings.json`). Users can now
reference environment variables using the `${VAR_NAME}` syntax.

This enhancement improves security and flexibility, particularly
for configurations like MCP server settings, which often require
sensitive tokens.

Previously, to configure an MCP server, a token might be directly
embedded:
```json
"mcpServers": {
  "github": {
    "env": {
      "GITHUB_PERSONAL_ACCESS_TOKEN": "pat_abc123"
    }
    // ...
  }
}
```

With this change, the same configuration can securely reference an
environment variable:
```json
"mcpServers": {
  "github": {
    "env": {
      "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PERSONAL_ACCESS_TOKEN}"
    }
    // ...
  }
}
```

This allows users to avoid storing secrets directly in configuration files.
2025-06-06 11:47:37 -04:00
Jacob Richman 9ad615c2a4
Fix build break due to changes to theme. (#796) 2025-06-06 08:05:00 -07:00
Jacob Richman 4262f5b0de
feat(cli): respect the NO_COLOR env variable (#772) 2025-06-06 07:55:28 -07:00
DeWitt Clinton c80ff146d2
Reduce noisy logging for missing .geminiignore file. (#793) 2025-06-06 07:47:43 -07:00
matt korwel 2f51c22141
Title & Big text Updates (#781) 2025-06-05 18:14:02 -07:00
Miguel Solorio 8a0a2523ca
Allow themes to theme the UI (#769) 2025-06-05 14:35:47 -07:00
Brandon Keiji 2285bba66e
refactor: remove unnecessary useRefs (#780) 2025-06-05 21:33:24 +00:00
Olcan d3a1026ae3
skip npm build for custom sandbox (#779) 2025-06-05 14:15:43 -07:00
N. Taylor Mullen 1ffe027d8a
Add support for configured mcp client timeout. (#775) 2025-06-05 20:35:00 +00:00
Tommaso Sciortino e59e18251b
Introduce generate content interface (#755) 2025-06-05 13:26:38 -07:00
Jerop Kipruto 2ebf2fbc82
OpenTelemetry Integration & Telemetry Control Flag (#762) 2025-06-05 13:04:25 -07:00
Olcan d3e43437a0
use execSync (vs spawnSync) so launch fails if build_sandbox fails; tweaks in build_sandbox to fix some shellcheck warnings, and to simplify the logic slightly (#767) 2025-06-05 13:02:56 -07:00
Eddie Santos e02868bb1a
Bump default model to `gemini-2.5-pro-preview-06-05` (#765) 2025-06-05 11:52:36 -07:00
Eddie Santos 422c763a55
Add support for `.geminiignore` file (#757) 2025-06-05 10:15:27 -07:00
Tolik Malibroda 1d20cedf03
fix: Disable automatic image building if BUILD_SANDBOX is not provided (#764) 2025-06-05 18:47:39 +02:00
Tolik Malibroda 4d4cf0f2f9
feat: Add multi-stage docker build support for custom sandbox.Dockerfile (#746) 2025-06-05 17:46:54 +02:00
anj-s 78b2a28fb6
Checks for diff changes before displaying the code snippet (#751) 2025-06-05 06:48:03 -07:00
Jacob Richman aa386d135b
Jacob314/memory fixes (#754)
Address multiple possible memory leaks found bystatic analysis of the codebase. The primary source of the leaks was event listeners on child processes and global objects that were not being properly removed, potentially causing their closures to be retained in memory indefinitely particularly for processes that did not exit.

There are two commits. A larger one made by gemini CLI and a smaller one by me to make sure we always disconnect child processes as part of the cleanup methods. These changes may not actually fix any leaks but do look like reasonable defensive coding to avoid leaking event listeners or child processes.

The following files were fixed:
This is Gemini's somewhat overconfident description of what it did.

packages/core/src/tools/shell.ts: Fixed a leak where an abortSignal listener was not being reliably removed.
packages/cli/src/utils/readStdin.ts: Fixed a significant leak where listeners on process.stdin were never removed.
packages/cli/src/utils/sandbox.ts: Fixed leaks in the imageExists and pullImage helper functions where listeners on spawned child processes were not being removed.
packages/core/src/tools/grep.ts: Fixed three separate leaks in the isCommandAvailable check and the git grep and system grep strategies due to un-removed listeners on child processes.
packages/core/src/tools/tool-registry.ts: Corrected a leak in the execute method of the DiscoveredTool class where listeners on the spawned tool process were not being removed.
2025-06-05 06:40:33 -07:00
N. Taylor Mullen 822803d9d6
Fix "npx https:...." header issue (#759) 2025-06-05 07:00:34 +00:00
N. Taylor Mullen 77afd37c2e
fix(cli): Handle non-array tool response parts (#758) 2025-06-05 06:25:57 +00:00
Eddie Santos d99d132cdf
Add `/tools` slash command to view available tools (#752) 2025-06-04 14:01:38 -07:00
Tommaso Sciortino 4192cfb092
CLI_TITLE env var for setting the CLI title (#748) 2025-06-04 10:44:50 -07:00
Miguel Solorio a2f03636a5
Update light themes (#726) 2025-06-04 10:41:03 -07:00
N. Taylor Mullen 44aff769a3
Bring back 2.5-pro usage (#744)
https://chat.google.com/room/AAQApBm33UQ/8DQw4Ykp8f0/8DQw4Ykp8f0?cls=10
2025-06-04 09:29:14 -07:00
N. Taylor Mullen afc30e314f
feat(accessibility): Add option to disable loading phrases (#745) 2025-06-04 07:46:57 +00:00
N. Taylor Mullen d179b3aae4
refactor(core): Centralize tool response formatting (#743) 2025-06-04 07:24:25 +00:00
Tolik Malibroda 4b2af10b04
fix: Fix piped input mode in sandbox (#739) 2025-06-04 08:24:33 +02:00
Marat Boshernitsan 7de790fbf2
Fix several bugs in prompt history (#734)
Co-authored-by: Marat Boshernitsan <maratb@google.com>
2025-06-03 23:01:26 -07:00
Keith Ballinger c313762ba0
Ignore folders files (#651)
# Add .gitignore-Aware File Filtering to gemini-cli

This pull request introduces .gitignore-based file filtering to the gemini-cli, ensuring that git-ignored files are automatically excluded from file-related operations and suggestions throughout the CLI. The update enhances usability, reduces noise from build artifacts and dependencies, and provides new configuration options for fine-tuning file discovery.

Key Improvements
.gitignore File Filtering

All @ (at) commands, file completions, and core discovery tools now honor .gitignore patterns by default.
Git-ignored files (such as node_modules/, dist/, .env, and .git) are excluded from results unless explicitly overridden.
The behavior can be customized via a new fileFiltering section in settings.json, including options for:
Turning .gitignore respect on/off.
Adding custom ignore patterns.
Allowing or excluding build artifacts.
Configuration & Documentation Updates

settings.json schema extended with fileFiltering options.
Documentation updated to explain new filtering controls and usage patterns.
Testing

New and updated integration/unit tests for file filtering logic, configuration merging, and edge cases.
Test coverage ensures .gitignore filtering works as intended across different workflows.
Internal Refactoring

Core file discovery logic refactored for maintainability and extensibility.
Underlying tools (ls, glob, read-many-files) now support git-aware filtering out of the box.


Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-04 04:40:46 +00:00
Cindy Xing d85f09ac51
Update configuration.md (#722) 2025-06-03 21:33:02 -07:00
Olcan 80a445c7ae
bandaid for broken mcp calls (#732) 2025-06-03 14:40:36 -07:00
Olcan 12059eb4ca
fix BUILD_SANDBOX env var for updating sandbox while running linked binary (#729) 2025-06-03 14:02:00 -07:00
Olcan 9df94103ac
remove noop code (#728) 2025-06-03 13:47:53 -07:00
Olcan 00a9f654a3
fixed strip-ansi dep by installing it in core package (also ran npm install in cli package that resulted in the minor changes here) (#727) 2025-06-03 13:37:59 -07:00
Brandon Keiji e96fd677ee
fix: do not try to pull development sandbox image from the internet (#725) 2025-06-03 19:32:17 +00:00
Brandon Keiji 546e033081
feat: notify user when chat context is compressed (#724) 2025-06-03 19:19:49 +00:00
Brandon Keiji fa5b616a10
feat: compress chat history when we approach token limit (#711) 2025-06-03 18:54:11 +00:00
N. Taylor Mullen 080af01715
Fix flash preview (#723) 2025-06-03 18:01:59 +00:00
N. Taylor Mullen c5099e9025
Workaround Gemini API break - Use flash 04-17 (#721) 2025-06-03 17:47:20 +00:00
Allen Hutchison 72f5ec3725
feat(cli): randomize and expand witty loading phrases (#704) 2025-06-03 10:12:47 -07:00
anj-s fffa06f0b1
Modify shortenPath and add param validation (#663) 2025-06-03 08:59:17 -07:00
anj-s e9d43b9388
Add params check for writeTool (#708) 2025-06-03 07:47:27 -07:00
N. Taylor Mullen c71d6ddc3b
Fix: Ensure MCP tools are discovered from slow-starting servers (#717) 2025-06-03 07:40:51 +00:00
N. Taylor Mullen 5f6f6a95a2
Refactor: Make MCP server discovery non-blocking (#716) 2025-06-03 06:37:02 +00:00
N. Taylor Mullen 8ab74ef1bb
Refactor: Use config.getGeminiClient() for GeminiClient instantiation (#715) 2025-06-03 05:30:52 +00:00
N. Taylor Mullen cf3e1a07c1
Remove redundant variable. (#713) 2025-06-02 21:18:01 -07:00
Brandon Keiji 74801e9004
refactor: maintain 1 GeminiChat per GeminiClient (#710) 2025-06-02 19:10:54 -07:00
Jacob Richman 447826ab40
fix(cli): restore first-launch theme prompt (#703) 2025-06-02 19:09:11 -07:00
Scott Densmore 2ab7e3da71
feat(cli): Allow custom title in CLI header (#706) 2025-06-02 17:09:55 -07:00
Bryan Morgan 91fa770196
upate to PR 669 (#700)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-02 16:59:38 -07:00
N. Taylor Mullen 8563e46ade
React to Gemini API break - Thought Inclusion (#705) 2025-06-02 23:32:45 +00:00
N. Taylor Mullen 6020c760b5
Feat: Enable YOLO mode for non-interactive execution (#702) 2025-06-02 22:35:03 +00:00
Scott Densmore e428707e07
Refactor: Centralize GeminiClient in Config (#693)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-02 14:55:51 -07:00
Olcan 1dcf0a4cbd
strip ansi from shell output (#699) 2025-06-02 14:50:12 -07:00
Jacob Richman 51949f3121
Fix bug pasting multiline strings (#632) 2025-06-02 14:31:35 -07:00
Olcan 8365c8f954
prefer to load gemini-specific .env file from .gemini folder when it exists there (#697) 2025-06-02 14:16:48 -07:00
Allen Hutchison 7f20425c98
feat(cli): add pro model availability check and fallback to flash (#608) 2025-06-02 13:55:54 -07:00
Olcan 59b6267b2f
allow toolDiscoveryCommand to return function declarations with or without a tool wrapper; fully document both toolDiscoveryCommand and toolCallCommand with examples and pointers to API docs (#696) 2025-06-02 13:41:49 -07:00
N. Taylor Mullen 58597c29d3
refactor: Update MCP tool discovery to use @google/genai - Also fixes JSON schema issues. (#682) 2025-06-02 20:39:25 +00:00
Tolik Malibroda 0795e55f0e
feat: Add --yolo mode that automatically accepts all tools executions (#695)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-02 22:05:45 +02:00
N. Taylor Mullen 42bedbc3d3
feat: Refactor CLI header for customizable logo text (#658) 2025-06-02 11:45:09 -07:00
Miguel Solorio 33052018a2
Color enhancements (#680) 2025-06-02 11:20:58 -07:00
Olcan c5869db080
enable async tool discovery by making the registry accessor async; remove call to discoverTools that caused duplicate discovery (#691) 2025-06-02 09:56:32 -07:00
N. Taylor Mullen 34b81abd9c
fix: Ensure all tool calls are complete before submitting responses (#689) 2025-06-02 08:50:28 +00:00
N. Taylor Mullen 27ba28ef76
fix: Refine model message consolidation for improved model interaction (#685) 2025-06-02 07:28:14 +00:00
Olcan d009267801
more strict italics: delimiters cannot be preceded/followed by \w or [./\\]\S (#677) 2025-06-01 16:52:31 -07:00
N. Taylor Mullen 2828fc6d66
feat: Implement non-interactive mode for CLI (#675) 2025-06-01 23:11:37 +00:00
N. Taylor Mullen c51d6cc9d3
fix: Display MCP server count in context summary (#674) 2025-06-01 22:48:48 +00:00
Bryan Morgan f7a2442fac
Added replace tool ability to replace more than 1 occurrence (#669)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-06-01 17:49:48 -04:00
N. Taylor Mullen f2a8d39f42
refactor: Centralize tool scheduling logic and simplify React hook (#670) 2025-06-01 14:16:24 -07:00
Leo edc12e416d
Update edit tool validation function to override validateToolParams (#667) 2025-06-01 11:18:43 -07:00
anj-s 9dae07784b
Fix for validating getDescription in read_file tool call (#660) 2025-06-01 00:02:00 -07:00
Scott Densmore c414512f19
Fix: Make file path case-insensitive in @-command (#659) 2025-05-31 16:19:14 -07:00
Bryan Morgan b1d693786c
Revert "cleanup: removed duplicate check from Config.registerCoreTool()" (#657)
Didn't notice the casing difference - duh....
2025-05-31 20:52:52 +00:00
Bryan Morgan b228923446
cleanup: removed duplicate check from Config.registerCoreTool() (#656) 2025-05-31 16:50:19 -04:00
Allen Hutchison 53bf778497
feat: allow custom filename for context files (#654)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-31 12:49:28 -07:00
Miguel Solorio cbc1614b84
Update default & ANSI theme names (#637) 2025-05-31 11:10:52 -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
Olcan 0dbd12e295
expose shell process group id to model, along with instructions for how to terminate or signal the group (#645) 2025-05-30 23:25:44 -07:00
Scott Densmore bda7ec94df
Fix: Update git branch watcher to use .git/logs/HEAD (#643) 2025-05-30 21:08:56 -07:00
Daniel Young Lee 1468047081 feat: Implement delayed Ctrl+C exit prompt
This change introduces a small delay after the first Ctrl+C press, prompting the user to press Ctrl+C again to exit. This helps prevent accidental termination of the application.

- Added `exitOnCtrlC={false}` to the Ink render options in `gemini.tsx` to enable custom Ctrl+C handling.
- Implemented logic in `App.tsx` to:
    - Display "Press Ctrl+C again to exit." for 2 seconds after the first Ctrl+C.
    - Exit the application if Ctrl+C is pressed again during this period.
    - Revert to normal operation if the second Ctrl+C is not pressed within the timeout.
- Defined a constant `CTRL_C_PROMPT_DURATION_MS` for the timeout duration.
2025-05-30 20:51:07 -07:00
Scott Densmore 7012c86336
Fix/cli version unknown (#642) 2025-05-30 20:45:15 -07:00
Tommaso Sciortino 21fba832d1
Rename server->core (#638) 2025-05-30 18:25:47 -07:00
Olcan c81148a0cc
use json block for mcp tool output (and re-enable markdown rendering) (#635) 2025-05-30 15:59:23 -07:00
Olcan 2e57989aec
confirm mcp tool executions from untrusted servers (per "trust" setting) (#631) 2025-05-30 15:32:21 -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
Allen Hutchison 3291ffbe09
fix(cli): Clear input buffer before onSubmit in InputPrompt (#633) 2025-05-30 15:16:06 -07:00
Olcan 4225567303
disable markdown for discovered (mcp) tools (#630) 2025-05-30 14:12:51 -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 0869fd168f
fix(sandbox): pull sandbox image if it doesnt exist locally (#628) 2025-05-30 20:49:47 +00: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
Brandon Keiji 31a7affb74
feat(sandbox): use package config to dictate sandbox image name (#624) 2025-05-30 19:28:46 +00:00
Brandon Keiji 816cc08a8f
fix(sandbox): set default env var to 'gemini-cli-sandbox' (#620) 2025-05-30 18:02:27 +00:00
N. Taylor Mullen 8c46108a85
feat: Implement retry with backoff for API calls (#613) 2025-05-30 17:57:00 +00:00
Taylor Mullen c5608869c0 Change ReadFile to not have a result display.
- It's verbose on its own; however, if file content is truncated we'll indicate that in the result display.
2025-05-30 10:48:10 -07:00
Taylor Mullen 9537ff4762 feat(server): consolidate adjacent model content in chat history
- Consolidates consecutive model messages into a single message in the chat history.
- This prevents multiple model messages from being displayed in a row, improving readability.
- This may also address some instances of 500 errors that could have been caused by multiple, rapidly succeeding model messages.
- Adds tests for the new consolidation logic.

Fixes https://b.corp.google.com/issues/421010429
2025-05-30 10:43:48 -07:00
Olcan 7c4a5464f6
truncate (hide) tool output at the top, add some spacing, also fix shell output interval change accidentally undone in a previous commit (#619) 2025-05-30 01:58:09 -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
Olcan fe049c286f
fix mcp tool names that are long or have invalid characters (based on 400 error) (#602) 2025-05-29 16:13:11 -07:00
Jacob Richman dab7517622
Refactor read-file and support images. (#480) 2025-05-29 15:30:18 -07:00
Olcan 4b7248fc46
allow writing to user cache directory on macos (fixes use of lyria mcp server [to generate songs] under seatbelt) (#600) 2025-05-29 15:06:09 -07:00
Allen Hutchison 5dbc83fabc
feat: Enhance web_fetch tool to process prompts with URLs using Gemini API (#587) 2025-05-29 15:02:31 -07:00
Seth Troisi 4b4ba85313
improve read-many-files output (#596) 2025-05-29 14:03:24 -07:00
Brandon Keiji dc94a03f39
feat: publish root Dockerfile to our image registry (#599) 2025-05-29 14:01:44 -07:00
Jacob Richman 6a1b94529b
Change Config to use named parameters. (#593) 2025-05-29 13:51:17 -07:00
Taylor Mullen d74c0f581b refactor: Extract MCP discovery from ToolRegistry
- Moves MCP tool discovery logic from ToolRegistry into a new, dedicated MCP client (mcp-client.ts and mcp-tool.ts).
- Updates ToolRegistry to utilize the new MCP client.
- Adds comprehensive tests for the new MCP client and its integration with ToolRegistry.

Part of https://github.com/google-gemini/gemini-cli/issues/577
2025-05-28 17:28:45 -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
Jacob Richman 00805cb2cd
Cleanup: Remove low value StreamingContextType interface. (#585) 2025-05-28 12:46:08 -07:00
Jacob Richman 05a49702d8
Refactor: Add GeminiRespondingSpinner to make use of streamingState idiomatic (#583) 2025-05-28 11:17:19 -07:00
DeWitt Clinton 98dcf43214
Add a keybinding for ctrl+w to delete the previous word. (#582)
Adds the following new keybindings to the cli text input buffer:

- `Ctrl+W` : Delete previous word
2025-05-28 09:59:25 -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
Brandon Keiji c1395a8808
fix: change entrypoint from 'gemini-code' to 'gemini' in published sandbox (#574) 2025-05-27 22:19:43 +00:00
Brandon Keiji d4ae1ede39
refactor: use React strict mode (#569) 2025-05-27 14:40:46 -07:00
Olcan 0c5673875b
improve shell tool output when cancelled in debug mode (#571) 2025-05-27 13:47:40 -07:00
Allen Hutchison 4e3c539f5e
feat: Publish test coverage summaries to PRs (#513) 2025-05-27 12:45:28 -07:00
sasha-gitg 3511e84dc3
fix: default to Gemini API if GEMINI_API_KEY is set and when GOOGLE_GENAI_USE_VERTEXAI is set to True (#566) 2025-05-27 10:00:07 -07:00
Taylor Mullen b3f52e215a feat: Replace SQLite with JSON logging for macOS sandbox compatibility
- Removes the sqlite3 dependency and refactors the logging mechanism to use a JSON file (logs.json) instead of a database.
- This change is a temporary workaround to address issues with macOS sandboxing that were caused by the SQLite native module.
- Storing all logs in a single JSON file may introduce scalability concerns in the future.

Fixes https://github.com/google-gemini/gemini-cli/issues/522
2025-05-26 16:13:37 -07:00
Taylor Mullen 9e1cfca53f Fix(chat): Finalize next speaker detection logic
- Enhance `checkNextSpeaker` to handle cases where the last message is a function response or an empty model message.
- If the last message is a function response, the model should speak next.
- If the last message is an empty model message, the model should speak next.
- This ensures more robust and accurate determination of the next speaker in the conversation, completing the fix for the issue.
- Updated tests.

Fixes https://github.com/google-gemini/gemini-cli/issues/551
2025-05-26 15:21:45 -07:00
Taylor Mullen c92d4edb89 Fix(chat): Ensure model responds when next speaker check indicates
- Corrects an issue where the `nextSpeakerCheck` would determine the model should speak next, but the models response was not properly propagated due to a missing `yield*` in a recursive call within `sendMessageStream`.
- This change ensures that when the model is designated as the next speaker, its generated content is correctly unwoven and returned, allowing the conversation to proceed as expected.

Part of https://github.com/google-gemini/gemini-cli/issues/551
2025-05-26 14:37:13 -07:00
Taylor Mullen 597dc86a9c Fix(chat): Prevent empty model response after function call
- Addresses a Gemini model bug where it may return an empty content object after a function response.
- Previously, the SDK attempted to inject an empty model message, which could disrupt curated history.
- This change modifies our custom  class to detect this scenario using an  utility and avoid pushing an unnecessary empty model message, thus preserving history integrity.

Workaround for https://b.corp.google.com/issues/420354090
Part of https://github.com/google-gemini/gemini-cli/issues/551
2025-05-26 14:29:24 -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 02503a3248 Chore(deps): Upgrade @google/genai to v1.0.1
- Upgraded the @google/genai SDK from ^0.13.0 to ^1.0.1.
- Addressed a related type error in `packages/server/src/tools/edit.test.ts` by updating a type assertion.

Part of https://github.com/google-gemini/gemini-cli/issues/551
2025-05-26 14:09:43 -07:00
Taylor Mullen 70d469ccd3 Fix(diff): Hide whitespace changes in diffs with content changes
- Updated the diff generation in `edit.ts` and `write-file.ts` to include the `ignoreWhitespace: true` option.
- This ensures that whitespace-only changes are not highlighted in the diff output when there are other content modifications, making the diffs cleaner and easier to review.
- Extract default diffing options into single source of truth.

Fixes https://github.com/google-gemini/gemini-cli/issues/548
2025-05-25 22:45:53 -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
Taylor Mullen 7408c78dbb Change tool call spinner to be different.
- This differentiates the tool calling spinner from one that matches the normal loading indiator to somethign a little more seamless.
2025-05-25 16:05:22 -07:00
Taylor Mullen 3281cbc835 Fix(test): Improve write-file and editCorrector test suites
- Enhanced  by:
  - Mocking  and  utilities (, ) to allow for more focused unit testing of .
  - Adding comprehensive tests for the private  method, covering new and existing file scenarios, as well as error handling.
  - Expanding tests for  and  to verify behavior with the new content correction logic, including diff generation and directory creation.
- Refined  by:
  - Introducing robust mocking for  and its methods (, , ) to simulate LLM interactions accurately.
  - Adding extensive test scenarios for , categorized by how  matches and how  is processed, including direct matches, unescaping, and LLM-based corrections.
  - Including tests for edge cases like no matches or multiple matches.
  - Adding a  utility for better test isolation.

Final fix for https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 15:02:08 -07:00
Taylor Mullen 5097b5a656 Fix(write-file): Correct over-escaping and improve content generation
- Leveraged existing edit correction technology from `edit.ts` to address over-escaping issues in `write-file.ts`.
- Introduced `ensureCorrectFileContent` for correcting content in new files, where a simple "replace" isnt applicable. This uses a new LLM prompt tailored for correcting potentially problematic string escaping.
- Added caching for `ensureCorrectFileContent` to optimize performance.
- Refactored `write-file.ts` to integrate these corrections, improving the reliability of file content generation and modification.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 14:45:47 -07:00
Taylor Mullen 1a5fe16b22 Ensure edit correction isn't re-done after confirm.
- Edit corretion leans on LLM-isms to ensure we properly fix poorly escaped content. Beacues of this we need to ensure that we don't re-run edit correction in many cases.
  - To ensure this an `LruCache` has been added to capture intermediate steps of edit correction to avoid re-computations.
  - Max cache size is 50 currently. This means a user can have a muti-confirmation flow of 25 items without recomputing anything (assuming they all break edit correction).
- Laid some groundwork for future testing.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 14:24:09 -07:00
Taylor Mullen c181fc1cf3 Correct edits even when auto-accept is enabled.
- Prior to this when a user would turn on auto-accept for edits we'd stop ensuring correct edits. This would result in a lot of back and forth by the model. This change also incoporates ensure correct edit into the normal execution flow.
- Added edit tests for this.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 14:18:54 -07:00
Taylor Mullen 48781272ee Trim edits if possible.
- Since we're now LLM correcting a lot of problematic edits we need to also potentially trim bad edits (llms have a bad habbit of adding whitespace places).

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 14:01:52 -07:00
Taylor Mullen 2e3eeaf920 Upon finding > 1 occurrences do not attempt auto-correction.
- When correcting edits prior to this if we found more than one occurrence we would try to auto-correct the old/new strings. There's no need in this situation because the tool has already provided too vague of an old_string to act upon. Instantly return.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 13:47:19 -07:00
Taylor Mullen ceb25c8350 refactor: Decouple new_string correction from old_string
- Previously, `new_string` was assumed to be over-escaped if `old_string` was.
- This change introduces an explicit check (`newStringPotentiallyEscaped`) to determine if `new_string` itself needs correction.
- If `new_string` is potentially escaped, its corrected using an LLM call; otherwise, the original `new_string` is used.
- This avoids unnecessary corrections to `new_string` when only `old_string` was problematic.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 13:40:58 -07:00
Taylor Mullen 24da7b3ca6 refactor: Correct Gemini's over-escaped new_string in replace tool
- Implement a heuristic to detect and unescape `new_string` if it appears Gemini has over-escaped it, while `old_string` is correctly formatted.
- This improves the reliability of the replace tool when the model generates an incorrectly escaped replacement string.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 13:30:08 -07:00
Taylor Mullen fa4a04157f refactor: Improve editCorrector logic and type safety
- Refactor `ensureCorrectEdit` to clarify the correction flow for `old_string` and `new_string`.
- Only correct `new_string` if it was potentially escaped; otherwise, use the original.
- Introduce `CorrectedEditParams` and `CorrectedEditResult` interfaces for better type definition.
- Relocate `countOccurrences` for better logical grouping.

Part of https://github.com/google-gemini/gemini-cli/issues/484
2025-05-25 13:18:07 -07:00
DeWitt Clinton 068b505d5e
Reduce excessive diff separators in CLI. (#535)
Increases the threshold for rendering diff separators in the CLI's diff display. Previously, a separator was shown for gaps of more than one context line, leading to excessive separators in diffs with many small changes close together (Issue #534).

By increasing `MAX_CONTEXT_LINES_WITHOUT_GAP` to 5, we allow for more context lines before a separator is added, significantly reducing visual clutter in such diffs.

Added a test case to `DiffRenderer.test.tsx` to verify that separators are not rendered for small gaps within the new threshold.
2025-05-25 10:26:51 -07:00
Taylor Mullen e297b56390 feat: Add GEMINI.md tip to UI
- Display a tip to create a GEMINI.md file if one doesn't exist.
- Pass config to Tips component so it can inspect the initial GEMINI.md
count.
2025-05-24 12:40:06 -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
DeWitt Clinton 7a3a9066f9
Add additional readline-like keybindings. (#524)
Adds the following conventional readline-like keybindings:

  - `Ctrl+H`: Delete the previous character.
  - `Ctrl+D`: Delete the next character.

Additionally, remaps the Debug Console command from Ctrl+D to Ctrl+O, which had been first introduced in PR #486.
2025-05-23 22:13:57 -07:00
Miguel Solorio 30080b9f4e 🧹 Format 2025-05-23 16:14:37 -07:00
Miguel Solorio 2a2d041dcd Update packages/cli/src/ui/types.ts
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-23 16:14:37 -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 1af19c57de Remove CLI info from footer 2025-05-23 16:14:37 -07:00
Miguel Solorio 221370acc5 Add `/about` command 2025-05-23 16:14:37 -07:00
Brandon Keiji 197c5b2bdf
infra: emit errors on no-explicit-any eslint rule (#516) 2025-05-23 22:35:50 +00:00
Taylor Mullen 1ff083af27 fix: Update dependencies to resolve deprecation warnings 2025-05-23 14:50:00 -07:00
cornmander 635666dec9
MCP SSE support (#511)
Matches the config format used by other MCP clients.
2025-05-23 17:19:30 -04:00
Brandon Keiji 8f266f9652
fix: do not retry cancelled tool calls (#504) 2025-05-23 17:30:09 +00:00
Jacob Richman 91ee02898a
feat: Modify loading indicator to support a paused state (#506) 2025-05-23 10:25:17 -07:00
Jordan Demeulenaere e993181628 Mention Kotlin & Compose (Mutliplatform) in prompt.ts 2025-05-23 10:14:54 -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
Olcan 70277591c4
update email to gemini-cli-dev (#510) 2025-05-23 08:35:16 -07:00
Olcan 564a213ebe
allow write to ~/.gitconfig in seatbelt profiles (#509) 2025-05-23 07:56:43 -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 1d0856dcc8
Fix(server): Ensure debug responses are not recorded after cancellation (#491) 2025-05-22 16:34:32 -07:00
N. Taylor Mullen 6d3af7b97f
Refactor: Consolidate and clarify core mandates and guidelines (#482)
Co-authored-by: Allen Hutchison <adh@google.com>
2025-05-22 22:42:33 +00:00
Brandon Keiji 3787aa78cd
fix: add shell-quote to server deps (#492) 2025-05-22 20:44:51 +00:00
Allen Hutchison 581709df80
Refactor: Streamline memoryUtils and update slash commands (#478) 2025-05-22 10:57:06 -07:00
Allen Hutchison 0c192555bb
Fix: Prevent hang in large directories by using BFS for getFolderStru… (#470)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
2025-05-22 10:47:21 -07:00
Jacob Richman 7eaf850489
Refactor: Improve console error/log display in CLI (#486) 2025-05-22 10:36:44 -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
Taylor Mullen 174fdce7d8 feat: Update feedback mechanism to use /bug command
- Replaces the previous email-based feedback with a /bug command in the system prompt.
2025-05-21 23:32:54 -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 efee7c6cce
Feat: Add test coverage scripts and ignore reports (#477) 2025-05-21 17:03:22 -07:00
Jacob Richman d74b0ac81d
Remove unneeded linebreaks in tool description in read-many-files. (#476) 2025-05-21 16:59:23 -07:00
Allen Hutchison 43da8bc747
Fix: Align WebSearchTool API key handling with GeminiClient (#474) 2025-05-21 15:50: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
Olcan c9de822930
fix exit code for shell tool (#465) 2025-05-21 08:51:22 -07:00
Olcan e30dc716b4
restore placeholder change likely dropped in a merge (#464) 2025-05-21 07:55:20 -07:00
Olcan 2080af029b
remove outdated $ echo example from help (#463) 2025-05-21 07:52:49 -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
Taylor Mullen 7fd7c1a539 fix(cli): Handle VSCode Shift+Enter in text buffer
- The text buffer now correctly interprets `\\\r` (produced by Shift+Enter in the VSCode terminal) as a newline character.
- Added a corresponding test case to `text-buffer.test.ts`.

Fixes https://buganizer.corp.google.com/issues/418505364
2025-05-20 23:44:53 -07:00
Taylor Mullen ba7f1e1e3c feat: Improve diff rendering with gap indicators
- Adds a visual indicator for skipped lines in the diff view.
- Updates tests to verify gap indicator rendering.
- Adjusts line number padding for better alignment.

Fixes https://b.corp.google.com/issues/414453107
2025-05-20 23:32:06 -07:00
Taylor Mullen 872f308536 feat: Allow Esc to exit shell mode
- Update InputPrompt.tsx to handle Esc key for exiting shell mode.
- Modify ShellModeIndicator.tsx to reflect the new keybinding.
Fixes https://buganizer.corp.google.com/issues/419087952
2025-05-20 22:47:11 -07:00
Jacob Richman 02ab0c234c
Merge InputPrompt and multiline-editor and move autocomplete logic directly into InputPrompt (#453) 2025-05-20 16:50:32 -07:00
Jacob Richman 937f473651
Update docs and tool description for read-many-files. (#456) 2025-05-20 16:32:49 -07:00
Olcan 17e28036fa
fix HOME in sandbox on cloudtops (linux) (#454) 2025-05-20 15:30:49 -07:00
Jacob Richman 716f7875a2
Support Images and PDFs (#447) 2025-05-20 13:02:41 -07:00
Olcan 26add7b078
fix system override indicator (#450) 2025-05-20 12:24:20 -07:00
Allen Hutchison 93e89215e3
Implementation of web search as a tool (#307) 2025-05-20 11:36:21 -07:00
DeWitt Clinton ee702c3139
Implement additional readline-like keybindings, including alt-left arrow and alt-right arrow. (#443)
This change adds keybinding support for:

  - `Ctrl+B`: Moves the cursor backward one character.
  - `Ctrl+F`: Moves the cursor forward one character.
  - `Alt+Left Arrow`: Moves the cursor backward one word.
  - `Alt+Right Arrow`: Moves the cursor forward one word.

Closes b/411469305.
2025-05-20 10:12:07 -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
Olcan 9c72a3ae12
ui tweaks (#442) 2025-05-19 16:58:57 -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
Olcan e1e59bf0cd
fix SIGPIPE and race condition causing dropping of final output ( "command not found" error) on cloudtops (#429) 2025-05-19 13:16:11 -07:00
Olcan 750649eb64
indicate system prompt override on bottom right; require GEMINI_SYSTEM_MD to make it more explicit; allow custom paths for read/write (#427) 2025-05-19 11:03:04 -07:00
Olcan 2a3c3d00ea
trim system prompt (#426) 2025-05-19 09:39:05 -07:00
Taylor Mullen 3d74a7061e fix(server): Use console.debug in GrepTool for less verbose logging
- Replaces `console.warn` and `console.error` calls with `console.debug` in `packages/server/src/tools/grep.ts`. This change reduces noise for the user, as `warn` and `error` messages are
displayed directly, while `debug` messages are not.
- Adds a comprehensive test suite for the GrepTool (`packages/server/src/tools/grep.test.ts`) to ensure its functionality remains robust after these changes and to cover various usage
scenarios.
- Improves error message consistency in `GrepTool`'s parameter validation and execution.

Fixes https://b.corp.google.com/issues/418648813
2025-05-18 23:19:15 -07:00
Taylor Mullen cd1dc7ec59 fix(cli): Disable slash commands and suggestions in shell mode
- Prevents slash commands from being triggered and suggestions from being displayed when shell mode is active. This ensures that user input is correctly interpreted as shell commands.

Fixes https://buganizer.corp.google.com/issues/418560826
2025-05-18 22:36:07 -07:00
Taylor Mullen db93ea736b feat(cli): Add ShellModeIndicator component
This commit introduces a new ShellModeIndicator component to visually signify when shell mode is active.

- Displays "shell mode enabled (! to toggle)" in the UI.
- The AutoAcceptIndicator is now hidden when shell mode is active to prevent UI clutter.
2025-05-18 22:18:49 -07:00
olcan 6cc0087105 allow comments in settings.json 2025-05-18 10:58:20 -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 0d4e0fe647 fix(cli): Remove duplicate auto-accept indicator
- The auto-accept edits indicator was appearing in two places:
  once next to the loading indicator and again in the CWD bar.
- This was introduced when the CWD bar was made always visible.
- This commit removes the duplicate indicator, leaving only the one
  in the CWD bar.

Fixes https://b.corp.google.com/issues/418498237
2025-05-18 00:31:55 -07:00
Taylor Mullen 3aaeb44739 fix(shell): Improve error reporting for shell command failures
This commit enhances the  tool to provide more informative feedback to the user when a shell command fails, especially in non-debug mode.

Previously, if a command terminated due to a signal (e.g., SIGPIPE during a  with no upstream) or failed without producing stdout/stderr, the user would see no output, making it difficult to diagnose the issue.

Changes:
- Modified  to update the  logic.
- If a command produces no direct output but results in an error, signal, non-zero exit code, or user cancellation, a concise message indicating this outcome is now shown in .
- Utilized the existing  utility from  for consistent error message formatting, which also resolved previous TypeScript type inference issues.

This ensures users receive clearer feedback on command execution status, improving the tool's usability and aiding in troubleshooting.

Fixes https://b.corp.google.com/issues/417998119
2025-05-18 00:25:53 -07:00
Taylor Mullen a0eb8e67c7 fix(glob): Improve glob tool accuracy and output
This commit enhances the glob tool by:

- Ensuring that glob patterns are used effectively. Previously, simple file names without glob syntax (e.g., "file.ts") would only search the root directory. This change encourages more precise glob patterns (e.g., "**\/file.ts") for broader searches.
- Returning absolute file paths instead of relative paths. This provides clearer, less ambiguous output and avoids encouraging the use of relative paths in subsequent operations.
- Adding comprehensive tests for various globbing scenarios, including case sensitivity and path specifications.

These changes address an issue where the glob tool could not find an expected item when a specific path was provided without appropriate glob syntax, and improve the overall reliability and usability of the tool.

Fixes https://b.corp.google.com/issues/418486553
2025-05-18 00:10:56 -07:00
Taylor Mullen f0b9199a77 refactor: Remove console.error from WriteFileTool
- Removes an unnecessary `console.error` call from the `shouldConfirmExecute` method in the `WriteFileTool` class.
- This logging was redundant as validation errors are already handled and returned by the method.
- Additionally, `console.error` is not suitable for this scenario, as incorrect arguments can be provided by the LLM, and these are anticipated and managed without needing an error log.

Fixes https://b.corp.google.com/issues/418491206
2025-05-17 23:06:50 -07:00
Taylor Mullen 5bddf40fd1 fix: Ensure CWD and auto-accept indicator are always visible
- This commit addresses an issue where the Current Working Directory (CWD) and the auto-accept indicator were not consistently visible, especially when tool confirmations were displayed.
- Previously, the CWD could be hidden during tool confirmation prompts, potentially leading to confusion about the context in which Gemini CLI was operating.

Fixes https://b.corp.google.com/issues/414289185
2025-05-17 22:50:06 -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
Olcan 9749fcb425
ability to write system prompt to file (#414) 2025-05-17 20:14:06 -07:00
Olcan 3bf0304e31
ability to override core system prompt (via .gemini/system.md) and specify core tools via coreTools setting (e.g. coreTools:["ls", "GrepTool", ...]) ; added tests, but did not update docs for now (#413) 2025-05-17 19:45:16 -07:00
Olcan 76cf5e9fc1
rename env vars GEMINI_CODE_{MODEL,SANDBOX,SANDBOX_IMAGE} (#411) 2025-05-17 17:28:44 -07:00
Olcan 4de4822219
added timeout setting to mcp server config, also switched to custom config type without "stderr" field that does not make sense in settings (#410) 2025-05-17 16:53:22 -07:00
olcan 324040032a fix multiple mcp servers 2025-05-17 14:14:59 -07:00
Taylor Mullen feb9dee4b1 fix: Prevent WriteFileTool from writing to directory paths
- Enhances WriteFileTool validation to check if the target file_path is an existing directory.
- If it is, the tool now returns a validation error "Path is a directory, not a file: <filePath>", preventing the attempt to write.
- This proactive check avoids underlying file system errors that would occur if fs.writeFileSync were called on a directory path, which could lead to console errors.
- Test cases have been updated to reflect this stricter validation.

Fixes https://b.corp.google.com/issues/418348176
2025-05-17 00:01:35 -07:00
Taylor Mullen 5dcdbe64ab refactor: Unify file modification confirmation state
- Modifies `EditTool` and `WriteFileTool` to share a single confirmation preference.
- The "Always Proceed" choice for file modifications is now stored in `Config.alwaysSkipModificationConfirmation`.
- This ensures that if a user chooses to always skip confirmation for one file modification tool, this preference is respected by the other.
- `WriteFileTool` constructor now accepts `Config` instead of `targetDir` to facilitate this shared state.
- Tests updated to reflect the new shared confirmation logic.

Fixes https://b.corp.google.com/issues/415897960
2025-05-16 23:34:48 -07:00
Taylor Mullen 58e0224061 Refactor: Use String.prototype.replaceAll() and update TS lib
- Replaces the custom `replaceAll` implementation in `packages/server/src/tools/edit.ts` with the standard `String.prototype.replaceAll()`.
- Updates `packages/server/tsconfig.json` to include `ES2021` in the `lib` compiler options to ensure TypeScript recognizes this method. This aligns with the project's Node.js version requirements \(Node.js 16.x+\).

Fixes https://github.com/google-gemini/gemini-cli/issues/7
2025-05-16 22:43:50 -07:00
Taylor Mullen e486d84d6a feat: Patch console.debug and display only in debug mode
- Patches `console.debug` in `ConsolePatcher.tsx` to capture debug messages.
- Updates `ConsoleOutput` to only display debug messages when `debugMode` is enabled.
- Passes `debugMode` prop from `App.tsx` to `ConsoleOutput`.

Fixes https://github.com/google-gemini/gemini-cli/issues/397
2025-05-16 22:29:12 -07:00
Taylor Mullen e0b88dc8da feat: Strip schema props from MCP tool definitions
- This change modifies the tool discovery process for MCP (Model Context Protocol) tools.
- When tools are fetched from an MCP server, the `additionalProperties` and `$schema` fields are now recursively removed from their input schemas. This ensures cleaner and more concise tool definitions within the CLI, aligning with the expected schema structure and preventing potential conflicts or verbose outputs.
- The corresponding tests in `tool-registry.test.ts` have been updated to reflect this new behavior and verify the correct stripping of these properties.

Workaround for https://github.com/google-gemini/gemini-cli/issues/398
2025-05-16 22:14:51 -07:00
Taylor Mullen 0e25fdd56e Avoid console.log for MCP
- Prior to this when attached MCP servers would report content we'd fall back to `console.log` which doesn't work well in  an Ink application.

Fixes https://github.com/google-gemini/gemini-cli/issues/397
2025-05-16 21:19:33 -07:00
Taylor Mullen 7f7f2cd47e GC "add tool registry tests"
- Ok
2025-05-16 17:04:29 -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
Olcan d9bd2b0e14
improved mcp support, including standard "mcpServers" setting with multiple named servers with command/args/env/cwd (#392) 2025-05-16 16:29:03 -07:00
Sébastien Cevey 48c3470303
Fix typo in server README.md (#379) 2025-05-16 14:27:25 -07:00
Jacob Richman 8b959c2060
strip escape characters when pasting. (#386) 2025-05-16 13:17:48 -07:00
Jacob Richman c692a0c583
Support auto wrapping of in the multiline editor. (#383) 2025-05-16 11:58:37 -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
sasha-gitg 609757f911
feat: Add support for Vertex AI and Vertex express mode (#380) 2025-05-16 08:06:43 -07:00
N. Taylor Mullen 7d818b46bc
feat: Enable CI test reporting and artifact management (#367) 2025-05-15 22:59:53 -07:00
Taylor Mullen 9c46acc793 Refactor: Improve UI rendering and address code review comments
This commit addresses several code review comments primarily focused on improving the rendering and stability of the CLI UI.

Key changes include:
- Passing `isPending` and `availableTerminalHeight` props to `MarkdownDisplay` to enable more intelligent rendering of content, especially for pending messages and code blocks.
- Adjusting height calculations in `ToolGroupMessage` and `ToolMessage` to more accurately reflect available space.
- Refining the logic in `App.tsx` for measuring and utilizing terminal height, including renaming `footerRef` to `mainControlsRef` for clarity.
- Ensuring consistent prop drilling for `isPending` and `availableTerminalHeight` through `HistoryItemDisplay`, `GeminiMessage`, and `GeminiMessageContent`.
- In `MarkdownDisplay`, when `isPending` is true and content exceeds `availableTerminalHeight`, the code block will now be truncated with a "... generating more ..." message. If there's insufficient space even for the
message, a simpler "... code is being written ..." will be shown.
2025-05-15 22:57:28 -07:00
Taylor Mullen 33743d347b Fix: Prevent UI tearing and improve display of long content
This commit introduces several changes to better manage terminal height and prevent UI tearing, especially when displaying long tool outputs or when the pending history item exceeds the available terminal height.

- Calculate and utilize available terminal height in `App.tsx`, `HistoryItemDisplay.tsx`, `ToolGroupMessage.tsx`, and `ToolMessage.tsx`.
- Refresh the static display area in `App.tsx` when a pending history item is too large, working around an Ink bug (see https://github.com/vadimdemedes/ink/pull/717).
- Truncate long tool output in `ToolMessage.tsx` and indicate the number of hidden lines.
- Refactor `App.tsx` to correctly measure and account for footer height.

Fixes https://b.corp.google.com/issues/414196943
2025-05-15 22:57:28 -07:00
Taylor Mullen 601a61ed31 Addressed code review comments 2025-05-15 21:57:10 -07:00
Taylor Mullen 6cb6f47b56 Refactor: Replace MarkdownRenderer with MarkdownDisplay component
- This commit refactors the Markdown rendering logic within the CLI UI.
  The existing `MarkdownRenderer.tsx` class-based component has been
  replaced with a new functional component `MarkdownDisplay.tsx`.
- The `MarkdownDisplay` component is a React.memoized component for
  improved performance and maintains the same core Markdown parsing
  and rendering capabilities.
2025-05-15 21:57:10 -07:00
Miguel Solorio 9862cf3204
UI improvements for suggestions & status (#373) 2025-05-15 16:35:21 -07:00