@@ -66,6 +66,8 @@ function normalizeInstallRecord(
6666 setInstallStringField ( normalized , "spec" , record . spec ) ;
6767 setInstallStringField ( normalized , "sourcePath" , record . sourcePath ) ;
6868 setInstallStringField ( normalized , "installPath" , record . installPath ) ;
69+ setInstallStringField ( normalized , "format" , record . format ) ;
70+ setInstallStringField ( normalized , "bundleFormat" , record . bundleFormat ) ;
6971 setInstallStringField ( normalized , "version" , record . version ) ;
7072 setInstallStringField ( normalized , "resolvedName" , record . resolvedName ) ;
7173 setInstallStringField ( normalized , "resolvedVersion" , record . resolvedVersion ) ;
@@ -121,6 +123,24 @@ function restoreInstallRecord(
121123 return structuredClone ( record ) as PluginInstallRecord ;
122124}
123125
126+ function isBundleFormat ( value : unknown ) : value is NonNullable < PluginInstallRecord [ "bundleFormat" ] > {
127+ return value === "codex" || value === "claude" || value === "cursor" ;
128+ }
129+
130+ function enrichInstallRecordWithIndexedFormat (
131+ restored : PluginInstallRecord | undefined ,
132+ plugin : InstalledPluginIndex [ "plugins" ] [ number ] ,
133+ ) : PluginInstallRecord | undefined {
134+ if ( ! restored || plugin . format !== "bundle" || ! isBundleFormat ( plugin . bundleFormat ) ) {
135+ return restored ;
136+ }
137+ return {
138+ ...restored ,
139+ format : "bundle" ,
140+ bundleFormat : plugin . bundleFormat ,
141+ } ;
142+ }
143+
124144/** Normalizes raw plugin install records into index-safe install record metadata. */
125145export function normalizeInstallRecordMap (
126146 records : Record < string , PluginInstallRecord > | undefined ,
@@ -157,11 +177,21 @@ export function extractPluginInstallRecordsFromInstalledPluginIndex(
157177 index : InstalledPluginIndex | null | undefined ,
158178) : Record < string , PluginInstallRecord > {
159179 if ( index && Object . hasOwn ( index , "installRecords" ) ) {
160- return restoreInstallRecordMap ( index . installRecords ) ;
180+ const records = restoreInstallRecordMap ( index . installRecords ) ;
181+ for ( const plugin of index . plugins ) {
182+ const enriched = enrichInstallRecordWithIndexedFormat ( records [ plugin . pluginId ] , plugin ) ;
183+ if ( enriched ) {
184+ records [ plugin . pluginId ] = enriched ;
185+ }
186+ }
187+ return records ;
161188 }
162189 const records : Record < string , PluginInstallRecord > = { } ;
163190 for ( const plugin of index ?. plugins ?? [ ] ) {
164- const record = restoreInstallRecord ( plugin . installRecord ) ;
191+ const record = enrichInstallRecordWithIndexedFormat (
192+ restoreInstallRecord ( plugin . installRecord ) ,
193+ plugin ,
194+ ) ;
165195 if ( record ) {
166196 records [ plugin . pluginId ] = record ;
167197 }
0 commit comments