diff --git a/pkg/cli/helpers.go b/pkg/cli/helpers.go index 980a0f812f8..4019067a03a 100644 --- a/pkg/cli/helpers.go +++ b/pkg/cli/helpers.go @@ -4,9 +4,12 @@ import ( "os" "strings" + "github.com/github/gh-aw/pkg/logger" "github.com/github/gh-aw/pkg/parser" ) +var helpersLog = logger.New("cli:helpers") + // getParentDir returns the directory part of a path func getParentDir(path string) string { idx := strings.LastIndex(path, "/") @@ -20,8 +23,10 @@ func getParentDir(path string) string { // and returns the "owner/repo" portion (e.g. "github/gh-aw"). Returns "" if the file // cannot be read, has no source field, or the field is not in the expected format. func readSourceRepoFromFile(path string) string { + helpersLog.Printf("Reading source repo from file: %s", path) content, err := os.ReadFile(path) if err != nil { + helpersLog.Printf("Failed to read file: %s", err) return "" } result, err := parser.ExtractFrontmatterFromContent(string(content)) @@ -41,7 +46,9 @@ func readSourceRepoFromFile(path string) string { if len(slashParts) < 2 { return "" } - return slashParts[0] + "/" + slashParts[1] + repo := slashParts[0] + "/" + slashParts[1] + helpersLog.Printf("Extracted source repo: %s", repo) + return repo } // sourceRepoLabel returns the source repo string for display in error messages. diff --git a/pkg/cli/trial_confirmation.go b/pkg/cli/trial_confirmation.go index d0d84e95750..112860f8da1 100644 --- a/pkg/cli/trial_confirmation.go +++ b/pkg/cli/trial_confirmation.go @@ -7,12 +7,16 @@ import ( "strings" "github.com/github/gh-aw/pkg/console" + "github.com/github/gh-aw/pkg/logger" "github.com/github/gh-aw/pkg/sliceutil" "github.com/github/gh-aw/pkg/workflow" ) +var trialConfirmationLog = logger.New("cli:trial_confirmation") + // showTrialConfirmation displays a confirmation prompt to the user using parsed workflow specs func showTrialConfirmation(parsedSpecs []*WorkflowSpec, logicalRepoSlug, cloneRepoSlug, hostRepoSlug string, deleteHostRepo bool, forceDeleteHostRepo bool, autoMergePRs bool, repeatCount int, directTrialMode bool, engineOverride string) error { + trialConfirmationLog.Printf("Showing trial confirmation: workflows=%d, hostRepo=%s, cloneRepo=%s, repeat=%d, directMode=%v", len(parsedSpecs), hostRepoSlug, cloneRepoSlug, repeatCount, directTrialMode) githubHost := getGitHubHost() hostRepoSlugURL := fmt.Sprintf("%s/%s", githubHost, hostRepoSlug) @@ -109,6 +113,7 @@ func showTrialConfirmation(parsedSpecs []*WorkflowSpec, logicalRepoSlug, cloneRe if err := checkCmd.Run(); err == nil { hostRepoExists = true } + trialConfirmationLog.Printf("Host repo check: exists=%v, forceDelete=%v", hostRepoExists, forceDeleteHostRepo) // Step 1: Repository creation/reuse stepNum := 1 @@ -213,8 +218,10 @@ func showTrialConfirmation(parsedSpecs []*WorkflowSpec, logicalRepoSlug, cloneRe } if !confirmed { + trialConfirmationLog.Print("Trial cancelled by user") return errors.New("trial cancelled by user") } + trialConfirmationLog.Print("Trial confirmed by user, proceeding") return nil } diff --git a/pkg/workflow/compiler_yaml_step_conversion.go b/pkg/workflow/compiler_yaml_step_conversion.go index e075417876f..02860a3236f 100644 --- a/pkg/workflow/compiler_yaml_step_conversion.go +++ b/pkg/workflow/compiler_yaml_step_conversion.go @@ -6,12 +6,16 @@ import ( "strings" "github.com/github/gh-aw/pkg/constants" + "github.com/github/gh-aw/pkg/logger" "github.com/goccy/go-yaml" ) +var stepConversionLog = logger.New("workflow:compiler_yaml_step_conversion") + // ConvertStepToYAML converts a step map to YAML string with proper indentation. // This is a shared utility function used by all engines and the compiler. func ConvertStepToYAML(stepMap map[string]any) (string, error) { + stepConversionLog.Printf("Converting step to YAML: fields=%d", len(stepMap)) // Use OrderMapFields to get ordered MapSlice orderedStep := OrderMapFields(stepMap, constants.PriorityStepFields) @@ -40,6 +44,7 @@ func ConvertStepToYAML(stepMap map[string]any) (string, error) { } } + stepConversionLog.Printf("Step conversion complete: %d lines generated", len(lines)) return result.String(), nil } @@ -95,6 +100,8 @@ func unquoteUsesWithComments(yamlStr string) string { // renderStepFromMap renders a GitHub Actions step from a map to YAML func (c *Compiler) renderStepFromMap(yaml *strings.Builder, step map[string]any, data *WorkflowData, indent string) { + stepName, _ := step["name"].(string) + stepConversionLog.Printf("Rendering step from map: name=%q, fields=%d", stepName, len(step)) // Start the step with a dash yaml.WriteString(indent + "- ") diff --git a/pkg/workflow/playwright_tools.go b/pkg/workflow/playwright_tools.go index a72d765b682..3a5ade8661a 100644 --- a/pkg/workflow/playwright_tools.go +++ b/pkg/workflow/playwright_tools.go @@ -1,5 +1,9 @@ package workflow +import "github.com/github/gh-aw/pkg/logger" + +var playwrightToolsLog = logger.New("workflow:playwright_tools") + // GetPlaywrightTools returns the list of Playwright browser tool names available in the // copilot agent MCP server configuration. // This is a shared function used by all engines for consistent Playwright tool configuration. @@ -33,5 +37,6 @@ func GetPlaywrightTools() []any { for i, tool := range tools { result[i] = tool } + playwrightToolsLog.Printf("Returning %d Playwright tools", len(result)) return result }