mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
3.2 KiB
3.2 KiB
Summary
This PR implements a seamless migration path for extensions to move to a new repository and optionally change their name without stranding existing users.
When an extension author sets the migratedTo field in their
gemini-extension.json and publishes an update to their old repository, the CLI
will detect this during the next update check. The CLI will then automatically
download the extension from the new repository, explicitly warn the user about
the migration (and any renaming) during the consent step, and seamlessly migrate
the installation and enablement status while cleaning up the old installation.
Details
- Configuration: Added
migratedToproperty toExtensionConfigandGeminiCLIExtensionto track the new repository URL. - Update checking & downloading: Updated
checkForExtensionUpdateandupdateExtensionto inspect themigratedTofield. If present, the CLI queries the new repository URL for an update and swaps the installation source so the update resolves from the new location. - Migration & renaming logic (
ExtensionManager):installOrUpdateExtensionnow fully supports renaming. It transfers global and workspace enablement states from the old extension name to the new one and deletes the old extension directory.- Added safeguards to block renaming if the new name conflicts with a different, already-installed extension or if the destination directory already exists.
- Exposed
getEnablementManager()toExtensionManagerfor better typing during testing.
- Consent messaging: Refactored
maybeRequestConsentOrFailto compute anisMigratingflag (by detecting a change in the installation source). TheextensionConsentStringoutput now explicitly informs users with messages like: "Migrating extension 'old-name' to a new repository, renaming to 'new-name', and installing updates." - Documentation: Documented the
migratedTofield indocs/extensions/reference.mdand added a comprehensive guide indocs/extensions/releasing.mdexplaining how extension maintainers can transition users using this feature. - Testing: Added extensive unit tests across
extension-manager.test.ts,consent.test.ts,github.test.ts, andupdate.test.tsto cover the new migration and renaming logic.
Related issues
N/A
How to validate
- Unit tests: Run all related tests to confirm everything passes:
npm run test -w @google/gemini-cli -- src/config/extensions/github.test.ts npm run test -w @google/gemini-cli -- src/config/extensions/update.test.ts npm run test -w @google/gemini-cli -- src/config/extensions/consent.test.ts npm run test -w @google/gemini-cli -- src/config/extension-manager.test.ts - End-to-end migration test:
- Install a local or git extension.
- Update its
gemini-extension.jsonto include amigratedTofield pointing to a different test repository. - Run
gemini extensions checkto confirm it detects the update from the new source. - Run
gemini extensions update <extension>. - Verify that the consent prompt explicitly mentions the migration.
- Verify that the new extension is installed, the old directory is deleted, and its enablement status carried over.