@@ -379,6 +379,7 @@ describe("Workflow Integration Tests", () => {
379379
380380      const  baseConfig  =  { 
381381        rules : [ "existing rule" ] , 
382+         prompts : [ ] , 
382383      } ; 
383384
384385      const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
@@ -387,34 +388,42 @@ describe("Workflow Integration Tests", () => {
387388        workflowService . getState ( ) , 
388389      ) ; 
389390
390-       // Prompts should be processed at runtime, not injected into config 
391-       // The workflow prompt is added to options.prompt and will be processed 
392-       // by processAndCombinePrompts() in chat.ts 
391+       // Workflow prompt should be added to config.prompts 
392+       expect ( enhancedConfig . prompts ) . toBeDefined ( ) ; 
393+       expect ( enhancedConfig . prompts ?. length ) . toBeGreaterThan ( 0 ) ; 
394+       expect ( enhancedConfig . prompts ?. [ 0 ] ) . toMatchObject ( { 
395+         prompt : "You are a workflow assistant." , 
396+         name : expect . stringContaining ( "Test Workflow" ) , 
397+       } ) ; 
393398      expect ( enhancedConfig . rules ) . toHaveLength ( 2 ) ; 
394399    } ) ; 
395400
396-     it ( "should add workflow prompt as prefix to existing  prompts" ,  async  ( )  =>  { 
401+     it ( "should add workflow prompt to config alongside other  prompts" ,  async  ( )  =>  { 
397402      // Setup workflow service with active workflow 
398403      mockLoadPackageFromHub . mockResolvedValue ( mockWorkflowFile ) ; 
399404      await  workflowService . initialize ( "owner/workflow" ) ; 
400405
401-       // Test that the workflow prompt gets added to options.prompt as prefix 
402-       const  baseOptions  =  {  prompt : [ "existing-prompt" ]  } ; 
403-       const  modifiedOptions  =  {  ...baseOptions  } ; 
406+       const  baseConfig  =  { 
407+         prompts : [ {  name : "Existing" ,  prompt : "existing-prompt"  } ] , 
408+       } ; 
409+       const  baseOptions  =  { } ; 
404410
405-       // Simulate what ConfigEnhancer does internally 
406-       const  workflowState  =  workflowService . getState ( ) ; 
407-       if  ( workflowState . workflowFile ?. prompt )  { 
408-         modifiedOptions . prompt  =  [ 
409-           workflowState . workflowFile . prompt , 
410-           ...( modifiedOptions . prompt  ||  [ ] ) , 
411-         ] ; 
412-       } 
413- 
414-       expect ( modifiedOptions . prompt ) . toEqual ( [ 
415-         "You are a workflow assistant." , 
416-         "existing-prompt" , 
417-       ] ) ; 
411+       const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
412+         baseConfig  as  any , 
413+         baseOptions , 
414+         workflowService . getState ( ) , 
415+       ) ; 
416+ 
417+       // Workflow prompt should be prepended to existing prompts 
418+       expect ( enhancedConfig . prompts ) . toHaveLength ( 2 ) ; 
419+       expect ( enhancedConfig . prompts ?. [ 0 ] ) . toMatchObject ( { 
420+         name : expect . stringContaining ( "Test Workflow" ) , 
421+         prompt : "You are a workflow assistant." , 
422+       } ) ; 
423+       expect ( enhancedConfig . prompts ?. [ 1 ] ) . toMatchObject ( { 
424+         name : "Existing" , 
425+         prompt : "existing-prompt" , 
426+       } ) ; 
418427    } ) ; 
419428
420429    it ( "should not add workflow prompt when workflow has no prompt" ,  async  ( )  =>  { 
@@ -426,43 +435,53 @@ describe("Workflow Integration Tests", () => {
426435      mockLoadPackageFromHub . mockResolvedValue ( workflowWithoutPrompt ) ; 
427436      await  workflowService . initialize ( "owner/workflow" ) ; 
428437
429-       const  baseOptions  =  {  prompt : [ "existing-prompt" ]  } ; 
430-       const  modifiedOptions  =  {  ...baseOptions  } ; 
438+       const  baseConfig  =  { 
439+         prompts : [ {  name : "Existing" ,  prompt : "existing-prompt"  } ] , 
440+       } ; 
441+       const  baseOptions  =  { } ; 
442+ 
443+       const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
444+         baseConfig  as  any , 
445+         baseOptions , 
446+         workflowService . getState ( ) , 
447+       ) ; 
431448
432-       // Simulate what ConfigEnhancer does internally 
433-       const  workflowState  =  workflowService . getState ( ) ; 
434-       if  ( workflowState . workflowFile ?. prompt )  { 
435-         modifiedOptions . prompt  =  [ 
436-           workflowState . workflowFile . prompt , 
437-           ...( modifiedOptions . prompt  ||  [ ] ) , 
438-         ] ; 
439-       } 
440- 
441-       expect ( modifiedOptions . prompt ) . toEqual ( [ "existing-prompt" ] ) ; 
449+       // Should only have the existing prompt, no workflow prompt added 
450+       expect ( enhancedConfig . prompts ) . toHaveLength ( 1 ) ; 
451+       expect ( enhancedConfig . prompts ?. [ 0 ] ) . toMatchObject ( { 
452+         name : "Existing" , 
453+         prompt : "existing-prompt" , 
454+       } ) ; 
442455    } ) ; 
443456  } ) ; 
444457
445458  describe ( "ConfigEnhancer prompt integration" ,  ( )  =>  { 
446-     it ( "should modify options  to include  workflow prompt as prefix " ,  async  ( )  =>  { 
459+     it ( "should add workflow prompt  to config.prompts when  workflow is active " ,  async  ( )  =>  { 
447460      // Setup workflow service with active workflow 
448461      mockLoadPackageFromHub . mockResolvedValue ( mockWorkflowFile ) ; 
449462      await  workflowService . initialize ( "owner/workflow" ) ; 
450463
451464      const  baseOptions  =  {  prompt : [ "user-prompt" ]  } ; 
465+       const  baseConfig  =  {  prompts : [ ]  } ; 
452466
453-       // This should internally modify the options to include  workflow prompt  
454-       await  configEnhancer . enhanceConfig ( 
455-         { }  as  any , 
467+       // Enhance config with  workflow state  
468+       const   enhancedConfig   =   await  configEnhancer . enhanceConfig ( 
469+         baseConfig  as  any , 
456470        baseOptions , 
457471        workflowService . getState ( ) , 
458472      ) ; 
459473
460-       // Verify that the workflow prompt was added to the options 
461-       // by checking that injectPrompts was called with workflow prompt prefixed 
462-       expect ( baseOptions . prompt ) . toHaveLength ( 1 ) ; 
474+       // Verify that the workflow prompt was added to config.prompts 
475+       expect ( enhancedConfig . prompts ) . toBeDefined ( ) ; 
476+       expect ( enhancedConfig . prompts ) . toHaveLength ( 1 ) ; 
477+       expect ( enhancedConfig . prompts ?. [ 0 ] ) . toMatchObject ( { 
478+         name : expect . stringContaining ( "Test Workflow" ) , 
479+         prompt : "You are a workflow assistant." , 
480+         description : "A test workflow for integration testing" , 
481+       } ) ; 
463482    } ) ; 
464483
465-     it ( "should work end-to-end with workflow prompt processing " ,  async  ( )  =>  { 
484+     it ( "should work end-to-end with workflow prompt in config " ,  async  ( )  =>  { 
466485      // Setup workflow service with active workflow 
467486      mockLoadPackageFromHub . mockResolvedValue ( mockWorkflowFile ) ; 
468487      await  workflowService . initialize ( "owner/workflow" ) ; 
@@ -472,24 +491,23 @@ describe("Workflow Integration Tests", () => {
472491        "You are a workflow assistant." , 
473492      ) ; 
474493
475-       // Verify that if we manually apply the same logic as ConfigEnhancer, 
476-       // the workflow prompt gets added as prefix 
477-       const  options  =  {  prompt : [ "Tell me about TypeScript" ]  } ; 
494+       const  baseConfig  =  {  prompts : [ ]  } ; 
495+       const  baseOptions  =  {  prompt : [ "Tell me about TypeScript" ]  } ; 
478496
479-       if  ( workflowState . workflowFile ?. prompt )  { 
480-         options . prompt  =  [ workflowState . workflowFile . prompt ,  ...options . prompt ] ; 
481-       } 
497+       // Enhance config with workflow 
498+       const  enhancedConfig  =  await  configEnhancer . enhanceConfig ( 
499+         baseConfig  as  any , 
500+         baseOptions , 
501+         workflowState , 
502+       ) ; 
482503
483-       expect ( options . prompt ) . toEqual ( [ 
504+       // Verify workflow prompt is added to config.prompts 
505+       expect ( enhancedConfig . prompts ) . toBeDefined ( ) ; 
506+       expect ( enhancedConfig . prompts ?. length ) . toBeGreaterThan ( 0 ) ; 
507+       expect ( enhancedConfig . prompts ?. [ 0 ] ?. prompt ) . toBe ( 
484508        "You are a workflow assistant." , 
485-         "Tell me about TypeScript" , 
486-       ] ) ; 
487- 
488-       // This mimics what processAndCombinePrompts would do 
489-       const  combinedPrompt  =  options . prompt . join ( "\n\n" ) ; 
490-       expect ( combinedPrompt ) . toBe ( 
491-         "You are a workflow assistant.\n\nTell me about TypeScript" , 
492509      ) ; 
510+       expect ( enhancedConfig . prompts ?. [ 0 ] ?. name ) . toContain ( "Test Workflow" ) ; 
493511    } ) ; 
494512  } ) ; 
495513
0 commit comments