-
-
Notifications
You must be signed in to change notification settings - Fork 260
fix(plugin-loader): support installed_plugins.json v1 format for backward compatibility #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-loader): support installed_plugins.json v1 format for backward compatibility #288
Conversation
…ward compatibility The installed_plugins.json file has two versions: - v1: plugins stored as direct objects - v2: plugins stored as arrays Use discriminated union types (InstalledPluginsDatabaseV1/V2) for proper type narrowing based on version field.
|
All contributors have signed the CLA. Thank you! ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Greptile SummaryAdded backward compatibility for Key changes:
Impact:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Loader as Plugin Loader
participant FS as File System
participant Extract as extractPluginEntries()
participant TypeCheck as TypeScript Type System
Loader->>FS: Read installed_plugins.json
FS-->>Loader: Return database content
Loader->>Loader: Parse JSON as InstalledPluginsDatabase
Note over Loader: Union type: V1 | V2
Loader->>Extract: extractPluginEntries(db)
Extract->>TypeCheck: Check db.version === 1
alt Version 1 (Legacy)
TypeCheck-->>Extract: Type narrowed to V1
Note over Extract: plugins: Record<string, PluginInstallation>
Extract->>Extract: Object.entries(db.plugins)
Extract->>Extract: Map to [key, installation]
Extract-->>Loader: Return entries with direct objects
else Version 2 (Current)
TypeCheck-->>Extract: Type narrowed to V2
Note over Extract: plugins: Record<string, PluginInstallation[]>
Extract->>Extract: Object.entries(db.plugins)
Extract->>Extract: Map to [key, installations[0]]
Extract-->>Loader: Return entries with first array element
end
Loader->>Loader: Iterate over entries
Loader->>Loader: Process each plugin installation
|
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
|
wow, didn't even knew how cc plugin has this kind of version stuff, thanks. |
…ward compatibility (#288) The installed_plugins.json file has two versions: - v1: plugins stored as direct objects - v2: plugins stored as arrays Use discriminated union types (InstalledPluginsDatabaseV1/V2) for proper type narrowing based on version field. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
Summary
installed_plugins.jsonv1 format to prevent destructuring errors when loading legacy plugin databasesProblem
The
installed_plugins.jsonfile has two versions with different structures:plugins: Record<string, PluginInstallation>(direct object)plugins: Record<string, PluginInstallation[]>(array)The current implementation only supports v2 format, causing the following error when running opencode (while loading v1 databases):
Workaround (v2.6.0)
If you encounter this error, you can work around it by:
installed_plugins.jsonto v2 format)Solution
InstalledPluginsDatabaseV1/InstalledPluginsDatabaseV2) for proper type narrowingextractPluginEntries()helper that handles both formats based on version fielddb.version === 1Changes
types.ts: Define separate interfaces for v1/v2 with literal version typesloader.ts: Add version-aware extraction logic with type narrowing