Skip to content

feat: implement Open Plugins hooks support#23697

Open
NTaylorMullen wants to merge 1 commit intontm/gh.1594from
ntm/gh.1593
Open

feat: implement Open Plugins hooks support#23697
NTaylorMullen wants to merge 1 commit intontm/gh.1594from
ntm/gh.1593

Conversation

@NTaylorMullen
Copy link
Collaborator

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

  • Hook Discovery: Automatically discovers hooks from plugin.json or hooks/hooks.json at the plugin root.
  • Protocol Translation: Implements OpenPluginTranslator to map internal Gemini events (e.g., BeforeTool) to Open Plugin events (e.g., onTool).
  • Variable Expansion: Supports ${PLUGIN_ROOT} expansion in hook commands.
  • Environment Injection: Injects PLUGIN_ROOT into the environment for hook child processes.
  • Metadata Alignment: Updated ExtensionConfig and GeminiCLIExtension interfaces to include standard Open Plugin fields (repository, homepage, logo, keywords).
  • Type Safety: Refactored manifest parsing and hook resolution for strict TypeScript compliance and ESLint alignment.

Related Issues

Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1593

How to Validate

  1. Run the new unit tests:
    npm test -w @google/gemini-cli -- src/config/open-plugin-discovery.test.ts
    npm test -w @google/gemini-cli-core -- src/hooks/openPluginTranslator.test.ts
  2. Run a full build to ensure no regressions:
    npm run build
  3. (Manual) Create a plugin with a hooks/hooks.json and verify the hook is triggered during the corresponding event.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed) - Interfaces updated to support metadata.
  • Added/updated tests (if needed) - Added openPluginTranslator.test.ts and updated open-plugin-discovery.test.ts.
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt

@NTaylorMullen NTaylorMullen requested review from a team as code owners March 24, 2026 19:26
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • ⚠️ Consider adding Evals: No behavioral evaluations (evals/*.eval.ts) were added or updated in this PR. Consider adding a test case to verify the new behavior and prevent regressions.
  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

@NTaylorMullen NTaylorMullen changed the base branch from main to ntm/gh.1594 March 24, 2026 19:26
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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

  • Open Plugin Hooks Support: Implemented support for Open Plugins hooks, allowing plugins to intercept and modify core Gemini events like tool calls, prompts, and model interactions using the standard Open Plugin protocol.
  • Hook Discovery and Translation: Enabled automatic discovery of hooks from plugin.json or hooks/hooks.json and introduced OpenPluginTranslator to map internal Gemini events to Open Plugin events.
  • Variable Expansion and Environment Injection: Added support for ${PLUGIN_ROOT} expansion in hook commands and injected PLUGIN_ROOT into the environment for hook child processes.
  • Metadata Alignment and Type Safety: Updated ExtensionConfig and GeminiCLIExtension interfaces to include standard Open Plugin fields and refactored manifest parsing for strict TypeScript compliance and ESLint alignment.
  • Enhanced Extension Loading Logic: Refactored the extension manager to bifurcate loading based on manifest type (Gemini CLI or Open Plugin) and improved error handling for missing configurations.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@NTaylorMullen NTaylorMullen changed the base branch from ntm/gh.1594 to ntm/gh.1595 March 24, 2026 19:26
@NTaylorMullen NTaylorMullen changed the base branch from ntm/gh.1595 to ntm/gh.1592 March 24, 2026 19:27
@NTaylorMullen NTaylorMullen changed the base branch from ntm/gh.1592 to ntm/gh.1594 March 24, 2026 19:35
@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 24, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant