Skip to content

feat(core): implement JIT plan directory provisioning with path safety#25384

Closed
mahimashanware wants to merge 6 commits intofeature/plan-mode-custom-dirs-phase-2from
feature/plan-mode-custom-dirs-phase-3
Closed

feat(core): implement JIT plan directory provisioning with path safety#25384
mahimashanware wants to merge 6 commits intofeature/plan-mode-custom-dirs-phase-2from
feature/plan-mode-custom-dirs-phase-3

Conversation

@mahimashanware
Copy link
Copy Markdown
Contributor

Summary

Phase 3 of the dynamic extension plan directory resolution implementation. This PR implements the logic for dynamically resolving and provisioning plan directories on-demand.

Details

  • Dynamic Resolution: Updates getPlansDir in packages/core/src/config/storage.ts to resolve paths based on the activeExtensionName and the plan.directory setting.
  • JIT Provisioning: Modifies EnterPlanModeTool in packages/core/src/tools/enter-plan-mode.ts to synchronously verify and create the target plan directory if it doesn't exist. This prevents ENOENT errors when sub-agents attempt to initialize in a new custom sandbox.
  • Path Safety Enforcement: Leverages the previously added resolveWorkspaceRelativePath to ensure that all extension-provided paths are jailed within the current workspace, preventing any accidental or malicious escapes.

Related Issues

Depends on Phase 2 (PR #25383).

How to Validate

Run unit tests for plan mode entry and storage:

npm test -w @google/gemini-cli-core -- src/tools/enter-plan-mode.test.ts src/config/storage.test.ts

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:
    • Linux
      • npm run

@mahimashanware mahimashanware requested a review from a team as a code owner April 14, 2026 14:23
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Apr 14, 2026

Hi @mahimashanware, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@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 introduces the third phase of dynamic extension plan directory resolution. It enhances the system's ability to handle custom plan storage locations by dynamically provisioning these directories on-demand while enforcing strict path safety to prevent unauthorized file system access.

Highlights

  • Dynamic Plan Directory Resolution: Updated the storage configuration to support resolving plan directories based on active extensions and custom settings.
  • JIT Provisioning: Implemented synchronous creation of required plan directories during the transition to plan mode to prevent runtime file system errors.
  • Path Safety: Integrated validation logic to ensure that custom extension-provided paths remain within the designated workspace boundaries.
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.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

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 enhances the EnterPlanModeTool to automatically provision plan directories for active extensions, ensuring they exist before the agent attempts to write to them. This is particularly important for sandboxed environments where host directories must be pre-created. The implementation now iterates through active extensions and creates any configured custom plan directories alongside the default one. Feedback indicates that the logic should also consider the default directory specified in an extension's manifest if no user-specific setting is found.

Comment thread packages/core/src/tools/enter-plan-mode.ts Outdated
@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-2 branch 2 times, most recently from c64d139 to 627d2a5 Compare April 15, 2026 03:30
@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-2 branch from 627d2a5 to fe5fade Compare April 15, 2026 04:06
@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-3 branch from ece2b0c to 0bb1927 Compare April 15, 2026 05:15
@gemini-cli gemini-cli Bot added the area/extensions Issues related to Gemini CLI extensions capability label Apr 15, 2026
@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-2 branch from fe5fade to e32ef3c Compare April 15, 2026 19:44
@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-3 branch from 0bb1927 to aad3e4b Compare April 15, 2026 20:32
@mahimashanware mahimashanware marked this pull request as ready for review April 16, 2026 15:07
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 updates the EnterPlanModeTool to support extension-specific plan directories. It now iterates through active extensions, resolving custom plan directories from user settings or extension manifests, and ensures they are created before entering plan mode. Feedback was provided regarding a potential issue where the path resolution logic might throw an error for non-existent directories, preventing their creation.


if (customDir) {
try {
dirsToCreate.add(this.config.storage.getPlansDir(customDir));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The getPlansDir(customDir) call will fail for any directory that does not already exist because resolveWorkspaceRelativePath uses resolveToRealPath, which throws an error if the path is missing. While Rule 2 mandates using resolveToRealPath for consistent path resolution, this strictness breaks JIT provisioning for new custom plan directories. The resolver or its usage should be updated to handle non-existent paths for creation purposes while maintaining the consistency required by Rule 2.

References
  1. Ensure consistent path resolution by using a single, robust function (e.g., resolveToRealPath) for all related path validations, including internal validations in components like WorkspaceContext.

@mahimashanware mahimashanware force-pushed the feature/plan-mode-custom-dirs-phase-2 branch from e32ef3c to eee6466 Compare April 17, 2026 17:41
@mahimashanware mahimashanware requested a review from a team as a code owner April 17, 2026 17:41
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli Bot commented Apr 29, 2026

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!

@gemini-cli gemini-cli Bot closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant