-
Notifications
You must be signed in to change notification settings - Fork 9.7k
feat: Multi-Directory Workspace Support (part2: add "directory" command) #5241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Multi-Directory Workspace Support (part2: add "directory" command) #5241
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @y-okt, 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 multi-directory workspace support in the Gemini CLI by introducing an interactive in-session command. It allows users to dynamically manage their workspace directories, ensuring the AI model's context remains up-to-date with their project structure without needing to restart the application. This improves flexibility and user experience for multi-project workflows.
Highlights
- New CLI Command: I've introduced a new
/directoryslash command (with/diras an alias) to manage workspace directories directly within the Gemini CLI, building upon the existing--include-directoriesstartup option. - Directory Management Subcommands: The
/directorycommand includes two subcommands:addto dynamically add new directories to the workspace, andshowto list all currently included directories. - Dynamic Environment Refresh: After successfully adding new directories via the
/directory addcommand, the CLI now triggers an environment refresh. This ensures the Gemini model's context is immediately updated with the newly included paths, providing more relevant responses. - Sandbox Compatibility: The
/directory addsubcommand is explicitly disabled when the CLI is running in a restrictive sandbox profile. In such cases, users are guided to use the--include-directoriesoption at startup instead, maintaining security while providing clear guidance.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
|
@jacob314 @allenhutchison Hi, could you please review this PR as well? This is a follow-up for #4605 , and I added "/directory" command to add context directories from the CLI as well. After this merge, I'll work on the settings.json configuration supports. Thanks! |
There was a problem hiding this 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 a valuable feature for multi-directory workspace support by adding the /directory command. The implementation is well-structured, including documentation, tests, and the core command logic. The addition of refreshEnvironment to update the chat context dynamically is a key part of this functionality.
My review identified one critical issue regarding an un-awaited asynchronous call, which could lead to race conditions. I've provided a detailed comment and a code suggestion to address this. The other changes appear to be correct and well-implemented.
83404e4 to
ff9a49a
Compare
|
Thank you for this contribution! The My review found one issue that need to be addressed before this can be merged:
Suggested change for the help text in export const directoryCommand: SlashCommand = {
name: 'directory',
altNames: ['dir'],
description: 'Manage workspace directories',
kind: CommandKind.BUILT_IN,
subCommands: [
{
name: 'add',
description: 'Add a directory to the workspace',
},
{
name: 'show',
description: 'Show all directories in the workspace',
},
],
action: async (context: CommandContext, args: string) => {
// ...
},
};Additionally, Memory Refresh Ignores New Directories: The |
6b01b43 to
3c34ba9
Compare
|
Hi @allenhutchison , thank you for reviewing! I appreciate your reviews and suggestions! I added it to my PR. Could you please review again? |
allenhutchison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this PR. This will be a valuable addition.
…t2: add "directory" command) (google-gemini#5241)
TLDR
I implemented in #4605 the Multi-Directory Workspace Support by adding
--include-directoriesoption in command line. To follow up on that, this ticket is to add/directorycommand in CLI, so that even after starting up gemini-cli, we can add directories.This feature is already discussed in #1118. Also, in the discussion with @jacob314 and @allenhutchison , we agreed to separate PRs for the sake of simplicity.
In another PR, I'm planning to work on configuration supports, suggested by this comment.
Dive Deeper
The same as TLDR.
Reviewer Test Plan
npm run start -- --include-direcotires ../testTesting Matrix
Linked issues / bugs
Partially Resolves #1118