feat(core): implement lsp_query tool for semantic code analysis#22580
feat(core): implement lsp_query tool for semantic code analysis#22580GitmanIII wants to merge 3 commits intogoogle-gemini:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
fe7d6f3 to
3012f3e
Compare
06c3710 to
a856f8e
Compare
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 significantly enhances the Gemini CLI's code understanding capabilities by integrating a new Language Server Protocol (LSP) query tool. This allows the agent to move beyond basic text searches and perform deep semantic analysis, such as finding definitions or references, which is crucial for complex software engineering tasks like bug fixing, feature development, and refactoring. The change provides a robust framework for managing language servers and ensures the agent can intelligently interact with various programming languages. Highlights
Changelog
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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable feature: the lsp_query tool for semantic code analysis. The implementation is well-structured, separating the low-level LSP client, the server manager, and the tool logic into distinct, well-defined modules. The addition of documentation and comprehensive tests is commendable. My review includes one high-severity comment regarding error handling in the LspServerManager to improve robustness and provide clearer feedback to the user in case of environment configuration issues. This comment aligns with general good practices and does not contradict any established rules. Overall, this is a solid contribution that greatly enhances the agent's code understanding capabilities.
Note: Security Review did not run due to the size of the PR.
| if (checkResult.status !== 0) { | ||
| throw new Error(`[LSP Configuration Error]: ${config.installHint}`); | ||
| } |
There was a problem hiding this comment.
The current check for the language server binary is not fully robust. If spawnSync fails to execute checkCmd (e.g., which is not in the user's PATH), checkResult.error will be set and checkResult.status will be null. While null !== 0 is true, the error thrown gives the user a misleading hint. It suggests installing the language server, when the actual problem is that the verification command (which or where) is missing.
A more robust check would differentiate between these two failure modes to provide a more accurate error message to the user.
if (checkResult.error || checkResult.status !== 0) {
const errorMessage = checkResult.error
? `Failed to check for language server binary. Please ensure '${checkCmd}' is in your system's PATH.`
: `[LSP Configuration Error]: ${config.installHint}`;
throw new Error(errorMessage);
}f1e67a8 to
e7c63b2
Compare
Address PR feedback from Gemini-code-assist by differentiating between a missing language server and a missing check command (which/where). Added a unit test to verify this failure mode.
…ess cleanup This update addresses several production-critical issues: 1. Implements RFC-compliant file URIs using pathToFileURL for Windows compatibility. 2. Adds a mapping from file extensions to standard LSP language identifiers. 3. Exports and integrates shutdownLspServers() into the Config disposal sequence to prevent zombie processes. 4. Enhances unit tests to verify the cleanup logic.
e7c63b2 to
d17f90d
Compare
Summary
Implement the
lsp_querytool, enabling semantic code analysis (definitions, references, hover, symbols) via the Language Server Protocol (LSP).Details
Note: This feature was originally developed using
gemini-cli-0.34.0-nightly.20260304.28af4e127as a baseline and has since been rebased and updated to integrate cleanly into the currentmainbranch.This PR introduces the
lsp_querytool to the Gemini CLI, allowing the agent to perform deep semantic analysis of codebases.LspTooltopackages/core.LspServerManagerandLspClientfor managing lifecycle and communication with local language servers.LspToolwhere parameter schemas were incorrectly initialized, preventing the model from providing required arguments.lsp_queryfor precise navigation tasks.LspToolandLspServerManager.Related Issues
Fixes the issue where semantic navigation was limited to text-based search.
How to Validate
npm run buildtypescript-language-serverfor TS).Pre-Merge Checklist