@@ -5,13 +5,19 @@ import (
55 "fmt"
66 "strings"
77
8+ "github.com/githubnext/gh-aw/pkg/logger"
89 "github.com/githubnext/gh-aw/pkg/parser"
910)
1011
12+ var importsLog = logger .New ("workflow:imports" )
13+
1114// MergeTools merges two tools maps, combining allowed arrays when keys coincide
1215// Handles newline-separated JSON objects from multiple imports/includes
1316func (c * Compiler ) MergeTools (topTools map [string ]any , includedToolsJSON string ) (map [string ]any , error ) {
17+ importsLog .Print ("Merging tools from imports" )
18+
1419 if includedToolsJSON == "" || includedToolsJSON == "{}" {
20+ importsLog .Print ("No included tools to merge" )
1521 return topTools , nil
1622 }
1723
@@ -22,6 +28,8 @@ func (c *Compiler) MergeTools(topTools map[string]any, includedToolsJSON string)
2228 result = make (map [string ]any )
2329 }
2430
31+ importsLog .Printf ("Processing %d tool definition lines" , len (lines ))
32+
2533 for _ , line := range lines {
2634 line = strings .TrimSpace (line )
2735 if line == "" || line == "{}" {
@@ -47,7 +55,10 @@ func (c *Compiler) MergeTools(topTools map[string]any, includedToolsJSON string)
4755// MergeMCPServers merges mcp-servers from imports with top-level mcp-servers
4856// Takes object maps and merges them directly
4957func (c * Compiler ) MergeMCPServers (topMCPServers map [string ]any , importedMCPServersJSON string ) (map [string ]any , error ) {
58+ importsLog .Print ("Merging MCP servers from imports" )
59+
5060 if importedMCPServersJSON == "" || importedMCPServersJSON == "{}" {
61+ importsLog .Print ("No imported MCP servers to merge" )
5162 return topMCPServers , nil
5263 }
5364
@@ -59,6 +70,7 @@ func (c *Compiler) MergeMCPServers(topMCPServers map[string]any, importedMCPServ
5970
6071 // Split by newlines to handle multiple JSON objects from different imports
6172 lines := strings .Split (importedMCPServersJSON , "\n " )
73+ importsLog .Printf ("Processing %d MCP server definition lines" , len (lines ))
6274
6375 for _ , line := range lines {
6476 line = strings .TrimSpace (line )
@@ -84,8 +96,11 @@ func (c *Compiler) MergeMCPServers(topMCPServers map[string]any, importedMCPServ
8496// MergeNetworkPermissions merges network permissions from imports with top-level network permissions
8597// Combines allowed domains from both sources into a single list
8698func (c * Compiler ) MergeNetworkPermissions (topNetwork * NetworkPermissions , importedNetworkJSON string ) (* NetworkPermissions , error ) {
99+ importsLog .Print ("Merging network permissions from imports" )
100+
87101 // If no imported network config, return top-level network as-is
88102 if importedNetworkJSON == "" || importedNetworkJSON == "{}" {
103+ importsLog .Print ("No imported network permissions to merge" )
89104 return topNetwork , nil
90105 }
91106
@@ -95,6 +110,7 @@ func (c *Compiler) MergeNetworkPermissions(topNetwork *NetworkPermissions, impor
95110 result .Mode = topNetwork .Mode
96111 result .Allowed = make ([]string , len (topNetwork .Allowed ))
97112 copy (result .Allowed , topNetwork .Allowed )
113+ importsLog .Printf ("Starting with %d top-level allowed domains" , len (topNetwork .Allowed ))
98114 }
99115
100116 // Track domains to avoid duplicates
@@ -105,6 +121,7 @@ func (c *Compiler) MergeNetworkPermissions(topNetwork *NetworkPermissions, impor
105121
106122 // Split by newlines to handle multiple JSON objects from different imports
107123 lines := strings .Split (importedNetworkJSON , "\n " )
124+ importsLog .Printf ("Processing %d network permission lines" , len (lines ))
108125
109126 for _ , line := range lines {
110127 line = strings .TrimSpace (line )
0 commit comments