@@ -480,6 +480,52 @@ describe("write-cli-startup-metadata", () => {
480480 expect ( written . subcommandHelpText . tasks ) . toContain ( "openclaw tasks" ) ;
481481 } ) ;
482482
483+ it ( "selects the root-help bundle that exports the renderer" , async ( ) => {
484+ const tempRoot = createTempDir ( "openclaw-startup-metadata-bundle-selection-" ) ;
485+ const distDir = path . join ( tempRoot , "dist" ) ;
486+ const extensionsDir = path . join ( tempRoot , "extensions" ) ;
487+ const outputPath = path . join ( distDir , "cli-startup-metadata.json" ) ;
488+ const renderSourceRootHelpText = vi . fn ( ( ) => "Usage: source fallback\n" ) ;
489+
490+ writeStartupMetadataSourceSignatureFixture ( tempRoot ) ;
491+ writeFixtureFile ( tempRoot , "package.json" , '{"type":"module"}\n' ) ;
492+ writeFixtureFile (
493+ distDir ,
494+ "root-help-live-config-fixture.js" ,
495+ "async function loadRootHelpRenderOptionsForConfigSensitivePlugins() { return null; }\nexport { loadRootHelpRenderOptionsForConfigSensitivePlugins };\n" ,
496+ ) ;
497+ writeFixtureFile (
498+ distDir ,
499+ "root-help-renderer-fixture.js" ,
500+ "async function outputRootHelp() { process.stdout.write('Usage: bundled renderer\\n'); }\nexport { outputRootHelp };\n" ,
501+ ) ;
502+
503+ await writeCliStartupMetadata ( {
504+ distDir,
505+ outputPath,
506+ extensionsDir,
507+ sourceRootDir : tempRoot ,
508+ renderSourceRootHelpText,
509+ renderSourceBrowserHelpText : ( ) => "Usage: openclaw browser\n" ,
510+ renderSourceSecretsHelpText : ( ) => "Usage: openclaw secrets\n" ,
511+ renderSourceNodesHelpText : ( ) => "Usage: openclaw nodes\n" ,
512+ renderSourceSubcommandHelpTextRecord : ( ) => ( {
513+ doctor : "Usage: openclaw doctor\n" ,
514+ gateway : "Usage: openclaw gateway\n" ,
515+ models : "Usage: openclaw models\n" ,
516+ plugins : "Usage: openclaw plugins\n" ,
517+ sessions : "Usage: openclaw sessions\n" ,
518+ tasks : "Usage: openclaw tasks\n" ,
519+ } ) ,
520+ } ) ;
521+
522+ const written = JSON . parse ( readFileSync ( outputPath , "utf8" ) ) as {
523+ rootHelpText : string ;
524+ } ;
525+ expect ( written . rootHelpText ) . toBe ( "Usage: bundled renderer\n" ) ;
526+ expect ( renderSourceRootHelpText ) . not . toHaveBeenCalled ( ) ;
527+ } ) ;
528+
483529 it ( "renders independent startup help snapshots concurrently" , async ( ) => {
484530 const tempRoot = createTempDir ( "openclaw-startup-metadata-concurrency-" ) ;
485531 const distDir = path . join ( tempRoot , "dist" ) ;
0 commit comments