refactor(core): Extract tool parameter names as constants#20460
refactor(core): Extract tool parameter names as constants#20460SandyTao520 wants to merge 1 commit intomainfrom
Conversation
|
Hi @SandyTao520, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
Summary of ChangesHello @SandyTao520, 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 improves code maintainability and reduces the risk of typos by centralizing tool parameter names into constants. This refactoring ensures that parameter names are consistently defined and referenced throughout the codebase, making future updates and debugging more efficient. 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 is a good step towards improving maintainability by refactoring hardcoded tool parameter names into centralized constants. The changes in the tool definition files and prompt snippets are well-executed. However, the refactoring is critically incomplete as the new constants are not used within the tool implementation files themselves (e.g., grep.ts, shell.ts), where parameters are still accessed via hardcoded strings. This leaves the codebase in an inconsistent state and undermines the primary goal of the PR. I've added a comment with details on how to complete the refactoring.
|
|
||
| // ============================================================================ | ||
| // TOOL NAMES | ||
| // SHARED PARAMETER NAMES (used by multiple tools) |
There was a problem hiding this comment.
This is a great refactoring to centralize tool parameter names. However, the refactoring appears to be incomplete. The newly introduced constants are not used in the tool implementation files, where parameter values are still accessed using hardcoded strings. This undermines the goal of improving maintainability and reducing typos, leaving the codebase in an inconsistent state.
To complete this refactoring, the constants should also be used when accessing parameters in the tool implementation files, such as:
packages/core/src/tools/edit.tspackages/core/src/tools/grep.tspackages/core/src/tools/memoryTool.tspackages/core/src/tools/read-file.tspackages/core/src/tools/shell.tspackages/core/src/tools/write-file.ts
For example, in packages/core/src/tools/shell.ts, this.params.command should be changed to this.params[SHELL_PARAM_COMMAND].
|
Size Change: +7.02 kB (+0.03%) Total Size: 25.7 MB
ℹ️ View Unchanged
|
Summary
This PR refactors hardcoded tool parameter names into centralized constants to improve maintainability and reduce the risk of typos across the codebase.
Details
file_path,dir_path,pattern,command, and others are now defined as exported constants inpackages/core/src/tools/definitions/base-declarations.ts.packages/core/src/prompts/snippets.tsto use these constants within prompt examples and guidelines.gemini-3.ts,default-legacy.ts) and dynamic declaration helpers (dynamic-declaration-helpers.ts) to use computed property names for parameters.packages/core/src/tools/tool-names.tsandpackages/core/src/tools/definitions/coreTools.tsto export these new constants for wider use.Related Issues
Related to #18007
How to Validate
npm run buildto ensure the project compiles correctly.file_pathis stillfile_pathin the JSON schema).Pre-Merge Checklist