Skip to content

feat: add terminal execution mode for custom commands#24

Merged
VdustR merged 3 commits intomainfrom
feature/terminal-mode-custom-commands
Mar 17, 2026
Merged

feat: add terminal execution mode for custom commands#24
VdustR merged 3 commits intomainfrom
feature/terminal-mode-custom-commands

Conversation

@VdustR
Copy link
Copy Markdown
Collaborator

@VdustR VdustR commented Mar 17, 2026

Summary

  • Add mode field to custom command config: "spawn" (default, unchanged) or "terminal" (VS Code integrated terminal)
  • Terminal mode creates an integrated terminal with the command's label as name, sends the shell-quoted command via sendText(), and keeps the terminal open for interaction
  • New runtime dependency: shell-quote for safe POSIX shell quoting (bundled by esbuild)

Changes

File Change
src/types.ts Add mode to CustomCommandConfig
src/utils/customCommandConfig.ts Validation + defaulting
src/commands/customCommand.ts terminalCommand() + mode branching
package.json JSON schema + shell-quote dep
src/utils/__tests__/customCommandConfig.test.ts Mode validation tests
src/commands/__tests__/customCommand.test.ts Terminal/spawn execution tests
docs/spec/custom-commands.md Spec update with terminal mode section
README.md Expanded custom commands docs with examples

Test plan

  • pnpm build — esbuild bundles shell-quote (30.3kb output)
  • pnpm test — 97/97 tests pass (89 baseline + 8 new)
  • pnpm lint:es — clean
  • Manual: "mode": "terminal" command opens terminal with correct name/cwd/command
  • Manual: "mode": "spawn" (or omitted) behaves unchanged
  • Manual: invalid "mode" value → entry skipped with log message

Closes #18

🤖 Generated with Claude Code

Add `mode` field to custom command config: `"spawn"` (default, unchanged)
or `"terminal"` (VS Code integrated terminal). Terminal mode uses
`shell-quote` for safe command quoting via `sendText()`.

Closes #18

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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 significantly enhances the custom commands feature by introducing a new execution mode that runs commands directly within a VS Code integrated terminal. This change provides users with greater flexibility and interactivity, enabling them to easily manage long-running processes like development servers or engage with interactive command-line tools without leaving the editor. The update includes necessary schema changes, robust validation, and comprehensive documentation to support the new functionality.

Highlights

  • New Terminal Execution Mode: Introduced a new mode field for custom commands, allowing them to be executed either as a detached background process ("spawn", the default) or within a VS Code integrated terminal ("terminal").
  • Interactive Command Execution: The "terminal" mode creates an integrated terminal named after the command's label, sends the shell-quoted command for execution, and keeps the terminal open for user interaction, making it ideal for dev servers or interactive CLI tools.
  • Safe Shell Quoting: Integrated the shell-quote library to safely quote commands for POSIX shells when using the "terminal" mode, ensuring correct execution of commands with arguments containing spaces or special characters.
  • Enhanced Documentation and Examples: Updated the README.md and docs/spec/custom-commands.md with detailed explanations of the new mode field, its behavior, and practical examples for both execution modes, including a known limitation regarding PowerShell.
  • Configuration Schema and Validation: Updated the package.json schema to include the mode field with "spawn" and "terminal" as valid options, and added validation logic in src/utils/customCommandConfig.ts to ensure correct configuration.

🧠 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/terminal-mode-custom-commands.md
    • Added a new changeset file to document the minor release for adding terminal execution mode for custom commands.
  • README.md
    • Updated the custom commands section to detail the new mode property and its "spawn" and "terminal" options.
    • Added new examples demonstrating how to run dev servers and interactive tools in terminal mode.
    • Included a new section on known limitations regarding PowerShell compatibility with shell-quote.
  • docs/spec/custom-commands.md
    • Added the mode property to the custom command entry schema.
    • Updated the execution flow to reflect the new mode options.
    • Introduced a new 'Terminal Mode' section detailing its behavior, command quoting, environment handling, and error handling.
    • Added new examples for running interactive CLI tools and starting Claude Code in terminal mode.
  • package.json
    • Added the mode property to the custom command configuration schema with "spawn" and "terminal" enum values and a default of "spawn".
    • Added @types/shell-quote as a dev dependency.
    • Added shell-quote as a runtime dependency.
  • pnpm-lock.yaml
    • Updated the lock file to include shell-quote and @types/shell-quote dependencies.
  • src/commands/tests/customCommand.test.ts
    • Added new test suite for runCustomCommand covering terminal mode execution, including terminal creation, command sending, and showing.
    • Expanded spawn mode tests to verify correct argument passing and process detachment.
    • Included tests for terminal mode error handling, ensuring logError and showErrorMessage are called.
    • Added a test to confirm default behavior is spawn when mode is omitted.
  • src/commands/customCommand.ts
    • Imported the quote function from shell-quote.
    • Implemented a new terminalCommand function to create and manage VS Code integrated terminals for command execution.
    • Modified runCustomCommand to include the mode property in the selected command object.
    • Added conditional logic in runCustomCommand to dispatch to either terminalCommand or spawnCommand based on the configured mode.
  • src/types.ts
    • Added an optional mode property to the CustomCommandConfig interface, allowing "spawn" or "terminal" values.
  • src/utils/tests/customCommandConfig.test.ts
    • Added new tests for validateCustomCommand to ensure correct validation of the mode property, including valid "spawn" and "terminal" values, omitted mode, and invalid mode values.
  • src/utils/customCommandConfig.ts
    • Added validation logic within validateCustomCommand to check for valid mode values ("spawn" or "terminal").
    • Modified getCustomCommands to assign a default "spawn" mode if the mode property is omitted in the configuration.
Activity
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.

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 new 'terminal' execution mode for custom commands, allowing them to run in an integrated VS Code terminal. The changes are well-implemented across the codebase, including updates to types, configuration validation, command execution logic, and comprehensive documentation in both the README and specification files. The addition of shell-quote for safe command argument handling is a good choice.

My review includes a couple of suggestions to enhance debuggability and test coverage. Specifically, I've recommended improving the logging for terminal commands to show the exact quoted command being executed, and strengthening the tests to cover cases with spaces in command arguments.

VdustR and others added 2 commits March 17, 2026 22:19
The previous mock joined args with spaces, which couldn't verify
that arguments with spaces are properly quoted. Updated mock to
simulate POSIX-style quoting and added a test case for it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The log message used args.join(" ") which didn't match the
shell-quoted command actually sent to the terminal, making
debug output misleading for arguments with spaces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@VdustR VdustR merged commit 8575241 into main Mar 17, 2026
1 check passed
@VdustR VdustR deleted the feature/terminal-mode-custom-commands branch March 17, 2026 14:21
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.

Support VS Code integrated terminal as custom command execution mode

1 participant