feat(cli): add inline natural-language shell expansion#22866
feat(cli): add inline natural-language shell expansion#22866migarci2 wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
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 introduces a significant enhancement to the CLI's shell mode by integrating inline natural-language shell command expansion. This feature allows users to quickly translate natural language requests into executable shell commands without leaving the shell context, bridging the gap between direct command input and full agent conversations. It aims to streamline the workflow for users who know what they want to achieve but might not recall the exact command syntax, providing an editable command for safety and flexibility. Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces an excellent new feature for shell mode: inline natural-language command expansion. When a user prefixes their input with ?, the CLI now uses Gemini to generate a corresponding shell command and inserts it into the prompt for editing and execution. The implementation is robust, leveraging a new React hook useShellCommandExpansion that correctly handles asynchronous operations and cancellations. The feature is well-integrated into the existing InputPrompt component, and the changes include thorough tests and documentation updates. The code quality is high, and I found no critical or high-severity issues.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
Title
feat(cli): add inline natural-language shell expansion in shell mode
Body
Summary
Adds inline natural-language command expansion to shell mode.
When shell mode is active, input that starts with
?is treated as a request togenerate a single editable shell command instead of being executed directly.
This covers the gap between “I know the exact shell command” and “I need a full
agent conversation,” while keeping the shell workflow fast and explicit.
Details
This PR adds a shell-mode-only expansion flow rather than introducing a new
agent mode.
Behavior:
?is intercepted before normal shellexecution.
?is sent to Gemini with a constrainedprompt that asks for a single shell command only.
?, and a transient“Generating shell command...” message is shown while expansion is in flight.
Implementation notes:
cleanup.
InputPromptto route?-prefixed shell input through inlineexpansion.
inserted.
?shortcuts help behavior unchanged outside shell mode.This issue is currently labeled
priority/p2.Related Issues
Closes #21798
Related to #21192
How to Validate
Build and run from the repo root:
If Gemini auth is not already configured, set an API key first:
export GEMINI_API_KEY=YOUR_API_KEY npm run generate npm run build npm run startManual validation:
!.? find all .log files older than 7 days.Enterwill generate an editableshell command.
Enter.Enteragain to execute it.Additional prompts to try:
? find all .log files? show processes using port 3000? show commits from the last 3 daysEdge cases:
?and pressEnter.Expected: a short error/hint is shown and nothing executes.
?on an empty prompt.Expected: the existing shortcuts help behavior still works.
? ..., generate a command, then edit it manually.Expected: normal shell editing behavior is preserved.
Automated checks run:
npm run generate npm run build --workspace @google/gemini-cli-core cd packages/cli npx vitest run src/ui/components/InputPrompt.test.tsx src/ui/hooks/useShellCommandExpansion.test.ts npx eslint src/ui/components/InputPrompt.tsx src/ui/components/InputPrompt.test.tsx src/ui/hooks/useShellCommandExpansion.ts src/ui/hooks/useShellCommandExpansion.test.tsPre-Merge Checklist