-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Load extension settings for hooks, agents, skills #17245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @chrstnb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Gemini CLI extension ecosystem by ensuring that extension settings are dynamically loaded and applied across all components—hooks, agent skills, and agents. It introduces a mechanism to restart extensions upon configuration changes, guaranteeing that updates take effect immediately. This improves the developer experience by making extension settings more robust, flexible, and responsive to user modifications. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Size Change: +1.42 kB (+0.01%) Total Size: 23.4 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a crucial feature for improving the developer experience with extensions: settings are now immediately applied to hooks, skills, and agents upon configuration by restarting the extension. However, two significant security vulnerabilities have been identified. First, a high-severity Command Injection vulnerability exists due to improper escaping of variables substituted into shell commands within hooks. Second, a critical Information Disclosure vulnerability allows sensitive environment variables from .env files to be unintentionally leaked into extension hook execution environments. It is recommended to apply proper shell escaping for command variables and to explicitly construct hook environments using only intended settings.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request successfully implements extension setting hydration for hooks, agent skills, and agents, introducing a restartExtension mechanism for real-time configuration updates. However, it also introduces a critical command injection vulnerability. This occurs because extension settings loaded from the workspace's .env file are used for raw string substitution in shell commands without proper trust checks, potentially allowing arbitrary code execution on the user's machine. While the overall implementation aligns with the stated goals and includes new test cases, addressing this security flaw is paramount. Recommendations for remediation, focusing on enforcing workspace trust and avoiding insecure string hydration in sensitive sinks, have been provided.
|
Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request. To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues. If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding! |
Summary
Extensions can define custom settings (e.g., API keys, model names, paths) that users can configure. These settings are then made available to the various components of the extension: hooks, skills, and agents.
Details
Provide these values in the following ways:
Related Issues
Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1282
How to Validate
1. Defining Settings
Extensions define their settings in
gemini-extension.json.{ "name": "my-extension", "version": "1.0.0", "settings": [ { "name": "API Key", "description": "Your API Key for the service", "envVar": "MY_SERVICE_API_KEY", "sensitive": true }, { "name": "Model Name", "description": "The model to use", "envVar": "MY_MODEL_NAME" } ] }2. Usage in Components
A. Hooks (Command Hooks)
For hooks, which execute external shell commands, settings are injected as environment variables. This is the standard and most secure way to pass configuration to subprocesses.
Example
hooks/hooks.json:{ "hooks": { "postCommand": [ { "command": "python script.py", "name": "My Hook" } ] } }Behavior:
When
python script.pyis executed, the process environment will contain:MY_SERVICE_API_KEY=...MY_MODEL_NAME=...GEMINI_PROJECT_DIR.Note: You do not need to use
${VAR}syntax in thecommandstring itself unless you want to substitute it into the command line arguments (e.g.,echo ${MY_MODEL_NAME}). However, relying on the environment variable inside your script is generally cleaner and safer.B. Agent skills
For skills defined in
skills/SKILL.md, settings are applied via text variable hydration. You can use${VAR_NAME}placeholders anywhere in the file (frontmatter or body).Example
skills/my-skill/SKILL.md:Behavior:
When the extension is loaded,
${MY_SERVICE_API_KEY}and${MY_MODEL_NAME}are replaced with their configured values before the skill is registered with the system.C. Agents
For local agents defined in
agents/my-agent.md, settings are also applied via text variable hydration. This is particularly useful for parametrizing the system prompt.Example
agents/my-agent.md:Behavior:
The system prompt and frontmatter fields are hydrated with the user's settings upon load.
3. Configuration & updates
Configure settings using the CLI command:
gemini extensions config my-extension # or specific setting gemini extensions config my-extension MY_MODEL_NAMEPre-Merge Checklist