# 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> |
||
---|---|---|
.. | ||
src | ||
README.md | ||
index.ts | ||
package.json | ||
tsconfig.json | ||
vitest.config.ts |
README.md
Gemini CLI
This package contains the core command-line interface for Gemini CLI.
Setup
- Get a Gemini API Key: Obtain your API key from Google AI Studio: https://aistudio.google.com/app/apikey
- Set Environment Variable: Set the
GEMINI_API_KEY
environment variable to your obtained key. You can do this temporarily in your current shell session:
Or add it to your shell's configuration file (likeexport GEMINI_API_KEY="YOUR_API_KEY"
~/.bashrc
,~/.zshrc
, or~/.profile
) for persistence:
Replaceecho 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc # Or your preferred shell config file source ~/.bashrc # Reload the config
"YOUR_API_KEY"
with your actual key.
Building
To build only the CLI package, navigate to this directory (packages/cli
) and run:
npm run build
This command executes the TypeScript compiler (tsc
) as defined in this package's package.json
. Ensure dependencies have been installed from the root directory (npm install
) first.
Running
To start the Gemini CLI directly from this directory:
npm start
This command executes node dist/gemini.js
as defined in this package's package.json
.
Debugging
To debug the CLI application using VS Code:
- Start the CLI in debug mode from this directory (
packages/cli
):
This command runsnpm run debug
node --inspect-brk dist/gemini.js
, pausing execution until a debugger attaches. - In VS Code (opened at the root of the monorepo), 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
.