Skip to content

refactor(core): complete centralization of core tool definitions#18991

Merged
aishaneeshah merged 6 commits into
mainfrom
refactor-remaining-tools
Feb 14, 2026
Merged

refactor(core): complete centralization of core tool definitions#18991
aishaneeshah merged 6 commits into
mainfrom
refactor-remaining-tools

Conversation

@aishaneeshah

@aishaneeshah aishaneeshah commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Complete refactor of remaining core tools to use centralized definitions in coreTools.ts.

Details

  • Refactored activate-skill.ts, ask-user.ts, enter-plan-mode.ts, exit-plan-mode.ts, get-internal-docs.ts, memoryTool.ts, read-many-files.ts, web-fetch.ts, and write-todos.ts to implement getSchema and use centralized definitions.
  • Updated coreToolsModelSnapshots.test.ts to include coverage for all core tools.

Related Issues

Related to #18944
Fixes #17958

How to Validate

Run snapshot tests:
npm test -w @google/gemini-cli-core -- src/tools/definitions/coreToolsModelSnapshots.test.ts

Run CLI tool tests:
npm test -w @google/gemini-cli -- src/ui/components/messages/ShellToolMessage.test.tsx

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • Linux
      • npm run

@aishaneeshah aishaneeshah requested a review from a team as a code owner February 13, 2026 15:11
@gemini-cli

gemini-cli Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Hi @aishaneeshah, 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!

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @aishaneeshah, 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 refactors the core tool definitions by centralizing them into a single file. This change improves maintainability, reduces redundancy, and ensures consistency across various tools by providing a single source of truth for their schemas and descriptions. The refactoring also addresses potential circular dependency issues and enhances test coverage for tool definitions.

Highlights

  • Centralization of Core Tool Definitions: Refactored nine core tools (activate-skill, ask-user, enter-plan-mode, exit-plan-mode, get-internal-docs, memoryTool, read-many-files, web-fetch, write-todos) to utilize centralized definitions stored in coreTools.ts.
  • Tool Name Management: Moved tool name constants to coreTools.ts and updated tool-names.ts to re-export these constants, effectively preventing circular dependencies and consolidating definitions.
  • Schema Implementation and Updates: Re-implemented the activate_skill schema using zod and updated coreToolsModelSnapshots.test.ts to include comprehensive coverage for all core tools, ensuring schema consistency and validation.
Changelog
  • packages/core/src/tools/activate-skill.ts
    • Removed direct zod and zodToJsonSchema imports.
    • Imported getActivateSkillDefinition and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized skill definition's description and parameter schema.
    • Added an override getSchema method to dynamically resolve the tool declaration.
  • packages/core/src/tools/ask-user.ts
    • Imported ASK_USER_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/definitions/snapshots/coreToolsModelSnapshots.test.ts.snap
    • Added new snapshot entries for activate_skill (with various skill counts), ask_user, enter_plan_mode, exit_plan_mode, get_internal_docs, read_many_files, save_memory, web_fetch, and write_todos tools for the gemini-2.5-pro and gemini-3-pro-preview models.
  • packages/core/src/tools/definitions/coreTools.ts
    • Added zod and zodToJsonSchema imports.
    • Moved and defined tool name constants for WRITE_TODOS, WEB_FETCH, READ_MANY_FILES, MEMORY, GET_INTERNAL_DOCS, ACTIVATE_SKILL, ASK_USER, EXIT_PLAN_MODE, and ENTER_PLAN_MODE.
    • Added complete ToolDefinition objects for WEB_FETCH, READ_MANY_FILES, MEMORY, WRITE_TODOS, GET_INTERNAL_DOCS, ASK_USER, and ENTER_PLAN_MODE.
    • Implemented factory functions getExitPlanModeDefinition and getActivateSkillDefinition to generate dynamic tool definitions.
  • packages/core/src/tools/definitions/coreToolsModelSnapshots.test.ts
    • Imported new tool definitions and their respective factory functions.
    • Extended the toolsToTest array to include all newly centralized tool definitions for snapshot testing.
  • packages/core/src/tools/enter-plan-mode.ts
    • Imported ENTER_PLAN_MODE_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/exit-plan-mode.ts
    • Imported getExitPlanModeDefinition and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema, dynamically generated based on plansDir.
    • Added an override getSchema method to dynamically resolve the tool declaration.
  • packages/core/src/tools/get-internal-docs.ts
    • Imported GET_INTERNAL_DOCS_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/memoryTool.ts
    • Removed the memoryToolDescription constant.
    • Imported MEMORY_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/read-many-files.ts
    • Removed the inline parameterSchema definition.
    • Imported READ_MANY_FILES_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/tool-names.ts
    • Modified imports to retrieve all core tool name constants from coreTools.js.
    • Updated exports to re-export these constants, removing their direct definition in this file.
    • Removed redundant constant definitions for WRITE_TODOS_TOOL_NAME, WEB_FETCH_TOOL_NAME, READ_MANY_FILES_TOOL_NAME, MEMORY_TOOL_NAME, GET_INTERNAL_DOCS_TOOL_NAME, ACTIVATE_SKILL_TOOL_NAME, ASK_USER_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, and ENTER_PLAN_MODE_TOOL_NAME.
  • packages/core/src/tools/web-fetch.ts
    • Removed the inline parameter schema definition.
    • Imported WEB_FETCH_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Added an override getSchema method to resolve the tool declaration.
  • packages/core/src/tools/write-todos.ts
    • Removed the WRITE_TODOS_DESCRIPTION constant and inline parameter schema definition.
    • Imported WRITE_TODOS_DEFINITION and resolveToolDeclaration from centralized definitions.
    • Updated the super constructor call to use the centralized definition's description and parameter schema.
    • Removed the schema getter and added an override getSchema method to resolve the tool declaration.
  • preflight.log
    • Added a new log file, likely generated during pre-merge checks.
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.

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

  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.

