@@ -374,3 +374,127 @@ func TestCollectPromptSections_GitHubMCPAndSafeOutputsConsistency(t *testing.T)
374374 }
375375 })
376376}
377+
378+ // TestCollectPromptSections_CliProxy tests that when the cli-proxy feature flag is
379+ // enabled, the cli-proxy prompt is used instead of the GitHub MCP tools prompt,
380+ // and that the GitHub MCP server guidance is never injected.
381+ func TestCollectPromptSections_CliProxy (t * testing.T ) {
382+ t .Run ("cli-proxy enabled without safe-outputs uses cli_proxy_prompt" , func (t * testing.T ) {
383+ compiler := & Compiler {}
384+
385+ data := & WorkflowData {
386+ ParsedTools : NewTools (map [string ]any {"github" : true }),
387+ Features : map [string ]any {"cli-proxy" : true },
388+ SafeOutputs : nil ,
389+ }
390+
391+ sections := compiler .collectPromptSections (data )
392+ require .NotEmpty (t , sections , "Should collect sections" )
393+
394+ // Should include cli-proxy prompt
395+ var cliProxySection * PromptSection
396+ for i := range sections {
397+ if sections [i ].IsFile && sections [i ].Content == cliProxyPromptFile {
398+ cliProxySection = & sections [i ]
399+ break
400+ }
401+ }
402+ require .NotNil (t , cliProxySection , "Should include cli_proxy_prompt.md when cli-proxy is enabled" )
403+
404+ // Should NOT include GitHub MCP tools prompt
405+ for _ , section := range sections {
406+ assert .NotEqual (t , githubMCPToolsPromptFile , section .Content ,
407+ "Should not include github_mcp_tools_prompt.md when cli-proxy is enabled" )
408+ assert .NotEqual (t , githubMCPToolsWithSafeOutputsPromptFile , section .Content ,
409+ "Should not include github_mcp_tools_with_safeoutputs_prompt.md when cli-proxy is enabled" )
410+ }
411+ })
412+
413+ t .Run ("cli-proxy enabled with safe-outputs uses cli_proxy_with_safeoutputs_prompt" , func (t * testing.T ) {
414+ compiler := & Compiler {}
415+
416+ data := & WorkflowData {
417+ ParsedTools : NewTools (map [string ]any {"github" : true }),
418+ Features : map [string ]any {"cli-proxy" : true },
419+ SafeOutputs : & SafeOutputsConfig {
420+ MissingData : & MissingDataConfig {},
421+ NoOp : & NoOpConfig {},
422+ },
423+ }
424+
425+ sections := compiler .collectPromptSections (data )
426+ require .NotEmpty (t , sections , "Should collect sections" )
427+
428+ // Should include the with-safeoutputs cli-proxy prompt
429+ var cliProxySection * PromptSection
430+ for i := range sections {
431+ if sections [i ].IsFile && sections [i ].Content == cliProxyWithSafeOutputsPromptFile {
432+ cliProxySection = & sections [i ]
433+ break
434+ }
435+ }
436+ require .NotNil (t , cliProxySection , "Should include cli_proxy_with_safeoutputs_prompt.md when cli-proxy and safe-outputs are both enabled" )
437+
438+ // Should NOT include GitHub MCP tools prompt
439+ for _ , section := range sections {
440+ assert .NotEqual (t , githubMCPToolsPromptFile , section .Content ,
441+ "Should not include github_mcp_tools_prompt.md when cli-proxy is enabled" )
442+ assert .NotEqual (t , githubMCPToolsWithSafeOutputsPromptFile , section .Content ,
443+ "Should not include github_mcp_tools_with_safeoutputs_prompt.md when cli-proxy is enabled" )
444+ }
445+ })
446+
447+ t .Run ("cli-proxy enabled without github tool still adds cli-proxy prompt" , func (t * testing.T ) {
448+ compiler := & Compiler {}
449+
450+ data := & WorkflowData {
451+ ParsedTools : NewTools (map [string ]any {}),
452+ Features : map [string ]any {"cli-proxy" : true },
453+ SafeOutputs : nil ,
454+ }
455+
456+ sections := compiler .collectPromptSections (data )
457+
458+ // Should include cli-proxy prompt even without github tool configured
459+ var cliProxySection * PromptSection
460+ for i := range sections {
461+ if sections [i ].IsFile && sections [i ].Content == cliProxyPromptFile {
462+ cliProxySection = & sections [i ]
463+ break
464+ }
465+ }
466+ require .NotNil (t , cliProxySection , "Should include cli_proxy_prompt.md when cli-proxy is enabled regardless of tools.github" )
467+ })
468+
469+ t .Run ("cli-proxy disabled uses GitHub MCP tools prompt when github tool is enabled" , func (t * testing.T ) {
470+ compiler := & Compiler {}
471+
472+ data := & WorkflowData {
473+ ParsedTools : NewTools (map [string ]any {"github" : true }),
474+ Features : nil ,
475+ SafeOutputs : nil ,
476+ }
477+
478+ sections := compiler .collectPromptSections (data )
479+
480+ // Should include the standard GitHub MCP tools prompt
481+ var githubMCPSection * PromptSection
482+ for i := range sections {
483+ if sections [i ].IsFile && strings .Contains (sections [i ].Content , "github_mcp_tools" ) {
484+ githubMCPSection = & sections [i ]
485+ break
486+ }
487+ }
488+ require .NotNil (t , githubMCPSection , "Should include github_mcp_tools file when cli-proxy is not enabled" )
489+ assert .Equal (t , githubMCPToolsPromptFile , githubMCPSection .Content ,
490+ "Should use the standard github_mcp_tools_prompt when cli-proxy is not enabled" )
491+
492+ // Should NOT include cli-proxy prompt
493+ for _ , section := range sections {
494+ assert .NotEqual (t , cliProxyPromptFile , section .Content ,
495+ "Should not include cli_proxy_prompt.md when cli-proxy is not enabled" )
496+ assert .NotEqual (t , cliProxyWithSafeOutputsPromptFile , section .Content ,
497+ "Should not include cli_proxy_with_safeoutputs_prompt.md when cli-proxy is not enabled" )
498+ }
499+ })
500+ }
0 commit comments