Skip to content

Commit a647fe3

Browse files
Add debug logging to Copilot engine and include expansion (#12000)
1 parent bda74be commit a647fe3

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

pkg/parser/include_expander.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ func ExpandIncludesWithManifest(content, baseDir string, extractTools bool) (str
7373

7474
// ExpandIncludesForEngines recursively expands @include and @import directives to extract engine configurations
7575
func ExpandIncludesForEngines(content, baseDir string) ([]string, error) {
76+
log.Printf("Expanding includes for engines: baseDir=%s", baseDir)
7677
return expandIncludesForField(content, baseDir, extractEngineFromContent, "")
7778
}
7879

7980
// ExpandIncludesForSafeOutputs recursively expands @include and @import directives to extract safe-outputs configurations
8081
func ExpandIncludesForSafeOutputs(content, baseDir string) ([]string, error) {
82+
log.Printf("Expanding includes for safe-outputs: baseDir=%s", baseDir)
8183
return expandIncludesForField(content, baseDir, extractSafeOutputsFromContent, "{}")
8284
}
8385

@@ -106,6 +108,7 @@ func expandIncludesForField(content, baseDir string, extractFunc func(string) (s
106108
currentContent = processedContent
107109
}
108110

111+
log.Printf("Field expansion complete: results=%d", len(results))
109112
return results, nil
110113
}
111114

pkg/workflow/copilot_engine.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ package workflow
1616

1717
import (
1818
"github.com/githubnext/gh-aw/pkg/constants"
19+
"github.com/githubnext/gh-aw/pkg/logger"
1920
)
2021

22+
var copilotLog = logger.New("workflow:copilot_engine")
23+
2124
const logsFolder = "/tmp/gh-aw/sandbox/agent/logs/"
2225

2326
// CopilotEngine represents the GitHub Copilot CLI agentic engine.
@@ -28,6 +31,7 @@ type CopilotEngine struct {
2831
}
2932

3033
func NewCopilotEngine() *CopilotEngine {
34+
copilotLog.Print("Creating new Copilot engine instance")
3135
return &CopilotEngine{
3236
BaseEngine: BaseEngine{
3337
id: "copilot",
@@ -53,15 +57,18 @@ func (e *CopilotEngine) GetDefaultDetectionModel() string {
5357
// GetRequiredSecretNames returns the list of secrets required by the Copilot engine
5458
// This includes COPILOT_GITHUB_TOKEN and optionally MCP_GATEWAY_API_KEY
5559
func (e *CopilotEngine) GetRequiredSecretNames(workflowData *WorkflowData) []string {
60+
copilotLog.Print("Collecting required secrets for Copilot engine")
5661
secrets := []string{"COPILOT_GITHUB_TOKEN"}
5762

5863
// Add MCP gateway API key if MCP servers are present (gateway is always started with MCP servers)
5964
if HasMCPServers(workflowData) {
65+
copilotLog.Print("Adding MCP_GATEWAY_API_KEY secret")
6066
secrets = append(secrets, "MCP_GATEWAY_API_KEY")
6167
}
6268

6369
// Add GitHub token for GitHub MCP server if present
6470
if hasGitHubTool(workflowData.ParsedTools) {
71+
copilotLog.Print("Adding GITHUB_MCP_SERVER_TOKEN secret")
6572
secrets = append(secrets, "GITHUB_MCP_SERVER_TOKEN")
6673
}
6774

@@ -70,15 +77,22 @@ func (e *CopilotEngine) GetRequiredSecretNames(workflowData *WorkflowData) []str
7077
for varName := range headerSecrets {
7178
secrets = append(secrets, varName)
7279
}
80+
if len(headerSecrets) > 0 {
81+
copilotLog.Printf("Added %d HTTP MCP header secrets", len(headerSecrets))
82+
}
7383

7484
// Add safe-inputs secret names
7585
if IsSafeInputsEnabled(workflowData.SafeInputs, workflowData) {
7686
safeInputsSecrets := collectSafeInputsSecrets(workflowData.SafeInputs)
7787
for varName := range safeInputsSecrets {
7888
secrets = append(secrets, varName)
7989
}
90+
if len(safeInputsSecrets) > 0 {
91+
copilotLog.Printf("Added %d safe-inputs secrets", len(safeInputsSecrets))
92+
}
8093
}
8194

95+
copilotLog.Printf("Total required secrets: %d", len(secrets))
8296
return secrets
8397
}
8498

0 commit comments

Comments
 (0)