gemini-cli - ✅(Solved) Fix exit_plan_mode hook regression caused by PR 22737 [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25054Fetched 2026-04-10 03:44:54
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
1
Author
Participants
Timeline (top)
labeled ×3subscribed ×1unlabeled ×1

PR fix notes

PR #25296: fix(core): expose GEMINI_PLANS_DIR to hook environment

Description (problem / solution / changelog)

Summary

Fixes a regression where hook scripts intercepting exit_plan_mode could no longer determine the absolute path to the plan file. This occurred because PR #22737 changed the plan_path argument to plan_filename.

Details

Following user steering, this PR:

  1. Exposes GEMINI_PLANS_DIR: Modified HookRunner to inject the absolute path of the plans directory into the environment of all command hooks.
  2. Updates Documentation:
    • Adds GEMINI_PLANS_DIR to the list of provided environment variables in docs/hooks/index.md.
    • Updates the archive-plan.sh example in docs/cli/plan-mode.md to show how to reconstruct the plan path using the new environment variable and the existing plan_filename input.
  3. Strengthens Tests: Added unit tests to HookRunner to verify the presence of GEMINI_PLANS_DIR in spawned processes.

This approach keeps the tool interface stable while providing necessary context to external scripts through the execution harness.

Related Issues

Closes #25054

How to Validate

  1. Unit Tests:
    npm test -w @google/gemini-cli-core -- src/hooks/hookRunner.test.ts
  2. Manual Verification: Configure a hook for exit_plan_mode that echoes $GEMINI_PLANS_DIR to verify it's correctly populated.

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

Changed files

  • docs/cli/plan-mode.md (modified, +6/-2)
  • docs/hooks/index.md (modified, +1/-0)
  • packages/core/src/hooks/hookRunner.test.ts (modified, +42/-0)
  • packages/core/src/hooks/hookRunner.ts (modified, +12/-0)

Code Example

> /about
| CLI Version                            0.36.0-nightly.20260317.2f90b4653-git.e77b22eGit Commit                             e77b22e                                                                  │
Model                                  gemini-3.1-pro-preview                                                   │
Sandbox                                no sandbox                                                               │
OS                                     linux                                                                    │
Auth Method                            gemini-api-key
RAW_BUFFERClick to expand / collapse

What happened?

The current docs suggest using a hook to auto-archive plan files: https://geminicli.com/docs/cli/plan-mode/#example-archive-approved-plans-to-gcs-aftertool

This is no longer possible since plan_path (abs path) was replaced by plan_filename (a filename like "plan.md") in #22737 . The hook script no longer receives sufficient data to resolve the path to the plan file by itself (based on the input JSON and env vars), unless it resorts to a hack such as parsing the returnDisplay message.

What did you expect to happen?

The exit_plan_mode hook script should be able to easily resolve the path to the plan file based on the input JSON.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
| CLI Version                            0.36.0-nightly.20260317.2f90b4653-git.e77b22e                            │
│ Git Commit                             e77b22e                                                                  │
│ Model                                  gemini-3.1-pro-preview                                                   │
│ Sandbox                                no sandbox                                                               │
│ OS                                     linux                                                                    │
│ Auth Method                            gemini-api-key
</details>

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

Update the hook script to handle the new plan_filename format and resolve the plan file path using an alternative approach.

Guidance

  • Review the changes introduced in #22737 to understand the implications of replacing plan_path with plan_filename.
  • Modify the hook script to parse the returnDisplay message or explore other environment variables to resolve the plan file path.
  • Consider updating the documentation to reflect the new requirements for the exit_plan_mode hook script.
  • Test the updated hook script to ensure it correctly resolves the plan file path and archives the plan files as expected.

Example

No code example is provided due to the lack of specific implementation details in the issue.

Notes

The solution may require additional modifications to the hook script or the documentation, depending on the specific requirements and constraints of the project.

Recommendation

Apply workaround: Update the hook script to handle the new plan_filename format, as the replacement of plan_path is a deliberate change introduced in #22737.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING