- Notifications
You must be signed in to change notification settings - Fork 126
Hooked #12
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
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.
Summary of Changes
Hello @jamubc, 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 delivers a comprehensive overhaul of the Gemini-Claude integration, focusing on reliability, efficiency, and user experience. It addresses long-standing issues with file reference handling and unnecessary file reading, introduces a groundbreaking one-time hook configuration to streamline edit application, and implements a sophisticated MCP-compliant batching system for managing large codebases. These changes collectively enhance the overall workflow, making AI-driven code modifications more seamless and robust.
Highlights
- Enhanced Gemini-Claude Workflow: Critical fixes ensure Gemini accurately processes file references (e.g.,
@ts/utils/instead of hardcoded patterns) and Claude directly applies edits without redundant file reading, streamlining the 'Gemini Reads, Claude Edits' flow. - One-Time Hook Configuration: A new
/mcp__gemini-cli__configure-hooksslash command allows a permanent, one-time setup to eliminate 'File has not been read yet' errors. This enables Claude to directly implement Gemini's edits while preserving diff view and approval processes, with hooks persisting across sessions. - MCP-Compliant Batching for Large Inputs: Implemented a new, robust batching system that respects user-specified file references, handles large codebases, and includes MCP progress notifications and cursor-based continuation to efficiently manage token limits (reduced from 1M to 25k threshold with 20k batch sizes).
- Intelligent Parameter Processing & Auto-Enforcement: The system now automatically detects edit intent in prompts and large input sizes, enabling
changeModeand appropriate batching strategies. This ensures optimal interaction, prevents common errors, and includes validation for parameter combinations. - Improved Robustness and Performance: Includes a fallback mechanism for Gemini responses that are suspiciously large (likely API bugs) by retrying with a different model (
gemini-2.5-flash). Performance is also enhanced through realistic token limits and a cleaner architecture.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
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 significant feature to streamline the "Gemini Reads, Claude Edits" workflow. My feedback focuses on enhancing robustness, maintainability, and cross-platform compatibility by addressing potential issues with external dependencies in scripts and a bug in the batch continuation logic.
| } | ||
| | ||
| // Process the batch | ||
| const result = await processMCPBatch(batchToProcess, "gemini-2.5-pro", false, true); |
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.
The call to processMCPBatch inside continueMCPBatch hardcodes several key parameters ("gemini-2.5-pro", false, true). This will cause subsequent batches to ignore the original parameters if a user started the batch operation with a different model or with sandbox=true. Store the original parameters in MCPBatchState and reuse them during continuation.
| command: `#!/bin/bash | ||
| # Auto-approve edits from Gemini workflow to prevent 'read first' failures | ||
| if [ -n "\\$STDIN" ]; then | ||
| session_id=$(echo "\\$STDIN" | jq -r '.session_id // empty') | ||
| transcript_path=$(echo "\\$STDIN" | jq -r '.transcript_path // empty') | ||
| tool_name=$(echo "\\$STDIN" | jq -r '.tool_name // empty') | ||
| if [ -n "\\$transcript_path" ] && [ -f "\\$transcript_path" ]; then | ||
| # Check last 30 lines for recent Gemini MCP activity | ||
| if tail -30 "\\$transcript_path" | grep -q 'mcp__gemini-cli__ask-gemini\\|mcp__gemini-cli__sandbox-test'; then | ||
| echo '{"decision": "approve", "reason": "Auto-approved: Gemini-guided edit workflow detected - bypassing read-first requirement"}' | ||
| exit 0 | ||
| fi | ||
| fi | ||
| fi | ||
| # If no Gemini context found, allow normal permission flow | ||
| exit 0` |
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.
The embedded bash script for the configure-hooks command has a hard dependency on jq, which may not be installed on a user's system. This dependency should be documented or removed by performing the JSON parsing within this Node.js script. The script's reliance on #!/bin/bash, tail, and grep also limits its portability for Windows users.
| }, | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "rebuild": "rm -rf dist && npm run build", |
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.
| * Generate unique batch ID | ||
| */ | ||
| function generateBatchId(): string { | ||
| return Date.now().toString(36) + Math.random().toString(36).substr(2); |
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.
Description
Brief description of changes
Type of Change
Testing