Commit Graph

673 Commits

Author SHA1 Message Date
Brandon Keiji ef7dcdb49e
feat: add alias to the cli bin directive (#126) 2025-04-23 01:04:34 +00: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 5c5c470671 Update confirmation dialog UI
- This chaneset aligns our confirmation dialog with: https://screenshot.googleplex.com/9yZCX636LzpMrgc
- Primary changes include having custom indicators for confirmation options that align with our coloring / scheme

Fixes https://b.corp.google.com/issues/412607128
2025-04-22 10:33:06 -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
Olcan a7fba66832
env var to set default model, display model on lower right (#110) 2025-04-21 23:25:10 -07:00
Brandon Keiji 79710375e3
fix: point npmrc to dogfood artifact registry (#108) 2025-04-21 23:11:51 -07: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 843d7c1fe3
Fix the broken build (#98) 2025-04-21 15:44:20 -07:00
Olcan 319f211211
improved (full color) sandbox, mount /tmp to display build warnings, display sandbox name in footer (#96) 2025-04-21 14:43:43 -07:00
Brandon Keiji dec9726083
fix: use relative imports within the same package (#93) 2025-04-21 14:09:14 -07:00
Jaana Dogan d4614619b4
Remove dead comments (#90) 2025-04-21 13:06:46 -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 9d608135e3
Make model-generated code copyable (#70) 2025-04-20 21:48:30 +01: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
Brandon Keiji f480ef4bbc
refactor: clean up build output (#53)
* refactor: clean up build output

* refactor: add index.ts to package roots
2025-04-20 12:33:39 -07: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
Olcan 99f5ed9ecb
Minimal container setup. Install docker (or podman), build container with scripts/build_container.sh, then start with scripts/start_container.sh. Exit with ^C for now. (#61) 2025-04-20 08:22:17 -07:00
Taylor Mullen f7edf71190 Give Gemini Code a face lift.
- This utilizes `ink-gradient` to render GEMINI CODE in amazing colors.
- Added a shared color configuration for UX (should this be in config?). It's very possible that we shouldn't be talking about the specific colors and instead be mentioning "foreground"/"background"/inlineCode etc. type colors.
- Updated existing color usages to utilize `Colors.*`

Fixes https://b.corp.google.com/issues/411385593
2025-04-19 17:10:06 -04: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 0c9e1ef61b
Adding some simple tests. (#54) 2025-04-19 18:07:24 +01:00
Allen Hutchison d9ad2a74ae
Fix the double warning for iterm. (#51) 2025-04-19 07:02:12 -07: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
Jaana Dogan 24371a3954
Take the turn management out of GeminiClient (#42) 2025-04-18 23:11:33 -07:00
Jaana Dogan 65e8e3ed1f
Show error when GEMINI_API_KEY is not set (#52)
Also fix the bug where the API key is used accidentally as the model name.
2025-04-18 19:26:16 -07: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
Olcan f3669f20a9
minor lint fix (#45) 2025-04-18 16:38:01 -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
Brandon Keiji 2a850ed051
fix: add --build flag to tsc commands (#40) 2025-04-18 16:14:20 -07: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
Brandon Keiji 23b43ff651
fix: add clean command to individual packages (#36) 2025-04-18 14:57:20 -07: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
Allen Hutchison dfae3f6284
Iterm refactor (#33)
* Add a warning about the flickering in iTerm.

* Move the iterm warning out of App.tsx.
2025-04-18 14:39:05 -07:00
Brandon Keiji 52683dafc3
infra: add multipackage support (#34) 2025-04-18 14:37:02 -07:00
Allen Hutchison f51ca774cf
Add a warning about the flickering in iTerm. (#32) 2025-04-18 14:09:06 -07: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
Allen Hutchison 3ed61f1ff2
Web fetch tool (#31)
* Adding a web fetch tool.
2025-04-18 13:20:39 -07:00
Brandon Keiji 56d4a35d05
feat: initial configs for npm publishing (#30)
* feat: initial configs for npm publishing

* fix: workspace reference

* fix: include LICENSE in npm run build
2025-04-18 12:46:42 -07:00
Taylor Mullen abb60a4d10 Finish manually fixing linter errors for tools dir (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 14:41:36 -04:00
Jaana Dogan 328846c6e3
Remove extra args from config (#27)
We don't have a use case for them yet.
2025-04-18 11:26:39 -07: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
Jaana Dogan e1fac40256
Rename invalidParams to validateToolParams (#12)
Methods should be verbs. Fixes #4.
2025-04-18 11:06:30 -07:00
Taylor Mullen 7cd3b95317 Fix linting errors in a number of core and tool files (partial)
- As part of this work I also started building out errors.ts which will be a cumulation of error helpers to better handle the challenging `catch (error: unknown)` requirement.
- 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 14:02:09 -04:00
Jaana Dogan 93fd6a9160
Style improvements to ls tool (#14) 2025-04-18 10:57:20 -07:00
Evan Senter f6a4a5c44d Revert "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."
This reverts commit 1bfc62dcc2.
2025-04-18 18:36:33 +01:00
Evan Senter bb95c8c45a Revert "Adding support for up / down arrows in the command history."
This reverts commit 3829ac6353.
2025-04-18 18:36:33 +01: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
Brandon Keiji 999d0568fa
Refactor: Update API key missing message with link (#23) 2025-04-18 10:25:32 -07: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
Evan Senter 3829ac6353 Adding support for up / down arrows in the command history. 2025-04-18 18:16:52 +01:00
Evan Senter 1bfc62dcc2 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. 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
Evan Senter cb30351403
Adding a new parameter for model, and updating the default to 2.5 Flash. (#18) 2025-04-18 17:06:16 +01: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
Taylor Mullen 7928c1727f Configure linter + prettier.
- This is based on existing expectations for TS code in Google-esc repos.
- First part of the change (we have not run any linter or formatting commands). After this changeset goes in I'll do a mass changeset push.

Fixes https://b.corp.google.com/issues/411384603
2025-04-17 15:29:34 -07:00
Taylor Mullen d970882428 Fix build break (tool -> tools).
- Without this we'd get a TS1261 about the name "tool" only differeing from "Tool" (the class) by case.
2025-04-17 17:25:01 -04:00
Taylor Mullen ece8630c33 Revert camelCasing for schemas 2025-04-17 14:15:20 -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
Brandon Keiji 898a83031c
docs: Add setup instructions for API key to README (#1) 2025-04-17 11:59:12 -07:00
Allen Hutchison f10aaf7e7e fix: Suppress crash from unhandled 429 stream error via global handler
Introduces a process.on('unhandledRejection') handler in src/gemini.ts
as a workaround for an issue where 429 ClientErrors originating from
the @google/genai library's sendMessageStream during iteration can
cause an unhandled rejection, even when caught within local try/catch
blocks in the application code (e.g., in processGeminiStream).
The handler specifically identifies this known 429 ClientError based on
its type and message content. If matched, it logs a warning indicating
the known issue is being suppressed and prevents process.exit(1).
Any other genuinely unhandled promise rejections will still be logged
as critical errors and will terminate the application, maintaining
default behavior for unexpected issues. This workaround mitigates a
suspected library-internal problem related to error propagation during
asynchronous stream iteration.
2025-04-17 13:20:11 -04:00
Taylor Mullen 123c3050dc Add and update README files
- Adds a detailed README.md to the `packages/cli` directory covering build, run, and debug instructions specific to the CLI package.
- Updates the root README.md with comprehensive project information, including cloning instructions (Gerrit), monorepo build/run/debug steps, and references to relevant resources.

Created by yours truly: __Gemini Code__
2025-04-17 13:20:06 -04: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