Skip to content

feat: Implement slash command handling in ACP for /memory,/init,/extensions and /restore#20528

Merged
skeshive merged 3 commits intomainfrom
sripas_1331
Mar 3, 2026
Merged

feat: Implement slash command handling in ACP for /memory,/init,/extensions and /restore#20528
skeshive merged 3 commits intomainfrom
sripas_1331

Conversation

@sripasg
Copy link
Contributor

@sripasg sripasg commented Feb 27, 2026

Summary

  • Integrate four of the core Gemini CLI slash commands (/memory, /extensions, /restore, and /init) into the ACP support. These are initially being made available. They are currently available via A2A.
  • Introduce a command pipeline to be extensible w.r.t new commands and explicitly broadcast their availability to the client so they appear in autocomplete suggestions in the relevant editors (JB, Zed)

Details

The implementation achieves this through three main additions in packages/cli/src/zed-integration/zedIntegration.ts:

1. Decoupling Execution from Presentation

  • All core business logic remains in @google/gemini-cli-core.
  • The terminal CLI has wrapper classes that render the output beautifully using (packages/cli/src/ui/commands).
  • The Zed integration now has its own set of thin, headless wrapper classes (packages/cli/src/zed-integration/commands) that take the raw data and format it cleanly for the editor.

2. A Structured Command Pipeline

We introduced a structured pipeline:

  • Command interface: Enforces standard contracts for execution, arguments, and aliases.
  • CommandHandler: A dedicated class responsible for extracting command tokens (e.g., /memory reload), matching them against a registry of supported commands, and handling aliases.
  • Direct Updates: The commands return structured text or data, which is then sent directly back to the editor over the Agent Client Protocol (ACP) using standard update events.

Related Issues

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

How to Validate

  • Set up the local gemini connection with ACP based editor like JB or Zed and ensure that these four slash commands can be run from the editor as expected.

Pre-Merge Checklist

  • [NA] Updated relevant documentation and README (if needed)
  • [✅] Added/updated tests (if needed)
  • [NA] Noted breaking changes (if any)
  • [✅] Validated on required platforms/methods:
    • [✅] MacOS
      • [✅] npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@sripasg sripasg requested a review from a team as a code owner February 27, 2026 03:11
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 27, 2026

Hi @sripasg, 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
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 significantly enhances the Agent Client Protocol (ACP) integration by enabling the direct handling of several core Gemini CLI slash commands within supported editors. It establishes a robust mechanism to inform clients about available commands, intercepts user input to identify and execute these commands, and provides a mocked environment for command execution, ensuring a seamless and interactive experience for users without involving the LLM for command processing.

Highlights

  • Slash Command Integration: Integrated four core Gemini CLI slash commands (/memory, /extensions, /restore, and /init) directly into the Agent Client Protocol (ACP) support.
  • Command Availability Broadcasting: Implemented a mechanism to broadcast available commands to the client, enabling editors like JB and Zed to provide autocomplete suggestions for these commands.
  • Prompt Interception and Execution: Introduced logic to intercept slash commands from user prompts, execute them using a mock UI context, and prevent them from being passed to the LLM.
  • Mock UI Context for Command Output: Developed a mocked CommandContext that routes command output directly to the ACP client by firing agent_message_chunk session notifications, displaying command results as chat dialogue.
Changelog
  • packages/cli/src/zed-integration/zedIntegration.test.ts
    • Added mocks for memoryCommand, extensionsCommand, restoreCommand, and initCommand modules.
    • Updated newSession test to utilize fake timers and verify the sendAvailableCommands call.
    • Included new tests to confirm the functionality of sendAvailableCommands.
    • Added dedicated tests to verify the correct handling and execution of /memory, /extensions, /restore, and /init commands.
    • Implemented a test case for handling unquoted commands originating from autocomplete suggestions.
  • packages/cli/src/zed-integration/zedIntegration.ts
    • Imported necessary command modules (memoryCommand, extensionsCommand, restoreCommand, initCommand) and command-related types.
    • Modified GeminiAgent's newSession and loadSession methods to pass settings to the Session constructor and to asynchronously call session.sendAvailableCommands().
    • Updated the Session constructor to accept settings as a new parameter.
    • Added a sendAvailableCommands method to the Session class to broadcast command details and descriptions to the ACP client.
    • Implemented command interception logic within the Session.prompt method to detect and handle slash commands based on user input.
    • Added handleCommand and runCommand private methods to the Session class for dispatching and executing commands using a mocked CommandContext, routing output via agent_message_chunk updates.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@sripasg sripasg requested a review from skeshive February 27, 2026 03:12
@sripasg sripasg assigned sripasg and unassigned skeshive Feb 27, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 slash command handling for /memory, /init, /extensions, and /restore within the ACP integration. My review focuses on improving maintainability by addressing hardcoded values for command descriptions and enhancing robustness by completing the mockUi object to prevent runtime errors from unimplemented UI methods. Both comments align with general best practices and do not contradict any specific rules.

@github-actions
Copy link

github-actions bot commented Feb 27, 2026

Size Change: +9.82 kB (+0.04%)

Total Size: 25.8 MB

Filename Size Change
./bundle/gemini.js 25.3 MB +9.82 kB (+0.04%)
ℹ️ View Unchanged
Filename Size
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B
./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-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 27, 2026
…sions` and `/restore`,and also send available commands to the client.
@sripasg sripasg added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 3, 2026
@skeshive skeshive added this pull request to the merge queue Mar 3, 2026
@skeshive skeshive removed this pull request from the merge queue due to a manual request Mar 3, 2026
@skeshive skeshive added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@skeshive skeshive added this pull request to the merge queue Mar 3, 2026
Merged via the queue into main with commit 27d7aeb Mar 3, 2026
27 checks passed
@skeshive skeshive deleted the sripas_1331 branch March 3, 2026 21:44
jwhelangoog pushed a commit that referenced this pull request Mar 3, 2026
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
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.

2 participants