Go to file
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
.github/workflows Fix remaining tslint errors (YAY). 2025-04-18 19:14:36 -04:00
.vscode Configure linter + prettier. 2025-04-17 15:29:34 -07:00
eslint-rules feat: add custom eslint rule for cross-package imports (#77) 2025-04-21 08:02:11 -07:00
packages Fix Gemini Code's (GC) smarts. 2025-04-21 11:07:09 -04:00
scripts seamless sandboxing (just set GEMINI_CODE_SANDBOX=true in .env) (#76) 2025-04-21 07:50:18 -07:00
.gitignore Quick fix gitignore (#49) 2025-04-19 07:01:54 -07:00
.npmrc fix: temporarily comment out .npmrc (#43) 2025-04-18 16:18:44 -07:00
.prettierrc.json Run `npm run format` 2025-04-17 15:29:34 -07:00
Dockerfile 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
LICENSE add LICENSE (#25) 2025-04-18 10:30:07 -07:00
README.md Update README to reflect current state of the world. 2025-04-20 22:25:20 -04:00
eslint.config.js feat: add custom eslint rule for cross-package imports (#77) 2025-04-21 08:02:11 -07:00
package-lock.json 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
package.json feat: add custom eslint rule for cross-package imports (#77) 2025-04-21 08:02:11 -07:00
tsconfig.json refactor: clean up build output (#53) 2025-04-20 12:33:39 -07:00

README.md

Gemini Code

Disclaimer: This README.md was created by gemini-code and this project was developed rapidly and currently lacks comprehensive testing, and other quality-of-life features common in mature projects.

This repository contains the Gemini Code CLI tool.

Setup

  1. Get a Gemini API Key: Obtain your API key from Google AI Studio: https://aistudio.google.com/app/apikey
  2. Set Environment Variable: Set the GEMINI_API_KEY environment variable to your obtained key. You can do this temporarily in your current shell session:
    export GEMINI_API_KEY="YOUR_API_KEY"
    
    Or add it to your shell's configuration file (like ~/.bashrc, ~/.zshrc, or ~/.profile) for persistence:
    echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc # Or your preferred shell config file
    source ~/.bashrc # Reload the config
    
    Replace "YOUR_API_KEY" with your actual key.

Building

To build the entire project, including the CLI package, run the following command from the root directory:

npm install
npm run build

This command installs dependencies and then runs the build script defined in the root package.json, which in turn executes the build scripts in all workspaces (including packages/cli).

Running

To start the Gemini Code CLI, run the following command from the root directory:

npm start

This command executes the start script defined in the root package.json, which specifically targets and runs the start script within the gemini-code-cli workspace.

Debugging

To debug the CLI application using VS Code:

  1. Start the CLI in debug mode from the root directory:
    npm run debug --workspace=gemini-code-cli
    
    This command runs node --inspect-brk dist/gemini.js within the packages/cli directory, pausing execution until a debugger attaches.
  2. In VS Code, use the "Attach" launch configuration (found in .vscode/launch.json). This configuration is set up to attach to the Node.js process listening on port 9229, which is the default port used by --inspect-brk.

Alternatively, you can use the "Launch Program" configuration in VS Code if you prefer to launch the currently open file directly, but the "Attach" method is generally recommended for debugging the main CLI entry point.

Formatting

To format the code in this project, run the following command from the root directory:

npm run format

This command uses Prettier to format the code according to the project's style guidelines.

Linting

To lint the code in this project, run the following command fro the root directory:

npm run lint

Chances are you will need to manually address errors output. You can also try npm run lint -- --fix where some errors may be resolved.