@@ -120,7 +120,7 @@ function deepFreeze<T>(value: T, seen = new WeakSet<object>()): T {
120120 return Object . freeze ( value ) ;
121121}
122122
123- function writePackageManifest ( rootDir : string , channelLabel : string ) {
123+ function writePackageManifest ( rootDir : string , channelLabel : string , selectionDocsPrefix ?: string ) {
124124 const packageJsonPath = path . join ( rootDir , "package.json" ) ;
125125 fs . writeFileSync (
126126 packageJsonPath ,
@@ -134,6 +134,7 @@ function writePackageManifest(rootDir: string, channelLabel: string) {
134134 channel : {
135135 id : "installed" ,
136136 label : channelLabel ,
137+ ...( selectionDocsPrefix !== undefined ? { selectionDocsPrefix } : { } ) ,
137138 } ,
138139 } ,
139140 } ) ,
@@ -142,9 +143,12 @@ function writePackageManifest(rootDir: string, channelLabel: string) {
142143 return packageJsonPath ;
143144}
144145
145- function createIndexWithPackageJson ( rootDir : string ) : InstalledPluginIndex {
146+ function createIndexWithPackageJson (
147+ rootDir : string ,
148+ selectionDocsPrefix ?: string ,
149+ ) : InstalledPluginIndex {
146150 const index = createIndexWithFileSignatures ( rootDir ) ;
147- const packageJsonPath = writePackageManifest ( rootDir , "Installed" ) ;
151+ const packageJsonPath = writePackageManifest ( rootDir , "Installed" , selectionDocsPrefix ) ;
148152 const record = index . plugins [ 0 ] ;
149153 if ( ! record ) {
150154 throw new Error ( "expected index record" ) ;
@@ -179,6 +183,16 @@ function createIndexWithUnhashedPackageJson(rootDir: string): InstalledPluginInd
179183}
180184
181185describe ( "loadPluginManifestRegistryForInstalledIndex" , ( ) => {
186+ const loadRegistry = ( index : InstalledPluginIndex ) =>
187+ loadPluginManifestRegistryForInstalledIndex ( {
188+ index,
189+ env : {
190+ OPENCLAW_VERSION : "2026.4.25" ,
191+ VITEST : "true" ,
192+ } ,
193+ includeDisabled : true ,
194+ } ) ;
195+
182196 it ( "reuses frozen installed-index fingerprints when file signatures are persisted" , ( ) => {
183197 const rootDir = makeTempDir ( ) ;
184198 writePlugin ( rootDir , "installed" , "installed-" ) ;
@@ -330,6 +344,38 @@ describe("loadPluginManifestRegistryForInstalledIndex", () => {
330344 } ) ;
331345 } ) ;
332346
347+ it ( "preserves empty docs prefixes from package channel metadata" , ( ) => {
348+ const rootDir = makeTempDir ( ) ;
349+ writePlugin ( rootDir , "installed" , "installed-" ) ;
350+
351+ const registry = loadRegistry ( createIndexWithPackageJson ( rootDir , "" ) ) ;
352+
353+ expect ( registry . plugins [ 0 ] ?. packageChannel ?. selectionDocsPrefix ) . toBe ( "" ) ;
354+ } ) ;
355+
356+ it ( "preserves empty docs prefixes from persisted installed-index metadata" , ( ) => {
357+ const rootDir = makeTempDir ( ) ;
358+ writePlugin ( rootDir , "installed" , "installed-" ) ;
359+ const index = createIndex ( rootDir ) ;
360+ const record = expectDefined ( index . plugins [ 0 ] , "index.plugins[0] test invariant" ) ;
361+
362+ const registry = loadRegistry ( {
363+ ...index ,
364+ plugins : [
365+ {
366+ ...record ,
367+ packageChannel : {
368+ id : "installed" ,
369+ label : "Installed" ,
370+ selectionDocsPrefix : "" ,
371+ } ,
372+ } ,
373+ ] ,
374+ } ) ;
375+
376+ expect ( registry . plugins [ 0 ] ?. packageChannel ?. selectionDocsPrefix ) . toBe ( "" ) ;
377+ } ) ;
378+
333379 it ( "reuses installed package json path validation across registry loads" , ( ) => {
334380 const rootDir = makeTempDir ( ) ;
335381 writePlugin ( rootDir , "installed" , "installed-" ) ;
0 commit comments