Skip to content

refactor(core): use absolute paths in GEMINI.md context markers#23135

Merged
SandyTao520 merged 1 commit intomainfrom
st/feat/absolute-paths-gemini-md-context
Mar 20, 2026
Merged

refactor(core): use absolute paths in GEMINI.md context markers#23135
SandyTao520 merged 1 commit intomainfrom
st/feat/absolute-paths-gemini-md-context

Conversation

@SandyTao520
Copy link
Contributor

Summary

Use absolute paths instead of relative paths in the --- Context from: ... --- markers when formatting GEMINI.md context. This removes the dependency on the current working directory for display purposes and makes the context markers deterministic and unambiguous regardless of where the CLI is invoked from.

Details

  • concatenateInstructions() now uses item.filePath directly (already absolute) instead of computing path.relative(cwd, filePath).
  • Removed the now-unused currentWorkingDirectoryForDisplay parameter from concatenateInstructions.
  • Removed the now-unused workingDir parameter from categorizeAndConcatenate.
  • Updated all callers in contextManager.ts and memoryDiscovery.ts.
  • Updated all related test assertions to expect absolute paths.

Related Issues

Related to #20062

How to Validate

  1. Run the unit tests:
    npm test -w @google/gemini-cli-core -- src/utils/memoryDiscovery.test.ts
    npm test -w @google/gemini-cli-core -- src/services/contextManager.test.ts
  2. Start the CLI with JIT enabled and observe that --- Context from: markers now show absolute paths (e.g., /Users/you/.gemini/GEMINI.md) instead of relative ones.

Pre-Merge Checklist

  • Updated relevant documentation and README (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

Replace relative path computation with absolute file paths in the
--- Context from: ... --- markers emitted by concatenateInstructions.
Remove the now-unused currentWorkingDirectoryForDisplay parameter
from concatenateInstructions and workingDir from categorizeAndConcatenate.
@SandyTao520 SandyTao520 requested a review from a team as a code owner March 19, 2026 18:39
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Mar 19, 2026

Hi @SandyTao520, 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
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 refactors the context management system to ensure that file paths displayed in GEMINI.md context markers are always absolute. This change enhances the determinism and clarity of context markers, making them unambiguous regardless of the command-line interface's invocation location. By simplifying path resolution, the system becomes more robust and easier to debug, as context references will consistently point to their exact location.

Highlights

  • Absolute Paths for Context Markers: The --- Context from: ... --- markers in GEMINI.md context now use absolute file paths, removing dependency on the current working directory for display.
  • Simplified Path Resolution: The concatenateInstructions() function directly uses the already absolute item.filePath, eliminating the need for path.relative(cwd, filePath) calculations.
  • Parameter Removal: The currentWorkingDirectoryForDisplay parameter was removed from concatenateInstructions, and the workingDir parameter was removed from categorizeAndConcatenate.
  • Codebase Updates: All relevant callers in contextManager.ts and memoryDiscovery.ts have been updated to reflect the changes in function signatures.
  • Test Assertion Alignment: All related test assertions were updated to expect absolute paths in the context markers.
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

Size Change: -387 B (0%)

Total Size: 26.2 MB

Filename Size Change
./bundle/chunk-PUXPWX46.js 0 B -3.63 MB (removed) 🏆
./bundle/chunk-RBZ7YN5E.js 0 B -13.5 MB (removed) 🏆
./bundle/chunk-TCYGHW2X.js 0 B -1.95 MB (removed) 🏆
./bundle/core-YTG5VIQF.js 0 B -41.6 kB (removed) 🏆
./bundle/devtoolsService-UXOVLBYA.js 0 B -27.7 kB (removed) 🏆
./bundle/interactiveCli-6IY4D7BP.js 0 B -1.61 MB (removed) 🏆
./bundle/oauth2-provider-R5BUOB5R.js 0 B -9.19 kB (removed) 🏆
./bundle/chunk-5IESVULR.js 1.95 MB +1.95 MB (new file) 🆕
./bundle/chunk-5VGKHZ33.js 3.63 MB +3.63 MB (new file) 🆕
./bundle/chunk-WGNI7JV7.js 13.5 MB +13.5 MB (new file) 🆕
./bundle/core-AD5RP2NF.js 41.6 kB +41.6 kB (new file) 🆕
./bundle/devtoolsService-JMAYDVVP.js 27.7 kB +27.7 kB (new file) 🆕
./bundle/interactiveCli-MZSG332O.js 1.61 MB +1.61 MB (new file) 🆕
./bundle/oauth2-provider-SCPN4HVM.js 9.19 kB +9.19 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-37ZTTFQF.js 966 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/gemini.js 697 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-C47CWCMG.js 0 B -922 B (removed) 🏆
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/undici-4X2YZID5.js 360 B 0 B
./bundle/memoryDiscovery-AVZXKJ6A.js 922 B +922 B (new file) 🆕

compressed-size-action

Copy link
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

The pull request successfully refactors the GEMINI.md context markers to use absolute paths instead of relative ones. This change simplifies the logic in concatenateInstructions and categorizeAndConcatenate by removing the need to calculate relative paths based on the current working directory. All relevant test assertions have been updated to reflect the new absolute path format, ensuring the correctness of the change. The refactoring improves the determinism and clarity of context markers, as they are now unambiguous regardless of the CLI's invocation location.

@gemini-cli gemini-cli bot added area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 19, 2026
@SandyTao520 SandyTao520 added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 26b9af1 Mar 20, 2026
30 checks passed
@SandyTao520 SandyTao520 deleted the st/feat/absolute-paths-gemini-md-context branch March 20, 2026 19:29
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 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants