refactor: extract common extension patterns into openhands.sdk.extensions module#2791
Draft
refactor: extract common extension patterns into openhands.sdk.extensions module#2791
Conversation
…ions module
Create a new `openhands.sdk.extensions` module to deduplicate code between
plugin, marketplace, and skills modules. This extracts:
- ExtensionSource, ResolvedExtensionSource, ExtensionAuthor (source.py)
- ExtensionCatalogEntry, ExtensionCatalog (catalog.py)
- fetch_extension_with_resolution (fetch.py)
- InstalledExtensionInfo, InstalledExtensionMetadata[T], InstalledExtensionManager[ItemT, InfoT] (installed.py)
Key changes:
- PluginSource now extends ExtensionSource
- PluginAuthor now extends ExtensionAuthor
- InstalledPluginInfo now extends InstalledExtensionInfo
- InstalledSkillInfo now extends InstalledExtensionInfo
- Both plugin/installed.py and skills/installed.py now use InstalledExtensionManager
- Backward-compatible wrappers preserve legacy API (InstalledPluginsMetadata, InstalledSkillsMetadata)
- Legacy metadata formats ("plugins", "skills" keys) are still supported when loading
This reduces code duplication by ~400+ lines while maintaining full backward compatibility.
Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Contributor
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
plugin,marketplace, andskillsmodules had significant code duplication:InstalledPluginInfoandInstalledSkillInfoshared 90% of their fieldsPluginSourceand skill source handling had identical logicInstalledPluginsMetadataandInstalledSkillsMetadatahad identical persistence codeSummary
openhands.sdk.extensionsmodule with shared base classesExtensionSource,ResolvedExtensionSource,ExtensionAuthorintosource.pyExtensionCatalogEntry,ExtensionCatalogintocatalog.pyfetch_extension_with_resolutionintofetch.pyInstalledExtensionInfo,InstalledExtensionMetadata[T],InstalledExtensionManager[ItemT, InfoT]intoinstalled.pyplugin/installed.py(~500 → ~150 lines) andskills/installed.py(~580 → ~200 lines) to use the new generic managerIssue Number
N/A - Internal refactoring task
How to Test
Run the tests for installed plugins and skills:
All 53 tests pass.
Backward compatibility verified:
InstalledPluginsMetadata(plugins={...})still works (legacy kwarg){"plugins": ...}or{"skills": ...}keys still worksPluginSource,PluginAuthor,InstalledPluginInfoall still work as beforeVideo/Screenshots
N/A - This is a refactoring PR with no UI changes.
Type
Notes
class Foo[T: Bound]InstalledExtensionManageris generic over both the item type (e.g.,Plugin,Skill) and the info type (e.g.,InstalledPluginInfo,InstalledSkillInfo)This PR was created by an AI assistant (OpenHands) on behalf of the user.
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22-slimgolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:776ea8c-pythonRun
All tags pushed for this build
About Multi-Architecture Support
776ea8c-python) is a multi-arch manifest supporting both amd64 and arm64776ea8c-python-amd64) are also available if needed