Commit Graph

471 Commits

Author SHA1 Message Date
Taylor Mullen a2cdd205b5 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 0eb4037523 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 22bf686c22 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 d02323b5c1 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 19b7c8e97a 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 9b2a01be9d 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 f07e421561 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 0f23df7c66 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 b927697bef 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 84cd998af3 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 e7c7ab908e 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 3fd511a7ee Make console message support more robust to logging in the middle of rendering. (#521) 2025-05-23 22:51:47 -07:00
DeWitt Clinton 298953a719 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 f943ed77fe 🧹 Format 2025-05-23 16:14:37 -07:00
Miguel Solorio 4e831e4d21 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 18c9322fa5 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 78e19038ae Remove CLI info from footer 2025-05-23 16:14:37 -07:00
Miguel Solorio 5ae4445321 Add /about command 2025-05-23 16:14:37 -07:00
Taylor Mullen c8a48306e4 feat: Enable npx execution on tagged versions
- Modify root package.json to allow publishing
- Update "files" to include only essential bundled assets

This change makes it possible to use npx with tagged versions of the
gemini-cli package (e.g., npx https://github.com/google-gemini/gemini-cli@early-access).
It removes "private: true" and refines the "files" array to ensure
that only the necessary bundled assets are included when the package is
fetched by npx, optimizing download size and ensuring correct execution.
2025-05-23 15:55:29 -07:00
Brandon Keiji e34b1fe782 infra: emit errors on no-explicit-any eslint rule (#516) 2025-05-23 22:35:50 +00:00
Taylor Mullen e68c69594e fix: Update dependencies to resolve deprecation warnings 2025-05-23 14:50:00 -07:00
cornmander a83ef4b13b MCP SSE support (#511)
Matches the config format used by other MCP clients.
2025-05-23 17:19:30 -04:00
Taylor Mullen 870adc521d feat: Enable npx execution directly from GitHub URL
This commit modifies the packaging setup to allow the CLI to be
executed directly from its GitHub URL using `npx`, for example:
`npx https://github.com/google-gemini/gemini-cli` (once merged to main).
This is achieved without requiring the bundle to be checked into
the repository.

Key changes and motivations:

- Modify `scripts.prepare` to run `npm run bundle`:
  Ensures the CLI bundle is generated automatically when `npx`
  installs the package from a git URL. This replaces previous
  approaches (e.g., using `prepack`) which were not consistently
  triggered in the `npx` environment.

- Update `scripts.bundle` to use a direct path for `esbuild`
  and externalize `sqlite3`:
  Using `node_modules/.bin/esbuild` provides a more reliable way
  to invoke the bundler. Externalizing `sqlite3` is crucial for
  correctly handling its native addon, preventing runtime errors.

- Add `bin`, `files`, and root `sqlite3` dependency:
  - The `bin` field defines the `gemini` command.
  - The `files` array ensures the generated `bundle/` directory is
    recognized by npm.
  - `sqlite3` is added as a root dependency to ensure it's
    installed by `npx` when `gemini-code` is fetched, allowing the
    externalized module to be resolved.

These changes collectively ensure that the necessary build artifacts
are created on-the-fly during `npx` installation, providing a
seamless execution experience directly from the GitHub repository URL.
2025-05-23 13:55:06 -07:00
Brandon Keiji 4bc9be3230 fix: do not retry cancelled tool calls (#504) 2025-05-23 17:30:09 +00:00
Jacob Richman 94af6cdd67 feat: Modify loading indicator to support a paused state (#506) 2025-05-23 10:25:17 -07:00
Jordan Demeulenaere 3370b38773 Mention Kotlin & Compose (Mutliplatform) in prompt.ts 2025-05-23 10:14:54 -07:00
Jacob Richman 0a9505e9a2 Fix bug updating the cursor after navigating history. (#507) 2025-05-23 09:40:01 -07:00
Allen Hutchison 858be0e9c5 Refactor(server): Centralize GEMINI.md discovery logic in server (#498) 2025-05-23 08:53:22 -07:00
Allen Hutchison c28ca00289 Refactor(cli): Move memory add logic to server tool call (#493) 2025-05-23 08:47:19 -07:00
Olcan be79843c37 update email to gemini-cli-dev (#510) 2025-05-23 08:35:16 -07:00
Olcan ccefef9919 allow write to ~/.gitconfig in seatbelt profiles (#509) 2025-05-23 07:56:43 -07:00
Taylor Mullen 2bceb9223d 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 2b61d08dff feat: add emphasis to tool confirmations (#502) 2025-05-23 05:28:31 +00:00
Allen Hutchison 80e61b941e Fix(server): Ensure debug responses are not recorded after cancellation (#491) 2025-05-22 16:34:32 -07:00
N. Taylor Mullen edb3edf6be 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
Allen Hutchison 177359ce3c Chore: Integrate coverage reporting into CI (#479) 2025-05-22 13:47:12 -07:00
Brandon Keiji c087cba2c6 fix: add shell-quote to server deps (#492) 2025-05-22 20:44:51 +00:00
Allen Hutchison a738bdbbbb Refactor: Streamline memoryUtils and update slash commands (#478) 2025-05-22 10:57:06 -07:00
Allen Hutchison 68a5eec345 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 7cd86cbd69 Refactor: Improve console error/log display in CLI (#486) 2025-05-22 10:36:44 -07:00
Brandon Keiji 2a76473b98 fix: cancel parallel tool calls mid-execution (#489) 2025-05-22 03:02:45 -07:00
Brandon Keiji 4eea2e594b fix: synchronization between executed tools and turn loops (#488) 2025-05-22 02:51:07 -07:00
Taylor Mullen 495b3a7c56 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 3aa1485865 fix: forward entire tool call confirmation object through useToolScheduler (#481) 2025-05-22 06:00:36 +00:00
Brandon Keiji 854de99e34 feat: useToolScheduler hook to manage parallel tool calls (#448) 2025-05-21 22:57:53 -07:00
Allen Hutchison b0075bacba Feat: Add test coverage scripts and ignore reports (#477) 2025-05-21 17:03:22 -07:00
Jacob Richman 2ed6993f83 Remove unneeded linebreaks in tool description in read-many-files. (#476) 2025-05-21 16:59:23 -07:00
Allen Hutchison a2f7f14a9d Fix: Align WebSearchTool API key handling with GeminiClient (#474) 2025-05-21 15:50:53 -07:00
Allen Hutchison a05fc1127b Fix: Resolve CLI version reporting in /bug command (#455) 2025-05-21 13:31:18 -07:00
Olcan 6b218284f8 use pending history item for shell mode, update as output is received (#471) 2025-05-21 13:16:50 -07:00