@github-actions

github-actions Bot commented Feb 13, 2026

Copy link
Copy Markdown

Size Change: +2.69 kB (+0.01%)

Total Size: 24.4 MB

Filename Size Change
./bundle/gemini.js 24.4 MB +2.69 kB (+0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB

compressed-size-action

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 is a well-executed refactoring that successfully centralizes the core tool definitions into coreTools.ts. This change significantly improves code organization and maintainability by removing duplicated schema definitions from individual tool files. The updates are consistently applied across all affected tools, and the snapshot tests have been updated accordingly, which is great to see. The approach to move tool name constants to prevent circular dependencies is also a solid improvement. Overall, this is a high-quality refactoring with no issues found.

@gemini-cli gemini-cli Bot added area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 13, 2026
Comment thread preflight.log Outdated

> gemini-cli-vscode-ide-companion@0.30.0-nightly.20260210.a2174751d check-types
> tsc --noEmit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was unintentionally committed. Can we delete it?

import { zodToJsonSchema } from 'zod-to-json-schema';

// ============================================================================
// TOOL NAMES

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should name this file to set the versioning strategy since we may have to do this again with future model generations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also worth a comment about the 2.5 - 3.0 split?

GetInternalDocsTool.Name,
'GetInternalDocs',
'Returns the content of Gemini CLI internal documentation files. If no path is provided, returns a list of all available documentation paths.',
GET_INTERNAL_DOCS_DEFINITION.base.description!,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place it'd be great to avoid the null suppression.

@gundermanc gundermanc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM though I think preflight.log should be deleted.

aishaneeshah and others added 5 commits February 14, 2026 03:44
Add comment in coreTools.ts
- Add 'type' to required parameters for 'ask_user' questions.
- Include missing plan mode and documentation tools in ALL_BUILTIN_TOOL_NAMES.
- Remove extra examples from 'save_memory' description to match main.
- Update snapshots for model definitions.
@aishaneeshah aishaneeshah force-pushed the refactor-remaining-tools branch from ed54396 to b12696d Compare February 14, 2026 04:23
@aishaneeshah aishaneeshah added this pull request to the merge queue Feb 14, 2026
Merged via the queue into main with commit 5559d40 Feb 14, 2026
27 checks passed
@aishaneeshah aishaneeshah deleted the refactor-remaining-tools branch February 14, 2026 05:04
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
@sripasg sripasg added the size/xl An extra large PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. size/xl An extra large PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool Improvements: Ensure Tool changes are avaialble per model

3 participants