Skip to content

feat: add custom commands for tree view context menu#19

Merged
VdustR merged 4 commits intomainfrom
feature/custom-commands
Mar 17, 2026
Merged

feat: add custom commands for tree view context menu#19
VdustR merged 4 commits intomainfrom
feature/custom-commands

Conversation

@VdustR
Copy link
Copy Markdown
Collaborator

@VdustR VdustR commented Mar 17, 2026

Summary

  • Add two new settings (customCommands.directory, customCommands.workspace) for configuring external commands triggered from the tree view context menu
  • Each command supports template variables ({name}, {branch}, {ref}, {head}, {path}, {dir}, {worktree}) and optional environment variables
  • Commands shown via QuickPick, spawned as fire-and-forget child processes
  • Add {dir} template variable for workspace items (parent directory of workspace file)
  • Add spec, update README, docs, and commands spec

Test plan

  • Right-click worktree/repository → "Custom Commands..." appears in context menu
  • Right-click workspace file → "Custom Commands..." appears (with workspace commands configured)
  • QuickPick shows configured commands with rendered command preview
  • External editor (Zed) opens correctly for both directory and workspace items
  • macOS GUI terminal (Ghostty via open -a) opens at correct directory
  • Menu item hidden when no custom commands configured
  • Menu item hidden on prunable items
  • Invalid config entries skipped with log warning
  • 89 tests passing, lint clean, build clean

Closes #17
Related: #18 (VS Code integrated terminal mode — future enhancement)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

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 introduces a powerful new feature that allows users to define and execute custom external commands directly from the Git WorkGrove tree view context menu. This significantly enhances the extensibility of the extension, enabling seamless integration with other tools and workflows by providing configurable command execution with dynamic context-aware arguments and environment variables. The implementation includes new settings, robust command validation, and comprehensive documentation.

Highlights

  • Custom Commands Feature: Introduced custom commands for tree view context menus, allowing users to define and execute external commands for directory and workspace items.
  • New Settings: Added two new settings, 'git-work-grove.customCommands.directory' and 'git-work-grove.customCommands.workspace', to configure these commands.
  • Template Variable Support: Implemented support for template variables (e.g., '{name}', '{path}', '{dir}') within custom commands and their environment variables, enhancing dynamic command generation.
  • Command Execution Flow: Enabled commands to be selected via a QuickPick menu and executed as fire-and-forget child processes, ensuring non-blocking operation.
  • New '{dir}' Template Variable: Expanded template variable functionality to include '{dir}' for workspace file items, representing the parent directory of the workspace file.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .changeset/custom-commands.md
    • Added a new changeset entry for the custom commands feature.
  • .gitignore
    • Updated to ignore the '.worktrees/' directory.
  • CLAUDE.md
    • Updated the documentation index to include the new custom commands specification.
  • README.md
    • Updated to announce the new 'Custom Commands' feature.
    • Described its functionality and provided configuration examples.
  • docs/plans/2026-03-17-custom-commands-plan.md
    • Added a detailed implementation plan for the custom commands feature.
  • docs/spec/commands.md
    • Updated the commands specification to list the new 'customCommand.directory' and 'customCommand.workspace' commands and their enablement conditions.
  • docs/spec/custom-commands.md
    • Added a comprehensive specification document detailing the custom commands feature, settings, template variables, UX flow, execution, and error handling.
  • docs/templates.md
    • Updated to include the new '{dir}' template variable for workspace file items.
    • Clarified usage notes about '{worktree}' and '{dir}' availability.
  • package.json
    • Updated to declare new custom command contributions and menu entries.
    • Added new configuration properties with their schemas for custom commands.
  • src/commands/customCommand.ts
    • Added a new module to handle the execution of custom commands, including variable resolution, QuickPick display, and child process spawning.
  • src/constants.ts
    • Added new constants for custom command IDs, context keys, and configuration keys.
  • src/extension.ts
    • Updated to register the new custom command handlers.
    • Modified to manage context keys for custom command visibility.
    • Configured to refresh the tree view upon configuration changes related to custom commands.
  • src/types.ts
    • Added the 'CustomCommandConfig' interface to define the structure of custom command settings.
  • src/utils/tests/customCommandConfig.test.ts
    • Added new unit tests for validating custom command configurations.
  • src/utils/tests/template.test.ts
    • Updated unit tests to cover the new '{dir}' template variable for workspace files.
  • src/utils/customCommandConfig.ts
    • Added a new utility module for validating and retrieving custom command configurations from VS Code settings.
  • src/utils/template.ts
    • Updated the 'workspaceFileVars' function to include the 'dir' variable, providing the parent directory path for workspace files.
Activity
  • The author outlined a detailed implementation plan, breaking down the feature into nine distinct tasks.
  • Unit tests were written for template variable resolution and custom command configuration validation, ensuring correctness.
  • The extension's 'package.json' was updated to register new commands, menu items, and configuration settings.
  • Comprehensive documentation, including a new specification and updates to the README, was provided.
  • Manual testing was performed across various scenarios, including right-clicking worktrees and workspace files, verifying QuickPick behavior, and external application launches.
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.

Allow users to configure external commands (e.g., open in Ghostty, Zed,
Terminal.app) triggered from the tree view context menu via two new settings:
- customCommands.directory: for worktree/repository items
- customCommands.workspace: for workspace file items

Each command supports template variables ({name}, {branch}, {ref}, {head},
{path}, {dir}, {worktree}) and optional environment variables. Commands are
shown in a QuickPick and spawned as fire-and-forget child processes.

Also adds {dir} template variable for workspace items (parent directory).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@VdustR VdustR force-pushed the feature/custom-commands branch from f3fe3c2 to 775868c Compare March 17, 2026 08:47
Copy link
Copy Markdown

@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 a powerful new feature for defining custom commands in the tree view context menu. The implementation is comprehensive, covering configuration, command execution, and documentation updates. My review focuses on a critical security vulnerability, a bug in configuration validation, and a few opportunities to improve code maintainability and consistency. Addressing the security issue is paramount before merging.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3fe3c2064

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

VdustR and others added 2 commits March 17, 2026 17:00
Template variables like {path} can contain shell metacharacters. Using
shell: true on POSIX would allow injection via crafted directory names.
POSIX spawn resolves PATH without a shell, so shell: true is only needed
on Windows for .cmd/.bat support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reject entries with non-string env values (e.g., { FOO: 123 }) during
validation instead of letting them crash renderTemplate at runtime.
Simplify getCustomCommands since env is now guaranteed valid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@VdustR VdustR merged commit a6f7f9a into main Mar 17, 2026
1 check passed
@VdustR VdustR deleted the feature/custom-commands branch March 17, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant