Skip to content

feat(cli): add support for the ${extensionPath} variable in extension TOML commands#22681

Merged
jerop merged 4 commits intogoogle-gemini:feat/builtin-conductorfrom
moisgobg:feat/extension-path-injection
Mar 17, 2026
Merged

feat(cli): add support for the ${extensionPath} variable in extension TOML commands#22681
jerop merged 4 commits intogoogle-gemini:feat/builtin-conductorfrom
moisgobg:feat/extension-path-injection

Conversation

@moisgobg
Copy link
Copy Markdown

@moisgobg moisgobg commented Mar 16, 2026

Summary

This PR enables portability for custom commands defined within extensions by introducing a new ${extensionPath} variable, and immediately applies this feature to fix a critical path resolution bug in the built-in Conductor extension.

Previously, extension commands had no reliable way to reference files or assets bundled within their own directory (e.g., the templates folder in Conductor) without hardcoding absolute paths or relying on fragile assumptions about where the extension was installed.

By injecting the absolute extension path dynamically at load time, extensions can now reliably bundle and access their own resources regardless of whether they are user-installed or built-in to the CLI bundle.

Details

Commit 1: Core Framework Support

  • Updates FileCommandLoader.ts to automatically detect and replace ${extensionPath} instances in parsed TOML prompt strings.
  • The substitution is only applied if the command belongs to an active extension (protecting standard User and Workspace commands from unexpected behavior).
  • Includes unit tests to verify the substitution logic.

Commit 2: Conductor Fix

  • Migrates the built-in Conductor setup.toml command away from hardcoded paths by replacing them with ${extensionPath}/templates/... to copy code style guides and the workflow template.
  • This directly unblocks the integration of Conductor as a built-in extension, as the bundled extension lives in a different installation directory, causing the previous hardcoded paths to fail.

How to Validate

1. Validate the Core Feature (Unit Tests)

Run the updated unit tests for the FileCommandLoader to ensure the injection logic is sound:

npm run test --workspace @google/gemini-cli -- src/services/FileCommandLoader.test.ts

2. Validate the Conductor Fix (Manual)

  1. Ensure you have the feat/extension-path-injection branch checked out.
  2. Run the CLI in a completely empty, temporary directory:
mkdir -p /tmp/conductor-test && cd /tmp/conductor-test
gemini
  1. Run /conductor:setup.
  2. Complete the interactive prompts. When you get to the code style guides step, you can either pick the recommended ones or choose specific guides.
  3. The CLI will present a shell confirmation prompt (Allow execution of: cp ...).
  4. Verify: Look closely at the cp command in the confirmation dialog. The source path should now correctly point to the absolute path of your current extension build directory rather than the hardcoded ~/.gemini/extensions/conductor/... path.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • 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

Fixes #22722

This allows extension commands to dynamically reference and read resources or templates bundled within their specific extension folder, avoiding the need to hardcode absolute paths.
…command

Replaces legacy ~/.gemini/extensions/conductor paths with the dynamic ${extensionPath} variable to ensure built-in and user-installed versions can resolve their internal templates correctly.
@moisgobg moisgobg marked this pull request as ready for review March 16, 2026 19:12
@moisgobg moisgobg requested a review from a team as a code owner March 16, 2026 19:12
@gemini-code-assist
Copy link
Copy Markdown
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 CLI's extension system by enabling extensions to reliably reference their internal resources, regardless of their installation location. It introduces a new ${extensionPath} variable that dynamically resolves to an extension's root directory, ensuring that custom commands can access bundled files without fragile, hardcoded paths. This change directly addresses and fixes a critical path resolution issue within the Conductor extension, making it fully portable when integrated as a built-in component.

Highlights

  • Extension Path Variable Support: Introduced the ${extensionPath} variable, allowing extension TOML commands to dynamically reference their own installation directory for improved portability.
  • Core Framework Implementation: Implemented logic within FileCommandLoader.ts to detect and replace ${extensionPath} instances in prompt strings, ensuring this functionality is applied only to active extension commands.
  • Conductor Extension Fix: Resolved a critical path resolution bug in the built-in Conductor extension by updating its setup.toml command to utilize the new ${extensionPath} variable, replacing previously hardcoded paths.
Changelog
  • packages/cli/src/services/FileCommandLoader.test.ts
    • Added a new unit test to verify the correct injection of the ${extensionPath} variable into extension command prompts.
  • packages/cli/src/services/FileCommandLoader.ts
    • Extended the CommandDirectory interface to include an optional extensionPath property.
    • Modified the loadCommands method to pass the extensionPath when processing extension command directories.
    • Implemented a string replacement mechanism within loadCommandFile to substitute ${extensionPath} placeholders in command prompt strings with the actual extension path for extension-specific commands.
  • packages/core/src/extensions/builtin/conductor/commands/conductor/setup.toml
    • Updated the setup.toml command to replace hardcoded paths (e.g., ~/.gemini/extensions/conductor/templates/) with the new ${extensionPath}/templates/ variable for listing and copying code style guides and workflow templates.
Activity
  • The pull request was created by moisgobg.
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
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 a valuable ${extensionPath} variable for extension commands, which significantly improves their portability. The overall implementation is solid, and the updates to the Conductor extension and the new unit tests are great additions. However, I've identified one high-severity security issue in the string replacement logic. The current approach can misinterpret special characters (like $) in file paths, potentially leading to incorrect command generation and security risks. I've provided a code suggestion to resolve this by ensuring the path is treated as a literal string during substitution, aligning with best practices for path sanitization.

@moisgobg moisgobg requested a review from a team as a code owner March 16, 2026 19:18
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Mar 16, 2026
@jerop jerop merged commit 59c9089 into google-gemini:feat/builtin-conductor Mar 17, 2026
1 check passed
jerop pushed a commit that referenced this pull request Mar 17, 2026
@moisgobg moisgobg self-assigned this Mar 17, 2026
jerop pushed a commit that referenced this pull request Mar 17, 2026
jerop pushed a commit that referenced this pull request Mar 17, 2026
@moisgobg moisgobg added area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/documentation Gemini CLI documentation tasks and issues 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. and removed status/need-issue Pull requests that need to have an associated issue. labels Mar 17, 2026
jerop pushed a commit that referenced this pull request Mar 20, 2026
jerop pushed a commit that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/documentation Gemini CLI documentation tasks and issues 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants