Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "/")
Expand All @@ -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)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printf uses %s with err (an error), which will produce a formatting mismatch when debug logging is enabled (e.g. %!s(...)). Use %v (or err.Error() with %s) to match established usage elsewhere (e.g. pkg/workflow/compiler_orchestrator_frontmatter.go:39).

Suggested change
helpersLog.Printf("Failed to read file: %s", err)
helpersLog.Printf("Failed to read file: %v", err)

Copilot uses AI. Check for mistakes.
return ""
}
result, err := parser.ExtractFrontmatterFromContent(string(content))
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions pkg/cli/trial_confirmation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions pkg/workflow/compiler_yaml_step_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 + "- ")

Expand Down
5 changes: 5 additions & 0 deletions pkg/workflow/playwright_tools.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
}
Loading