Skip to content

feat(extensions): show package.json version alongside tag in extension info#23105

Open
Br1an67 wants to merge 1 commit intogoogle-gemini:mainfrom
Br1an67:feat-extensions-version-info
Open

feat(extensions): show package.json version alongside tag in extension info#23105
Br1an67 wants to merge 1 commit intogoogle-gemini:mainfrom
Br1an67:feat-extensions-version-info

Conversation

@Br1an67
Copy link
Copy Markdown

@Br1an67 Br1an67 commented Mar 19, 2026

Summary

When extensions use non-descriptive version strings like "latest" in their gemini-extension.json, the /extensions list and /extensions update commands now also display the concrete version from package.json. For example: latest (0.20.2) instead of just latest.

Details

Added two utility functions in extension.ts:

  • getPackageVersion(extensionDir) — reads the version field from an extension's package.json, returning undefined if unavailable.
  • formatVersion(configVersion, packageVersion?) — returns just the config version when it matches the package version (or when no package version exists), otherwise combines them: configVersion (packageVersion).

These are applied in:

  • extension-manager.tstoOutputString() for /extensions list
  • config/extensions/update.tsoriginalVersion/updatedVersion in ExtensionUpdateInfo
  • commands/extensions/update.ts — "extension not found" error message listing

When config version equals package version (i.e., the author already uses proper semver), the display is unchanged.

Related Issues

Closes #22932

How to Validate

  1. Install an extension that uses "latest" as its version in gemini-extension.json (e.g. chrome-devtools-mcp).
  2. Run /extensions list — the output should now show latest (x.y.z) instead of just latest.
  3. Run /extensions update <name> — the success message should show meaningful version transitions like latest (0.20.0) → latest (0.20.2) instead of latest → latest.
  4. Install an extension that already uses proper semver (e.g. 1.0.0) — verify the display remains unchanged (no duplicate version).

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

…n info

When extensions use non-descriptive version strings like 'latest' in their
gemini-extension.json, the list and update commands now also read the
package.json version and display both values, e.g. 'latest (0.20.2)'.

This enriches version display in:
- /extensions list output
- /extensions update success messages
- CLI 'gemini extensions list' and 'gemini extensions update' commands

Closes google-gemini#22932
@Br1an67 Br1an67 requested a review from a team as a code owner March 19, 2026 13:33
@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 improves the clarity of extension version reporting within the CLI. By integrating package.json version information, users will now see more precise and actionable version details, especially for extensions that use generic version identifiers. This change enhances the user experience by providing a more complete picture of installed and updated extension versions without altering the display for extensions already using semantic versioning.

Highlights

  • Enhanced Extension Version Display: The /extensions list and /extensions update commands now display the concrete version from package.json alongside non-descriptive version strings (e.g., latest (0.20.2) instead of just latest).
  • New Version Utility Functions: Two new utility functions, getPackageVersion and formatVersion, were added to extension.ts to handle reading package.json versions and formatting them for display.
  • Improved Update Messages: Extension update messages now show meaningful version transitions, such as latest (0.20.0) → latest (0.20.2), providing clearer information to users.
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.

@gemini-cli gemini-cli bot added the area/extensions Issues related to Gemini CLI extensions capability label Mar 19, 2026
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 feature to display the package.json version alongside the configured extension version, enhancing user information. A security audit found no exploitable high or critical vulnerabilities, with functions like getPackageVersion and formatVersion handling data safely. However, there's a potential efficiency concern due to synchronous file system access within the getPackageVersion function, which could lead to performance degradation when listing or updating multiple extensions, as highlighted by the comments referencing the rule against blocking I/O.

.map((extension) => `${extension.name} (${extension.version})`)
.map(
(extension) =>
`${extension.name} (${formatVersion(extension.version, getPackageVersion(extension.path))})`,
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 call to getPackageVersion(extension.path) within this .map function performs a synchronous file read for each installed extension. Performing synchronous I/O operations in a loop can block the Node.js event loop and lead to performance degradation, especially when a large number of extensions are installed.

Suggestion:
Consider optimizing the retrieval of package.json versions. The most robust solution would be to load and store the packageVersion directly on the GeminiCLIExtension object during its initial loading (e.g., in _buildExtension in extension-manager.ts). If modifying the GeminiCLIExtension interface is not feasible within this change, an alternative could be to make getPackageVersion asynchronous and use Promise.all to fetch all versions concurrently, or implement a caching mechanism for getPackageVersion results if the same extension.path might be queried multiple times.

References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.


const status = workspaceEnabled ? chalk.green('✓') : chalk.red('✗');
let output = `${status} ${extension.name} (${extension.version})`;
let output = `${status} ${extension.name} (${formatVersion(extension.version, getPackageVersion(extension.path))})`;
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

Similar to the previous comment, the toOutputString method calls getPackageVersion(extension.path) for each extension. This also involves synchronous file system access in a potentially iterated context (e.g., when listing all extensions). This can contribute to performance issues due to blocking I/O, particularly if many extensions are displayed.

Suggestion:
Refer to the suggestion for packages/cli/src/commands/extensions/update.ts. Ideally, the packageVersion should be loaded once and stored on the GeminiCLIExtension object. If that's not possible, explore asynchronous file reading with Promise.all or a caching strategy for getPackageVersion to mitigate the impact of synchronous I/O.

References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.

const originalVersion = extension.version;
const originalVersion = formatVersion(
extension.version,
getPackageVersion(extension.path),
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 updateExtension function calls getPackageVersion(extension.path) twice: once for originalVersion and once for updatedVersion. While this function is typically called for a single extension at a time, the synchronous nature of fs.readFileSync within getPackageVersion still introduces blocking I/O. If updateExtension were to be called in a batch process (e.g., for multiple extensions in parallel), this could compound the performance impact.

Suggestion:
While the impact here might be less severe than in listing scenarios, it's still a synchronous file read. The long-term solution remains to store the packageVersion on the GeminiCLIExtension object. For immediate improvement, if getPackageVersion were made asynchronous, these calls would need to be awaited.

References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.

const updatedVersion = updatedExtension.version;
const updatedVersion = formatVersion(
updatedExtension.version,
getPackageVersion(updatedExtension.path),
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

This is another instance where getPackageVersion(updatedExtension.path) is called synchronously. As noted in previous comments, repeated synchronous file I/O can lead to performance bottlenecks and is generally an anti-pattern in Node.js for operations that might involve multiple items.

Suggestion:
Refer to the suggestion for packages/cli/src/commands/extensions/update.ts. The long-term solution remains to store the packageVersion on the GeminiCLIExtension object. For immediate improvement, if getPackageVersion were made asynchronous, these calls would need to be awaited.

References
  1. Use asynchronous file system operations (e.g., fs.promises.readFile) instead of synchronous ones (e.g., fs.readFileSync) to avoid blocking the event loop.

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Apr 3, 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!

@cocosheng-g
Copy link
Copy Markdown
Contributor

@Br1an67, apologies for the bot closing this PR! We have reopened it. Please sync your branch to the latest main and we will have someone review it shortly.

@gemini-cli gemini-cli bot added the help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! label Apr 9, 2026
@lesteral
Copy link
Copy Markdown

@Br1an67 - I would greatly appreciate your completing this PR, if you can spare the time. Thanks, Lester

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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/extensions update ... needs meaningful version info.

3 participants