feat: implement Open Plugins hooks support#23697
feat: implement Open Plugins hooks support#23697NTaylorMullen wants to merge 1 commit intontm/gh.1594from
Conversation
🧠 Model Steering GuidanceThis PR modifies files that affect the model's behavior (prompts, tools, or instructions).
This is an automated guidance message triggered by steering logic signatures. |
Summary of ChangesHello, 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 introduces comprehensive support for Open Plugins within the Gemini CLI, significantly enhancing its extensibility. It allows external plugins to define and register hooks that can react to and influence various core CLI operations, such as tool execution and model interactions. The changes involve a new manifest discovery mechanism, event translation, and robust variable expansion, ensuring seamless integration and improved type safety for both existing Gemini extensions and new Open Plugins. 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. Footnotes
|
1c8696d to
3509a34
Compare
3509a34 to
5770abf
Compare
- Implement discovery of hooks from plugin.json and hooks/hooks.json at the plugin root
- Add support for ${PLUGIN_ROOT} variable expansion in hook command strings
- Implement Open Plugin protocol for hook execution, including JSON communication over stdin/stdout
- Add OpenPluginTranslator to map Gemini internal events to standard Open Plugin events (e.g., BeforeTool -> onTool)
- Translate Open Plugin hook responses (e.g., allow: false) to Gemini hook decisions (e.g., decision: 'block')
- Inject PLUGIN_ROOT into the environment for hook child processes
- Include plugin_name and plugin_root in the HookInput passed to Open Plugin hooks
- Align ExtensionConfig and GeminiCLIExtension with Open Plugin metadata (repository, homepage, etc.)
- Refactor for type safety and cleaner ESLint compliance
Fixes google-gemini/maintainers-gemini-cli#1593
5770abf to
2b85575
Compare
Summary
Implement support for Open Plugins hooks in Gemini CLI. This allows plugins to intercept and modify core Gemini events (like tool calls, prompts, and model interactions) using the standard Open Plugin protocol.
Details
plugin.jsonorhooks/hooks.jsonat the plugin root.OpenPluginTranslatorto map internal Gemini events (e.g.,BeforeTool) to Open Plugin events (e.g.,onTool).${PLUGIN_ROOT}expansion in hook commands.PLUGIN_ROOTinto the environment for hook child processes.ExtensionConfigandGeminiCLIExtensioninterfaces to include standard Open Plugin fields (repository,homepage,logo,keywords).Related Issues
Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1593
How to Validate
hooks/hooks.jsonand verify the hook is triggered during the corresponding event.Pre-Merge Checklist
openPluginTranslator.test.tsand updatedopen-plugin-discovery.test.ts.